Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiled crates are not reused across dev/release even if the configuration is the same #7627

Closed
Vlad-Shcherbina opened this issue Nov 24, 2019 · 2 comments
Labels
C-bug Category: bug

Comments

@Vlad-Shcherbina
Copy link

Steps to reproduce

  1. Create a crate with the following Cargo.toml:
    [package]
    name = "cargo_cache_is_frustrating"
    version = "0.1.0"
    edition = "2018"
    
    [dependencies]
    bitflags = "1.2"
    
    [profile.dev]
    opt-level = 3
    debug = false
    rpath = false
    lto = false
    debug-assertions = false
    codegen-units = 16
    panic = 'unwind'
    incremental = false
    overflow-checks = false
    
    [profile.release]  # exactly the same
    opt-level = 3
    debug = false
    rpath = false
    lto = false
    debug-assertions = false
    codegen-units = 16
    panic = 'unwind'
    incremental = false
    overflow-checks = false
  2. cargo build
  3. cargo build --release

Actual result

> cargo build
   Compiling bitflags v1.2.1
   Compiling cargo_cache_is_frustrating v0.1.0 (...\cargo_cache_is_frustrating)
    Finished dev [optimized] target(s) in 1.92s
> cargo build --release
   Compiling bitflags v1.2.1
   Compiling cargo_cache_is_frustrating v0.1.0 (...\cargo_cache_is_frustrating)
    Finished release [optimized] target(s) in 4.33s

Expected result

> cargo build
   Compiling bitflags v1.2.1
   Compiling cargo_cache_is_frustrating v0.1.0 (...\cargo_cache_is_frustrating)
    Finished dev [optimized] target(s) in 1.92s
> cargo build --release
    Finished release [optimized] target(s) in 0.00s

I checked cargo --build-plan outputs and they're identical
except they use paths in target/debug and target/release and

 {
     "invocations": [
         ...
         {
             "package_name": "bitflags",
             ...
             "env": {
                 ...
-                "PROFILE": "debug",
+                "PROFILE": "release",

Why do I care

In this case maybe I don't. It's just a small repro. However, this also happens with dependency profile overrides, and there it entirely defeats one of their main purposes.

Version info

> cargo version --verbose
cargo 1.41.0-nightly (8280633db 2019-11-11)
release: 1.41.0
commit-hash: 8280633db680dec5bfe1de25156d1a1d53e6d190
commit-date: 2019-11-11
@Vlad-Shcherbina Vlad-Shcherbina added the C-bug Category: bug label Nov 24, 2019
@alexcrichton
Copy link
Member

I believe this would be fixed by #6668, but it's a very tricky change.

@ehuss
Copy link
Contributor

ehuss commented Dec 3, 2019

Yea, #6668 would address this. Since this is on our radar (and there is a meta tracking issue at #7150), I'm going to close this. Thanks for the report, though!

@ehuss ehuss closed this as completed Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants