Skip to content

Commit

Permalink
llvm: Set target-abi module flag.
Browse files Browse the repository at this point in the history
LLVM is increasingly making use of this module flag when present.
  • Loading branch information
alexrp committed Mar 5, 2025
1 parent 0a7146b commit 58b5963
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1107,14 +1107,24 @@ pub const Object = struct {
}

{
var module_flags = try std.ArrayList(Builder.Metadata).initCapacity(o.gpa, 7);
var module_flags = try std.ArrayList(Builder.Metadata).initCapacity(o.gpa, 8);
defer module_flags.deinit();

const behavior_error = try o.builder.metadataConstant(try o.builder.intConst(.i32, 1));
const behavior_warning = try o.builder.metadataConstant(try o.builder.intConst(.i32, 2));
const behavior_max = try o.builder.metadataConstant(try o.builder.intConst(.i32, 7));
const behavior_min = try o.builder.metadataConstant(try o.builder.intConst(.i32, 8));

if (target_util.llvmMachineAbi(comp.root_mod.resolved_target.result)) |abi| {
module_flags.appendAssumeCapacity(try o.builder.metadataModuleFlag(
behavior_error,
try o.builder.metadataString("target-abi"),
try o.builder.metadataConstant(
try o.builder.stringConst(try o.builder.string(abi)),
),
));
}

const pic_level = target_util.picLevel(comp.root_mod.resolved_target.result);
if (comp.root_mod.pic) {
module_flags.appendAssumeCapacity(try o.builder.metadataModuleFlag(
Expand Down

0 comments on commit 58b5963

Please sign in to comment.