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/
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;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to