Page MenuHomePhabricator

[Driver][Windows] Add dependent lib argument for profile instr generate
ClosedPublic

Authored by russell.gallop on Thu, May 9, 9:51 AM.

Details

Summary

This is needed so lld-link can find clang_rt.profile when self hosting on Windows with PGO.

Trying to self host on Windows with PGO runs into undefined symbols as lld-link doesn't know to link clang_rt.profile as discussed here:
http://lists.llvm.org/pipermail/llvm-dev/2019-January/129500.html

Using clang-cl as a linker knows to add the library but self hosting, using -DCMAKE_LINKER=<...>/lld-link.exe doesn't. I think that the cleanest way to make this work is to add a dependent library when using profile-instr-generate on Windows.

Note some cmake changes are also required to get PGO self hosting on Windows working. I will post them separately.

Diff Detail

Repository
rC Clang

Event Timeline

russell.gallop created this revision.Thu, May 9, 9:51 AM
rnk added a comment.Thu, May 9, 1:56 PM

Thanks, I would like to do this for the sanitizers as well, since this is a constant pain point for users, who have to come up with an architecture-dependent filename (clang_rt.asan-dynamic-$arch.lib or something).

clang/lib/Driver/ToolChains/Clang.cpp
787 ↗(On Diff #198861)

This won't work with ld.bfd, so I would restrict this to a Windows MSVC environment. For mingw, I'd expect the user to call the compiler to link, and the right library path to be supplied to the linker by the compiler driver.

Prevent adding -dependent-lib on mingw32 and add tests.

In D61742#1497259, @rnk wrote:

Thanks, I would like to do this for the sanitizers as well, since this is a constant pain point for users

That would be good. I think that this might already work for UBSan.

russell.gallop marked an inline comment as done.Fri, May 10, 7:31 AM
dmajor added a subscriber: dmajor.Mon, May 13, 6:57 AM
rnk accepted this revision.Mon, May 13, 1:37 PM

lgtm

This revision is now accepted and ready to land.Mon, May 13, 1:37 PM
This revision was automatically updated to reflect the committed changes.