2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
|
|
|
, localSystem, crossSystem, config, overlays, crossOverlays ? []
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
bootStages = import ../. {
|
|
|
|
inherit lib localSystem overlays;
|
|
|
|
|
|
|
|
crossSystem = localSystem;
|
|
|
|
crossOverlays = [];
|
|
|
|
|
|
|
|
# Ignore custom stdenvs when cross compiling for compatability
|
|
|
|
config = builtins.removeAttrs config [ "replaceStdenv" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
in lib.init bootStages ++ [
|
|
|
|
|
|
|
|
# Regular native packages
|
|
|
|
(somePrevStage: lib.last bootStages somePrevStage // {
|
|
|
|
# It's OK to change the built-time dependencies
|
|
|
|
allowCustomOverrides = true;
|
|
|
|
})
|
|
|
|
|
|
|
|
# Build tool Packages
|
|
|
|
(vanillaPackages: {
|
|
|
|
inherit config overlays;
|
|
|
|
selfBuild = false;
|
|
|
|
stdenv =
|
|
|
|
assert vanillaPackages.stdenv.buildPlatform == localSystem;
|
|
|
|
assert vanillaPackages.stdenv.hostPlatform == localSystem;
|
|
|
|
assert vanillaPackages.stdenv.targetPlatform == localSystem;
|
|
|
|
vanillaPackages.stdenv.override { targetPlatform = crossSystem; };
|
|
|
|
# It's OK to change the built-time dependencies
|
|
|
|
allowCustomOverrides = true;
|
|
|
|
})
|
|
|
|
|
|
|
|
# Run Packages
|
2021-09-18 10:52:07 +00:00
|
|
|
(buildPackages: let
|
|
|
|
adaptStdenv =
|
|
|
|
if crossSystem.isStatic
|
|
|
|
then buildPackages.stdenvAdapters.makeStatic
|
|
|
|
else lib.id;
|
|
|
|
in {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit config;
|
2021-09-18 10:52:07 +00:00
|
|
|
overlays = overlays ++ crossOverlays;
|
2020-04-24 23:36:52 +00:00
|
|
|
selfBuild = false;
|
2021-09-18 10:52:07 +00:00
|
|
|
stdenv = adaptStdenv (buildPackages.stdenv.override (old: rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
buildPlatform = localSystem;
|
|
|
|
hostPlatform = crossSystem;
|
|
|
|
targetPlatform = crossSystem;
|
|
|
|
|
|
|
|
# Prior overrides are surely not valid as packages built with this run on
|
|
|
|
# a different platform, and so are disabled.
|
|
|
|
overrides = _: _: {};
|
2021-05-28 09:39:13 +00:00
|
|
|
extraBuildInputs = [ ] # Old ones run on wrong platform
|
|
|
|
++ lib.optionals hostPlatform.isDarwin [ buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation ]
|
|
|
|
;
|
2020-04-24 23:36:52 +00:00
|
|
|
allowedRequisites = null;
|
|
|
|
|
|
|
|
hasCC = !targetPlatform.isGhcjs;
|
|
|
|
|
|
|
|
cc = if crossSystem.useiOSPrebuilt or false
|
|
|
|
then buildPackages.darwin.iosSdkPkgs.clang
|
|
|
|
else if crossSystem.useAndroidPrebuilt or false
|
|
|
|
then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang
|
|
|
|
else if targetPlatform.isGhcjs
|
|
|
|
# Need to use `throw` so tryEval for splicing works, ugh. Using
|
|
|
|
# `null` or skipping the attribute would cause an eval failure
|
|
|
|
# `tryEval` wouldn't catch, wrecking accessing previous stages
|
|
|
|
# when there is a C compiler and everything should be fine.
|
|
|
|
then throw "no C compiler provided for this platform"
|
2020-10-07 09:15:18 +00:00
|
|
|
else if crossSystem.isDarwin
|
2022-01-26 04:04:25 +00:00
|
|
|
then buildPackages.llvmPackages.libcxxClang
|
2020-04-24 23:36:52 +00:00
|
|
|
else if crossSystem.useLLVM or false
|
2021-05-28 09:39:13 +00:00
|
|
|
then buildPackages.llvmPackages.clangUseLLVM
|
2020-04-24 23:36:52 +00:00
|
|
|
else buildPackages.gcc;
|
|
|
|
|
|
|
|
extraNativeBuildInputs = old.extraNativeBuildInputs
|
|
|
|
++ lib.optionals
|
|
|
|
(hostPlatform.isLinux && !buildPlatform.isLinux)
|
|
|
|
[ buildPackages.patchelf ]
|
|
|
|
++ lib.optional
|
2020-08-20 17:08:02 +00:00
|
|
|
(let f = p: !p.isx86 || builtins.elem p.libc [ "musl" "wasilibc" "relibc" ] || p.isiOS || p.isGenode;
|
|
|
|
in f hostPlatform && !(f buildPlatform) )
|
2020-04-24 23:36:52 +00:00
|
|
|
buildPackages.updateAutotoolsGnuConfigScriptsHook
|
|
|
|
;
|
2021-09-18 10:52:07 +00:00
|
|
|
}));
|
2020-04-24 23:36:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
]
|