Skip to content

Divide data segments across all output files when using wasm2c #2626

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

white-axe
Copy link

wasm2c has a --num-outputs flag for splitting the output C file into smaller files to reduce compilation time and memory usage by the compiler, but it only splits the functions across the output files. The data segments are all still put in the first output file instead of being split across the output files. That can cause problems on some PowerPC platforms, where the PowerPC TOC places an upper limit on the size of a translation unit. I've modified the code generator to distribute the data segments across all the output files when the --num-outputs flag is set to something greater than one.

@keithw
Copy link
Member

keithw commented Aug 6, 2025

Cool! Can you add a test to https://github.com/WebAssembly/wabt/tree/main/test/wasm2c/spec-multi-output that exercises this please? I'm not sure we have anything that uses data segments, much less multiple ones.

@white-axe
Copy link
Author

The memory_init tests already test reading from memory with multiple data segments. Each of the data S-expressions in memory_init.wast is a data segment.

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