From 999ef20129cf0c4809a3d654f2378192f6b32ef1 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 11 Nov 2019 00:08:45 -0500 Subject: mingw-w64 libc: Multiple outputs and parallel builds Also deduplicate more of the GCC derivations. --- pkgs/development/compilers/gcc/4.8/default.nix | 25 ++++++------------- pkgs/development/compilers/gcc/4.9/default.nix | 25 ++++++------------- pkgs/development/compilers/gcc/5/default.nix | 25 ++++++------------- pkgs/development/compilers/gcc/6/default.nix | 25 ++++++------------- pkgs/development/compilers/gcc/7/default.nix | 25 ++++++------------- pkgs/development/compilers/gcc/8/default.nix | 25 ++++++------------- pkgs/development/compilers/gcc/9/default.nix | 25 ++++++------------- .../compilers/gcc/common/configure-flags.nix | 2 +- .../compilers/gcc/common/extra-target-flags.nix | 28 ++++++++++++++++++++++ .../development/compilers/gcc/snapshot/default.nix | 25 ++++++------------- pkgs/os-specific/windows/mingw-w64/default.nix | 4 ++++ 11 files changed, 89 insertions(+), 145 deletions(-) create mode 100644 pkgs/development/compilers/gcc/common/extra-target-flags.nix diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 324599e49821d..e8892e17b711f 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -251,24 +251,13 @@ stdenv.mkDerivation ({ ++ optionals javaAwtGtk [ gmp mpfr ] )); - EXTRA_TARGET_FLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" - ] ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ]); - - EXTRA_TARGET_LDFLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" - ] ++ (if crossStageStatic then [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ] else [ - "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" - "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" - ])); + inherit + (import ../common/extra-target-flags.nix { + inherit stdenv crossStageStatic libcCross; + }) + EXTRA_TARGET_FLAGS + EXTRA_TARGET_LDFLAGS + ; passthru = { inherit langC langCC langObjC langObjCpp langFortran langGo version; diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index 9d4d8a9b6ac28..4f6d32b33174d 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -257,24 +257,13 @@ stdenv.mkDerivation ({ ++ optionals javaAwtGtk [ gmp mpfr ] )); - EXTRA_TARGET_FLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" - ] ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ]); - - EXTRA_TARGET_LDFLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" - ] ++ (if crossStageStatic then [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ] else [ - "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" - "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" - ])); + inherit + (import ../common/extra-target-flags.nix { + inherit stdenv crossStageStatic libcCross; + }) + EXTRA_TARGET_FLAGS + EXTRA_TARGET_LDFLAGS + ; passthru = { inherit langC langCC langObjC langObjCpp langFortran langGo version; diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index d809c6c4e3648..3c8cdde810360 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -264,24 +264,13 @@ stdenv.mkDerivation ({ ++ optionals javaAwtGtk [ gmp mpfr ] )); - EXTRA_TARGET_FLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" - ] ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ]); - - EXTRA_TARGET_LDFLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" - ] ++ (if crossStageStatic then [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ] else [ - "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" - "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" - ])); + inherit + (import ../common/extra-target-flags.nix { + inherit stdenv crossStageStatic libcCross; + }) + EXTRA_TARGET_FLAGS + EXTRA_TARGET_LDFLAGS + ; passthru = { inherit langC langCC langObjC langObjCpp langFortran langGo version; diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 1eec43cb320a1..82cec33756d8a 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -266,24 +266,13 @@ stdenv.mkDerivation ({ ++ optionals javaAwtGtk [ gmp mpfr ] )); - EXTRA_TARGET_FLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" - ] ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ]); - - EXTRA_TARGET_LDFLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" - ] ++ (if crossStageStatic then [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ] else [ - "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" - "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" - ])); + inherit + (import ../common/extra-target-flags.nix { + inherit stdenv crossStageStatic libcCross; + }) + EXTRA_TARGET_FLAGS + EXTRA_TARGET_LDFLAGS + ; passthru = { inherit langC langCC langObjC langObjCpp langFortran langGo version; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 7a4b0ed322285..c500bb477a255 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -230,24 +230,13 @@ stdenv.mkDerivation ({ LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); - EXTRA_TARGET_FLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" - ] ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ]); - - EXTRA_TARGET_LDFLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" - ] ++ (if crossStageStatic then [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ] else [ - "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" - "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" - ])); + inherit + (import ../common/extra-target-flags.nix { + inherit stdenv crossStageStatic libcCross; + }) + EXTRA_TARGET_FLAGS + EXTRA_TARGET_LDFLAGS + ; passthru = { inherit langC langCC langObjC langObjCpp langFortran langGo version; diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index c0df37bd5f8f1..6ce10a784273f 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -212,24 +212,13 @@ stdenv.mkDerivation ({ LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); - EXTRA_TARGET_FLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" - ] ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ]); - - EXTRA_TARGET_LDFLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" - ] ++ (if crossStageStatic then [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ] else [ - "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" - "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" - ])); + inherit + (import ../common/extra-target-flags.nix { + inherit stdenv crossStageStatic libcCross; + }) + EXTRA_TARGET_FLAGS + EXTRA_TARGET_LDFLAGS + ; passthru = { inherit langC langCC langObjC langObjCpp langFortran langGo version; diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index 23a5eeafb8b88..0e78cffdef2cf 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -211,24 +211,13 @@ stdenv.mkDerivation ({ LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); - EXTRA_TARGET_FLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" - ] ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ]); - - EXTRA_TARGET_LDFLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" - ] ++ (if crossStageStatic then [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ] else [ - "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" - "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" - ])); + inherit + (import ../common/extra-target-flags.nix { + inherit stdenv crossStageStatic libcCross; + }) + EXTRA_TARGET_FLAGS + EXTRA_TARGET_LDFLAGS + ; passthru = { inherit langC langCC langObjC langObjCpp langFortran langGo version; diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index 0707e0871787a..a0c9941e3c660 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -49,7 +49,7 @@ let "--disable-decimal-float" # requires libc "--disable-libmpx" # requires libc ] ++ lib.optionals crossMingw [ - "--with-headers=${libcCross}/include" + "--with-headers=${lib.getDev libcCross}/include" "--with-gcc" "--with-gnu-as" "--with-gnu-ld" diff --git a/pkgs/development/compilers/gcc/common/extra-target-flags.nix b/pkgs/development/compilers/gcc/common/extra-target-flags.nix new file mode 100644 index 0000000000000..1c2fad8fbc512 --- /dev/null +++ b/pkgs/development/compilers/gcc/common/extra-target-flags.nix @@ -0,0 +1,28 @@ +{ stdenv, crossStageStatic, libcCross }: + +let + inherit (stdenv) lib hostPlatform targetPlatform; +in + +{ + EXTRA_TARGET_FLAGS = let + mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([ + "-idirafter ${lib.getDev dep}${dep.incdir or "/include"}" + ] ++ stdenv.lib.optionals (! crossStageStatic) [ + "-B${lib.getLib dep}${dep.libdir or "/lib"}" + ]); + in mkFlags libcCross + ; + + EXTRA_TARGET_LDFLAGS = let + mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([ + "-Wl,-L${lib.getLib dep}${dep.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${lib.getLib dep}${dep.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${lib.getLib dep}${dep.libdir or "/lib"}" + "-Wl,-rpath-link,${lib.getLib dep}${dep.libdir or "/lib"}" + ])); + in mkFlags libcCross + ; +} diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix index d073edfb09c83..f431df03549be 100644 --- a/pkgs/development/compilers/gcc/snapshot/default.nix +++ b/pkgs/development/compilers/gcc/snapshot/default.nix @@ -184,24 +184,13 @@ stdenv.mkDerivation ({ LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); - EXTRA_TARGET_FLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" - ] ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ]); - - EXTRA_TARGET_LDFLAGS = optionals - (targetPlatform != hostPlatform && libcCross != null) - ([ - "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" - ] ++ (if crossStageStatic then [ - "-B${libcCross.out}${libcCross.libdir or "/lib"}" - ] else [ - "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" - "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" - ])); + inherit + (import ../common/extra-target-flags.nix { + inherit stdenv crossStageStatic libcCross; + }) + EXTRA_TARGET_FLAGS + EXTRA_TARGET_LDFLAGS + ; passthru = { inherit langC langCC langObjC langObjCpp langFortran langGo version; diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index 022aaffe59618..7efc2e2131336 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -11,11 +11,15 @@ in stdenv.mkDerivation { sha256 = "00zq3z1hbzd5yzmskskjg79xrzwsqx7ihyprfaxy4hb897vf29sm"; }; + outputs = [ "out" "dev" ]; + configureFlags = [ "--enable-idl" "--enable-secure-api" ]; + enableParallelBuilding = true; + buildInputs = [ windows.mingw_w64_headers ]; dontStrip = true; hardeningDisable = [ "stackprotector" "fortify" ]; -- cgit 1.4.1