Currently clang improperly handles the generation of the libLTO path, which is passed unconditionally to '-lto_library`on the linker, when the compiler is invoked via a symlink.
The attached patch solves this issue by passing D.Dir rather than D.getInstalledDir() to llvm::sys::path::parent_path() when setting P to the parent directory path.
IMHO, the nomenclature used for Dir and InstalledDir is confusing. Dir is actually the installed location of the compiler binary while InstalledDir is the unresolved path of the invoked compiler. I discovered this empirically by stepping through the execution of a stage1 bootstrap clang compiler when invoked through a direct path at /sw/src/fink.build/llvm40-4.0.0-1/build/stage3/bin/clang-4.0 and through a symlink at /tmp/clang-4.0.
Comparison of the lldb output for 'p/s D' after stepping past 'const Driver &getDriver() const { return D; }' revealed that, counterintuitively, Dir represents the path to the actual compiler binary and InstallDir represents the path to the symlink.
--- binary 2016-10-28 09:28:14.000000000 -0400 +++ symlink 2016-10-28 09:28:32.000000000 -0400 @@ -11,7 +11,7 @@ Name = "clang-4.0" Dir = "/sw/src/fink.build/llvm40-4.0.0-1/build/stage3/bin" ClangExecutable = "/sw/src/fink.build/llvm40-4.0.0-1/build/stage3/bin/clang-4.0" - InstalledDir = "/sw/src/fink.build/llvm40-4.0.0-1/build/last/bin" + InstalledDir = "/tmp" ResourceDir = "/sw/src/fink.build/llvm40-4.0.0-1/build/stage3/bin/../lib/clang/4.0.0"