Description
Please check out the minimized project to reproduce: https://github.com/skletsun/cargo_feature_dylib_issue.
There is a workspace that contains a dynamic library and a project that depends on it. The library has a feature. The problem is that the same building and testing scenario does not work for recent toolchains:
Working scenario:
cargo +1.26.2 build --features feature
cargo +1.26.2 test --all -- --nocapture
Doesn't work:
cargo +1.28.0 build --features feature
cargo +1.28.0 test --all -- --nocapture
My current observations (tested on OSX): Working scenario - at step (1) library libcargo_check.dylib
gets built within the target/debug/deps
directory and then copied to target/debug
. At step (2) it gets rebuilt (because of the missing feature), also copied (overwriting the old one) to the target/debug
and then the test app is executed being linked against the shared library in the target/debug
. When I try doing the same with newer toolchain (non-working scenario) it behaves almost same way except that on step (2) the library gets rebuilt into target/debug/deps
BUT NOT COPIED to the target/debug
and the test app is executed against the old version of the dynamic library in target/debug
. And if I manually delete the outdated libcargo_check.dylib
in target/debug
then cargo +1.28.0 test --all -- --nocapture
works as expected because the test app is executed against dynamic library located in target/debug/deps
.
The original Rust project is a part of a complex project that involves Java, so the whole project gets built with Maven, which in turn executes cargo for building and testing in some order. My expectation is that cargo test
should behave the same way as in previous versions of toolchains.
I tested it against a few versions of toolchain and can say that it works for 1.26.2 and 1.27.2, but doesn't work for 1.28.0 and 1.29.1.
Thanks in advance!