I am trying to use the clang C++ compiler with Bazel, as well as the libc++ standard library implementation. To this end I set my system up as follows:
- Install clang, libc++-dev, libc++abi-dev
- Symlink /usr/lib/llvm-11/include/c++/v1 to /usr/include/c++/v1
- Cet the environment CC=clang-11
At this point, note that regular building works as expected and uses clang, but still with libstdc++.
Now I switch to libc++ by using the following build flags:
- --copt=-stdlib=libc++ --linkopt=-lc++abi --linkopt=-lc++
What I now see is that the resulting binary is linked _both_ against libc++ and libstdc++. I made a tiny toy cc_library :foo, and here are the relevant entries in bazel-bin/foo-2.params:
-o
bazel-out/k8-opt/bin/foo
-fuse-ld=/usr/bin/ld.gold
-Wl,-no-as-needed
-Wl,-z,relro,-z,now
-B/usr/bin
-lstdc++
-lm
-Wl,--gc-sections
bazel-out/k8-opt/bin/_objs/foo/foo.o
-lc++abi
-lc++
Is there anything I'm doing wrong, and how should I go about using libc++?
Thank you!
Thomas