Target families for executable format #716
Labels
major-change
A proposal to make a major change to rustc
major-change-accepted
A major change proposal that was accepted
T-compiler
Add this label so rfcbot knows to poll the compiler team
Proposal
We augment the builtin targets specs with a
target_family
identifying their executable format, where appropriate. For example x86_64-unknown-linux-gnu would gettarget_family = "elf"
for ELF, aarch64-apple-darwin would gettarget_family = "mach-o"
for Mach-O, and i686-pc-windows-msvc would gettarget_family = "coff"
for COFF.Target families are defined by the Reference as "a more generic description of a target, such as the family of the operating systems or architectures that the target generally falls into. Any number of target_family key-value pairs can be set." Extrapolating this to family of operating systems or architectures or executable formats is a natural fit.
Targets are allowed to belong to any number of target families, so this feature does not interfere with targets that already have
"unix"
or"windows"
as a target family. For examplecfg(target_family = "unix")
andcfg(target_family = "elf")
might both evaluate true on the same target.Having target families for executable format is useful in the ecosystem because it supersedes the use of
target_os
as a proxy for this purpose, for example in theinventory
orlinkme
crates which deal with executable-format-specific link sections.Before:
After:
This approach based on
target_family
is friendlier to custom targets. For example the target spec for seL4 userspace components, which usestarget_os = "none"
, can just set an"elf"
target family in its target specifications and thereby pick up ELF-specific functionality in the ecosystem. Having the ecosystem conflatetarget_os = "none"
with ELF as currently most often done is unwise. Additionally,target_family
plays nicely with private / closed source operating systems compared totarget_os
. Some company with an internal target for a private OS doesn't want to push a PR to all the crates to add a case for their private ELF-basedtarget_os
for which maybe the name isn't even public.Mentors or Reviewers
@dtolnay with guidance from @nspin
Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
The text was updated successfully, but these errors were encountered: