Skip to content

Commit

Permalink
Merge pull request #40307 from obsidiansystems/lib-float-for-18.03
Browse files Browse the repository at this point in the history
lib: Simplify float handling
  • Loading branch information
Ericson2314 committed May 11, 2018
2 parents b1a9f68 + e988144 commit ad1af29
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 166 deletions.
9 changes: 1 addition & 8 deletions lib/systems/examples.nix
Expand Up @@ -11,21 +11,16 @@ rec {

sheevaplug = rec {
config = "armv5tel-unknown-linux-gnueabi";
float = "soft";
platform = platforms.sheevaplug;
};

raspberryPi = rec {
config = "armv6l-unknown-linux-gnueabihf";
float = "hard";
fpu = "vfp";
platform = platforms.raspberrypi;
};

armv7l-hf-multiplatform = rec {
config = "armv7a-unknown-linux-gnueabihf";
float = "hard";
fpu = "vfpv3-d16";
platform = platforms.armv7l-hf-multiplatform;
};

Expand All @@ -47,26 +42,24 @@ rec {

pogoplug4 = rec {
config = "armv5tel-unknown-linux-gnueabi";
float = "soft";
platform = platforms.pogoplug4;
};

ben-nanonote = rec {
config = "mipsel-unknown-linux-uclibc";
float = "soft";
platform = {
name = "ben_nanonote";
kernelMajor = "2.6";
kernelArch = "mips";
gcc = {
arch = "mips32";
float = "soft";
};
};
};

fuloongminipc = rec {
config = "mipsel-unknown-linux-gnu";
float = "hard";
platform = platforms.fuloong2f_n32;
};

Expand Down
32 changes: 18 additions & 14 deletions lib/systems/parse.nix
Expand Up @@ -182,20 +182,24 @@ rec {
types.abi = enum (attrValues abis);

abis = setTypes types.openAbi {
android = {};
cygnus = {};
gnu = {};
msvc = {};
eabi = {};
androideabi = {};
gnueabi = {};
gnueabihf = {};
musleabi = {};
musleabihf = {};
musl = {};
uclibceabihf = {};
uclibceabi = {};
uclibc = {};
cygnus = {};
msvc = {};
eabi = {};

androideabi = {};
android = {};

gnueabi = { float = "soft"; };
gnueabihf = { float = "hard"; };
gnu = {};

musleabi = { float = "soft"; };
musleabihf = { float = "hard"; };
musl = {};

uclibceabihf = { float = "soft"; };
uclibceabi = { float = "hard"; };
uclibc = {};

unknown = {};
};
Expand Down
6 changes: 1 addition & 5 deletions lib/systems/platforms.nix
Expand Up @@ -25,7 +25,6 @@ rec {

gcc = {
arch = "armv5te";
float = "soft";
};

kernelMajor = "2.6";
Expand Down Expand Up @@ -158,7 +157,6 @@ rec {
kernelDTB = true; # Beyond 3.10
gcc = {
arch = "armv5te";
float = "soft";
};
};

Expand Down Expand Up @@ -336,7 +334,6 @@ rec {
gcc = {
cpu = "cortex-a9";
fpu = "vfpv3";
float = "hard";
};
};

Expand All @@ -363,7 +360,6 @@ rec {
gcc = {
cpu = "cortex-a9";
fpu = "neon";
float = "hard";
};
};

Expand Down Expand Up @@ -449,6 +445,7 @@ rec {
kernelTarget = "vmlinux";
gcc = {
arch = "loongson2f";
float = "hard";
abi = "n32";
};
};
Expand Down Expand Up @@ -498,7 +495,6 @@ rec {
# and the above page suggests NEON is only an improvement with hand-written assembly.
arch = "armv7-a";
fpu = "vfpv3-d16";
float = "hard";

# For Raspberry Pi the 2 the best would be:
# cpu = "cortex-a7";
Expand Down
18 changes: 1 addition & 17 deletions pkgs/development/compilers/gcc/4.5/default.nix
Expand Up @@ -64,22 +64,6 @@ let version = "4.5.4";

javaAwtGtk = langJava && gtk2 != null;

/* 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 */
crossMingw = (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt");

Expand Down Expand Up @@ -312,7 +296,7 @@ stdenv.mkDerivation ({
# Ada
optional langAda "--enable-libada" ++

platformFlags ++
(import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++

# Platform-specific flags
Expand Down
18 changes: 1 addition & 17 deletions pkgs/development/compilers/gcc/4.8/default.nix
Expand Up @@ -108,22 +108,6 @@ let version = "4.8.5";

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) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
Expand Down Expand Up @@ -372,7 +356,7 @@ stdenv.mkDerivation ({
# Ada
optional langAda "--enable-libada" ++

platformFlags ++
(import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++

Expand Down
18 changes: 1 addition & 17 deletions pkgs/development/compilers/gcc/4.9/default.nix
Expand Up @@ -113,22 +113,6 @@ let version = "4.9.4";

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) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
Expand Down Expand Up @@ -394,7 +378,7 @@ stdenv.mkDerivation ({
# Ada
optional langAda "--enable-libada" ++

platformFlags ++
(import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++

Expand Down
18 changes: 1 addition & 17 deletions pkgs/development/compilers/gcc/5/default.nix
Expand Up @@ -103,22 +103,6 @@ let version = "5.5.0";

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) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
Expand Down Expand Up @@ -396,7 +380,7 @@ stdenv.mkDerivation ({
# Ada
optional langAda "--enable-libada" ++

platformFlags ++
(import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++

Expand Down
18 changes: 1 addition & 17 deletions pkgs/development/compilers/gcc/6/default.nix
Expand Up @@ -97,22 +97,6 @@ let version = "6.4.0";

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) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
Expand Down Expand Up @@ -400,7 +384,7 @@ stdenv.mkDerivation ({
# Ada
optional langAda "--enable-libada" ++

platformFlags ++
(import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++

Expand Down
18 changes: 1 addition & 17 deletions pkgs/development/compilers/gcc/7/default.nix
Expand Up @@ -98,22 +98,6 @@ let version = "7.3.0";

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) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
Expand Down Expand Up @@ -396,7 +380,7 @@ stdenv.mkDerivation ({
# Ada
optional langAda "--enable-libada" ++

platformFlags ++
(import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++

Expand Down
13 changes: 13 additions & 0 deletions pkgs/development/compilers/gcc/common/platform-flags.nix
@@ -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}")
]
18 changes: 1 addition & 17 deletions pkgs/development/compilers/gcc/snapshot/default.nix
Expand Up @@ -95,22 +95,6 @@ let version = "7-20170409";

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) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
Expand Down Expand Up @@ -368,7 +352,7 @@ stdenv.mkDerivation ({
# Ada
optional langAda "--enable-libada" ++

platformFlags ++
(import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++
optional (targetPlatform != hostPlatform) crossConfigureFlags ++
optional (!bootstrap) "--disable-bootstrap" ++

Expand Down

1 comment on commit ad1af29

@dezgeg
Copy link
Contributor

@dezgeg dezgeg commented on ad1af29 May 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sort of refactoring doesn't belong to a stable branch.

Please sign in to comment.