We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
0.11.0-dev.1017+d86685ac9
I'm running a MacBook Pro 16-inch from 2019 with macOS Ventura 13.1.
Install the latest version of Zig for macOS using Homebrew:
$ brew install zig --HEAD
Create an add.zig file having this code:
add.zig
export fn add(x: i32, y: i32) i32 { return x + y; }
Compile it to Wasm:
$ zig build-lib add.zig -target wasm32-freestanding -dynamic
Inspect the generated Wasm file with wasm2wat:
wasm2wat
$ wasm2wat add.wasm (module (memory (;0;) 16) (global $__stack_pointer (mut i32) (i32.const 1048576)) (export "memory" (memory 0)))
Notice the add() function is missing !
add()
However, if we recompile while forcing the export with --export=add it will work. For brevity of output, let's also use -O ReleaseSmall:
--export=add
-O ReleaseSmall
$ zig build-lib add.zig -target wasm32-freestanding -dynamic -O ReleaseSmall --export=add
Again, inspect the generated Wasm with wasm2wat:
$ wasm2wat add.wasm (module (type (;0;) (func (param i32 i32) (result i32))) (func (;0;) (type 0) (param i32 i32) (result i32) local.get 1 local.get 0 i32.add) (memory (;0;) 16) (global (;0;) (mut i32) (i32.const 1048576)) (export "memory" (memory 0)) (export "add" (func 0)))
Finally a good result but we were forced to export explicitly on the command line. This would be a pain if we had many things to export.
My expectation is that running:
will produce a Wasm file that includes the add() function.
To put it in general terms, all exports should actually be exported by default.
The text was updated successfully, but these errors were encountered:
This is an intentional (breaking) change, see #14102.
Sorry, something went wrong.
I see, so the solution for my situation is to include -rdynamic:
-rdynamic
$ zig build-lib add.zig -target wasm32-freestanding -dynamic -rdynamic -O ReleaseSmall $ wasm2wat add.wasm (module (type (;0;) (func (param i32 i32) (result i32))) (func (;0;) (type 0) (param i32 i32) (result i32) local.get 1 local.get 0 i32.add) (memory (;0;) 16) (global (;0;) (mut i32) (i32.const 1048576)) (export "memory" (memory 0)) (export "add" (func 0)))
That works for me. Thanks, @schmee !
No branches or pull requests
Zig Version
0.11.0-dev.1017+d86685ac9
Steps to Reproduce and Observed Behavior
I'm running a MacBook Pro 16-inch from 2019 with macOS Ventura 13.1.
Install the latest version of Zig for macOS using Homebrew:
Create an
add.zig
file having this code:Compile it to Wasm:
Inspect the generated Wasm file with
wasm2wat
:Notice the
add()
function is missing !However, if we recompile while forcing the export with
--export=add
it will work. For brevity of output, let's also use-O ReleaseSmall
:Again, inspect the generated Wasm with
wasm2wat
:Finally a good result but we were forced to export explicitly on the command line. This would be a pain if we had many things to export.
Expected Behavior
My expectation is that running:
will produce a Wasm file that includes the
add()
function.To put it in general terms, all exports should actually be exported by default.
The text was updated successfully, but these errors were encountered: