authorgravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2024-09-01 15:09:25+02:00
committergravatar for liljaanton2001@gmail.comantlilja <liljaanton2001@gmail.com> 2024-09-01 15:12:49+02:00
log15b4c01ab1dd578b0a306b18b11b79f6b9bce88d
treea6c92ebae495519513808e27f2fbdf0f9ad47940
parent76908da3ac2f4ba64a80d6618211e7390995c00e

Rename usesLargePIC to picLevel and return the PIC level


2 files changed, 5 insertions(+), 5 deletions(-)

src/codegen/llvm.zig+3-3
......@@ -1107,12 +1107,12 @@ 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
......@@ -1120,7 +1120,7 @@ pub const Object = struct {
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+2-2
......@@ -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
52pub fn usesLargePIC(target: std.Target) bool {
52pub 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