-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New cfg key: target_binary_format #152586
Copy link
Copy link
Open
Labels
A-binary-formatsArea: binary formats (e.g. ELF, XCOFF, etc.)Area: binary formats (e.g. ELF, XCOFF, etc.)A-cfgArea: `cfg` conditional compilationArea: `cfg` conditional compilationA-targetsArea: Concerning the implications of different compiler targetsArea: Concerning the implications of different compiler targetsC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCI-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-binary-formatsArea: binary formats (e.g. ELF, XCOFF, etc.)Area: binary formats (e.g. ELF, XCOFF, etc.)A-cfgArea: `cfg` conditional compilationArea: `cfg` conditional compilationA-targetsArea: Concerning the implications of different compiler targetsArea: Concerning the implications of different compiler targetsC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCI-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
The proposal is to experimentally add a new
cfgkey to the language,target_binary_format(or similar, e.g.target_bin_fmt), for use by things likewasm32-none-componenttargets.Code for such targets wants to
cfgbased on the object or binary format in use. Based on the current state of discussion about. the target maintainers don't feel comfortable forcing this information intotarget_env, astarget_envdoes not contain this information for any other target.This would also simplify certain existing
cfgcombinations that have to do annoying forms of reasoning to arrive at the answer to questions like e.g. "so, is this a PE32+ binary (whether executable or dll)?" The answer is unfortunately not as simple as "is this Windows?" due to the existence of e.g.target_os = "cygwin"andtarget_os = "uefi".@rust-lang/lang Do I need a sponsor for this or something?
We have some of this information available in our target definitions, for reference. The proposal is to expose some already-known-to-the-compiler information, with some minor expansions on such as we will upgrade from only knowing about linkable intermediates to also knowing about linked binary formats:
rust/compiler/rustc_target/src/spec/mod.rs
Lines 2370 to 2371 in d7daac0
Object Format By Type and Loader/OS
Unresolved Questions
target_exe_formatandtarget_dll_format? All major binary formats I'm aware of define both their executable and dynamic library formats as variations on the same object format, but "major" and "I'm aware of" are doing a lot of lifting there. It might be fine to simply say something liketarget_bin_formatand add an additional key fortarget_dll_formatlater if we find an exception.target_o_format? It seems unlikely to me personally (@workingjubilee), as while I wonder about the need to future proof against unexpected target variation, this primarily is about knowledge of the binary that code will actually execute in. However, as Amanieu noted2, arguably it is "more principled" to reason based purely on object format.See also
wasm32-componenttarget compiler-team#948Footnotes
https://github.com/rust-lang/rust/issues/152586#issuecomment-3961167536 ↩
https://github.com/rust-lang/rust/issues/152586#issuecomment-3967411885 ↩