[PATCH] [compiler-rt] Use @rpath as LC_ID_DYLIB for ASan dylib on OS X

Kuba Brecka kuba.brecka at gmail.com
Tue Oct 28 15:42:38 PDT 2014


The current LC_ID_DYLIB is hardcoded to be the absolute path to the build result. This means that ASan only works out-of-the-box if you never move the compiler/libraries from the directory you built it in. We currently have an issue with the prebuilt binary releases, because of the hardcoded path: http://llvm.org/bugs/show_bug.cgi?id=21316

This patch proposes to change the LC_ID_DYLIB of ASan's dynamic libraries on OS X to be set to "@rpath/libclang_rt.asan_osx_dynamic.dylib" and similarly for iossim. Clang driver then sets the "-rpath" to be the real path to where clang currently has the dylib (because clang uses the relative path to its current executable). This means if you move the compiler or install the binary release, -fsanitize=address will link to the proper library. The remaining issue is that if you delete or move the dylib, the previously linked executables will still have the old path in them, but this issue already exists with the current state as well.

I also modified one of ASan tests not to depend on the fact that the dylib is referenced with the full path. Instead, it now locates the dylib by issuing "clang -fsanitize=address -###" and finding the dylib path there.

http://reviews.llvm.org/D6018

Files:
  projects/compiler-rt/lib/asan/CMakeLists.txt
  projects/compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.c
  tools/clang/lib/Driver/ToolChains.cpp
  tools/clang/lib/Driver/ToolChains.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6018.15532.patch
Type: text/x-patch
Size: 4131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141028/a245845b/attachment.bin>


More information about the llvm-commits mailing list