[cfe-commits] r108346 - in /cfe/trunk: include/clang/Driver/Driver.h lib/Driver/Driver.cpp lib/Driver/Tools.cpp

Daniel Dunbar daniel at zuster.org
Wed Jul 14 11:46:27 PDT 2010


Author: ddunbar
Date: Wed Jul 14 13:46:27 2010
New Revision: 108346

URL: http://llvm.org/viewvc/llvm-project?rev=108346&view=rev
Log:
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).

Modified:
    cfe/trunk/include/clang/Driver/Driver.h
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=108346&r1=108345&r2=108346&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Wed Jul 14 13:46:27 2010
@@ -62,6 +62,9 @@
   /// 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 @@
   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
   /// @{

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=108346&r1=108345&r2=108346&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jul 14 13:46:27 2010
@@ -75,6 +75,11 @@
   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() {

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=108346&r1=108345&r2=108346&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 14 13:46:27 2010
@@ -1489,8 +1489,7 @@
 
   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 @@
     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 @@
     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,





More information about the cfe-commits mailing list