[RFC] ppc64le enablement (#45340)

* ppc64le enablement

* gcc, glibc: properly handle __float128

* lib/systems, stdenv: syntax cleanup

* gcc7: remove ugly hack

* gcc: add/update __float128 flags

* stdenv: add another pair of quotes for consistency

* gcc: move __float128 flag for ppc64le-glibc into common/platform-flags.nix
This commit is contained in:
CrystalGamma 2018-08-21 21:31:34 +02:00 committed by John Ericson
parent cb44c3ff4c
commit 72d161f548
16 changed files with 87 additions and 23 deletions

View file

@ -44,5 +44,5 @@ in rec {
openbsd = filterDoubles predicates.isOpenBSD; openbsd = filterDoubles predicates.isOpenBSD;
unix = filterDoubles predicates.isUnix; unix = filterDoubles predicates.isUnix;
mesaPlatforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux"]; mesaPlatforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "aarch64-linux" "powerpc64le-linux"];
} }

View file

@ -8,6 +8,14 @@ rec {
# #
# Linux # Linux
# #
powernv = {
config = "powerpc64le-unknown-linux-gnu";
platform = platforms.powernv;
};
musl-power = {
config = "powerpc64le-unknown-linux-musl";
platform = platforms.powernv;
};
sheevaplug = rec { sheevaplug = rec {
config = "armv5tel-unknown-linux-gnueabi"; config = "armv5tel-unknown-linux-gnueabi";

View file

@ -11,6 +11,7 @@ rec {
isi686 = { cpu = cpuTypes.i686; }; isi686 = { cpu = cpuTypes.i686; };
isx86_64 = { cpu = cpuTypes.x86_64; }; isx86_64 = { cpu = cpuTypes.x86_64; };
isPowerPC = { cpu = cpuTypes.powerpc; }; isPowerPC = { cpu = cpuTypes.powerpc; };
isPower = { cpu = { family = "power"; }; };
isx86 = { cpu = { family = "x86"; }; }; isx86 = { cpu = { family = "x86"; }; };
isAarch32 = { cpu = { family = "arm"; bits = 32; }; }; isAarch32 = { cpu = { family = "arm"; bits = 32; }; };
isAarch64 = { cpu = { family = "arm"; bits = 64; }; }; isAarch64 = { cpu = { family = "arm"; bits = 64; }; };

View file

@ -90,6 +90,8 @@ rec {
mips64el = { bits = 64; significantByte = littleEndian; family = "mips"; }; mips64el = { bits = 64; significantByte = littleEndian; family = "mips"; };
powerpc = { bits = 32; significantByte = bigEndian; family = "power"; }; powerpc = { bits = 32; significantByte = bigEndian; family = "power"; };
powerpc64 = { bits = 64; significantByte = bigEndian; family = "power"; };
powerpc64le = { bits = 64; significantByte = littleEndian; family = "power"; };
riscv32 = { bits = 32; significantByte = littleEndian; family = "riscv"; }; riscv32 = { bits = 32; significantByte = littleEndian; family = "riscv"; };
riscv64 = { bits = 64; significantByte = littleEndian; family = "riscv"; }; riscv64 = { bits = 64; significantByte = littleEndian; family = "riscv"; };

View file

@ -20,6 +20,22 @@ rec {
kernelAutoModules = false; kernelAutoModules = false;
}; };
powernv = {
name = "PowerNV";
kernelArch = "powerpc";
kernelBaseConfig = "powernv_defconfig";
kernelTarget = "zImage";
kernelInstallTarget = "install";
kernelFile = "vmlinux";
kernelAutoModules = true;
# avoid driver/FS trouble arising from unusual page size
kernelExtraConfig = ''
PPC_64K_PAGES n
PPC_4K_PAGES y
IPV6 y
'';
};
## ##
## ARM ## ARM
## ##
@ -458,5 +474,6 @@ rec {
"armv7l-linux" = armv7l-hf-multiplatform; "armv7l-linux" = armv7l-hf-multiplatform;
"aarch64-linux" = aarch64-multiplatform; "aarch64-linux" = aarch64-multiplatform;
"mipsel-linux" = fuloong2f_n32; "mipsel-linux" = fuloong2f_n32;
"powerpc64le-linux" = powernv;
}.${system} or pcBase; }.${system} or pcBase;
} }

View file

@ -171,7 +171,7 @@ stdenv.mkDerivation {
else if targetPlatform.isWindows then "pe" else if targetPlatform.isWindows then "pe"
else "elf" + toString targetPlatform.parsed.cpu.bits; else "elf" + toString targetPlatform.parsed.cpu.bits;
endianPrefix = if targetPlatform.isBigEndian then "big" else "little"; endianPrefix = if targetPlatform.isBigEndian then "big" else "little";
sep = optionalString (!targetPlatform.isMips) "-"; sep = optionalString (!targetPlatform.isMips && !targetPlatform.isPower) "-";
arch = arch =
/**/ if targetPlatform.isAarch64 then endianPrefix + "aarch64" /**/ if targetPlatform.isAarch64 then endianPrefix + "aarch64"
else if targetPlatform.isAarch32 then endianPrefix + "arm" else if targetPlatform.isAarch32 then endianPrefix + "arm"
@ -183,7 +183,7 @@ stdenv.mkDerivation {
"mips64" = "btsmip"; "mips64" = "btsmip";
"mips64el" = "ltsmip"; "mips64el" = "ltsmip";
}.${targetPlatform.parsed.cpu.name} }.${targetPlatform.parsed.cpu.name}
else if targetPlatform.isPowerPC then "powerpc" else if targetPlatform.isPower then if targetPlatform.isBigEndian then "ppc" else "lppc"
else if targetPlatform.isSparc then "sparc" else if targetPlatform.isSparc then "sparc"
else throw "unknown emulation for platform: " + targetPlatform.config; else throw "unknown emulation for platform: " + targetPlatform.config;
in targetPlatform.platform.bfdEmulation or (fmt + sep + arch); in targetPlatform.platform.bfdEmulation or (fmt + sep + arch);

View file

@ -54,7 +54,8 @@ let version = "7.3.0";
url = "https://git.busybox.net/buildroot/plain/package/gcc/7.1.0/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02"; url = "https://git.busybox.net/buildroot/plain/package/gcc/7.1.0/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02";
sha256 = "0mrvxsdwip2p3l17dscpc1x8vhdsciqw1z5q9i6p5g9yg1cqnmgs"; sha256 = "0mrvxsdwip2p3l17dscpc1x8vhdsciqw1z5q9i6p5g9yg1cqnmgs";
}) })
++ optional langFortran ../gfortran-driving.patch; ++ optional langFortran ../gfortran-driving.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch;
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";

