Skip to content

Add support for extra rustc environment variables #3510

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nmattia
Copy link
Contributor

@nmattia nmattia commented Jul 18, 2025

This adds support for injecting environment variables into rustc invocations via build settings:

  • //rust/settings:extra_rustc_env for the target configuration
  • //rust/settings:extra_exec_rustc_env for the exec configuration

These settings can be set from the command line with flags like:

  --@rules_rust//rust/settings:extra_rustc_env=RUSTC_BOOTSTRAP=1

This mirrors how extra rustc flags are handled and enables build-wide env-based feature control without editing individual rules. Useful for enabling unstable features across many crates, or toggling behavior in proc macros and build scripts.

This adds support for injecting environment variables into rustc invocations
via build settings:

- `//rust/settings:extra_rustc_env` for the target configuration
- `//rust/settings:extra_exec_rustc_env` for the exec configuration

These settings can be set from the command line with flags like:

```
  --@rules_rust//rust/settings:extra_rustc_env=RUSTC_BOOTSTRAP=1
```

This mirrors how extra rustc flags are handled and enables build-wide env-based
feature control without editing individual rules. Useful for enabling unstable
features across many crates, or toggling behavior in proc macros and build scripts.
@nmattia nmattia force-pushed the nm-extra-rustc-env branch from a1ca705 to 87ec024 Compare July 18, 2025 14:05
nmattia added a commit to dfinity/ic that referenced this pull request Jul 18, 2025
This will allow us to keep up to date with new changes and to
cherry-pick our patches more cleanly
(bazelbuild/rules_rust#3434,
bazelbuild/rules_rust#3510)
nmattia added a commit to dfinity/ic that referenced this pull request Jul 18, 2025
this drops the nightly toolchain that was used in the fuzzers. Instead,
`RUSTC_BOOTSTRAP=1` is set in the fuzzer targets, which has the same
effect without requiring the download of a second toolchain.

NOTE: This vendors the following upstream patch: bazelbuild/rules_rust#3510
Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, thanks! One small request :)

@nmattia nmattia requested a review from illicitonion July 21, 2025 08:56
github-merge-queue bot pushed a commit to dfinity/ic that referenced this pull request Jul 21, 2025
This will allow us to keep up to date with new changes and to
cherry-pick our patches more cleanly
(bazelbuild/rules_rust#3434,
bazelbuild/rules_rust#3510)
github-merge-queue bot pushed a commit to dfinity/ic that referenced this pull request Jul 21, 2025
This will allow us to keep up to date with new changes and to
cherry-pick our patches more cleanly
(bazelbuild/rules_rust#3434,
bazelbuild/rules_rust#3510)
@nmattia nmattia force-pushed the nm-extra-rustc-env branch from 179b2b4 to 356cea5 Compare July 21, 2025 09:18
nmattia added a commit to dfinity/ic that referenced this pull request Jul 21, 2025
this drops the nightly toolchain that was used in the fuzzers. Instead,
`RUSTC_BOOTSTRAP=1` is set in the fuzzer targets, which has the same
effect without requiring the download of a second toolchain.

NOTE: This vendors the following upstream patch: bazelbuild/rules_rust#3510
nmattia added a commit to dfinity/ic that referenced this pull request Jul 21, 2025
this drops the nightly toolchain that was used in the fuzzers. Instead,
`RUSTC_BOOTSTRAP=1` is set in the fuzzer targets, which has the same
effect without requiring the download of a second toolchain.

NOTE: This vendors the following upstream patch: bazelbuild/rules_rust#3510
nmattia added a commit to dfinity/ic that referenced this pull request Jul 21, 2025
this drops the nightly toolchain that was used in the fuzzers. Instead,
`RUSTC_BOOTSTRAP=1` is set in the fuzzer targets, which has the same
effect without requiring the download of a second toolchain.

NOTE: This vendors the following upstream patch: bazelbuild/rules_rust#3510
nmattia added a commit to dfinity/ic that referenced this pull request Jul 21, 2025
this drops the nightly toolchain that was used in the fuzzers. Instead,
`RUSTC_BOOTSTRAP=1` is set in the fuzzer targets, which has the same
effect without requiring the download of a second toolchain.

NOTE: This vendors the following upstream patch: bazelbuild/rules_rust#3510
github-merge-queue bot pushed a commit to dfinity/ic that referenced this pull request Jul 21, 2025
this drops the nightly toolchain that was used in the fuzzers. Instead,
`RUSTC_BOOTSTRAP=1` is set in the fuzzer targets, which has the same
effect without requiring the download of a second toolchain.

NOTE: This vendors the following upstream patch:
bazelbuild/rules_rust#3510
Andrei1998 pushed a commit to dfinity/ic that referenced this pull request Jul 22, 2025
this drops the nightly toolchain that was used in the fuzzers. Instead,
`RUSTC_BOOTSTRAP=1` is set in the fuzzer targets, which has the same
effect without requiring the download of a second toolchain.

NOTE: This vendors the following upstream patch:
bazelbuild/rules_rust#3510
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 this pull request may close these issues.

2 participants