diff options
author | Nick Kledzik <kledzik@apple.com> | 2009-06-04 00:28:45 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2009-06-04 00:28:45 +0000 |
commit | 39d9b419bb1c3cdc9eb807dffd3f0d116dc0fb44 (patch) | |
tree | 4e1b1453bacb85aef8998892b242e71cec8cb694 /tools/lto/LTOCodeGenerator.cpp | |
parent | 214ae9730699e74bdbb1a80526db9992187bf8b6 (diff) | |
download | external_llvm-39d9b419bb1c3cdc9eb807dffd3f0d116dc0fb44.zip external_llvm-39d9b419bb1c3cdc9eb807dffd3f0d116dc0fb44.tar.gz external_llvm-39d9b419bb1c3cdc9eb807dffd3f0d116dc0fb44.tar.bz2 |
<rdar://problem/6940611> libLTO.dylib needs to let linker specify path to assembler
Add lto_codegen_set_assembler_path() API which allows the linker to specify the
path to the assembler tool to run. When assembler is used (instead of compiler)
different command line options are used.
Add LTO_API_VERSION #define so clients (linkers) can conditionalize use of new APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72823 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto/LTOCodeGenerator.cpp')
-rw-r--r-- | tools/lto/LTOCodeGenerator.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index 7aa591a..17c83bb 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -72,7 +72,7 @@ LTOCodeGenerator::LTOCodeGenerator() : _linker("LinkTimeOptimizer", "ld-temp.o"), _target(NULL), _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false), _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), - _nativeObjectFile(NULL), _gccPath(NULL) + _nativeObjectFile(NULL), _gccPath(NULL), _assemblerPath(NULL) { } @@ -128,6 +128,13 @@ void LTOCodeGenerator::setGccPath(const char* path) _gccPath = new sys::Path(path); } +void LTOCodeGenerator::setAssemblerPath(const char* path) +{ + if ( _assemblerPath ) + delete _assemblerPath; + _assemblerPath = new sys::Path(path); +} + void LTOCodeGenerator::addMustPreserveSymbol(const char* sym) { _mustPreserveSymbols[sym] = 1; @@ -220,13 +227,18 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) bool LTOCodeGenerator::assemble(const std::string& asmPath, const std::string& objPath, std::string& errMsg) { - sys::Path gcc; - if ( _gccPath ) { - gcc = *_gccPath; + sys::Path tool; + bool needsCompilerOptions = true; + if ( _assemblerPath ) { + tool = *_assemblerPath; + needsCompilerOptions = false; + } + else if ( _gccPath ) { + tool = *_gccPath; } else { // find compiler driver - gcc = sys::Program::FindProgramByName("gcc"); - if ( gcc.isEmpty() ) { + tool = sys::Program::FindProgramByName("gcc"); + if ( tool.isEmpty() ) { errMsg = "can't locate gcc"; return true; } @@ -235,7 +247,7 @@ bool LTOCodeGenerator::assemble(const std::string& asmPath, // build argument list std::vector<const char*> args; std::string targetTriple = _linker.getModule()->getTargetTriple(); - args.push_back(gcc.c_str()); + args.push_back(tool.c_str()); if ( targetTriple.find("darwin") != targetTriple.size() ) { if (strncmp(targetTriple.c_str(), "i386-apple-", 11) == 0) { args.push_back("-arch"); @@ -275,16 +287,18 @@ bool LTOCodeGenerator::assemble(const std::string& asmPath, args.push_back("armv6"); } } - args.push_back("-c"); - args.push_back("-x"); - args.push_back("assembler"); + if ( needsCompilerOptions ) { + args.push_back("-c"); + args.push_back("-x"); + args.push_back("assembler"); + } args.push_back("-o"); args.push_back(objPath.c_str()); args.push_back(asmPath.c_str()); args.push_back(0); // invoke assembler - if ( sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 0, 0, &errMsg) ) { + if ( sys::Program::ExecuteAndWait(tool, &args[0], 0, 0, 0, 0, &errMsg) ) { errMsg = "error in assembly"; return true; } |