Exclude symbols starting with '_Z' from user exports #24738
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Regression introduced in: Emscripten 4.0.3
Affects: SIDE_MODULE builds which contain mangled Rust standard library symbols.
SIDE_MODULE builds fail with "invalid export name" errors:
Reproduction: nickpdemarco/emsdk-export-bug
Emscripten's post-processing incorrectly classifies mangled symbols (internal implementation details) as user exports, triggering validation that fails on invalid WebAssembly identifier characters.
Note: this issue existed prior to 4.0.3, but this change exposed it.
Analysis
Expected behavior: Only explicitly requested functions should be exported from SIDE_MODULE builds
Actual behavior: Internal mangled symbols are misclassified as user exports
Pipeline breakdown (from debug analysis):
EXPORTED_FUNCTIONS=["_add_numbers","_multiply"]
wasm-ld --export=add_numbers --export=multiply
_Z*
symbols as user exports, validation failsThe problematic symbol exists in the WASM as an internal implementation detail but was never requested for export by the user or passed to the linker.