Skip to content

Commit 1e65a37

Browse files
Rollup merge of rust-lang#155453 - ferrocene:a53-linux-fix-errata, r=wesleywiser
apply Cortex-A53 errata 843419 mitigation to the AArch64 Linux targets as it's done for other AArch64 targets although the linker (GCC) _may_ be configured to apply the fix by default it's preferred to have rustc pass the flag to the linker to ensure the mitigation is always applied for example, the Arm GNU toolchain does _not_ enable the errata mitigation by default (checked version: 13.3.Rel1) see rust-lang#118095 for background information
2 parents 2bcacd6 + 221687a commit 1e65a37

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_gnu.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::spec::{
2-
Arch, FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base,
2+
Arch, Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target,
3+
TargetMetadata, TargetOptions, base,
34
};
45

56
pub(crate) fn target() -> Target {
@@ -15,6 +16,11 @@ pub(crate) fn target() -> Target {
1516
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
1617
arch: Arch::AArch64,
1718
options: TargetOptions {
19+
// Enable the Cortex-A53 errata 843419 mitigation by default
20+
pre_link_args: TargetOptions::link_args(
21+
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
22+
&["-mfix-cortex-a53-843419"],
23+
),
1824
features: "+v8a,+outline-atomics".into(),
1925
// the AAPCS64 expects use of non-leaf frame pointers per
2026
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer

compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_musl.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::spec::{
2-
Arch, FramePointer, SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base,
2+
Arch, Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target,
3+
TargetMetadata, TargetOptions, base,
34
};
45

56
pub(crate) fn target() -> Target {
@@ -29,6 +30,11 @@ pub(crate) fn target() -> Target {
2930
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
3031
arch: Arch::AArch64,
3132
options: TargetOptions {
33+
// Enable the Cortex-A53 errata 843419 mitigation by default
34+
pre_link_args: TargetOptions::link_args(
35+
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
36+
&["-mfix-cortex-a53-843419"],
37+
),
3238
// the AAPCS64 expects use of non-leaf frame pointers per
3339
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
3440
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not

0 commit comments

Comments
 (0)