Skip to content

bootstrap: only encode RUSTFLAGS when a flag contains a space#158775

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
valentynkit:bootstrap-readable-rustflags
Jul 6, 2026
Merged

bootstrap: only encode RUSTFLAGS when a flag contains a space#158775
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
valentynkit:bootstrap-readable-rustflags

Conversation

@valentynkit

@valentynkit valentynkit commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

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.:

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 #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

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.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jul 4, 2026
@Mark-Simulacrum

Copy link
Copy Markdown
Member

@bors r+

Thanks!

@rust-bors

rust-bors Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d0c3225 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 4, 2026
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
JonathanBrouwer added a commit to JonathanBrouwer/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
JonathanBrouwer added a commit to JonathanBrouwer/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
JonathanBrouwer added a commit to JonathanBrouwer/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 6, 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
rust-bors Bot pushed a commit that referenced this pull request Jul 6, 2026
Rollup of 20 pull requests

Successful merges:

 - #158377 (add `-Zforce-intrinsic-fallback` flag)
 - #158642 (Clarify some interning details)
 - #158743 (Look for cdb location in the registry first)
 - #158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space)
 - #158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage)
 - #158785 (hook intrinsic-test into aarch64-gnu)
 - #157734 (Stabilize `local_key_cell_update`)
 - #158183 (std: allocate less memory in `current_exe` for OpenBSD)
 - #158671 (Move tests batch 17)
 - #158730 (Update `FIXME(static_mut_refs)` comments)
 - #158752 (Reorganize `tests/ui/issues` [18/N])
 - #158755 (Use `ThinVec` more in the AST)
 - #158757 (Fix incorrect tracking issue for `read_le`/`read_be`)
 - #158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`)
 - #158771 (library: expand HashSet::extract_if coverage)
 - #158772 (rustc-dev-guide subtree update)
 - #158776 (fix: emit diagnostic for AVR target without target-cpu)
 - #158786 (Add regression test for builtin attr macro values)
 - #158807 (Add regression test for CString::clone_into unwind safety)
 - #158825 (Fix typo)
rust-bors Bot pushed a commit that referenced this pull request Jul 6, 2026
Rollup of 24 pull requests

Successful merges:

 - #158377 (add `-Zforce-intrinsic-fallback` flag)
 - #158642 (Clarify some interning details)
 - #158694 (Positive test for closures needing expectations)
 - #158743 (Look for cdb location in the registry first)
 - #158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space)
 - #158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage)
 - #158785 (hook intrinsic-test into aarch64-gnu)
 - #158819 (Put `InhabitedPredicate::NotInModule` earlier in disjunction since it can be a lot faster)
 - #157734 (Stabilize `local_key_cell_update`)
 - #158183 (std: allocate less memory in `current_exe` for OpenBSD)
 - #158310 (Remove unexpected usage of Unambig in non-infer variants)
 - #158671 (Move tests batch 17)
 - #158730 (Update `FIXME(static_mut_refs)` comments)
 - #158752 (Reorganize `tests/ui/issues` [18/N])
 - #158755 (Use `ThinVec` more in the AST)
 - #158757 (Fix incorrect tracking issue for `read_le`/`read_be`)
 - #158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`)
 - #158771 (library: expand HashSet::extract_if coverage)
 - #158772 (rustc-dev-guide subtree update)
 - #158776 (fix: emit diagnostic for AVR target without target-cpu)
 - #158786 (Add regression test for builtin attr macro values)
 - #158810 (Add supplementary information for get_unchecked(mut))
 - #158825 (Fix typo)
 - #158838 (tidy: Use `empty_alternate = true` for triagebot mention glob check)
rust-bors Bot pushed a commit that referenced this pull request Jul 6, 2026
Rollup of 24 pull requests

Successful merges:

 - #158377 (add `-Zforce-intrinsic-fallback` flag)
 - #158642 (Clarify some interning details)
 - #158694 (Positive test for closures needing expectations)
 - #158743 (Look for cdb location in the registry first)
 - #158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space)
 - #158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage)
 - #158785 (hook intrinsic-test into aarch64-gnu)
 - #158819 (Put `InhabitedPredicate::NotInModule` earlier in disjunction since it can be a lot faster)
 - #157734 (Stabilize `local_key_cell_update`)
 - #158183 (std: allocate less memory in `current_exe` for OpenBSD)
 - #158310 (Remove unexpected usage of Unambig in non-infer variants)
 - #158671 (Move tests batch 17)
 - #158730 (Update `FIXME(static_mut_refs)` comments)
 - #158752 (Reorganize `tests/ui/issues` [18/N])
 - #158755 (Use `ThinVec` more in the AST)
 - #158757 (Fix incorrect tracking issue for `read_le`/`read_be`)
 - #158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`)
 - #158771 (library: expand HashSet::extract_if coverage)
 - #158772 (rustc-dev-guide subtree update)
 - #158776 (fix: emit diagnostic for AVR target without target-cpu)
 - #158786 (Add regression test for builtin attr macro values)
 - #158810 (Add supplementary information for get_unchecked(mut))
 - #158825 (Fix typo)
 - #158838 (tidy: Use `empty_alternate = true` for triagebot mention glob check)
