blob: 3dd9a57373d71afffc5c2a0f138d8ca473376430 [file] [log] [blame]
In simple-chrome, clang is a shell wrapper, it calls clang.elf, which is the
real binary, then, clang.elf calls clang.elf itself. It is the last invocation
"clang.elf -> clang.elf" that breaks, because direct calls to clang.elf misses
all environment setup in clang wrapper. Fix this by calling to clang wrapper
instead of clang.elf binary.
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 52d391fc6971..6e740cf0b304 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -486,6 +486,9 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) {
}
std::string Path = GetExecutablePath(ToolContext.Path, CanonicalPrefixes);
+ size_t PathLen = Path.length();
+ if (PathLen > 4 && Path.substr(PathLen - 4) == ".elf")
+ Path = Path.substr(0, PathLen - 4);
// Whether the cc1 tool should be called inside the current process, or if we
// should spawn a new clang subprocess (old behavior).