Open InBetweenNames opened 1 month ago
@InBetweenNames, zig code run? Please, try: https://github.com/kassane/riscv64-hello-linux/blob/hello-zig/src/main.zig
This is an LLVM assembler bug.
❯ cat test.s
.global __start
__start:
j $ra
❯ clang -target mipsisa64r6-linux-gnu -nostdlib test.s
❯ objdump --disassemble=__start a.out
a.out: file format elf64-tradbigmips
Disassembly of section .text:
00000000000003f0 <__start>:
3f0: 03e00008 .word 0x3e00008
3f4: 00000000 nop
❯ mips64-linux-gnuabi64-gcc -march=mips64r6 -nostdlib test.s
❯ objdump --disassemble=__start a.out
a.out: file format elf64-tradbigmips
Disassembly of section .text:
0000000120000150 <__start>:
120000150: 03e00009 jr ra
120000154: 00000000 nop
...
https://github.com/ziglang/zig/pull/21441 will work around this on our side. This bug should remain open to track removing the workaround when the LLVM assembler bug is fixed.
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
Hello Zig team!
Thanks for continuing to maintain such a fantastic project.
I tried to build and run a simple
hello world
C program usingzig cc
and have encountered a problem in the init code in musl when building for MIPS32BE, target triple mips-linux-musl.The program (main.c):
The compile line:
To run:
Note that MIPS32R5 and below seem to work just fine.
I looked at the generated output and it seems that the symbol
_init
has an instruction that isn't valid MIPS32R6 in there, which should be a jump. The instruction machine code is0x03e00008
which should be aJR $ra
. Unfortunately, all of my tools are failing to decode this in the binary for MIPS32R6. I haven't dug deeper yet to see why this is, but it does appear to be something going wrong in the musl compilation for this target.-none
target triples seem to work fine.Any advice on how I can debug this further? I understand MIPS32R6 changed or removed some instructions relative to previous revisions and I suspect something like that is going on.
Thank you very much!
Expected Behavior
The program should print
Hello World!
and exit successfully.