Merge pull request #269461 from Artturin/addcrossreplace

config.replaceCrossStdenv: add
This commit is contained in:
Artturin 2024-05-03 01:25:05 +03:00 committed by GitHub
commit 124c828155
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,7 @@ let
crossOverlays = []; crossOverlays = [];
# Ignore custom stdenvs when cross compiling for compatibility # Ignore custom stdenvs when cross compiling for compatibility
# Use replaceCrossStdenv instead.
config = builtins.removeAttrs config [ "replaceStdenv" ]; config = builtins.removeAttrs config [ "replaceStdenv" ];
}; };
@ -44,47 +45,49 @@ in lib.init bootStages ++ [
inherit config; inherit config;
overlays = overlays ++ crossOverlays; overlays = overlays ++ crossOverlays;
selfBuild = false; selfBuild = false;
stdenv = adaptStdenv (buildPackages.stdenv.override (old: rec { stdenv = let
buildPlatform = localSystem; baseStdenv = adaptStdenv (buildPackages.stdenv.override (old: rec {
hostPlatform = crossSystem; buildPlatform = localSystem;
targetPlatform = crossSystem; hostPlatform = crossSystem;
targetPlatform = crossSystem;
# Prior overrides are surely not valid as packages built with this run on # Prior overrides are surely not valid as packages built with this run on
# a different platform, and so are disabled. # a different platform, and so are disabled.
overrides = _: _: {}; overrides = _: _: {};
extraBuildInputs = [ ] # Old ones run on wrong platform extraBuildInputs = [ ] # Old ones run on wrong platform
++ lib.optionals hostPlatform.isDarwin [ buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation ] ++ lib.optionals hostPlatform.isDarwin [ buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation ]
; ;
allowedRequisites = null; allowedRequisites = null;
hasCC = !targetPlatform.isGhcjs; hasCC = !targetPlatform.isGhcjs;
cc = if crossSystem.useiOSPrebuilt or false cc = if crossSystem.useiOSPrebuilt or false
then buildPackages.darwin.iosSdkPkgs.clang then buildPackages.darwin.iosSdkPkgs.clang
else if crossSystem.useAndroidPrebuilt or false else if crossSystem.useAndroidPrebuilt or false
then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang
else if targetPlatform.isGhcjs else if targetPlatform.isGhcjs
# Need to use `throw` so tryEval for splicing works, ugh. Using # Need to use `throw` so tryEval for splicing works, ugh. Using
# `null` or skipping the attribute would cause an eval failure # `null` or skipping the attribute would cause an eval failure
# `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 else if crossSystem.isDarwin
then buildPackages.llvmPackages.libcxxClang then buildPackages.llvmPackages.libcxxClang
else if crossSystem.useLLVM or false else if crossSystem.useLLVM or false
then buildPackages.llvmPackages.clang then buildPackages.llvmPackages.clang
else buildPackages.gcc; else buildPackages.gcc;
extraNativeBuildInputs = old.extraNativeBuildInputs extraNativeBuildInputs = old.extraNativeBuildInputs
++ lib.optionals ++ lib.optionals
(hostPlatform.isLinux && !buildPlatform.isLinux) (hostPlatform.isLinux && !buildPlatform.isLinux)
[ buildPackages.patchelf ] [ buildPackages.patchelf ]
++ lib.optional ++ lib.optional
(let f = p: !p.isx86 || builtins.elem p.libc [ "musl" "wasilibc" "relibc" ] || p.isiOS || p.isGenode; (let f = p: !p.isx86 || builtins.elem p.libc [ "musl" "wasilibc" "relibc" ] || p.isiOS || p.isGenode;
in f hostPlatform && !(f buildPlatform) ) in f hostPlatform && !(f buildPlatform) )
buildPackages.updateAutotoolsGnuConfigScriptsHook buildPackages.updateAutotoolsGnuConfigScriptsHook
; ;
})); }));
in if config ? replaceCrossStdenv then config.replaceCrossStdenv { inherit buildPackages baseStdenv; } else baseStdenv;
}) })
] ]