Skip to content

Commit

Permalink
Simplify nix overlay code (#975)
Browse files Browse the repository at this point in the history
This PR cuts out a bunch of Nix code that we seemed to be using only for
historical purposes related to old Nixpkgs bugs and older LLVM versions.
  • Loading branch information
Baltoli authored Feb 7, 2024
1 parent cf3818a commit b6c80c9
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,13 @@ let
llvmPackages =
mkLlvmPackages prev."llvmPackages_${toString prev.llvm-version}";

clang = if !llvmPackages.stdenv.targetPlatform.isDarwin then
llvmPackages.clangNoLibcxx.override (attrs: {
extraBuildCommands = ''
${attrs.extraBuildCommands}
sed -i $out/nix-support/cc-cflags -e '/^-nostdlib/ d'
'';
})
else
# In llvmPackages_15/16, libcxx is broken, so we use clang 14 as our compiler
# for C code etc, but still use LLVM 15 to build the backend properly. This
# is a workaround until the underlying package is more stable on macOS.
let
clangPackages = if prev.llvm-version >= 15 then
mkLlvmPackages prev.llvmPackages_14
else
llvmPackages;
in clangPackages.libcxxClang.overrideAttrs (old: {
# Hack from https://github.com/NixOS/nixpkgs/issues/166205 for macOS
postFixup = old.postFixup + ''
echo "-lc++abi" >> $out/nix-support/libcxx-ldflags
'';
});

jemalloc = prev.jemalloc.overrideDerivation (oldAttrs: rec {
# Some tests for jemalloc fail on the M1! Our tests seem to pass but this may be flaky
doCheck = false;
stdenv = prev.stdenv;
});
clang = llvmPackages.clangNoLibcxx;

llvm-backend = prev.callPackage ./llvm-backend.nix {
inherit (llvmPackages) llvm libllvm libcxxabi;
stdenv = if !llvmPackages.stdenv.targetPlatform.isDarwin then
llvmPackages.stdenv
else
prev.overrideCC llvmPackages.stdenv clang;
stdenv = llvmPackages.stdenv;
cmakeBuildType = prev.llvm-backend-build-type;
src = prev.llvm-backend-src;
inherit jemalloc;
host.clang = clang;
};

Expand Down

0 comments on commit b6c80c9

Please sign in to comment.