ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.73k stars 2.48k forks source link

[arm-uefi-msvc] LLVM ERROR: target architecture doesn't map to a CodeView CPUType #18231

Open AnErrupTion opened 9 months ago

AnErrupTion commented 9 months ago

Zig Version

0.11.0 & 0.12.0-dev.1802+56deb5b05

Steps to Reproduce and Observed Behavior

Create a new project (with zig init-exe on 0.11.0 for example) with the following target:

const target = std.zig.CrossTarget{
    .cpu_arch = .arm,
    .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_a15 },
    .os_tag = .uefi,
    .abi = .msvc,
};

And execute zig build. This produces the following error:

zig build-exe Cyborg Debug arm-uefi-msvc: error: LLVM ERROR: target architecture doesn't map to a CodeView CPUType

Note: This also seems to happen with .windows set as os_tag.

Expected Behavior

I should be able to compile just fine.

Vexu commented 9 months ago

Looks like you should use thumb arch instead of arm.

AnErrupTion commented 9 months ago

Looks like you should use thumb arch instead of arm.

That seems to work, however I have 2 issues. The first one, relatively minor, is a missing implementation for the __rt_udiv64 function. I implemented it like below, but i'm not sure if it's right or not:

export fn __rt_udiv64(a: u64, b: u64) u64 {
    return a / b;
}

However, a bigger issue is, when I try to boot the EFI application on the bare metal, it just does... nothing. It basically freezes. Keep in mind there's still nothing in the main function either, so it should just boot straight into the OS, but it doesn't, it's stuck.

I know this isn't particularly precise, but I'm not sure how to even debug this.