Auto merge of #78959 - petrochenkov:likeuefi, r=nagisa
rustc_target: Mark UEFI targets as `is_like_windows`/`is_like_msvc` And document what `is_like_windows` and `is_like_msvc` actually mean in more detail. Addresses FIXMEs left from https://github.com/rust-lang/rust/pull/71030. r? `@nagisa`
This commit is contained in:
commit
66c1309446
@ -925,9 +925,7 @@ unsafe fn embed_bitcode(
|
||||
|| cgcx.opts.target_triple.triple().starts_with("asmjs")
|
||||
{
|
||||
// nothing to do here
|
||||
} else if cgcx.opts.target_triple.triple().contains("windows")
|
||||
|| cgcx.opts.target_triple.triple().contains("uefi")
|
||||
{
|
||||
} else if cgcx.is_pe_coff {
|
||||
let asm = "
|
||||
.section .llvmbc,\"n\"
|
||||
.section .llvmcmd,\"n\"
|
||||
|
@ -307,6 +307,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
|
||||
pub allocator_module_config: Arc<ModuleConfig>,
|
||||
pub tm_factory: TargetMachineFactory<B>,
|
||||
pub msvc_imps_needed: bool,
|
||||
pub is_pe_coff: bool,
|
||||
pub target_pointer_width: u32,
|
||||
pub target_arch: String,
|
||||
pub debuginfo: config::DebugInfo,
|
||||
@ -1022,6 +1023,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||
tm_factory: TargetMachineFactory(backend.target_machine_factory(tcx.sess, ol)),
|
||||
total_cgus,
|
||||
msvc_imps_needed: msvc_imps_needed(tcx),
|
||||
is_pe_coff: tcx.sess.target.is_like_windows,
|
||||
target_pointer_width: tcx.sess.target.pointer_width,
|
||||
target_arch: tcx.sess.target.arch.clone(),
|
||||
debuginfo: tcx.sess.opts.debuginfo,
|
||||
|
@ -822,10 +822,23 @@ pub struct TargetOptions {
|
||||
/// Only useful for compiling against Illumos/Solaris,
|
||||
/// as they have a different set of linker flags. Defaults to false.
|
||||
pub is_like_solaris: bool,
|
||||
/// Whether the target toolchain is like Windows'. Only useful for compiling against Windows,
|
||||
/// only really used for figuring out how to find libraries, since Windows uses its own
|
||||
/// library naming convention. Defaults to false.
|
||||
/// Whether the target is like Windows.
|
||||
/// This is a combination of several more specific properties represented as a single flag:
|
||||
/// - The target uses a Windows ABI,
|
||||
/// - uses PE/COFF as a format for object code,
|
||||
/// - uses Windows-style dllexport/dllimport for shared libraries,
|
||||
/// - uses import libraries and .def files for symbol exports,
|
||||
/// - executables support setting a subsystem.
|
||||
pub is_like_windows: bool,
|
||||
/// Whether the target is like MSVC.
|
||||
/// This is a combination of several more specific properties represented as a single flag:
|
||||
/// - The target has all the properties from `is_like_windows`
|
||||
/// (for in-tree targets "is_like_msvc ⇒ is_like_windows" is ensured by a unit test),
|
||||
/// - has some MSVC-specific Windows ABI properties,
|
||||
/// - uses a link.exe-like linker,
|
||||
/// - uses CodeView/PDB for debuginfo and natvis for its visualization,
|
||||
/// - uses SEH-based unwinding,
|
||||
/// - supports control flow guard mechanism.
|
||||
pub is_like_msvc: bool,
|
||||
/// Whether the target toolchain is like Emscripten's. Only useful for compiling with
|
||||
/// Emscripten toolchain.
|
||||
|
@ -8,6 +8,7 @@ pub(super) fn test_target(target: Target) {
|
||||
|
||||
impl Target {
|
||||
fn check_consistency(&self) {
|
||||
assert!(self.is_like_windows || !self.is_like_msvc);
|
||||
// Check that LLD with the given flavor is treated identically to the linker it emulates.
|
||||
// If your target really needs to deviate from the rules below, except it and document the
|
||||
// reasons.
|
||||
@ -16,6 +17,7 @@ impl Target {
|
||||
|| self.linker_flavor == LinkerFlavor::Lld(LldFlavor::Link),
|
||||
self.lld_flavor == LldFlavor::Link,
|
||||
);
|
||||
assert_eq!(self.is_like_msvc, self.lld_flavor == LldFlavor::Link);
|
||||
for args in &[
|
||||
&self.pre_link_args,
|
||||
&self.late_link_args,
|
||||
|
@ -46,15 +46,6 @@ pub fn opts() -> TargetOptions {
|
||||
stack_probes: true,
|
||||
singlethread: true,
|
||||
linker: Some("rust-lld".to_string()),
|
||||
// FIXME: This should likely be `true` inherited from `msvc_base`
|
||||
// because UEFI follows Windows ABI and uses PE/COFF.
|
||||
// The `false` is probably causing ABI bugs right now.
|
||||
is_like_windows: false,
|
||||
// FIXME: This should likely be `true` inherited from `msvc_base`
|
||||
// because UEFI follows Windows ABI and uses PE/COFF.
|
||||
// The `false` is probably causing ABI bugs right now.
|
||||
is_like_msvc: false,
|
||||
|
||||
..base
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user