Skip to content

Commit

Permalink
gcc{6,7,8,9,10,11}: fix cross-compiler build on x86_64-darwin
Browse files Browse the repository at this point in the history
Building a cross-compiler fails due to register storage class specifier
errors when building with clang 16 due to its defaulting to C++17.
Downgrading the error allows the older cross-compilers to build.

(cherry picked from commit f2a7764)
  • Loading branch information
reckenrode authored and emilytrau committed Dec 3, 2023
1 parent b707c14 commit bcc0bb7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkgs/development/compilers/gcc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,11 @@ lib.pipe ((callFile ./common/builder.nix {}) ({
badPlatforms = if targetPlatform != hostPlatform then [ "aarch64-darwin" ] else [ ];
};
} // optionalAttrs is7 {
env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument";
NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument"
# Downgrade register storage class specifier errors to warnings when building a cross compiler from a clang stdenv.
+ lib.optionalString (stdenv.cc.isClang && targetPlatform != hostPlatform) " -Wno-register";
} // optionalAttrs (!is7 && !atLeast12 && stdenv.cc.isClang && targetPlatform != hostPlatform) {
NIX_CFLAGS_COMPILE = "-Wno-register";
} // lib.optionalAttrs (!atLeast10 && stdenv.targetPlatform.isDarwin) {
# GCC <10 requires default cctools `strip` instead of `llvm-strip` used by Darwin bintools.
preBuild = ''
Expand Down

0 comments on commit bcc0bb7

Please sign in to comment.