Follow symlinks when scanning the sysroot for proc-macro dylibs - #23297
Open
onlycs wants to merge 1 commit into
Open
Follow symlinks when scanning the sysroot for proc-macro dylibs#23297onlycs wants to merge 1 commit into
onlycs wants to merge 1 commit into
Conversation
The scan of the target libdir for rustc_macros & co. used DirEntry::file_type(), which does not follow symlinks. Toolchains assembled out of symlinks (e.g. by nix / oxalica's rust-overlay) link every dylib into the sysroot, so all proc-macro dylibs were skipped. As a result `rustc_queries!` never expanded for rustc_private projects and the macro-generated TyCtxt query getters (`tcx.mir_keys(())` etc.) did not resolve at all. Use fs::metadata, which traverses symlinks, instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Sep 4, 2026
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.
Problem
With a nix toolchain, every macro-generated
TyCtxtquery getter (tcx.mir_keys(()), e.g.) resolves to{unknown}. Three independent bugs cause this, one of which was fixed in 7015591, one with #23296, and one in this PRsymlinked proc-macro dylibs are skipped
WorkspaceBuildScripts::rustc_cratesscans the target libdir for the prebuilt proc-macro dylibs (librustc_macros.so& co.) usingDirEntry::file_type(), which does not follow symlinks. Nix sysroots symlink every file into place, so all dylibs were filtered out. Withoutrustc_macros,rustc_queries!never expands, the generatedrustc_with_all_queriesmacro doesn't exist, and none ofdefine_callbacks!'s output (those macro-generated query getters) is ever created.The fix here was to just use
fs::metadatawhich traverses symlinks.AI disclosure
These changes were authored with AI assistance (Claude Code); the commits carry
Co-Authored-Bytrailers. I have reviewed the changes, use them in a current project using a patched build, and can answer questions about them myself.See also: #23251
Version Info
cargo:
cargo 1.99.0-nightly (eb98b54bc 2026-08-11)Toolchain:
nightly-2026-08-14, componentsrustc-dev,llvm-tools-preview,rust-src.Configuration (Zed,
.zed/settings.json):{ "lsp": { "rust-analyzer": { "initialization_options": { "rustc": { "source": "discover" } } } } }