diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index e4cebab266e84..ae5e64dc98faf 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -257,6 +257,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix index de764b9ccc7c2..e42ad6c4e5b5e 100644 --- a/pkgs/development/compilers/gcc/11/default.nix +++ b/pkgs/development/compilers/gcc/11/default.nix @@ -261,6 +261,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/12/default.nix b/pkgs/development/compilers/gcc/12/default.nix index 3c9362fee1ad2..7486c6e5ddd2c 100644 --- a/pkgs/development/compilers/gcc/12/default.nix +++ b/pkgs/development/compilers/gcc/12/default.nix @@ -299,6 +299,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index ba084af53ee52..d376eed8f46be 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -277,6 +277,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index c28ef88ce9338..4c6e158e2b17f 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -297,6 +297,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 8bd9d41f1eaed..880967e71cd44 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -308,6 +308,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 637be9fd971c6..c4ed5e6dd9298 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -263,6 +263,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index 4eb47d00c5c21..669a2404a8378 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -241,6 +241,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index 4c49cdaa3e259..80d64b6a4bd32 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -256,6 +256,7 @@ stdenv.mkDerivation ({ }) EXTRA_FLAGS_FOR_TARGET EXTRA_LDFLAGS_FOR_TARGET + hostEqualsTarget ; passthru = { diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index 2d7a058fa015c..dc0f89ef404fb 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -96,7 +96,7 @@ if test "$noSysDirs" = "1"; then declare EXTRA_FLAGS${post}="${extraFlags[*]}" done - if test -z "${targetConfig-}"; then + if test "$hostEqualsTarget" == 1; then # host = target, so the flags are the same EXTRA_FLAGS_FOR_TARGET="$EXTRA_FLAGS" EXTRA_LDFLAGS_FOR_TARGET="$EXTRA_LDFLAGS" @@ -128,7 +128,7 @@ if test "$noSysDirs" = "1"; then "FLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" ) - if test -z "${targetConfig-}"; then + if test "$hostEqualsTarget" == 1; then makeFlagsArray+=( "BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" "BOOT_LDFLAGS=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" diff --git a/pkgs/development/compilers/gcc/common/extra-target-flags.nix b/pkgs/development/compilers/gcc/common/extra-target-flags.nix index 4dedd333b0028..2550c48af36cc 100644 --- a/pkgs/development/compilers/gcc/common/extra-target-flags.nix +++ b/pkgs/development/compilers/gcc/common/extra-target-flags.nix @@ -5,6 +5,8 @@ let in { + hostEqualsTarget = stdenv.hostPlatform == stdenv.targetPlatform; + # For non-cross builds these flags are currently assigned in builder.sh. # It would be good to consolidate the generation of makeFlags # ({C,CXX,LD}FLAGS_FOR_{BUILD,TARGET}, etc...) at some point.