[MacPorts] #38527: clang-3.3 @3.3-r173279 AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH
MacPorts
noreply at macports.org
Mon Mar 25 08:06:18 PDT 2013
#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
More information about the macports-tickets
mailing list