[clang] 969b91a - [Driver] Default arm-linux-androideabi to -z max-page-size=4096
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 8 12:05:50 PDT 2020
Author: Fangrui Song
Date: 2020-04-08T12:05:28-07:00
New Revision: 969b91af732d83870bb17e1e0ca0202fe4b89965
URL: https://github.com/llvm/llvm-project/commit/969b91af732d83870bb17e1e0ca0202fe4b89965
DIFF: https://github.com/llvm/llvm-project/commit/969b91af732d83870bb17e1e0ca0202fe4b89965.diff
LOG: [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
Added:
clang/test/Driver/android-link.cpp
Modified:
clang/lib/Driver/ToolChains/Linux.cpp
Removed:
clang/test/Driver/android-aarch64-link.cpp
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 3d76e6801149..788b089351d4 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -253,10 +253,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
ExtraOpts.push_back("relro");
}
- // The lld default page size is too large for Aarch64, which produces much
- // larger .so files and images for arm64 device targets. Use 4KB page size
- // for Android arm64 targets instead.
- if (Triple.isAArch64() && Triple.isAndroid()) {
+ // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
+ // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
+ if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
ExtraOpts.push_back("-z");
ExtraOpts.push_back("max-page-size=4096");
}
diff --git a/clang/test/Driver/android-aarch64-link.cpp b/clang/test/Driver/android-link.cpp
similarity index 75%
rename from clang/test/Driver/android-aarch64-link.cpp
rename to clang/test/Driver/android-link.cpp
index 051bcd57b17b..fa9cbc5d0c7a 100644
--- a/clang/test/Driver/android-aarch64-link.cpp
+++ b/clang/test/Driver/android-link.cpp
@@ -1,4 +1,7 @@
-// Check that we automatically add relevant linker flags for Android aarch64.
+// Check that we add relevant linker flags for Android ARM/AArch64.
+
+// RUN: %clang -### -target arm-linux-androideabi %s 2>&1 | \
+// RUN: FileCheck --check-prefix=MAX-PAGE-SIZE %s
// RUN: %clang -target aarch64-none-linux-android \
// RUN: -### -v %s 2> %t
@@ -19,4 +22,4 @@
// GENERIC-ARM: --fix-cortex-a53-843419
// CORTEX-A53: --fix-cortex-a53-843419
// CORTEX-A57-NOT: --fix-cortex-a53-843419
-// MAX-PAGE-SIZE: max-page-size=4096
+// MAX-PAGE-SIZE: "-z" "max-page-size=4096"
More information about the cfe-commits
mailing list