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

cargo install --path re-compiles all the crates #7688

Closed
aplanas opened this issue Dec 9, 2019 · 2 comments
Closed

cargo install --path re-compiles all the crates #7688

aplanas opened this issue Dec 9, 2019 · 2 comments
Labels
C-bug Category: bug

Comments

@aplanas
Copy link

aplanas commented Dec 9, 2019

Problem

When working with a project with workspaces, and I compile it in release mode (cargo build --release), it will recompile all the crates when I install a binary (cargo install --root ... --path ...)

I would expect that the libraries already compiled in release mode, are not recompiled when installing.

This is happening in nightly but also in stable 1.39.

Steps

> cargo --version
cargo 1.41.0-nightly (626f0f40e 2019-12-03)

> rustc --version
rustc 1.41.0-nightly (59947fcae 2019-12-08)

> cat Cargo.toml

[workspace]
members = [
        "kanidm_proto",
        "kanidmd",
        "kanidm_client",
        "kanidm_tools",
]

> cargo build --workspace --release
   Compiling libc v0.2.65
...
   Compiling kanidm_client v0.1.0 (...kanidm/kanidm_client)
   Compiling kanidm v0.1.0 (...kanidm/kanidmd)
   Compiling kanidm_tools v0.1.0 (...kanidm/kanidm_tools)
    Finished release [optimized] target(s) in 3m 40s

ls -la target/release/
total 61632
drwxr-xr-x   7 xx xx     4096 Dec  9 15:51 .
drwxr-xr-x   3 xx xx     4096 Dec  9 15:51 ..
drwxr-xr-x  94 xx xx     4096 Dec  9 15:47 build
-rw-r--r--   1 xx xx        0 Dec  9 15:47 .cargo-lock
drwxr-xr-x   2 xx xx    57344 Dec  9 15:51 deps
drwxr-xr-x   2 xx xx     4096 Dec  9 15:47 examples
drwxr-xr-x 326 xx xx    20480 Dec  9 15:47 .fingerprint
drwxr-xr-x   2 xx xx     4096 Dec  9 15:47 incremental
-rwxr-xr-x   2 xx xx  9563608 Dec  9 15:50 kanidm
-rw-r--r--   1 xx xx      270 Dec  9 15:51 kanidm.d
-rwxr-xr-x   2 xx xx 14258824 Dec  9 15:51 kanidmd
-rw-r--r--   1 xx xx     3026 Dec  9 15:51 kanidmd.d
...

> ls -ld target/release/build/libc*
drwxr-xr-x 3 xx xx 4096 Dec  9 15:47 target/release/build/libc-4f0e06f887637e12
drwxr-xr-x 2 xx xx 4096 Dec  9 15:47 target/release/build/libc-a0bc39419ec38101

> cargo install --root tmp --path kanidmd
  Installing kanidm v0.1.0 (...kanidm/kanidmd)
    Updating crates.io index
   Compiling libc v0.2.66
...
   Compiling kanidm v0.1.0 (...kanidm/kanidmd)
    Finished release [optimized] target(s) in 2m 23s
  Installing tmp/bin/kanidmd
   Installed package `kanidm v0.1.0 (...kanidm/kanidmd)` (executable `kanidmd`)

> ls -ld target/release/build/libc*
drwxr-xr-x 3 xx xx 4096 Dec  9 15:53 target/release/build/libc-09252e2d78456def
drwxr-xr-x 3 xx xx 4096 Dec  9 15:47 target/release/build/libc-4f0e06f887637e12
drwxr-xr-x 2 xx xx 4096 Dec  9 15:47 target/release/build/libc-a0bc39419ec38101
drwxr-xr-x 2 xx xx 4096 Dec  9 15:53 target/release/build/libc-b5a8abe7c40a1557
@aplanas aplanas added the C-bug Category: bug label Dec 9, 2019
@ehuss
Copy link
Contributor

ehuss commented Dec 9, 2019

I suspect this is because Cargo is choosing different features for dependencies. When built in the root of a virtual workspace, the features will get unified across the workspace. But when you build (or install) a member in isolation, it only uses the features needed by that member. Can you verify that it is choosing different features?

If that's the case, you can make sure each member declares the same features (even for transitive dependencies). In rustc, we use an empty crate to ensure everything uses the same feature set.

(There are a variety of open issues on this topic, such as #5210 and #4463.)

@aplanas
Copy link
Author

aplanas commented Dec 11, 2019

This is the case. Let me close this one, and I will follow the one pointed.

Thanks a lot for your help!

@aplanas aplanas closed this as completed Dec 11, 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

2 participants