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

Dependencies for all platforms are downloaded. #255

Open
kevincox opened this issue Jun 23, 2022 · 3 comments
Open

Dependencies for all platforms are downloaded. #255

kevincox opened this issue Jun 23, 2022 · 3 comments

Comments

@kevincox
Copy link

When building for a single platform naersk downloads the dependencies for all platforms. Ideally it would only download for the current target. For example when building a project that depends on tokio on linux it downloads all of the winapi crates.

One downside is that the crates derivation will be different for different OSes. I don't think this is an issue because right now the checksum is done per-crate so that shouldn't be an issue. Maybe slightly wasted space if we build up different dependency trees for different platforms? But symlinking or hardlinking would likely resolve that.

@Patryk27
Copy link
Contributor

Hmm, but that's a chicken-egg problem, no?

We have to download / checkout crate even if to read its Cargo.toml (to see the targets), and if we do that, then we might as well just keep the downloaded crate around.

Is there some magic Cargo.lock-per-platform I'm not aware of? 😅

@Patryk27
Copy link
Contributor

Patryk27 commented Jun 25, 2022

Ah, cargo metadata returns dependencies[].target - that could come useful 👀

Edit: even better, cargo metadata supports --filter-platform.

@kevincox
Copy link
Author

Yup, the dependant crate has the dependency conditions in its Cargo.toml. If you look at Tokio's dependencies you will see that lots of them are conditional on the platform.

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