System headers not found when using clang with libc++ #13071
Labels
P3
We're not considering working on this, but happy to review a PR. (No assignee)
team-Rules-CPP
Issues for C++ rules
type: support / not a bug (process)
Description of the problem / feature request:
Building C++ using clang and libc++ results in standard system headers not being found. For example:
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
clang-11
,libc++-11-dev
,libc++abi-dev
).bazelrc
file in the workspace root with options to enable C++ compilation with clang and libc++ (see below).bazel build
..bazelrc
:What operating system are you running Bazel on?
Linux (Debian Bullseye)
What's the output of
bazel info release
?release 4.0.0
Have you found anything relevant by searching the web?
Yes. Relevant information on how to enable clang + libc++ as well as how auto-configure works for cc_toolchain_config.
Any other information, logs, or outputs that you want to share?
I suspect the issue is with the combination of where clang lists its include path for libc++ headers and the the
-no-canonical-prefixes
compiler flag added byunix_cc_configure
. For example, compare the include paths specified by clang using the following commands:clang -E -xc++ - -v -stdlib=libc++ -std=c++17
:clang -E -xc++ - -v -stdlib=libc++ -std=c++17 -no-canonical-prefixes
:The path
/usr/lib/llvm-11/bin/../include/c++/v1
which resolves to/usr/lib/llvm-11/include/c++/v1
is missing from the latter. Indeed, dropping-no-canonical-prefixes
from theclang
command that's shown when using the--sandbox_debug
flag results in successful compilation.The text was updated successfully, but these errors were encountered: