diff options
author | Adam Joseph <adam@westernsemico.com> | 2023-04-07 21:44:28 -0700 |
---|---|---|
committer | Artturin <Artturin@artturin.com> | 2023-04-11 20:19:58 +0300 |
commit | de8ce81ff28dea6298527043150218969ea47f9d (patch) | |
tree | 566283640d78823f030615433b30dfbb8f0c63bb | |
parent | f06ab170fae68622dbfd254aac094fb13b0cfcaa (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.
-rw-r--r-- | pkgs/build-support/cc-wrapper/default.nix | 6 |
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 |