ziglang / zig

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

-target armv6m-freestanding-none does not compile #4266

Open markfirmware opened 4 years ago

markfirmware commented 4 years ago

I'm using armv6m for https://github.com/markfirmware/zig-bare-metal-microbit and updated to the newest zig, got this problem and reduced it to an emty program:

export fn main() noreturn {
    while (true) {}
}

zig version 0.5.0+c522699f2
zig build-exe -target armv6m-freestanding-none --linker-script linker.ld main.zig
<inline asm>:5:2: error: invalid instruction, any one of the following would fix this:
 mov r1, #1
 ^
<inline asm>:5:10: note: operand must be a register in range [r0, r15]
 mov r1, #1
         ^
<inline asm>:5:2: note: instruction requires: thumb2
 mov r1, #1
 ^
<inline asm>:14:2: error: conditional execution not supported in Thumb1
 movne r0, r2
 ^
<inline asm>:15:2: error: conditional execution not supported in Thumb1
 addeq r1, #16
 ^
<inline asm>:18:2: error: conditional execution not supported in Thumb1
 movne r0, r2
 ^
<inline asm>:19:2: error: conditional execution not supported in Thumb1
 addeq r1, #8
 ^
<inline asm>:22:2: error: conditional execution not supported in Thumb1
 movne r0, r2
 ^
<inline asm>:23:2: error: conditional execution not supported in Thumb1
 addeq r1, #4
 ^
<inline asm>:26:2: error: conditional execution not supported in Thumb1
 movne r0, r2
 ^
<inline asm>:27:2: error: conditional execution not supported in Thumb1
 addeq r1, #2
 ^
<inline asm>:39:2: error: invalid instruction, any one of the following would fix this:
 sub r0, r1, r0, lsr #1
 ^
<inline asm>:39:2: note: instruction requires: thumb2
 sub r0, r1, r0, lsr #1
 ^
<inline asm>:39:18: note: invalid operand for instruction
 sub r0, r1, r0, lsr #1
                 ^
<inline asm>:39:18: note: operand must be an immediate in the range [0,7]
 sub r0, r1, r0, lsr #1
                 ^
<inline asm>:39:18: note: operand must be a register in range [r0, r7]
 sub r0, r1, r0, lsr #1
                 ^
LLVM ERROR: Error parsing inline asm
LemonBoy commented 4 years ago

Yeah, ARMv6m ISA only supports the Thumb-1 subset. Once #4264 is merged we'll be able to avoid this problem by checking for the noarm feature.

You can avoid this problem by going straight for thumbv6m

markfirmware commented 4 years ago

Thanks!

daurnimator commented 4 years ago

With #4264 now merged this issue should be unblocked