Skip to content

Feature/Stability staging is flaky #21230

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

Closed
nagisa opened this issue Jan 16, 2015 · 7 comments
Closed

Feature/Stability staging is flaky #21230

nagisa opened this issue Jan 16, 2015 · 7 comments

Comments

@nagisa
Copy link
Member

nagisa commented Jan 16, 2015

NB: This refers to the feature of making #[unstable] APIs unusable in release channels.

Currently, to allow bootstrap compilers to build standard library, the CFG_BOOTSTRAP_KEY environment variable (see #20663) should match some secret value decided at compile time of rustc. This has several problems:

  1. The key is very easy to find out (looking at build logs, running strings etc);
  2. Key generation is not cross platform. On BSDs and OS Xs the generated key is well known and currently is equal to N;
  3. It broke snapshots.

The proposed solution is to build two different versions of rustc for stage2/3 instead, depending on the situation:

  1. stage2/3 src/driver/driver.rs which can process unstable libraries (e.g. using `--cfg enable_unstable);
  2. stage2/3 libraries are built;
  3. stage2/3 src/driver/driver.rs which cannot process unstable libraries;
  4. Proper binary is packaged/shipped depending on the channel.

This has benefits of not having to do any environment variable dance during the build. It is also not really workaround-able without manually rebuilding rustc, unlike the current approach.

(also see logs)

cc @brson, @eddyb

@eddyb
Copy link
Member

eddyb commented Jan 16, 2015

You don't actually need to build librustc_driver twice, you can have two rustc binaries built with the same libs, but different configs for src/driver/driver.rs.
I would suggest having the default set a TLS key before calling into librustc_driver, while the release version wouldn't do that extra step. The build system could then package bin/rustc-stable (or whatever name it would have) as bin/rustc for the release.

@nagisa
Copy link
Member Author

nagisa commented Jan 16, 2015

This approach is made harder by the fact rustdoc test driver depends on get_unstable_features_settings(). This means that to use the proposed approach not only two versions of rustc, but also two versions of rustdoc have to be built.

(alternatively two versions of librustc_driver can be built)

@eddyb
Copy link
Member

eddyb commented Jan 16, 2015

Building two versions of both rustc and rustdoc shouldn't be a problem - in fact, it probably makes some things simpler by using the same release packaging logic for both binaries.

@kmcallister kmcallister added A-infrastructure A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Jan 16, 2015
nagisa added a commit to nagisa/rust that referenced this issue Jan 16, 2015
Do not use magic values to forbid the use of unstable values.

WIP to fix rust-lang#21230
@brson
Copy link
Contributor

brson commented Jan 16, 2015

The issue of whether it can be worked around does not really matter to me - if people really want to cheat then it's in their hands.

It seems more complicated to me to teach the build system to build a second driver than to do what we're presently doing.

Can you tell me how it broke snapshots?

@eddyb
Copy link
Member

eddyb commented Jan 17, 2015

@brson Can you really claim the release can't compile unstable code when I have a grep/sed one-liner to do it on linux (without patching the binary) and on OSX you can turn off the unstable warnings in the alpha with RUSTC_BOOTSTRAP_KEY=N.
I wouldn't care much for any of this (@bstrie might point out the problem of negative reactions to what is essentially a "security by obscurity" scheme with all its typical issues and no upsides), if it didn't break snapshots.
Which happened because the keys on the snapshot builder are unique to each build, amd without them, the snapshot behaves like a nightly, warning on unstable (which turns into errors in some cases).
Oh, and getting the build system to build two versions of the same binary is easier than the key stuff: foreach stable, 0 1 in the last part of mk/target.mk, and then have TARGET_TOOL change the file name and add a --cfg flag when the stable argument is 1. @nagisa is already working on this, and seems to have everything else ready in the latest commit mentioned on this issue.
What's a bit more tricky is getting make install and the release process to pick the right versions of the files.

@brson
Copy link
Contributor

brson commented Jan 17, 2015

@eddyb I'm sorry you are feeling so hurt about this. I will fix the snapshot situation.

Don't confuse this with a security issue. There is no security involved here. The bootstrap key is just a token effort do discourage people from breaking the feature gates - it was a fun lark. We do not need to implement some kind of DRM scheme in the rust compiler.

bors added a commit that referenced this issue Jan 18, 2015
This fixes the issues mentioned in #21236, as well as the one #21230 where `CFG_BOOTSTRAP_KEY` was being set to simply 'N'. It changes the build such that `RUSTC_BOOTSTRAP_KEY` is only exported on -beta and -stable, so that the behavior of the -dev, -nightly, and snapshot compilers is the same everywhere.

Haven't run it completely through 'make check' yet, but the I have verified that the aforementioned issues are fixed.

r? @alexcrichton cc @eddyb
bors added a commit that referenced this issue Jan 18, 2015
This fixes the issues mentioned in #21236, as well as the one #21230 where `CFG_BOOTSTRAP_KEY` was being set to simply 'N'. It changes the build such that `RUSTC_BOOTSTRAP_KEY` is only exported on -beta and -stable, so that the behavior of the -dev, -nightly, and snapshot compilers is the same everywhere.

Haven't run it completely through 'make check' yet, but the I have verified that the aforementioned issues are fixed.

r? @alexcrichton cc @eddyb
@alexcrichton alexcrichton removed the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label Aug 17, 2015
@alexcrichton
Copy link
Member

This is essentially obsoleted by #32731, so closing

spikespaz pushed a commit to spikespaz/dotwalk-rs that referenced this issue Aug 29, 2024
This fixes the issues mentioned in rust-lang/rust#21236, as well as the one rust-lang/rust#21230 where `CFG_BOOTSTRAP_KEY` was being set to simply 'N'. It changes the build such that `RUSTC_BOOTSTRAP_KEY` is only exported on -beta and -stable, so that the behavior of the -dev, -nightly, and snapshot compilers is the same everywhere.

Haven't run it completely through 'make check' yet, but the I have verified that the aforementioned issues are fixed.

r? @alexcrichton cc @eddyb
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

No branches or pull requests

5 participants