Merge pull request #86223 from pikajude/darwin-static-eval
pkgsStatic: use clang for C compiler on Darwin
This commit is contained in:
commit
4aabac8d88
|
@ -15,7 +15,7 @@ rec {
|
||||||
# Used to override packages in stdenv like Make. Should not be used
|
# Used to override packages in stdenv like Make. Should not be used
|
||||||
# for other dependencies.
|
# for other dependencies.
|
||||||
overrideInStdenv = stdenv: pkgs:
|
overrideInStdenv = stdenv: pkgs:
|
||||||
stdenv.override (prev: { allowedRequisites = null; extraBuildInputs = prev.extraBuildInputs or [] ++ pkgs; });
|
stdenv.override (prev: { allowedRequisites = null; extraBuildInputs = (prev.extraBuildInputs or []) ++ pkgs; });
|
||||||
|
|
||||||
|
|
||||||
# Override the setup script of stdenv. Useful for testing new
|
# Override the setup script of stdenv. Useful for testing new
|
||||||
|
@ -34,7 +34,7 @@ rec {
|
||||||
makeStaticBinaries = stdenv:
|
makeStaticBinaries = stdenv:
|
||||||
let stdenv' = if stdenv.hostPlatform.libc != "glibc" then stdenv else
|
let stdenv' = if stdenv.hostPlatform.libc != "glibc" then stdenv else
|
||||||
stdenv.override (prev: {
|
stdenv.override (prev: {
|
||||||
extraBuildInputs = prev.extraBuildInputs or [] ++ [
|
extraBuildInputs = (prev.extraBuildInputs or []) ++ [
|
||||||
stdenv.glibc.static
|
stdenv.glibc.static
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,6 +63,8 @@ in lib.init bootStages ++ [
|
||||||
# `tryEval` wouldn't catch, wrecking accessing previous stages
|
# `tryEval` wouldn't catch, wrecking accessing previous stages
|
||||||
# when there is a C compiler and everything should be fine.
|
# when there is a C compiler and everything should be fine.
|
||||||
then throw "no C compiler provided for this platform"
|
then throw "no C compiler provided for this platform"
|
||||||
|
else if crossSystem.isDarwin
|
||||||
|
then buildPackages.llvmPackages.clang
|
||||||
else if crossSystem.useLLVM or false
|
else if crossSystem.useLLVM or false
|
||||||
then buildPackages.llvmPackages_8.lldClang
|
then buildPackages.llvmPackages_8.lldClang
|
||||||
else buildPackages.gcc;
|
else buildPackages.gcc;
|
||||||
|
|
|
@ -14,15 +14,18 @@ self: super: let
|
||||||
inherit (super.stdenvAdapters) makeStaticBinaries
|
inherit (super.stdenvAdapters) makeStaticBinaries
|
||||||
makeStaticLibraries
|
makeStaticLibraries
|
||||||
propagateBuildInputs;
|
propagateBuildInputs;
|
||||||
inherit (super.lib) foldl optional flip id composeExtensions optionalAttrs;
|
inherit (super.lib) foldl optional flip id composeExtensions optionalAttrs optionalString;
|
||||||
inherit (super) makeSetupHook;
|
inherit (super) makeSetupHook;
|
||||||
|
|
||||||
# Best effort static binaries. Will still be linked to libSystem,
|
# Best effort static binaries. Will still be linked to libSystem,
|
||||||
# but more portable than Nix store binaries.
|
# but more portable than Nix store binaries.
|
||||||
makeStaticDarwin = stdenv: stdenv // {
|
makeStaticDarwin = stdenv_: let stdenv = stdenv_.override {
|
||||||
|
# extraBuildInputs are dropped in cross.nix, but darwin still needs them
|
||||||
|
extraBuildInputs = [ self.buildPackages.darwin.CF ];
|
||||||
|
}; in stdenv // {
|
||||||
mkDerivation = args: stdenv.mkDerivation (args // {
|
mkDerivation = args: stdenv.mkDerivation (args // {
|
||||||
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "")
|
NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "")
|
||||||
+ " -static-libgcc";
|
+ optionalString stdenv.cc.isGNU " -static-libgcc";
|
||||||
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ (makeSetupHook {
|
nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ (makeSetupHook {
|
||||||
substitutions = {
|
substitutions = {
|
||||||
libsystem = "${stdenv.cc.libc}/lib/libSystem.B.dylib";
|
libsystem = "${stdenv.cc.libc}/lib/libSystem.B.dylib";
|
||||||
|
|
Loading…
Reference in New Issue