Procmacro with openssl fails to build after switching rustc to 1.71

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

That seems really odd to me. Are you sure you have not upgraded/downgraded any other of your packages, before you switched to the latest stable rust version? Could you please provide more info as to what oppssl libs you are using? I was able to compile your project with rustc 1.71.0 (8ede3aae2 2023-07-12) on arch linux with lib32-openssl 1:3.0.8-1 and openssl 3.0.8-1. In my experience, a cargo clean helps / deleting traget directory + cargo cache folder. Because the upgrading/downgrading of rust may interfere with current cache data.
I hope I was able to help you.

This may also be a regression in the 1.71 release. If you can't fix it trivially but are able to consistently reproduce it, you might want to create a ticket against the Rust repo.

Are you sure you have not upgraded/downgraded any other of your packages

I can still build the project with the v1.70 so I doubt it.
My libssll-dev version: 3.0.2-0ubuntu1.10
I do not use sccache, cleaning the target folder does not help.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.