-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Precedence of cargo rustc -- <flags>
is too low to override flags set by Cargo
#14346
Comments
Decreases linux release wheel size by 2MB. See rust-lang/cargo#14346 Fixes #5683
I had a hunch that this might be related to #13257, which landed in Rust 1.77.0. Trying with Rust
But with
So it does seem like #13257 could be the cause? I'm presuming the command passed to rustc ends up being |
Yeah your observation is correct. It's about precedence.
I have no idea why rustflags from I am not sure how to document the behavior. Adding rustflags is usually a lower level thing, and the same regression might happen again for other kind of rustflags. Generally using |
Another approach is we move cargo/src/cargo/core/compiler/mod.rs Line 686 in d3e84f0
It has less impact to the precedence of other user-overridable rustflags ( |
Use `-C strip=symbols` instead of `-C link-arg=-s`. Still broken due to rust-lang/cargo#14346, but i think it's the right modernization anyway.
Use `-C strip=symbols` instead of `-C link-arg=-s`. Still broken due to rust-lang/cargo#14346, but i think it's the right modernization anyway.
Hmm, I didn't think of that. Yeah, this is tricky, but it also happens with other rustc flags set by Cargo, it just didn't happen for If you use the @weihanglo I think that it would make sense to raise the priority of the |
I have already put this on the Cargo triage agenda, but I was out for family issues for the past two weeks. A zulip thread sounds good to me as a start |
Awesome, thanks! |
This is kinda accepted with some requirements:
|
Re-opened to track the stabilization of #14587. In case of the new precedence start blocking your builds, please let us know and use |
-C strip=symbols
doesn't work like strip = true
cargo rustc -- <flags>
is too low to override flags set by Cargo
Original issue title:
-C strip=symbols
doesn't work likestrip = true
Problem
Reproducer: https://github.com/konstin/strip-reproducer/blob/main/compile.sh
With the default linker on linux, passing
-C link-arg=-s
,-C strip=symbols
and-C strip=debuginfo
tocargo rustc
all don't strip the binary properly as settingstrip = true
does, even though the docs say "The strip option controls the -C strip flag".In maturin we expose a
--strip
option, since small size is important for publishing. We pass this on tocargo rustc
, historically with-C link-arg=-s
, but i also tried with-C strip=symbols
. This does strip some debuginfo, 40MB -> 37MB in the case of uv, but not down to 30MB for the fully stripped binary (astral-sh/uv#5683). In the minimal reproducer, onlystrip = true
shows any effect.Note that this only happens with the default linker, mold strips properly in both cases.
Steps
https://github.com/konstin/strip-reproducer/blob/main/compile.sh
Create a new project with
cargo new strip-reproducer
, then run:Possible Solution(s)
There should ideally be a cli option to strip like
strip = true
does, or the docs should be adjusted on the differences betweenstrip = true
and the-C
options.Notes
No response
Version
The text was updated successfully, but these errors were encountered: