zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit ea7142c43f6a7539f6deb1e77ae5af168fde613e (tree)
parent defda6202a5c9fd50f465b3a6a9728ba5d636a38
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon,  2 May 2022 21:35:03 -0700

LLVM: set module PIC, PIE, and CodeModel

Some simple code from stage1 ported over to stage2.

Diffstat:
Msrc/codegen/llvm.zig | 4++++
Msrc/codegen/llvm/bindings.zig | 9+++++++++
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig @@ -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.?, diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig @@ -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;