-
Notifications
You must be signed in to change notification settings - Fork 8
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
Build the standard library with custom profile settings #2
Comments
A related (and IMO important) point is control over whether the standard library is (re)built in the first place, when a binary of it is available through rustup. Profile configuration is stable, so an existing app can for example set So I think Cargo should not change its default behavior for existing projects, at least those that are compatible with the Stable channel. But of course some other project may want to recompile std with different settings. So there needs to be an opt-in mechanism, presumably with some syntax in the root |
Yes, that is the intent. Compiling the standard library will be explicitly opt-in (this is different from RFC 2663). Now how exactly that will be spelled out in |
No this is bad. See what @SimonSapin said in #5 (comment), I couldn't put it better myself :).
I almost want to say it should change it. It's just a 1-time rebuild if we were to cache globally, and in the meantime rustup could ship more binaries? Baring that, I would say the |
Right, the opt in that I had in mind would not be about rebuilding v.s. not, but about whether the configured profile settings should override defaults for the standard library or not. If that mode / flag is enabled but the profile settings happen to match a configuration for which rustup has a binary available, that binary can still be used. |
Noting some issues with the current way profile-overrides work:
|
Is there any cmdline options that can be used to override the default "release" profile for the std library? |
It is possible to build stdlib with the same configuration as you build the rest of your code. This requires nightly and the build-std unstable feature. You are also required to explicitly state target so you need to do something like: |
@kjetilkjeka So as long as build-std feature is used, it automatically builds the std library using the same profile set in my |
I've used the feature to successfully enable debug symbols in the stdlib for debug builds. Based on this, without being familiar with the internals, I believe that is how it works. EDIT: From the documentation linked above "The functionality implemented today is behind a flag called -Z build-std. This flag indicates that Cargo should compile the standard library from source code using the same profile as the main build itself." |
@kjetilkjeka Thanks! |
This is a "use case" issue to try to clarify and discuss a use case, and how it will be addressed.
Currently the standard library is only available with the profile settings chosen when Rust is distributed. Currently that is the "release" profile with
opt-level
set to 2, andcodegen-units
set to 1.It may be desirable for some to use different settings.
"std-aware Cargo" should make this quite simple to accomplish. When Cargo builds the standard library, it will use whatever profile is in effect at the time.
If the user wants to use different settings specifically for the standard library, they will likely need to individually select the crates (like
core
orstd
) with profile overrides.The text was updated successfully, but these errors were encountered: