-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add a windows manifest file #13131
Add a windows manifest file #13131
Conversation
This avoids the need for compatibility shims, sets the code page to UTF-8 and enables long path awareness.
r? @ehuss (rustbot has picked a reviewer for you, use r? to override) |
A minor concern I had is that there is a fairly significant amount of C code that cargo uses. What are the chances this would cause a problem (like a buffer overflow) with that? It seems pretty unlikely to me, but I don't know which APIs might be at risk. Is it just looking out for usage of |
Yes. I think the risk is low. If C code does use fixed sized |
Btw, I'm not sure why check-version-bump failed. It doesn't seem related to this PR? But maybe I'm missing something. curl-sys error
|
Probably due to alexcrichton/curl-rust#542. |
OK, I did a little bit of auditing. I think these should mostly be OK, but I'm always a little worried about what I don't know here. home uses a fixed-width MAX_PATH buffer, but
sqlite is limited to MAX_PATH in a lot of places, but I'm going to assume all its usage is correct. It can be compiled with a define to use a longer path, but I don't think that is immediately necessary. There is a special VFS to support 32K paths, but that requires special handling. We'll need to consider this if we start using sqlite in the target directory, and we want to support target directories that exceed MAX_PATH. curl has a disturbingly large amount of MAX_PATH routines that I don't feel inclined to review. Hopefully someone out there has already done that. 🤷 git2 also has a bunch of MAX_PATH buffers, but looks to usually validate lengths. However, I also don't feel inclined to review. It is a little worrisome that it appears to support paths longer than MAX_PATH even though there are code paths that seem to have MAX_PATH buffers. I'm not sure how it does that. It seems to honor There's a few other little things (like openssl), but none jumped out to me. It looks like this might help a few long-path scenarios, but doesn't cover everything. IIUC, |
I think
Looking through a few of the curl/sqlite/git2 hits, I'm not too worried by what I've seen so far. I think the main issue would be UB due to incorrect assumptions which I'm not seeing. I'm not so worried about cases where the buffer is simply too small. That's an error but it's no worse than the current situation and can be fixed. libgit2 is however funny in that it has to artificially enforce the
True. Though this could change.
With longpathaware it can be.
It should do now. |
Oh, wait the combination of both running a process and setting the current directory might not work together (i.e. EDIT: Yeah, launching a process with a current directory longer than |
|
I'm unable to get this to work. Perhaps it depends on the shell? I have Windows 10 22H2 (19045.3693), with the LongPathsEnabled registry entry set, running in Windows Terminal, using cargo built with this PR. Running cargo prints:
Ah, that does seem to work now if there is a manifest. However, for processes that don't have a manifest (like build scripts launching other processes), it fails. I get |
See my next comment. Using |
I've created an issue about Ok, so I think that having long path awareness is on the whole better than not having it. It can help in a few cases and, from what I've seen, the C dependencies seem fine with it. I admittedly haven't fully audited it all so I can't be certain but given that long path awareness has been around since ~2016, it's not like we're blazing a trail here. Still, I can understand if Cargo wants to be more cautious. I'd be happy to update this PR to remove the The issue of setting the current directory is more concerning. Cargo uses |
I'll go ahead and approve. I think on balance, it probably should be safe, and does help with a few, although limited circumstances. In the future we may want to consider moving this file (and possibly Regarding @bors r+ |
☀️ Test successful - checks-actions |
Update cargo 12 commits in 9787229614b27854cf73d57ffae430d7c1e6caa4..6feabf94773286928b7d73d0d313c0c5562b66af 2023-12-06 02:29:23 +0000 to 2023-12-08 22:38:37 +0000 - fix: explicitly remap current dir by using `.` (rust-lang/cargo#13114) - Don't rely on mtime to test changes (rust-lang/cargo#13143) - refactor: Pull PackageIdSpec into schema (rust-lang/cargo#13128) - fix: Print rustc messages colored on wincon (rust-lang/cargo#13140) - Add a windows manifest file (rust-lang/cargo#13131) - Avoid writing CACHEDIR.TAG if it already exists (rust-lang/cargo#13132) - re-enable flaky tests thanks to update to `gix-config`. (rust-lang/cargo#11821) (rust-lang/cargo#13130) - fix bash completion in directory with spaces (rust-lang/cargo#13126) - test: re-ignore git auth tests for gitoxide (rust-lang/cargo#13129) - fix(toml): Disallow inheriting of dependency public status (rust-lang/cargo#13125) - re-enable previously disabled tests with Windows-specific fix (rust-lang/cargo#13117) - refactor: Clarify PackageId constructor names (rust-lang/cargo#13123) r? ghost
Update cargo 13 commits in 9787229614b27854cf73d57ffae430d7c1e6caa4..66ad359b408ccdf867cceb30cc2dff1ed4afd82d 2023-12-06 02:29:23 +0000 to 2023-12-09 12:30:01 +0000 - chore: downgrade to openssl v1.1.1 (rust-lang/cargo#13144) - fix: explicitly remap current dir by using `.` (rust-lang/cargo#13114) - Don't rely on mtime to test changes (rust-lang/cargo#13143) - refactor: Pull PackageIdSpec into schema (rust-lang/cargo#13128) - fix: Print rustc messages colored on wincon (rust-lang/cargo#13140) - Add a windows manifest file (rust-lang/cargo#13131) - Avoid writing CACHEDIR.TAG if it already exists (rust-lang/cargo#13132) - re-enable flaky tests thanks to update to `gix-config`. (rust-lang/cargo#11821) (rust-lang/cargo#13130) - fix bash completion in directory with spaces (rust-lang/cargo#13126) - test: re-ignore git auth tests for gitoxide (rust-lang/cargo#13129) - fix(toml): Disallow inheriting of dependency public status (rust-lang/cargo#13125) - re-enable previously disabled tests with Windows-specific fix (rust-lang/cargo#13117) - refactor: Clarify PackageId constructor names (rust-lang/cargo#13123)
Update cargo 20 commits in 9787229614b27854cf73d57ffae430d7c1e6caa4..1aa9df1a5be205cce621f0bc0ea6062a5e22a98c 2023-12-06 02:29:23 +0000 to 2023-12-12 14:52:31 +0000 - crates-io: Add support for other 2xx HTTP status codes (rust-lang/cargo#13158) - Remove the deleted feature test_2018_feature from the test (rust-lang/cargo#13156) - refactor(schema): Remove reliance on cargo types (rust-lang/cargo#13154) - fix(toml)!: Disallow `[lints]` in virtual workspaces (rust-lang/cargo#13155) - Limit exported-private-dependencies lints to libraries (rust-lang/cargo#13135) - chore: update to gix-index@0.27.1 (rust-lang/cargo#13148) - Update curl-sys to bring in curl 8.5.0 (rust-lang/cargo#13147) - chore: downgrade to openssl v1.1.1 (rust-lang/cargo#13144) - fix: explicitly remap current dir by using `.` (rust-lang/cargo#13114) - Don't rely on mtime to test changes (rust-lang/cargo#13143) - refactor: Pull PackageIdSpec into schema (rust-lang/cargo#13128) - fix: Print rustc messages colored on wincon (rust-lang/cargo#13140) - Add a windows manifest file (rust-lang/cargo#13131) - Avoid writing CACHEDIR.TAG if it already exists (rust-lang/cargo#13132) - re-enable flaky tests thanks to update to `gix-config`. (rust-lang/cargo#11821) (rust-lang/cargo#13130) - fix bash completion in directory with spaces (rust-lang/cargo#13126) - test: re-ignore git auth tests for gitoxide (rust-lang/cargo#13129) - fix(toml): Disallow inheriting of dependency public status (rust-lang/cargo#13125) - re-enable previously disabled tests with Windows-specific fix (rust-lang/cargo#13117) - refactor: Clarify PackageId constructor names (rust-lang/cargo#13123)
manifest.to_str().unwrap() | ||
); | ||
// Turn linker warnings into errors. | ||
println!("cargo:rustc-link-arg-bin=cargo=/WX"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warnings as errors outside of CI doesn't sound like a good idea. New warnings might get introduced in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with Windows in terms of how often it gets new linker warnings. If it turns out too annoying we can always change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trouble here is that this might make versions of Cargo harder to build in the future. If a new version of MSVC gets released that throws a warning here, we'll need to patch all old versions of Cargo to even make them build. See https://embeddedartistry.com/blog/2017/05/22/werror-is-not-your-friend/ ("-Werror Introduces a Toolchain Version Dependency"). It's better to only enable /WX
in CI, this way you can always change it, but don't leave users who want to compile Cargo with errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assumed "we" referring to someone needing to build olders Cargo on their own. Although we only support the latest stable Cargo, we should try our best to play nice with downstream packagers. Could you open an issue and the team can discuss there?
This adds a Windows application manifest file to the built
cargo.exe
for windows msvc. This manifest file is used to enable modern features of Windows.rustc
has been using a similar manifest for about a year now.The manifest file does the following:
\\?\
paths internally. However, this doesn't work for the current directory whereas using this option does.You can test that a manifest file has been embedded by extracting it to a new file:
You can also examine the
.rsrc
(aka resource) section usingdumpbin
Additional info
This also sets the
/Wx
linker option which turns linker warnings into errors. When setting linker options manually, I prefer to also set this because, unless there are also linker errors,rustc
will not show linker warnings by default. Linker warnings should be rare and usually do indicate an actual problem so not ignoring them should be fine.