#Having issues compiling code to WASM

1 messages · Page 1 of 1 (latest)

finite coyote
#

Well, i was trying to compile this code to WASM:

export fn add(a: i32, b: i32) i32 {
  return a + b;
}

Let's name the file math.zig.
When i use the command: zig build-lib math.zig -target wasm32-freestanding -dynamic
The ouput code ( in wat format ) looks like this:

(module
 (memory $0 16)
 (global $__stack_pointer (mut i32) (i32.const 1048576))
 (export "memory" (memory $0))
 ;; custom section ".debug_info", size 1410
 ;; custom section ".debug_pubtypes", size 469
 ;; custom section ".debug_loc", size 29
 ;; custom section ".debug_ranges", size 24
 ;; custom section ".debug_abbrev", size 292
 ;; custom section ".debug_line", size 241
 ;; custom section ".debug_str", size 1434
 ;; custom section ".debug_pubnames", size 381
 ;; custom section "producers", size 16
)
wide bloom
#

try with -rdynamic

#

(don't remove -dynamic)

finite coyote
wide bloom
#

you can also do --export=add

finite coyote
wide bloom
#

read below comments

finite coyote