This is an archive of the discontinued LLVM Phabricator instance.

[DarwinDriver] Use -lto_library to specify the path for libLTO.dylib
ClosedPublic

Authored by bruno on Sep 23 2015, 1:56 PM.

Details

Summary

Usually, when using LTO with a clang installation newer than the system one, there's a libLTO.dylib version mismatch and LTO fails. One solution to this is to make ld point to the right libLTO.dylib by changing DYLD_LIBRARY_PATH.

However, ld64 supports specifying the complete path to the desired libLTO.dylib through the -lto_library option. This patch adds support for the clang driver to use this option whenever it's capable of finding a libLTO.dylib in clang's installed library directory. This way, we don't need to rely on DYLD_LIBRARY_PATH nor get caught by version mismatches.

Diff Detail

Repository
rL LLVM

Event Timeline

bruno updated this revision to Diff 35547.Sep 23 2015, 1:56 PM
bruno retitled this revision from to [DarwinDriver] Use -lto_library to specify the path for libLTO.dylib.
bruno updated this object.
bruno added a reviewer: dexonsmith.
bruno set the repository for this revision to rL LLVM.
bruno added subscribers: cfe-commits, kledzik, bob.wilson.
dexonsmith edited edge metadata.Sep 23 2015, 3:06 PM
dexonsmith added a subscriber: dexonsmith.

The code LGTM, but there ought to be a way to add a LIT test for this.

Looking for -object_path_lto, I found this:

RUN: %clang -target x86_64-apple-darwin10 -### %s \
RUN: -mlinker-version=117 -flto 2> %t.log
RUN: cat %t.log
RUN: FileCheck -check-prefix=LINK_OBJECT_LTO_PATH %s < %t.log

LINK_OBJECT_LTO_PATH: {{ld(.exe)?"}}

// LINK_OBJECT_LTO_PATH: "-object_path_lto"

in test/Driver/darwin-ld.c. Can you add a similar test there?

bruno updated this revision to Diff 35664.Sep 24 2015, 11:57 AM
bruno edited edge metadata.

Added test per Duncan's comment.

Sorry for the review fragmentation, but I just noticed there's no test
for the new warning. Can you add one? After that, LGTM.

bruno accepted this revision.Apr 13 2017, 12:45 PM
This revision is now accepted and ready to land.Apr 13 2017, 12:45 PM
bruno closed this revision.Apr 13 2017, 12:45 PM

Done way back in r248932