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 0.73 build broken on windows #12562

Closed
est31 opened this issue Aug 25, 2023 · 4 comments · Fixed by #12563 or #12564
Closed

cargo 0.73 build broken on windows #12562

est31 opened this issue Aug 25, 2023 · 4 comments · Fixed by #12563 or #12564
Labels
A-cargo-api Area: cargo-the-library API and internal code issues O-windows OS: Windows P-high Priority: High S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@est31
Copy link
Member

est31 commented Aug 25, 2023

I updated cargo to 0.73 from crates.io in cargo-udeps (commit) and got the following build failure on ci:

 error[E0432]: unresolved import `windows_sys::Win32::Storage::FileSystem::LockFileEx`
   --> C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cargo-0.73.0\src/cargo\util\flock.rs:443:9
    |
443 |         LockFileEx, UnlockFile, LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY,
    |         ^^^^^^^^^^
    |         |
    |         no `LockFileEx` in `Windows::Win32::Storage::FileSystem`
    |         help: a similar name exists in the module: `LockFile`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `cargo` (lib) due to previous error

If you look at the rustdoc for LockFileEx, it writes:

Required features: "Win32_Storage_FileSystem", "Win32_Foundation", "Win32_System_IO"

Compare this with the Cargo.toml of 0.73:

cargo/Cargo.toml

Lines 180 to 188 in 103a7ff

[target.'cfg(windows)'.dependencies.windows-sys]
workspace = true
features = [
"Win32_Foundation",
"Win32_Storage_FileSystem",
"Win32_System_Console",
"Win32_System_Threading",
"Win32_System_JobObjects",
]

The former two are found while Win32_System_IO isn't present. I suppose this is the cause for the failure: in the cargo repo this works fine because of dependency unification and another crate in the DAG enabling the Win32_System_IO features. But if you use cargo from crates.io, then it is not enabled, which is what I ran into.

The fix is simple, just add Win32_System_IO to the list. Ideally this would also be published in a new release.

I have worked around the issue by making cargo-udeps depend on windows-sys and enabling the feature (commit).

@weihanglo weihanglo added P-high Priority: High A-cargo-api Area: cargo-the-library API and internal code issues S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review O-windows OS: Windows labels Aug 25, 2023
@est31
Copy link
Member Author

est31 commented Aug 26, 2023

So apparently with master cargo the issue doesn't occur, as seen in the second commit of my PR est31/cargo-udeps#194 . the third commit uses cargo 0.73 from git and reproduces the issue. The fourth commit applies a patch that just adds Win32_System_IO and it fixes the issue. IDK about beta cargo or what changed to fix the issue until master.

@weihanglo
Copy link
Member

Thanks for the report! This was introduced by #12176, which claimed has tested against each crate.

The short term plan here is adding back missing features. In long term we might adding tool like cargo-hack or cargo-hakari to prevent this from happening again.

We might also have a deeper look at #11987, which might not worth pursuing in CI.

Sorry for the inconvenience 😞.

bors added a commit that referenced this issue Aug 26, 2023
[beta-1.73.0] add missing `windows-sys` features back

Fixes <#12562>

Beta backports:

- <#12563>

In order to make CI pass, the following PRs are also cherry-picked:

-
bors added a commit that referenced this issue Aug 26, 2023
[stable-1.72.0] add missing `windows-sys` features back

Stable backports:

- <#12563>

In order to make CI pass, the following PRs are also cherry-picked:

- b4a26b0 from #12475
- c508cb6 from #12538
- 43c253e from #12351
- 689defd from #12500

---

Fixes <#12562>

This won't affect Rust releases, i.e. no 1.72.1 will happen. We do this only for release `cargo` crate.
bors added a commit that referenced this issue Aug 26, 2023
[beta-1.73.0] add missing `windows-sys` features back

Fixes <#12562>

Beta backports:

- <#12563>

In order to make CI pass, the following PRs are also cherry-picked:

- c508cb6 from #12538
@ehuss
Copy link
Contributor

ehuss commented Aug 26, 2023

0.73.1 should be published now.

I opened #12567 to try to figure out if there is some way to avoid this in the future.

@est31
Copy link
Member Author

est31 commented Aug 26, 2023

@ehuss @weihanglo thanks for the quick fix!

est31 added a commit to est31/cargo-udeps that referenced this issue Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo-api Area: cargo-the-library API and internal code issues O-windows OS: Windows P-high Priority: High S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
3 participants