Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failure on latest mater for target AVR25 (ATTiny13A MCU) #21487

Closed
seletskiy opened this issue Sep 22, 2024 · 5 comments
Closed

Compilation failure on latest mater for target AVR25 (ATTiny13A MCU) #21487

seletskiy opened this issue Sep 22, 2024 · 5 comments
Labels
arch-avr 8-bit AVR backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior regression It worked in a previous version of Zig, but stopped working. upstream An issue with a third party project that Zig uses.
Milestone

Comments

@seletskiy
Copy link

seletskiy commented Sep 22, 2024

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.zig

    const 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.zig

    pub 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.

@seletskiy seletskiy added the bug Observed behavior contradicts documented or intended behavior label Sep 22, 2024
@alexrp
Copy link
Member

alexrp commented Sep 22, 2024

Haven't looked closely at this yet, but my suspicion would be that this is fixed by llvm/llvm-project#109124.

@alexrp alexrp added arch-avr 8-bit AVR regression It worked in a previous version of Zig, but stopped working. labels Oct 9, 2024
@alexrp alexrp added this to the 0.14.0 milestone Oct 9, 2024
@alexrp
Copy link
Member

alexrp commented Nov 28, 2024

Seems like llvm/llvm-project#118015 might resolve this.

@alexrp alexrp added upstream An issue with a third party project that Zig uses. backend-llvm The LLVM backend outputs an LLVM IR Module. labels Nov 28, 2024
@alexrp alexrp modified the milestones: 0.14.0, 0.15.0 Nov 28, 2024
@Patryk27
Copy link

Patryk27 commented Jan 2, 2025

Note that there's also a follow-up pull request - llvm/llvm-project#121498.

@Patryk27
Copy link

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:

llvm/llvm-project#125081

@alexrp
Copy link
Member

alexrp commented Mar 9, 2025

I've merged ziglang/zig-bootstrap#207 so the fix for this will be included in Zig 0.14.1. For master, it'll be fixed with #22780.

Thanks @Patryk27!

@alexrp alexrp closed this as completed Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-avr 8-bit AVR backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior regression It worked in a previous version of Zig, but stopped working. upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

No branches or pull requests

3 participants