Driver: When re'execing clang, use path to the main executable instead of

looking up Clang in the normal search paths (which may end up finding the wrong
clang).

llvm-svn: 108346
This commit is contained in:
Daniel Dunbar 2010-07-14 18:46:27 +00:00
parent 9c3ed5f4d0
commit 9765b9817d
3 changed files with 17 additions and 6 deletions

View File

@ -62,6 +62,9 @@ public:
/// command line.
std::string Dir;
/// The original path to the clang executable.
std::string ClangExecutable;
/// The path to the compiler resource directory.
std::string ResourceDir;
@ -163,6 +166,11 @@ public:
const std::string &getTitle() { return DriverTitle; }
void setTitle(std::string Value) { DriverTitle = Value; }
/// \brief Get the path to the main clang executable.
std::string getClangProgramPath() const {
return ClangExecutable;
}
/// @}
/// @name Primary Functionality
/// @{

View File

@ -75,6 +75,11 @@ Driver::Driver(llvm::StringRef _Name, llvm::StringRef _Dir,
P.appendComponent("clang");
P.appendComponent(CLANG_VERSION_STRING);
ResourceDir = P.str();
// Save the original clang executable path.
P = Dir;
P.appendComponent(Name);
ClangExecutable = P.str();
}
Driver::~Driver() {

View File

@ -1489,8 +1489,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddAllArgs(CmdArgs, options::OPT_undef);
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("clang"));
std::string Exec = getToolChain().getDriver().getClangProgramPath();
// Optionally embed the -cc1 level arguments into the debug info, for build
// analysis.
@ -1510,7 +1509,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(Flags.str()));
}
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
Dest.addCommand(new Command(JA, *this, Exec.c_str(), CmdArgs));
// Explicitly warn that these options are unsupported, even though
// we are allowing compilation to continue.
@ -1589,9 +1588,8 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Input.getFilename());
}
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("clang"));
Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
std::string Exec = getToolChain().getDriver().getClangProgramPath();
Dest.addCommand(new Command(JA, *this, Exec.c_str(), CmdArgs));
}
void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,