Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkgs/build-support/cc-wrapper/cc-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
6 changes: 3 additions & 3 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,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++
Expand Down
Loading