I have a strange compilation error on Pop!_OS 22.04 LTS with rustc 1.71. I have narrowed it down to following:
Cargo.toml:
[package]
name = "procmacro_ssl_bug"
version = "0.1.0"
edition = "2021"
[dependencies]
openssl = { version = "0.10.29", features = [] } # "vendored" works!
[lib]
proc-macro = true
src/lib.rs:
#[proc_macro]
pub fn make_answer(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let _ = openssl::ssl::SslMethod::tls();
item
}
tests/test.rs:
procmacro_ssl_bug::make_answer!();
Building the test fails:
$ cargo build --tests
Compiling procmacro_ssl_bug v0.1.0 (path/to/project)
error[E0463]: can't find crate for `procmacro_ssl_bug`
--> tests/test.rs:1:1
|
1 | procmacro_ssl_bug::make_answer!();
| ^^^^^^^^^^^^^^^^^ can't find crate
error: cannot determine resolution for the macro `procmacro_ssl_bug::make_answer`
--> tests/test.rs:1:1
|
1 | procmacro_ssl_bug::make_answer!();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: import resolution is stuck, try simplifying macro imports
For more information about this error, try `rustc --explain E0463`.
error: could not compile `procmacro_ssl_bug` (test "test") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Note that the code above works with rustc 1.70, also when vendored
feature is turned on. I do have pkg-config
and libssl-dev
installed on the system.
I cannot trigger it with a regular library and an integration test.
Rust Analyzer shows this error:
proc macro `make_answer` not expanded: Cannot create expander for /path/to/procmacro_ssl_bug/target/debug/deps/libprocmacro_ssl_bug-d1fa512bff5716a7.so: libssl.so.3: cannot open shared object file: No such file or directory