Loading pkgs/build-support/cc-wrapper/default.nix +14 −0 Original line number Diff line number Diff line Loading @@ -629,6 +629,20 @@ stdenvNoCC.mkDerivation { echo " -L${libcxx_solib}" >> $out/nix-support/cc-ldflags '' ## Prevent clang from seeing /usr/include. There is a desire to achieve this ## through alternate means because it breaks -sysroot and related functionality. # # This flag prevents global system header directories from # leaking through on non‐NixOS Linux. However, on macOS, the # SDK path is used as the sysroot, and forcing `-nostdlibinc` # breaks `-isysroot` with an unwrapped compiler. As macOS has # no `/usr/include`, there’s essentially no risk to dropping # the flag there. See discussion in NixOS/nixpkgs#191152. # + optionalString ((cc.isClang or false) && !targetPlatform.isDarwin) '' echo " -nostdlibinc" >> $out/nix-support/cc-cflags '' ## ## Man page and info support ## Loading pkgs/development/compilers/llvm/common/clang/add-nostdlibinc-flag.patchdeleted 100644 → 0 +0 −18 Original line number Diff line number Diff line diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 3f29afd35971..223d2769cdfc 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -491,6 +491,13 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { } #endif + { + Arg *A = DAL->MakeFlagArg(/*BaseArg=*/nullptr, + Opts.getOption(options::OPT_nostdlibinc)); + A->claim(); + DAL->append(A); + } + return DAL; } pkgs/development/compilers/llvm/common/default.nix +0 −17 Original line number Diff line number Diff line Loading @@ -540,23 +540,6 @@ let # mis-compilation in firefox. # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1741454 (metadata.getVersionFile "clang/revert-malloc-alignment-assumption.patch") # This patch prevents global system header directories from # leaking through on non‐NixOS Linux. However, on macOS, the # SDK path is used as the sysroot, and forcing `-nostdlibinc` # breaks `-isysroot` with an unwrapped compiler. As macOS has # no `/usr/include`, there’s essentially no risk to skipping # the patch there. It’s possible that Homebrew headers in # `/usr/local/include` might leak through to unwrapped # compilers being used without an SDK set or something, but # it hopefully shouldn’t matter. # # TODO: Figure out a better solution to this whole problem so # that we won’t have to choose between breaking unwrapped # compilers breaking libclang when we can do Linux‐to‐Darwin # cross‐compilation again. ++ lib.optional ( !args.stdenv.hostPlatform.isDarwin || !args.stdenv.targetPlatform.isDarwin ) ./clang/add-nostdlibinc-flag.patch ++ [ (substituteAll { src = Loading Loading
pkgs/build-support/cc-wrapper/default.nix +14 −0 Original line number Diff line number Diff line Loading @@ -629,6 +629,20 @@ stdenvNoCC.mkDerivation { echo " -L${libcxx_solib}" >> $out/nix-support/cc-ldflags '' ## Prevent clang from seeing /usr/include. There is a desire to achieve this ## through alternate means because it breaks -sysroot and related functionality. # # This flag prevents global system header directories from # leaking through on non‐NixOS Linux. However, on macOS, the # SDK path is used as the sysroot, and forcing `-nostdlibinc` # breaks `-isysroot` with an unwrapped compiler. As macOS has # no `/usr/include`, there’s essentially no risk to dropping # the flag there. See discussion in NixOS/nixpkgs#191152. # + optionalString ((cc.isClang or false) && !targetPlatform.isDarwin) '' echo " -nostdlibinc" >> $out/nix-support/cc-cflags '' ## ## Man page and info support ## Loading
pkgs/development/compilers/llvm/common/clang/add-nostdlibinc-flag.patchdeleted 100644 → 0 +0 −18 Original line number Diff line number Diff line diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 3f29afd35971..223d2769cdfc 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -491,6 +491,13 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { } #endif + { + Arg *A = DAL->MakeFlagArg(/*BaseArg=*/nullptr, + Opts.getOption(options::OPT_nostdlibinc)); + A->claim(); + DAL->append(A); + } + return DAL; }
pkgs/development/compilers/llvm/common/default.nix +0 −17 Original line number Diff line number Diff line Loading @@ -540,23 +540,6 @@ let # mis-compilation in firefox. # See: https://bugzilla.mozilla.org/show_bug.cgi?id=1741454 (metadata.getVersionFile "clang/revert-malloc-alignment-assumption.patch") # This patch prevents global system header directories from # leaking through on non‐NixOS Linux. However, on macOS, the # SDK path is used as the sysroot, and forcing `-nostdlibinc` # breaks `-isysroot` with an unwrapped compiler. As macOS has # no `/usr/include`, there’s essentially no risk to skipping # the patch there. It’s possible that Homebrew headers in # `/usr/local/include` might leak through to unwrapped # compilers being used without an SDK set or something, but # it hopefully shouldn’t matter. # # TODO: Figure out a better solution to this whole problem so # that we won’t have to choose between breaking unwrapped # compilers breaking libclang when we can do Linux‐to‐Darwin # cross‐compilation again. ++ lib.optional ( !args.stdenv.hostPlatform.isDarwin || !args.stdenv.targetPlatform.isDarwin ) ./clang/add-nostdlibinc-flag.patch ++ [ (substituteAll { src = Loading