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

Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0 #106767

Merged
merged 1 commit into from
Jan 25, 2023

Conversation

chbaker0
Copy link
Contributor

Two locations check whether this build-time environment variable is defined. Allowing it to be explicitly disabled with a "0" value is useful, especially for integrating with external build systems.

Two locations check whether this build-time environment variable is
defined. Allowing it to be explicitly disabled with a "0" value is
useful, especially for integrating with external build systems.
@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2023

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 12, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@Mark-Simulacrum
Copy link
Member

Allowing it to be explicitly disabled with a "0" value is useful, especially for integrating with external build systems.

Can you say more about the motivation here? In general it seems a little suspicious to be compiling these checks in a way that something else is trying to enable feature gating and you're aiming to override that.

Can you link/name the build system in question, perhaps?

@Mark-Simulacrum Mark-Simulacrum 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 Jan 14, 2023
@chbaker0
Copy link
Contributor Author

In general it seems a little suspicious to be compiling these checks in a way that something else is trying to enable feature gating and you're aiming to override that

This is not the issue at play. Rather, it's to let a build system keep track of all environment variables needed for a target. The goal is just dependency correctness.

The specific issue is integrating with GN, Chromium's build system. A GN Rust target definition can set environment variables for its rustc invocation. However, you can't explicitly unset a variable.

GN's invokes rustc asking it to produce an depfile, which will contain any build-time environment variables as well. GN notices this, but also notices the variable is unaccounted for in the target definition, so it will rebuild that target every time.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 16, 2023
@Mark-Simulacrum
Copy link
Member

Are you trying to compile rustc or libtest during a GN-managed build? These variables are only read at compile-time of rustc itself, not by regular invocations of rustc.

Part of my confusion is that there are many more such variables in rustc, I think, and presumably not all of them are being managed by rustc.

--

Regardless of whether this solves your particular use case, I think I'm OK merging this PR -- wanting to always set an environment variable seems largely reasonable. I would caution that in an ideal world, this would be left at 1 (i.e., you do not enable unstable features by default in GN/Chromium), and instead rely on RUSTC_BOOTSTRAP and -Zallow-features to more selectively enable features (if needed at all).

@Mark-Simulacrum Mark-Simulacrum 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 Jan 21, 2023
@chbaker0
Copy link
Contributor Author

Are you trying to compile rustc or libtest during a GN-managed build? These variables are only read at compile-time of rustc itself, not by regular invocations of rustc.

Yes, building libtest in a GN-managed build. Essentially we're doing the equivalent of Cargo's build-std feature but within Chromium's GN build. The change to rustc_feature isn't even necessary for us since we build rustc the usual way: from a Rust checkout using x.py. But I figured keeping the two lines in sync was good.

Part of my confusion is that there are many more such variables in rustc, I think, and presumably not all of them are being managed by rustc.

Maybe this is an ad-hoc solution but this was the only env dependency reported by rustc that was not accounted for by GN (and could not be because setting it to anything would break the build).

I would caution that in an ideal world, this would be left at 1 (i.e., you do not enable unstable features by default in GN/Chromium), and instead rely on RUSTC_BOOTSTRAP and -Zallow-features to more selectively enable features (if needed at all).

We use a nightly or dev toolchain, so normally this would not be defined when building libtest. We have no intention to use this outside of the libtest build.

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jan 24, 2023

📌 Commit 0a03d1c has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 24, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 25, 2023
Rollup of 9 pull requests

Successful merges:

 - rust-lang#105552 (Add help message about function pointers)
 - rust-lang#106583 (Suggest coercion of `Result` using `?`)
 - rust-lang#106767 (Allow setting CFG_DISABLE_UNSTABLE_FEATURES to 0)
 - rust-lang#106823 (Allow fmt::Arguments::as_str() to return more Some(_).)
 - rust-lang#107166 (rustc_metadata: Support non-`Option` nullable values in metadata tables)
 - rust-lang#107213 (Add suggestion to remove if in let..else block)
 - rust-lang#107223 (`sub_ptr()` is equivalent to `usize::try_from().unwrap_unchecked()`, not `usize::from().unwrap_unchecked()`)
 - rust-lang#107227 (`new_outside_solver` ->  `evaluate_root_goal`)
 - rust-lang#107232 (rustdoc: simplify settings popover DOM, CSS, JS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9e6873f into rust-lang:master Jan 25, 2023
@rustbot rustbot added this to the 1.69.0 milestone Jan 25, 2023
aarongable pushed a commit to chromium/chromium that referenced this pull request Feb 17, 2023
Instead of hard-coding these into gnrt, which necessitates rebuilding
it for any cfg changes, this adds a gnrt_config.toml to supply these
options at runtime.

This CL also adds a couple libc cfgs required as of the latest Rust
roll, and adds an env definition for libtest (which was blocked on
rust-lang/rust#106767).

Bug: 1368806
Change-Id: I542485b9cbed3f2a6fa7c2e72cb9df65da417281

Cq-Include-Trybots: luci.chromium.try:android-rust-arm-dbg,android-rust-arm-rel,linux-rust-x64-dbg,linux-rust-x64-rel
Change-Id: I542485b9cbed3f2a6fa7c2e72cb9df65da417281
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4261814
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1107012}
Kwizatz pushed a commit to AeonGames/build that referenced this pull request Feb 23, 2023
Instead of hard-coding these into gnrt, which necessitates rebuilding
it for any cfg changes, this adds a gnrt_config.toml to supply these
options at runtime.

This CL also adds a couple libc cfgs required as of the latest Rust
roll, and adds an env definition for libtest (which was blocked on
rust-lang/rust#106767).

Bug: 1368806
Change-Id: I542485b9cbed3f2a6fa7c2e72cb9df65da417281

Cq-Include-Trybots: luci.chromium.try:android-rust-arm-dbg,android-rust-arm-rel,linux-rust-x64-dbg,linux-rust-x64-rel
Change-Id: I542485b9cbed3f2a6fa7c2e72cb9df65da417281
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4261814
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1107012}
NOKEYCHECK=True
GitOrigin-RevId: 8cc20b86395addd1afd7fb806b3bb62722b481f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library 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