Merge pull request #59897 from matthewbauer/mb-cross-fixes2

Miscellaneous cross compilation fixes
This commit is contained in:
Matthew Bauer 2019-04-20 16:52:26 -04:00 committed by GitHub
commit c351eb2842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 77 additions and 29 deletions

View File

@ -72,16 +72,22 @@ rec {
release = null;
};
kernelArch =
if final.isAarch32 then "arm"
else if final.isAarch64 then "arm64"
else if final.isx86_32 then "x86"
else if final.isx86_64 then "ia64"
else final.parsed.cpu.name;
qemuArch =
if final.isArm then "arm"
else if final.isx86_64 then "x86_64"
else if final.isx86 then "i386"
else {
"powerpc" = "ppc";
"powerpcle" = "ppc";
"powerpc64" = "ppc64";
"powerpc64le" = "ppc64";
"mips64" = "mips";
"mipsel64" = "mipsel";
"powerpc64le" = "ppc64le";
}.${final.parsed.cpu.name} or final.parsed.cpu.name;
emulator = pkgs: let
@ -103,7 +109,7 @@ rec {
in
if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name &&
pkgs.stdenv.hostPlatform.isCompatible final
then "${pkgs.runtimeShell} -c"
then "${pkgs.runtimeShell} -c '\"$@\"' --"
else if final.isWindows
then "${wine}/bin/${wine-name}"
else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux

View File

@ -127,22 +127,42 @@ rec {
(b == i386 && isCompatible a i486)
(b == i486 && isCompatible a i586)
(b == i586 && isCompatible a i686)
# NOTE: Not true in some cases. Like in WSL mode.
# XXX: Not true in some cases. Like in WSL mode.
(b == i686 && isCompatible a x86_64)
# ARM
# ARMv4
(b == arm && isCompatible a armv5tel)
(b == armv5tel && isCompatible a armv6m)
(b == armv6m && isCompatible a armv6l)
(b == armv6l && isCompatible a armv7a)
(b == armv7a && isCompatible a armv7r)
(b == armv7r && isCompatible a armv7m)
(b == armv7m && isCompatible a armv7l)
(b == armv7l && isCompatible a armv8a)
(b == armv8a && isCompatible a armv8r)
(b == armv8r && isCompatible a armv8m)
# NOTE: not always true! Some arm64 cpus dont support arm32 mode.
(b == armv8m && isCompatible a aarch64)
# ARMv5
(b == armv5tel && isCompatible a armv6l)
# ARMv6
(b == armv6l && isCompatible a armv6m)
(b == armv6m && isCompatible a armv7l)
# ARMv7
(b == armv7l && isCompatible a armv7a)
(b == armv7l && isCompatible a armv7r)
(b == armv7l && isCompatible a armv7m)
(b == armv7a && isCompatible a armv8a)
(b == armv7r && isCompatible a armv8a)
(b == armv7m && isCompatible a armv8a)
(b == armv7a && isCompatible a armv8r)
(b == armv7r && isCompatible a armv8r)
(b == armv7m && isCompatible a armv8r)
(b == armv7a && isCompatible a armv8m)
(b == armv7r && isCompatible a armv8m)
(b == armv7m && isCompatible a armv8m)
# ARMv8
(b == armv8r && isCompatible a armv8a)
(b == armv8m && isCompatible a armv8a)
# XXX: not always true! Some arm64 cpus dont support arm32 mode.
(b == aarch64 && a == armv8a)
(b == armv8a && isCompatible a aarch64)
(b == aarch64 && a == aarch64_be)
(b == aarch64_be && isCompatible a aarch64)

View File

@ -31,7 +31,7 @@ in stdenv.mkDerivation rec {
})
];
configurePlatforms = [ "host" "target" ];
configurePlatforms = [ ];
preConfigure = ''
export CXXFLAGS="-fpermissive"
@ -51,7 +51,11 @@ in stdenv.mkDerivation rec {
"--with-intl-api"
"--enable-readline"
"--enable-shared-js"
] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-jemalloc";
] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-jemalloc"
++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"--host=${stdenv.buildPlatform.config}"
"--target=${stdenv.hostPlatform.config}"
];
makeFlags = [
"HOST_CC=${buildPackages.stdenv.cc}/bin/cc"

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, cmake }:
{ lib, stdenv, fetchFromGitHub, cmake, libexecinfo }:
stdenv.mkDerivation rec {
pname = "aws-c-common";
@ -13,6 +13,8 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake ];
buildInputs = lib.optional stdenv.hostPlatform.isMusl libexecinfo;
NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
"-Wno-nullability-extension"
"-Wno-typedef-redefinition"

