nixpkgs/pkgs/development/compilers/zig/default.nix
William Roe d51340f27f zig: fix build
It looks like https://github.com/NixOS/nixpkgs/pull/88248 broke the
build for zig.

The error you get when building zig on the current master branch is:

```
Scanning dependencies of target zig_build_libstage2
: CommandLine Error: Option 'polly' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
make[2]: *** [CMakeFiles/zig_build_libstage2.dir/build.make:77: CMakeFiles/zig_build_libstage2] Error 1
make[1]: *** [CMakeFiles/Makefile2:252: CMakeFiles/zig_build_libstage2.dir/all] Error 2
make: *** [Makefile:150: all] Error 2
```

The patch that added polly into some build args was likely necessary
only for LLVM 10.0.0 and when that was updated to 10.0.1 it stopped
working or became unnecessary. With this patch removed, zig builds fine
and passes the tests.
2020-08-03 13:17:40 +01:00

44 lines
965 B
Nix

{ stdenv, fetchFromGitHub, cmake, llvmPackages, libxml2, zlib, substituteAll }:
llvmPackages.stdenv.mkDerivation rec {
version = "0.6.0";
pname = "zig";
src = fetchFromGitHub {
owner = "ziglang";
repo = pname;
rev = version;
sha256 = "13dwm2zpscn4n0p5x8ggs9n7mwmq9cgip383i3qqphg7m3pkls8z";
};
nativeBuildInputs = [ cmake ];
buildInputs = [
llvmPackages.clang-unwrapped
llvmPackages.llvm
llvmPackages.lld
libxml2
zlib
];
preBuild = ''
export HOME=$TMPDIR;
'';
checkPhase = ''
runHook preCheck
./zig test $src/test/stage1/behavior.zig
runHook postCheck
'';
doCheck = true;
meta = with stdenv.lib; {
description =
"General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
homepage = "https://ziglang.org/";
license = licenses.mit;
platforms = platforms.unix;
maintainers = [ maintainers.andrewrk ];
};
}