diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index 2f7991a92124..93f8f278dc30 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -103,9 +103,15 @@ stdenv.mkDerivation ({ hardeningDisable = [ "format" "pie" ]; + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' # This should kill all the stdinc frameworks that gcc and friends like to # insert into default search paths. - prePatch = lib.optionalString hostPlatform.isDarwin '' + + lib.optionalString hostPlatform.isDarwin '' substituteInPlace gcc/config/darwin-c.c \ --replace 'if (stdinc)' 'if (0)' @@ -114,14 +120,8 @@ stdenv.mkDerivation ({ substituteInPlace libgfortran/configure \ --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" - ''; - - postPatch = '' - configureScripts=$(find . -name configure) - for configureScript in $configureScripts; do - patchShebangs $configureScript - done - '' + ( + '' + + ( if targetPlatform != hostPlatform || stdenv.cc.libc != null then # On NixOS, use the right path to the dynamic linker instead of # `/lib/ld*.so'. diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix index 3a9f50be3e7f..8bd1abe8f97f 100644 --- a/pkgs/development/compilers/gcc/11/default.nix +++ b/pkgs/development/compilers/gcc/11/default.nix @@ -103,9 +103,15 @@ stdenv.mkDerivation ({ hardeningDisable = [ "format" "pie" ]; + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' # This should kill all the stdinc frameworks that gcc and friends like to # insert into default search paths. - prePatch = lib.optionalString hostPlatform.isDarwin '' + + lib.optionalString hostPlatform.isDarwin '' substituteInPlace gcc/config/darwin-c.c \ --replace 'if (stdinc)' 'if (0)' @@ -114,14 +120,8 @@ stdenv.mkDerivation ({ substituteInPlace libgfortran/configure \ --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" - ''; - - postPatch = '' - configureScripts=$(find . -name configure) - for configureScript in $configureScripts; do - patchShebangs $configureScript - done - '' + ( + '' + + ( if targetPlatform != hostPlatform || stdenv.cc.libc != null then # On NixOS, use the right path to the dynamic linker instead of # `/lib/ld*.so'. diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 32a4ad0dd090..4e2a7d5e15f1 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -154,7 +154,7 @@ stdenv.mkDerivation ({ hardeningDisable = [ "format" "pie" ]; - prePatch = + postPatch = # This should kill all the stdinc frameworks that gcc and friends like to # insert into default search paths. lib.optionalString hostPlatform.isDarwin '' @@ -166,9 +166,8 @@ stdenv.mkDerivation ({ substituteInPlace libgfortran/configure \ --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" - ''; - - postPatch = + '' + + ( if targetPlatform != hostPlatform || stdenv.cc.libc != null then # On NixOS, use the right path to the dynamic linker instead of # `/lib/ld*.so'. @@ -191,7 +190,7 @@ stdenv.mkDerivation ({ sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' '' ) - else null; + else ""); inherit noSysDirs staticCompiler langJava crossStageStatic libcCross crossMingw; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 33edc81ce539..28984887a954 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -114,9 +114,15 @@ stdenv.mkDerivation ({ hardeningDisable = [ "format" "pie" ]; + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' # This should kill all the stdinc frameworks that gcc and friends like to # insert into default search paths. - prePatch = lib.optionalString hostPlatform.isDarwin '' + + lib.optionalString hostPlatform.isDarwin '' substituteInPlace gcc/config/darwin-c.c \ --replace 'if (stdinc)' 'if (0)' @@ -125,14 +131,8 @@ stdenv.mkDerivation ({ substituteInPlace libgfortran/configure \ --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" - ''; - - postPatch = '' - configureScripts=$(find . -name configure) - for configureScript in $configureScripts; do - patchShebangs $configureScript - done - '' + ( + '' + + ( if targetPlatform != hostPlatform || stdenv.cc.libc != null then # On NixOS, use the right path to the dynamic linker instead of # `/lib/ld*.so'. diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index dae98afccb90..d811d1b3c73c 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -101,9 +101,15 @@ stdenv.mkDerivation ({ hardeningDisable = [ "format" "pie" ]; + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' # This should kill all the stdinc frameworks that gcc and friends like to # insert into default search paths. - prePatch = lib.optionalString hostPlatform.isDarwin '' + + lib.optionalString hostPlatform.isDarwin '' substituteInPlace gcc/config/darwin-c.c \ --replace 'if (stdinc)' 'if (0)' @@ -112,14 +118,8 @@ stdenv.mkDerivation ({ substituteInPlace libgfortran/configure \ --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" - ''; - - postPatch = '' - configureScripts=$(find . -name configure) - for configureScript in $configureScripts; do - patchShebangs $configureScript - done - '' + ( + '' + + ( if targetPlatform != hostPlatform || stdenv.cc.libc != null then # On NixOS, use the right path to the dynamic linker instead of # `/lib/ld*.so'. diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index ebe20e0cba5c..a0115b6f74e4 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -117,9 +117,15 @@ stdenv.mkDerivation ({ hardeningDisable = [ "format" "pie" ]; + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' # This should kill all the stdinc frameworks that gcc and friends like to # insert into default search paths. - prePatch = lib.optionalString hostPlatform.isDarwin '' + + lib.optionalString hostPlatform.isDarwin '' substituteInPlace gcc/config/darwin-c.c \ --replace 'if (stdinc)' 'if (0)' @@ -128,14 +134,8 @@ stdenv.mkDerivation ({ substituteInPlace libgfortran/configure \ --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" - ''; - - postPatch = '' - configureScripts=$(find . -name configure) - for configureScript in $configureScripts; do - patchShebangs $configureScript - done - '' + ( + '' + + ( if targetPlatform != hostPlatform || stdenv.cc.libc != null then # On NixOS, use the right path to the dynamic linker instead of # `/lib/ld*.so'.