Skip to content

clippy: add missing proc_macros aux-build declarations.#159147

Closed
daym wants to merge 1 commit into
rust-lang:mainfrom
daym:clippy-build-race
Closed

clippy: add missing proc_macros aux-build declarations.#159147
daym wants to merge 1 commit into
rust-lang:mainfrom
daym:clippy-build-race

Conversation

@daym

@daym daym commented Jul 11, 2026

Copy link
Copy Markdown

Fix two Clippy UI tests that import the proc_macros auxiliary crate without declaring it as an aux-build dependency.

Both tests only declare:

//@aux-build:proc_macro_derive.rs

but they also contain:

extern crate proc_macros;
use proc_macros::inline_macros;

Because proc_macros.rs is not declared, ui_test does not pass an explicit --extern proc_macros=.../libproc_macros.so for these tests. The tests can still appear to work when another test has already built proc_macros.rs, because rustc then finds it through the shared -L .../tests/ui/auxiliary directory.

That fallback is racy. During a parallel Clippy UI run, the auxiliary build can leave libproc_macros.rmeta visible before libproc_macros.so is written. If one of these tests starts in that window, rustc loads metadata for a proc-macro crate but has no dylib in the crate source, then ICEs in rustc_metadata::creader with:

no dylib for a proc-macro crate

Adding //@aux-build:proc_macros.rs makes the dependency explicit, forcing ui_test to build proc_macros.rs before running the test and to pass the proc-macro dylib through --extern.

Happened to me when building rust (1.94.1 specifically) on a 64 core amd epyc.

@rustbot

rustbot commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. labels Jul 11, 2026
@rustbot

rustbot commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @jieyouxu (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Fallback group: @Mark-Simulacrum, @jieyouxu
  • @Mark-Simulacrum, @jieyouxu expanded to Mark-Simulacrum, jieyouxu
  • Random selection from Mark-Simulacrum, jieyouxu

@daym

daym commented Jul 11, 2026

Copy link
Copy Markdown
Author

Ok, opened a PR at rust-lang/rust-clippy#17406 .

Still good to record here that this problem exists starting with the rust release 1.94.1 and following (at least).

non_canonical_clone_impl.rs: bug present since rust 1.81.0. Earlier versions didnt use proc macros.

@rust-log-analyzer

This comment has been minimized.

Fix two Clippy UI tests that import the `proc_macros` auxiliary crate without
declaring it as an aux-build dependency.

Both tests only declare:

  //@aux-build:proc_macro_derive.rs

but they also contain:

  extern crate proc_macros;
  use proc_macros::inline_macros;

Because `proc_macros.rs` is not declared, ui_test does not pass an explicit
`--extern proc_macros=.../libproc_macros.so` for these tests.  The tests can
still appear to work when another test has already built `proc_macros.rs`,
because rustc then finds it through the shared `-L .../tests/ui/auxiliary`
directory.

That fallback is racy.  During a parallel Clippy UI run, the auxiliary build can
leave `libproc_macros.rmeta` visible before `libproc_macros.so` is written.  If
one of these tests starts in that window, rustc loads metadata for a proc-macro
crate but has no dylib in the crate source, then ICEs in
`rustc_metadata::creader` with:

  no dylib for a proc-macro crate

Adding `//@aux-build:proc_macros.rs` makes the dependency explicit, forcing
ui_test to build `proc_macros.rs` before running the test and to pass the
proc-macro dylib through `--extern`.
@daym
daym force-pushed the clippy-build-race branch from 93aaa0b to 6bd9c1d Compare July 11, 2026 19:49
@ada4a

ada4a commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

I'd say let's close this one in favor of the clippy PR? To avoid wasting CI cycles

@daym daym closed this Jul 11, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 11, 2026
@jieyouxu jieyouxu removed their assignment Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-clippy Relevant to the Clippy team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants