typedef enum {
LTO_CODEGEN_PIC_MODEL_STATIC = 0,
LTO_CODEGEN_PIC_MODEL_DYNAMIC = 1,
- LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2
+ LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC = 2,
+ LTO_CODEGEN_PIC_MODEL_DEFAULT = 3
} lto_codegen_model;
/** opaque reference to a loaded object module */
LTOCodeGenerator::LTOCodeGenerator()
: Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
- CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), NativeObjectFile(NULL),
+ CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT), NativeObjectFile(NULL),
DiagHandler(NULL), DiagContext(NULL) {
initializeLTOPasses();
}
case LTO_CODEGEN_PIC_MODEL_STATIC:
case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
+ case LTO_CODEGEN_PIC_MODEL_DEFAULT:
CodeModel = model;
return;
}
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
RelocModel = Reloc::DynamicNoPIC;
break;
+ case LTO_CODEGEN_PIC_MODEL_DEFAULT:
+ // RelocModel is already the default, so leave it that way.
+ break;
}
// construct LTOModule, hand over ownership of module and target
LTOCodeGenerator CodeGen;
- CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC);
+ switch (RelocModel) {
+ case Reloc::Static:
+ CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_STATIC);
+ break;
+ case Reloc::PIC_:
+ CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC);
+ break;
+ case Reloc::DynamicNoPIC:
+ CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC);
+ break;
+ default:
+ CodeGen.setCodePICModel(LTO_CODEGEN_PIC_MODEL_DEFAULT);
+ }
+
CodeGen.setDebugInfo(LTO_DEBUG_MODEL_DWARF);
CodeGen.setTargetOptions(Options);