-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
explicitly set float ABI for all ARM targets #134932
Changes from all commits
fff026c
a0dbb37
a51fefc
c3189c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1085,6 +1085,35 @@ impl ToJson for CodeModel { | |
} | ||
} | ||
|
||
/// The float ABI setting to be configured in the LLVM target machine. | ||
#[derive(Clone, Copy, PartialEq, Hash, Debug)] | ||
pub enum FloatAbi { | ||
Soft, | ||
Hard, | ||
Comment on lines
+1091
to
+1092
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some documentation about what each variant mean would be great ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what to say here other than "use softfloat ABI" vs "use hardfloat ABI", which seems a bit pointless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could hypothetically say something about what "soft float" and "hard float" mean, but I think that is something we should consider as a more general topic. |
||
} | ||
|
||
impl FromStr for FloatAbi { | ||
type Err = (); | ||
|
||
fn from_str(s: &str) -> Result<FloatAbi, ()> { | ||
Ok(match s { | ||
"soft" => FloatAbi::Soft, | ||
"hard" => FloatAbi::Hard, | ||
_ => return Err(()), | ||
}) | ||
} | ||
} | ||
|
||
impl ToJson for FloatAbi { | ||
fn to_json(&self) -> Json { | ||
match *self { | ||
FloatAbi::Soft => "soft", | ||
FloatAbi::Hard => "hard", | ||
} | ||
.to_json() | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy, PartialEq, Hash, Debug)] | ||
pub enum TlsModel { | ||
GeneralDynamic, | ||
|
@@ -2150,6 +2179,8 @@ pub struct TargetOptions { | |
pub env: StaticCow<str>, | ||
/// ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, `"eabi"` | ||
/// or `"eabihf"`. Defaults to "". | ||
/// This field is *not* forwarded directly to LLVM; its primary purpose is `cfg(target_abi)`. | ||
/// However, parts of the backend do check this field for specific values to enable special behavior. | ||
pub abi: StaticCow<str>, | ||
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown". | ||
pub vendor: StaticCow<str>, | ||
|
@@ -2446,8 +2477,17 @@ pub struct TargetOptions { | |
pub llvm_mcount_intrinsic: Option<StaticCow<str>>, | ||
|
||
/// LLVM ABI name, corresponds to the '-mabi' parameter available in multilib C compilers | ||
/// and the `-target-abi` flag in llc. In the LLVM API this is `MCOptions.ABIName`. | ||
pub llvm_abiname: StaticCow<str>, | ||
|
||
/// Control the float ABI to use, for architectures that support it. The only architecture we | ||
/// currently use this for is ARM. Corresponds to the `-float-abi` flag in llc. In the LLVM API | ||
/// this is `FloatABIType`. (clang's `-mfloat-abi` is similar but more complicated since it | ||
/// can also affect the `soft-float` target feature.) | ||
/// | ||
/// If not provided, LLVM will infer the float ABI from the target triple (`llvm_target`). | ||
pub llvm_floatabi: Option<FloatAbi>, | ||
|
||
/// Whether or not RelaxElfRelocation flag will be passed to the linker | ||
pub relax_elf_relocations: bool, | ||
|
||
|
@@ -2719,6 +2759,7 @@ impl Default for TargetOptions { | |
mcount: "mcount".into(), | ||
llvm_mcount_intrinsic: None, | ||
llvm_abiname: "".into(), | ||
llvm_floatabi: None, | ||
relax_elf_relocations: false, | ||
llvm_args: cvs![], | ||
use_ctors_section: false, | ||
|
@@ -3153,7 +3194,8 @@ impl Target { | |
); | ||
} | ||
|
||
// Check that RISC-V targets always specify which ABI they use. | ||
// Check that RISC-V targets always specify which ABI they use, | ||
// and that ARM targets specify their float ABI. | ||
match &*self.arch { | ||
"riscv32" => { | ||
check_matches!( | ||
|
@@ -3170,6 +3212,9 @@ impl Target { | |
"invalid RISC-V ABI name" | ||
); | ||
} | ||
"arm" => { | ||
check!(self.llvm_floatabi.is_some(), "ARM targets must specify their float ABI",) | ||
} | ||
_ => {} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume all the Apple targets use a hardfloat ABI? This is about armv7s_apple_ios.rs and armv7k_apple_watchos.rs. Both of these set
+neon
in their target features. LLVM switches to hardfloats for(TargetTriple.isOSBinFormatMachO() && TargetTriple.getSubArch() == Triple::ARMSubArch_v7em)
, not sure if that applies here.Cc @deg4uss3r @madsmtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is my understanding, yeah, and matches what Clang reports when you try to use a different float ABI: