Description
I'm trying to use the "profile-overrides" feature in cargo. The tracking issue for this feature is here: #48683
The documentation for this is here: https://doc.rust-lang.org/cargo/reference/unstable.html#profile-overrides
I'm trying to build my crate without optimizations, and upstream crates with optimizations. (The application runs too slowly to properly test if the upstream crates are not optimized.)
My .toml looks like this:
[profile.dev]
opt-level = 0
[profile.dev.overrides."*"]
opt-level = 3
I have a minimum reproducible example here: https://github.com/aclysma/mre-optimize-dependencies-only
The "slow" crate is nphysics. The minimum reproducible example contains a "main" root crate and a shim crate. Both have nearly the same code, but behave differently:
- If I call nphysics code from the root crate (that should have optimizations disabled,) it appears in the debugger that the nphysics code is unoptimized.
- If I call the code from the shim crate (that should have optimizations enabled,) the nphysics code is optimized.
Expected Behavior: the linked binary would have a single implementation for any functions in nphysics, and all call sites would jump to that one address
Observed Behavior: My linked executable appears to have both an unoptimized and optimized version of nphysics, and depending on if the caller is optimized or not, the jump goes to a different address.