[experiment] bootstrap: leverage cargo trim-paths - #161049
Conversation
|
@bors try |
This comment has been minimized.
This comment has been minimized.
[experiment] bootstrap: leverage cargo trim-paths
This comment has been minimized.
This comment has been minimized.
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: |
|
@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple |
This comment has been minimized.
This comment has been minimized.
[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.
|
💔 Test for bd743b7 failed: CI. Failed jobs:
|
b0b31e6 to
9981c62
Compare
This comment has been minimized.
This comment has been minimized.
|
@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple |
This comment has been minimized.
This comment has been minimized.
[experiment] bootstrap: leverage cargo trim-paths try-job: dist-x86_64-msvc try-job: dist-x86_64-linux try-job: dist-aarch64-apple
9981c62 to
21aed96
Compare
This comment has been minimized.
This comment has been minimized.
21aed96 to
80d0ecc
Compare
|
@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple |
This comment has been minimized.
This comment has been minimized.
[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.
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}/`
Starting with cc@1.3.0 cc inherits path remap rules from cargo trim-paths and forwards them to the C compiler. We bump to that to take advantage of that instead. The next commit will remove that custom cflags
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.
547c942 to
e416b25
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
@bors try jobs=dist-x86_64-msvc,dist-x86_64-linux,dist-aarch64-apple |
This comment has been minimized.
This comment has been minimized.
[experiment] bootstrap: leverage cargo trim-paths try-job: dist-x86_64-msvc try-job: dist-x86_64-linux try-job: dist-aarch64-apple
With this we get remap for free when building in rustc bootstrap: See * rust-lang/rust#161049 * rust-lang#17309
### 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?
| // 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"), |
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`.
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>
There was a problem hiding this comment.
Yeah, the same is probably also not done for compiler.
|
☔ The latest upstream changes (presumably #161128) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
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)>
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)>
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)>
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)>
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)>
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
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)>
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.
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.
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