authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-19 08:03:19+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-20 10:02:51+02:00
log4cf3a1d89789ef96c90862b52596c2d9f673a951
tree2f9332acf473ecbfeb05fc268ce4a45e5ac0dd25
parent1a801d2bd454af79c1c7cbb339a3f82afe58c156
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: fix some inaccuracies in stackAlignment()


1 files changed, 18 insertions(+), 9 deletions(-)

lib/std/Target.zig+18-9
...@@ -3087,14 +3087,17 @@ pub fn ptrBitWidth(target: *const Target) u16 {...@@ -3087,14 +3087,17 @@ pub fn ptrBitWidth(target: *const Target) u16 {
3087pub fn stackAlignment(target: *const Target) u16 {3087pub fn stackAlignment(target: *const Target) u16 {
3088 // Overrides for when the stack alignment is not equal to the pointer width.3088 // Overrides for when the stack alignment is not equal to the pointer width.
3089 switch (target.cpu.arch) {3089 switch (target.cpu.arch) {
3090 .ez80 => return 1,3090 .avr,
3091 .ez80,
3092 => return 1,
30913093
3092 .m68k => return 2,3094 .m68k => if (target.os.tag != .netbsd) return 2,
30933095
3094 .amdgcn => return 4,3096 .amdgcn => return 4,
30953097
3096 .arm,3098 .arm,
3097 .armeb,3099 .armeb,
3100 .hexagon,
3098 .hppa,3101 .hppa,
3099 .lanai,3102 .lanai,
3100 .mips,3103 .mips,
...@@ -3112,28 +3115,34 @@ pub fn stackAlignment(target: *const Target) u16 {...@@ -3112,28 +3115,34 @@ pub fn stackAlignment(target: *const Target) u16 {
3112 .hppa64,3115 .hppa64,
3113 .loongarch32,3116 .loongarch32,
3114 .loongarch64,3117 .loongarch64,
3118 .m88k,
3115 .mips64,3119 .mips64,
3116 .mips64el,3120 .mips64el,
3121 .powerpc,
3122 .powerpcle,
3123 .powerpc64,
3124 .powerpc64le,
3117 .sparc64,3125 .sparc64,
3118 .ve,3126 .ve,
3119 .wasm32,3127 .wasm32,
3120 .wasm64,3128 .wasm64,
3121 .x86_64,3129 .x86_64,
3130 .xtensa,
3131 .xtensaeb,
3122 => return 16,3132 => return 16,
31233133
3124 // Some of the following prongs should really be testing the ABI, but our current `Abi` enum
3125 // can't handle that level of nuance yet.
3126 .powerpc64,
3127 .powerpc64le,
3128 => if (target.os.tag == .linux) return 16,
3129
3130 .riscv32,3134 .riscv32,
3131 .riscv32be,3135 .riscv32be,
3132 .riscv64,3136 .riscv64,
3133 .riscv64be,3137 .riscv64be,
3134 => if (!target.cpu.has(.riscv, .e)) return 16,3138 => if (!target.cpu.has(.riscv, .e)) return 16,
31353139
3136 .x86 => if (target.os.tag != .windows and target.os.tag != .uefi) return 16,3140 .x86 => switch (target.os.tag) {
3141 .hurd,
3142 .linux,
3143 => return 16,
3144 else => {},
3145 },
31373146
3138 .kvx => return 32,3147 .kvx => return 32,
31393148