Skip to content
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

Bootstrapping unstable code from a stable compiler #29557

Closed
brson opened this issue Nov 4, 2015 · 4 comments · Fixed by #32942
Closed

Bootstrapping unstable code from a stable compiler #29557

brson opened this issue Nov 4, 2015 · 4 comments · Fixed by #32942

Comments

@brson
Copy link
Contributor

brson commented Nov 4, 2015

The stable Rust compiler requires the nightly Rust compiler to build. This is no good for distros that want to bootstrap from their own toolchain and don't want to maintain a nightly toolchain just for building Rust. We'll teach the Rust makefiles to deal with bootstrapping off the stable compiler transparently (the stable compiler already contains nightly features, just inaccessible).

https://internals.rust-lang.org/t/perfecting-rust-packaging-the-plan/2767

@brson
Copy link
Contributor Author

brson commented Dec 28, 2015

@eddyb may have some ideas abut this

@eddyb
Copy link
Member

eddyb commented Dec 28, 2015

If distros don't have anything against multiple packages, they can generate, e.g. rustc-unstable-1.5 which has only a tiny wrapper script setting the appropriate env var.

Otherwise, we could put an "unlocked" rustc in $prefix/lib/rustlib/$triple/bin/rustc_driver and then install a wrapper script as $prefix/bin/rustc for stable releases, which passes --disable-unstable (with no flag to re-enable unstable features).

Then our build system can look for a compatible $prefix/lib/rustlib/$triple/bin/rustc_driver, and check whether it's actually compatible, and if so, use it.

@cuviper
Copy link
Member

cuviper commented Dec 28, 2015

If we just relax the bootstrap key a little, and make it a statically-known value instead of a "secret", then there would be no need for wrapper scripts. The build system could just export that value applicable to stage0 invocations too.

As the configure script says itself, that secret is just meant to be a mild deterrent. By default it's only a %H:%M:%S timestamp -- that's easily grepped from strings librustc-*.so for a determined user. I think it would still be a good enough deterrent to be something fixed like "unsupported-rustc-bootstrap-mode". (Now that I say it, I guess each distro could choose their own fixed CFG_BOOTSTRAP_KEY already.)

A statically-known bootstrap key is not that different from an unlocked rustc_driver, deterrent-wise.

Aside, it might be nice if the resulting UnstableFeatures value showed up in debuginfo somewhere, perhaps in DW_AT_producer.

@SimonSapin
Copy link
Contributor

Would this include cross-compiling std and friends to a target not in http://static.rust-lang.org/dist/rust-std-*.tar.gz? Even if I wanted to use Nightly for that, I’d have to guess which nightly works for building e.g. 1.5.0 stable.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 19, 2016
This commit removes all infrastructure from the repository for our so-called
snapshots to instead bootstrap the compiler from stable releases. Bootstrapping
from a previously stable release is a long-desired feature of distros because
they're not fans of downloading binary stage0 blobs from us. Additionally, this
makes our own CI easier as we can decommission all of the snapshot builders and
start having a regular cadence to when we update the stage0 compiler.

A new `src/etc/get-stage0.py` script was added which shares some code with
`src/bootstrap/bootstrap.py` to read a new file, `src/stage0.txt`, which lists
the current stage0 compiler as well as cargo that we bootstrap from. This script
will download the relevant `rustc` package an unpack it into `$target/stage0` as
we do today.

One problem of bootstrapping from stable releases is that we're not able to
compile unstable code (e.g. all the `#![feature]` directives in libcore/libstd).
To overcome this we employ two strategies:

* The bootstrap key of the previous compiler is hardcoded into `src/stage0.txt`
  (enabled as a result of rust-lang#32731) and exported by the build system. This enables
  nightly features in the compiler we download.
* The standard library and compiler are pinned to a specific stage0, which
  doesn't change, so we're guaranteed that we'll continue compiling as we start
  from a known fixed source.

The process for making a release will also need to be tweaked now to continue to
cadence of bootstrapping from the previous release. This process looks like:

1. Merge `beta` to `stable`
2. Produce a new stable compiler.
3. Change `master` to bootstrap from this new stable compiler.
4. Merge `master` to `beta`
5. Produce a new beta compiler
6. Change `master` to bootstrap from this new beta compiler.

Step 3 above should involve very few changes as `master` was previously
bootstrapping from `beta` which is the same as `stable` at that point in time.
Step 6, however, is where we benefit from removing lots of `#[cfg(stage0)]` and
get to use new features. This also shouldn't slow the release too much as steps
1-5 requires little work other than waiting and step 6 just needs to happen at
some point during a release cycle, it's not time sensitive.

Closes rust-lang#29555
Closes rust-lang#29557
bors added a commit that referenced this issue Apr 20, 2016
mk: Bootstrap from stable instead of snapshots

This commit removes all infrastructure from the repository for our so-called
snapshots to instead bootstrap the compiler from stable releases. Bootstrapping
from a previously stable release is a long-desired feature of distros because
they're not fans of downloading binary stage0 blobs from us. Additionally, this
makes our own CI easier as we can decommission all of the snapshot builders and
start having a regular cadence to when we update the stage0 compiler.

A new `src/etc/get-stage0.py` script was added which shares some code with
`src/bootstrap/bootstrap.py` to read a new file, `src/stage0.txt`, which lists
the current stage0 compiler as well as cargo that we bootstrap from. This script
will download the relevant `rustc` package an unpack it into `$target/stage0` as
we do today.

One problem of bootstrapping from stable releases is that we're not able to
compile unstable code (e.g. all the `#![feature]` directives in libcore/libstd).
To overcome this we employ two strategies:

* The bootstrap key of the previous compiler is hardcoded into `src/stage0.txt`
  (enabled as a result of #32731) and exported by the build system. This enables
  nightly features in the compiler we download.
* The standard library and compiler are pinned to a specific stage0, which
  doesn't change, so we're guaranteed that we'll continue compiling as we start
  from a known fixed source.

The process for making a release will also need to be tweaked now to continue to
cadence of bootstrapping from the previous release. This process looks like:

1. Merge `beta` to `stable`
2. Produce a new stable compiler.
3. Change `master` to bootstrap from this new stable compiler.
4. Merge `master` to `beta`
5. Produce a new beta compiler
6. Change `master` to bootstrap from this new beta compiler.

Step 3 above should involve very few changes as `master` was previously
bootstrapping from `beta` which is the same as `stable` at that point in time.
Step 6, however, is where we benefit from removing lots of `#[cfg(stage0)]` and
get to use new features. This also shouldn't slow the release too much as steps
1-5 requires little work other than waiting and step 6 just needs to happen at
some point during a release cycle, it's not time sensitive.

Closes #29555
Closes #29557
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants