-
Notifications
You must be signed in to change notification settings - Fork 733
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
Fix wasm2c generating undeclared identifier errors #2554
base: main
Are you sure you want to change the base?
Conversation
Seems like are lacking a test here? |
Does the project have a way of updating the generated wasm2c code in all tests? |
Yes, there's |
Hmm, I just tried compiling our "fac" example with "--num-outputs=4" and wasn't able to replicate this failure (using gcc 13.3). Are you able to share more info about how you're seeing this? I wonder if the issue is related to the inline enum declaration requiring a more-recent C version as the compiler default or something like that. |
@keithw Could you share your setup for the "fac" example with When I can cleanly reproduce only using code in the wabt repo, I'll come up with a test for this. Perhaps this is because our tooling uses clang to compile the generated code. |
For You can run any of the wasm2c spec tests this way by adding $ ./test/run-tests.py -p spec-multi-output/call
/usr/bin/python3 /tmp/wabt/test/run-spec-wasm2c.py out/test/wasm2c/spec-multi-output/call.wast --bindir=/tmp/wabt/bin --no-error-cmdline -o out/test/wasm2c/spec-multi-output/call --num-outputs=4
[+1|-0|%100] (1.05s) test/wasm2c/spec-multi-output/call.txt and then adding "-p" to that command-line: $ /usr/bin/python3 /tmp/wabt/test/run-spec-wasm2c.py out/test/wasm2c/spec-multi-output/call.wast --bindir=/tmp/wabt/bin --no-error-cmdline -o out/test/wasm2c/spec-multi-output/call --num-outputs=4 -p
/tmp/wabt/bin/wast2json out/test/wasm2c/spec-multi-output/call.wast -o out/test/wasm2c/spec-multi-output/call/call.json
/tmp/wabt/bin/wasm2c out/test/wasm2c/spec-multi-output/call/call.0.wasm -o out/test/wasm2c/spec-multi-output/call/call.0.c -n call_0_wasm --num-outputs 4
cc -I/tmp/wabt/wasm2c -I/tmp/wabt/third_party/simde -std=c99 -c out/test/wasm2c/spec-multi-output/call/call.0_0.c -o out/test/wasm2c/spec-multi-output/call/call.0_0.o -O2 -Wall -Werror -Wno-unused -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -Wno-pass-failed -fno-optimize-sibling-calls -frounding-math -fsignaling-nans -D_DEFAULT_SOURCE
cc -I/tmp/wabt/wasm2c -I/tmp/wabt/third_party/simde -std=c99 -c out/test/wasm2c/spec-multi-output/call/call.0_1.c -o out/test/wasm2c/spec-multi-output/call/call.0_1.o -O2 -Wall -Werror -Wno-unused -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -Wno-pass-failed -fno-optimize-sibling-calls -frounding-math -fsignaling-nans -D_DEFAULT_SOURCE
cc -I/tmp/wabt/wasm2c -I/tmp/wabt/third_party/simde -std=c99 -c out/test/wasm2c/spec-multi-output/call/call.0_2.c -o out/test/wasm2c/spec-multi-output/call/call.0_2.o -O2 -Wall -Werror -Wno-unused -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -Wno-pass-failed -fno-optimize-sibling-calls -frounding-math -fsignaling-nans -D_DEFAULT_SOURCE
cc -I/tmp/wabt/wasm2c -I/tmp/wabt/third_party/simde -std=c99 -c out/test/wasm2c/spec-multi-output/call/call.0_3.c -o out/test/wasm2c/spec-multi-output/call/call.0_3.o -O2 -Wall -Werror -Wno-unused -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -Wno-pass-failed -fno-optimize-sibling-calls -frounding-math -fsignaling-nans -D_DEFAULT_SOURCE
cc -I/tmp/wabt/wasm2c -I/tmp/wabt/third_party/simde -std=c99 -c out/test/wasm2c/spec-multi-output/call/call-main.c -o out/test/wasm2c/spec-multi-output/call/call-main.o -O2 -Wall -Werror -Wno-unused -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -Wno-pass-failed -fno-optimize-sibling-calls -frounding-math -fsignaling-nans -D_DEFAULT_SOURCE
cc -I/tmp/wabt/wasm2c -I/tmp/wabt/third_party/simde -std=c99 -c /tmp/wabt/wasm2c/wasm-rt-impl.c -o out/test/wasm2c/spec-multi-output/call/wasm-rt-impl.o -O2 -Wall -Werror -Wno-unused -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -Wno-pass-failed -fno-optimize-sibling-calls -frounding-math -fsignaling-nans -D_DEFAULT_SOURCE
cc -I/tmp/wabt/wasm2c -I/tmp/wabt/third_party/simde -std=c99 -c /tmp/wabt/wasm2c/wasm-rt-exceptions-impl.c -o out/test/wasm2c/spec-multi-output/call/wasm-rt-exceptions-impl.o -O2 -Wall -Werror -Wno-unused -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -Wno-pass-failed -fno-optimize-sibling-calls -frounding-math -fsignaling-nans -D_DEFAULT_SOURCE
cc -I/tmp/wabt/wasm2c -I/tmp/wabt/third_party/simde -std=c99 -c /tmp/wabt/wasm2c/wasm-rt-mem-impl.c -o out/test/wasm2c/spec-multi-output/call/wasm-rt-mem-impl.o -O2 -Wall -Werror -Wno-unused -Wno-array-bounds -Wno-ignored-optimization-argument -Wno-tautological-constant-out-of-range-compare -Wno-infinite-recursion -Wno-pass-failed -fno-optimize-sibling-calls -frounding-math -fsignaling-nans -D_DEFAULT_SOURCE
cc out/test/wasm2c/spec-multi-output/call/call.0_0.o out/test/wasm2c/spec-multi-output/call/call.0_1.o out/test/wasm2c/spec-multi-output/call/call.0_2.o out/test/wasm2c/spec-multi-output/call/call.0_3.o out/test/wasm2c/spec-multi-output/call/call-main.o out/test/wasm2c/spec-multi-output/call/wasm-rt-impl.o out/test/wasm2c/spec-multi-output/call/wasm-rt-exceptions-impl.o out/test/wasm2c/spec-multi-output/call/wasm-rt-mem-impl.o -o out/test/wasm2c/spec-multi-output/call/call -lm
72/72 tests passed. It does seem to work for me with gcc 13 and clang 18 (and the tests work on GitHub Actions). |
Without this change, building generated wasm2c headers results in the following errors: