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

For direct dependencies it is a lot harder to not accidentally resolve
an ambiguity through an indirect dependency edge and as it turns out
this check was actually more expensive than the work it skipped. For
indirect dependencies existing_match is still necessary due to an assert
in load, but at the same time it also can't accidentally resolve an
ambiguity given that we already know exactly which crate to look for
based on the crate hash.
@rust-bors
Copy link

rust-bors bot commented Dec 11, 2025

☀️ Try build successful (CI)
Build commit: 4b32e88 (4b32e8883bc4abd17faa4dde839024ec21dfb625, parent: f5209000832c9d3bc29c91f4daef4ca9f28dc797)

@bjorn3 bjorn3 force-pushed the crate_locator_improvements branch from 15b716c to 7f1828c Compare December 11, 2025 11:38
@bjorn3
Copy link
Member Author

bjorn3 commented Dec 11, 2025

I think I fixed the duplicate crate detection. Squashed all changes to detect duplicate crates into a single commit.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 11, 2025
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 11, 2025

📌 Commit 7f1828c 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 Dec 11, 2025
bors added a commit that referenced this pull request Dec 13, 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 Dec 13, 2025

⌛ Testing commit 7f1828c with merge 1785a9c...

@bors
Copy link
Collaborator

bors commented Dec 13, 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 Dec 13, 2025
@bjorn3
Copy link
Member Author

bjorn3 commented Dec 13, 2025

The logs for github actions seem to be broken, so I can't see where this went wrong.

@bors try jobs=dist-x86_64-msvc

@rust-bors

This comment has been minimized.

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

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

rust-bors bot commented Dec 13, 2025

☀️ Try build successful (CI)
Build commit: 6ca89ca (6ca89caf8e45d1f15be7373b4f596605f8e85b22, parent: eb171a227f9e5de5d376b6edb56b174bc8235fb3)

@bjorn3
Copy link
Member Author

bjorn3 commented Dec 13, 2025

Guess it was a spurious failure on github's side.

@bors retry

@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 Dec 13, 2025
@bors
Copy link
Collaborator

bors commented Dec 14, 2025

⌛ Testing commit 7f1828c with merge 08de25c...

@bors
Copy link
Collaborator

bors commented Dec 14, 2025

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 08de25c to main...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 14, 2025
@bors bors merged commit 08de25c into rust-lang:main Dec 14, 2025
13 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 14, 2025
@github-actions
Copy link
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 3f4dc1e (parent) -> 08de25c (this PR)

Test differences

Show 7 test diffs

Stage 1

  • [run-make] tests/run-make/duplicate-dependency-no-disambiguate: [missing] -> pass (J2)

Stage 2

  • [run-make] tests/run-make/duplicate-dependency-no-disambiguate: [missing] -> pass (J0)
  • [run-make] tests/run-make/duplicate-dependency-no-disambiguate: [missing] -> ignore (ignored if target does not support std) (J1)

Additionally, 4 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 08de25c4ea16d7ecc3ceeb093d4f343a2be30df5 --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. dist-aarch64-linux: 6221.5s -> 8799.9s (+41.4%)
  2. dist-apple-various: 3340.0s -> 4103.9s (+22.9%)
  3. aarch64-apple: 10833.1s -> 9036.7s (-16.6%)
  4. dist-x86_64-apple: 7057.8s -> 6142.3s (-13.0%)
  5. x86_64-gnu-llvm-21-1: 4316.8s -> 4758.6s (+10.2%)
  6. x86_64-gnu-llvm-20-2: 5465.1s -> 6004.1s (+9.9%)
  7. dist-x86_64-solaris: 5714.5s -> 5201.1s (-9.0%)
  8. dist-aarch64-apple: 6175.8s -> 6711.6s (+8.7%)
  9. pr-check-2: 2728.2s -> 2556.6s (-6.3%)
  10. dist-x86_64-llvm-mingw: 7342.7s -> 6883.5s (-6.3%)
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.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (08de25c): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-6.7%, -0.1%] 11
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -4.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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.6% [-7.5%, -0.6%] 5
All ❌✅ (primary) - - 0

Cycles

Results (secondary 0.8%)

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.0% [2.9%, 3.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.4% [-3.4%, -3.4%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 478.161s -> 476.492s (-0.35%)
Artifact size: 390.27 MiB -> 390.29 MiB (0.01%)

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 merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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