authorgravatar for e820@noreply.codeberg.orge820 <e820@noreply.codeberg.org> 2026-01-02 23:16:08+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-02 23:16:08+01:00
log4cee1f7b9a6df9c890268eddc526e66dfa16f0ad
tree7d8690221551f536e78102adda204d57c1d36f45
parent53ebfde6b433ebdb28d4989a345e8d34abf049b7

Forgo `const` qualifiers on `register` locals generated by asm (#30645)

See https://codeberg.org/ziglang/zig/issues/30637 for details. Works around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86673 Co-authored-by: Laurin-Luis Lehning <65224843+e820@users.noreply.github.com> Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30645 Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org> Co-authored-by: e820 <e820@noreply.codeberg.org> Co-committed-by: e820 <e820@noreply.codeberg.org>

1 files changed, 3 insertions(+), 1 deletions(-)

src/codegen/c.zig+3-1
...@@ -5529,7 +5529,9 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5529,7 +5529,9 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
5529 .alignas = CType.AlignAs.fromAbiAlignment(input_ty.abiAlignment(zcu)),5529 .alignas = CType.AlignAs.fromAbiAlignment(input_ty.abiAlignment(zcu)),
5530 });5530 });
5531 try f.allocs.put(gpa, input_local.new_local, false);5531 try f.allocs.put(gpa, input_local.new_local, false);
5532 try f.object.dg.renderTypeAndName(w, input_ty, input_local, Const, .none, .complete);5532 // Do not render the declaration as `const` qualified if we're generating an
5533 // explicit `register` local, as GCC will ignore the constraint completely.
5534 try f.object.dg.renderTypeAndName(w, input_ty, input_local, if (is_reg) .{} else Const, .none, .complete);
5533 if (is_reg) {5535 if (is_reg) {
5534 try w.writeAll(" __asm(\"");5536 try w.writeAll(" __asm(\"");
5535 try w.writeAll(constraint["{".len .. constraint.len - "}".len]);5537 try w.writeAll(constraint["{".len .. constraint.len - "}".len]);