Skip to content

wasm-smith: add --module-shape option. #2255

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

Merged
merged 1 commit into from
Jul 15, 2025

Conversation

mobsceneZ
Copy link
Contributor

This PR fixes #2250 and the key changes are summarized as follows:

  • Add a new option called module_shape into wasm-smith which automatically disables available_imports and exports when enabled;
  • For simplicity, we handle the imports and exports declared in the shape module together in a single function: _imports_exports_from_module_shape. And this function presents two notable differences when compared with function _arbitrary_imports_from_available and _required_exports:
    1. To adhere more closely to the meaning of "module shape", it copies all declared imports into the target module, rather than randomly selecting a subset. As a result, defined limits such as max_funcs may be exceeded;
    2. Relying on wasmparser::Validator for type information, as the _required_exports does, would introduce the inconvenient step of converting CoreTypeId back to ModuleIndex. To avoid this, this function directly copies the entire type section from the shape module to the target module, which also aligns with the implementation of _arbitrary_imports_from_available;

Please feel free to share any suggestions/concerns.

@mobsceneZ mobsceneZ requested a review from a team as a code owner July 14, 2025 15:17
@mobsceneZ mobsceneZ requested review from dicej and removed request for a team July 14, 2025 15:17
Copy link
Collaborator

@dicej dicej left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! Looks good to me overall; please see the comment inline about panicking on error.

@dicej dicej added this pull request to the merge queue Jul 15, 2025
Merged via the queue into bytecodealliance:main with commit f0cb97d Jul 15, 2025
32 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.

Wasm-smith's --exports option does not support exporting globals with GC types
2 participants