diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-08-10 18:55:09 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-08-10 18:55:09 +0000 |
commit | 98197e55c10176c3ef9100f7d852abbd2347225f (patch) | |
tree | 3b00eb54a98821ffcc4bfa091d2181d74f1a0c0c /tools | |
parent | 9db3ea46cb7bd6bdf108d314daffd0dfd50a73fe (diff) | |
download | llvm-98197e55c10176c3ef9100f7d852abbd2347225f.tar.gz llvm-98197e55c10176c3ef9100f7d852abbd2347225f.tar.bz2 llvm-98197e55c10176c3ef9100f7d852abbd2347225f.tar.xz |
Make it possible to set the flags passed to the assembler.
Nick, please review.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110705 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gold/gold-plugin.cpp | 12 | ||||
-rw-r--r-- | tools/lto/LTOCodeGenerator.cpp | 13 | ||||
-rw-r--r-- | tools/lto/LTOCodeGenerator.h | 2 | ||||
-rw-r--r-- | tools/lto/lto.cpp | 10 |
4 files changed, 37 insertions, 0 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 207c0d8b46..d649ccb048 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -66,6 +66,7 @@ namespace options { static generate_bc generate_bc_file = BC_NO; static std::string bc_path; static std::string as_path; + static std::vector<std::string> as_args; static std::vector<std::string> pass_through; static std::string extra_library_path; static std::string triple; @@ -91,6 +92,9 @@ namespace options { } else { as_path = opt.substr(strlen("as=")); } + } else if (opt.startswith("as-arg=")) { + llvm::StringRef item = opt.substr(strlen("as-arg=")); + as_args.push_back(item.str()); } else if (opt.startswith("extra-library-path=")) { extra_library_path = opt.substr(strlen("extra_library_path=")); } else if (opt.startswith("pass-through=")) { @@ -401,6 +405,14 @@ static ld_plugin_status all_symbols_read_hook(void) { sys::Path p = sys::Program::FindProgramByName(options::as_path); lto_codegen_set_assembler_path(cg, p.c_str()); } + if (!options::as_args.empty()) { + std::vector<const char *> as_args_p; + for (std::vector<std::string>::iterator I = options::as_args.begin(), + E = options::as_args.end(); I != E; ++I) { + as_args_p.push_back(I->c_str()); + } + lto_codegen_set_assembler_args(cg, &as_args_p[0], as_args_p.size()); + } // Pass through extra options to the code generator. if (!options::extra.empty()) { for (std::vector<std::string>::iterator it = options::extra.begin(); diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index 911fddfe18..7850b5d6d2 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -126,6 +126,14 @@ void LTOCodeGenerator::setAssemblerPath(const char* path) _assemblerPath = new sys::Path(path); } +void LTOCodeGenerator::setAssemblerArgs(const char** args, int nargs) +{ + for (int i = 0; i < nargs; ++i) { + const char *arg = args[i]; + _assemblerArgs.push_back(arg); + } +} + void LTOCodeGenerator::addMustPreserveSymbol(const char* sym) { _mustPreserveSymbols[sym] = 1; @@ -257,6 +265,11 @@ bool LTOCodeGenerator::assemble(const std::string& asmPath, args.push_back("-c"); args.push_back("-x"); args.push_back("assembler"); + } else { + for (std::vector<std::string>::iterator I = _assemblerArgs.begin(), + E = _assemblerArgs.end(); I != E; ++I) { + args.push_back(I->c_str()); + } } args.push_back("-o"); args.push_back(objPath.c_str()); diff --git a/tools/lto/LTOCodeGenerator.h b/tools/lto/LTOCodeGenerator.h index cac3b8c8bf..9086befc26 100644 --- a/tools/lto/LTOCodeGenerator.h +++ b/tools/lto/LTOCodeGenerator.h @@ -37,6 +37,7 @@ struct LTOCodeGenerator { bool setDebugInfo(lto_debug_model, std::string& errMsg); bool setCodePICModel(lto_codegen_model, std::string& errMsg); void setAssemblerPath(const char* path); + void setAssemblerArgs(const char** args, int nargs); void addMustPreserveSymbol(const char* sym); bool writeMergedModules(const char* path, std::string& errMsg); @@ -62,6 +63,7 @@ private: llvm::MemoryBuffer* _nativeObjectFile; std::vector<const char*> _codegenOptions; llvm::sys::Path* _assemblerPath; + std::vector<std::string> _assemblerArgs; }; #endif // LTO_CODE_GENERATOR_H diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index a299dd187d..703447b499 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -218,6 +218,16 @@ void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path) cg->setAssemblerPath(path); } + +// +// sets extra arguments that libLTO should pass to the assembler +// +void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char** args, + int nargs) +{ + cg->setAssemblerArgs(args, nargs); +} + // // 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 |