Closed catamorphism closed 1 year ago
Huh, usually Rust gets around this by setting RUSTC_BOOTSTRAP=1
, and usually when we bootstrap it's with a beta compiler, which does need that set by x.py
, and that would allow all the features. I wonder if RUSTC_BOOTSTRAP
wasn't set?
Huh, usually Rust gets around this by setting
RUSTC_BOOTSTRAP=1
, and usually when we bootstrap it's with a beta compiler, which does need that set byx.py
, and that would allow all the features. I wonder ifRUSTC_BOOTSTRAP
wasn't set?
It's set, but the command that's actually failing (it took some effort to figure out which executable was actually failing) is:
"/usr/bin/rustc" "--crate-name" "core" "--edition=2021" "library/core/src/lib.rs" "--error-format=json" "--json=diagnostic-rendered-ansi,artifacts,future-incompat" "--diagnostic-width=80" "--crate-type" "lib" "--emit=dep-info,metadata,link" "--cfg=bootstrap" "-Zunstable-options" "--check-cfg=values(bootstrap)"
And what's installed for me in /usr/bin/rustc
is a stable compiler. I realized after the fact that I can't use it to bootstrap, but with a different error message I might have noticed that sooner.
Forwards compatibility in diagnostics seems extremely hard. I think a much simpler and more helpful fix is to check the output of rustc --version
in bootstrap and give a hard error if it's not either the current version or N-1.
Note that the problem here is that you were trying to use 1.68 to build 1.70; it's unrelated to stable vs beta, the problem is that it was two versions behind instead of only one.
Mentoring instructions: in src/bootstrap/config.rs
, if build.rustc
is set, run that process with --version
. Compare that output to the contents of src/version
using the semver
crate; if the minor versions aren't either the same or 1 apart, give a hard error.
Note that this should also disallow e.g. building 1.68 with 1.69; we use deny-warnings in most cases and have no guarantees that unstable features will be the same between releases. Only building 1.68 with 1.67 or 1.68 should be allowed.
btw @catamorphism I've noticed you running into a few different bootstrap bugs the past few days — reading through https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html may or may not make it easier to diagnose these issues without having to spend ages interpreting the diagnostics. I'm also happy to chat about "how should this work" sorts of things on Zulip.
btw @catamorphism I've noticed you running into a few different bootstrap bugs the past few days — reading through https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html may or may not make it easier to diagnose these issues without having to spend ages interpreting the diagnostics.
Yes, I've read that.
I'm also happy to chat about "how should this work" sorts of things on Zulip.
Thanks!
Note that the problem here is that you were trying to use 1.68 to build 1.70; it's unrelated to stable vs beta, the problem is that it was two versions behind instead of only one.
The error message could be improved though. Maybe one could make the bump-stage0
to put rust-version = "<version of stage0 beta>"
into libcore/bootstrap's Cargo.toml?
@est31 I don't think rust-version is a good way to solve this, no - that won't give a warning or error if you use a future version to compile an older version. Also it won't be able to catch local-rebuild issues where the nightly version of the bootstrap compiler is too old. See my suggestion in https://github.com/rust-lang/rust/issues/110067#issuecomment-1500786014.
Forwards compatibility in diagnostics seems extremely hard. I think a much simpler and more helpful fix is to check the output of
rustc --version
in bootstrap and give a hard error if it's not either the current version or N-1.
Hmm, I'm afraid I might have said something unclear. I'm not asking for forward compatibility in diagnostics. The const_closures
feature was added in version 1.68.0, according to https://github.com/rust-lang/rust/blob/master/compiler/rustc_feature/src/active.rs#L343 , and I was using rustc version 1.68.2. So it should "know" about that feature, but my understanding is that when I was invoking rustc it was with flags that prevent unstable features from being used.
@catamorphism hmm, in that case something strange is going on because playground gives a much more reasonable error than the one you saw: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=72c1630fcbccba1d2df75abbe61a54bf
error[[E0658]](https://doc.rust-lang.org/stable/error_codes/E0658.html): const closures are experimental
--> src/lib.rs:2:13
|
2 | let _ = const move |a, b| NeverShortCircuit(f(a, b));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: [see issue #106003 <https://github.com/rust-lang/rust/issues/106003>](https://github.com/rust-lang/rust/issues/106003) for more information
@catamorphism what commit of rustc were you trying to build when you got this error? I'm going to see if I can replicate it locally.
@catamorphism what commit of rustc were you trying to build when you got this error? I'm going to see if I can replicate it locally.
I was trying to build 94524020ea12f7947275063b65f8b7d705be073e .
Ah ok, it was related to the context of the const
closure: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9c71507b2e0273d5062102e2cc0756e9
If you look at the same gist with beta, the error message is much better:
error[E0658]: const trait impls are experimental
--> src/lib.rs:5:24
|
5 | const fn foo() -> impl ~const FnMut(usize, usize) -> NeverShortCircuit {
| ^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
error[E0658]: const closures are experimental
--> src/lib.rs:6:5
|
6 | const move |a, b| NeverShortCircuit(f(a, b))
| ^^^^^
|
= note: see issue #106003 <https://github.com/rust-lang/rust/issues/106003> for more information
So I think this particular diagnostic issue has already been fixed. I still want to keep this issue open to track checking the version of the bootstrap compiler, though.
I'm trying to build Rust on a Tier 3 platform (
riscv64-alpine-linux-musl
; actually it'sriscv64-unknown-musl
that's listed in Tier 3, but I don't think that affects the problem). Since there are no snapshots for this platform, I installed rustc from the distro's package manager (apk) and created aconfig.toml
file to force using the pre-installed rustc rather than downloading snapshots:And the output of
rustc --version -v
:I ran
./x.py build
; when it got as far as building the core library, I got a series of errors that were very hard to make sense of until I realized that it's because core library code depends on unstable features and I was using a stable rustc to compile it:There were many more errors, but I think they all relate to unstable features.
It took me ages to figure out that (for example) the first error is due to the
const_closures
feature being disabled in stable.I understand that the stable compiler won't allow using unstable features even with
-Zunstable-options
, but is it possible for the parser to recognize this code even so and reject it with something like "featureconst_closures
is not enabled" instead of the much more generic "expected identifier" error?