[experiment] bootstrap: leverage cargo trim-paths - #161049
Draft
weihanglo wants to merge 5 commits into
Draft
Conversation
Member
Author
|
@bors try |
This comment has been minimized.
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
This comment has been minimized.
This comment has been minimized.
Member
Author
|
@bors try cancel |
Contributor
|
Try build cancelled. Cancelled workflows: |
Member
Author
|
@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple |
This comment has been minimized.
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
This comment has been minimized.
This comment has been minimized.
Contributor
|
💔 Test for bd743b7 failed: CI. Failed jobs:
|
weihanglo
force-pushed
the
bootstrap-trim-paths-exp
branch
from
August 13, 2026 16:17
b0b31e6 to
9981c62
Compare
This comment has been minimized.
This comment has been minimized.
Member
Author
|
@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple |
This comment has been minimized.
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
Contributor
weihanglo
force-pushed
the
bootstrap-trim-paths-exp
branch
from
August 13, 2026 22:52
9981c62 to
21aed96
Compare
This comment has been minimized.
This comment has been minimized.
weihanglo
force-pushed
the
bootstrap-trim-paths-exp
branch
from
August 14, 2026 01:45
21aed96 to
80d0ecc
Compare
Member
Author
|
@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple |
This comment has been minimized.
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
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 15, 2026
[experiment] bootstrap: leverage cargo trim-paths try-job: dist-x86_64-msvc try-job: dist-x86_64-linux try-job: dist-aarch64-apple
pull Bot
pushed a commit
to Mattlk13/cargo
that referenced
this pull request
Aug 15, 2026
With this we get remap for free when building in rustc bootstrap: See * rust-lang/rust#161049 * rust-lang#17309
pull Bot
pushed a commit
to Mattlk13/cargo
that referenced
this pull request
Aug 15, 2026
### What does this PR try to resolve? With this we get remap for free when building in rustc bootstrap: See * rust-lang/rust#161049 * rust-lang#17309 * rust-lang/cc-rs#1794 ### How to test and review this PR?
Contributor
Urgau
reviewed
Aug 15, 2026
| // When building the standard library sources, we want to apply the std remap scheme. | ||
| let map = [ | ||
| // Cargo use relative paths for workspace members, so let's remap those. | ||
| format!("library/={map_to}/library"), |
Member
There was a problem hiding this comment.
Seems like this remapping isn't done anymore.
$ rustc +62cf67c121864e5bfc57b32497dc24e22b7a91a0 diag.rs
error[E0277]: the trait bound `{integer}: AsRef<Path>` is not satisfied
--> diag.rs:2:37
|
2 | let a = std::fs::read_to_string(12).unwrap();
| ----------------------- ^^ the trait `AsRef<Path>` is not implemented for `{integer}`
| |
| required by a bound introduced by this call
|
note: required by a bound in `std::fs::read_to_string`
--> library/std/src/fs.rs:383:0
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
Member
Author
There was a problem hiding this comment.
Ah, we forgot library=<map_to>/library remap, which its relative form not covered by Cargo's <absolute-workspace-root>=<map_to>
Member
There was a problem hiding this comment.
Yeah, the same is probably also not done for compiler.
This comment has been minimized.
This comment has been minimized.
weihanglo
added a commit
to weihanglo/cargo
that referenced
this pull request
Aug 15, 2026
This is effectively `library/=<to>/library` and `compiler/=<to>/compiler` in rustc bootstrap, when `__CARGO_RUSTC_BOOTSTRAP_WS_REMAP` is set. This isn't needed for normal cases because relative member paths are exactly what users want. See <rust-lang/rust#161049 (comment)>
weihanglo
added a commit
to weihanglo/cargo
that referenced
this pull request
Aug 15, 2026
This is effectively `library/=<to>/library` and `compiler/=<to>/compiler` in rustc bootstrap, when `__CARGO_RUSTC_BOOTSTRAP_WS_REMAP` is set. This isn't needed for normal cases because relative member paths are exactly what users want. See <rust-lang/rust#161049 (comment)>
weihanglo
added a commit
to weihanglo/cargo
that referenced
this pull request
Aug 15, 2026
This is effectively `library/=<to>/library` and `compiler/=<to>/compiler` in rustc bootstrap, when `__CARGO_RUSTC_BOOTSTRAP_WS_REMAP` is set. This isn't needed for normal cases because relative member paths are exactly what users want. See <rust-lang/rust#161049 (comment)>
weihanglo
added a commit
to weihanglo/cargo
that referenced
this pull request
Aug 15, 2026
This is effectively `library/=<to>/library` and `compiler/=<to>/compiler` in rustc bootstrap, when `__CARGO_RUSTC_BOOTSTRAP_WS_REMAP` is set. This isn't needed for normal cases because relative member paths are exactly what users want. See <rust-lang/rust#161049 (comment)>
weihanglo
added a commit
to weihanglo/cargo
that referenced
this pull request
Aug 16, 2026
This is effectively `library/=<to>/library` and `compiler/=<to>/compiler` in rustc bootstrap, when `__CARGO_RUSTC_BOOTSTRAP_WS_REMAP` is set. This isn't needed for normal cases because relative member paths are exactly what users want. See <rust-lang/rust#161049 (comment)>
pull Bot
pushed a commit
to xtqqczze/rust-lang-miri
that referenced
this pull request
Aug 17, 2026
With this, we get C dep remap for free when building in rustc bootstrap: See * rust-lang/rust#161049 * rust-lang/cargo#17309 * rust-lang/cc-rs#1794
weihanglo
added a commit
to weihanglo/cargo
that referenced
this pull request
Aug 19, 2026
This is effectively `library/=<to>/library` and `compiler/=<to>/compiler` in rustc bootstrap, when `__CARGO_RUSTC_BOOTSTRAP_WS_REMAP` is set. This isn't needed for normal cases because relative member paths are exactly what users want. See <rust-lang/rust#161049 (comment)>
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 19, 2026
chore: bump to cc@1.4.3 for rustc_llvm and library ### What is this? Old cc-rs derives this from the `-Clto` rustflag on its own. `cc@1.2.39` starts gating that behind `-Clinker-plugin-lto`, which bootstrap doesn't pass. Therefore, we need to pass this flag explicitly to keep LTO mode Previous efforts: * #146186 * #155438 I personally want this because of cc 1.3.0+ has the support of Cargo `-Ztrim-paths`, which helps what I am experimenting in <#161049>. ### How to review Commit by commit. To keep commits bisect-able, I added the first commit without cc bump. clang should be fine with duplicate `-flto` flags. One thing I am not certain is whether we should probe `-flto` flag in this case, or just make this fail if `-flto` isn't supported. (I assume `-flto` is quote widely supported) r? Kobzol --- 🤖 **LLM disclosure:** I used LLM for the experiment of <#161049>, but not the bootstrap LTO change in this PR.
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 19, 2026
chore: bump to cc@1.4.3 for rustc_llvm and library ### What is this? Old cc-rs derives this from the `-Clto` rustflag on its own. `cc@1.2.39` starts gating that behind `-Clinker-plugin-lto`, which bootstrap doesn't pass. Therefore, we need to pass this flag explicitly to keep LTO mode Previous efforts: * #146186 * #155438 I personally want this because of cc 1.3.0+ has the support of Cargo `-Ztrim-paths`, which helps what I am experimenting in <#161049>. ### How to review Commit by commit. To keep commits bisect-able, I added the first commit without cc bump. clang should be fine with duplicate `-flto` flags. One thing I am not certain is whether we should probe `-flto` flag in this case, or just make this fail if `-flto` isn't supported. (I assume `-flto` is quote widely supported) r? Kobzol --- 🤖 **LLM disclosure:** I used LLM for the experiment of <#161049>, but not the bootstrap LTO change in this PR.
weihanglo
added a commit
to weihanglo/cargo
that referenced
this pull request
Aug 21, 2026
This is effectively `library/=<to>/library` and `compiler/=<to>/compiler` in rustc bootstrap, when `__CARGO_RUSTC_BOOTSTRAP_WS_REMAP` is set. This isn't needed for normal cases because relative member paths are exactly what users want. See <rust-lang/rust#161049 (comment)>
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 21, 2026
chore: bump to cc@1.4.3 for rustc_llvm and library ### What is this? Old cc-rs derives this from the `-Clto` rustflag on its own. `cc@1.2.39` starts gating that behind `-Clinker-plugin-lto`, which bootstrap doesn't pass. Therefore, we need to pass this flag explicitly to keep LTO mode Previous efforts: * #146186 * #155438 I personally want this because of cc 1.3.0+ has the support of Cargo `-Ztrim-paths`, which helps what I am experimenting in <#161049>. ### How to review Commit by commit. To keep commits bisect-able, I added the first commit without cc bump. clang should be fine with duplicate `-flto` flags. One thing I am not certain is whether we should probe `-flto` flag in this case, or just make this fail if `-flto` isn't supported. (I assume `-flto` is quote widely supported) r? Kobzol --- 🤖 **LLM disclosure:** I used LLM for the experiment of <#161049>, but not the bootstrap LTO change in this PR.
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.
weihanglo
force-pushed
the
bootstrap-trim-paths-exp
branch
from
August 22, 2026 03:11
e416b25 to
7d23b0e
Compare
Member
Author
|
@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple |
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 22, 2026
[experiment] bootstrap: leverage cargo trim-paths try-job: dist-x86_64-msvc try-job: dist-x86_64-linux try-job: dist-aarch64-apple
Contributor
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.
View all comments
What
Leverage Cargo's
-Ztrim-pathsto remap compiler and library. See rust-lang/cargo#17309.I'll do some dist jobs and see if artifacts are remapped correctly.
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