-
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
add a RUSTLINKFLAGS environment variable #4349
Comments
This is a pressing enough problem that I don't think it's worth waiting for custom profiles (as those may take awhile to get underway). Do you have a gist of the errors you were seeing with Failing that though I may prefer to take a more targeted route for now where we just allow LTO (e.g. |
A random thought I just had is that an argument to cargo that allows to override what is set in Cargo.toml would go a long way (similarly to e.g.
|
Hm yeah an excellent point! It's worth noting though that cargo's system configuration is pretty different than Cargo.toml configuration, but I think we should make an exception for profiles which really should be build time configuration |
The error when
which I think fits in with your suggestion of dropping the warning?
I can't think of any problems at the moment! I like the |
If we're going to fix this in a simple way, making rustc not warn about |
The problem with custom profiles is that they're quadratic. You may need variants for debug and non-debug. Opt vs. no-opt. LTO vs no-LTO, abort panics vs. unwind, etc. |
Ah yes, indeed! In retrospect I think at most a warning should be emitted in that case and in reality we should just ignore it in the compiler, doing a 'best effort' thing when possible and otherwise ignoring it for things like rlibs.
Indeed! I'll comment on the PR wrt this strategy. |
Cross-linking https://bugzilla.mozilla.org/show_bug.cgi?id=1386371 here |
For us, this is primarily right now a size issue. See: https://internals.rust-lang.org/t/rust-staticlibs-and-optimizing-for-size/5746 For more information, there are these two issues: rust-lang/cargo#4349 https://bugzilla.mozilla.org/show_bug.cgi?id=1386371 The basic issue here is that a build with LTO off (and a trivial change to add a `println!` takes 14s here, and with it on takes 38s. However, with LTO off the stripped size of `librpmostree_rust.a` is `6M`, with LTO on it's `1.1M`. I named this `--enable-lto` as I'd like to investigate doing this for the C code too.
For us, this is primarily right now a size issue. See: https://internals.rust-lang.org/t/rust-staticlibs-and-optimizing-for-size/5746 For more information, there are these two issues: rust-lang/cargo#4349 https://bugzilla.mozilla.org/show_bug.cgi?id=1386371 The basic issue here is that a build with LTO off (and a trivial change to add a `println!` takes 14s here, and with it on takes 38s. However, with LTO off the stripped size of `librpmostree_rust.a` is `6M`, with LTO on it's `1.1M`. I named this `--enable-lto` as I'd like to investigate doing this for the C code too. Closes: #1664 Approved by: jlebon
If I'm understanding correctly, there is a somewhat related RFC at rust-lang/rfcs#3310 |
The motivating example here is when you want to have development and release profiles with
lto = false
, because LTO is so expensive. Why not putlto = true
in your release profile? Because the release profile might not be used for releases, per se; it might be used for people doing local development, and they don't want to bear the burden of compiling with LTO all the time. They want to compile with optimization on so at least their performance measurements are not completely out of whack.But you do want to compile with LTO at certain times: when you're doing a formal release of your software, for instance. It would be convenient to turn LTO on via
-C lto
inRUSTFLAGS
...but-C lto
isn't valid for all places whereRUSTFLAGS
would be passed.Hence the request for a
RUSTLINKFLAGS
or similar that would specify flags to be used in the final link of a binary artifact.This could be made somewhat superfluous by #2007, where we could specify another profile for "release releases", but it might still be handy to have for flags that can't be injected via
Cargo.toml
./cc @luser @glandium
The text was updated successfully, but these errors were encountered: