You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, create an assembly source file like the following, and add it to the exe archive.
; A rv32 asm source file, like `src/asmfile.s`.section .text._start,"ax", @progbits.globl _start.align1_start: j _start
// add it into `exe`exe.addAssemblyFile(b.path("src/asmfile.s"));
Now try to run zig build, and if everything works, you will get an elf file. However, when I enable lto, an error occurs. Modify the build.zig to add the LTO.
exe.want_lto=true;
And re-run zig build, the ld.lld said.
error: ld.lld: D:\a\test\.zig-cache\o\somehash\test.lto.o:
cannot link object files with different floating-point ABI from D:\a\test\.zig-cache\o\somehash\asmfile.o
I tried reading the elf header file with readelf and found that the header of asmfile.o is different from the header of the zig build output file without LTO.
# asmfile.o
ELF Header:
...
Flags: 0x5, RVC, double-float ABI
# `zig build` output with exe.want_lto = true; excluding the assembly file
ELF Header:
...
Flags: 0x0
# `zig build` output with exe.want_lto = false; excluding the assembly file
ELF Header:
...
Flags: 0x5, RVC, double-float ABI
It looks like it's caused by something missing from the ELF header on the LTO output.
Is this a bug? how should I fix it
Expected Behavior
baseline_rv32 is rv32iamcd, so it includes the D extension, so LTO's ELF Header should include double-float ABI
The ELF Header for LTO's output should also have double-float ABI
The text was updated successfully, but these errors were encountered:
XiangYyang
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Feb 3, 2025
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
Start a new project and use
zig init
. Then, set the target inbuild.zig
.Then, create an assembly source file like the following, and add it to the
exe
archive.Now try to run
zig build
, and if everything works, you will get an elf file. However, when I enable lto, an error occurs. Modify thebuild.zig
to add the LTO.And re-run
zig build
, theld.lld
said.I tried reading the elf header file with
readelf
and found that the header ofasmfile.o
is different from the header of thezig build
output file without LTO.# asmfile.o ELF Header: ... Flags: 0x5, RVC, double-float ABI
# `zig build` output with exe.want_lto = true; excluding the assembly file ELF Header: ... Flags: 0x0
# `zig build` output with exe.want_lto = false; excluding the assembly file ELF Header: ... Flags: 0x5, RVC, double-float ABI
It looks like it's caused by something missing from the ELF header on the LTO output.
Is this a bug? how should I fix it
Expected Behavior
baseline_rv32
is rv32iamcd, so it includes the D extension, so LTO's ELF Header should includedouble-float ABI
double-float ABI
The text was updated successfully, but these errors were encountered: