compiler: use CanonAbi for entry_abi
makes entry_abi a lowering of the ABI string, so now it can be ```json "entry_abi": "C", "entry_abi": "win64", "entry_abi": "aapcs", ```
This commit is contained in:
@@ -3,7 +3,7 @@ use std::fmt;
|
||||
#[cfg(feature = "nightly")]
|
||||
use rustc_macros::HashStable_Generic;
|
||||
|
||||
use crate::{AbiFromStrErr, ExternAbi};
|
||||
use crate::ExternAbi;
|
||||
|
||||
/// Calling convention to determine codegen
|
||||
///
|
||||
|
||||
@@ -2,10 +2,12 @@ use std::borrow::Cow;
|
||||
use std::collections::BTreeMap;
|
||||
use std::str::FromStr;
|
||||
|
||||
use rustc_abi::ExternAbi;
|
||||
use serde_json::Value;
|
||||
|
||||
use super::{Target, TargetKind, TargetOptions, TargetWarnings};
|
||||
use crate::json::{Json, ToJson};
|
||||
use crate::spec::AbiMap;
|
||||
|
||||
impl Target {
|
||||
/// Loads a target descriptor from a JSON object.
|
||||
@@ -515,18 +517,6 @@ impl Target {
|
||||
}
|
||||
}
|
||||
} );
|
||||
($key_name:ident, Conv) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.remove(&name).and_then(|o| o.as_str().and_then(|s| {
|
||||
match super::Conv::from_str(s) {
|
||||
Ok(c) => {
|
||||
base.$key_name = c;
|
||||
Some(Ok(()))
|
||||
}
|
||||
Err(e) => Some(Err(e))
|
||||
}
|
||||
})).unwrap_or(Ok(()))
|
||||
} );
|
||||
}
|
||||
|
||||
if let Some(j) = obj.remove("target-endian") {
|
||||
@@ -546,6 +536,7 @@ impl Target {
|
||||
incorrect_type.push("frame-pointer".into())
|
||||
}
|
||||
}
|
||||
|
||||
key!(c_int_width = "target-c-int-width");
|
||||
key!(c_enum_min_bits, Option<u64>); // if None, matches c_int_width
|
||||
key!(os);
|
||||
@@ -659,9 +650,23 @@ impl Target {
|
||||
key!(supports_stack_protector, bool);
|
||||
key!(small_data_threshold_support, SmallDataThresholdSupport)?;
|
||||
key!(entry_name);
|
||||
key!(entry_abi, Conv)?;
|
||||
key!(supports_xray, bool);
|
||||
|
||||
// we're going to run `update_from_cli`, but that won't change the target's AbiMap
|
||||
// FIXME: better factor the Target definition so we enforce this on a type level
|
||||
let abi_map = AbiMap::from_target(&base);
|
||||
|
||||
if let Some(abi_str) = obj.remove("entry-abi") {
|
||||
if let Json::String(abi_str) = abi_str {
|
||||
match abi_str.parse::<ExternAbi>() {
|
||||
Ok(abi) => base.options.entry_abi = abi_map.canonize_abi(abi, false).unwrap(),
|
||||
Err(_) => return Err(format!("{abi_str} is not a valid ExternAbi")),
|
||||
}
|
||||
} else {
|
||||
incorrect_type.push("entry-abi".to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
base.update_from_cli();
|
||||
base.check_consistency(TargetKind::Json)?;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ use std::str::FromStr;
|
||||
use std::{fmt, io};
|
||||
|
||||
use rustc_abi::{
|
||||
Align, Endian, ExternAbi, Integer, Size, TargetDataLayout, TargetDataLayoutErrors,
|
||||
Align, CanonAbi, Endian, ExternAbi, Integer, Size, TargetDataLayout, TargetDataLayoutErrors,
|
||||
};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
||||
use rustc_fs_util::try_canonicalize;
|
||||
@@ -53,7 +53,6 @@ use rustc_span::{Symbol, kw, sym};
|
||||
use serde_json::Value;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::callconv::Conv;
|
||||
use crate::json::{Json, ToJson};
|
||||
use crate::spec::crt_objects::CrtObjects;
|
||||
|
||||
@@ -2657,9 +2656,9 @@ pub struct TargetOptions {
|
||||
/// Default value is "main"
|
||||
pub entry_name: StaticCow<str>,
|
||||
|
||||
/// The ABI of entry function.
|
||||
/// Default value is `Conv::C`, i.e. C call convention
|
||||
pub entry_abi: Conv,
|
||||
/// The ABI of the entry function.
|
||||
/// Default value is `CanonAbi::C`
|
||||
pub entry_abi: CanonAbi,
|
||||
|
||||
/// Whether the target supports XRay instrumentation.
|
||||
pub supports_xray: bool,
|
||||
@@ -2890,7 +2889,7 @@ impl Default for TargetOptions {
|
||||
generate_arange_section: true,
|
||||
supports_stack_protector: true,
|
||||
entry_name: "main".into(),
|
||||
entry_abi: Conv::C,
|
||||
entry_abi: CanonAbi::C,
|
||||
supports_xray: false,
|
||||
small_data_threshold_support: SmallDataThresholdSupport::DefaultForArch,
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
// The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with
|
||||
// LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features.
|
||||
|
||||
use crate::callconv::Conv;
|
||||
use rustc_abi::{CanonAbi, X86Call};
|
||||
|
||||
use crate::spec::{RustcAbi, Target, TargetMetadata, base};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
@@ -13,7 +14,7 @@ pub(crate) fn target() -> Target {
|
||||
base.cpu = "x86-64".into();
|
||||
base.plt_by_default = false;
|
||||
base.max_atomic_width = Some(64);
|
||||
base.entry_abi = Conv::X86_64Win64;
|
||||
base.entry_abi = CanonAbi::X86(X86Call::Win64);
|
||||
|
||||
// We disable MMX and SSE for now, even though UEFI allows using them. Problem is, you have to
|
||||
// enable these CPU features explicitly before their first use, otherwise their instructions
|
||||
|
||||
Reference in New Issue
Block a user