This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Add -print-runtime-dir
ClosedPublic

Authored by zero9178 on Mar 18 2021, 7:25 AM.

Details

Summary

This patch adds a new command line option to clang which outputs the directory containing clangs runtime libraries to stdout.

The primary use case for this command line flag is for build systems using clang-cl. Build systems when using clang-cl invoke the linker, that is either link or lld-link in this case, directly instead of invoking the compiler for the linking process as is common with the other drivers. This leads to issues when runtime libraries of clang, such as sanitizers or profiling, have to be linked in as the compiler cannot communicate the link directory to the linker.

Using this flag, build systems would be capable of getting the directory containing all of clang's runtime libraries and add it to the linker path.

One such implementation is in LLVM's CMake scripts which currently gets the path to the builtins library and uses the containing directory. This also has issues however when the builtins library does not exist, which AFAIK is not a prerequisite to using clang-cl. More info here: https://reviews.llvm.org/D98786

Diff Detail

Event Timeline

zero9178 created this revision.Mar 18 2021, 7:25 AM
zero9178 requested review of this revision.Mar 18 2021, 7:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2021, 7:25 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rnk accepted this revision.Mar 19 2021, 9:33 AM

lgtm

I'm somewhat surprised this doesn't exist already, but I looked at the -print-* options and don't see anything.

This revision is now accepted and ready to land.Mar 19 2021, 9:33 AM
This revision was landed with ongoing or failed builds.Mar 19 2021, 9:48 AM
This revision was automatically updated to reflect the committed changes.