You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For crates built upon pyo3, you need different linker args for binaries and libraries. Binaries need to link libpython, while libraries are forbidden by PEP 513 to link libpython. By default pyo3's build script add emits the arguments to link libpython and libraries use a feature called extension-module to deactivate those flags.
When building in a workspace with --all, cargo seems to conflate the linker args, causing linker errors. Pyo3 itself for example has a main crate with tests and an example that is an extension module. cargo test works fine and cd examples/word-count/ && cargo test also works fine, but cargo build --all --tests fails to compile the tests with linker errors missing libpython: Output of cargo build --all --tests -vvv. This seems to mean that cargo uses the linker args of the word count example with the extension module feature for the tests of pyo3 itself instead of using those for the pyo3 crate without the extension module feature.
This bug also occurs in dependent crate, e.g. rust-numpy. Building and testing works fine until you add a workspace with "example/extensions" in it, after which cargo test --all will fail with linker errors.
In summary, cargo seems to use the linker args of one crate in the workspace for all crates instead of using the correct ones for each crate.
This is a conflation of a number of preexisting bugs. They're not super well indexed unfortunately. Cargo unions all features which means with --all it would union all the features requested by anything, and a different bug means that Cargo never compiles multiple versions of a crate with different sets of features meaning that a crate is only compiled once with one set of features.
In that sense it's not compatible with features today in Cargo to have a set of binaries that only work with a feature and a set that only work without, and then build them all at once.
As this is caused by feature unification, I'm closing this in favor of #4463. If there is a reason for us to keep this specific issue open, let us know!
For crates built upon pyo3, you need different linker args for binaries and libraries. Binaries need to link libpython, while libraries are forbidden by PEP 513 to link libpython. By default pyo3's build script add emits the arguments to link libpython and libraries use a feature called
extension-module
to deactivate those flags.When building in a workspace with
--all
, cargo seems to conflate the linker args, causing linker errors. Pyo3 itself for example has a main crate with tests and an example that is an extension module.cargo test
works fine andcd examples/word-count/ && cargo test
also works fine, butcargo build --all --tests
fails to compile the tests with linker errors missing libpython: Output ofcargo build --all --tests -vvv
. This seems to mean that cargo uses the linker args of the word count example with the extension module feature for the tests of pyo3 itself instead of using those for the pyo3 crate without the extension module feature.This bug also occurs in dependent crate, e.g. rust-numpy. Building and testing works fine until you add a workspace with
"example/extensions"
in it, after whichcargo test --all
will fail with linker errors.In summary, cargo seems to use the linker args of one crate in the workspace for all crates instead of using the correct ones for each crate.
Used Versions
cargo -V
:cargo 1.29.0-nightly (6a7672ef5 2018-08-14)
The text was updated successfully, but these errors were encountered: