[MacPorts] #38527: clang-3.3 @3.3-r173279 AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH
#38527: clang-3.3 @3.3-r173279 AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH -------------------------------+-------------------------------- Reporter: andrew.c.morrow@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Keywords: | Port: clang-3.3 -------------------------------+-------------------------------- 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. -- Ticket URL: <https://trac.macports.org/ticket/38527> MacPorts <http://www.macports.org/> Ports system for OS X
#38527: clang-3.3 @3.3-r173279 AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH --------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: clang-3.3 | --------------------------------+------------------------ Changes (by larryv@…): * cc: andrew.c.morrow@… (removed) * owner: macports-tickets@… => jeremyhu@… Old description:
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.
New description: 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. -- Comment: Thanks for the ticket. In the future, please Cc relevant port maintainers. Also, you don’t have to Cc yourself. -- Ticket URL: <https://trac.macports.org/ticket/38527#comment:2> MacPorts <http://www.macports.org/> Ports system for OS X
#38527: clang-3.3 @3.3-r173279 AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH --------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: clang-3.3 | --------------------------------+------------------------ Comment (by 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. -- Ticket URL: <https://trac.macports.org/ticket/38527#comment:3> MacPorts <http://www.macports.org/> Ports system for OS X
#38527: clang-3.2, clang-3.3, clang-3.4: AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH ----------------------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: clang-3.2, clang-3.3, clang-3.4 | ----------------------------------------------+------------------------ Changes (by ryandesign@…): * cc: dh@…, larryv@… (added) * port: clang-3.3 => clang-3.2, clang-3.3, clang-3.4 Comment: Has duplicate #39267. -- Ticket URL: <https://trac.macports.org/ticket/38527#comment:4> MacPorts <http://www.macports.org/> Ports system for OS X
#38527: clang-3.2, clang-3.3, clang-3.4: AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH ----------------------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: clang-3.2, clang-3.3, clang-3.4 | ----------------------------------------------+------------------------ Comment (by jeremyhu@…): I'll pull this into the next llvm bump. -- Ticket URL: <https://trac.macports.org/ticket/38527#comment:5> MacPorts <http://www.macports.org/> Ports system for OS X
#38527: libclang_rt.asan_osx_dynamic.dylib has incorrect dylib id ----------------------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: | Keywords: Port: clang-3.2, clang-3.3, clang-3.4 | ----------------------------------------------+------------------------ -- Ticket URL: <https://trac.macports.org/ticket/38527#comment:6> MacPorts <http://www.macports.org/> Ports system for OS X
#38527: libclang_rt.asan_osx_dynamic.dylib has incorrect dylib id ----------------------------------------------+------------------------ Reporter: andrew.c.morrow@… | Owner: jeremyhu@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.1.3 Resolution: fixed | Keywords: Port: clang-3.2, clang-3.3, clang-3.4 | ----------------------------------------------+------------------------ Changes (by jeremyhu@…): * status: new => closed * resolution: => fixed Comment: r109324 -- Ticket URL: <https://trac.macports.org/ticket/38527#comment:8> MacPorts <http://www.macports.org/> Ports system for OS X
participants (1)
-
MacPorts