zig
zig copied to clipboard
Compilation failure on latest mater for target AVR25 (ATTiny13A MCU)
Zig Version
0.14.0-dev.1632+d83a3f174
Steps to Reproduce and Observed Behavior
Minimal case to repro:
-
build.zig.zon.{ .name = "tmp.CsP3FWngBQ", .version = "0.0.0", .paths = .{ "build.zig", "build.zig.zon", "src", }, } -
build.zigconst std = @import("std"); pub fn build(b: *std.Build) void { const target = b.resolveTargetQuery(std.Target.Query{ .cpu_arch = .avr, .cpu_model = .{ .explicit = &std.Target.avr.cpu.attiny13a }, .os_tag = .freestanding, .abi = .none, }); const optimize = std.builtin.OptimizeMode.ReleaseSmall; const exe = b.addExecutable(.{ .name = "tmp.CsP3FWngBQ", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); b.installArtifact(exe); } -
src/main.zigpub export fn _start() void {}
zig build output:
install
└─ install tmp.CsP3FWngBQ
└─ zig build-exe tmp.CsP3FWngBQ ReleaseSmall avr-freestanding-none failure
error: error: <unknown>:0: out of range branch target (expected an integer in the range -4096 to 4095)
Expected Behavior
Code compiles successfully. Confirmed to work on 0.13.0.
Haven't looked closely at this yet, but my suspicion would be that this is fixed by https://github.com/llvm/llvm-project/pull/109124.
Seems like https://github.com/llvm/llvm-project/pull/118015 might resolve this.
Note that there's also a follow-up pull request - https://github.com/llvm/llvm-project/pull/121498.
Status: there's a backport ready, but it won't be accepted, because LLVM 20 is already on its way - if you want, you can pull it manually to Zig:
https://github.com/llvm/llvm-project/pull/125081
I've merged https://github.com/ziglang/zig-bootstrap/pull/207 so the fix for this will be included in Zig 0.14.1. For master, it'll be fixed with #22780.
Thanks @Patryk27!