Skip to content

bootstrap: leverage cargo trim-paths - #161049

Merged
rust-bors[bot] merged 6 commits into
rust-lang:mainfrom
weihanglo:bootstrap-trim-paths-exp
Sep 2, 2026
Merged

bootstrap: leverage cargo trim-paths#161049
rust-bors[bot] merged 6 commits into
rust-lang:mainfrom
weihanglo:bootstrap-trim-paths-exp

Conversation

@weihanglo

@weihanglo weihanglo commented Aug 13, 2026

Copy link
Copy Markdown
Member

View all comments

What

Leverage Cargo's -Ztrim-paths to remap compiler and library. See rust-lang/cargo#17309. Bootstrap no longer needs custom remap.

Changes in toolchain distributions:

  • /rustc/<sha> remap does not change for toolchain binaries
  • /rustc-dev/<sha> remap does not change for toolchain private binaries
  • /rustc/llvm remap does not change for LLVM we distributed
  • crates.io dependency remaps becomes /cargo/registry/<hash> from /rust/deps
  • vendored dependency remaps becomes /cargo/deps from /rust/deps

This has some implicit dependencies:

try-jobs: dist-x86_64-msvc
try-jobs: dist-x86_64-linux
try-jobs: dist-aarch64-apple

🤖 LLM disclosure: I used LLM to do the first pass of bootstrap integration and temporary stage0 bump. The usage was signed off here on Zulip: #llm-reviews > Experiment with Cargo's trim-path in bootstrap. See #161049 (comment) for a more recent disclosure.

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-release Relevant to the release subteam, which will review and decide on the PR/issue. labels Aug 13, 2026
@weihanglo

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 13, 2026
[experiment] bootstrap: leverage cargo trim-paths
@rust-log-analyzer

This comment has been minimized.

@weihanglo

Copy link
Copy Markdown
Member Author

@bors try cancel

@rust-bors

rust-bors Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Try build cancelled. Cancelled workflows:

@weihanglo

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 13, 2026
[experiment] bootstrap: leverage cargo trim-paths


try-job: dist-x86_64-msvc
try-job: dist-x86_64-linux
try-job: dist-aarch64-apple
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

💔 Test for bd743b7 failed: CI. Failed jobs:

@weihanglo
weihanglo force-pushed the bootstrap-trim-paths-exp branch from b0b31e6 to 9981c62 Compare August 13, 2026 16:17
@rust-log-analyzer

This comment has been minimized.

@weihanglo

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 13, 2026
[experiment] bootstrap: leverage cargo trim-paths


try-job: dist-x86_64-msvc
try-job: dist-x86_64-linux
try-job: dist-aarch64-apple
@rust-bors

rust-bors Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 67c6105 (67c6105718f0714463e9014eca86d60e96ba0b12)
Base parent: ba28ff7 (ba28ff76f353a722f31c4f3dd2ac4e437d36411b)

@weihanglo
weihanglo force-pushed the bootstrap-trim-paths-exp branch from 9981c62 to 21aed96 Compare August 13, 2026 22:52
@rust-log-analyzer

This comment has been minimized.

@weihanglo
weihanglo force-pushed the bootstrap-trim-paths-exp branch from 21aed96 to 80d0ecc Compare August 14, 2026 01:45
@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Aug 14, 2026
@weihanglo

Copy link
Copy Markdown
Member Author

@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 14, 2026
[experiment] bootstrap: leverage cargo trim-paths


try-job: dist-x86_64-msvc
try-job: dist-x86_64-linux
try-job: dist-aarch64-apple
@Urgau

Urgau commented Sep 1, 2026

Copy link
Copy Markdown
Member

Sure, I just installed the toolchain with rustup-toolchain-install-master b54c46dce1c5f83017e8be8f3ab20e07a05c215b --component rustc-dev.

And then tried to compile this dumb test program (rustc +b54c46dce1c5f83017e8be8f3ab20e07a05c215b a.rs):

#![feature(rustc_private)]

extern crate rustc_session;

fn main() {
    let sess = rustc_session::Session::timer(12u32);
}

@Urgau

Urgau commented Sep 1, 2026

Copy link
Copy Markdown
Member

I manually looked at the debuginfo with llvm-dwarfdump of the standard library rlibs and didn't find any leaked paths for Rust source code.

There are however several leaks in compiler-builtins rlib:

DW_AT_decl_file ("/rustroot/lib/clang/23/include/stdint.h")

It also reproduces on nightly, so it's not a regression of this PR, and I don't think it's problematic, it's not like we are gonna try to un-remap C deps anyway.

@Urgau Urgau 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.

Thanks for all the hard work, in particular on the Cargo side.

I will let @jieyouxu do his review as well, in particular the bootstrap part.

View changes since this review

@jieyouxu jieyouxu 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.

@jieyouxu

jieyouxu commented Sep 2, 2026

Copy link
Copy Markdown
Member

@bors r=Urgau,jieyouxu rollup=never note="path remapping logic"

@rust-bors

rust-bors Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 31e8b4b has been approved by Urgau,jieyouxu

It is now in the queue for this repository.

