Skip to content

Commit

Permalink
WIP: Add separate Darwin for nixpkgs 24.11
Browse files Browse the repository at this point in the history
  • Loading branch information
tshaynik committed Dec 17, 2024
1 parent aeb209a commit dcba3e0
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions toolchains/cc/cc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,35 @@ let
${darwin.sigtool}/bin/codesign -f -s - "$linkerOutput"
'';
};
darwinCC =
oldDarwinCC =
# Work around https://github.com/NixOS/nixpkgs/issues/42059.
# See also https://github.com/NixOS/nixpkgs/pull/41589.
pkgs.wrapCCWith rec {
cc = stdenv.cc.cc;
bintools = stdenv.cc.bintools.override { inherit postLinkSignHook; };
extraBuildCommands =
with pkgs.darwin.apple_sdk.frameworks;
''
echo "-Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-Wno-elaborated-enum-base" >> $out/nix-support/cc-cflags
echo "-isystem ${pkgs.llvmPackages.libcxx.dev}/include/c++/v1" >> $out/nix-support/cc-cflags
echo "-isystem ${pkgs.llvmPackages.clang-unwrapped.lib}/lib/clang/${cc.version}/include" >> $out/nix-support/cc-cflags
echo "-F${CoreFoundation}/Library/Frameworks" >> $out/nix-support/cc-cflags
echo "-F${CoreServices}/Library/Frameworks" >> $out/nix-support/cc-cflags
echo "-F${Security}/Library/Frameworks" >> $out/nix-support/cc-cflags
echo "-F${Foundation}/Library/Frameworks" >> $out/nix-support/cc-cflags
echo "-F${SystemConfiguration}/Library/Frameworks" >> $out/nix-support/cc-cflags
echo "-L${pkgs.llvmPackages.libcxx}/lib" >> $out/nix-support/cc-cflags
echo "-L${pkgs.libiconv}/lib" >> $out/nix-support/cc-cflags
echo "-L${pkgs.darwin.libobjc}/lib" >> $out/nix-support/cc-cflags
echo "-resource-dir=${pkgs.stdenv.cc}/resource-root" >> $out/nix-support/cc-cflags
''
+ pkgs.lib.optionalString (builtins.hasAttr "libcxxabi" pkgs.llvmPackages) ''
echo "-L${pkgs.llvmPackages.libcxxabi}/lib" >> $out/nix-support/cc-cflags
'';
};
# for nixpkgs 24.11 and later
newDarwinCC =
# Work around https://github.com/NixOS/nixpkgs/issues/42059.
# See also https://github.com/NixOS/nixpkgs/pull/41589.
pkgs.wrapCCWith rec {
Expand Down Expand Up @@ -65,7 +93,12 @@ let
pkgs.buildEnv (
let
cc =
if stdenv.isDarwin && pkgs.lib.versionOlder pkgs.lib.version "24.11" then darwinCC else stdenv.cc;
if !stdenv.isDarwin then
stdenv.cc
else if pkgs.lib.versionOlder pkgs.lib.version "24.11" then
oldDarwinCC
else
newDarwinCC;
in
{
name = "bazel-${cc.name}-wrapper";
Expand Down

0 comments on commit dcba3e0

Please sign in to comment.