diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/docs/CommandGuide/clang.rst | 3 | ||||
| -rw-r--r-- | clang/include/clang/Driver/Options.td | 3 | ||||
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 10 | ||||
| -rw-r--r-- | clang/test/Driver/print-libgcc-file-name.c | 15 |
4 files changed, 28 insertions, 3 deletions
diff --git a/clang/docs/CommandGuide/clang.rst b/clang/docs/CommandGuide/clang.rst index 14c81270e17..c71544915e4 100644 --- a/clang/docs/CommandGuide/clang.rst +++ b/clang/docs/CommandGuide/clang.rst @@ -394,7 +394,8 @@ Driver Options .. option:: -print-libgcc-file-name - Print the library path for "libgcc.a". + Print the library path for the currently used compiler runtime library + ("libgcc.a" or "libclang_rt.builtins.*.a"). .. option:: -print-prog-name=<name> diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index a6b006108fc..ad10bcb2737 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1861,7 +1861,8 @@ def print_file_name_EQ : Joined<["-", "--"], "print-file-name=">, def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>, HelpText<"Enable Objective-C Ivar layout bitmap print trace">; def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">, - HelpText<"Print the library path for \"libgcc.a\"">; + HelpText<"Print the library path for the currently used compiler runtime " + "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">; def print_multi_directory : Flag<["-", "--"], "print-multi-directory">; def print_multi_lib : Flag<["-", "--"], "print-multi-lib">; def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">, diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index f26d61f1d7d..fd0bcfbeba5 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -994,7 +994,15 @@ bool Driver::HandleImmediateArgs(const Compilation &C) { } if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) { - llvm::outs() << GetFilePath("libgcc.a", TC) << "\n"; + ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs()); + switch (RLT) { + case ToolChain::RLT_CompilerRT: + llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n"; + break; + case ToolChain::RLT_Libgcc: + llvm::outs() << GetFilePath("libgcc.a", TC) << "\n"; + break; + } return false; } diff --git a/clang/test/Driver/print-libgcc-file-name.c b/clang/test/Driver/print-libgcc-file-name.c new file mode 100644 index 00000000000..46a0808dfb8 --- /dev/null +++ b/clang/test/Driver/print-libgcc-file-name.c @@ -0,0 +1,15 @@ +// Test that -print-libgcc-file-name correctly respects -rtlib=. + +// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LIBGCC %s +// CHECK-LIBGCC: libgcc.a + +// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ +// RUN: --target=x86_64-pc-linux \ +// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s +// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a + +// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ +// RUN: --target=i686-pc-linux \ +// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s +// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a |

