-O3 for android
This commit is contained in:
parent
6f3bf16c40
commit
76fa2c9849
2 changed files with 178 additions and 1 deletions
177
src/build/config/android/BUILD.gn
Normal file
177
src/build/config/android/BUILD.gn
Normal file
|
@ -0,0 +1,177 @@
|
|||
# Copyright 2023 The Chromium Authors and Alex313031.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//build/config/android/rules.gni")
|
||||
import("//build/config/c++/c++.gni")
|
||||
import("//build/config/compiler/compiler.gni")
|
||||
import("//build/config/sanitizers/sanitizers.gni")
|
||||
|
||||
if (current_toolchain == default_toolchain) {
|
||||
import("//build/toolchain/concurrent_links.gni")
|
||||
}
|
||||
|
||||
assert(is_android)
|
||||
|
||||
# This is included by reference in the //build/config/compiler config that
|
||||
# is applied to all targets. It is here to separate out the logic that is
|
||||
# Android-only.
|
||||
config("compiler") {
|
||||
cflags = [
|
||||
"-ffunction-sections",
|
||||
"-fno-short-enums",
|
||||
"-O3",
|
||||
]
|
||||
defines = [
|
||||
"ANDROID",
|
||||
|
||||
# The NDK has these things, but doesn't define the constants to say that it
|
||||
# does. Define them here instead.
|
||||
"HAVE_SYS_UIO_H",
|
||||
|
||||
# Forces full rebuilds on NDK rolls. To rebuild everything when NDK version
|
||||
# stays the same, increment the suffix number.
|
||||
"ANDROID_NDK_VERSION_ROLL=${android_ndk_version}_1",
|
||||
]
|
||||
|
||||
ldflags = [
|
||||
# Don't allow visible symbols from libraries that contain
|
||||
# assembly code with symbols that aren't hidden properly.
|
||||
# http://crbug.com/448386
|
||||
"-Wl,--exclude-libs=libvpx_assembly_arm.a",
|
||||
"-Wl,-O3",
|
||||
]
|
||||
|
||||
if (current_cpu == "arm64") {
|
||||
# Reduce the page size from 65536 in order to reduce binary size slightly
|
||||
# by shrinking the alignment gap between segments. This also causes all
|
||||
# segments to be mapped adjacently, which breakpad relies on.
|
||||
ldflags += [ "-Wl,-z,max-page-size=4096" ]
|
||||
}
|
||||
|
||||
if (current_cpu == "arm64") {
|
||||
if (arm_control_flow_integrity == "standard") {
|
||||
cflags += [ "-mbranch-protection=standard", "-mfloat-abi=hard", "-march=armv8-a+simd", "-mtune=generic-armv8-a+simd", "-mfpu=neon", ]
|
||||
} else if (arm_control_flow_integrity == "pac") {
|
||||
cflags += [ "-mbranch-protection=pac-ret", "-mfloat-abi=hard", "-march=armv8-a+simd", "-mtune=generic-armv8-a+simd", "-mfpu=neon", ]
|
||||
}
|
||||
}
|
||||
|
||||
if (current_cpu == "arm") {
|
||||
cflags += [ "-march=armv7-a", "-mtune=generic-armv7-a", ]
|
||||
}
|
||||
|
||||
# Instead of using an unwind lib from the toolchain,
|
||||
# buildtools/third_party/libunwind will be built and used directly.
|
||||
ldflags += [ "--unwindlib=none" ]
|
||||
|
||||
# $compile_api_level corresponds to the API level used for the sysroot path
|
||||
# calculation in //build/config/android/config.gni
|
||||
if (android_64bit_target_cpu) {
|
||||
compile_api_level = android64_ndk_api_level
|
||||
} else {
|
||||
compile_api_level = android32_ndk_api_level
|
||||
}
|
||||
|
||||
cflags += [ "--target=$android_abi_target$compile_api_level" ]
|
||||
ldflags += [ "--target=$android_abi_target$compile_api_level" ]
|
||||
|
||||
# Assign any flags set for the C compiler to asmflags so that they are sent
|
||||
# to the assembler.
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
# This is included by reference in the //build/config/compiler:runtime_library
|
||||
# config that is applied to all targets. It is here to separate out the logic
|
||||
# that is Android-only. Please see that target for advice on what should go in
|
||||
# :runtime_library vs. :compiler.
|
||||
config("runtime_library") {
|
||||
libs = []
|
||||
ldflags = []
|
||||
|
||||
# On 64-bit platforms, the only symbols provided by libandroid_support.a are
|
||||
# strto{d,f,l,ul}_l. These symbols are not used by our libc++, and newer NDKs
|
||||
# don't provide a libandroid_support.a on 64-bit platforms, so we only depend
|
||||
# on this library on 32-bit platforms.
|
||||
if (current_cpu == "arm" || current_cpu == "x86") {
|
||||
libs += [ "android_support" ]
|
||||
}
|
||||
|
||||
if (current_cpu == "arm" && arm_version == 6) {
|
||||
libs += [ "atomic" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("hide_all_but_jni_onload") {
|
||||
ldflags = [ "-Wl,--version-script=" + rebase_path(
|
||||
"//build/android/android_only_explicit_jni_exports.lst",
|
||||
root_build_dir) ]
|
||||
}
|
||||
|
||||
config("hide_all_but_jni") {
|
||||
ldflags = [ "-Wl,--version-script=" +
|
||||
rebase_path("//build/android/android_only_jni_exports.lst",
|
||||
root_build_dir) ]
|
||||
}
|
||||
|
||||
config("lld_pack_relocations") {
|
||||
ldflags = [ "-Wl,--pack-dyn-relocs=android" ]
|
||||
}
|
||||
|
||||
config("lld_relr_relocations") {
|
||||
# RELR supported API 30+, but supported 28+ with --use-android-relr-tags.
|
||||
# https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#relative-relocations-relr
|
||||
ldflags = [ "-Wl,--pack-dyn-relocs=relr,--use-android-relr-tags" ]
|
||||
}
|
||||
|
||||
config("lld_branch_target_hardening") {
|
||||
# Config opts a shared library into BTI linker hardening. This
|
||||
# is an opt-in config (rather than default-enabled) to avoid
|
||||
# interfering with the V8 CFI bots (crbug.com/1334614).
|
||||
if (current_cpu == "arm64") {
|
||||
if (arm_control_flow_integrity == "standard") {
|
||||
# Linking objects without GNU_PROPERTY_AARCH64_FEATURE_1_BTI
|
||||
# in their .gnu.note section implicitly results in the final
|
||||
# binary losing Branch Target Identification (BTI) support.
|
||||
# Issue a warning if this happens.
|
||||
ldflags = [ "-Wl,-z,force-bti" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Used for instrumented build to generate the orderfile.
|
||||
config("default_orderfile_instrumentation") {
|
||||
if (use_order_profiling) {
|
||||
cflags = [ "-finstrument-function-entry-bare" ]
|
||||
if (use_thin_lto) {
|
||||
# TODO(pcc): This should not be necessary. Remove once
|
||||
# https://reviews.llvm.org/D50016 lands and gets rolled in.
|
||||
ldflags = [ "-Wl,-u,__cyg_profile_func_enter_bare" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config("jni_include_dir") {
|
||||
include_dirs = [ jni_headers_dir ]
|
||||
}
|
||||
|
||||
if (current_toolchain == default_toolchain) {
|
||||
pool("goma_javac_pool") {
|
||||
# Override action_pool when goma is enabled for javac.
|
||||
depth = 10000
|
||||
}
|
||||
|
||||
# nocompile tests share output directory to avoid them all needing to rebuild
|
||||
# things. But this also means they can't run in parallel.
|
||||
pool("nocompile_pool") {
|
||||
depth = 1
|
||||
}
|
||||
|
||||
# When defined, this pool should be used instead of link_pool for command
|
||||
# that need 1-2GB of RAM. https://crbug.com/1078460
|
||||
if (defined(java_cmd_pool_size)) {
|
||||
pool("java_cmd_pool") {
|
||||
depth = java_cmd_pool_size
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2022 The Chromium Authors and Alex313031. All rights reserved.
|
||||
# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
|
|
Loading…
Reference in a new issue