openwrt / openwrt/packages

python-cryptography: Fix LTO/Rust symbol relocation issues

Open
#25,463 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Makefile
Stars
4.6k
Forks
4k
Avg merge
3d 12h
Merged PRs (30d)
134

Description

Describe the bug

python-cryptography 41.0.0+ fails to load with "Error relocating: PyInit__openssl: symbol not found" when built with GCC LTO. This is due to interaction between GCC's LTO and Rust compilation.

OpenWrt version

r0-685e979d4

OpenWrt release

SNAPSHOT

OpenWrt target/subtarget

x86/64

Device

PC Engines apu2

Image kind

Self-built image

Steps to reproduce
  1. Install python3-cryptography
  2. Try to import cryptography in Python or use any application that depends on it
  3. Get ImportError: Error relocating /usr/lib/python3.11/site-packages/cryptography/hazmat/bindings/_rust.abi3.so: PyInit__openssl: symbol not found
Actual behaviour

Python module fails to load with symbol relocation errors

Expected behaviour

Python module loads successfully

Additional info

This is a known upstream issue: https://github.com/pyca/cryptography/issues/9023

The fix is to use clang/lld for compilation instead of GCC, as this provides proper integration between Rust and C parts of the module.

Applied fix:

  • Use clang/lld toolchain
  • Set appropriate RUSTFLAGS for proper LTO between Rust and clang components
Diffconfig
N/A - Package fix only
Terms
  • I am reporting an issue for OpenWrt, not an unsupported fork.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the python3-cryptography package build definition and reproduce the failure by importing cryptography on the reported OpenWrt snapshot. Review upstream issue 9023 and the described clang/lld and RUSTFLAGS approach; the work is done when the module imports successfully without the PyInit__openssl relocation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.