Skip to content

Commit

Permalink
zig: 0.10 fix macOS build
Browse files Browse the repository at this point in the history
Relevant upstream issue: ziglang/zig#14559

The patch is a backport of fixes that landed in zig-master and can
be removed with zig-0.11 release.

Additionally, make sure we link statically against LLVM to avoid
unpleasant runtime surprises originating from mixing static and
dynamic LLVM libraries.

Finally, unbreak Zig 0.10.1 on macOS.
  • Loading branch information
kubkon committed Mar 14, 2023
1 parent 35e37ef commit 18c80c1
Show file tree
Hide file tree
Showing 3 changed files with 377 additions and 6 deletions.
13 changes: 9 additions & 4 deletions pkgs/development/compilers/zig/0.10.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ stdenv.mkDerivation rec {
llvm
]);

patches = [
# Backport alignment related panics from zig-master to 0.10.
# Upstream issue: https://github.com/ziglang/zig/issues/14559
./zig_14559.patch
];

preBuild = ''
export HOME=$TMPDIR;
'';
Expand All @@ -49,6 +55,9 @@ stdenv.mkDerivation rec {
# file RPATH_CHANGE could not write new RPATH
"-DCMAKE_SKIP_BUILD_RPATH=ON"

# always link against static build of LLVM
"-DZIG_STATIC_LLVM=ON"

# ensure determinism in the compiler build
"-DZIG_TARGET_MCPU=baseline"
];
Expand All @@ -75,9 +84,5 @@ stdenv.mkDerivation rec {
license = licenses.mit;
maintainers = with maintainers; [ aiotter andrewrk AndersonTorres ];
platforms = platforms.unix;
# Build fails on Darwin on both AArch64 and x86_64:
# https://github.com/NixOS/nixpkgs/pull/210324#issuecomment-1381313616
# https://github.com/NixOS/nixpkgs/pull/210324#issuecomment-1381236045
broken = stdenv.isDarwin;
};
}
Loading

0 comments on commit 18c80c1

Please sign in to comment.