[Driver] Add -print-runtime-dir
authorMarkus Böck <markus.boeck02@gmail.com>
Fri, 19 Mar 2021 16:47:07 +0000 (17:47 +0100)
committerMarkus Böck <markus.boeck02@gmail.com>
Fri, 19 Mar 2021 16:48:03 +0000 (17:48 +0100)
commitaafc3f7be804d117a632365489a18c3e484a3931
treef482af984b90a14e707df7b13e5cfc7a5cd55c02
parent3aa6a4cb39c4032983bbc0aaeda646ebdd3ebefa
[Driver] Add -print-runtime-dir

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.

Differential Revision: https://reviews.llvm.org/D98868
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/Inputs/resource_dir/lib/windows/clang_rt.builtins-x86_64.lib [new file with mode: 0644]
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-pc-windows-msvc/clang_rt.builtins.lib [new file with mode: 0644]
clang/test/Driver/immediate-options.c