diff options
author | Reid Kleckner <rnk@google.com> | 2015-09-10 23:28:06 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-09-10 23:28:06 +0000 |
commit | 89d4b1a77cae9ddf1ddaf684a5a3eccd4478c479 (patch) | |
tree | 20d5bbfa1a15a4361580a352da22b9be169c4b23 /llvm/lib/Support/Unix/Path.inc | |
parent | c536bd9e73a4a525771e41b15b209dd1149040cd (diff) | |
download | bcm5719-llvm-89d4b1a77cae9ddf1ddaf684a5a3eccd4478c479.tar.gz bcm5719-llvm-89d4b1a77cae9ddf1ddaf684a5a3eccd4478c479.zip |
ScanDirForExecutable on Windows fails to find executables with the "exe" extension in name
When the driver tries to locate a program by its name, e.g. a linker, it
scans the paths provided by the toolchain using the ScanDirForExecutable
function. If the lookup fails, the driver uses
llvm::sys::findProgramByName. Unlike llvm::sys::findProgramByName,
ScanDirForExecutable is not aware of file extensions. If the program has
the "exe" extension in its name, which is very common on Windows,
ScanDirForExecutable won't find it under the toolchain-provided paths.
This patch changes the Windows version of the "`can_execute`" function
called by ScanDirForExecutable to respect file extensions, similarly to
llvm::sys::findProgramByName.
Patch by Oleg Ranevskyy
Reviewers: rnk
Differential Revision: http://reviews.llvm.org/D12711
llvm-svn: 247358
Diffstat (limited to 'llvm/lib/Support/Unix/Path.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index a77efcca8f5..93e5654f284 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -325,6 +325,10 @@ std::error_code access(const Twine &Path, AccessMode Mode) { return std::error_code(); } +bool can_execute(const Twine &Path) { + return !access(Path, AccessMode::Execute); +} + bool equivalent(file_status A, file_status B) { assert(status_known(A) && status_known(B)); return A.fs_st_dev == B.fs_st_dev && |