View file

@ -49,7 +49,8 @@ let version = "8.2.0";
url = "https://git.busybox.net/buildroot/plain/package/gcc/${version}/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02"; url = "https://git.busybox.net/buildroot/plain/package/gcc/${version}/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02";
sha256 = ""; # TODO: uncomment and check hash when available. sha256 = ""; # TODO: uncomment and check hash when available.
}) */ }) */
++ optional langFortran ../gfortran-driving.patch; ++ optional langFortran ../gfortran-driving.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch;
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";

View file

@ -10,4 +10,7 @@ in lib.concatLists [
(lib.optional (p ? fpu) "--with-fpu=${p.fpu}") (lib.optional (p ? fpu) "--with-fpu=${p.fpu}")
(lib.optional (p ? float) "--with-float=${p.float}") (lib.optional (p ? float) "--with-float=${p.float}")
(lib.optional (p ? mode) "--with-mode=${p.mode}") (lib.optional (p ? mode) "--with-mode=${p.mode}")
(lib.optional
(let tp = targetPlatform; in tp.isPower && tp.libc == "glibc" && tp.is64bit && tp.isLittleEndian)
"--with-long-double-128")
] ]

View file

@ -0,0 +1,18 @@
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index cbee89140dd..e1f26b0a096 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -996,13 +996,7 @@ ncrtn.o%s"
{ GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
-#ifdef LOCAL_INCLUDE_DIR
-#define INCLUDE_DEFAULTS_MUSL_LOCAL \
- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
-#else
#define INCLUDE_DEFAULTS_MUSL_LOCAL
-#endif
#ifdef PREFIX_INCLUDE_DIR
#define INCLUDE_DEFAULTS_MUSL_PREFIX \

View file

@ -98,6 +98,7 @@ let
sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g' sed -i "$mf" -e 's|/usr/bin/||g ; s|/bin/||g ; s|/sbin/||g'
done done
sed -i Makefile -e 's|= depmod|= ${buildPackages.kmod}/bin/depmod|' sed -i Makefile -e 's|= depmod|= ${buildPackages.kmod}/bin/depmod|'
sed -i scripts/ld-version.sh -e "s|/usr/bin/awk|${buildPackages.gawk}/bin/awk|"
''; '';
configurePhase = '' configurePhase = ''
@ -145,9 +146,12 @@ let
++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware"; ++ optional installsFirmware "INSTALL_FW_PATH=$(out)/lib/firmware";
# Some image types need special install targets (e.g. uImage is installed with make uinstall) # Some image types need special install targets (e.g. uImage is installed with make uinstall)
installTargets = [ (if platform.kernelTarget == "uImage" then "uinstall" else installTargets = [ (
if platform.kernelTarget == "zImage" || platform.kernelTarget == "Image.gz" then "zinstall" else if platform ? kernelInstallTarget then platform.kernelInstallTarget
"install") ]; else if platform.kernelTarget == "uImage" then "uinstall"
else if platform.kernelTarget == "zImage" || platform.kernelTarget == "Image.gz" then "zinstall"
else "install"
) ];
postInstall = (optionalString installsFirmware '' postInstall = (optionalString installsFirmware ''
mkdir -p $out/lib/firmware mkdir -p $out/lib/firmware

View file

@ -1,4 +1,4 @@
{ stdenv, lib, fetchurl { stdenv, lib, fetchurl, hostPlatform
, linuxHeaders ? null , linuxHeaders ? null
, useBSDCompatHeaders ? true , useBSDCompatHeaders ? true
}: }:
@ -61,11 +61,12 @@ stdenv.mkDerivation rec {
configureFlagsArray+=("--syslibdir=$out/lib") configureFlagsArray+=("--syslibdir=$out/lib")
''; '';
CFLAGS="-fstack-protector-strong" + lib.optionalString hostPlatform.isPower " -mlong-double-64";
configureFlags = [ configureFlags = [
"--enable-shared" "--enable-shared"
"--enable-static" "--enable-static"
"--enable-debug" "--enable-debug"
"CFLAGS=-fstack-protector-strong"
"--enable-wrapper=all" "--enable-wrapper=all"
]; ];

View file

@ -47,6 +47,7 @@ in
"aarch64-linux" = stagesLinux; "aarch64-linux" = stagesLinux;
"mipsel-linux" = stagesLinux; "mipsel-linux" = stagesLinux;
"powerpc-linux" = /* stagesLinux */ stagesNative; "powerpc-linux" = /* stagesLinux */ stagesNative;
"powerpc64le-linux" = stagesLinux;
"x86_64-darwin" = stagesDarwin; "x86_64-darwin" = stagesDarwin;
"x86_64-solaris" = stagesNix; "x86_64-solaris" = stagesNix;
"i686-cygwin" = stagesNative; "i686-cygwin" = stagesNative;

View file

@ -9,6 +9,9 @@ echo Patching the bootstrap tools...
if test -f $out/lib/ld.so.?; then if test -f $out/lib/ld.so.?; then
# MIPS case # MIPS case
LD_BINARY=$out/lib/ld.so.? LD_BINARY=$out/lib/ld.so.?
elif test -f $out/lib/ld64.so.?; then
# ppc64(le)
LD_BINARY=$out/lib/ld64.so.?
else else
# i686, x86_64 and armv5tel # i686, x86_64 and armv5tel
LD_BINARY=$out/lib/ld-*so.? LD_BINARY=$out/lib/ld-*so.?

View file

@ -16,11 +16,13 @@
"armv7l-linux" = import ./bootstrap-files/armv7l.nix; "armv7l-linux" = import ./bootstrap-files/armv7l.nix;
"aarch64-linux" = import ./bootstrap-files/aarch64.nix; "aarch64-linux" = import ./bootstrap-files/aarch64.nix;
"mipsel-linux" = import ./bootstrap-files/loongson2f.nix; "mipsel-linux" = import ./bootstrap-files/loongson2f.nix;
"powerpc64le-linux" = import ./bootstrap-files/ppc64le.nix;
}; };
"musl" = { "musl" = {
"aarch64-linux" = import ./bootstrap-files/aarch64-musl.nix; "aarch64-linux" = import ./bootstrap-files/aarch64-musl.nix;
"armv6l-linux" = import ./bootstrap-files/armv6l-musl.nix; "armv6l-linux" = import ./bootstrap-files/armv6l-musl.nix;
"x86_64-linux" = import ./bootstrap-files/x86_64-musl.nix; "x86_64-linux" = import ./bootstrap-files/x86_64-musl.nix;
"powerpc64le-linux" = import ./bootstrap-files/ppc64le-musl.nix;
}; };
}; };
archLookupTable = table.${localSystem.libc} archLookupTable = table.${localSystem.libc}

View file

@ -5,16 +5,18 @@ let
localSystem = { inherit system; }; localSystem = { inherit system; };
inherit crossSystem; inherit crossSystem;
}; };
lib = import ../../../lib;
in with (import ../../../lib).systems.examples; { in lib.mapAttrs (n: make) (with lib.systems.examples; {
armv5tel = make sheevaplug; armv5tel = sheevaplug;
scaleway = make scaleway-c1; scaleway = scaleway-c1;
pogoplug4 = make pogoplug4; pogoplug4 = pogoplug4;
armv6l = make raspberryPi; armv6l = raspberryPi;
armv7l = make armv7l-hf-multiplatform; armv7l = armv7l-hf-multiplatform;
aarch64 = make aarch64-multiplatform; aarch64 = aarch64-multiplatform;
x86_64-musl = make musl64; x86_64-musl = musl64;
armv6l-musl = make muslpi; armv6l-musl = muslpi;
aarch64-musl = make aarch64-multiplatform-musl; aarch64-musl = aarch64-multiplatform-musl;
riscv64 = make riscv64; riscv64 = riscv64;
} powerpc64le = powernv;
powerpc64le-musl = musl-power;
})