Commit 39c7f4dc authored by Ting-Yuan Huang's avatar Ting-Yuan Huang Committed by Commit Bot

build: introduce use_icf to control Identical Code Folding.

ICF is currently decided by platform/compiler/etc. We need a switch to
turn it off in some cases.

BUG=b:72175832

Change-Id: I9637c27cd5e663152afc3102ac6996fc9cc1f5f6
Reviewed-on: https://chromium-review.googlesource.com/876802Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarMike Frysinger <vapier@chromium.org>
Commit-Queue: Ting-Yuan Huang <laszio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532177}
parent cc695e68
......@@ -123,6 +123,26 @@ declare_args() {
use_cxx11_on_android = use_cxx11
}
declare_args() {
# Set to true to use icf, Identical Code Folding.
#
# TODO(thakis): Remove `!is_android` below once NDK gold has been rolled
# with the fix for https://sourceware.org/bugzilla/show_bug.cgi?id=17704
# merged. See also https://crbug.com/663886
#
# `linux_use_bundled_binutils` is to avoid breaking Linux distros which may
# still have a buggy gold.
#
# chromeos binutils has been patched with the fix, so always use icf there.
#
# The bug only affects x86 and x64, so we can still use ICF when targeting
# other architectures.
use_icf = is_posix && (use_gold || (use_lld && !is_nacl)) &&
!using_sanitizer && !(is_android && use_order_profiling) &&
((!is_android && linux_use_bundled_binutils) || is_chromeos ||
!(current_cpu == "x86" || current_cpu == "x64"))
}
if (is_clang) {
update_args = [ "--print-revision" ]
if (llvm_force_head_revision) {
......@@ -426,20 +446,8 @@ config("compiler") {
ldflags += [ "-fuse-ld=bfd" ]
}
if (is_posix && (use_gold || (use_lld && !is_nacl)) && !using_sanitizer &&
!(is_android && use_order_profiling)) {
# TODO(thakis): Remove `!is_android` below once NDK gold has been rolled
# with the fix for https://sourceware.org/bugzilla/show_bug.cgi?id=17704
# merged. See also https://crbug.com/663886
# `linux_use_bundled_binutils` is to avoid breaking Linux distros which may
# still have a buggy gold.
# chromeos binutils has been patched with the fix, so always use icf there.
# The bug only affects x86 and x64, so we can still use ICF when targeting
# other architectures.
if ((!is_android && linux_use_bundled_binutils) || is_chromeos ||
!(current_cpu == "x86" || current_cpu == "x64")) {
ldflags += [ "-Wl,--icf=all" ]
}
if (use_icf) {
ldflags += [ "-Wl,--icf=all" ]
}
if (linux_use_bundled_binutils) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment