bootstrap: only encode RUSTFLAGS when a flag contains a space#158775
Open
valentynkit wants to merge 1 commit into
Open
bootstrap: only encode RUSTFLAGS when a flag contains a space#158775valentynkit wants to merge 1 commit into
valentynkit wants to merge 1 commit into
Conversation
Bootstrap now passes rustc and rustdoc flags via CARGO_ENCODED_RUSTFLAGS
and CARGO_ENCODED_RUSTDOCFLAGS, whose values use \x1f to separate flags.
That control character renders as \u{1f} when a failing command is
debug-printed, so the printed command can't be copy-pasted.
Prefer the plain, space-separated RUSTFLAGS/RUSTDOCFLAGS form, which is
equivalent whenever no flag value contains a space, and only fall back to
the encoded form when a flag value does contain a space.
Member
|
@bors r+ Thanks! |
Contributor
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jul 5, 2026
…tflags, r=Mark-Simulacrum bootstrap: only encode RUSTFLAGS when a flag contains a space Fixes rust-lang#158749 Since rust-lang#158073, bootstrap passes rustc and rustdoc flags to cargo through `CARGO_ENCODED_RUSTFLAGS` / `CARGO_ENCODED_RUSTDOCFLAGS`, whose values are `\x1f`-separated. When a command fails and gets debug-printed, that separator shows up as `\u{1f}`, e.g.: ``` CARGO_ENCODED_RUSTDOCFLAGS="--cfg=windows_raw_dylib\u{1f}-Csymbol-mangling-version=v0\u{1f}..." ``` which isn't a valid escape in bash/zsh, so the printed command can't be copy-pasted. The encoded form is only needed when a flag value contains a space (the case rust-lang#158073 fixed, e.g. an `-L` path from `llvm-config --libdir` under a directory whose name has a space). Cargo splits `RUSTFLAGS` on spaces, so when no flag contains one the plain, space-separated `RUSTFLAGS`/`RUSTDOCFLAGS` form is equivalent and stays readable. This uses the plain form in that case and only falls back to the encoded form when a flag actually contains a space. It also clears any inherited `CARGO_ENCODED_RUSTFLAGS`/`CARGO_ENCODED_RUSTDOCFLAGS`, since cargo prefers the encoded variable over the plain one and the plain form would otherwise be ignored. r? @Mark-Simulacrum
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jul 5, 2026
…tflags, r=Mark-Simulacrum bootstrap: only encode RUSTFLAGS when a flag contains a space Fixes rust-lang#158749 Since rust-lang#158073, bootstrap passes rustc and rustdoc flags to cargo through `CARGO_ENCODED_RUSTFLAGS` / `CARGO_ENCODED_RUSTDOCFLAGS`, whose values are `\x1f`-separated. When a command fails and gets debug-printed, that separator shows up as `\u{1f}`, e.g.: ``` CARGO_ENCODED_RUSTDOCFLAGS="--cfg=windows_raw_dylib\u{1f}-Csymbol-mangling-version=v0\u{1f}..." ``` which isn't a valid escape in bash/zsh, so the printed command can't be copy-pasted. The encoded form is only needed when a flag value contains a space (the case rust-lang#158073 fixed, e.g. an `-L` path from `llvm-config --libdir` under a directory whose name has a space). Cargo splits `RUSTFLAGS` on spaces, so when no flag contains one the plain, space-separated `RUSTFLAGS`/`RUSTDOCFLAGS` form is equivalent and stays readable. This uses the plain form in that case and only falls back to the encoded form when a flag actually contains a space. It also clears any inherited `CARGO_ENCODED_RUSTFLAGS`/`CARGO_ENCODED_RUSTDOCFLAGS`, since cargo prefers the encoded variable over the plain one and the plain form would otherwise be ignored. r? @Mark-Simulacrum
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.
Fixes #158749
Since #158073, bootstrap passes rustc and rustdoc flags to cargo through
CARGO_ENCODED_RUSTFLAGS/CARGO_ENCODED_RUSTDOCFLAGS, whose values are\x1f-separated. When a command fails and gets debug-printed, that separator shows up as\u{1f}, e.g.:which isn't a valid escape in bash/zsh, so the printed command can't be copy-pasted.
The encoded form is only needed when a flag value contains a space (the case #158073 fixed, e.g. an
-Lpath fromllvm-config --libdirunder a directory whose name has a space). Cargo splitsRUSTFLAGSon spaces, so when no flag contains one the plain, space-separatedRUSTFLAGS/RUSTDOCFLAGSform is equivalent and stays readable. This uses the plain form in that case and only falls back to the encoded form when a flag actually contains a space.It also clears any inherited
CARGO_ENCODED_RUSTFLAGS/CARGO_ENCODED_RUSTDOCFLAGS, since cargo prefers the encoded variable over the plain one and the plain form would otherwise be ignored.r? @Mark-Simulacrum