diff options
| author | George Rimar <grimar@accesssoftek.com> | 2015-10-08 16:03:19 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2015-10-08 16:03:19 +0000 |
| commit | 87780300f624e5437aee0c5a2d7ca30ea87b5ba2 (patch) | |
| tree | ce0a3b2249242a5a077e319a0623f1d64c9f0ce2 /llvm/lib/Support | |
| parent | b1cfcd4a53e34a88ecf937555b763f94051d3dff (diff) | |
| download | bcm5719-llvm-87780300f624e5437aee0c5a2d7ca30ea87b5ba2.tar.gz bcm5719-llvm-87780300f624e5437aee0c5a2d7ca30ea87b5ba2.zip | |
Windows: Fixed sys::findProgramByName to work with files containing dot in their name.
Problem was in SearchPathW function that does not attach an extension if file already has one.
That does not work for executables like ld.lld2 for example which require to have .exe extension but SearchPath thinks that its "lld2".
Solution was to add the extension manually.
Differential Revision: http://reviews.llvm.org/D13536
llvm-svn: 249696
Diffstat (limited to 'llvm/lib/Support')
| -rw-r--r-- | llvm/lib/Support/Windows/Program.inc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Support/Windows/Program.inc b/llvm/lib/Support/Windows/Program.inc index fe83118b064..e2a167c0a2b 100644 --- a/llvm/lib/Support/Windows/Program.inc +++ b/llvm/lib/Support/Windows/Program.inc @@ -75,8 +75,15 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name, do { U16Result.reserve(Len); - Len = ::SearchPathW(Path, c_str(U16Name), - U16Ext.empty() ? nullptr : c_str(U16Ext), + // Lets attach the extension manually. That is needed for files + // with a point in name like aaa.bbb. SearchPathW will not add extension + // from its argument to such files because it thinks they already had one. + SmallVector<wchar_t, MAX_PATH> U16NameExt; + if (std::error_code EC = + windows::UTF8ToUTF16(Twine(Name + Ext).str(), U16NameExt)) + return EC; + + Len = ::SearchPathW(Path, c_str(U16NameExt), nullptr, U16Result.capacity(), U16Result.data(), nullptr); } while (Len > U16Result.capacity()); |

