git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #40306 from obsidiansystems/lib-float

lib: Simplify float handling

commit31e6caabb9a2f23dda0f7c30af3673042ed6cc51 authorJohn Ericson <Ericson2314@yahoo.com> dateFri 11 May 2018, 01:22 (9 years ago) parent2dc8831f18ddab
12 files changed+47−157
lib/systems/examples.nix+1−8 lib/systems/parse.nix+18−14 lib/systems/platforms.nix+1−5 pkgs/development/compilers/gcc/4.8/default.nix+1−17 pkgs/development/compilers/gcc/4.9/default.nix+1−17 pkgs/development/compilers/gcc/5/default.nix+1−17 pkgs/development/compilers/gcc/6/default.nix+1−17 pkgs/development/compilers/gcc/7/default.nix+1−18 pkgs/development/compilers/gcc/8/default.nix+1−17 pkgs/development/compilers/gcc/common/platform-flags.nix+13 pkgs/development/compilers/gcc/snapshot/default.nix+1−17 pkgs/development/libraries/glibc/common.nix+7−10
lib/systems/examples.nix+1−8
@@ -11,21 +11,16 @@ rec {
1111
1212 sheevaplug = rec {
1313 config = "armv5tel-unknown-linux-gnueabi";
14− float = "soft";
1514 platform = platforms.sheevaplug;
1615 };
1716
1817 raspberryPi = rec {
1918 config = "armv6l-unknown-linux-gnueabihf";
20− float = "hard";
21− fpu = "vfp";
2219 platform = platforms.raspberrypi;
2320 };
2421
2522 armv7l-hf-multiplatform = rec {
2623 config = "armv7a-unknown-linux-gnueabihf";
27− float = "hard";
28− fpu = "vfpv3-d16";
2924 platform = platforms.armv7l-hf-multiplatform;
3025 };
3126
@@ -47,26 +42,24 @@ rec {
4742
4843 pogoplug4 = rec {
4944 config = "armv5tel-unknown-linux-gnueabi";
50− float = "soft";
5145 platform = platforms.pogoplug4;
5246 };
5347
5448 ben-nanonote = rec {
5549 config = "mipsel-unknown-linux-uclibc";
56− float = "soft";
5750 platform = {
5851 name = "ben_nanonote";
5952 kernelMajor = "2.6";
6053 kernelArch = "mips";
6154 gcc = {
6255 arch = "mips32";
56+ float = "soft";
6357 };
6458 };
6559 };
6660
6761 fuloongminipc = rec {
6862 config = "mipsel-unknown-linux-gnu";
69− float = "hard";
7063 platform = platforms.fuloong2f_n32;
7164 };
7265
lib/systems/parse.nix+18−14
@@ -190,9 +190,16 @@ rec {
190190 types.abi = enum (attrValues abis);
191191
192192 abis = setTypes types.openAbi {
193− android = {};
194− cygnus = {};
195− gnu = {
193+ cygnus = {};
194+ msvc = {};
195+ eabi = {};
196+
197+ androideabi = {};
198+ android = {};
199+
200+ gnueabi = { float = "soft"; };
201+ gnueabihf = { float = "hard"; };
202+ gnu = {
196203 assertions = [
197204 { assertion = platform: !platform.isAarch32;
198205 message = ''
@@ -201,17 +208,14 @@ rec {
201208 }
202209 ];
203210 };
204− msvc = {};
205− eabi = {};
206− androideabi = {};
207− gnueabi = {};
208− gnueabihf = {};
209− musleabi = {};
210− musleabihf = {};
211− musl = {};
212− uclibceabihf = {};
213− uclibceabi = {};
214− uclibc = {};
211+
212+ musleabi = { float = "soft"; };
213+ musleabihf = { float = "hard"; };
214+ musl = {};
215+
216+ uclibceabihf = { float = "soft"; };
217+ uclibceabi = { float = "hard"; };
218+ uclibc = {};
215219
216220 unknown = {};
217221 };
lib/systems/platforms.nix+1−5
@@ -25,7 +25,6 @@ rec {
2525
2626 gcc = {
2727 arch = "armv5te";
28− float = "soft";
2928 };
3029
3130 kernelMajor = "2.6";
@@ -158,7 +157,6 @@ rec {
158157 kernelDTB = true; # Beyond 3.10
159158 gcc = {
160159 arch = "armv5te";
161− float = "soft";
162160 };
163161 };
164162
@@ -336,7 +334,6 @@ rec {
336334 gcc = {
337335 cpu = "cortex-a9";
338336 fpu = "vfpv3";
339− float = "hard";
340337 };
341338 };
342339
@@ -363,7 +360,6 @@ rec {
363360 gcc = {
364361 cpu = "cortex-a9";
365362 fpu = "neon";
366− float = "hard";
367363 };
368364 };
369365
@@ -449,6 +445,7 @@ rec {
449445 kernelTarget = "vmlinux";
450446 gcc = {
451447 arch = "loongson2f";
448+ float = "hard";
452449 abi = "n32";
453450 };
454451 };
@@ -498,7 +495,6 @@ rec {
498495 # and the above page suggests NEON is only an improvement with hand-written assembly.
499496 arch = "armv7-a";
500497 fpu = "vfpv3-d16";
501− float = "hard";
502498
503499 # For Raspberry Pi the 2 the best would be:
504500 # cpu = "cortex-a7";
pkgs/development/compilers/gcc/4.8/default.nix+1−17
@@ -99,22 +99,6 @@ let version = "4.8.5";
9999
100100 javaAwtGtk = langJava && x11Support;
101101
102− /* Platform flags */
103− platformFlags = let
104− gccArch = targetPlatform.platform.gcc.arch or null;
105− gccCpu = targetPlatform.platform.gcc.cpu or null;
106− gccAbi = targetPlatform.platform.gcc.abi or null;
107− gccFpu = targetPlatform.platform.gcc.fpu or null;
108− gccFloat = targetPlatform.platform.gcc.float or null;
109− gccMode = targetPlatform.platform.gcc.mode or null;
110− in
111− optional (gccArch != null) "--with-arch=${gccArch}" ++
112− optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
113− optional (gccAbi != null) "--with-abi=${gccAbi}" ++
114− optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
115− optional (gccFloat != null) "--with-float=${gccFloat}" ++
116− optional (gccMode != null) "--with-mode=${gccMode}";
117−
118102 /* Cross-gcc settings (build == host != target) */
119103 crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
120104 crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@@ -356,7 +340,7 @@ stdenv.mkDerivation ({
356340 optional javaAwtGtk "--enable-java-awt=gtk" ++
357341 optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
358342
359− platformFlags ++
343+ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
360344 optional (targetPlatform != hostPlatform) crossConfigureFlags ++
361345 optional (!bootstrap) "--disable-bootstrap" ++
362346
pkgs/development/compilers/gcc/4.9/default.nix+1−17
@@ -104,22 +104,6 @@ let version = "4.9.4";
104104
105105 javaAwtGtk = langJava && x11Support;
106106
107− /* Platform flags */
108− platformFlags = let
109− gccArch = targetPlatform.platform.gcc.arch or null;
110− gccCpu = targetPlatform.platform.gcc.cpu or null;
111− gccAbi = targetPlatform.platform.gcc.abi or null;
112− gccFpu = targetPlatform.platform.gcc.fpu or null;
113− gccFloat = targetPlatform.platform.gcc.float or null;
114− gccMode = targetPlatform.platform.gcc.mode or null;
115− in
116− optional (gccArch != null) "--with-arch=${gccArch}" ++
117− optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
118− optional (gccAbi != null) "--with-abi=${gccAbi}" ++
119− optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
120− optional (gccFloat != null) "--with-float=${gccFloat}" ++
121− optional (gccMode != null) "--with-mode=${gccMode}";
122−
123107 /* Cross-gcc settings (build == host != target) */
124108 crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
125109 crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@@ -378,7 +362,7 @@ stdenv.mkDerivation ({
378362 optional javaAwtGtk "--enable-java-awt=gtk" ++
379363 optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
380364
381− platformFlags ++
365+ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
382366 optional (targetPlatform != hostPlatform) crossConfigureFlags ++
383367 optional (!bootstrap) "--disable-bootstrap" ++
384368
pkgs/development/compilers/gcc/5/default.nix+1−17
@@ -94,22 +94,6 @@ let version = "5.5.0";
9494
9595 javaAwtGtk = langJava && x11Support;
9696
97− /* Platform flags */
98− platformFlags = let
99− gccArch = targetPlatform.platform.gcc.arch or null;
100− gccCpu = targetPlatform.platform.gcc.cpu or null;
101− gccAbi = targetPlatform.platform.gcc.abi or null;
102− gccFpu = targetPlatform.platform.gcc.fpu or null;
103− gccFloat = targetPlatform.platform.gcc.float or null;
104− gccMode = targetPlatform.platform.gcc.mode or null;
105− in
106− optional (gccArch != null) "--with-arch=${gccArch}" ++
107− optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
108− optional (gccAbi != null) "--with-abi=${gccAbi}" ++
109− optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
110− optional (gccFloat != null) "--with-float=${gccFloat}" ++
111− optional (gccMode != null) "--with-mode=${gccMode}";
112−
11397 /* Cross-gcc settings (build == host != target) */
11498 crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
11599 crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@@ -380,7 +364,7 @@ stdenv.mkDerivation ({
380364 optional javaAwtGtk "--enable-java-awt=gtk" ++
381365 optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
382366
383− platformFlags ++
367+ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
384368 optional (targetPlatform != hostPlatform) crossConfigureFlags ++
385369 optional (!bootstrap) "--disable-bootstrap" ++
386370
pkgs/development/compilers/gcc/6/default.nix+1−17
@@ -88,22 +88,6 @@ let version = "6.4.0";
8888
8989 javaAwtGtk = langJava && x11Support;
9090
91− /* Platform flags */
92− platformFlags = let
93− gccArch = targetPlatform.platform.gcc.arch or null;
94− gccCpu = targetPlatform.platform.gcc.cpu or null;
95− gccAbi = targetPlatform.platform.gcc.abi or null;
96− gccFpu = targetPlatform.platform.gcc.fpu or null;
97− gccFloat = targetPlatform.platform.gcc.float or null;
98− gccMode = targetPlatform.platform.gcc.mode or null;
99− in
100− optional (gccArch != null) "--with-arch=${gccArch}" ++
101− optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
102− optional (gccAbi != null) "--with-abi=${gccAbi}" ++
103− optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
104− optional (gccFloat != null) "--with-float=${gccFloat}" ++
105− optional (gccMode != null) "--with-mode=${gccMode}";
106−
10791 /* Cross-gcc settings (build == host != target) */
10892 crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
10993 crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@@ -384,7 +368,7 @@ stdenv.mkDerivation ({
384368 optional javaAwtGtk "--enable-java-awt=gtk" ++
385369 optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
386370
387− platformFlags ++
371+ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
388372 optional (targetPlatform != hostPlatform) crossConfigureFlags ++
389373 optional (!bootstrap) "--disable-bootstrap" ++
390374
pkgs/development/compilers/gcc/7/default.nix+1−18
@@ -93,22 +93,6 @@ let version = "7.3.0";
9393
9494 javaAwtGtk = langJava && x11Support;
9595
96− /* Platform flags */
97− platformFlags = let
98− gccArch = targetPlatform.platform.gcc.arch or null;
99− gccCpu = targetPlatform.platform.gcc.cpu or null;
100− gccAbi = targetPlatform.platform.gcc.abi or null;
101− gccFpu = targetPlatform.platform.gcc.fpu or null;
102− gccFloat = targetPlatform.platform.gcc.float or null;
103− gccMode = targetPlatform.platform.gcc.mode or null;
104− in
105− optional (gccArch != null) "--with-arch=${gccArch}" ++
106− optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
107− optional (gccAbi != null) "--with-abi=${gccAbi}" ++
108− optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
109− optional (gccFloat != null) "--with-float=${gccFloat}" ++
110− optional (gccMode != null) "--with-mode=${gccMode}";
111−
11296 /* Cross-gcc settings (build == host != target) */
11397 crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
11498 crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@@ -389,8 +373,7 @@ stdenv.mkDerivation ({
389373 optional javaAwtGtk "--enable-java-awt=gtk" ++
390374 optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
391375
392−
393− platformFlags ++
376+ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
394377 optional (targetPlatform != hostPlatform) crossConfigureFlags ++
395378 optional (!bootstrap) "--disable-bootstrap" ++
396379
pkgs/development/compilers/gcc/8/default.nix+1−17
@@ -54,22 +54,6 @@ let version = "8.1.0";
5454 }) */
5555 ++ optional langFortran ../gfortran-driving.patch;
5656
57− /* Platform flags */
58− platformFlags = let
59− gccArch = targetPlatform.platform.gcc.arch or null;
60− gccCpu = targetPlatform.platform.gcc.cpu or null;
61− gccAbi = targetPlatform.platform.gcc.abi or null;
62− gccFpu = targetPlatform.platform.gcc.fpu or null;
63− gccFloat = targetPlatform.platform.gcc.float or null;
64− gccMode = targetPlatform.platform.gcc.mode or null;
65− in
66− optional (gccArch != null) "--with-arch=${gccArch}" ++
67− optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
68− optional (gccAbi != null) "--with-abi=${gccAbi}" ++
69− optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
70− optional (gccFloat != null) "--with-float=${gccFloat}" ++
71− optional (gccMode != null) "--with-mode=${gccMode}";
72−
7357 /* Cross-gcc settings (build == host != target) */
7458 crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
7559 crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@@ -331,7 +315,7 @@ stdenv.mkDerivation ({
331315 # Optional features
332316 optional (isl != null) "--with-isl=${isl}" ++
333317
334− platformFlags ++
318+ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
335319 optional (targetPlatform != hostPlatform) crossConfigureFlags ++
336320 optional (!bootstrap) "--disable-bootstrap" ++
337321
pkgs/development/compilers/gcc/common/platform-flags.nixnew file+13
@@ -0,0 +1,13 @@
1+{ lib, targetPlatform }:
2+
3+let
4+ p = targetPlatform.platform.gcc or {};
5+ float = p.float or (targetPlatform.parsed.abi.float or null);
6+in lib.concatLists [
7+ (lib.optional (p ? arch) "--with-arch=${p.arch}")
8+ (lib.optional (p ? cpu) "--with-cpu=${p.cpu}")
9+ (lib.optional (p ? abi) "--with-abi=${p.abi}")
10+ (lib.optional (p ? fpu) "--with-fpu=${p.fpu}")
11+ (lib.optional (float != null) "--with-float=${float}")
12+ (lib.optional (p ? mode) "--with-mode=${p.mode}")
13+]
pkgs/development/compilers/gcc/snapshot/default.nix+1−17
@@ -86,22 +86,6 @@ let version = "7-20170409";
8686
8787 javaAwtGtk = langJava && x11Support;
8888
89− /* Platform flags */
90− platformFlags = let
91− gccArch = targetPlatform.platform.gcc.arch or null;
92− gccCpu = targetPlatform.platform.gcc.cpu or null;
93− gccAbi = targetPlatform.platform.gcc.abi or null;
94− gccFpu = targetPlatform.platform.gcc.fpu or null;
95− gccFloat = targetPlatform.platform.gcc.float or null;
96− gccMode = targetPlatform.platform.gcc.mode or null;
97− in
98− optional (gccArch != null) "--with-arch=${gccArch}" ++
99− optional (gccCpu != null) "--with-cpu=${gccCpu}" ++
100− optional (gccAbi != null) "--with-abi=${gccAbi}" ++
101− optional (gccFpu != null) "--with-fpu=${gccFpu}" ++
102− optional (gccFloat != null) "--with-float=${gccFloat}" ++
103− optional (gccMode != null) "--with-mode=${gccMode}";
104−
10589 /* Cross-gcc settings (build == host != target) */
10690 crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
10791 crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
@@ -352,7 +336,7 @@ stdenv.mkDerivation ({
352336 optional javaAwtGtk "--enable-java-awt=gtk" ++
353337 optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++
354338
355− platformFlags ++
339+ (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
356340 optional (targetPlatform != hostPlatform) crossConfigureFlags ++
357341 optional (!bootstrap) "--disable-bootstrap" ++
358342
pkgs/development/libraries/glibc/common.nix+7−10
@@ -39,7 +39,6 @@ let
3939 version = "2.27";
4040 patchSuffix = "";
4141 sha256 = "0wpwq7gsm7sd6ysidv0z575ckqdg13cr2njyfgrbgh4f65adwwji";
42− cross = if buildPlatform != hostPlatform then hostPlatform else null;
4342in
4443
4544assert withLinuxHeaders -> linuxHeaders != null;
@@ -49,9 +48,6 @@ stdenv.mkDerivation ({
4948 inherit version installLocales;
5049 linuxHeaders = if withLinuxHeaders then linuxHeaders else null;
5150
52− # The host/target system.
53− crossConfig = if cross != null then cross.config else null;
54−
5551 inherit (stdenv) is64bit;
5652
5753 enableParallelBuilding = true;
@@ -123,11 +119,12 @@ stdenv.mkDerivation ({
123119 else "--disable-profile")
124120 ] ++ lib.optionals withLinuxHeaders [
125121 "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26
126− ] ++ lib.optionals (cross != null) [
127− (if cross ? float && cross.float == "soft" then "--without-fp" else "--with-fp")
128− ] ++ lib.optionals (cross != null) [
122+ ] ++ lib.optionals (hostPlatform != buildPlatform) [
123+ (if hostPlatform.platform.gcc.float or (hostPlatform.parsed.abi.float or "hard") == "soft"
124+ then "--without-fp"
125+ else "--with-fp")
129126 "--with-__thread"
130− ] ++ lib.optionals (cross == null && stdenv.isAarch32) [
127+ ] ++ lib.optionals (hostPlatform == buildPlatform && hostPlatform.isAarch32) [
131128 "--host=arm-linux-gnueabi"
132129 "--build=arm-linux-gnueabi"
133130
@@ -179,7 +176,7 @@ stdenv.mkDerivation ({
179176 }
180177
181178
182− '' + lib.optionalString (cross != null) ''
179+ '' + lib.optionalString (hostPlatform != buildPlatform) ''
183180 sed -i s/-lgcc_eh//g "../$sourceRoot/Makeconfig"
184181
185182 cat > config.cache << "EOF"
@@ -211,7 +208,7 @@ stdenv.mkDerivation ({
211208 } // meta;
212209}
213210
214−// lib.optionalAttrs (cross != null) {
211+// lib.optionalAttrs (hostPlatform != buildPlatform) {
215212 preInstall = null; # clobber the native hook
216213
217214 dontStrip = true;