Skip to content

Commit 969b91a

Browse files
committed
[Driver] Default arm-linux-androideabi to -z max-page-size=4096
Similar to D55029. The requirement arises when discussing increasing default max-page-size for lld ARM (D77330). For the record, the default max-page-size on the 3 commonly used linkers: * GNU ld since 2014 (https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=7572ca8989ead4c3425a1500bc241eaaeffa2c89) defaults to 65536 * GNU gold remains 4096 * lld<=10 uses 4096. lld from 11 onwards will use 65536 (D77330) Reviewed By: srhines, thieta Differential Revision: https://reviews.llvm.org/D77746
1 parent 82bec93 commit 969b91a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
253253
ExtraOpts.push_back("relro");
254254
}
255255

256-
// The lld default page size is too large for Aarch64, which produces much
257-
// larger .so files and images for arm64 device targets. Use 4KB page size
258-
// for Android arm64 targets instead.
259-
if (Triple.isAArch64() && Triple.isAndroid()) {
256+
// Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
257+
// from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
258+
if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
260259
ExtraOpts.push_back("-z");
261260
ExtraOpts.push_back("max-page-size=4096");
262261
}

clang/test/Driver/android-aarch64-link.cpp renamed to clang/test/Driver/android-link.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// Check that we automatically add relevant linker flags for Android aarch64.
1+
// Check that we add relevant linker flags for Android ARM/AArch64.
2+
3+
// RUN: %clang -### -target arm-linux-androideabi %s 2>&1 | \
4+
// RUN: FileCheck --check-prefix=MAX-PAGE-SIZE %s
25

36
// RUN: %clang -target aarch64-none-linux-android \
47
// RUN: -### -v %s 2> %t
@@ -19,4 +22,4 @@
1922
// GENERIC-ARM: --fix-cortex-a53-843419
2023
// CORTEX-A53: --fix-cortex-a53-843419
2124
// CORTEX-A57-NOT: --fix-cortex-a53-843419
22-
// MAX-PAGE-SIZE: max-page-size=4096
25+
// MAX-PAGE-SIZE: "-z" "max-page-size=4096"

0 commit comments

Comments
 (0)