[PATCH] D44808: Fix lib.exe detection when running within MSVC toolchain
Alexandre Ganea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 22 14:52:25 PDT 2018
aganea created this revision.
aganea added reviewers: rnk, ruiu.
Herald added a subscriber: llvm-commits.
Fixed llvm-ar executable casing detection.
We ran into a case where llvm-lib.exe is used as lib.exe, but the MSVC v140 toolchain ends up reading the executable name as Lib.exe (first L uppercase)
This prevents llvm-lib from properly detecting the tool as 'lib.exe' and ends up printing the help page.
The culpit was the following command, generated by msbuild:
1> C:\Program Files (x86)\MSBuild\14.0\bin\Tracker.exe /d "C:\Program Files (x86)\MSBuild\14.0\bin\FileTracker32.dll" /i F:\path\mylib.tlog /r F:\path\mylib.OBJ /c "C:\Program Files (x86)\LLVM\msbuild-bin\Lib.exe" /OUT:"..\..\..\..\tmp\mylib.lib" /NOLOGO /MACHINE:X64 /ignore:4098,4099,4217,4221 ..\..\..\..\tmp\mylib.obj
Repository:
rL LLVM
https://reviews.llvm.org/D44808
Files:
llvm/tools/llvm-ar/llvm-ar.cpp
Index: llvm/tools/llvm-ar/llvm-ar.cpp
===================================================================
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -855,11 +855,11 @@
llvm::InitializeAllAsmParsers();
StringRef Stem = sys::path::stem(ToolName);
- if (Stem.find("dlltool") != StringRef::npos)
+ if (Stem.find_lower("dlltool") != StringRef::npos)
return dlltoolDriverMain(makeArrayRef(argv, argc));
- if (Stem.find("ranlib") == StringRef::npos &&
- Stem.find("lib") != StringRef::npos)
+ if (Stem.find_lower("ranlib") == StringRef::npos &&
+ Stem.find_lower("lib") != StringRef::npos)
return libDriverMain(makeArrayRef(argv, argc));
for (int i = 1; i < argc; i++) {
@@ -887,9 +887,9 @@
" This program archives bitcode files into single libraries\n"
);
- if (Stem.find("ranlib") != StringRef::npos)
+ if (Stem.find_lower("ranlib") != StringRef::npos)
return ranlib_main();
- if (Stem.find("ar") != StringRef::npos)
+ if (Stem.find_lower("ar") != StringRef::npos)
return ar_main();
fail("Not ranlib, ar, lib or dlltool!");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44808.139516.patch
Type: text/x-patch
Size: 1119 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180322/36593857/attachment.bin>
More information about the llvm-commits
mailing list