ac44b254b4
26b9a2f4a1
changes Zig 0.10 to build the
compiler (notably *not* its outputs, at least not by default) with
its baseline CPU target, but we should ideally do it for both versions
to increase reproducibility, as well as increase the number of users who
are able to use Hydra-provided Zig binaries.
This also adds a comment above the flag in 0.10, to explain why we're adding
the flag, as we do with the RPATH one.
See https://github.com/NixOS/nixpkgs/issues/214356 and https://github.com/NixOS/nixpkgs/issues/185665
for further context.
85 lines
1.9 KiB
Nix
85 lines
1.9 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchFromGitHub
|
|
, cmake
|
|
, llvmPackages
|
|
, libxml2
|
|
, zlib
|
|
}:
|
|
|
|
let
|
|
zig_0_10_0 = fetchFromGitHub {
|
|
owner = "ziglang";
|
|
repo = "zig";
|
|
rev = "0.10.0";
|
|
hash = "sha256-DNs937N7PLQimuM2anya4npYXcj6cyH+dRS7AiOX7tw=";
|
|
};
|
|
in
|
|
stdenv.mkDerivation rec {
|
|
pname = "zig";
|
|
version = "0.9.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "ziglang";
|
|
repo = pname;
|
|
rev = version;
|
|
hash = "sha256-x2c4c9RSrNWGqEngio4ArW7dJjW0gg+8nqBwPcR721k=";
|
|
};
|
|
|
|
patches = [
|
|
# Fix index out of bounds reading RPATH (cherry-picked from 0.10-dev)
|
|
./rpath.patch
|
|
# Fix build on macOS 13 (cherry-picked from 0.10-dev)
|
|
./ventura.patch
|
|
];
|
|
|
|
# TODO: remove on next upgrade
|
|
prePatch = ''
|
|
cp -R ${zig_0_10_0}/lib/libc/include/any-macos.13-any lib/libc/include/any-macos.13-any
|
|
cp -R ${zig_0_10_0}/lib/libc/include/aarch64-macos.13-none lib/libc/include/aarch64-macos.13-gnu
|
|
cp -R ${zig_0_10_0}/lib/libc/include/x86_64-macos.13-none lib/libc/include/x86_64-macos.13-gnu
|
|
cp ${zig_0_10_0}/lib/libc/darwin/libSystem.13.tbd lib/libc/darwin/
|
|
'';
|
|
|
|
nativeBuildInputs = [
|
|
cmake
|
|
llvmPackages.llvm.dev
|
|
];
|
|
|
|
buildInputs = [
|
|
libxml2
|
|
zlib
|
|
] ++ (with llvmPackages; [
|
|
libclang
|
|
lld
|
|
llvm
|
|
]);
|
|
|
|
preBuild = ''
|
|
export HOME=$TMPDIR;
|
|
'';
|
|
|
|
cmakeFlags = [
|
|
# file RPATH_CHANGE could not write new RPATH
|
|
"-DCMAKE_SKIP_BUILD_RPATH=ON"
|
|
|
|
# ensure determinism in the compiler build
|
|
"-DZIG_TARGET_MCPU=baseline"
|
|
];
|
|
|
|
doCheck = true;
|
|
checkPhase = ''
|
|
runHook preCheck
|
|
./zig test --cache-dir "$TMPDIR" -I $src/test $src/test/behavior.zig
|
|
runHook postCheck
|
|
'';
|
|
|
|
meta = with lib; {
|
|
homepage = "https://ziglang.org/";
|
|
description =
|
|
"General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software";
|
|
license = licenses.mit;
|
|
maintainers = with maintainers; [ aiotter andrewrk AndersonTorres ];
|
|
platforms = platforms.unix;
|
|
};
|
|
}
|