[PATCH] Driver: Add -print-compiler-rt-file-name option.

Shiz hi at shiz.me
Tue May 26 18:22:47 PDT 2015


Hi bogner,

In analogy to -print-libgcc-file-name, this allows a caller to retrieve the full file name to the clang_rt part that contains the builtins. It depends on ToolChain::GetRuntimeLibPath(), posted at  http://reviews.llvm.org/D10050.

This is particularly useful in -nostdlib situations where the caller still wants to use compiler-rt, where -rtlib=compiler_rt is ignored and there is no way to tell the compiler to link to compiler-rt. Still wanting to use the compiler runtime libraries with -nostdlib is a common wish, and even recommended in the GCC man page.

http://reviews.llvm.org/D10052

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp

Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1500,6 +1500,8 @@
 def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">;
 def prebind : Flag<["-"], "prebind">;
 def preload : Flag<["-"], "preload">;
+def print_compiler_rt_file_name : Flag<["-", "--"], "print-compiler-rt-file-name">,
+  HelpText<"Print the library path for \"libclang_rt.builtins.*.a\"">;
 def print_file_name_EQ : Joined<["-", "--"], "print-file-name=">,
   HelpText<"Print the full library path of <file>">, MetaVarName<"<file>">;
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -778,6 +778,12 @@
     return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_compiler_rt_file_name)) {
+    llvm::outs() << TC.GetRuntimeLibPath(ToolChain::RLT_CompilerRT, "builtins")
+                 << "\n";
+    return false;
+  }
+
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
     llvm::outs() << TC.GetRuntimeLibPath(ToolChain::RLT_Libgcc, "") << "\n";
     return false;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10052.26564.patch
Type: text/x-patch
Size: 1307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150527/ebd7c47b/attachment.bin>


More information about the cfe-commits mailing list