[PATCH] D63775: [LLD][COFF] Case insensitive compares for /nodefaultlib

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 15:09:40 PDT 2019


aganea updated this revision to Diff 206536.
aganea marked an inline comment as done.
aganea added a comment.

Case-insensitive on Linux as requested.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63775/new/

https://reviews.llvm.org/D63775

Files:
  COFF/Config.h
  COFF/Driver.cpp
  test/COFF/nodefaultlib.test


Index: test/COFF/nodefaultlib.test
===================================================================
--- test/COFF/nodefaultlib.test
+++ test/COFF/nodefaultlib.test
@@ -29,3 +29,10 @@
 
 # RUN: env LIB=%T lld-link /out:%t.exe /entry:main \
 # RUN:   /subsystem:console hello64.obj /defaultlib:std64.lib
+
+MSVC stamps uppercase references in OBJ directives, thus ensure that passing lowercase 'libcmt' and 'oldnames' to /nodefaultlib works.
+# RUN: lld-link %S/Inputs/precomp.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib:libcmt /nodefaultlib:oldnames /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf
+# RUN: llvm-pdbutil dump -modules %t.pdb | FileCheck %s -check-prefix UPPERCASE
+
+UPPERCASE-NOT: OLDNAMES
+UPPERCASE-NOT: LIBCMT
Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -356,7 +356,7 @@
       parseMerge(Arg->getValue());
       break;
     case OPT_nodefaultlib:
-      Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()));
+      Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()).lower());
       break;
     case OPT_section:
       parseSection(Arg->getValue());
@@ -457,7 +457,7 @@
     return None;
 
   StringRef Path = doFindLib(Filename);
-  if (Config->NoDefaultLibs.count(Path))
+  if (Config->NoDefaultLibs.count(Path.lower()))
     return None;
 
   if (Optional<sys::fs::UniqueID> ID = getUniqueID(Path))
@@ -1240,7 +1240,7 @@
 
   // Handle /nodefaultlib:<filename>
   for (auto *Arg : Args.filtered(OPT_nodefaultlib))
-    Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()));
+    Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()).lower());
 
   // Handle /nodefaultlib
   if (Args.hasArg(OPT_nodefaultlib_all))
Index: COFF/Config.h
===================================================================
--- COFF/Config.h
+++ COFF/Config.h
@@ -115,7 +115,7 @@
   // Symbols in this set are considered as live by the garbage collector.
   std::vector<Symbol *> GCRoot;
 
-  std::set<StringRef> NoDefaultLibs;
+  std::set<std::string> NoDefaultLibs;
   bool NoDefaultLibAll = false;
 
   // True if we are creating a DLL.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63775.206536.patch
Type: text/x-patch
Size: 2185 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190625/330fd5ff/attachment.bin>


More information about the llvm-commits mailing list