I have a github repository showing an awkward linking problem with a c++ library.
In this repository and branch I bulld some rust code, c++ code and Swift code and link it together to an executable. There is also a Criterion benchmark comparing the performance of some functions there in the different language implementations. The curious thing is, if I run
cargo run --release
everything builds and links fine and the resulting executable runs.
But if I do
cargo bench
cargo fails to link the benchmark executable with an error message indicating (and I can see in the linker invocation line that this is indeed the case) that the c++ library isn't linked into the executable.
My current workaround is to make the c++ code a shared library. But I consider this behaviour to be a bug. If cargo run works (cargo build as well), cargo bench should work either.
Or what am I doing wrong here?
This is on MacOS Sonoma on Apple Silicon.