fix: re-add reference-types target feature stripped by strip = true#1015
fix: re-add reference-types target feature stripped by strip = true#1015connyay wants to merge 1 commit into
strip = true#1015Conversation
`strip = true` (alias for `strip = "symbols"`) drops the `target_features` custom section from the compiled wasm, which removes the `reference-types` advertisement that `wasm-bindgen` needs to run its externref transform. Without it, builds fail with "externref table required for catch wrappers". Generalize the wasm custom-section helpers in `producers.rs` so they can be reused, and add a new `reference_types` module that patches the feature back in after cargo and before `wasm-bindgen` runs. Fixes cloudflare#1014
| // `strip = true` drops the target_features section that wasm-bindgen | ||
| // needs to enable its externref transform. Patch it back in. | ||
| crate::reference_types::ensure_reference_types_feature(&wasm_path) | ||
| .context("Failed to ensure the reference-types target feature is advertised")?; |
There was a problem hiding this comment.
I'm torn on if patching is the right call here. https://rustwasm.github.io/docs/book/reference/code-size.html#optimizing-builds-for-code-size doesn't mention strip = true, so I am not sure how widespread strip = true or strip = "symbols" is in the wild.
Might be safer to detect strip = true or strip = "symbols" and raise an error instead. Open to suggestions/feedback here.
|
Could we just ungate the reference types feature check for externref transforms in wasm bindgen? Surely it can just be assumed now? |
yes. I'll take that approach |
hm. actually. would need to bump the wasm-bindgen rust version to 1.82 - is there appetite for that? |
|
We can't bump the library MSRV for another 4 months. The CLI MSRV (the one required by the actual processor), should already be above 1.82 though? |
strip = true(alias forstrip = "symbols") drops thetarget_featurescustom section from the compiled wasm, which removes thereference-typesadvertisement thatwasm-bindgenneeds to run its externref transform. Without it, builds fail with "externref table required for catch wrappers".Generalize the wasm custom-section helpers in
producers.rsso they can be reused, and add a newreference_typesmodule that patches the feature back in after cargo and beforewasm-bindgenruns.Fixes #1014