From d922302771cff731915866d959d6ae64690f28e4 Mon Sep 17 00:00:00 2001 From: happysalada Date: Tue, 16 May 2023 07:34:12 -0400 Subject: vlang: improve darwin situation --- pkgs/development/compilers/vlang/default.nix | 46 ++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/vlang/default.nix b/pkgs/development/compilers/vlang/default.nix index 81c9f414d8e..c0e6bf1e129 100644 --- a/pkgs/development/compilers/vlang/default.nix +++ b/pkgs/development/compilers/vlang/default.nix @@ -2,12 +2,29 @@ let version = "weekly.2023.19"; + ptraceSubstitution = '' + #include + #include + ''; # Required for bootstrap. - vc = fetchFromGitHub { - owner = "vlang"; - repo = "vc"; - rev = "f7c2b5f2a0738d0d236161c9de9f31dd0280ac86"; - sha256 = "sha256-xU3TvyNgc0o4RCsHtoC6cZTNaue2yuAiolEOvP37TKA="; + vc = stdenv.mkDerivation { + pname = "v.c"; + version = "unstable-2023-05-14"; + src = fetchFromGitHub { + owner = "vlang"; + repo = "vc"; + rev = "f7c2b5f2a0738d0d236161c9de9f31dd0280ac86"; + sha256 = "sha256-xU3TvyNgc0o4RCsHtoC6cZTNaue2yuAiolEOvP37TKA="; + }; + + # patch the ptrace reference for darwin + installPhase = lib.optionalString stdenv.isDarwin '' + substituteInPlace v.c \ + --replace "#include " "${ptraceSubstitution}" + '' + '' + mkdir -p $out + cp v.c $out/ + ''; }; # Required for vdoc. markdown = fetchFromGitHub { @@ -38,11 +55,15 @@ stdenv.mkDerivation { ]; env.VC = vc; - # libX11.dev and xorg.xorgproto are needed because of - # builder error: Header file , needed for module `clipboard.x11` was not found. Please install a package with the X11 development headers, for example: `apt-get install libx11-dev`. - # libXau, libxcb, libXdmcp need to be static if you use static gcc otherwise - # /nix/store/xnk2z26fqy86xahiz3q797dzqx96sidk-glibc-2.37-8/lib/libc.so.6: undefined reference to `_rtld_glob al_ro@GLIBC_PRIVATE' - env.VFLAGS = "-cc ${pkgsStatic.gcc}/bin/gcc -no-retry-compilation -cflags -I${xorg.libX11.dev}/include -cflags -I${xorg.xorgproto}/include -ldflags -L${binaryen}/lib -ldflags -L${pkgsStatic.xorg.libX11}/lib -ldflags -L${pkgsStatic.xorg.libxcb}/lib -ldflags -lxcb -ldflags -L${pkgsStatic.xorg.libXau}/lib -ldflags -lXau -ldflags -L${pkgsStatic.xorg.libXdmcp}/lib -ldflags -lXdmcp"; + env.VFLAGS = if stdenv.isDarwin then + # on darwin we need to add a manual link to libgc since it doesn't have a libgc.a + "-cg -cc ${pkgsStatic.clang}/bin/clang -no-retry-compilation -ldflags -L${pkgsStatic.boehmgc}/lib -ldflags -lgc -ldflags -L${binaryen}/lib" + else + # libX11.dev and xorg.xorgproto are needed because of + # builder error: Header file , needed for module `clipboard.x11` was not found. Please install a package with the X11 development headers, for example: `apt-get install libx11-dev`. + # libXau, libxcb, libXdmcp need to be static if you use static gcc otherwise + # /nix/store/xnk2z26fqy86xahiz3q797dzqx96sidk-glibc-2.37-8/lib/libc.so.6: undefined reference to `_rtld_glob al_ro@GLIBC_PRIVATE' + "-cc ${pkgsStatic.gcc}/bin/gcc -no-retry-compilation -cflags -I${xorg.libX11.dev}/include -cflags -I${xorg.xorgproto}/include -ldflags -L${binaryen}/lib -ldflags -L${pkgsStatic.xorg.libX11}/lib -ldflags -L${pkgsStatic.xorg.libxcb}/lib -ldflags -lxcb -ldflags -L${pkgsStatic.xorg.libXau}/lib -ldflags -lXau -ldflags -L${pkgsStatic.xorg.libXdmcp}/lib -ldflags -lXdmcp"; preBuild = '' export HOME=$(mktemp -d) @@ -51,6 +72,11 @@ stdenv.mkDerivation { # we don't use tcc at all since it fails on a missing libatomic ln -s ${pkgsStatic.tinycc}/bin/tcc ./thirdparty/tcc/tcc.exe cp -r ${pkgsStatic.boehmgc}/lib/* ./thirdparty/tcc/lib + '' + lib.optionalString stdenv.isDarwin '' + # this file isn't used by clang, but it's just to silence a warning + # the compiler complains on an empty file, so this makes it "close" to real + substituteInPlace vlib/builtin/builtin_d_gcboehm.c.v \ + --replace "libgc.a" "libgc.la" ''; # vcreate_test.v requires git, so we must remove it when building the tools. -- cgit 1.4.1