aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Driver/Driver.h8
-rw-r--r--lib/Driver/Driver.cpp5
-rw-r--r--lib/Driver/Tools.cpp10
3 files changed, 17 insertions, 6 deletions
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h
index 153981f842..bb578b516c 100644
--- a/include/clang/Driver/Driver.h
+++ b/include/clang/Driver/Driver.h
@@ -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
/// @{
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 5da7908434..2fc0a5354d 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -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() {
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 14744998f1..f423d4e3b9 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -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,