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
The wasmer CLI is currently using zig build-exe to cross-compile .wasm files to .exe files across platforms. We support multiple compilers: llvm, cranelift and our "singlepass" compiler.
For some reason, wasmer / zig build-exe fails to link the files together, but only with llvm-compiled files on -target x86_64-macos-none and -target x86_64-windows-gnu (cross-compiling from my Mac on aarch64-apple-darwin).
cd zigbug
./test.sh
error(link): undefined reference to symbol 'wasmer_vm_raise_trap'
error(link): first referenced in '/Users/fs/Desktop/zigbug/python.o'
error(link): undefined reference to symbol 'wasmer_vm_f64_floor'
error(link): first referenced in '/Users/fs/Desktop/zigbug/python.o'
error(link): undefined reference to symbol 'wasmer_vm_f64_ceil'
error(link): first referenced in '/Users/fs/Desktop/zigbug/python.o'
error: UndefinedSymbolReference
The object files are the unpacked version of libwasmer.a, I just unpacked the .a file into a folder and the test script links all object files in the folder.
The disassembly (in disassembly.txt) shows that wasmer_vm_raise_trap is in the object file and the script does link the object file. The problem is now: why can't the linker find these functions, even if the object file is given as an input?
This issue does only seem to happen when the python.o file gets compiled with LLVM, with other compilers it works.
Our assumption is that zig ld (called internally) passes some flags to ld, especially enabling -dead_strip (there is no -no_dead_strip in zig). In general: can there be some way to manually pass linker flags? If someone wants to use more experimental linker flags, then you'd first have to wait for zig to add support, which isn't great.
I am not sure if this is a solution to your issue but you can disable dead code stripping in build.zig with exe.link_gc_sections = false where exe: *std.Build.CompileStep.
Zig Version
0.10.0
Steps to Reproduce and Observed Behavior
The wasmer CLI is currently using zig build-exe to cross-compile .wasm files to .exe files across platforms. We support multiple compilers: llvm, cranelift and our "singlepass" compiler.
For some reason, wasmer / zig build-exe fails to link the files together, but only with llvm-compiled files on
-target x86_64-macos-none
and-target x86_64-windows-gnu
(cross-compiling from my Mac onaarch64-apple-darwin
).I've attached a minimum testcase here:
zigbug.zip
The object files are the unpacked version of
libwasmer.a
, I just unpacked the .a file into a folder and the test script links all object files in the folder.The disassembly (in
disassembly.txt
) shows thatwasmer_vm_raise_trap
is in the object file and the script does link the object file. The problem is now: why can't the linker find these functions, even if the object file is given as an input?This issue does only seem to happen when the
python.o
file gets compiled with LLVM, with other compilers it works.Our assumption is that
zig ld
(called internally) passes some flags told
, especially enabling-dead_strip
(there is no-no_dead_strip
in zig). In general: can there be some way to manually pass linker flags? If someone wants to use more experimental linker flags, then you'd first have to wait for zig to add support, which isn't great.Issue first appeared here: wasmerio/wasmer#3374 (comment)
Expected Behavior
The script should output a
./output
file, which should be a Python CLI on targetx86_64-macos-none
.The text was updated successfully, but these errors were encountered: