Opened 11 years ago

Last modified 11 years ago

#38527 closed defect

clang-3.3 @3.3-r173279 AddressSanitizer binaries don't work without explicitly setting DYLD_LIBRARY_PATH — at Version 2

Reported by: acmorrow (Andrew C. Morrow) Owned by: jeremyhu@…
Priority: Normal Milestone:
Component: ports Version: 2.1.3
Keywords: Cc:
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 (2)

comment:1 Changed 11 years ago by acmorrow (Andrew C. Morrow)

Cc: andrew.c.morrow@… added

Cc Me!

comment:2 Changed 11 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.

Note: See TracTickets for help on using tickets.