Bazel uses /usr/bin/clang instead of /usr/bin/clang++ to link C++ code on FreeBSD? #161
Open
4 tasks done
Labels
P3
Accepted issue. Team is likely to fix this issue in the future, but no short-term promises are made.
Description of the problem / feature request:
Apparently, Bazel uses
/usr/bin/clang
instead of/usr/bin/clang++
to compile/link C++ code. I'm not sure whether this is intentional, but the behavior forclang
is different fromclang++
resulting in subtle problems at compile/link time:The first command is what Bazel uses for purely C++ code on my FreeBSD system and the latter is what it should use. The only difference is
clang++
instead ofclang
.Feature requests: what underlying problem are you trying to solve with this feature?
Perhaps use clang++/g++ for C++ code and clang/gcc for C code. The problem is very likely
rules_cc
usingclang
instead ofclang++
as the C++ compiler in its toolchain definition. AFAIK,clang
is the C compiler driver, not the C++ compiler driver. The two languages should use different rulesets as well:cc_library
,cc_binary
for C++ andc_library
,c_binary
for C code. AFAIK, C and C++ aren't the same.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Compile anything using googletest on FreeBSD.
What operating system are you running Bazel on?
What's the output of
bazel info release
?If
bazel info release
returns "development version" or "(@non-git)", tell us how you built Bazel.What version of rules_cc do you use? Can you paste the workspace rule used to fetch rules_cc? What other relevant dependencies does your project have?
MODULE.bazel
What Bazel options do you use to trigger the issue? What C++ toolchain do you use?
No custom options. The default toolchain used for freebsd.
Have you found anything relevant by searching the web?
Yes, apparently, everybody including me was getting around this by adding
-lm
linker flags until it was noticed that/usr/bin/clang
is being used instead of/usr/bin/clang++
to link C++ code. Here's an example from the Bazel source tree.Any other information, logs, or outputs that you want to share?
/usr/bin/clang
instead of/usr/bin/clang++
to link C++ code on FreeBSD? bazel#12023 for FreeBSD 12.0-lm
flags were added togoogletest
as a work around, but I'm not sure it is the correct solution. This needs to be fixed by separating cc_* from c_*, and by usingclang++
for C++ andclang
for C code.The text was updated successfully, but these errors were encountered: