Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build asan with clang? #14489

Closed
spacewander opened this issue Dec 21, 2020 · 7 comments
Closed

How to build asan with clang? #14489

spacewander opened this issue Dec 21, 2020 · 7 comments
Labels
area/build stale stalebot believes this issue/PR has not been touched recently

Comments

@spacewander
Copy link
Contributor

Title: I need some help for building asan with clang

Description:
I tried bazel test --config=clang-asan ..., but got:

ld.lld: error: undefined symbol: __muloti4
>>> referenced by numbers.cc
>>>               bazel-out/k8-fastbuild/bin/external/com_google_absl/absl/strings/_objs/strings/numbers.pic.o:(absl::operator*(absl::int128, absl::int128))
clang: error: linker command failed with exit code 1

After applying the solution in https://bugs.llvm.org/show_bug.cgi?id=16404

diff --git .bazelrc .bazelrc
index 6a7cd55d0..7d9c1ef49 100644
--- .bazelrc
+++ .bazelrc
@@ -69,6 +69,7 @@ build:asan --copt -fno-optimize-sibling-calls
 # Clang ASAN/UBSAN
 build:clang-asan --config=asan
 build:clang-asan --linkopt -fuse-ld=lld
+build:clang-asan --linkopt -rtlib=compiler-rt

 # macOS ASAN/UBSAN
 build:macos --cxxopt=-std=c++1

now I get:

ld.lld: error: undefined symbol: _Unwind_Backtrace
>>> referenced by sanitizer_unwind_linux_libcdep.cpp.o:(__sanitizer::BufferedStackTrace::UnwindSlow(unsigned long, unsigned int)) in archive /usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.a
>>> referenced by sanitizer_unwind_linux_libcdep.cpp.o:(__sanitizer::BufferedStackTrace::UnwindSlow(unsigned long, void*, unsigned int)) in archive /usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.a

ld.lld: error: undefined symbol: _Unwind_GetIP
>>> referenced by sanitizer_unwind_linux_libcdep.cpp.o:(__sanitizer::(anonymous namespace)::Unwind_Trace(_Unwind_Context*, void*)) in archive /usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.a
clang: error: linker command failed with exit code 1

Maybe I miss something? I am using Ubuntu 20.04 & clang 11. It would be great if anyone provides me some help.

@spacewander spacewander added the triage Issue requires triage label Dec 21, 2020
@caitong93
Copy link

Plz try ./ci/run_envoy_docker.sh 'bazel test --config=clang-asan ..' . It's suggested to use docker build to keep ur local development environment same as others https://github.com/envoyproxy/envoy/tree/master/ci#on-linux .

@spacewander
Copy link
Contributor Author

It seems the docker used by ./ci/run_envoy_docker.sh doesn't contain clang.

./ci/run_envoy_docker.sh 'echo $(which clang)'

./ci/run_envoy_docker.sh 'echo $(which gcc)'
/usr/bin/gcc

@caitong93
Copy link

@nareddyt
Copy link
Contributor

So it seems like some of the bazel flags from

build:clang-asan --action_env=ENVOY_UBSAN_VPTR=1
are needed. These are not set for clang-asan in the root-level bazelrc by default, only added for CI. Wonder why.

@mattklein123 mattklein123 added area/build and removed triage Issue requires triage labels Dec 26, 2020
@nareddyt
Copy link
Contributor

nareddyt commented Jan 14, 2021

The issue seems related to #13973. Unfortunately I had no luck setting those extra bazel flags, so I had to disable Ubsan for now. GoogleCloudPlatform/esp-v2#462 and envoyproxy/nighthawk#593 track this.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Feb 22, 2021
@github-actions
Copy link

github-actions bot commented Mar 2, 2021

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

@github-actions github-actions bot closed this as completed Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

4 participants