rust-bors Bot pushed a commit that referenced this pull request Jul 6, 2026
Rollup of 24 pull requests

Successful merges:

 - #158377 (add `-Zforce-intrinsic-fallback` flag)
 - #158642 (Clarify some interning details)
 - #158694 (Positive test for closures needing expectations)
 - #158743 (Look for cdb location in the registry first)
 - #158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space)
 - #158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage)
 - #158785 (hook intrinsic-test into aarch64-gnu)
 - #158819 (Put `InhabitedPredicate::NotInModule` earlier in disjunction since it can be a lot faster)
 - #157734 (Stabilize `local_key_cell_update`)
 - #158183 (std: allocate less memory in `current_exe` for OpenBSD)
 - #158310 (Remove unexpected usage of Unambig in non-infer variants)
 - #158671 (Move tests batch 17)
 - #158730 (Update `FIXME(static_mut_refs)` comments)
 - #158752 (Reorganize `tests/ui/issues` [18/N])
 - #158755 (Use `ThinVec` more in the AST)
 - #158757 (Fix incorrect tracking issue for `read_le`/`read_be`)
 - #158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`)
 - #158771 (library: expand HashSet::extract_if coverage)
 - #158772 (rustc-dev-guide subtree update)
 - #158776 (fix: emit diagnostic for AVR target without target-cpu)
 - #158786 (Add regression test for builtin attr macro values)
 - #158810 (Add supplementary information for get_unchecked(mut))
 - #158825 (Fix typo)
 - #158838 (tidy: Use `empty_alternate = true` for triagebot mention glob check)
@rust-bors rust-bors Bot merged commit de5f3dd into rust-lang:main Jul 6, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 6, 2026
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jul 7, 2026
Rollup of 24 pull requests

Successful merges:

 - rust-lang/rust#158377 (add `-Zforce-intrinsic-fallback` flag)
 - rust-lang/rust#158642 (Clarify some interning details)
 - rust-lang/rust#158694 (Positive test for closures needing expectations)
 - rust-lang/rust#158743 (Look for cdb location in the registry first)
 - rust-lang/rust#158775 (bootstrap: only encode RUSTFLAGS when a flag contains a space)
 - rust-lang/rust#158782 (Add and use cfg(target_has_threads) to enforce no_thread impl usage)
 - rust-lang/rust#158785 (hook intrinsic-test into aarch64-gnu)
 - rust-lang/rust#158819 (Put `InhabitedPredicate::NotInModule` earlier in disjunction since it can be a lot faster)
 - rust-lang/rust#157734 (Stabilize `local_key_cell_update`)
 - rust-lang/rust#158183 (std: allocate less memory in `current_exe` for OpenBSD)
 - rust-lang/rust#158310 (Remove unexpected usage of Unambig in non-infer variants)
 - rust-lang/rust#158671 (Move tests batch 17)
 - rust-lang/rust#158730 (Update `FIXME(static_mut_refs)` comments)
 - rust-lang/rust#158752 (Reorganize `tests/ui/issues` [18/N])
 - rust-lang/rust#158755 (Use `ThinVec` more in the AST)
 - rust-lang/rust#158757 (Fix incorrect tracking issue for `read_le`/`read_be`)
 - rust-lang/rust#158765 (Fix ICE on non-ident path in `doc(auto_cfg values)`)
 - rust-lang/rust#158771 (library: expand HashSet::extract_if coverage)
 - rust-lang/rust#158772 (rustc-dev-guide subtree update)
 - rust-lang/rust#158776 (fix: emit diagnostic for AVR target without target-cpu)
 - rust-lang/rust#158786 (Add regression test for builtin attr macro values)
 - rust-lang/rust#158810 (Add supplementary information for get_unchecked(mut))
 - rust-lang/rust#158825 (Fix typo)
 - rust-lang/rust#158838 (tidy: Use `empty_alternate = true` for triagebot mention glob check)
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-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bootstrap printing failing command contains non-shell escape sequences

3 participants