Skip to content

Conversation

@bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Nov 24, 2025

Previously if a dependency of the current crate depended on a sysroot crate, then extern crate would in the current crate would pick the first loaded version of said sysroot crate even in case of an ambiguity. This is surprising and brittle. For -Ldependency= we already blocked this since #110229, but the fix didn't account for sysroot crates.

Should fix #147966

Previously if a dependency of the current crate depended on a sysroot
crate, then extern crate would in the current crate would pick the first
loaded version of said sysroot crate even in case of an ambiguity. This
is surprising and brittle. For -Ldependency= we already blocked this,
but the fix didn't account for sysroot crates.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 24, 2025

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Nov 24, 2025

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 24, 2025

We end up with two copies of rustc_macros in the stage1 sysroot. librustc_macros-ec6b51dc176f057f.so and librustc_macros.so. find build -iname 'librustc_macros*' | sort shows

build/aarch64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_macros-60ab85e5fc9a97c5.so
build/aarch64-unknown-linux-gnu/stage1-rustc-rmeta-artifacts/host/librustc_macros-60ab85e5fc9a97c5.so
build/aarch64-unknown-linux-gnu/stage1-rustc/release/deps/librustc_macros-60ab85e5fc9a97c5.so
build/aarch64-unknown-linux-gnu/stage1/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_macros-ec6b51dc176f057f.so
build/aarch64-unknown-linux-gnu/stage1/lib/rustlib/aarch64-unknown-linux-gnu/lib/librustc_macros.so
build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/librustc_macros-7577fab33cd32388.so
build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/librustc_macros-ec6b51dc176f057f.so
build/aarch64-unknown-linux-gnu/stage2-rustc/release/librustc_macros.d
build/aarch64-unknown-linux-gnu/stage2-rustc/release/librustc_macros.so
build/aarch64-unknown-linux-gnu/stage2/lib/librustc_macros.so
     Running `/home/gh-bjorn3/rust/build/bootstrap/debug/rustc /home/gh-bjorn3/rust/build/bootstrap/debug/rustc --crate-name rustc_macros --edition=2024 compiler/rustc_macros/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=189 --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no -C debuginfo=1 -C overflow-checks=off --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=be7e7ca919dfe741 -C extra-filename=-ec6b51dc176f057f --out-dir /home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps -L dependency=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps --extern proc_macro2=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/libproc_macro2-f1b117abea6fea0b.rlib --extern quote=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/libquote-2b307f2bbd14d75c.rlib --extern syn=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/libsyn-dacac49cff7dc945.rlib --extern synstructure=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/libsynstructure-62471687b53f2245.rlib --extern proc_macro -Z binary-dep-depinfo`
     Running `/home/gh-bjorn3/rust/build/bootstrap/debug/rustc /home/gh-bjorn3/rust/build/bootstrap/debug/rustc --crate-name rustc_macros --edition=2024 compiler/rustc_macros/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=189 --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C opt-level=3 -C embed-bitcode=no -C debuginfo=1 -C debug-assertions=on -C overflow-checks=off --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=5ad205a615dda1e1 -C extra-filename=-7577fab33cd32388 --out-dir /home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps -L dependency=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps --extern proc_macro2=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/libproc_macro2-f1b117abea6fea0b.rlib --extern quote=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/libquote-2b307f2bbd14d75c.rlib --extern syn=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/libsyn-dacac49cff7dc945.rlib --extern synstructure=/home/gh-bjorn3/rust/build/aarch64-unknown-linux-gnu/stage2-rustc/release/deps/libsynstructure-62471687b53f2245.rlib --extern proc_macro -Z binary-dep-depinfo`

I suspect cargo decided to built rustc_macros once as build dependency without optimizations and once as output artifact with optimizations because bootstrap passed -p rustc_macros.

@petrochenkov petrochenkov self-assigned this Nov 25, 2025
@rustbot rustbot added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Nov 25, 2025
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the crate_locator_improvements branch from 8d439c2 to f0a26f2 Compare November 25, 2025 12:34
@chenyukang chenyukang removed their assignment Nov 26, 2025
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 26, 2025
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Nov 27, 2025
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 27, 2025