View File

@ -12,7 +12,7 @@ let
inherit sha256;
};
ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or (throw "missing kernelArch");
ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or stdenvNoCC.hostPlatform.kernelArch;
# It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
# We do this so we have a build->build, not build->host, C compiler.

View File

@ -129,12 +129,12 @@ in stdenv.mkDerivation rec {
test -e $i
substituteInPlace $i \
--replace /usr/bin/getent ${getent}/bin/getent \
--replace /sbin/swapon ${utillinux.bin}/sbin/swapon \
--replace /sbin/swapoff ${utillinux.bin}/sbin/swapoff \
--replace /sbin/fsck ${utillinux.bin}/sbin/fsck \
--replace /sbin/swapon ${lib.getBin utillinux}/sbin/swapon \
--replace /sbin/swapoff ${lib.getBin utillinux}/sbin/swapoff \
--replace /sbin/fsck ${lib.getBin utillinux}/sbin/fsck \
--replace /bin/echo ${coreutils}/bin/echo \
--replace /bin/cat ${coreutils}/bin/cat \
--replace /sbin/sulogin ${utillinux.bin}/sbin/sulogin \
--replace /sbin/sulogin ${lib.getBin utillinux}/sbin/sulogin \
--replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck \
--replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
done

View File

@ -43,8 +43,14 @@ in
"x86_64-linux" = stagesLinux;
"armv5tel-linux" = stagesLinux;
"armv6l-linux" = stagesLinux;
"armv6m-linux" = stagesLinux;
"armv7a-linux" = stagesLinux;
"armv7l-linux" = stagesLinux;
"armv7r-linux" = stagesLinux;
"armv7m-linux" = stagesLinux;
"armv8a-linux" = stagesLinux;
"armv8r-linux" = stagesLinux;
"armv8m-linux" = stagesLinux;
"aarch64-linux" = stagesLinux;
"mipsel-linux" = stagesLinux;
"powerpc-linux" = /* stagesLinux */ stagesNative;

View File

@ -13,7 +13,6 @@
"x86_64-linux" = import ./bootstrap-files/x86_64.nix;
"armv5tel-linux" = import ./bootstrap-files/armv5tel.nix;
"armv6l-linux" = import ./bootstrap-files/armv6l.nix;
"armv7a-linux" = import ./bootstrap-files/armv7l.nix;
"armv7l-linux" = import ./bootstrap-files/armv7l.nix;
"aarch64-linux" = import ./bootstrap-files/aarch64.nix;
"mipsel-linux" = import ./bootstrap-files/loongson2f.nix;
@ -26,10 +25,19 @@
"powerpc64le-linux" = import ./bootstrap-files/ppc64le-musl.nix;
};
};
# Try to find an architecture compatible with our current system. We
# just try every bootstrap weve got and test to see if it is
# compatible with or current architecture.
getCompatibleTools = lib.foldl (v: system:
if v != null then v
else if localSystem.isCompatible (lib.systems.elaborate { inherit system; }) then archLookupTable.${system}
else null) null (lib.attrNames archLookupTable);
archLookupTable = table.${localSystem.libc}
or (abort "unsupported libc for the pure Linux stdenv");
files = archLookupTable.${localSystem.system}
or (abort "unsupported platform for the pure Linux stdenv");
files = archLookupTable.${localSystem.system} or (if getCompatibleTools != null then getCompatibleTools
else (abort "unsupported platform for the pure Linux stdenv"));
in files
}:

View File

@ -72,6 +72,8 @@ in
else overlays homeOverlaysDir
else []
, crossOverlays ? []
, ...
} @ args:
@ -80,7 +82,7 @@ in
assert args ? localSystem -> !(args ? system || args ? platform);
import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
inherit config overlays crossSystem;
inherit config overlays crossSystem crossOverlays;
# Fallback: Assume we are building packages on the current (build, in GNU
# Autotools parlance) system.
localSystem = (if args ? localSystem then {}