@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 Sep 2, 2026
Comment thread src/bootstrap/src/core/builder/cargo.rs
Replace `RUSTC_DEBUGINFO_MAP` and `RUSTC_CARGO_REGISTRY_SRC_TO_REMAP`
with cargo trim-paths and `__CARGO_RUSTC_BOOTSTRAP_WS_REMAP` override
(See cargo#17309).

The `RUSTC_DEBUGINFO_MAP` into `-ffile-prefix-map` in rustc_llvm
will be covered cc@1.3.0+ natively
(which inherits and forwards `CARGO_TRIM_PATHS_REMAP`)
The current dwarfdump checks cannot see `.rmeta` leaks:

* The compiler keeps unremapped local paths in metadata
  unless the remap scope is `all` (see issue 159621)
* std ships metadata as separate `.rmeta` via `-Zembed-metadata=no`
  so the leak does not even appear in the rlibs

This commit enhances to also check rmeta files.
Registry dependencies are now remapped by cargo trim-paths as
`/cargo/registry/{source-hash}/{pkg}-{ver}/`
The `-fdebug-prefix-map` flags in `cc_unhandled_cflags` served three
kinds of consumers.

* The cc-rs-driven C/C++ builds inside cargo:
  They now inherit the same remap pairs from cargo trim-paths
  so passing the flag through `CFLAGS` there is redundant.
* The CMake-driven LLVM build:
  This is the one we need the remaps.
* The remaining callers
  (`compiler_file` probing, cc detection, test fixtures):
  They never produce distributed artifacts.
@rust-bors

rust-bors Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ A new commit 8d43ad3441784c2be601b5ec97bc9bca18c889b3 was pushed.

This pull request was unapproved.

@rustbot

rustbot commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Urgau

Urgau commented Sep 2, 2026

Copy link
Copy Markdown
Member

@bors r=Urgau,jieyouxu rollup=never note="path remapping logic"

@rust-bors

rust-bors Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 8d43ad3 has been approved by Urgau,jieyouxu

It is now in the queue for this repository.

@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: Urgau,jieyouxu
Duration: 3h 13m 31s
Pushing fb9a338 to main...

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 824336a (parent) -> fb9a338 (this PR)

Test differences

Show 3 test diffs

Stage 2

  • [run-make] tests/run-make/compressed-debuginfo-zstd: pass -> ignore (ignored if LLVM wasn't build with zstd for ELF section compression or LLVM is not the default codegen backend) (J0)

Additionally, 2 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard fb9a3389fdeb347c7658a422ed41b79499434452 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-gcc-core-tests: 14m 13s -> 23m 33s (+65.7%)
  2. x86_64-rust-for-linux: 46m 13s -> 1h 7m (+46.2%)
  3. dist-x86_64-netbsd: 1h 3m -> 1h 32m (+44.6%)
  4. dist-s390x-linux: 1h 4m -> 1h 31m (+42.5%)
  5. x86_64-gnu-aux: 1h 57m -> 2h 45m (+41.4%)
  6. pr-check-2: 41m 26s -> 56m 26s (+36.2%)
  7. x86_64-gnu-llvm-21-1: 43m 50s -> 59m 37s (+36.0%)
  8. test-various: 1h 53m -> 2h 31m (+33.4%)
  9. optional-x86_64-gnu-autodiff: 38m 7s -> 49m 34s (+30.0%)
  10. x86_64-gnu-stdlib-semver-check: 17m 54s -> 23m 2s (+28.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@Kobzol

Kobzol commented Sep 2, 2026

Copy link
Copy Markdown
Member

[run-make] tests/run-make/compressed-debuginfo-zstd: pass -> ignore (ignored if LLVM wasn't build with zstd for ELF section compression or LLVM is not the default codegen backend) (J0)

The test diff is curious. Why would this PR cause compiletest think that LLVM doesn't have zstd or isn't the default codegen backend anymore 🤔

@Kobzol

Kobzol commented Sep 2, 2026

Copy link
Copy Markdown
Member

Ah, maybe that was just because the LLVM stamp was bumped, so the test used a locally built LLVM without zstd (because zstd isn't installed on the test runner), interesting. This is essentially the same issue that we had with GCC and binutils (CC @antoyo just to let you know that we also run into this issue with LLVM).

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (fb9a338): comparison URL.

Overall result: no relevant changes - BENCHMARK(S) FAILED

@rustbot label: -perf-regression

❗ ❗ ❗ ❗ ❗
Warning ⚠️: The following benchmark(s) failed to build:

  • Job failure

❗ ❗ ❗ ❗ ❗

cc @rust-lang/wg-compiler-performance

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary 4.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
4.4% [4.4%, 4.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.4% [4.4%, 4.4%] 1

Cycles

Results (primary 2.5%, secondary 2.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.5% [2.5%, 2.5%] 1
Regressions ❌
(secondary)
2.9% [2.6%, 3.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.5% [2.5%, 2.5%] 1

Binary size

Results (primary 0.0%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 3
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 3

Bootstrap: missing data
Artifact size: 401.09 MiB -> 401.19 MiB (0.03%)

@Kobzol

Kobzol commented Sep 2, 2026

Copy link
Copy Markdown
Member

The failure is not caused by this PR.. sigh.

@jieyouxu

jieyouxu commented Sep 3, 2026

Copy link
Copy Markdown
Member

Did the merge status on this PR... also get lost?

@Kobzol

Kobzol commented Sep 3, 2026

Copy link
Copy Markdown
Member

What merge status?

@jieyouxu

jieyouxu commented Sep 3, 2026

Copy link
Copy Markdown
Member

What merge status?

Normally merged PRs have this:

Screenshot 2026-09-03 161220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool merged-by-bors This PR was explicitly merged by bors. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-release Relevant to the release subteam, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants