From c9f6a82b619675a4ee1eb4fe9eac57efb69232fe Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 10 May 2018 17:13:52 -0400 Subject: gcc: Factor out "platform flags" --- pkgs/development/compilers/gcc/4.5/default.nix | 18 +----------------- pkgs/development/compilers/gcc/4.8/default.nix | 18 +----------------- pkgs/development/compilers/gcc/4.9/default.nix | 18 +----------------- pkgs/development/compilers/gcc/5/default.nix | 18 +----------------- pkgs/development/compilers/gcc/6/default.nix | 18 +----------------- pkgs/development/compilers/gcc/7/default.nix | 18 +----------------- .../compilers/gcc/common/platform-flags.nix | 12 ++++++++++++ pkgs/development/compilers/gcc/snapshot/default.nix | 18 +----------------- 8 files changed, 19 insertions(+), 119 deletions(-) create mode 100644 pkgs/development/compilers/gcc/common/platform-flags.nix diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix index 8cee08c0926..36b48b88021 100644 --- a/pkgs/development/compilers/gcc/4.5/default.nix +++ b/pkgs/development/compilers/gcc/4.5/default.nix @@ -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"); @@ -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 diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index c798a67de84..dea8b912b27 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -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"; @@ -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" ++ diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index c729bbeb66f..343d820fa23 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -99,22 +99,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"; @@ -380,7 +364,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" ++ diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index f2a091e34dc..0d9565de0a7 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -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"; @@ -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" ++ diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 3de5b4dd270..29f2bad7eac 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -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"; @@ -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" ++ diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 888e455488c..e75e22efce1 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -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"; @@ -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" ++ diff --git a/pkgs/development/compilers/gcc/common/platform-flags.nix b/pkgs/development/compilers/gcc/common/platform-flags.nix new file mode 100644 index 00000000000..71997752ad1 --- /dev/null +++ b/pkgs/development/compilers/gcc/common/platform-flags.nix @@ -0,0 +1,12 @@ +{ lib, targetPlatform }: + +let + p = targetPlatform.platform.gcc or {}; +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 (p ? float) "--with-float=${p.float}") + (lib.optional (p ? mode) "--with-mode=${p.mode}") +] diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix index 3c98b7a58f7..609d418693d 100644 --- a/pkgs/development/compilers/gcc/snapshot/default.nix +++ b/pkgs/development/compilers/gcc/snapshot/default.nix @@ -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"; @@ -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" ++ -- cgit 1.4.1