gcc*: always force --program-prefix and pass --target

Don't rely on gcc detecting from the passed platforms which prefix to
use, but always specify the prefix nixpkgs expects (or doesn't). This
allows us to work around problems where the configure script would add
prefix where nixpkgs doesn't expect one (if `--target` was specified,
but the same as `--host`) or doesn't add one if nixpkgs expects one (if
`--target` and `--host` are the same, but we are actually cross
compiling, but the relevant parts of the platform are not encoded into
the platform config.

See also ca9be0511b.
launchpad/nixpkgs/master
sternenseemann 3 years ago
parent ca9be0511b
commit acdc783418
  1. 3
      pkgs/development/compilers/gcc/10/default.nix
  2. 3
      pkgs/development/compilers/gcc/4.8/default.nix
  3. 3
      pkgs/development/compilers/gcc/4.9/default.nix
  4. 3
      pkgs/development/compilers/gcc/6/default.nix
  5. 3
      pkgs/development/compilers/gcc/7/default.nix
  6. 3
      pkgs/development/compilers/gcc/8/default.nix
  7. 3
      pkgs/development/compilers/gcc/9/default.nix
  8. 15
      pkgs/development/compilers/gcc/common/configure-flags.nix

@ -186,8 +186,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" "target" ];
configureFlags = import ../common/configure-flags.nix {
inherit

@ -196,8 +196,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" "target" ];
configureFlags = import ../common/configure-flags.nix {
inherit

@ -209,8 +209,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" "target" ];
configureFlags = import ../common/configure-flags.nix {
inherit

@ -232,8 +232,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" "target" ];
configureFlags = import ../common/configure-flags.nix {
inherit

@ -197,8 +197,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" "target" ];
configureFlags = import ../common/configure-flags.nix {
inherit

@ -182,8 +182,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" "target" ];
configureFlags = import ../common/configure-flags.nix {
inherit

@ -199,8 +199,7 @@ stdenv.mkDerivation ({
dontDisableStatic = true;
# TODO(@Ericson2314): Always pass "--target" and always prefix.
configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";
configurePlatforms = [ "build" "host" "target" ];
configureFlags = import ../common/configure-flags.nix {
inherit

@ -44,6 +44,9 @@ let
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
"${stdenv.targetPlatform.config}-";
crossConfigureFlags =
# Ensure that -print-prog-name is able to find the correct programs.
[
@ -112,6 +115,18 @@ let
# Basic configuration
++ [
# Force target prefix. The behavior if `--target` and `--host`
# are specified is inconsistent: Sometimes specifying `--target`
# always causes a prefix to be generated, sometimes it's only
# added if the `--host` and `--target` differ. This means that
# sometimes there may be a prefix even though nixpkgs doesn't
# expect one and sometimes there may be none even though nixpkgs
# expects one (since not all information is serialized into the
# config attribute). The easiest way out of these problems is to
# always set the program prefix, so gcc will conform to our
# expectations.
"--program-prefix=${targetPrefix}"
(lib.enableFeature enableLTO "lto")
"--disable-libstdcxx-pch"
"--without-included-gettext"

Loading…
Cancel
Save