summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2009-06-03 22:52:12 +0000
committerNick Kledzik <kledzik@apple.com>2009-06-03 22:52:12 +0000
commitf5a1c35f1b62556d31b95e874863b262ef46f974 (patch)
tree107577583e180247ea4143984a87af993842b389 /tools
parente0f0e0be1c5f6f80cd866d84643509ef399eec96 (diff)
downloadllvm-f5a1c35f1b62556d31b95e874863b262ef46f974.tar.gz
llvm-f5a1c35f1b62556d31b95e874863b262ef46f974.tar.bz2
llvm-f5a1c35f1b62556d31b95e874863b262ef46f974.tar.xz
<rdar://problem/6941517> C++ static constructors not preserved for static executable using LTO
Move setRelocationModel() to be called before TargetMachine is instantiated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72816 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/lto/LTOCodeGenerator.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index dcbae95bd6..7aa591ab74 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -304,6 +304,20 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
if ( march == NULL )
return true;
+ // The relocation model is actually a static member of TargetMachine
+ // and needs to be set before the TargetMachine is instantiated.
+ switch( _codeModel ) {
+ case LTO_CODEGEN_PIC_MODEL_STATIC:
+ TargetMachine::setRelocationModel(Reloc::Static);
+ break;
+ case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
+ TargetMachine::setRelocationModel(Reloc::PIC_);
+ break;
+ case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
+ TargetMachine::setRelocationModel(Reloc::DynamicNoPIC);
+ break;
+ }
+
// construct LTModule, hand over ownership of module and target
std::string FeatureStr =
getFeatureString(_linker.getModule()->getTargetTriple().c_str());
@@ -363,19 +377,6 @@ bool LTOCodeGenerator::generateAssemblyCode(raw_ostream& out,
if ( _target->getTargetAsmInfo()->doesSupportExceptionHandling() )
llvm::ExceptionHandling = true;
- // set codegen model
- switch( _codeModel ) {
- case LTO_CODEGEN_PIC_MODEL_STATIC:
- _target->setRelocationModel(Reloc::Static);
- break;
- case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
- _target->setRelocationModel(Reloc::PIC_);
- break;
- case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
- _target->setRelocationModel(Reloc::DynamicNoPIC);
- break;
- }
-
// if options were requested, set them
if ( !_codegenOptions.empty() )
cl::ParseCommandLineOptions(_codegenOptions.size(),