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.
This commit is contained in:
Adam Joseph 2023-04-07 21:44:28 -07:00 committed by Artturin
parent f06ab170fa
commit de8ce81ff2

View file

@ -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