-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling libz-ng using wasi-sdk produces an invalid binary #492
Comments
Given that both Wasmtime and node consider this an invalid Wasm, I suspect that the toolchain really is producing an invalid Wasm, rather than that both validators have the same bug. So I suspect this is ultimately a bug in either LLVM or |
I found out a bit more with:
which points to this location. Which ended up not being that illuminating. Looking at the disassembly I see: (;@191c2 ;) (func $adler32_stub (;191;) (type 2) (param i32 i32 i32) (result i32)
(;@191c3 ;) (local i32 i32 i32)
(;@191c5 ;) global.get $__stack_pointer
(;@191cb ;) i32.const 16
(;@191cd ;) i32.sub
(;@191ce ;) local.tee 3
(;@191d0 ;) global.set $__stack_pointer
(;@191d6 ;) global.get $GOT.data.internal.__memory_base
(;@191dc ;) local.set 4
(;@191de ;) local.get 3
(;@191e0 ;) i32.const 15
(;@191e2 ;) i32.add
(;@191e3 ;) call $cpu_check_features
(;@191e9 ;) local.get 4
(;@191eb ;) i32.const 7453020
(;@191f1 ;) i32.add
(;@191f2 ;) local.tee 4
(;@191f4 ;) global.get $GOT.func.internal.adler32_c
(;@191fa ;) i32.store offset=4
(;@191fd ;) local.get 4
(;@191ff ;) global.get $GOT.data.internal.__table_base
(;@19205 ;) local.tee 5
(;@19207 ;) i32.const 40
(;@1920d ;) i32.add
(;@1920e ;) i32.store
(;@19211 ;) local.get 4
;; ...
(;@192d5 ;) local.get 1
(;@192d7 ;) local.get 2
(;@192d9 ;) call $_start
(;@192df ;) local.set 4
(;@192e1 ;) local.get 3
(;@192e3 ;) i32.const 16
(;@192e5 ;) i32.add
(;@192e6 ;) global.set $__stack_pointer
(;@192ec ;) local.get 4
) which also isn't too illuminating. I'm seeing |
Disabling |
I believe it's intended to work, but that's at least good for helping to narrow down the issue! I'm not familiar enough with |
yes, this sounds like some kind llvm/lld issue with linking Can you open an llvm bug for this? If possible with a simple reproducer attached. |
Pushed a reproducer which barely uses any rust (aside from to build zlib-ng) to https://github.com/bjorn3/wasi-sdk-issue-492 Turns out that opt-level=1 is necessary for the bug to show up. |
One reduction via creduce is
I'm not sure if that's the exact same issue as the one here, but it looks similar at least. |
Have you already opened an llvm issue or do you mind if I open one? |
I haven't yet, please feel free! |
Opened llvm/llvm-project#111855 |
The latest version of the cc crate has stopped passing |
The blogpost-uncompress example of zlib-rs includes the C libz-ng library. Without libz-ng, zlib-rs compiles fine for wasm.
Reproduction
The text was updated successfully, but these errors were encountered: