From ef95f2ded6f373cf870ad726751de9c249610975 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Thu, 28 Jun 2018 17:30:17 +0000 Subject: [PATCH] [build] Enable linker identical code folding. Change-Id: I04ab9ef71c41f96abd2d9e23ee107937617fb99d Reviewed-on: https://dart-review.googlesource.com/62707 Reviewed-by: Zach Anderson Commit-Queue: Ryan Macnak --- build/config/compiler/BUILD.gn | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 8154e4e9a2c..e29aa03d2b8 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -315,12 +315,6 @@ config("compiler") { "-Wl,--exclude-libs=libgcc.a", "-Wl,--exclude-libs=libc++_static.a", ] - if (current_cpu == "arm") { - ldflags += [ - # Enable identical code folding to reduce size. - "-Wl,--icf=safe", - ] - } if (is_clang) { if (current_cpu == "arm") { @@ -662,7 +656,10 @@ if (is_win) { "/Gw", ] } - common_optimize_on_ldflags = [ "/OPT:REF" ] + common_optimize_on_ldflags = [ + "/OPT:REF", + "/OPT:ICF", + ] } else { common_optimize_on_cflags = [ # Don't emit the GCC version ident directives, they just end up in the @@ -693,6 +690,10 @@ if (is_win) { # See http://lwn.net/Articles/192624/ . "-Wl,-O1", "-Wl,--gc-sections", + + # Identical code folding to reduce size. + # Warning: This changes C/C++ semantics of function pointer comparison. + "-Wl,--icf=all", ] if (!using_sanitizer) {