Opened 12 years ago
Closed 11 years ago
#38527 closed defect (fixed)
libclang_rt.asan_osx_dynamic.dylib has incorrect dylib id
Reported by: | acmorrow (Andrew C. Morrow) | Owned by: | jeremyhu (Jeremy Huddleston Sequoia) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.1.3 |
Keywords: | Cc: | dh@…, larryv (Lawrence Velázquez), cooljeanius (Eric Gallager) | |
Port: | clang-3.2, clang-3.3, clang-3.4 |
Description (last modified by larryv (Lawrence Velázquez))
I'm using clang-3.3 @3.3-r173279:
> /opt/local/bin/clang-mp-3.3 --version clang version 3.3 (trunk 173279) Target: x86_64-apple-darwin12.3.0 Thread model: posix
Given a simple hello world C++ program compiled with -fsanitize=address, the resulting binary cannot execute.
> cat ./hello_world.cpp #include <cstdlib> #include <iostream> int main(int argc, char* argv[]) { std::cout << "Hello, World!\n"; return EXIT_SUCCESS; } > /opt/local/bin/clang-mp-3.3 ./hello_world.cpp -fsanitize=address -o ./hello_world > ./hello_world dyld: Library not loaded: /opt/local/var/macports/build/_opt_mports_dports_lang_llvm-3.3/clang-3.3/work/trunk/Release+Debug+Asserts/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib Referenced from: hello_world/./hello_world Reason: image not found [1] 62828 trace trap ./hello_world
It looks as if it is looking for the asan support library in the original build path, not the install path. But we do find that library in the install for the port:
> mdfind -name libclang_rt.asan_osx_dynamic.dylib /opt/local/libexec/llvm-3.3/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
Adding the containing directory to the DYLD_LIBRARY_PATH fixes things: the binary now runs:
> DYLD_LIBRARY_PATH=/opt/local/libexec/llvm-3.3/lib/clang/3.3/lib/darwin ./hello_world Hello, World!
AddressSanitizer is super useful, it would be great if it worked out of the box for macports clang.
Change History (8)
comment:1 Changed 12 years ago by acmorrow (Andrew C. Morrow)
Cc: | andrew.c.morrow@… added |
---|
comment:2 Changed 12 years ago by larryv (Lawrence Velázquez)
Cc: | andrew.c.morrow@… removed |
---|---|
Description: | modified (diff) |
Owner: | changed from macports-tickets@… to jeremyhu@… |
Thanks for the ticket. In the future, please Cc relevant port maintainers. Also, you don’t have to Cc yourself.
comment:3 Changed 11 years ago by acmorrow (Andrew C. Morrow)
One workaround for this is to change to the directory where libclang_rt.asan lives and use install_name_tool to patch it up:
$ mdfind -name libclang_rt.asan_osx_dynamic.dylib /opt/local/libexec/llvm-3.4/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib /opt/local/libexec/llvm-3.3/lib/clang/3.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib /opt/local/libexec/llvm-3.2/lib/clang/3.2/lib/darwin/libclang_rt.asan_osx_dynamic.dylib $ cd /opt/local/libexec/llvm-3.4/lib/clang/3.4/lib/darwin/ $ sudo install_name_tool -id $(grealpath ./libclang_rt.asan_osx_dynamic.dylib) ./libclang_rt.asan_osx_dynamic.dylib
You will need to re-link any executables built with -fsanitize=address so they pick up the new install name. Obviously, if you re-install the port, you will need to redo this.
comment:4 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | dh@… larryv@… added |
---|---|
Port: | clang-3.2 clang-3.4 added |
Summary: | clang-3.3 @3.3-r173279 AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH → clang-3.2, clang-3.3, clang-3.4: AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH |
Has duplicate #39267.
comment:5 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)
I'll pull this into the next llvm bump.
comment:6 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)
Summary: | clang-3.2, clang-3.3, clang-3.4: AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH → libclang_rt.asan_osx_dynamic.dylib has incorrect dylib id |
---|
comment:8 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)
Resolution: | → fixed |
---|---|
Status: | new → closed |
Cc Me!