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

Improve fidelity of rustc-crates-on-stable test #133168

Closed

Conversation

jieyouxu
Copy link
Member

Use RUSTC_BOOTSTRAP=-1 to make the underlying rustc think it is a stable rustc, really making sure that these compiler crates can be compiled on the stable channel.

cc @Kobzol who suggested this in #132993 (comment), thanks!

You can tell this works because if I keep .env("RUSTFLAGS", "-Zallow-features="), the underlying rustc thinks it is very stable and thus rejects the unstable -Zallow-features flag.

error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `X:\repos\rust\build\x86_64-pc-windows-msvc\stage1\bin\rustc.exe - --crate-name ___ --print=file-names -Zallow-features= --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit code: 1)
  --- stderr
  error: the option `Z` is only accepted on the nightly compiler

r? compiler

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 18, 2024
@jieyouxu
Copy link
Member Author

Asked cargo team about if cargo has some way of pretending it is a stable cargo in https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Pretend.20to.20be.20a.20stable.20cargo.

@jieyouxu jieyouxu added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 18, 2024
@lqd
Copy link
Member

lqd commented Nov 18, 2024

While it should be doable for rustc, IIRC cargo features are checked for the workspace and not only the crates you build (you could for example add -Zallow-features='' to reject unstable cargo features if it doesn't support opting into its stable behavior) which would then also prevent other compiler crates from using e.g. edition 2024.

Which is also maybe a reason why stage0 cargo could or could not be used to simulate this stable cargo. But again any behavior here should not impact the crates that r-a doesn't use.

@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 18, 2024
@jieyouxu jieyouxu force-pushed the modify-rustc-crates-stable-test branch from bb390e8 to f9721de Compare November 18, 2024 15:40
@jieyouxu jieyouxu force-pushed the modify-rustc-crates-stable-test branch from f9721de to e255082 Compare November 18, 2024 15:42
@jieyouxu
Copy link
Member Author

jieyouxu commented Nov 18, 2024

While it should be doable for rustc, IIRC cargo features are checked for the workspace and not only the crates you build (you could for example add -Zallow-features='' to reject unstable cargo features if it doesn't support opting into its stable behavior) which would then also prevent other compiler crates from using e.g. edition 2024.

Which is also maybe a reason why stage0 cargo could or could not be used to simulate this stable cargo. But again any behavior here should not impact the crates that r-a doesn't use.

Good point about the workspace because other compiler crates necessarily require using unstable cargo features, so we can't ask this cargo to pretend that it is a stable cargo. However, what I can do here is:

  1. Use -Zallow-features= on a stage1 (or whatever) cargo to ask that no unstable cargo features are allowed for the list of compiler crates.
  2. Use RUSTC_BOOTSTRAP=-1 to double-check that the underlying compiler crates can compile on stable.

EDIT: right, cargo -Zallow-features='' propagates -Zallow-features='' to the underlying rustc, which can't work because rustc thinks it's stable 🤣

@jieyouxu
Copy link
Member Author

I thought about this, and I don't think this change is quite correct because it must not affect other compiler crates. Thanks for the reminder @lqd!

@jieyouxu jieyouxu closed this Nov 18, 2024
@jieyouxu jieyouxu deleted the modify-rustc-crates-stable-test branch November 18, 2024 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants