-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-cratesArea: Crates and their interactions (like crate loading)Area: Crates and their interactions (like crate loading)A-rust-for-linuxRelevant for the Rust-for-Linux projectRelevant for the Rust-for-Linux projectC-bugCategory: This is a bug.Category: This is a bug.E-needs-designThis issue needs exploration and design to see how and if we can fix/implement itThis issue needs exploration and design to see how and if we can fix/implement itT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
macro.rs:
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn your_macro(_attr: TokenStream, item: TokenStream) -> TokenStream {
// Macro implementation
item
}
main.rs:
extern crate macros;
#[macros::your_macro]
fn main() {
println!("Hello, world!");
}
This works:
rustc --crate-type proc-macro macros.rs -o libmacros.dylib
rustc main.rs --extern macros=libmacros.dylib
This doesn't:
rustc --crate-type proc-macro macros.rs -o libmacros.so
rustc main.rs --extern macros=libmacros.so
error: extern location for macros is of an unknown type: libmacros.so
--> main.rs:4:1
|
4 | extern crate macros;
| ^^^^^^^^^^^^^^^^^^^^
error: file name should be lib*.rlib or lib*.dylib
--> main.rs:4:1
|
4 | extern crate macros;
| ^^^^^^^^^^^^^^^^^^^^
error[E0463]: can't find crate for `macros`
--> main.rs:4:1
|
4 | extern crate macros;
| ^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0463`.
This has come up in Rust-For-Linux where we'd like to always use the .so suffix, but this causes the build to fail on macOS. If we change the suffix to .dylib, it works on macOS, but not Linux.
Metadata
Metadata
Assignees
Labels
A-cratesArea: Crates and their interactions (like crate loading)Area: Crates and their interactions (like crate loading)A-rust-for-linuxRelevant for the Rust-for-Linux projectRelevant for the Rust-for-Linux projectC-bugCategory: This is a bug.Category: This is a bug.E-needs-designThis issue needs exploration and design to see how and if we can fix/implement itThis issue needs exploration and design to see how and if we can fix/implement itT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.