-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Proposal
This compiler MCP proposes a new target: x86_64-nt-windows-msvc. This target will be a variation of the pc-windows-msvc target, but produces executables for the native subsystem and thus only uses NT API calls and no external C runtime.
An implementation of that target is still a work-in-process and not publicly available yet, as I wanted to first await the responses to this MCP.
Motivation / rationale
NT supports subsystems, of which Win32 is the only surviving one but, it also supports running applications that target the native subsystem, i.e. no other subsystem at all. This kind of application is used for certain applications during the boot process (the executables in the BootExecute and SetupExecute registry values that are run during the boot process are required to be for the native subsystem because they run before Win32 is initialized), and can also be executed via RtlCreateUserProcess. They are, however, not supported by CreateProcess. Otherwise, they are standard PE executables running within Windows, not some special construct like WSL.
As NT is the base layer onto which Win32 builds on, there are certain differences to what x86_64-pc-windows-msvc requires that make it best suited for a separate target:
- There is no C runtime library, so
memcpy, and other builtins need to be provided bycompiler-builtins. - Similarly,
_fltused, currently only used for UEFI, and_chkstk, currently only used for the GNU targets, need to be provided bycompiler-builtins. - Native subsystem applications use a different entrypoint,
NtProcessStartup, with a signature differing frommainCRTStartup's. - Win32 DLLs cannot be loaded as they require the Win32 subsystem, which leaves ntdll as the only system library that can be used. This means networking is unsupported, as it is implemented within the Win32 WinSock library in terms of undocumented direct interaction with the Ancillary Function Driver (the very same used by mio). It also means that the std implementation for that target will need to leverage the NT functions directly in the places where it isn't already doing that. These days, a good chunk of ntdll.dll is documented, with some undocumented functions being shipped as part of windows-sys, which I consider to be good enough for a Tier 3 target.
Target Tier Policy
A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target.(The mechanism to track and CC such developers may evolve over time.)
I will be the designated maintainer for that target.
Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.
Ack. I believe -msvc is the correct target env for this target, as MSVC can generate code for it.
Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.
Ack. This is a variation of the already existing x86_64-pc-windows-msvc target.
Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
Ack.
Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.
Ack. The target will support core, alloc and std, with networking unsupported as explained above.
The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.
Ack.
Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via @) to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.
As far as I can tell, this new target won't be any more of a burden than our existing Windows support; the areas where it needs a separate implementation will be treated as such, similarly to how platform-specific support for different targets is separated.
Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
Ack.
Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)
The LLVM support for Windows already meets those criteria.
Mentors or Reviewers
I intend to implement support for this target.
Process
The main points of the Major Change Process are as follows:
- File an issue describing the proposal.
- A compiler team member who is knowledgeable in the area can second by writing
@rustbot secondor kickoff a team FCP with@rfcbot fcp $RESOLUTION.- Refer to Proposals, Approvals and Stabilization docs for when a second is sufficient, or when a full team FCP is required.
- Once an MCP is seconded, the Final Comment Period begins.
- Final Comment Period lasts for 10 days after all outstanding concerns are solved.
- Outstanding concerns will block the Final Comment Period from finishing. Once all concerns are resolved, the 10 day countdown is restarted.
- If no concerns are raised after 10 days since the resolution of the last outstanding concern, the MCP is considered approved.
You can read more about Major Change Proposals on forge.