Allow setting linker args that only apply to bin or lib targets #5881
Labels
A-linkage
Area: linker issues, dylib, cdylib, shared libraries, so
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-needs-team-input
Status: Needs input from team on whether/how to proceed.
For crates built on pyo3, you need to link libpython for binaries and you must not link libpython for libraries (the latter is required by PEP 513). The current workaround is that there is an
extension-module
feature for libraries, which tells pyo3's build script to not link libpython.Unfortunately, this doesn't work anymore when the same crate contains a bin (or test or bench) and a lib target. Take hyperjson as an example. It's
Cargo.toml
contains the followingcargo build
fails on linux bacause it tries to build the bench target, which is lacking symbols the linker arguments to link libpython. Removing thefeatures = ["extension-module"]
is also not an option as it makes libhyperjson.so also link libpython, whichldd
confirms.cargo build output
This would be solved by allowing build scripts to define linker args that only apply to binaries or only to shared libraries.
Cargo version:
cargo 1.29.0-nightly (2cd36b4ed 2018-07-25)
The text was updated successfully, but these errors were encountered: