Skip to content

Commit 15b4c01

Browse files
committed
Rename usesLargePIC to picLevel and return the PIC level
1 parent 76908da commit 15b4c01

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/codegen/llvm.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,20 +1107,20 @@ pub const Object = struct {
11071107
const behavior_max = try o.builder.metadataConstant(try o.builder.intConst(.i32, 7));
11081108
const behavior_min = try o.builder.metadataConstant(try o.builder.intConst(.i32, 8));
11091109

1110-
const large_pic = target_util.usesLargePIC(comp.root_mod.resolved_target.result);
1110+
const pic_level = target_util.picLevel(comp.root_mod.resolved_target.result);
11111111
if (comp.root_mod.pic) {
11121112
module_flags.appendAssumeCapacity(try o.builder.metadataModuleFlag(
11131113
behavior_min,
11141114
try o.builder.metadataString("PIC Level"),
1115-
try o.builder.metadataConstant(try o.builder.intConst(.i32, @as(i32, if (large_pic) 2 else 1))),
1115+
try o.builder.metadataConstant(try o.builder.intConst(.i32, pic_level)),
11161116
));
11171117
}
11181118

11191119
if (comp.config.pie) {
11201120
module_flags.appendAssumeCapacity(try o.builder.metadataModuleFlag(
11211121
behavior_max,
11221122
try o.builder.metadataString("PIE Level"),
1123-
try o.builder.metadataConstant(try o.builder.intConst(.i32, @as(i32, if (large_pic) 2 else 1))),
1123+
try o.builder.metadataConstant(try o.builder.intConst(.i32, pic_level)),
11241124
));
11251125
}
11261126

src/target.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ pub fn requiresPIC(target: std.Target, linking_libc: bool) bool {
4949
(target.abi == .ohos and target.cpu.arch == .aarch64);
5050
}
5151

52-
pub fn usesLargePIC(target: std.Target) bool {
52+
pub fn picLevel(target: std.Target) u32 {
5353
// MIPS always uses PIC level 1; other platforms vary in their default PIC levels, but they
5454
// support both level 1 and 2, in which case we prefer 2.
55-
return !target.cpu.arch.isMIPS();
55+
return if (target.cpu.arch.isMIPS()) 1 else 2;
5656
}
5757

5858
/// This is not whether the target supports Position Independent Code, but whether the -fPIC

0 commit comments

Comments
 (0)