-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.C-bugCategory: bugCategory: bug
Description
Problem
If you have a proc-macro depend on a crate with crate-type=["dylib"] building the proc-macro apparently succeeds, but then building the crate which uses it fails with an error message
error[E0463]: can't find crate for `macone`
--> user/src/main.rs:1:1
|
1 | macone::macone!();
| ^^^^^^ can't find crate
This occurs because LD_LIBRARY_PATH is not set when running rustc to build the final crate that uses the proc macro, and as a result it can't find the shared dep. And rustc's error messages here aren't very good.
Steps
git clone https://github.com/gmorenz/shared_proc_macro_dep/
cd shared_proc_macro_dep/user
cargo build
Possible Solution(s)
There are three solutions here:
- Error if proc macros depend on dylib's (or probably cdylibs)
- Provide
LD_LIBRARY_PATHto rustc invocations. - Kick this out to rustc to provide better error messages when building the crate that depends on a proc macro that it fails to load. Which it probably should - but its not in the same position as cargo is to understand why that's failing.
The second option would enable things like this (without hacks): facet-rs/facet#1143
The first is probably less work.
Notes
No response
Version
cargo 1.93.0-nightly (2a7c49606 2025-11-25)
release: 1.93.0-nightly
commit-hash: 2a7c4960677971f88458b0f8b461a866836dff59
commit-date: 2025-11-25
host: x86_64-unknown-linux-gnu
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.15.0-DEV (sys:0.4.83+curl-8.15.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Arch Linux Rolling Release [64-bit]
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.C-bugCategory: bugCategory: bug