8000 Add explicit XP targets by ChrisDenton · Pull Request #66801 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Add explicit XP targets #66801

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

Closed
wants to merge 5 commits into from
Closed

Add explicit XP targets #66801

wants to merge 5 commits into from

Conversation

ChrisDenton
Copy link
Member

Windows XP support in Rust can generously be described as anaemic (if not outright broken) and yet the fully supported Windows 7+ target is partially reliant on maintaining some compatibility with XP (e.g. the runtime compatibility layer in libstd). So this PR adds two target triples for XP, allowing 32-bit and 64-bit Windows XP to be targetted separately from Windows 7+. For now the targets are literally a copy/paste of the current i686-pc-windows-msvc and x86_64-pc-windows-msvc, though this could be improved if someone is willing to tackle XP support more thoroughly.

I think this is advantageous whatever the future of XP in Rust. If support is dropped completely then this could potentially provide a more graceful transition before removing it. However if anybody is willing to maintain an XP target then having an explicit triple can only help. And even if XP support remains, as it is now, in a kind of limbo then at least crates will be able to target XP separately from Windows 7+ (although unsurprisingly most crates ignore XP support entirely).

In any case allowing the pc-windows targets to be focused on Windows7+ support would be an advantage.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @varkor (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 27, 2019
@crlf0710
Copy link
Member
crlf0710 commented Nov 27, 2019

@ChrisDenton Windows XP compatible compilation need to properly specify the /subsystem property to the linker.

Crate config Target Type Linker Flags
normal crate normal msvc target specify nothing or /SUBSYSTEM:console
#![windows_subsystem(x)] crate normal msvc target specify /SUBSYSTEM:x
normal crate xp msvc target 32bit specify /SUBSYSTEM:console,5.01
#![windows_subsystem(x)] crate xp msvc target 32bit specify /SUBSYSTEM:x,5.01
normal crate xp msvc target 64bit specify /SUBSYSTEM:console,5.02
#![windows_subsystem(x)] crate xp msvc target 64bit specify /SUBSYSTEM:x,5.02

Here's the ms document for these:
https://docs.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=vs-2019

Extra notes: MINGW GNU flavor linker syntax is "--subsystem which:major.minor", changing the comma to a semicolon.
https://manpages.debian.org/unstable/binutils-mingw-w64-x86-64/x86_64-w64-mingw32-ld.1.en.html

@ChrisDenton
Copy link
Member Author

Thanks. My thinking was to provide these targets as a baseline to be improved if there is an appetite for it. Windows XP is already considered a "tier 3" platform using pc-windows-msvc as is and I'm not confident enough with Rust's codegen to be sure of my changes to it.

However, I'll attempt the changes. On my first attempt I missed your note about MINGW so I'll need to rethink that commit.

@ChrisDenton
Copy link
Member Author

Hopefully this commit is more robust. There's basically two parts to it. It adds an optional version parameter to the Linker subsystem function. To make use of this it also changes the windows_subsystem field of CodegenResults to be this struct instead of a string:

pub struct WindowsSubsystem {
    pub name: String,
    pub version: Option<String>
}

The part that may be more iffy is where I override Windows XP targets to set the subsystem version.

@varkor
Copy link
Member
varkor commented Nov 27, 2019

r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned varkor Nov 27, 2019
@petrochenkov
Copy link
Contributor

What's the problem with the dynamic fallbacks as they exist now?

I now care not even about XP/Vista, but about ReactOS, which may lack some newer APIs without matching a specific version of Windows precisely, thus probably requiring dynamic fallbacks.
I would expect it to not have a separate target, because the goal of the project is to run Windows software unmodified.
(I don't know what exact APIs they lack now, but a few years ago they were somewhere around Vista, and the development was pretty fast in the last couple of years.)

@crlf0710
Copy link
Member
crlf0710 commented Nov 28, 2019