Skip to content

Commit

Permalink
Merge pull request #798 from ehaas/zig-update
Browse files Browse the repository at this point in the history
Zig updates for x32/n32 ABI and thumb arch check
  • Loading branch information
Vexu authored Nov 4, 2024
2 parents 22bb0eb + 6cf7a73 commit d1da291
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/aro/Driver.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ pub fn getPICMode(d: *Driver, lastpic: []const u8) !struct { backend.CodeGenOpti
return .{ if (pic) .two else .none, false };
}

const embedded_pi_supported = target.cpu.arch.isArmOrThumb();
const embedded_pi_supported = target.cpu.arch.isArm();
if (!embedded_pi_supported) {
if (d.ropi) try d.unsupportedOptionForTarget(target, "-fropi");
if (d.rwpi) try d.unsupportedOptionForTarget(target, "-frwpi");
Expand Down
19 changes: 15 additions & 4 deletions src/aro/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,18 @@ pub fn ldEmulationOption(target: std.Target, arm_endianness: ?std.builtin.Endian
.loongarch64 => "elf64loongarch",
.mips => "elf32btsmip",
.mipsel => "elf32ltsmip",
.mips64 => if (target.abi == .gnuabin32) "elf32btsmipn32" else "elf64btsmip",
.mips64el => if (target.abi == .gnuabin32) "elf32ltsmipn32" else "elf64ltsmip",
.x86_64 => if (target.abi == .gnux32 or target.abi == .muslx32) "elf32_x86_64" else "elf_x86_64",
.mips64 => switch (target.abi) {
.gnuabin32, .muslabin32 => "elf32btsmipn32",
else => "elf64btsmip",
},
.mips64el => switch (target.abi) {
.gnuabin32, .muslabin32 => "elf32ltsmipn32",
else => "elf64ltsmip",
},
.x86_64 => switch (target.abi) {
.gnux32, .muslx32 => "elf32_x86_64",
else => "elf_x86_64",
},
.ve => "elf64ve",
.csky => "cskyelf_linux",
else => null,
Expand Down Expand Up @@ -696,13 +705,15 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
.gnuf32 => "gnuf32",
.gnusf => "gnusf",
.gnux32 => "gnux32",
.gnuilp32 => "gnuilp32",
.gnuilp32 => "gnu_ilp32",
.code16 => "code16",
.eabi => "eabi",
.eabihf => "eabihf",
.android => "android",
.androideabi => "androideabi",
.musl => "musl",
.muslabin32 => "muslabin32",
.muslabi64 => "muslabi64",
.musleabi => "musleabi",
.musleabihf => "musleabihf",
.muslx32 => "muslx32",
Expand Down
2 changes: 1 addition & 1 deletion src/aro/toolchains/Linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn buildExtraOpts(self: *Linux, tc: *const Toolchain) !void {
self.extra_opts.appendAssumeCapacity("relro");
}

if (target.cpu.arch.isARM() or target.cpu.arch.isAARCH64() or is_android) {
if ((target.cpu.arch.isArm() and !target.cpu.arch.isThumb()) or target.cpu.arch.isAARCH64() or is_android) {
try self.extra_opts.ensureUnusedCapacity(gpa, 2);
self.extra_opts.appendAssumeCapacity("-z");
self.extra_opts.appendAssumeCapacity("max-page-size=4096");
Expand Down

0 comments on commit d1da291

Please sign in to comment.