Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
target: implement isPICDefault function
Browse files Browse the repository at this point in the history
Organ1sm committed Sep 17, 2024
1 parent 9059c68 commit 1a590fb
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions src/aro/target.zig
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ const std = @import("std");
const LangOpts = @import("LangOpts.zig");
const Type = @import("Type.zig");
const TargetSet = @import("Builtins/Properties.zig").TargetSet;
const Driver = @import("Driver.zig");
const backend = @import("backend");

/// intmax_t for this target
@@ -799,6 +800,92 @@ fn isPIEDefault(d: *const Driver) bool {
},
};
}
fn isPICdefault(d: *const Driver) bool {
const target = d.comp.target;
return switch (target.os.tag) {
.aix,
.haiku,

.macos,
.ios,
.tvos,
.watchos,
.visionos,
.driverkit,

.amdhsa,
.amdpal,
.mesa3d,

.ps4,
.ps5,
=> true,

.fuchsia,
.cuda,
.zos,
.shadermodel,
=> false,

.dragonfly,
.openbsd,
.netbsd,
.freebsd,
.solaris,
.hurd,
=> {
return switch (target.cpu.arch) {
.mips64, .mips64el => true,
else => false,
};
},

.linux,
.elfiamcu,
=> {
if (target.abi == .ohos)
return false;

return switch (target.cpu.arch) {
.mips64, .mips64el => true,
else => false,
};
},

.windows => {
if (target.isMinGW())
return (target.cpu.arch == .x86_64 or target.cpu.arch == .aarch64);

if (target.abi == .itanium)
return target.cpu.arch == .x86_64;

if (target.abi == .msvc or target.abi == .none) {
if (std.mem.eql(u8, d.use_linker.?, "bfd"))
return target.cpu.arch == .x86_64
else
return (target.cpu.arch == .x86_64 or target.cpu.arch == .aarch64);
}

if (target.ofmt == .macho)
return true;

return switch (target.cpu.arch) {
.x86_64, .mips64, .mips64el => true,
else => false,
};
},

else => {
if (target.ofmt == .macho)
return true;

return switch (target.cpu.arch) {
.mips64, .mips64el => true,
else => false,
};
},
};
}
/// This currently just returns the desired settings without considering target defaults / requirements
pub fn getPICMode(target: std.Target, desired_pic_level: ?backend.CodeGenOptions.PicLevel, wants_pie: ?bool) struct { backend.CodeGenOptions.PicLevel, bool } {
_ = target;

0 comments on commit 1a590fb

Please sign in to comment.