Checking how important the --extern fast path in existing_match is.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 27, 2025
Don't leak sysroot crates through dependencies
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 27, 2025
@rust-bors
Copy link

rust-bors bot commented Nov 27, 2025

☀️ Try build successful (CI)
Build commit: c77897e (c77897e64048c8406614d7cc2520bd22084bf335, parent: 7b9905edb4df3aeaabd0d6cd0d4c09b183d7d965)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c77897e): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.4% [-2.7%, -0.4%] 9
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.3%, secondary -5.4%)

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

mean range count
Regressions ❌
(primary)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
4.8% [4.8%, 4.8%] 1
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
-7.9% [-11.5%, -0.6%] 4
All ❌✅ (primary) -0.3% [-2.1%, 1.5%] 2

Cycles

Results (primary -2.0%, secondary 3.6%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.6% [2.6%, 4.6%] 2
Improvements ✅
(primary)
-2.0% [-2.1%, -1.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.0% [-2.1%, -1.9%] 2

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 470.06s -> 469.991s (-0.01%)
Artifact size: 386.96 MiB -> 386.96 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 27, 2025
@bjorn3 bjorn3 force-pushed the crate_locator_improvements branch from ac0aabb to e58a6df Compare November 27, 2025 18:07
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 27, 2025

That turns out to be much better than I expected. It is a small perf win rather than a perf hit as I was afraid of. I've now cleaned up existing_match and made it immediately return None when no crate hash is given rather than still iterating over all crates, which should improve perf even more.

@rustbot ready

@petrochenkov
Copy link
Contributor

Very nice.
@bors r+

@bors
Copy link
Collaborator

bors commented Nov 28, 2025

📌 Commit 871ec86 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors 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 Nov 28, 2025
@bjorn3 bjorn3 force-pushed the crate_locator_improvements branch from 0a7346e to 871ec86 Compare November 28, 2025 20:58
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 28, 2025

Oops, pushed to the wrong branch. Force pushed it back to the approved state.

@bors r=petrochenkov

@bors
Copy link
Collaborator

bors commented Nov 28, 2025

📌 Commit 871ec86 has been approved by petrochenkov

It is now in the queue for this repository.

bors added a commit that referenced this pull request Nov 29, 2025
…nkov

Don't leak sysroot crates through dependencies

Previously if a dependency of the current crate depended on a sysroot crate, then `extern crate` would in the current crate would pick the first loaded version of said sysroot crate even in case of an ambiguity. This is surprising and brittle. For `-Ldependency=` we already blocked this since #110229, but the fix didn't account for sysroot crates.

Should fix #147966
@bors
Copy link
Collaborator

bors commented Nov 29, 2025

⌛ Testing commit 871ec86 with merge 8626569...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Nov 29, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 29, 2025
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 29, 2025

@bors try jobs=dist-x86_64-msvc

rust-bors bot added a commit that referenced this pull request Nov 29, 2025
Don't leak sysroot crates through dependencies

try-job: dist-x86_64-msvc
@rust-bors

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Nov 29, 2025

☀️ Try build successful (CI)
Build commit: cee9c81 (cee9c8136595e0372e7b7e4f302efb0e26488aa5, parent: 3c5c55864f8f441054730037bc9f9901f9151398)

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 29, 2025

@rustbot ready

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 29, 2025

📌 Commit 1ba6869 has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors 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 Nov 29, 2025
bors added a commit that referenced this pull request Nov 29, 2025
…nkov

Don't leak sysroot crates through dependencies

Previously if a dependency of the current crate depended on a sysroot crate, then `extern crate` would in the current crate would pick the first loaded version of said sysroot crate even in case of an ambiguity. This is surprising and brittle. For `-Ldependency=` we already blocked this since #110229, but the fix didn't account for sysroot crates.

Should fix #147966
@bors
Copy link
Collaborator

bors commented Nov 29, 2025

⌛ Testing commit 1ba6869 with merge f480fb1...

@rust-log-analyzer
Copy link
Collaborator

The job dist-powerpc64le-linux-gnu failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Collaborator

bors commented Nov 30, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs 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) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

regression: ICE no resolution found for import

7 participants