Merge pull request #269461 from Artturin/addcrossreplace

config.replaceCrossStdenv: add

authored by Artturin and committed by GitHub 124c8281 f8de5fbf

+40 -37
+40 -37
pkgs/stdenv/cross/default.nix
··· 10 10 crossOverlays = []; 11 11 12 12 # Ignore custom stdenvs when cross compiling for compatibility 13 + # Use replaceCrossStdenv instead. 13 14 config = builtins.removeAttrs config [ "replaceStdenv" ]; 14 15 }; 15 16 ··· 44 45 inherit config; 45 46 overlays = overlays ++ crossOverlays; 46 47 selfBuild = false; 47 - stdenv = adaptStdenv (buildPackages.stdenv.override (old: rec { 48 - buildPlatform = localSystem; 49 - hostPlatform = crossSystem; 50 - targetPlatform = crossSystem; 48 + stdenv = let 49 + baseStdenv = adaptStdenv (buildPackages.stdenv.override (old: rec { 50 + buildPlatform = localSystem; 51 + hostPlatform = crossSystem; 52 + targetPlatform = crossSystem; 51 53 52 - # Prior overrides are surely not valid as packages built with this run on 53 - # a different platform, and so are disabled. 54 - overrides = _: _: {}; 55 - extraBuildInputs = [ ] # Old ones run on wrong platform 56 - ++ lib.optionals hostPlatform.isDarwin [ buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation ] 57 - ; 58 - allowedRequisites = null; 54 + # Prior overrides are surely not valid as packages built with this run on 55 + # a different platform, and so are disabled. 56 + overrides = _: _: {}; 57 + extraBuildInputs = [ ] # Old ones run on wrong platform 58 + ++ lib.optionals hostPlatform.isDarwin [ buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation ] 59 + ; 60 + allowedRequisites = null; 59 61 60 - hasCC = !targetPlatform.isGhcjs; 62 + hasCC = !targetPlatform.isGhcjs; 61 63 62 - cc = if crossSystem.useiOSPrebuilt or false 63 - then buildPackages.darwin.iosSdkPkgs.clang 64 - else if crossSystem.useAndroidPrebuilt or false 65 - then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang 66 - else if targetPlatform.isGhcjs 67 - # Need to use `throw` so tryEval for splicing works, ugh. Using 68 - # `null` or skipping the attribute would cause an eval failure 69 - # `tryEval` wouldn't catch, wrecking accessing previous stages 70 - # when there is a C compiler and everything should be fine. 71 - then throw "no C compiler provided for this platform" 72 - else if crossSystem.isDarwin 73 - then buildPackages.llvmPackages.libcxxClang 74 - else if crossSystem.useLLVM or false 75 - then buildPackages.llvmPackages.clang 76 - else buildPackages.gcc; 64 + cc = if crossSystem.useiOSPrebuilt or false 65 + then buildPackages.darwin.iosSdkPkgs.clang 66 + else if crossSystem.useAndroidPrebuilt or false 67 + then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang 68 + else if targetPlatform.isGhcjs 69 + # Need to use `throw` so tryEval for splicing works, ugh. Using 70 + # `null` or skipping the attribute would cause an eval failure 71 + # `tryEval` wouldn't catch, wrecking accessing previous stages 72 + # when there is a C compiler and everything should be fine. 73 + then throw "no C compiler provided for this platform" 74 + else if crossSystem.isDarwin 75 + then buildPackages.llvmPackages.libcxxClang 76 + else if crossSystem.useLLVM or false 77 + then buildPackages.llvmPackages.clang 78 + else buildPackages.gcc; 77 79 78 - extraNativeBuildInputs = old.extraNativeBuildInputs 79 - ++ lib.optionals 80 - (hostPlatform.isLinux && !buildPlatform.isLinux) 81 - [ buildPackages.patchelf ] 82 - ++ lib.optional 83 - (let f = p: !p.isx86 || builtins.elem p.libc [ "musl" "wasilibc" "relibc" ] || p.isiOS || p.isGenode; 84 - in f hostPlatform && !(f buildPlatform) ) 85 - buildPackages.updateAutotoolsGnuConfigScriptsHook 86 - ; 87 - })); 80 + extraNativeBuildInputs = old.extraNativeBuildInputs 81 + ++ lib.optionals 82 + (hostPlatform.isLinux && !buildPlatform.isLinux) 83 + [ buildPackages.patchelf ] 84 + ++ lib.optional 85 + (let f = p: !p.isx86 || builtins.elem p.libc [ "musl" "wasilibc" "relibc" ] || p.isiOS || p.isGenode; 86 + in f hostPlatform && !(f buildPlatform) ) 87 + buildPackages.updateAutotoolsGnuConfigScriptsHook 88 + ; 89 + })); 90 + in if config ? replaceCrossStdenv then config.replaceCrossStdenv { inherit buildPackages baseStdenv; } else baseStdenv; 88 91 }) 89 92 90 93 ]