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

Put windows deps in (default-included) feature #766

Open
jhartzell42 opened this issue Mar 23, 2023 · 9 comments
Open

Put windows deps in (default-included) feature #766

jhartzell42 opened this issue Mar 23, 2023 · 9 comments

Comments

@jhartzell42
Copy link
Contributor

Due to idiosyncrasies of how cargo resolves dependencies, all the Windows dependencies show up in Cargo.lock files even on Linux -- and in Yocto builds, which is making our build process more difficult. Features do not have the same issue.

There should be a "windows" feature, included by default to avoid breaking existing clients, that can be explicitly disabled if the windows dependencies are not going to be used. This will make building easier on Yocto and other build systems.

I am willing to (and going to) write a PR for this; I'm just adding an issue first for discussion in principle.

@sigmaSd
Copy link
Contributor

sigmaSd commented Mar 23, 2023

Is there an issue about this in cargo repo ?

@jhartzell42
Copy link
Contributor Author

rust-lang/cargo#1197 is very close.

@jhartzell42
Copy link
Contributor Author

The fix I have is #767 , which takes my project from not building on Yocto to building on Yocto, I think without hurting anyone else's builds on Windows or Unix.

@jhartzell42
Copy link
Contributor Author

#767 being merged addresses the issue.

@joshka
Copy link
Collaborator

joshka commented Nov 18, 2024

Hey @jhartzell42

I'm looking at @TimonPost's comment on https://github.com/crossterm-rs/crossterm/pull/943/files#r1845623030 about the changes that you made here and trying to understand what the underlying problem was.

The windows deps appearing in the lockfile is intended cargo behavior, as the lockfile doesn't specify which dependencies to use, only which versions of them to use if called for by the manifest. The Cargo.toml file is responsible for choosing which deps to use. The previous configuration without the feature flag correctly gated the windows deps with conditions that only evaluate as true on windows. This works fine on my Mac to not enable the winapi stuff.

I'm curious why the contents of the lock file caused problems in your build process. Is Yocto doing something special?

@joshka joshka reopened this Nov 18, 2024
@joshka
Copy link
Collaborator

joshka commented Nov 18, 2024

Digging a bit deeper meta-rust/cargo-bitbake#58 suggests that removing the windows deps from the Yocto side is the correct thing to do, instead of marking the correctly specified deps as optional and behind a feature flag like this. It's possible I'm misunderstanding this in some way...

joshka added a commit that referenced this issue Nov 22, 2024
In #766 / #767, a windows feature flag was added to solve an issue with
the way that Yocto package generation was working. This is not actually
a problem with Crossterm, but with the Yocto package generation tooling
which adds all the dependencies for all features, even if they are not
relevant to the target platform. This is a bug in the Yocto / meta-rust
/ bitbake tooling and not in Crossterm. For more information, see
<meta-rust/cargo-bitbake#58>.

The fix for this on the Yocto side is to remove dependencies that are
conditional on windows. This commit removes the windows feature flag as
it's not needed.

This is a breaking change for any apps which were specifically using
the windows feature flag. If you were using this feature flag, you will
need to update your Cargo.toml to remove it. The necessary dependencies
are still included in the Cargo.toml file, so you should not need to
make any other changes.
@joshka
Copy link
Collaborator

joshka commented Nov 22, 2024

#948 reverts this change. @jhartzell42 can you please confirm that this doesn't have problems (I think it's the correct thing to do, but would like do check that there's not something I'm missing).

@jhartzell42
Copy link
Contributor Author

I don't work on the Yocto project anymore and don't have access to it and cannot troubleshoot, unfortunately.

@joshka
Copy link
Collaborator

joshka commented Nov 23, 2024

Thanks for the reply. My understanding is that the problem you saw was in generating package config right, i.e. dev / config time problems not a hard fail right? No problem if you can't recall.

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

3 participants