diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-04-30 15:24:09 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-04-30 15:24:09 +0000 |
commit | 195bea3498a7de1d84ace6d4685f02d4d7485468 (patch) | |
tree | ef987190535265c94f3c479cab77548c8c8517ac /tools/lto | |
parent | 4e5ea553d055512b0b8aa098e363ae17bafda957 (diff) | |
download | llvm-195bea3498a7de1d84ace6d4685f02d4d7485468.tar.gz llvm-195bea3498a7de1d84ace6d4685f02d4d7485468.tar.bz2 llvm-195bea3498a7de1d84ace6d4685f02d4d7485468.tar.xz |
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
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/LTOCodeGenerator.cpp | 24 | ||||
-rw-r--r-- | tools/lto/LTOCodeGenerator.h | 2 | ||||
-rw-r--r-- | tools/lto/lto.cpp | 8 |
3 files changed, 28 insertions, 6 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index 70744c9a8f..d3a3f7f7b8 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -71,7 +71,7 @@ LTOCodeGenerator::LTOCodeGenerator() : _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 @@ bool LTOCodeGenerator::setCodePICModel(lto_codegen_model model, 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 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) 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 diff --git a/tools/lto/LTOCodeGenerator.h b/tools/lto/LTOCodeGenerator.h index 4a28136f0a..57398b0650 100644 --- a/tools/lto/LTOCodeGenerator.h +++ b/tools/lto/LTOCodeGenerator.h @@ -36,6 +36,7 @@ public: bool addModule(class LTOModule*, std::string& errMsg); bool setDebugInfo(lto_debug_model, std::string& errMsg); bool setCodePICModel(lto_codegen_model, std::string& errMsg); + void setGccPath(const char* path); void addMustPreserveSymbol(const char* sym); bool writeMergedModules(const char* path, std::string& errMsg); @@ -59,6 +60,7 @@ private: StringSet _mustPreserveSymbols; llvm::MemoryBuffer* _nativeObjectFile; std::vector<const char*> _codegenOptions; + llvm::sys::Path* _gccPath; }; #endif // LTO_CODE_GENERATOR_H diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 227823f32f..5c3f90aa48 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -202,6 +202,14 @@ bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) } // +// sets the path to gcc +// +void lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path) +{ + cg->setGccPath(path); +} + +// // adds to a list of all global symbols that must exist in the final // generated code. If a function is not listed there, it might be // inlined into every usage and optimized away. |