diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 7a1b0723840..b1210162023 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -887,12 +887,6 @@ if (is_win) { "-Wl,--gc-sections", ] - if (is_clang && !using_sanitizer) { - # Identical code folding to reduce size. - # Warning: This changes C/C++ semantics of function pointer comparison. - common_optimize_on_ldflags += [ "-Wl,--icf=all" ] - } - if (!using_sanitizer) { # Functions interposed by the sanitizers can make ld think # that some libraries aren't needed when they actually are, @@ -900,6 +894,13 @@ if (is_win) { common_optimize_on_ldflags += [ "-Wl,--as-needed" ] } } + + if (is_clang && !using_sanitizer) { + # Identical code folding to reduce size. + # Warning: This changes C/C++ semantics of function pointer comparison. + # Needs lld/gold/mold instead of GNU ld/Mac ld. + common_optimize_on_ldflags += [ "-Wl,--icf=all" ] + } } # Default "optimization on" config. On Windows, this favors size over speed.