-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openssl backend fails to import since 41.0.0 #9023
Comments
Does cryptography 40.0 work? |
Yes. 40.0.0, 40.0.1 and 40.0.2 all work properly. |
I just pulled Running
|
Hmm, that's a bit perplexing, the only things I can imagine causing this were all changes that happened in 40.0, between 40.0 and 41.0 there weren't any substantial changes to our build process that I can think of (or that a brief perusal of the diff turned up). |
Indeed that is the case. I have just figured out that LTO is what makes the issue appears. The problem only reproduces with |
That's a head-scratcher. I guess lto is deleting the function for some reason, even though there's a direct call to it from Rust? |
Comparing the nm output indicates that all openssl and cffi symbols were removed by LTO, too. |
The only change we made between 40.0 and 41.0 that might effect this: in 40.0, the crate that links against the compiled cffi module is the root crate, but in 41.0 it's another crate (which the root crate depends on). I don't know why that matters, but I'm sure it's the cause. I also don't understand how to fix it. |
As pointed out by @liushuyu (Thanks!), using GCC's LTO on the C/C++ side with LLVM's LTO on the Rust side is known to have compatibility issues. I have updated Arch's PKGBUILD to use clang and lld respectively, and the problem did go away even with LTO still turned on. It might be a good idea if setuptools-rust or cryptography would default to use clang/lld when available, though. I am currently supplying |
Hmm, on the one hand, this is miserable to debug. On the other hand using something other than the default system compiler seems like very surprising behavior. |
One of Gentoo users his this problem too: https://bugs.gentoo.org/903908 |
I wonder if the appropriate fix is in the |
It will work with |
Yes, you're right I should have been more precise. Though, AFAIK, it can also fail with clang, if clang and rustc are using different versions of LLVM. |
I can confirm that this is due to GCC's LTO, and is also platform-independent as I observed it on PowerPC. |
So, I don't think there's an action for us to take here, since this is a general problem. I'd like us to find an appropriate home for this issue before I close it though, do folks feel |
This issue has been waiting for a reporter response for 3 days. It will be auto-closed if no activity occurs in the next 5 days. |
Causes "_rust.abi3.so: undefined symbol: PyInit__openssl" due to LTO conflict when using GCC for C/C++ and Clang/LLVM for Rust. https://bugs.gentoo.org/903908 pyca/cryptography#9023
This issue has not received a reporter response and has been auto-closed. If the issue is still relevant please leave a comment and we can reopen it. |
41.0.3 still affected by this issue. |
41.0.4 still affected mold can't be used, too: |
Mold is unrelated to this issue. |
Versions of Python,
cryptography
,cffi
,pip
, andsetuptools
you're using
Python 3.11.3
cryptography 41.0.0/41.0.1
pip 23.1.2
setuptools 67.8.0
setuptools-rust 1.6.0
openssl 3.1.1
How you installed
cryptography
Building the Arch Linux package (I am the packager)
Clear steps for reproducing your bug
Since 41.0.0, I am getting the following error when trying to import the openssl backend:
Which isn't the case for 40.0.2 or older versions with everything else unchanged. The package was built with a plain "python setup.py build" and the build went well.
The text was updated successfully, but these errors were encountered: