r263422 - [Driver] Enable --rtlib option for MSVC target
Andrey Turetskiy via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 14 04:19:43 PDT 2016
Author: aturetsk
Date: Mon Mar 14 06:19:43 2016
New Revision: 263422
URL: http://llvm.org/viewvc/llvm-project?rev=263422&view=rev
Log:
[Driver] Enable --rtlib option for MSVC target
This enables "--rtlib compiler-rt" option under MSVC environment.
Patch by Roman Shirokiy.
Differential Revision: http://reviews.llvm.org/D17453
Added:
cfe/trunk/test/Driver/msvc-compiler-rt.c (with props)
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/nostdlib.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=263422&r1=263421&r2=263422&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar 14 06:19:43 2016
@@ -8948,7 +8948,16 @@ static void AddRunTimeLibs(const ToolCha
}
break;
case ToolChain::RLT_Libgcc:
- AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
+ // Make sure libgcc is not used under MSVC environment by default
+ if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+ // Issue error diagnostic if libgcc is explicitly specified
+ // through command line as --rtlib option argument.
+ if (Args.hasArg(options::OPT_rtlib_EQ)) {
+ TC.getDriver().Diag(diag::err_drv_unsupported_rtlib_for_platform)
+ << Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "MSVC";
+ }
+ } else
+ AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
break;
}
}
@@ -9754,6 +9763,12 @@ void visualstudio::Linker::ConstructJob(
}
}
+ // Add compiler-rt lib in case if it was explicitly
+ // specified as an argument for --rtlib option.
+ if (!Args.hasArg(options::OPT_nostdlib)) {
+ AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
+ }
+
// Add filenames, libraries, and other linker inputs.
for (const auto &Input : Inputs) {
if (Input.isFilename()) {
Added: cfe/trunk/test/Driver/msvc-compiler-rt.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msvc-compiler-rt.c?rev=263422&view=auto
==============================================================================
--- cfe/trunk/test/Driver/msvc-compiler-rt.c (added)
+++ cfe/trunk/test/Driver/msvc-compiler-rt.c Mon Mar 14 06:19:43 2016
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix MSVC-COMPILER-RT
+// RUN: not %clang %s -target x86_64-pc-windows-msvc --rtlib=libgcc 2>&1 | FileCheck %s -check-prefix CHECK-ERROR
+
+// MSVC-COMPILER-RT: "{{.*}}clang_rt.builtins{{.*}}"
+// CHECK-ERROR: unsupported runtime library 'libgcc' for platform 'MSVC'
Propchange: cfe/trunk/test/Driver/msvc-compiler-rt.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/Driver/msvc-compiler-rt.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Propchange: cfe/trunk/test/Driver/msvc-compiler-rt.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cfe/trunk/test/Driver/nostdlib.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlib.c?rev=263422&r1=263421&r2=263422&view=diff
==============================================================================
--- cfe/trunk/test/Driver/nostdlib.c (original)
+++ cfe/trunk/test/Driver/nostdlib.c Mon Mar 14 06:19:43 2016
@@ -22,6 +22,10 @@
// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
// RUN: | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
//
+// RUN: %clang -target x86_64-pc-windows-msvc -nostdlib --rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+// RUN: %clang -target x86_64-pc-windows-msvc --rtlib=compiler-rt -nostdlib -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-NOSTDLIB
+//
// CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt'
// CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.builtins-i686.a"
+// CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt'
More information about the cfe-commits
mailing list