Support OUT_DIR located in \\?\
path on Windows
#13914
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
See rust-lang/rust#75075. If cargo.exe is compiled on Windows with a target dir that begins with "\\?\", the build fails with an error similar to the one seen in https://github.com/tokio-rs/tokio/actions/runs/9075609753/job/24936610110.
Normally in Windows paths
/
works just as well as\
, but from Maximum Path Length Limitation: File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections.How should we test and review this PR?
This should be "if it compiles, it works" and Cargo's CI already has coverage on Windows. We can look into what Tokio's CI was doing to trigger the "\\?\" case in GitHub Actions and try to reproduce it in Cargo's CI if desired.
Additional information
Future work: I hope that someone can make a successful proposal for something like
include_bytes!(concat!(env!("OUT_DIR") / "man.tgz"))
that works in a cross-platform manner by using the correct path separator for rustc's host OS.