about summary refs log tree commit diff
path: root/pkgs/build-support/cc-wrapper
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2023-04-07 21:44:28 -0700
committerArtturin <Artturin@artturin.com>2023-04-11 20:19:58 +0300
commitde8ce81ff28dea6298527043150218969ea47f9d (patch)
tree566283640d78823f030615433b30dfbb8f0c63bb /pkgs/build-support/cc-wrapper
parentf06ab170fae68622dbfd254aac094fb13b0cfcaa (diff)
cc-wrapper: deunify clang/gcc treatment of -isystem
In https://github.com/NixOS/nixpkgs/pull/209870 I tried to unify the
treatment of clang and gcc in cc-wrapper as much as possible.
However it appears that I went too far.

Clang requires -isystem flags in order to be able to find gcc's
libstdc++.  Gcc does not need these flags.  If they are added,
gfortran will get confused:

  https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1500550903

This commit deunifies the chunk of code that adds the -isystem
flags, and explains why this chunk applies only to clang.
Diffstat (limited to 'pkgs/build-support/cc-wrapper')
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index 597e8105fa1dd..fdc1457cc469b 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -407,7 +407,11 @@ stdenv.mkDerivation {
       touch "$out/nix-support/libcxx-cxxflags"
       touch "$out/nix-support/libcxx-ldflags"
     ''
-    + optionalString (libcxx == null && (useGccForLibs && gccForLibs.langCC or false)) ''
+    # Adding -isystem flags should be done only for clang; gcc
+    # already knows how to find its own libstdc++, and adding
+    # additional -isystem flags will confuse gfortran (see
+    # https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1500550903)
+    + optionalString (libcxx == null && isClang && (useGccForLibs && gccForLibs.langCC or false)) ''
       for dir in ${gccForLibs}${lib.optionalString (hostPlatform != targetPlatform) "/${targetPlatform.config}"}/include/c++/*; do
         echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
       done