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

--features=asan doesn't work on macOS #192

Closed
garymm opened this issue Mar 10, 2023 · 5 comments
Closed

--features=asan doesn't work on macOS #192

garymm opened this issue Mar 10, 2023 · 5 comments

Comments

@garymm
Copy link
Contributor

garymm commented Mar 10, 2023

Building my code with bazel build --features=asan fails with:
ld: file not found: external/llvm_toolchain_llvm/lib/clang/15.0.6/lib/darwin/libclang_rt.asan_osx_dynamic.dylib

Using LLVM 15.0.6.
The file does exist. I haven't really investigated much, just filing the issue so it's common knowledge.

@siddharthab
Copy link
Contributor

We stopped making dylib files available in the toolchain during the build phase because the files will not be available when running or deploying your application. But perhaps we overdid it, and we can make the .dylib files in the lib/clang/{llvm_version}/lib/darwin/ directory available.

To test, you can add a glob expression here and see if it works for you. If it does, please send a PR.

@keith
Copy link
Member

keith commented Mar 10, 2023

For iOS builds with the standard bazel toolchain we copy the dylibs into the shipping bundle in that case, but that's easier in that setup because there's a clear place to do that piece

@siddharthab
Copy link
Contributor

Thanks. My original imagination here was that the osx sysroot could be a good proxy of what's available at runtime. And so if a dylib is not there, it's not available. But this looks like a special case.

@timbess
Copy link
Contributor

timbess commented Feb 3, 2024

FWIW, I tested the suggested change and it works, but I ended up having to add @llvm_toolchain//:linker-files-aarch64-darwin as a data dependency of my binary so that it could find other dylibs at runtime.
image

It seems like the binary is executing in the bazel-bin and the dylibs aren't created in any of the places the RPATH looks for it in unless I add the linker files as a data dep.

@timbess
Copy link
Contributor

timbess commented Feb 3, 2024

image

Ok so using the _llvm repo to grab the :lib target at least doesn't directly reference my toolchain triple by name, so I'll just gate this behind a select I guess for now.

jez pushed a commit to sorbet/bazel-toolchain that referenced this issue Apr 30, 2024
…zel-contrib#250)

Add dylibs to the `lib` target so that santizers work properly on MacOS.

Resolves bazel-contrib#192.

---------

Co-authored-by: Siddhartha Bagaria <starsid@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants