Skip to content

Using profile-overrides results in both optimized and unoptimized versions of the same crate in linked executable  #63484

Closed as not planned
@aclysma

Description

@aclysma

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-cargoRelevant to the cargo team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions