Skip to content

Commit d4e2c0b

Browse files
authored
[Driver] Add options to control workaround for Cortex-A53 Erratum 843419 (#143915)
Implement the -mfix-cortex-a53-843419 and -mno-fix-cortex-a53-843419 options, which have been introduced to GCC to allow the user to control the workaround for the erratum. If the option is enabled (which is the default, unchanged by this patch), Clang passes --fix-cortex-a53-843419 to the linker when it cannot ensure that the target is not a Cortex A53, otherwise it doesn't. See https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-mfix-cortex-a53-843419 for information on the GCC options.
1 parent 6e8cf9c commit d4e2c0b

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5150,10 +5150,16 @@ def mno_fix_cortex_a72_aes_1655431 : Flag<["-"], "mno-fix-cortex-a72-aes-1655431
51505150
Alias<mno_fix_cortex_a57_aes_1742098>;
51515151
def mfix_cortex_a53_835769 : Flag<["-"], "mfix-cortex-a53-835769">,
51525152
Group<m_aarch64_Features_Group>,
5153-
HelpText<"Workaround Cortex-A53 erratum 835769 (AArch64 only)">;
5153+
HelpText<"Work around Cortex-A53 erratum 835769 (AArch64 only)">;
51545154
def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">,
51555155
Group<m_aarch64_Features_Group>,
5156-
HelpText<"Don't workaround Cortex-A53 erratum 835769 (AArch64 only)">;
5156+
HelpText<"Don't work around Cortex-A53 erratum 835769 (AArch64 only)">;
5157+
def mfix_cortex_a53_843419 : Flag<["-"], "mfix-cortex-a53-843419">,
5158+
Group<m_aarch64_Features_Group>,
5159+
HelpText<"Work around Cortex-A53 erratum 843419 (AArch64 only)">;
5160+
def mno_fix_cortex_a53_843419 : Flag<["-"], "mno-fix-cortex-a53-843419">,
5161+
Group<m_aarch64_Features_Group>,
5162+
HelpText<"Don't work around Cortex-A53 erratum 843419 (AArch64 only)">;
51575163
def mmark_bti_property : Flag<["-"], "mmark-bti-property">,
51585164
Group<m_aarch64_Features_Group>,
51595165
HelpText<"Add .note.gnu.property with BTI to assembly files (AArch64 only)">;

clang/lib/Driver/ToolChains/Fuchsia.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
9191
CmdArgs.push_back("--execute-only");
9292

9393
std::string CPU = getCPUName(D, Args, Triple);
94-
if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
94+
if (Args.hasFlag(options::OPT_mfix_cortex_a53_843419,
95+
options::OPT_mno_fix_cortex_a53_843419, true) &&
96+
(CPU.empty() || CPU == "generic" || CPU == "cortex-a53"))
9597
CmdArgs.push_back("--fix-cortex-a53-843419");
9698
}
9799

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
402402

403403
// Most Android ARM64 targets should enable the linker fix for erratum
404404
// 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
405-
if (Arch == llvm::Triple::aarch64 && (isAndroid || isOHOSFamily)) {
405+
if (Arch == llvm::Triple::aarch64 && (isAndroid || isOHOSFamily) &&
406+
Args.hasFlag(options::OPT_mfix_cortex_a53_843419,
407+
options::OPT_mno_fix_cortex_a53_843419, true)) {
406408
std::string CPU = getCPUName(D, Args, Triple);
407409
if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
408410
CmdArgs.push_back("--fix-cortex-a53-843419");

clang/test/Driver/android-link.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
1717

1818
// RUN: %clang --target=aarch64-none-linux-android \
19+
// RUN: -mno-fix-cortex-a53-843419 \
20+
// RUN: -### -v %s 2> %t
21+
// RUN: FileCheck -check-prefix=OVERRIDDEN < %t %s
22+
//
23+
// RUN: %clang -target aarch64-none-linux-android \
24+
// RUN: -mno-fix-cortex-a53-843419 -mfix-cortex-a53-843419 \
25+
// RUN: -### -v %s 2> %t
26+
// RUN: FileCheck -check-prefix=OVERRIDDEN2 < %t %s
27+
//
28+
// RUN: %clang -target aarch64-none-linux-android \
1929
// RUN: -### -v %s 2> %t
2030
// RUN: FileCheck -check-prefix=MAX-PAGE-SIZE-16KB < %t %s
2131

@@ -31,6 +41,8 @@
3141
// GENERIC-ARM: --fix-cortex-a53-843419
3242
// CORTEX-A53: --fix-cortex-a53-843419
3343
// CORTEX-A57-NOT: --fix-cortex-a53-843419
44+
// OVERRIDDEN-NOT: --fix-cortex-a53-843419
45+
// OVERRIDDEN2: --fix-cortex-a53-843419
3446
// MAX-PAGE-SIZE-4KB: "-z" "max-page-size=4096"
3547
// MAX-PAGE-SIZE-16KB: "-z" "max-page-size=16384"
3648
// NO-MAX-PAGE-SIZE-16KB-NOT: "-z" "max-page-size=16384"

0 commit comments

Comments
 (0)