Skip to content

Conversation

catamorphism
Copy link
Contributor

WARNING: This commit edits the auto-generated files wasip2.h and wasip2.c to add the _Noreturn attribute to exit_exit.

WARNING: This commit edits the auto-generated files wasip2.h
and wasip2.c to add the _Noreturn attribute to `exit_exit`.
@catamorphism catamorphism marked this pull request as ready for review August 11, 2025 18:08
@catamorphism
Copy link
Contributor Author

I'm not sure if wit-bindgen has a way to mark a function as "not returning" so it would generate the _Noreturn attribute automatically? I couldn't find one.

Copy link
Collaborator

@pchickey pchickey left a comment

Choose a reason for hiding this comment

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

wit-bindgen doesn't have the ability to annotate with _Noreturn because exit is the one and only special case which requires it. We had put it in witx and witx-bindgen to handle the special case, but decided not to carry on with that, since there's no way to nontrivially virtualize a call to exit. I'm resigned to exit always being a strange, special case.

In general the wasm vm still doesn't provide a reasonable way to implement exit besides host magic - I had thought thered be a way to implement it with the exceptions proposal, but since exit forbids running destructors, we'd have to come up with some way to avoid those if we were to implement exit by unwinding to the return site of main.

@@ -1084,7 +1084,7 @@ extern bool environment_initial_cwd(wasip2_string_t *ret);

// Imported Functions from `wasi:cli/[email protected]`
// Exit the current instance and any linked instances.
extern void exit_exit(exit_result_void_void_t *status);
_Noreturn extern void exit_exit(exit_result_void_void_t *status);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since editing these files is unexpected, but I agree necessary in this case, please add to the comment here noting this signature has been edited from the generated code. I'm not sure if anyone will ever read the comment, but it might make it stick out more in a git diff if the files get regenerated in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 58c47bc

@pchickey pchickey merged commit b530caf into WebAssembly:main Aug 13, 2025
16 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.

2 participants