LLVM: set module PIC, PIE, and CodeModel

Some simple code from stage1 ported over to stage2.
This commit is contained in:
Andrew Kelley 2022-05-02 21:35:03 -07:00
parent defda6202a
commit ea7142c43f
2 changed files with 13 additions and 0 deletions

View File

@ -340,6 +340,10 @@ pub const Object = struct {
llvm_module.setModuleDataLayout(target_data);
if (options.pic) llvm_module.setModulePICLevel();
if (options.pie) llvm_module.setModulePIELevel();
if (code_model != .Default) llvm_module.setModuleCodeModel(code_model);
return Object{
.gpa = gpa,
.module = options.module.?,

View File

@ -310,6 +310,15 @@ pub const Module = opaque {
pub const setModuleDataLayout = LLVMSetModuleDataLayout;
extern fn LLVMSetModuleDataLayout(*const Module, *const TargetData) void;
pub const setModulePICLevel = ZigLLVMSetModulePICLevel;
extern fn ZigLLVMSetModulePICLevel(module: *const Module) void;
pub const setModulePIELevel = ZigLLVMSetModulePIELevel;
extern fn ZigLLVMSetModulePIELevel(module: *const Module) void;
pub const setModuleCodeModel = ZigLLVMSetModuleCodeModel;
extern fn ZigLLVMSetModuleCodeModel(module: *const Module, code_model: CodeModel) void;
pub const addFunction = LLVMAddFunction;
extern fn LLVMAddFunction(*const Module, Name: [*:0]const u8, FunctionTy: *const Type) *const Value;