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

PyO3 doesn't build on musl targets (Alpine linux) #1109

Closed
alex opened this issue Aug 16, 2020 · 5 comments · Fixed by PyO3/setuptools-rust#80
Closed

PyO3 doesn't build on musl targets (Alpine linux) #1109

alex opened this issue Aug 16, 2020 · 5 comments · Fixed by PyO3/setuptools-rust#80

Comments

@alex
Copy link
Contributor

alex commented Aug 16, 2020

error: cannot produce cdylib for cryptography-rust v0.1.0 (/tmp/pip-req-build-oczfn6un/src/rust) as the target x86_64-unknown-linux-musl does not support these crate types

This was previously reported as #599, however that referred to a different failure, that proc-macro wasn't supported on musl targets. The corresponding Rust issue was closed, and indeed there's now a new error message. I'm hoping to understand where the blocker to moving this ball forward is, and how I can help!

🐛 Bug Reports

🌍 Environment

  • Your operating system and version: Alpine Linux 3.12.0
  • Your Rust version (rustc --version): rustc 1.45.2 (d3fb005a3 2020-07-31)
  • Your PyO3 version: 0.11.1
  • Have you tried using latest PyO3 master (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?: Not yet

💥 Reproducing

pyca/cryptography#5410 see the failing Alpine build https://travis-ci.org/github/pyca/cryptography/jobs/718454323

@alex
Copy link
Contributor Author

alex commented Aug 17, 2020

Discovery: Building with RUSTFLAGS="-C target-feature=-crt-static" resolves this. Does this sound like the correct solution to folks? If yes, I'll work up a PR to setuptools-rust to do this automatically when targeting musl. If no... back to the drawing board I guess? :-)

@alex
Copy link
Contributor Author

alex commented Aug 17, 2020

Well, I submitted a PR for that approach: PyO3/setuptools-rust#80

@kngwyu
Copy link
Member

kngwyu commented Aug 17, 2020

Thank you for reporting,

RUSTFLAGS="-C target-feature=-crt-static"

Any link or document where you find this solution?
I don't know why it works for musl...

@konstin
Copy link
Member

konstin commented Aug 17, 2020

This is explained somehow in rust-lang/rust#59302 (comment), while the reference has some background information (https://doc.rust-lang.org/reference/linkage.html#static-and-dynamic-c-runtimes). I have the same problem with maturin (PyO3/maturin#154) and it appears that target-feature=-crt-static is all you can (and need) to do.

@davidhewitt
Copy link
Member

Thanks for reporting & investigating! As we've pushed issues to both of the packaging tools, let's close this one out? I think anyone building software for the musl target regularly probably will know about this target-feature=-crt-static flag.

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

Successfully merging a pull request may close this issue.

4 participants