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 build on workspaces does not interact well with vendored dependencies #3539

Closed
froydnj opened this issue Jan 12, 2017 · 3 comments
Closed

Comments

@froydnj
Copy link
Contributor

froydnj commented Jan 12, 2017

I'm not sure if this is a problem with vendored dependencies, or whether it's a problem with how the dependencies of workspaces get computed. Apologies in advance for the long-winded details.

Firefox has some crates that get built separately:

Both of these crates depend on a shared crate:

Building both gkrust and gkrust-gtest require separate builds of gkrust-shared, which is unnecessary work; we would like to use workspaces to solve this problem.

Firefox also vendors all of its Rust dependencies:

https://hg.mozilla.org/mozilla-central/file/tip/third_party/rust

The crates currently there permit all the Rust code in tree to be built without a problem. In particular. the mp4parse crate:

https://hg.mozilla.org/mozilla-central/file/tip/media/libstagefright/binding/mp4parse/Cargo.toml

has a dev-dependencies of test-assembler, but we do not have test-assembler vendored, as we don't compile tests, examples, or benchmarks (as the documentation behind dev-dependencies indicates).

If we try to tie gkrust and gkrust-gtest into a workspace, however, by introducing a top-level Cargo.toml:

[workspace]
members = [
    "toolkit/library/rust",
    "toolkit/library/gtest/rust",
]

# Explicitly specify what our profiles use.
[profile.dev]
opt-level = 1
debug = true
rpath = false
lto = false
debug-assertions = true
codegen-units = 1
panic = "abort"

[profile.release]
opt-level = 2
debug = true
rpath = false
lto = true
debug-assertions = false
panic = "abort"

when we try to build the gkrust crate via cargo build, Cargo says:

error: no matching package named `test-assembler` found (required by `mp4parse`)
location searched: registry https://github.com/rust-lang/crates.io-index
version required: = 0.1.5

But Cargo shouldn't need that crate for cargo build, since building gkrust standalone without workspaces works just fine.

@froydnj
Copy link
Contributor Author

froydnj commented Jan 12, 2017

@mbrubeck informs me that this behavior was implemented in #3125. I claim there are still some bugs to be worked out. :)

@alexcrichton
Copy link
Member

I believe that this is intended behavior of Cargo today, and I believe that #3125 is unrelated to this issue.

On all Cargo invocations it will always generate a Cargo.lock, and for a workspace this lock file describes the entire workspace. Lock files contain dev dependencies to support cargo test (e.g. everything is resolved ahead of time), and cargo test is supported on all crates in a workspace. That means that all member crates of a workspace will have all their dev-dependencies included in the lock file.

A solution here would be to exclude mp4parse from the workspace, but that would likely require #3192 to be implemented. Conversely the test-assembler could also be vendored for now in the vendor directory.

Does that make sense?

@alexcrichton
Copy link
Member

I'm going to close this as intended behavior, but let me know if there's still something here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants