Skip to content

Commit 9dcd232

Browse files
committed
[clang][driver][NFC] Call IsARMBigEndain function only for isARM and isThumb.
IsARMBIgEndian function returns true only if: 1. The triples are either arm or thumb and the commandline has the option -mbig-endian 2. The triples are either armeb or thumbeb. Missing the checking of arm or thumb triples in the first case pass through the --be8 endian flag to linker For AArch64 as well which is not expected. This is the regression happened from the previous patch https://reviews.llvm.org/D154786. It is better to refactor to only call IsARMBigEndian for isARM and isthumb satisfying conditions which keeps ARM and AArch64 separate. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D155808
1 parent 4eff7fa commit 9dcd232

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,13 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
443443

444444
CmdArgs.push_back("-Bstatic");
445445

446-
if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) {
446+
if (Triple.isARM() || Triple.isThumb()) {
447447
bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
448448
if (IsBigEndian)
449449
arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
450-
IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be;
451450
CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
451+
} else if (Triple.isAArch64()) {
452+
CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
452453
}
453454

454455
Args.AddAllArgs(CmdArgs,

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,13 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
424424
if (Args.hasArg(options::OPT_s))
425425
CmdArgs.push_back("-s");
426426

427-
if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) {
427+
if (Triple.isARM() || Triple.isThumb()) {
428428
bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
429429
if (IsBigEndian)
430430
arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
431-
IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be;
432431
CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
432+
} else if (Triple.isAArch64()) {
433+
CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
433434
}
434435

435436
// Most Android ARM64 targets should enable the linker fix for erratum

0 commit comments

Comments
 (0)