-
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
What will the UX be for enabling "build libstd" logic? #43
Comments
The feature gate to opt into this feature while it is unstable should be a As to the eventual behavior after the feature is stabilized, I feel that should not be a flag at all for this. Rather, Cargo should try to compile the standard library automatically if a binary is not already available for the requested |
Oh sorry right good point, should probalby discuss that possibility! I'm personally worried about automatically inferring the profile of libstd and switching to Even for missing targets though, that one's also pretty tricky. It's difficult to distinguish between the case of "I forgot to I'd love to eventually get to a world where we could automatically infer this, but I fear that it's pretty far away that we could robustly automatically infer whether |
Right, I also think that we should not change the semantics of existing manifests that run on the stable channel. This implies that
That’s a good point. When a std binary can be obtained either by spending bandwidth (rustup target add) or CPU time (recompile), there’s not an obvious answer as to which is prefereable.
In theory shouldn’t they work, if for example MinGW (or whatever other requirement) is available? |
Ah yeah it's also worth pointing out that my proposal at the top only included MinGW/wasi/etc are unfortunately pretty weird in how they're integrated with the compiler, but it's probably best to keep discussion for that on #30. |
There are cases where it might make sense to re-build libstd implicitly. For example, if the Ideally, at some point, rustc would be able to error when these issues happen, but that might disrupt the workflows of people using |
I wasn’t aware of such soundness issue, could you say more? It sounds worrying, since |
In a nutshell, target-features are part of the call ABI, but Rust does not take into account, yet. For example, for an x86 target without SSE linking these two crates shows the issue: // crate A
#[target_feature(enable = "sse")] pub fn foo(x: f32) -> f32 { x }
// crate B
extern "Rust" {
fn foo(x: f32) -> f32;
}
unsafe { assert_eq!(foo(42.0), 42.0) }; // UB The ABI of Instead of using Now, most features are compatible, e.g., if you have a target like x86_64-unknown-linux-gnu, which enables SSE2, and link against it a crate that enables SSE3 on top, then there is no change in the calling convention, and everything works. But if you try to, e.g., use something like The real fix for this would be for rustc to consider target-features part of the function ABI (e.g. |
The issue with I think the fact of the matter is that we just do not have a great mechanism of automatically inferring "libstd must be built from source". I think that factors into the UX of how we want to enable this feature eventually in terms of it should likely be opt-in but should also likely be very lightweight to opt-in (like |
Agreed. I think that the appropriate fix for the soundness bugs is for The role of Maybe the |
What's the status of this? The current requirement to pass the I know that there are a lot of details that need to be carefully worked out, but would it be possible to add some sort of unstable configuration key to the |
|
I actually have the opposite thought. If a lib crate depends on getting a fresh libstd or libcore relying only on |
I implemented a prototype with explicit std dependencies in |
I have posted a proposal for feedback at https://internals.rust-lang.org/t/build-std-and-the-standard-library/11459. |
This is intended to be a tracking issue for the eventual state of how one actually enables Cargo building libstd. Currently this is done via the
-Z build-std
flag. The-Z build-std
flag takes an optional list of parameters, but this optional list will ideally no longer be necessary once #5 is implemented.What should the eventual syntax for
-Z build-std
end up being in that case? (assuming the value of the flag is removed). A strawman proposal might be to add a configuration valuebuild.std
(defaults tofalse
) to the configuration. That wayCARGO_BUILD_STD=true
would enable it for a build, you could also use.cargo/config
, and with rust-lang/cargo#6699 could even be--config build.std=true
as a CLI flag.One question would be if we can infer this configuration value in some situations. For example if libstd is missing for the target you're building for, should we default to building libstd? In any case, things to think about!
The text was updated successfully, but these errors were encountered: