[PATCH] D25932: Unconditionally pass `-lto_library` to the linker on Darwin

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 21 14:11:22 PST 2016

rnk added a comment.

In https://reviews.llvm.org/D25932#601820, @mehdi_amini wrote:

> We ship `clang + libLTO + ld64` bundled in the toolchain, so even if you don't package libLTO yourself, it is already accessible from the linker: it will use the one in the toolchain when needed.
> I don't have an immediate idea to prevent this and have the linker issue an error (other than removing manually libLTO from the Xcode installation).

So, even if clang doesn't pass -lto_library to ld64, ld64 will auto-discover the bundled libLTO that happens to be next to it? That could go badly.

> This is the motivation behind the warning I believe: we're trying to prevent this situation where a user would have clang but not his own libLTO and may encounter an unexpected issue. Even when the user does not opt-in to build his own project with LTO enabled, there can be static archive dependencies that contain bitcode.

I guess ld64 doesn't expose a flag like `-fno-lto` to disable this completely? Maybe we could pass `-lto_library /dev/null` or something?



More information about the cfe-commits mailing list