[PATCH] D49054: [MinGW] Treat any -lucrt* as replacing -lmsvcrt

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 7 14:52:31 PDT 2018


mstorsjo created this revision.
mstorsjo added reviewers: rnk, martell, compnerd, smeenai.

Since SVN r314138, we check if the user has specified any particular alternative msvcrt/ucrt version, and skip the default -lmsvcrt in those cases.

In addition to the existing names checked, we should also treat a plain -lucrt in the same way, mingw-w64 has now added a separate import library named libucrt.a, in addition to libucrtbase.a.


Repository:
  rC Clang

https://reviews.llvm.org/D49054

Files:
  lib/Driver/ToolChains/MinGW.cpp
  test/Driver/mingw-msvcrt.c


Index: test/Driver/mingw-msvcrt.c
===================================================================
--- test/Driver/mingw-msvcrt.c
+++ test/Driver/mingw-msvcrt.c
@@ -1,6 +1,12 @@
 // RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_DEFAULT %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | FileCheck -check-prefix=CHECK_MSVCR120 %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lucrtbase -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRTBASE %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lucrt -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRT %s
 
 // CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
 // CHECK_MSVCR120: "-lmsvcr120"
 // CHECK_MSVCR120-SAME: "-lmingwex" "-ladvapi32"
+// CHECK_UCRTBASE: "-lucrtbase"
+// CHECK_UCRTBASE-SAME: "-lmingwex" "-ladvapi32"
+// CHECK_UCRT: "-lucrt"
+// CHECK_UCRT-SAME: "-lmingwex" "-ladvapi32"
Index: lib/Driver/ToolChains/MinGW.cpp
===================================================================
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -83,7 +83,7 @@
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
   for (auto Lib : Args.getAllArgValues(options::OPT_l))
-    if (StringRef(Lib).startswith("msvcr") || Lib == "ucrtbase")
+    if (StringRef(Lib).startswith("msvcr") || StringRef(Lib).startswith("ucrt"))
       return;
   CmdArgs.push_back("-lmsvcrt");
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49054.154502.patch
Type: text/x-patch
Size: 1440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180707/4ff1629e/attachment-0001.bin>


More information about the cfe-commits mailing list