Unverified Commit 31cf83ad authored by Randy Eckenrode's avatar Randy Eckenrode Committed by GitHub
Browse files

cc-wrapper: always include libc++ in the search path (#445095)

parents adebddbd 76a8ffa6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -140,6 +140,15 @@ if [ "$NIX_ENFORCE_NO_NATIVE_@suffixSalt@" = 1 ]; then
    params=(${kept+"${kept[@]}"})
fi

# Some build systems such as Bazel and SwiftPM use `clang` instead of `clang++`,
# which will find the libc++ headers in the sysroot for C++ files.
if [[ "$isCxx" = 0 && "@isClang@" ]]; then
# This duplicates the behavior of a native toolchain, which can find the
# libc++ headers but requires `-lc++` to be specified explicitly when linking.
    isCxx=1
    cxxLibrary=0
fi

if [[ "$isCxx" = 1 ]]; then
    if [[ "$cxxInclude" = 1 ]]; then
        #
+3 −3
Original line number Diff line number Diff line
@@ -753,14 +753,14 @@ stdenvNoCC.mkDerivation {
    # https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1500550903)
    + optionalString (libcxx == null && isClang && (useGccForLibs && gccForLibs.langCC or false)) ''
      for dir in ${gccForLibs}/include/c++/*; do
        include -isystem "$dir" >> $out/nix-support/libcxx-cxxflags
        include -cxx-isystem "$dir" >> $out/nix-support/libcxx-cxxflags
      done
      for dir in ${gccForLibs}/include/c++/*/${targetPlatform.config}; do
        include -isystem "$dir" >> $out/nix-support/libcxx-cxxflags
        include -cxx-isystem "$dir" >> $out/nix-support/libcxx-cxxflags
      done
    ''
    + optionalString (libcxx.isLLVM or false) ''
      include -isystem "${getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
      include -cxx-isystem "${getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags
      echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags
    ''
    # GCC NG friendly libc++