Allow a user of libLTO to specify the full pathname of the gcc executable to
run when assembling.
Wire this up to the gold plugin. You can now pass --plugin-opt gcc=/foo/bar/gcc
and it will run that gcc instead of looking for it on the path.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70490 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 70744c9..d3a3f7f 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -71,7 +71,7 @@
: _linker("LinkTimeOptimizer", "ld-temp.o"), _target(NULL),
_emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
_codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
- _nativeObjectFile(NULL)
+ _nativeObjectFile(NULL), _gccPath(NULL)
{
}
@@ -120,6 +120,13 @@
return true;
}
+void LTOCodeGenerator::setGccPath(const char* path)
+{
+ if ( _gccPath )
+ delete _gccPath;
+ _gccPath = new sys::Path(path);
+}
+
void LTOCodeGenerator::addMustPreserveSymbol(const char* sym)
{
_mustPreserveSymbols[sym] = 1;
@@ -212,11 +219,16 @@
bool LTOCodeGenerator::assemble(const std::string& asmPath,
const std::string& objPath, std::string& errMsg)
{
- // find compiler driver
- const sys::Path gcc = sys::Program::FindProgramByName("gcc");
- if ( gcc.isEmpty() ) {
- errMsg = "can't locate gcc";
- return true;
+ sys::Path gcc;
+ if ( _gccPath ) {
+ gcc = *_gccPath;
+ } else {
+ // find compiler driver
+ gcc = sys::Program::FindProgramByName("gcc");
+ if ( gcc.isEmpty() ) {
+ errMsg = "can't locate gcc";
+ return true;
+ }
}
// build argument list