[lld] r187259 - [PECOFF][Driver] Add ".lib" extension to the path given with /defaultlib.
Rui Ueyama
ruiu at google.com
Fri Jul 26 15:22:26 PDT 2013
Author: ruiu
Date: Fri Jul 26 17:22:26 2013
New Revision: 187259
URL: http://llvm.org/viewvc/llvm-project?rev=187259&view=rev
Log:
[PECOFF][Driver] Add ".lib" extension to the path given with /defaultlib.
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=187259&r1=187258&r2=187259&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Fri Jul 26 17:22:26 2013
@@ -236,6 +236,15 @@ bool handleFailIfMismatchOption(StringRe
return true;
}
+// Add ".lib" extension if the path does not already have the extension to mimic
+// link.exe behavior.
+StringRef canonicalizeImportLibraryPath(PECOFFTargetInfo &info, StringRef path) {
+ std::string s(path.lower());
+ if (StringRef(s).endswith(".lib"))
+ return path;
+ return info.allocateString(std::string(path).append(".lib"));
+}
+
// Process "LINK" environment variable. If defined, the value of the variable
// should be processed as command line arguments.
std::vector<const char *> processLinkEnv(PECOFFTargetInfo &info,
@@ -442,7 +451,7 @@ bool WinLinkDriver::parse(int argc, cons
// specified by the option should have lower precedence than the other files
// added above, which is important for link.exe compatibility.
for (const StringRef path : defaultLibs)
- info.appendLibraryFile(path);
+ info.appendLibraryFile(canonicalizeImportLibraryPath(info, path));
// If /out option was not specified, the default output file name is
// constructed by replacing an extension of the first input file
Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=187259&r1=187258&r2=187259&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Fri Jul 26 17:22:26 2013
@@ -112,10 +112,12 @@ TEST_F(WinLinkParserTest, MinMajorMinorO
}
TEST_F(WinLinkParserTest, DefaultLib) {
- EXPECT_FALSE(parse("link.exe", "/defaultlib:user32.lib", "a.obj", nullptr));
- EXPECT_EQ(2, inputFileCount());
+ EXPECT_FALSE(parse("link.exe", "/defaultlib:user32.lib",
+ "/defaultlib:kernel32", "a.obj", nullptr));
+ EXPECT_EQ(3, inputFileCount());
EXPECT_EQ("a.obj", inputFile(0));
EXPECT_EQ("user32.lib", inputFile(1));
+ EXPECT_EQ("kernel32.lib", inputFile(2));
}
TEST_F(WinLinkParserTest, Base) {
More information about the llvm-commits
mailing list