phosek created this revision. When -no-canonical-prefixes option is used and argv0 contains only a program name, we need to do a PATH lookup to get an executable path, otherwise the return value won't be a valid path and any subsequent uses of it (e.g. invoking -cc1) will fail with an error.
Repository: rL LLVM https://reviews.llvm.org/D34290 Files: tools/driver/driver.cpp Index: tools/driver/driver.cpp =================================================================== --- tools/driver/driver.cpp +++ tools/driver/driver.cpp @@ -53,8 +53,15 @@ using namespace llvm::opt; std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) { - if (!CanonicalPrefixes) - return Argv0; + if (!CanonicalPrefixes) { + SmallString<128> ExecutablePath(Argv0); + // Do a PATH lookup, if there are no directory components. + if (llvm::sys::path::filename(ExecutablePath) == ExecutablePath) + if (llvm::ErrorOr<std::string> P = + llvm::sys::findProgramByName(ExecutablePath)) + ExecutablePath = *P; + return ExecutablePath.str(); + } // This just needs to be some symbol in the binary; C++ doesn't // allow taking the address of ::main however.
Index: tools/driver/driver.cpp =================================================================== --- tools/driver/driver.cpp +++ tools/driver/driver.cpp @@ -53,8 +53,15 @@ using namespace llvm::opt; std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) { - if (!CanonicalPrefixes) - return Argv0; + if (!CanonicalPrefixes) { + SmallString<128> ExecutablePath(Argv0); + // Do a PATH lookup, if there are no directory components. + if (llvm::sys::path::filename(ExecutablePath) == ExecutablePath) + if (llvm::ErrorOr<std::string> P = + llvm::sys::findProgramByName(ExecutablePath)) + ExecutablePath = *P; + return ExecutablePath.str(); + } // This just needs to be some symbol in the binary; C++ doesn't // allow taking the address of ::main however.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits