authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-02 21:35:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-02 22:14:17-07:00
logea7142c43f6a7539f6deb1e77ae5af168fde613e
treee46954a8f6db1a37802eeaf708f0619fb9cca701
parentdefda6202a5c9fd50f465b3a6a9728ba5d636a38

LLVM: set module PIC, PIE, and CodeModel

Some simple code from stage1 ported over to stage2.

2 files changed, 13 insertions(+), 0 deletions(-)

src/codegen/llvm.zig+4
...@@ -340,6 +340,10 @@ pub const Object = struct {...@@ -340,6 +340,10 @@ pub const Object = struct {
340340
341 llvm_module.setModuleDataLayout(target_data);341 llvm_module.setModuleDataLayout(target_data);
342342
343 if (options.pic) llvm_module.setModulePICLevel();
344 if (options.pie) llvm_module.setModulePIELevel();
345 if (code_model != .Default) llvm_module.setModuleCodeModel(code_model);
346
343 return Object{347 return Object{
344 .gpa = gpa,348 .gpa = gpa,
345 .module = options.module.?,349 .module = options.module.?,
src/codegen/llvm/bindings.zig+9
...@@ -310,6 +310,15 @@ pub const Module = opaque {...@@ -310,6 +310,15 @@ pub const Module = opaque {
310 pub const setModuleDataLayout = LLVMSetModuleDataLayout;310 pub const setModuleDataLayout = LLVMSetModuleDataLayout;
311 extern fn LLVMSetModuleDataLayout(*const Module, *const TargetData) void;311 extern fn LLVMSetModuleDataLayout(*const Module, *const TargetData) void;
312312
313 pub const setModulePICLevel = ZigLLVMSetModulePICLevel;
314 extern fn ZigLLVMSetModulePICLevel(module: *const Module) void;
315
316 pub const setModulePIELevel = ZigLLVMSetModulePIELevel;
317 extern fn ZigLLVMSetModulePIELevel(module: *const Module) void;
318
319 pub const setModuleCodeModel = ZigLLVMSetModuleCodeModel;
320 extern fn ZigLLVMSetModuleCodeModel(module: *const Module, code_model: CodeModel) void;
321
313 pub const addFunction = LLVMAddFunction;322 pub const addFunction = LLVMAddFunction;
314 extern fn LLVMAddFunction(*const Module, Name: [*:0]const u8, FunctionTy: *const Type) *const Value;323 extern fn LLVMAddFunction(*const Module, Name: [*:0]const u8, FunctionTy: *const Type) *const Value;
315324