diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 324599e49821..e8892e17b711 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 9d4d8a9b6ac2..4f6d32b33174 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 d809c6c4e364..3c8cdde81036 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 1eec43cb320a..82cec33756d8 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 7a4b0ed32228..c500bb477a25 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 c0df37bd5f8f..6ce10a784273 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 23a5eeafb8b8..0e78cffdef2c 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 0707e0871787..a0c9941e3c66 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 000000000000..1c2fad8fbc51 --- /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 d073edfb09c8..f431df03549b 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 022aaffe5961..7efc2e213133 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" ];