mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
<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
This commit is contained in:
parent
e0f0e0be1c
commit
f5a1c35f1b
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user