]> granicus.if.org Git - clang/commitdiff
set default max-page-size to 4KB in lld for Android Aarch64
authorZhizhou Yang <zhizhouyang@gmail.com>
Thu, 29 Nov 2018 18:52:22 +0000 (18:52 +0000)
committerZhizhou Yang <zhizhouyang@gmail.com>
Thu, 29 Nov 2018 18:52:22 +0000 (18:52 +0000)
Summary:
This patch passes an option '-z max-page-size=4096' to lld through clang driver.

This is for Android on Aarch64 target.

The lld default page size is too large for Aarch64, which produces larger .so files and images for arm64 device targets.
In this patch we set default page size to 4KB for Android Aarch64 targets instead.

Reviewers: srhines, danalbert, ruiu, chh, peter.smith

Reviewed By: srhines

Subscribers: javed.absar, kristof.beyls, cfe-commits, george.burgess.iv, llozano

Differential Revision: https://reviews.llvm.org/D55029

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347897 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/Linux.cpp
test/Driver/android-aarch64-link.cpp

index 79deb04f97503dfa5ce3b93a8a9451f83b81e134..65ab9b2daf549584e7d35f42183d02808fae825d 100644 (file)
@@ -247,6 +247,14 @@ 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()) {
+    ExtraOpts.push_back("-z");
+    ExtraOpts.push_back("max-page-size=4096");
+  }
+
   if (GCCInstallation.getParentLibPath().find("opt/rh/devtoolset") !=
       StringRef::npos)
     // With devtoolset on RHEL, we want to add a bin directory that is relative
index 2c4cfb9898ebc15207358ecc8db50fb1bb8ce44f..051bcd57b17b6e7ec09b868b92e5b0a169570db5 100644 (file)
 // RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
 // RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
 //
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=MAX-PAGE-SIZE < %t %s
+//
 // 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