Merge pull request #21224 from alexrp/mips-gnu-fixes

Fix MIPS PIC level and work around an LLVM bug for `mips(el)-linux-gnueabi(hf)`
This commit is contained in:
Andrew Kelley
2024-08-30 14:47:43 -07:00
committed by GitHub
6 changed files with 34 additions and 27 deletions

View File

@@ -1276,8 +1276,11 @@ pub const Object = struct {
);
errdefer target_machine.dispose();
if (pic) module.setModulePICLevel();
if (comp.config.pie) module.setModulePIELevel();
const large_pic = target_util.usesLargePIC(comp.root_mod.resolved_target.result);
if (pic) module.setModulePICLevel(large_pic);
if (comp.config.pie) module.setModulePIELevel(large_pic);
if (code_model != .Default) module.setModuleCodeModel(code_model);
if (comp.llvm_opt_bisect_limit >= 0) {
@@ -1294,6 +1297,8 @@ pub const Object = struct {
.tsan = options.sanitize_thread,
.sancov = options.fuzz,
.lto = options.lto,
// https://github.com/ziglang/zig/issues/21215
.allow_fast_isel = !comp.root_mod.resolved_target.result.cpu.arch.isMIPS(),
.asm_filename = null,
.bin_filename = options.bin_path,
.llvm_ir_filename = options.post_ir_path,

View File

@@ -53,10 +53,10 @@ pub const Module = opaque {
extern fn LLVMDisposeModule(*Module) void;
pub const setModulePICLevel = ZigLLVMSetModulePICLevel;
extern fn ZigLLVMSetModulePICLevel(module: *Module) void;
extern fn ZigLLVMSetModulePICLevel(module: *Module, big: bool) void;
pub const setModulePIELevel = ZigLLVMSetModulePIELevel;
extern fn ZigLLVMSetModulePIELevel(module: *Module) void;
extern fn ZigLLVMSetModulePIELevel(module: *Module, large: bool) void;
pub const setModuleCodeModel = ZigLLVMSetModuleCodeModel;
extern fn ZigLLVMSetModuleCodeModel(module: *Module, code_model: CodeModel) void;
@@ -91,6 +91,7 @@ pub const TargetMachine = opaque {
tsan: bool,
sancov: bool,
lto: bool,
allow_fast_isel: bool,
asm_filename: ?[*:0]const u8,
bin_filename: ?[*:0]const u8,
llvm_ir_filename: ?[*:0]const u8,