From de8ce81ff28dea6298527043150218969ea47f9d Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Fri, 7 Apr 2023 21:44:28 -0700 Subject: 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. --- pkgs/build-support/cc-wrapper/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pkgs/build-support/cc-wrapper') 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 -- cgit 1.4.1