emscripten-core / emscripten-core/emscripten

inconsistent results, export function not found.

Open
#13,955 1 comment 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Hi all,

Do not know it this is the place for this, but if not, feel free to delete this, and if you could, pls point me to right direction :)

test_1_fib.c C/wasm file: https://pastebin.com/AnFkhLCa

These results I got, are so inconsistent, that I've no idea what to do. I'm not fluent in C, nor wasm. File sizes fluctuates, even when only giving new output filename with -o param (part 2). Exported function is only found without underscore, even when emcc gives errors.

---- part 1 - this WORKS:
wasm build test_1_fib.c, output file: a.out.wasm (size: 597B):
emcc test_1_fib.c -O3 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS="['retFib']"

result: emcc: error: undefined exported symbol: "retFib" [-Wundefined] [-Werror]

wasmer-go:
fib, err := instance.Exports.GetFunction("retFib")

Result: This, again, is fine, even with emcc errors. It works. Can get results from retFib

---- part 2 (same as above, + emcc with -o retFib.wasm) - does NOT work:

wasm build test_1_fib.c, output file: retFib.wasm (size 1,1KB!!):
emcc test_1_fib.c -O3 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS="['retFib']" -o retFib.wasm
result: emcc: error: undefined exported symbol: "retFib" [-Wundefined] [-Werror]

wasmer-go (pointing to a new wasm file):
fib, err := instance.Exports.GetFunction("retFib")

Result(from golang): Panic: runtime error: invalid memory address or nil pointer dereference

---- part 3 (emcc export func with underscore, no output file defined) - does NOT work:
wasm build test_1_fib.c, output file: a.out.wasm (size 236B):
emcc test_1_fib.c -O3 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS="['_retFib']"

wasmer-go (pointing to a new wasm file):
fib, err := instance.Exports.GetFunction("_retFib")

Result(from golang): Panic: runtime error: Export '_retFib' does not exist

---- part 3 (emcc export func with underscore, output file defined) - does NOT work:

This does not work:
wasm build test_1_fib.c, output file: retFib.wasm (size 683B):
emcc test_1_fib.c -O3 -s WASM=1 -s NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS="['_retFib']" -o retFib.wasm

wasmer-go (pointing to a new wasm file):
fib, err := instance.Exports.GetFunction("_retFib")

Result(from golang): Panic: runtime error: invalid memory address or nil pointer dereference

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.