[lld] r220508 - [PECOFF] Fix /nodefaultlib option.
Rui Ueyama
ruiu at google.com
Thu Oct 23 13:42:07 PDT 2014
Author: ruiu
Date: Thu Oct 23 15:42:07 2014
New Revision: 220508
URL: http://llvm.org/viewvc/llvm-project?rev=220508&view=rev
Log:
[PECOFF] Fix /nodefaultlib option.
/nodefaultlib argument is a path name, so that needs to be compared
case-insensitive way. Also the ".lib" extension should be ignored.
Modified:
lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=220508&r1=220507&r2=220508&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Thu Oct 23 15:42:07 2014
@@ -248,9 +248,17 @@ public:
}
void setAlternateName(StringRef def, StringRef weak);
- void addNoDefaultLib(StringRef path) { _noDefaultLibs.insert(path); }
+ void addNoDefaultLib(StringRef path) {
+ if (path.endswith_lower(".lib"))
+ _noDefaultLibs.insert(path.drop_back(4).lower());
+ else
+ _noDefaultLibs.insert(path.lower());
+ }
+
bool hasNoDefaultLib(StringRef path) const {
- return _noDefaultLibs.count(path) == 1;
+ if (path.endswith_lower(".lib"))
+ return _noDefaultLibs.count(path.drop_back(4).lower()) > 0;
+ return _noDefaultLibs.count(path.lower()) > 0;
}
void setNoDefaultLibAll(bool val) { _noDefaultLibAll = val; }
Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=220508&r1=220507&r2=220508&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Thu Oct 23 15:42:07 2014
@@ -416,6 +416,15 @@ TEST_F(WinLinkParserTest, NoDefaultLib)
EXPECT_EQ("kernel32.lib", inputFile(2, 0));
}
+TEST_F(WinLinkParserTest, NoDefaultLibCase) {
+ EXPECT_TRUE(parse("link.exe", "/defaultlib:user32",
+ "/defaultlib:kernel32", "/nodefaultlib:USER32.LIB", "a.obj",
+ nullptr));
+ EXPECT_EQ(3, inputFileCount());
+ EXPECT_EQ("a.obj", inputFile(0));
+ EXPECT_EQ("kernel32.lib", inputFile(2, 0));
+}
+
TEST_F(WinLinkParserTest, NoDefaultLibAll) {
EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
"/defaultlib:kernel32", "/nodefaultlib", "a.obj", nullptr));
More information about the llvm-commits
mailing list