Skip to content

Don't change WASM_EXCEPTIONS mode when setting -fno-exceptions#26184

Merged
dschuff merged 1 commit intoemscripten-core:mainfrom
dschuff:ex-sj
Jan 28, 2026
Merged

Don't change WASM_EXCEPTIONS mode when setting -fno-exceptions#26184
dschuff merged 1 commit intoemscripten-core:mainfrom
dschuff:ex-sj

Conversation

@dschuff
Copy link
Member

@dschuff dschuff commented Jan 28, 2026

We have 3 main user-facing EH flags, -fwasm-exceptions, -fexceptions,
and -fno-exceptions. IIRC they aren't supposed to be mutually exclusive,
-fwasm-exceptions` composes with the other 2, setting the mode of codegen,
where the other 2 set whether exceptions compile.

If you do em++ -fno-exceptions -fwasm-exceptions on a file that has try/catch,
you get the expected compile-time error. However if you do
em++ -fwasm-exceptions -fno-exceptions you should get the same error, but
instead you get
clang++: error: invalid argument '-fwasm-exceptions' not allowed with '-enable-emscripten-sjlj'.
This is because the underlying clang is indeed getting passed the
-mllvm -enable-emscripten-sjlj flag in the latter case but not the former case.

We have 3 main user-facing EH flags, `-fwasm-exceptions`, `-fexceptions`,
and `-fno-exceptions`. IIRC they aren't supposed to be mutually exclusive,
-fwasm-exceptions` composes with the other 2, setting the mode of codegen,
where the other 2 set whether exceptions compile.

If you do `em++ -fno-exceptions -fwasm-exceptions` on a file that has try/catch,
you get the expected compile-time error. However if you do
`em++ -fwasm-exceptions -fno-exceptions` you should get the same error, but
instead you get
`clang++: error: invalid argument '-fwasm-exceptions' not allowed with '-enable-emscripten-sjlj'`.
This is because the underlying clang is indeed getting passed the
`-mllvm -enable-emscripten-sjlj` flag in the latter case but not the former case.
@dschuff dschuff requested a review from aheejin January 28, 2026 01:01
@dschuff
Copy link
Member Author

dschuff commented Jan 28, 2026

I think this is an OK solution? aside from the effect tested for here, it will affect the error checking for combinations with settings like DISABLE_EXCEPTION_CATCHING, but I think not in a way that should break things?

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me

Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

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

I can't figure out why the error changes from the top of my head, but -fno-exceptions changing the exception kind is certainly weird to me.

@dschuff dschuff merged commit 926214f into emscripten-core:main Jan 28, 2026
36 checks passed
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