Skip to content

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