Skip to content

ANDROID: x86_64: Set default max-page-size to 16kB #87413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
// 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()) {
} else if (Triple.isAArch64() || Triple.getArch() == llvm::Triple::x86_64) {
// Android AArch64 uses max-page-size=16384 to support 4k/16k page sizes.
// Android emulates a 16k page size for app testing on x86_64 machines.
ExtraOpts.push_back("-z");
ExtraOpts.push_back("max-page-size=16384");
}
Expand Down
38 changes: 24 additions & 14 deletions clang/test/Driver/android-link.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
// Check that we add relevant linker flags for Android ARM/AArch64.
// Check that we add relevant linker flags for Android ARM/AArch64/i386/x86_64.

// RUN: %clang -### -target arm-linux-androideabi %s 2>&1 | \
// RUN: FileCheck --check-prefix=MAX-PAGE-SIZE %s
// RUN: %clang -### --target=arm-linux-androideabi %s 2>&1 | \
// RUN: FileCheck --check-prefix=MAX-PAGE-SIZE-4KB %s

// RUN: %clang -target aarch64-none-linux-android \
// RUN: %clang --target=aarch64-none-linux-android \
// RUN: -### -v %s 2> %t
// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
//
// RUN: %clang -target aarch64-none-linux-android \

// RUN: %clang --target=aarch64-none-linux-android \
// RUN: -mcpu=cortex-a53 -### -v %s 2> %t
// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
//
// RUN: %clang -target aarch64-none-linux-android \

// RUN: %clang --target=aarch64-none-linux-android \
// RUN: -mcpu=cortex-a57 -### -v %s 2> %t
// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
//
// RUN: %clang -target aarch64-none-linux-android \

// RUN: %clang --target=aarch64-none-linux-android \
// RUN: -### -v %s 2> %t
// RUN: FileCheck -check-prefix=MAX-PAGE-SIZE-AARCH64 < %t %s
//
// RUN: FileCheck -check-prefix=MAX-PAGE-SIZE-16KB < %t %s

// RUN: %clang -### --target=i386-none-linux-android %s 2>&1 | \
// RUN: FileCheck --check-prefix=NO-MAX-PAGE-SIZE-16KB %s

// RUN: %clang -### --target=x86_64-none-linux-gnu %s 2>&1 | \
// RUN: FileCheck --check-prefix=NO-MAX-PAGE-SIZE-16KB %s

// RUN: %clang -### --target=x86_64-none-linux-android %s 2>&1 | \
// RUN: FileCheck --check-prefix=MAX-PAGE-SIZE-16KB %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"
// MAX-PAGE-SIZE-4KB: "-z" "max-page-size=4096"
// MAX-PAGE-SIZE-16KB: "-z" "max-page-size=16384"
// NO-MAX-PAGE-SIZE-16KB-NOT: "-z" "max-page-size=16384"