Skip to content
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

cdylib builds with -Cprofile-generate RUSTFLAGS are broken under Unix with PyO3 0.23 #4796

Open
gi0baro opened this issue Dec 13, 2024 · 3 comments
Labels

Comments

@gi0baro
Copy link
Contributor

gi0baro commented Dec 13, 2024

Bug Description

During the process of releasing a new version of Granian I realised it seems not possible to create PGO builds in Linux and MacOS.
Maturin successfully builds the wheels with RUSTFLAGS=-Cprofile-generate=$(pwd)/profdata, but importing the library results in a segfault under MacOS and the following in Linux:

ImportError: /home/runner/work/granian/granian/.venv/lib/python3.9/site-packages/granian/_granian.cpython-39-x86_64-linux-gnu.so: undefined symbol: __gcov_indirect_call

Tested both on GHA (you can inspect the run here) and locally on MacOS.

Also tried to test different maturin versions (1.7.4->1.7.8) and reverting changes on other cargo dependencies from the last successful build with PyO3 0.22: nothing seems to work, reverting to PyO3 0.22 immediately fix the issue. Also, Windows seems to be unaffected by this.
Not sure this is 100% PyO3 fault, but given my limited knowledge on the inner processes it's also hard to identify other major responsibilities on something else. To maintainers: if you think this is Maturin related or it involves other components, feel free to close this and point me out to the right place.

Steps to Reproduce

  1. Run RUSTFLAGS=-Cprofile-generate=$(pwd)/profdata maturin build --release -i {interpreter}
  2. Install the generated wheel
  3. Import the library in Python

Backtrace

No response

Your operating system and version

Ubuntu 22.04, MacOS 13, MacOS 14

Your Python version (python --version)

Python 3.9->3.13

Your Rust version (rustc --version)

1.82.0, 1.83.0

Your PyO3 version

0.23.3

How did you install python? Did you use a virtualenv?

pyenv, brew, uv

Additional Info

No response

@gi0baro gi0baro added the bug label Dec 13, 2024
@gi0baro
Copy link
Contributor Author

gi0baro commented Dec 13, 2024

Update: removing the following dependency from Cargo.toml

tikv-jemallocator = { version = "0.6.0", default-features = false, features = ["disable_initial_exec_tls"] }

seems to solve the issue. Still quite unclear to me why this happens on 0.23.x and not 0.22.x

@gi0baro
Copy link
Contributor Author

gi0baro commented Dec 13, 2024

Update: removing tikv-jemallocator dependency seems to solve the issue.

Actually on MacOS only. Linux still suffers from the same issue described in the OP

@gi0baro
Copy link
Contributor Author

gi0baro commented Dec 16, 2024

Same Linux issue with another project, you can inspect the GHA workflow run here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant