doc: improve documentation on using cfg values with build scripts#16671
Merged
arlosi merged 3 commits intorust-lang:masterfrom Feb 24, 2026
Merged
doc: improve documentation on using cfg values with build scripts#16671arlosi merged 3 commits intorust-lang:masterfrom
arlosi merged 3 commits intorust-lang:masterfrom
Conversation
Collaborator
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
arlosi
approved these changes
Feb 24, 2026
arlosi
added a commit
to arlosi/rust
that referenced
this pull request
Feb 25, 2026
8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000 - fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674) - doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671) - Fix typo in cargo-yank docs (rust-lang/cargo#16656) - fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652) - Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661) - Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659) - fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621) - test(build-std): Update error message (rust-lang/cargo#16658)
rust-bors bot
pushed a commit
to rust-lang/rust
that referenced
this pull request
Feb 26, 2026
Update cargo submodule 8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000 - fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674) - doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671) - Fix typo in cargo-yank docs (rust-lang/cargo#16656) - fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652) - Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661) - Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659) - fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621) - test(build-std): Update error message (rust-lang/cargo#16658)
RalfJung
pushed a commit
to RalfJung/miri
that referenced
this pull request
Feb 26, 2026
Update cargo submodule 8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000 - fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674) - doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671) - Fix typo in cargo-yank docs (rust-lang/cargo#16656) - fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652) - Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661) - Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659) - fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621) - test(build-std): Update error message (rust-lang/cargo#16658)
github-actions bot
pushed a commit
to rust-lang/rust-analyzer
that referenced
this pull request
Mar 2, 2026
Update cargo submodule 8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000 - fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674) - doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671) - Fix typo in cargo-yank docs (rust-lang/cargo#16656) - fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652) - Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661) - Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659) - fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621) - test(build-std): Update error message (rust-lang/cargo#16658)
makai410
pushed a commit
to makai410/rustc_public
that referenced
this pull request
Mar 19, 2026
Update cargo submodule 8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000 - fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674) - doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671) - Fix typo in cargo-yank docs (rust-lang/cargo#16656) - fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652) - Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661) - Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659) - fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621) - test(build-std): Update error message (rust-lang/cargo#16658)
makai410
pushed a commit
to makai410/rustc_public
that referenced
this pull request
Mar 19, 2026
Update cargo submodule 8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000 - fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674) - doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671) - Fix typo in cargo-yank docs (rust-lang/cargo#16656) - fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652) - Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661) - Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659) - fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621) - test(build-std): Update error message (rust-lang/cargo#16658)
makai410
pushed a commit
to makai410/rustc_public
that referenced
this pull request
Mar 27, 2026
Update cargo submodule 8 commits in 8cc0cb136772b8f54eafe0d163fcb7226a06af0c..f298b8c82da0cba538516b45b04a480fc501d4c0 2026-02-17 12:16:26 +0000 to 2026-02-24 21:59:20 +0000 - fix(host-config): fix panic when cross-compiling with host-config (rust-lang/cargo#16674) - doc: improve documentation on using cfg values with build scripts (rust-lang/cargo#16671) - Fix typo in cargo-yank docs (rust-lang/cargo#16656) - fix(job_queue): Handle Clippy CLI arguments in `fix` message (rust-lang/cargo#16652) - Add a test for fingerprint checking when a symlink target changes (rust-lang/cargo#16661) - Fix parallel locking when `-Zfine-grain-locking` is enabled (rust-lang/cargo#16659) - fix(cli): Remove `--lockfile-path` (rust-lang/cargo#16621) - test(build-std): Update error message (rust-lang/cargo#16658)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
Fixes #12198
This PR improves documentation on using cfg values with build scripts. Currently, the docs don't clearly explain how to properly read configuration values in a build script, leading to common mistakes when cross-compiling.
The key issue is that developers often use
cfg!or#[cfg]in build scripts to check target configuration, but these actually check the host platform (where the build script runs), not the target platform being compiled for.Changes:
build-scripts.md: Added a note warning aboutcfg!vsCARGO_CFG_*and recommending thebuild-rscrateenvironment-variables.md: Added a tip in theCARGO_CFG_*section about usingbuild-rsand the host/target distinctionbuild-script-examples.md: Added a new "Reading target configuration" section with a practical exampleHow to test and review this PR?
cd src/doc mdbook serve --openReview the following pages:
reference/build-scripts.html- Check the new note in "Inputs to the Build Script"reference/environment-variables.html- Check the new tip underCARGO_CFG_*reference/build-script-examples.html- Check the new "Reading target configuration" sectionVerify all links work correctly (the
build-rscrate links and cross-references)