Merge android's use_gold settings with the main use_gold GN arg logic
This also fixes Android settin -Wl,--icf=all in a different spot. BUG=606749 Review-Url: https://codereview.chromium.org/1972183003 Cr-Original-Commit-Position: refs/heads/master@{#393355} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0f484bfda36d849c474922639f94eaf12d785d04
This commit is contained in:
Родитель
9025cb001c
Коммит
be888670a0
|
@ -4,12 +4,9 @@
|
|||
|
||||
import("//build/config/android/config.gni")
|
||||
import("//build/config/sanitizers/sanitizers.gni")
|
||||
import("//build/config/sysroot.gni")
|
||||
|
||||
assert(is_android)
|
||||
|
||||
use_gold = current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm"
|
||||
|
||||
# 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.
|
||||
|
@ -25,12 +22,7 @@ config("compiler") {
|
|||
# does. Define them here instead.
|
||||
"HAVE_SYS_UIO_H",
|
||||
]
|
||||
ldflags = []
|
||||
|
||||
if (!is_clang) {
|
||||
# Clang doesn't support these flags.
|
||||
cflags += [ "-finline-limit=64" ]
|
||||
}
|
||||
if (is_clang) {
|
||||
rebased_android_toolchain_root =
|
||||
rebase_path(android_toolchain_root, root_build_dir)
|
||||
|
@ -42,29 +34,12 @@ config("compiler") {
|
|||
"-B${rebased_android_toolchain_root}/bin", # Else /usr/bin/as gets picked up.
|
||||
]
|
||||
}
|
||||
} else {
|
||||
# Clang doesn't support these flags.
|
||||
cflags += [ "-finline-limit=64" ]
|
||||
}
|
||||
|
||||
# Use gold for Android for most CPU architectures.
|
||||
if (use_gold) {
|
||||
ldflags += [ "-fuse-ld=gold" ]
|
||||
if (is_clang) {
|
||||
# Let clang find the ld.gold in the NDK.
|
||||
ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ]
|
||||
}
|
||||
|
||||
# Use -mstackrealign due to a bug on ia32 Jelly Bean.
|
||||
# See crbug.com/521527
|
||||
if (current_cpu == "x86") {
|
||||
cflags += [ "-mstackrealign" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (current_cpu == "mipsel" && is_clang) {
|
||||
# Let clang find the ld.bfd in the NDK.
|
||||
ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ]
|
||||
}
|
||||
|
||||
ldflags += [
|
||||
ldflags = [
|
||||
"-Wl,--build-id=sha1",
|
||||
"-Wl,--no-undefined",
|
||||
|
||||
|
@ -78,12 +53,6 @@ config("compiler") {
|
|||
# http://crbug.com/448386
|
||||
"-Wl,--exclude-libs=libvpx_assembly_arm.a",
|
||||
]
|
||||
if (current_cpu == "arm" && !use_order_profiling) {
|
||||
ldflags += [
|
||||
# Enable identical code folding to reduce size.
|
||||
"-Wl,--icf=all",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_clang) {
|
||||
if (current_cpu == "arm") {
|
||||
|
@ -181,12 +150,6 @@ config("executable_config") {
|
|||
cflags = [ "-fPIE" ]
|
||||
asmflags = [ "-fPIE" ]
|
||||
ldflags = [ "-pie" ]
|
||||
|
||||
if (!use_gold) {
|
||||
# ld needs help finding libraries when linking.
|
||||
_rebased_sysroot = rebase_path(sysroot, root_build_dir)
|
||||
ldflags += [ "-Wl,-rpath-link=.:$_rebased_sysroot/usr/lib" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("hide_native_jni_exports") {
|
||||
|
|
|
@ -45,12 +45,6 @@ declare_args() {
|
|||
# Requires profiling to be set to true.
|
||||
enable_full_stack_frames_for_profiling = false
|
||||
|
||||
# TODO: We should be using 64-bit gold for linking on both 64-bit Linux
|
||||
# and 32-bit linux; 32-bit Gold runs out of address-space on 32-bit builds.
|
||||
# However, something isn't quite working right on the 32-bit builds.
|
||||
use_gold =
|
||||
is_linux && (current_cpu == "x64" || current_cpu == "arm") && !use_lld
|
||||
|
||||
# When we are going to use gold we need to find it.
|
||||
# This is initialized below, after use_gold might have been overridden.
|
||||
gold_path = false
|
||||
|
@ -303,24 +297,35 @@ config("compiler") {
|
|||
if (is_posix && use_lld && !is_nacl) {
|
||||
ldflags += [ "-fuse-ld=lld" ]
|
||||
} else if (use_gold) {
|
||||
ldflags += [
|
||||
"-B$gold_path",
|
||||
ldflags += [ "-fuse-ld=gold" ]
|
||||
if (is_android) {
|
||||
if (is_clang) {
|
||||
_rebased_android_toolchain_root =
|
||||
rebase_path(android_toolchain_root, root_build_dir)
|
||||
|
||||
# Newer gccs and clangs support -fuse-ld, use the flag to force gold
|
||||
# selection.
|
||||
# gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html
|
||||
"-fuse-ld=gold",
|
||||
# Let clang find the ld.gold in the NDK.
|
||||
ldflags += [ "--gcc-toolchain=$_rebased_android_toolchain_root" ]
|
||||
}
|
||||
|
||||
# Experimentation found that using four linking threads
|
||||
# saved ~20% of link time.
|
||||
# https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
|
||||
# Only apply this to the target linker, since the host
|
||||
# linker might not be gold, but isn't used much anyway.
|
||||
# TODO(raymes): Disable threading because gold is frequently
|
||||
# crashing on the bots: crbug.com/161942.
|
||||
#"-Wl,--threads",
|
||||
#"-Wl,--thread-count=4",
|
||||
]
|
||||
# Use -mstackrealign due to a bug on ia32 Jelly Bean.
|
||||
# See crbug.com/521527
|
||||
if (current_cpu == "x86") {
|
||||
cflags += [ "-mstackrealign" ]
|
||||
}
|
||||
} else {
|
||||
ldflags += [
|
||||
"-B$gold_path",
|
||||
# Experimentation found that using four linking threads
|
||||
# saved ~20% of link time.
|
||||
# https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
|
||||
# Only apply this to the target linker, since the host
|
||||
# linker might not be gold, but isn't used much anyway.
|
||||
# TODO(raymes): Disable threading because gold is frequently
|
||||
# crashing on the bots: crbug.com/161942.
|
||||
#"-Wl,--threads",
|
||||
#"-Wl,--thread-count=4",
|
||||
]
|
||||
}
|
||||
|
||||
if (gdb_index) {
|
||||
ldflags += [ "-Wl,--gdb-index" ]
|
||||
|
@ -336,6 +341,11 @@ config("compiler") {
|
|||
# Gold is the default linker for the bundled binutils so we explicitly
|
||||
# enable the bfd linker when use_gold is not set.
|
||||
ldflags += [ "-fuse-ld=bfd" ]
|
||||
} else if (is_android && current_cpu == "mipsel" && is_clang) {
|
||||
# Let clang find the ld.bfd in the NDK.
|
||||
_rebased_android_toolchain_root =
|
||||
rebase_path(android_toolchain_root, root_build_dir)
|
||||
ldflags += [ "--gcc-toolchain=$rebased_android_toolchain_root" ]
|
||||
}
|
||||
|
||||
if (is_posix && (use_gold || (use_lld && !is_nacl)) && !using_sanitizer &&
|
||||
|
|
|
@ -6,6 +6,7 @@ import("//build/config/android/config.gni")
|
|||
import("//build/config/chrome_build.gni")
|
||||
import("//build/config/chromecast_build.gni")
|
||||
import("//build/config/sanitizers/sanitizers.gni")
|
||||
import("//build/toolchain/toolchain.gni")
|
||||
|
||||
declare_args() {
|
||||
# How many symbols to include in the build. This affects the performance of
|
||||
|
@ -33,6 +34,16 @@ declare_args() {
|
|||
full_wpo_on_official = false
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
# TODO: We should be using 64-bit gold for linking on both 64-bit Linux
|
||||
# and 32-bit linux; 32-bit Gold runs out of address-space on 32-bit builds.
|
||||
# However, something isn't quite working right on the 32-bit builds.
|
||||
use_gold = !use_lld &&
|
||||
((is_linux && (current_cpu == "x64" || current_cpu == "arm")) ||
|
||||
(is_android && (current_cpu == "x86" || current_cpu == "x64" ||
|
||||
current_cpu == "arm")))
|
||||
}
|
||||
|
||||
# If it wasn't manually set, set to an appropriate default.
|
||||
assert(symbol_level >= -1 && symbol_level <= 2, "Invalid symbol_level")
|
||||
if (symbol_level == -1) {
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//build/config/compiler/compiler.gni")
|
||||
import("//build/config/sanitizers/sanitizers.gni")
|
||||
import("//build/config/sysroot.gni")
|
||||
import("//build/toolchain/toolchain.gni")
|
||||
|
||||
# This config causes functions not to be automatically exported from shared
|
||||
|
@ -69,8 +71,9 @@ config("rpath_for_built_shared_libraries") {
|
|||
|
||||
# Settings for executables.
|
||||
config("executable_ldconfig") {
|
||||
ldflags = []
|
||||
if (is_android) {
|
||||
ldflags = [
|
||||
ldflags += [
|
||||
"-Bdynamic",
|
||||
"-Wl,-z,nocopyreloc",
|
||||
]
|
||||
|
@ -80,19 +83,26 @@ config("executable_ldconfig") {
|
|||
if (is_component_build || using_sanitizer) {
|
||||
configs = [ ":rpath_for_built_shared_libraries" ]
|
||||
}
|
||||
if (current_cpu == "mipsel") {
|
||||
ldflags += [ "-pie" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_android || !use_gold) {
|
||||
# Find the path containing shared libraries for this toolchain
|
||||
# relative to the build directory. ${root_out_dir} will be a
|
||||
# subdirectory of ${root_build_dir} when cross compiling.
|
||||
rebased_out_dir = rebase_path(root_out_dir, root_build_dir)
|
||||
_rpath_link = rebase_path(root_out_dir, root_build_dir)
|
||||
if (shlib_subdir != ".") {
|
||||
rpath_link = "${rebased_out_dir}/${shlib_subdir}"
|
||||
} else {
|
||||
rpath_link = rebased_out_dir
|
||||
_rpath_link += "/$shlib_subdir"
|
||||
}
|
||||
if (is_android) {
|
||||
_rebased_sysroot = rebase_path(sysroot, root_build_dir)
|
||||
_rpath_link += ":$_rebased_sysroot/usr/lib"
|
||||
}
|
||||
|
||||
ldflags = [
|
||||
"-Wl,-rpath-link=${rpath_link}",
|
||||
ldflags += [
|
||||
"-Wl,-rpath-link=$_rpath_link",
|
||||
|
||||
# TODO(GYP): Do we need a check on the binutils version here?
|
||||
#
|
||||
|
@ -100,9 +110,6 @@ config("executable_ldconfig") {
|
|||
# and the new DT_RUNPATH doesn't work without --no-as-needed flag.
|
||||
"-Wl,--disable-new-dtags",
|
||||
]
|
||||
if (current_cpu == "mipsel") {
|
||||
ldflags += [ "-pie" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче