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.
DarwinStaticLib name makes no sense at this point. Consider fixing this in a preliminary commit.