Skip to content

Commit

Permalink
[Driver] Pass --fix-cortex-a53-843419 automatically on Fuchsia
Browse files Browse the repository at this point in the history
When targeting cortex-a53, set this linker flag rather than relying
on the toolchain users to do it in their build.

Differential Revision: https://reviews.llvm.org/D114023
  • Loading branch information
petrhosek committed May 6, 2022
1 parent 6a9c102 commit 7f0e741
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clang/lib/Driver/ToolChains/Fuchsia.cpp
Expand Up @@ -37,6 +37,8 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
static_cast<const toolchains::Fuchsia &>(getToolChain());
const Driver &D = ToolChain.getDriver();

const llvm::Triple &Triple = ToolChain.getEffectiveTriple();

ArgStringList CmdArgs;

// Silence warning for "clang -g foo.o -o foo"
Expand Down Expand Up @@ -84,6 +86,12 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("--hash-style=gnu");
}

if (ToolChain.getArch() == llvm::Triple::aarch64) {
std::string CPU = getCPUName(D, Args, Triple);
if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
CmdArgs.push_back("--fix-cortex-a53-843419");
}

CmdArgs.push_back("--eh-frame-hdr");

if (Args.hasArg(options::OPT_static))
Expand Down
1 change: 1 addition & 0 deletions clang/test/Driver/fuchsia.c
Expand Up @@ -41,6 +41,7 @@
// CHECK: "-pie"
// CHECK: "--build-id"
// CHECK: "--hash-style=gnu"
// CHECK-AARCH64: "--fix-cortex-a53-843419"
// CHECK: "-dynamic-linker" "ld.so.1"
// CHECK: Scrt1.o
// CHECK-NOT: crti.o
Expand Down

0 comments on commit 7f0e741

Please sign in to comment.