Intercept cargo's -C strip in the rustc wrapper instead of predicting it - #5737
Open
nicoburns wants to merge 2 commits into
Open
Intercept cargo's -C strip in the rustc wrapper instead of predicting it#5737nicoburns wants to merge 2 commits into
-C strip in the rustc wrapper instead of predicting it#5737nicoburns wants to merge 2 commits into
Conversation
The CLI previously injected --config profile.<x>.strip=false and predicted the profile's strip setting with get_strip_setting(), which missed cargo's implicit default of stripping debuginfo when debuginfo is disabled (Rust 1.77+), leaving ~1.3MB of DWARF in release wasm and crashing wasm-opt. Now the rustc wrapper removes the -C strip=... flag cargo computed and records its value; post_process_executable applies it with rust-objcopy after asset extraction. Fixes #5119
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #5119 (wasm-opt SIGABRT "compile unit size was incorrect" on
dx build --web --release, and more generally ~1.3MB of leftover std DWARF in release wasm).Since #4966, dx injects
--config profile.<x>.strip=falseso manganis asset symbols survive the build, then strips manually inpost_process_executable()based onget_strip_setting(). That prediction only honored an explicitstripkey in Cargo.toml, missing Cargo's implicit default (since Rust 1.77, debuginfo is stripped when the profile's debuginfo is off — as release is by default). The un-stripped DWARF then gets rewritten by wasm-bindgen and crashes binaryen's DWARF re-emitter.Instead of predicting what Cargo would do, this PR lets Cargo compute the strip setting and intercepts it in the rustc wrapper (
RUSTC_WORKSPACE_WRAPPER), which dx already uses for Base/Fat builds:profile_args()no longer injectsstrip=false, andget_strip_setting()is deleted.inheritschains,.cargo/config.toml[profile]tables,CARGO_PROFILE_*env vars, and the implicit 1.77 default.wasm_splitbuilds are still never stripped.versionto 2 so stale captures (with-C stripstill inargsand nostripfield) aren't replayed.This is the more robust alternative to #5736, which instead mirrors Cargo's implicit default inside
get_strip_setting()(and cannot see.cargo/config.toml/ env-var overrides).Verification
With a fresh
cargo newapp depending ondioxus(featureweb), using dx built from this branch:dx build --web --release: output wasm has no.debug_*custom sections (on main, ~1.1MB of.debug_*remains).dx build --web(dev): debug sections retained.strip = "symbols": binary is fully stripped (--strip-all, nonamesection), assets still extracted.debug = trueand nostripkey: not stripped.CARGO_PROFILE_RELEASE_STRIP=none dx build --web --release: env override honored, debuginfo retained (the key case cli: mirror Cargo's implicit strip default when manually stripping binaries (fixes wasm-opt SIGABRT) #5736 can't handle).dx build --web --fat-binary: fat build path still works.cargo fmtandcargo clippy -p dioxus-cliare clean.Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/51b6fb74d9a0452985a2f6840ff2d2bd
Requested by: @nicoburns