Repository navigation
Description
Summary
./x build fails with an assertion panic in bootstrap when the repository is checked out under a directory path that contains spaces. The
error message gives no indication that the path is the problem, making it very hard to debug.
The root cause is in src/bootstrap/src/core/builder/cargo.rs when building tools like rustdoc (mode ToolRustcPrivate), bootstrap runs
llvm-config --libdir and passes the result as a -Clink-arg=-L<path> rustflag. Rustflags::arg() asserts that arguments contain no
spaces, but if the repo path has a space in it (e.g. /Users/foo/Open Source/rust), the libdir path inherits that space and the assertion
fires.
Command used
```sh
RUST_BACKTRACE=1 ./x build
```
Expected behaviour
Build completes successfully, or fails with a clear error explaining that paths with spaces aren't supported.
Actual behaviour
Bootstrap panics with a cryptic assertion error:
thread 'main' panicked at src/bootstrap/src/core/builder/cargo.rs:54:9:
assertion left == right failed
left: 2
right: 1
```
Nothing in the output points to the repo path being the issue.
Bootstrap configuration (bootstrap.toml)
```toml
none default configuration
```
Operating system
macOS 15 (aarch64, Apple Silicon)
HEAD
Additional context
The repo was cloned to /Users/<user>/Open Source/rust. Renaming the parent directory to remove the space (OpenSource) fixes the build
immediately.
The problematic line is cargo.rs:1189:
```rust
rustflags.arg(&format!("-Clink-arg=-L{llvm_libdir}"));
```
llvm_libdir contains the full repo path (via the ci-llvm build dir), which includes the space. `Rustflags` uses a space-delimited internal
format so any path with spaces breaks the assertion.
This is reproducible by cloning the repo to any path containing a space and running ./x build.
Build Log
Building bootstrap
Finished dev profile [unoptimized] target(s) in 0.09s
/Users/rohansingla/Open Source/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Building stage1 compiler artifacts (stage0 -> stage1, aarch64-apple-darwin)
Finished release profile [optimized + debuginfo] target(s) in 0.28s
Creating a sysroot for stage1 compiler (use rustup toolchain link 'name' build/host/stage1)
Building stage1 library artifacts{...} (stage1 -> stage1, aarch64-apple-darwin)
Finished dist profile [optimized + debuginfo] target(s) in 0.03s
thread 'main' panicked at src/bootstrap/src/core/builder/cargo.rs:54:9:
assertion left == right failed
left: 2
right: 1
stack backtrace:
4: bootstrap::core::builder::cargo::Rustflags::arg
5: bootstrap::core::builder::Builder::cargo (cargo.rs:1189)
6: bootstrap::core::builder::cargo::Cargo::new
7: bootstrap::core::build_steps::tool::prepare_tool_cargo (tool.rs:191)
8: <bootstrap::core::build_steps::tool::ToolBuild as bootstrap::core::builder::Step>::run
10: <bootstrap::core::build_steps::tool::Rustdoc as bootstrap::core::builder::Step>::run
Build completed unsuccessfully in 0:00:09
Activity
Rohan-Singla commentedon Jun 17, 2026
Also if this makes sense can i work on this issue ?
Unique-Usman commentedon Jun 17, 2026
cc: @Kobzol, this issues looks valid, thought ?
ChrisDenton commentedon Jun 17, 2026
llvm-config, prior to LLVM 22, didn't support outputting quoted paths. So this will either need to check for--quote-pathssupport or else wait for our minimum LLVM version to be 22.Kobzol commentedon Jun 17, 2026
I guess that we could just quote the path ourselves.
Rohan-Singla commentedon Jun 17, 2026
Makes sense , Thanks! I'll fix it in src/bootstrap/src/core/builder/cargo.rs at line 1189 by quoting the path returned by llvm-config --libdir before
passing it as a -Clink-arg rustflag, so paths with spaces are handled correctly.
@rustbot claim
bjorn3 commentedon Jun 17, 2026
RUSTFLAGS does not support spaces in arguments. It would need to be CARGO_ENCODED_RUSTFLAGS. Not sure if we already use that.
Rollup merge of rust-lang#158073 - Rohan-Singla:fix/rust-lang#158052,…
Rollup merge of rust-lang#158073 - Rohan-Singla:fix/rust-lang#158052,…
Rollup merge of rust-lang#158073 - Rohan-Singla:fix/rust-lang#158052,…
Rollup merge of rust-lang#158073 - Rohan-Singla:fix/rust-lang#158052,…
Rollup merge of rust-lang#158073 - Rohan-Singla:fix/rust-lang#158052,…
Rollup merge of rust-lang#158073 - Rohan-Singla:fix/rust-lang#158052,…
Auto merge of #158073 - Rohan-Singla:fix/#158052, r=<try>
Rollup merge of rust-lang#158073 - Rohan-Singla:fix/rust-lang#158052,…
Unrolled build for #158073
Rollup merge of #158073 - Rohan-Singla:fix/#158052, r=kobzol,mark-sim…