Skip to content

Commit

Permalink
ANDROID: AArch64: Change default max-page-size from 4k to 16k (#70251)
Browse files Browse the repository at this point in the history
File size increase were found negligible from sparseness and zero
block compression in f2fs and ext4 (supported filesystems for
Android's userdata partition).

Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Co-authored-by: Kalesh Singh <kaleshsingh@google.com>
  • Loading branch information
Kalesh-Singh and Kalesh Singh committed Feb 29, 2024
1 parent be8f987 commit 856ce49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
17 changes: 12 additions & 5 deletions clang/lib/Driver/ToolChains/Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,18 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
ExtraOpts.push_back("relro");
}

// 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");
// Note, lld from 11 onwards default max-page-size to 65536 for both ARM and
// AArch64.
if (Triple.isAndroid()) {
if (Triple.isARM()) {
// Android ARM uses max-page-size=4096 to reduce VMA usage.
ExtraOpts.push_back("-z");
ExtraOpts.push_back("max-page-size=4096");
} else if (Triple.isAArch64()) {
// Android AArch64 uses max-page-size=16384 to support 4k/16k page sizes.
ExtraOpts.push_back("-z");
ExtraOpts.push_back("max-page-size=16384");
}
}

if (GCCInstallation.getParentLibPath().contains("opt/rh/"))
Expand Down
3 changes: 2 additions & 1 deletion clang/test/Driver/android-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
//
// RUN: %clang -target aarch64-none-linux-android \
// RUN: -### -v %s 2> %t
// RUN: FileCheck -check-prefix=MAX-PAGE-SIZE < %t %s
// RUN: FileCheck -check-prefix=MAX-PAGE-SIZE-AARCH64 < %t %s
//
// GENERIC-ARM: --fix-cortex-a53-843419
// CORTEX-A53: --fix-cortex-a53-843419
// CORTEX-A57-NOT: --fix-cortex-a53-843419
// MAX-PAGE-SIZE: "-z" "max-page-size=4096"
// MAX-PAGE-SIZE-AARCH64: "-z" "max-page-size=16384"

0 comments on commit 856ce49

Please sign in to comment.