Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -5147,10 +5147,16 @@ def mno_fix_cortex_a72_aes_1655431 : Flag<["-"], "mno-fix-cortex-a72-aes-1655431
Alias<mno_fix_cortex_a57_aes_1742098>;
def mfix_cortex_a53_835769 : Flag<["-"], "mfix-cortex-a53-835769">,
Group<m_aarch64_Features_Group>,
HelpText<"Workaround Cortex-A53 erratum 835769 (AArch64 only)">;
HelpText<"Work around Cortex-A53 erratum 835769 (AArch64 only)">;
def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">,
Group<m_aarch64_Features_Group>,
HelpText<"Don't workaround Cortex-A53 erratum 835769 (AArch64 only)">;
HelpText<"Don't work around Cortex-A53 erratum 835769 (AArch64 only)">;
def mfix_cortex_a53_843419 : Flag<["-"], "mfix-cortex-a53-843419">,
Group<m_aarch64_Features_Group>,
HelpText<"Work around Cortex-A53 erratum 843419 (AArch64 only)">;
def mno_fix_cortex_a53_843419 : Flag<["-"], "mno-fix-cortex-a53-843419">,
Group<m_aarch64_Features_Group>,
HelpText<"Don't work around Cortex-A53 erratum 843419 (AArch64 only)">;
def mmark_bti_property : Flag<["-"], "mmark-bti-property">,
Group<m_aarch64_Features_Group>,
HelpText<"Add .note.gnu.property with BTI to assembly files (AArch64 only)">;
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Driver/ToolChains/Fuchsia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("--execute-only");

std::string CPU = getCPUName(D, Args, Triple);
if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
if (Args.hasFlag(options::OPT_mfix_cortex_a53_843419,
options::OPT_mno_fix_cortex_a53_843419, true) &&
Comment on lines +94 to +95
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if the option should always be honoured if it was present (with any CPU). If it isn't present then we enable it with a generic or empty or a53 CPU. But that doesn't look like how the GCC option is specified in the docs.

It should ideally be automatically disabled if the archecture is armv8.1-a or later, as that code cannot run on cortex-a53. That is probably a separate issue though, and would equally apply to mfix_cortex_a53_835769 too.

Copy link
Collaborator Author

@bryanpkc bryanpkc Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GCC docs say that these options are "ignored if an architecture or cpu is specified on the command line which does not need the workaround". So I think what we have in this PR mostly matches that description.

I can submit a new PR to add a condition to check whether the architecture is armv8.1-a or later.

(CPU.empty() || CPU == "generic" || CPU == "cortex-a53"))
CmdArgs.push_back("--fix-cortex-a53-843419");
}

Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,

// Most Android ARM64 targets should enable the linker fix for erratum
// 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
if (Arch == llvm::Triple::aarch64 && (isAndroid || isOHOSFamily)) {
if (Arch == llvm::Triple::aarch64 && (isAndroid || isOHOSFamily) &&
Args.hasFlag(options::OPT_mfix_cortex_a53_843419,
options::OPT_mno_fix_cortex_a53_843419, true)) {
std::string CPU = getCPUName(D, Args, Triple);
if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
CmdArgs.push_back("--fix-cortex-a53-843419");
Expand Down
12 changes: 12 additions & 0 deletions clang/test/Driver/android-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s

// RUN: %clang --target=aarch64-none-linux-android \
// RUN: -mno-fix-cortex-a53-843419 \
// RUN: -### -v %s 2> %t
// RUN: FileCheck -check-prefix=OVERRIDDEN < %t %s
//
// RUN: %clang -target aarch64-none-linux-android \
// RUN: -mno-fix-cortex-a53-843419 -mfix-cortex-a53-843419 \
// RUN: -### -v %s 2> %t
// RUN: FileCheck -check-prefix=OVERRIDDEN2 < %t %s
//
// RUN: %clang -target aarch64-none-linux-android \
// RUN: -### -v %s 2> %t
// RUN: FileCheck -check-prefix=MAX-PAGE-SIZE-16KB < %t %s

Expand All @@ -31,6 +41,8 @@
// GENERIC-ARM: --fix-cortex-a53-843419
// CORTEX-A53: --fix-cortex-a53-843419
// CORTEX-A57-NOT: --fix-cortex-a53-843419
// OVERRIDDEN-NOT: --fix-cortex-a53-843419
// OVERRIDDEN2: --fix-cortex-a53-843419
// MAX-PAGE-SIZE-4KB: "-z" "max-page-size=4096"
// MAX-PAGE-SIZE-16KB: "-z" "max-page-size=16384"
// NO-MAX-PAGE-SIZE-16KB-NOT: "-z" "max-page-size=16384"
Loading