Skip to content

Prepare for exnref native build#16

Closed
zebreus wants to merge 3 commits into8.3.21-wasixfrom
prepare-for-exnref-build
Closed

Prepare for exnref native build#16
zebreus wants to merge 3 commits into8.3.21-wasixfrom
prepare-for-exnref-build

Conversation

@zebreus
Copy link

@zebreus zebreus commented Feb 19, 2026

Some changes to the build process that are required for an exnref exception handling build. Needs a published wasixcc version with exnref exception handling.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prepares the build infrastructure for exnref (exception reference) native builds in the WASIX environment. The changes update compiler optimization levels, adjust the wasm-opt pipeline to handle exception handling correctly, and bump the wasixcc toolchain version to v0.4.0 which includes exnref exception handling support.

Changes:

  • Increased optimization level from O2 to O4 for both compilation and wasm-opt stages
  • Split wasm-opt into two stages: first with debug info and asyncify, second for stripping and final optimization
  • Updated wasixcc toolchain from v0.3.0 to v0.4.0 to support exnref exception handling
  • Added php-debug.wasm intermediate build artifact to .gitignore

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
wasix-configure-eh.sh Updated CFLAGS, CXXFLAGS, and LIBS to use O4 optimization; added --enable-debug flag to configure
wasix-build-eh.sh Refactored wasm-opt to use two-stage approach with EH-incompatible passes disabled; generates intermediate php-debug.wasm
.gitignore Added php-debug.wasm to ignore list for the new intermediate build artifact
.github/workflows/wasix-pr.yaml Bumped wasixcc version from v0.3.0 to v0.4.0 for exnref support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7 to +8
# Some wasm-opt passes are not compatible with EH.
# When generating debug info, we don't need to disable them but without debug info we do, otherwise wasm-opt crashes.
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states that passes need to be disabled "without debug info" to avoid crashes, but in the actual implementation below, these passes are skipped in BOTH wasm-opt runs (both the one WITH debug info on line 13-26 and the one WITHOUT debug info on line 30-39). This creates an inconsistency between the comment and the implementation. Either the comment should be updated to reflect that passes are always skipped for EH compatibility, or the first wasm-opt run should not skip these passes if they're only problematic without debug info.

Suggested change
# Some wasm-opt passes are not compatible with EH.
# When generating debug info, we don't need to disable them but without debug info we do, otherwise wasm-opt crashes.
# Some wasm-opt passes are not compatible with EH, so we always disable them in this script
# to avoid issues (they have been observed to crash in certain configurations).

Copilot uses AI. Check for mistakes.
LIBS="-L$PHP_WASIX_DEPS/lib-eh --no-wasm-opt" \
CFLAGS="-g -flto -O4" \
CXXFLAGS="-g -flto -O4" \
LIBS="-L$PHP_WASIX_DEPS/lib-eh --no-wasm-opt -g -flto -O4" \
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LIBS environment variable now includes compiler flags (-g -flto -O4) mixed with linker flags. This is semantically incorrect as LIBS should only contain library-related linker flags (like -L and -l flags). The compiler flags should be specified in CFLAGS and CXXFLAGS (which they already are), not in LIBS. This could potentially cause issues with build tools that expect LIBS to contain only linker flags.

Suggested change
LIBS="-L$PHP_WASIX_DEPS/lib-eh --no-wasm-opt -g -flto -O4" \
LIBS="-L$PHP_WASIX_DEPS/lib-eh --no-wasm-opt" \

Copilot uses AI. Check for mistakes.
Comment on lines +28 to +39
# A second wasm-opt run for stripping debug
# info and running full O4
wasm-opt --strip-debug \
-O4 \
--no-validation \
--all-features \
--disable-gc \
--closed-world \
--skip-pass=flatten \
--skip-pass=dae-optimizing \
--skip-pass=inlining-optimizing \
sapi/cli/php-debug.wasm -o sapi/cli/php.wasm No newline at end of file
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second wasm-opt run is missing the --asyncify flag and related pass arguments (asyncify-imports, asyncify-ignore-indirect, max-func-params) that are present in the first run. Since this second run takes the output of the first asyncified run as input, this is likely intentional. However, the comment on line 28-29 doesn't mention this and only talks about stripping debug info and running full O4. Consider updating the comment to clarify that asyncify transformation has already been applied and doesn't need to be reapplied.

Copilot uses AI. Check for mistakes.
@Arshia001
Copy link

This is no longer needed after this wasixcc fix: wasix-org/wasixcc#55

Closing the PR.

@Arshia001 Arshia001 closed this Feb 24, 2026
@zebreus
Copy link
Author

zebreus commented Mar 4, 2026

@Arshia001 I don't know what you mean by that, this PR has nothing to do with that fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants