Merge pull request #40306 from obsidiansystems/lib-float

lib: Simplify float handling
This commit is contained in:
John Ericson 2018-05-11 01:22:55 -04:00 committed by GitHub
commit 31e6caabb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 47 additions and 157 deletions

View File

@ -11,21 +11,16 @@ rec {
sheevaplug = rec { sheevaplug = rec {
config = "armv5tel-unknown-linux-gnueabi"; config = "armv5tel-unknown-linux-gnueabi";
float = "soft";
platform = platforms.sheevaplug; platform = platforms.sheevaplug;
}; };
raspberryPi = rec { raspberryPi = rec {
config = "armv6l-unknown-linux-gnueabihf"; config = "armv6l-unknown-linux-gnueabihf";
float = "hard";
fpu = "vfp";
platform = platforms.raspberrypi; platform = platforms.raspberrypi;
}; };
armv7l-hf-multiplatform = rec { armv7l-hf-multiplatform = rec {
config = "armv7a-unknown-linux-gnueabihf"; config = "armv7a-unknown-linux-gnueabihf";
float = "hard";
fpu = "vfpv3-d16";
platform = platforms.armv7l-hf-multiplatform; platform = platforms.armv7l-hf-multiplatform;
}; };
@ -47,26 +42,24 @@ rec {
pogoplug4 = rec { pogoplug4 = rec {
config = "armv5tel-unknown-linux-gnueabi"; config = "armv5tel-unknown-linux-gnueabi";
float = "soft";
platform = platforms.pogoplug4; platform = platforms.pogoplug4;
}; };
ben-nanonote = rec { ben-nanonote = rec {
config = "mipsel-unknown-linux-uclibc"; config = "mipsel-unknown-linux-uclibc";
float = "soft";
platform = { platform = {
name = "ben_nanonote"; name = "ben_nanonote";
kernelMajor = "2.6"; kernelMajor = "2.6";
kernelArch = "mips"; kernelArch = "mips";
gcc = { gcc = {
arch = "mips32"; arch = "mips32";
float = "soft";
}; };
}; };
}; };
fuloongminipc = rec { fuloongminipc = rec {
config = "mipsel-unknown-linux-gnu"; config = "mipsel-unknown-linux-gnu";
float = "hard";
platform = platforms.fuloong2f_n32; platform = platforms.fuloong2f_n32;
}; };

View File

@ -190,9 +190,16 @@ rec {
types.abi = enum (attrValues abis); types.abi = enum (attrValues abis);
abis = setTypes types.openAbi { abis = setTypes types.openAbi {
android = {}; cygnus = {};
cygnus = {}; msvc = {};
gnu = { eabi = {};
androideabi = {};
android = {};
gnueabi = { float = "soft"; };
gnueabihf = { float = "hard"; };
gnu = {
assertions = [ assertions = [
{ assertion = platform: !platform.isAarch32; { assertion = platform: !platform.isAarch32;
message = '' message = ''
@ -201,17 +208,14 @@ rec {
} }
]; ];
}; };
msvc = {};
eabi = {}; musleabi = { float = "soft"; };
androideabi = {}; musleabihf = { float = "hard"; };
gnueabi = {}; musl = {};
gnueabihf = {};
musleabi = {}; uclibceabihf = { float = "soft"; };
musleabihf = {}; uclibceabi = { float = "hard"; };
musl = {}; uclibc = {};
uclibceabihf = {};
uclibceabi = {};
uclibc = {};
unknown = {}; unknown = {};
}; };

View File

@ -25,7 +25,6 @@ rec {
gcc = { gcc = {
arch = "armv5te"; arch = "armv5te";
float = "soft";
}; };
kernelMajor = "2.6"; kernelMajor = "2.6";
@ -158,7 +157,6 @@ rec {
kernelDTB = true; # Beyond 3.10 kernelDTB = true; # Beyond 3.10
gcc = { gcc = {
arch = "armv5te"; arch = "armv5te";
float = "soft";
}; };
}; };
@ -336,7 +334,6 @@ rec {
gcc = { gcc = {
cpu = "cortex-a9"; cpu = "cortex-a9";
fpu = "vfpv3"; fpu = "vfpv3";
float = "hard";
}; };
}; };
@ -363,7 +360,6 @@ rec {
gcc = { gcc = {
cpu = "cortex-a9"; cpu = "cortex-a9";
fpu = "neon"; fpu = "neon";
float = "hard";
}; };
}; };
@ -449,6 +445,7 @@ rec {
kernelTarget = "vmlinux"; kernelTarget = "vmlinux";
gcc = { gcc = {
arch = "loongson2f"; arch = "loongson2f";
float = "hard";
abi = "n32"; abi = "n32";
}; };
}; };
@ -498,7 +495,6 @@ rec {
# and the above page suggests NEON is only an improvement with hand-written assembly. # and the above page suggests NEON is only an improvement with hand-written assembly.
arch = "armv7-a"; arch = "armv7-a";
fpu = "vfpv3-d16"; fpu = "vfpv3-d16";
float = "hard";
# For Raspberry Pi the 2 the best would be: # For Raspberry Pi the 2 the best would be:
# cpu = "cortex-a7"; # cpu = "cortex-a7";

View File

@ -99,22 +99,6 @@ let version = "4.8.5";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */
platformFlags = let
gccArch = targetPlatform.platform.gcc.arch or null;
gccCpu = targetPlatform.platform.gcc.cpu or null;
gccAbi = targetPlatform.platform.gcc.abi or null;
gccFpu = targetPlatform.platform.gcc.fpu or null;
gccFloat = targetPlatform.platform.gcc.float or null;
gccMode = targetPlatform.platform.gcc.mode or null;
in
optional (gccArch != null) "--with-arch=${gccArch}" ++
optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
optional (gccAbi != null) "--with-abi=${gccAbi}" ++
optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
optional (gccFloat != null) "--with-float=${gccFloat}" ++
optional (gccMode != null) "--with-mode=${gccMode}";
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@ -356,7 +340,7 @@ stdenv.mkDerivation ({
optional javaAwtGtk "--enable-java-awt=gtk" ++ optional javaAwtGtk "--enable-java-awt=gtk" ++
optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
platformFlags ++ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++ optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++ optional (!bootstrap) "--disable-bootstrap" ++

View File

@ -104,22 +104,6 @@ let version = "4.9.4";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */
platformFlags = let
gccArch = targetPlatform.platform.gcc.arch or null;
gccCpu = targetPlatform.platform.gcc.cpu or null;
gccAbi = targetPlatform.platform.gcc.abi or null;
gccFpu = targetPlatform.platform.gcc.fpu or null;
gccFloat = targetPlatform.platform.gcc.float or null;
gccMode = targetPlatform.platform.gcc.mode or null;
in
optional (gccArch != null) "--with-arch=${gccArch}" ++
optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
optional (gccAbi != null) "--with-abi=${gccAbi}" ++
optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
optional (gccFloat != null) "--with-float=${gccFloat}" ++
optional (gccMode != null) "--with-mode=${gccMode}";
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@ -378,7 +362,7 @@ stdenv.mkDerivation ({
optional javaAwtGtk "--enable-java-awt=gtk" ++ optional javaAwtGtk "--enable-java-awt=gtk" ++
optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
platformFlags ++ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++ optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++ optional (!bootstrap) "--disable-bootstrap" ++

View File

@ -94,22 +94,6 @@ let version = "5.5.0";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */
platformFlags = let
gccArch = targetPlatform.platform.gcc.arch or null;
gccCpu = targetPlatform.platform.gcc.cpu or null;
gccAbi = targetPlatform.platform.gcc.abi or null;
gccFpu = targetPlatform.platform.gcc.fpu or null;
gccFloat = targetPlatform.platform.gcc.float or null;
gccMode = targetPlatform.platform.gcc.mode or null;
in
optional (gccArch != null) "--with-arch=${gccArch}" ++
optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
optional (gccAbi != null) "--with-abi=${gccAbi}" ++
optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
optional (gccFloat != null) "--with-float=${gccFloat}" ++
optional (gccMode != null) "--with-mode=${gccMode}";
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@ -380,7 +364,7 @@ stdenv.mkDerivation ({
optional javaAwtGtk "--enable-java-awt=gtk" ++ optional javaAwtGtk "--enable-java-awt=gtk" ++
optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
platformFlags ++ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++ optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++ optional (!bootstrap) "--disable-bootstrap" ++

View File

@ -88,22 +88,6 @@ let version = "6.4.0";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */
platformFlags = let
gccArch = targetPlatform.platform.gcc.arch or null;
gccCpu = targetPlatform.platform.gcc.cpu or null;
gccAbi = targetPlatform.platform.gcc.abi or null;
gccFpu = targetPlatform.platform.gcc.fpu or null;
gccFloat = targetPlatform.platform.gcc.float or null;
gccMode = targetPlatform.platform.gcc.mode or null;
in
optional (gccArch != null) "--with-arch=${gccArch}" ++
optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
optional (gccAbi != null) "--with-abi=${gccAbi}" ++
optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
optional (gccFloat != null) "--with-float=${gccFloat}" ++
optional (gccMode != null) "--with-mode=${gccMode}";
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@ -384,7 +368,7 @@ stdenv.mkDerivation ({
optional javaAwtGtk "--enable-java-awt=gtk" ++ optional javaAwtGtk "--enable-java-awt=gtk" ++
optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
platformFlags ++ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++ optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++ optional (!bootstrap) "--disable-bootstrap" ++

View File

@ -93,22 +93,6 @@ let version = "7.3.0";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */
platformFlags = let
gccArch = targetPlatform.platform.gcc.arch or null;
gccCpu = targetPlatform.platform.gcc.cpu or null;
gccAbi = targetPlatform.platform.gcc.abi or null;
gccFpu = targetPlatform.platform.gcc.fpu or null;
gccFloat = targetPlatform.platform.gcc.float or null;
gccMode = targetPlatform.platform.gcc.mode or null;
in
optional (gccArch != null) "--with-arch=${gccArch}" ++
optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
optional (gccAbi != null) "--with-abi=${gccAbi}" ++
optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
optional (gccFloat != null) "--with-float=${gccFloat}" ++
optional (gccMode != null) "--with-mode=${gccMode}";
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@ -389,8 +373,7 @@ stdenv.mkDerivation ({
optional javaAwtGtk "--enable-java-awt=gtk" ++ optional javaAwtGtk "--enable-java-awt=gtk" ++
optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
(import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
platformFlags ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++ optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++ optional (!bootstrap) "--disable-bootstrap" ++

View File

@ -54,22 +54,6 @@ let version = "8.1.0";
}) */ }) */
++ optional langFortran ../gfortran-driving.patch; ++ optional langFortran ../gfortran-driving.patch;
/* Platform flags */
platformFlags = let
gccArch = targetPlatform.platform.gcc.arch or null;
gccCpu = targetPlatform.platform.gcc.cpu or null;
gccAbi = targetPlatform.platform.gcc.abi or null;
gccFpu = targetPlatform.platform.gcc.fpu or null;
gccFloat = targetPlatform.platform.gcc.float or null;
gccMode = targetPlatform.platform.gcc.mode or null;
in
optional (gccArch != null) "--with-arch=${gccArch}" ++
optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
optional (gccAbi != null) "--with-abi=${gccAbi}" ++
optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
optional (gccFloat != null) "--with-float=${gccFloat}" ++
optional (gccMode != null) "--with-mode=${gccMode}";
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@ -331,7 +315,7 @@ stdenv.mkDerivation ({
# Optional features # Optional features
optional (isl != null) "--with-isl=${isl}" ++ optional (isl != null) "--with-isl=${isl}" ++
platformFlags ++ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++ optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++ optional (!bootstrap) "--disable-bootstrap" ++

View File

@ -0,0 +1,13 @@
{ lib, targetPlatform }:
let
p = targetPlatform.platform.gcc or {};
float = p.float or (targetPlatform.parsed.abi.float or null);
in lib.concatLists [
(lib.optional (p ? arch) "--with-arch=${p.arch}")
(lib.optional (p ? cpu) "--with-cpu=${p.cpu}")
(lib.optional (p ? abi) "--with-abi=${p.abi}")
(lib.optional (p ? fpu) "--with-fpu=${p.fpu}")
(lib.optional (float != null) "--with-float=${float}")
(lib.optional (p ? mode) "--with-mode=${p.mode}")
]

View File

@ -86,22 +86,6 @@ let version = "7-20170409";
javaAwtGtk = langJava && x11Support; javaAwtGtk = langJava && x11Support;
/* Platform flags */
platformFlags = let
gccArch = targetPlatform.platform.gcc.arch or null;
gccCpu = targetPlatform.platform.gcc.cpu or null;
gccAbi = targetPlatform.platform.gcc.abi or null;
gccFpu = targetPlatform.platform.gcc.fpu or null;
gccFloat = targetPlatform.platform.gcc.float or null;
gccMode = targetPlatform.platform.gcc.mode or null;
in
optional (gccArch != null) "--with-arch=${gccArch}" ++
optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
optional (gccAbi != null) "--with-abi=${gccAbi}" ++
optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
optional (gccFloat != null) "--with-float=${gccFloat}" ++
optional (gccMode != null) "--with-mode=${gccMode}";
/* Cross-gcc settings (build == host != target) */ /* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@ -352,7 +336,7 @@ stdenv.mkDerivation ({
optional javaAwtGtk "--enable-java-awt=gtk" ++ optional javaAwtGtk "--enable-java-awt=gtk" ++
optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
platformFlags ++ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++ optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++ optional (!bootstrap) "--disable-bootstrap" ++

View File

@ -39,7 +39,6 @@ let
version = "2.27"; version = "2.27";
patchSuffix = ""; patchSuffix = "";
sha256 = "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji"; sha256 = "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji";
cross = if buildPlatform != hostPlatform then hostPlatform else null;
in in
assert withLinuxHeaders -> linuxHeaders != null; assert withLinuxHeaders -> linuxHeaders != null;
@ -49,9 +48,6 @@ stdenv.mkDerivation ({
inherit version installLocales; inherit version installLocales;
linuxHeaders = if withLinuxHeaders then linuxHeaders else null; linuxHeaders = if withLinuxHeaders then linuxHeaders else null;
# The host/target system.
crossConfig = if cross != null then cross.config else null;
inherit (stdenv) is64bit; inherit (stdenv) is64bit;
enableParallelBuilding = true; enableParallelBuilding = true;
@ -123,11 +119,12 @@ stdenv.mkDerivation ({
else "--disable-profile") else "--disable-profile")
] ++ lib.optionals withLinuxHeaders [ ] ++ lib.optionals withLinuxHeaders [
"--enable-kernel=3.2.0" # can't get below with glibc >= 2.26 "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26
] ++ lib.optionals (cross != null) [ ] ++ lib.optionals (hostPlatform != buildPlatform) [
(if cross ? float && cross.float == "soft" then "--without-fp" else "--with-fp") (if hostPlatform.platform.gcc.float or (hostPlatform.parsed.abi.float or "hard") == "soft"
] ++ lib.optionals (cross != null) [ then "--without-fp"
else "--with-fp")
"--with-__thread" "--with-__thread"
] ++ lib.optionals (cross == null && stdenv.isAarch32) [ ] ++ lib.optionals (hostPlatform == buildPlatform && hostPlatform.isAarch32) [
"--host=arm-linux-gnueabi" "--host=arm-linux-gnueabi"
"--build=arm-linux-gnueabi" "--build=arm-linux-gnueabi"
@ -179,7 +176,7 @@ stdenv.mkDerivation ({
} }
'' + lib.optionalString (cross != null) '' '' + lib.optionalString (hostPlatform != buildPlatform) ''
sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig" sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig"
cat > config.cache << "EOF" cat > config.cache << "EOF"
@ -211,7 +208,7 @@ stdenv.mkDerivation ({
} // meta; } // meta;
} }
// lib.optionalAttrs (cross != null) { // lib.optionalAttrs (hostPlatform != buildPlatform) {
preInstall = null; # clobber the native hook preInstall = null; # clobber the native hook
dontStrip = true; dontStrip = true;