Skip to content

Change build_rs::input::cargo_cfg_target_env to return Option - #17632

Merged
weihanglo merged 1 commit into
rust-lang:masterfrom
CAD97:build-rs-cargo-cfg-target-env
Oct 23, 2026
Merged

weihanglo merged 1 commit into
rust-lang:masterfrom
CAD97:build-rs-cargo-cfg-target-env

Conversation

@CAD97

@CAD97 CAD97 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

This matches the semantics better as well as how the other "for historical reasons" fn cargo_cfg_target_abi which was exposed to return Option.

It's my fault from during the 0.1 to 0.2 refactor that these two diverge. cargo_cfg_target_env was copied over from 0.1 with the original design of only mapping to Option for maybe-undefined environment variables and wasn't caught in the refactor that mapped empty-means-none environment variables to Option, whereas newly added cargo_cfg_target_abi post-refactor got the new convention.

Notes to reviewers

The build-rs crate is meant to be light such that having duplicated major versions of it in the build tree has a minimal compile-time impact even on a cold build. Even with that said, though, it's up to the maintainers if this change should merit bumping to a new semver-incompatible version.

If it doesn't, it probably merits a source comment noting why the convention differs from cargo_cfg_target_abi.


🤖 LLM involvement: None.

@rustbot rustbot added A-build-scripts Area: build.rs scripts S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2026
@rustbot

rustbot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Muscraft, @epage, @weihanglo
  • @Muscraft, @epage, @weihanglo expanded to Muscraft, epage, weihanglo
  • Random selection from Muscraft, epage, weihanglo

@CAD97
CAD97 force-pushed the build-rs-cargo-cfg-target-env branch from a52f80b to d3c6a53 Compare October 23, 2026 19:11
This matches the semantics better as well as how the other "for
historical reasons" fn cargo_cfg_target_abi which was exposed to
return Option.

It's my fault from during the 0.1 to 0.2 refactor that these two
diverge. cargo_cfg_target_env was copied over from 0.1 with the
original design of only mapping to Option for maybe-undefined
environment variables and wasn't caught in the refactor that mapped
empty-means-none environment variables to Option, whereas newly
added cargo_cfg_target_abi post-refactor got the new convention.
@CAD97
CAD97 force-pushed the build-rs-cargo-cfg-target-env branch from d3c6a53 to 645cb41 Compare October 23, 2026 19:18

@weihanglo weihanglo left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. The other breaking change we can probably ship is renaming cargo_target_family to cargo_cfg_target_family for consistency reason.

View changes since this review

@weihanglo
weihanglo added this pull request to the merge queue Oct 23, 2026
Merged via the queue into rust-lang:master with commit 3fcd5d6 Oct 23, 2026
32 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 23, 2026
@CAD97
CAD97 deleted the build-rs-cargo-cfg-target-env branch October 23, 2026 22:36
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-rust-lang__cargo that referenced this pull request Oct 24, 2026
…ust-lang#17636)

### What does this PR try to resolve?

This improves consistency in build-rs's naming.

### Notes to reviewers

- See:
rust-lang#17632 (review)

r? @weihanglo

---

🤖 LLM involvement: None
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Oct 24, 2026
Update cargo submodule

11 commits in 15be64aa0859b5c36f7a86d52f7aa0db44ba4d84..cad07cf8e597397fff5d0f6cb79c9f870c0b1dd2
2026-10-20 16:03:21 +0000 to 2026-10-23 22:04:58 +0000
- build-rs: rename `cargo_target_family` to `cargo_cfg_target_family` (rust-lang/cargo#17636)
- chore: replace `cfg(any())` with `cfg(false)` (rust-lang/cargo#17633)
- feat(timings): peak memory as a column in unit table (rust-lang/cargo#17631)
- Change `build_rs::input::cargo_cfg_target_env` to return `Option` (rust-lang/cargo#17632)
- Update gix to 0.90.0 and adapt Git error recovery (rust-lang/cargo#17578)
- Fix unused dep annotation (rust-lang/cargo#17625)
- fix!: stop uplifting rlibs on nightly  (rust-lang/cargo#17621)
- refactor(config): Pull out the ConfigStore into its own module (rust-lang/cargo#17614)
- test: simplify file content assertions (rust-lang/cargo#17617)
- perf(context): Don't initialize windows-specific code on all platforms (rust-lang/cargo#17615)
- refactor(context): Remove RLS-specific function (rust-lang/cargo#17616)
@rustbot rustbot added this to the 1.101.0 milestone Oct 24, 2026
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Oct 24, 2026
Update cargo submodule

11 commits in 15be64aa0859b5c36f7a86d52f7aa0db44ba4d84..cad07cf8e597397fff5d0f6cb79c9f870c0b1dd2
2026-10-20 16:03:21 +0000 to 2026-10-23 22:04:58 +0000
- build-rs: rename `cargo_target_family` to `cargo_cfg_target_family` (rust-lang/cargo#17636)
- chore: replace `cfg(any())` with `cfg(false)` (rust-lang/cargo#17633)
- feat(timings): peak memory as a column in unit table (rust-lang/cargo#17631)
- Change `build_rs::input::cargo_cfg_target_env` to return `Option` (rust-lang/cargo#17632)
- Update gix to 0.90.0 and adapt Git error recovery (rust-lang/cargo#17578)
- Fix unused dep annotation (rust-lang/cargo#17625)
- fix!: stop uplifting rlibs on nightly  (rust-lang/cargo#17621)
- refactor(config): Pull out the ConfigStore into its own module (rust-lang/cargo#17614)
- test: simplify file content assertions (rust-lang/cargo#17617)
- perf(context): Don't initialize windows-specific code on all platforms (rust-lang/cargo#17615)
- refactor(context): Remove RLS-specific function (rust-lang/cargo#17616)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-scripts Area: build.rs scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants