From 7ba8beaeefe9fef6ab8769858d646f85c5071e78 Mon Sep 17 00:00:00 2001 From: Alexander Frick Date: Mon, 15 Jul 2024 13:15:40 -0500 Subject: [PATCH] update compiler and V8 build.gns --- arm/build/config/compiler/BUILD.gn | 230 +++--- other/AVX2/build/config/compiler/BUILD.gn | 226 +++--- other/AVX512/build/config/compiler/BUILD.gn | 228 +++--- other/CrOS/build/config/compiler/BUILD.gn | 231 +++--- other/SSE2/build/config/compiler/BUILD.gn | 231 +++--- other/SSE3/build/config/compiler/BUILD.gn | 231 +++--- other/SSE4.1/build/config/compiler/BUILD.gn | 231 +++--- src/build/config/compiler/BUILD.gn | 226 +++--- src/v8/BUILD.gn | 769 +++++--------------- 9 files changed, 1232 insertions(+), 1371 deletions(-) diff --git a/arm/build/config/compiler/BUILD.gn b/arm/build/config/compiler/BUILD.gn index a5ef3c64..41699a28 100644 --- a/arm/build/config/compiler/BUILD.gn +++ b/arm/build/config/compiler/BUILD.gn @@ -20,7 +20,6 @@ import("//build/config/ui.gni") import("//build/config/unwind.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/cros/cros_config.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -68,10 +67,6 @@ declare_args() { # Requires profiling to be set to true. enable_full_stack_frames_for_profiling = false - # 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 = "" - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ use_polly = false @@ -152,7 +147,7 @@ declare_args() { # # Flag discussion: https://crbug.com/977230 # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and + # TODO(crbug.com/40721698): This regresses binary size by ~1MB on Android and # needs to be evaluated before enabling it there as well. init_stack_vars = !(is_android && is_official_build) @@ -205,7 +200,7 @@ declare_args() { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. + # TODO(crbug.com/40244196): Remove if the upstream default ever changes. # # This greatly reduces the size of debug builds, at the cost of # debugging information which is required by some specialized @@ -215,19 +210,9 @@ declare_args() { declare_args() { # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # 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. - # - # lld doesn't have the bug. use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) + !(is_android && use_order_profiling) && use_lld } if (is_android) { @@ -254,10 +239,8 @@ declare_args() { (clang_use_default_sample_profile || clang_sample_profile_path != "")) } -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") +assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"), + "rbe with locally built clang only works on linux") # default_include_dirs --------------------------------------------------------- # @@ -338,12 +321,13 @@ config("compiler") { # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr # operations (e.g. dereferencing) into defined behavior. This avoids deletion # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 + # The older NaCl toolchain does not support the flag. And, we still want UBSan + # to catch undefined behavior related to nullptrs, so do not add this flag if + # UBSan is enabled. GCC seems to have some bugs compiling constexpr code when + # this is defined, so only enable it if using_clang. + # See: https://gcc.gnu.org/PR97913 # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { + if ((!is_nacl || is_nacl_saigo) && !is_ubsan && is_clang) { cflags += [ "-fno-delete-null-pointer-checks" ] } @@ -534,35 +518,6 @@ config("compiler") { # Linux-specific compiler flags setup. # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # 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. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - if (use_icf && (!is_apple || use_lld)) { ldflags += [ "-Wl,--icf=all" ] } @@ -630,9 +585,9 @@ config("compiler") { } } - # TODO(crbug.com/1488374): This causes binary size growth and potentially + # TODO(crbug.com/40283598): This causes binary size growth and potentially # other problems. - # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + # TODO(crbug.com/40284925): This isn't supported by Cronet's mainline llvm version. if (default_toolchain != "//build/toolchain/cros:target" && !llvm_android_mainline) { cflags += [ @@ -648,7 +603,7 @@ config("compiler") { } } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. + # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=fast" ] } else { @@ -743,6 +698,19 @@ config("compiler") { # example by disabling the optimize configuration. # TODO(pcc): Make this conditional on is_official_build rather than on gn # flags for specific features. + # + # High-end Android: While Full LTO provides a small performance improvement + # (according to Speedometer), it also results in an unacceptable increase in + # build time. Thin LTO appears to provide the best build time-optimization + # tradeoff. As of April 2024, Full LTO: + # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours + # with Thin LTO) on Chromium builders. + # - Increases Speedometer 2.1 score by 1.1% [0]. + # - Increases Speedometer 3.0 score by 1.2% [1]. + # ... over Thin LTO. + # + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000 if (!is_debug && use_thin_lto && is_a_target_toolchain) { assert(use_lld, "LTO is only supported with lld") @@ -776,6 +744,16 @@ config("compiler") { # binary size than the default setting of 100. # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # should be able to better manage binary size increases on its own. + # + # For high-end Android, 30 seems to be the right trade-off between performance + # and binary size, at least based on Speedometer. For example, increasing + # `import_instr_limit`to 50 improves Speedometer 2.1 score by 0.7% [0], while + # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size + # increases by about 2MB [2] (or 1.1%: the arm64 native code size in M124 is + # 178MB). + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000 + # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442 import_instr_limit = 30 if (is_win) { @@ -803,8 +781,10 @@ config("compiler") { # FIXME(inglorion): maybe tune these? # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. import_instr_limit = 30 - } else if (is_android && optimize_for_size) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win + } else if (is_android && (optimize_for_size || use_order_profiling)) { + # Reduce inlining for the orderfile instrumented build to mitigate + # crbug.com/330761384. + # TODO(crbug.com/40219076): Investigate if we can get the > 6% perf win # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. import_instr_limit = 30 } @@ -820,7 +800,22 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] } - # TODO(https://crbug.com/1211155): investigate why this isn't effective on + # TODO(crbug.com/335365324): Enable on other platforms. + if (is_android && !optimize_for_size) { + # Ideally the compiler would handle this automatically with PGO (see + # comments at https://crrev.com/c/5440500). + # + # Android binary size impact (as of April 2024): The arm64 native code + # size increases by ~627KB (or 0.34%: the arm64 native code size in + # M124 is 178MB). + cflags += [ + "-mllvm", + "-inlinehint-threshold=360", + ] + ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ] + } + + # TODO(crbug.com/40182783): investigate why this isn't effective on # arm32. if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] @@ -878,7 +873,7 @@ config("compiler") { ldflags += [ "-Wl,--no-rosegment" ] } - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by + # TODO(crbug.com/40242425): Cleanup undefined symbol errors caught by # --no-undefined-version. if (use_lld && !is_win && !is_mac && !is_ios) { ldflags += [ "-Wl,--undefined-version" ] @@ -902,8 +897,6 @@ config("compiler") { if (is_clang && !is_nacl && show_includes) { if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ "/clang:-H", "/clang:-fshow-skipped-includes", @@ -1084,10 +1077,10 @@ config("compiler") { # consistently apply in both Chromium and non-Chromium code *and* non-NaCl # and NaCl code. # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` + # TODO(crbug.com/40511454): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # TODO(crbug.com/40275904): Switch saigo to hardened mode once # it's rolled in. if (is_nacl_saigo) { defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] @@ -1220,6 +1213,10 @@ config("compiler_cpu_abi") { cflags += [ "--target=arm-linux-gnueabihf", "-O3", ] ldflags += [ "--target=arm-linux-gnueabihf", "-Wl,-O3", ] } + if (is_android) { + cflags += [ "-O3", ] + ldflags += [ "-Wl,-O3", ] + } if (!is_nacl) { cflags += [ "-march=$arm_arch", @@ -1518,7 +1515,7 @@ config("compiler_codegen") { if (current_cpu == "arm64" && !is_win && is_clang) { # Disable outlining everywhere on arm64 except Win. For more information see # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. + # TODO(crbug.com/40890229): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1604,7 +1601,7 @@ config("compiler_deterministic") { # Tells the compiler not to use absolute paths when passing the default # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. + # really need it and it can mess up the RBE cache entries. if (is_clang && (!is_nacl || is_nacl_saigo)) { cflags += [ "-no-canonical-prefixes" ] @@ -1612,7 +1609,7 @@ config("compiler_deterministic") { # with a relative path and pass relative paths to built-in # libraries. Not needed on Windows because we call the linker # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner + # We don't link on RBE, so this change is just for cleaner # internal linker invocations, for people who work on the build. if (!is_win) { ldflags += [ "-no-canonical-prefixes" ] @@ -1709,7 +1706,7 @@ config("runtime_library") { configs += [ "//build/config/clang:compiler_builtins" ] } - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia + # TODO(crbug.com/40570904): Come up with a better name for is POSIX + Fuchsia # configuration. if (is_posix || is_fuchsia) { configs += [ "//build/config/posix:runtime_library" ] @@ -1896,41 +1893,47 @@ config("default_warnings") { if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. + # Currently RBE can not handle case sensitiveness for windows well. cflags += [ "-Wno-nonportable-include-path" ] } if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474434): fix and reenable + # TODO(crbug.com/42050603): fix and reenable "-Wno-missing-field-initializers", # TODO(https://crbug.com/324953188): fix and reenable "-Wno-extra-qualification", + + # TODO(https://crbug.com/332931387): fix and reenable + "-Wno-unused-but-set-variable", ] } cflags += [ + # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now. + "-Wno-cast-function-type", + # Ignore warnings about MSVC optimization pragmas. # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 "-Wno-ignored-pragma-optimize", - # TODO(crbug.com/1343975) Evaluate and possibly enable. + # TODO(crbug.com/40231599) Evaluate and possibly enable. "-Wno-deprecated-builtins", - # TODO(crbug.com/1352183) Evaluate and possibly enable. + # TODO(crbug.com/40234766) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", - # TODO(crbug.com/1412713) Evaluate and possibly enable. + # TODO(crbug.com/40255410) Evaluate and possibly enable. "-Wno-deprecated-this-capture", - # TODO(https://crbug.com/1491833): Fix and re-enable. + # TODO(crbug.com/40285259): Fix and re-enable. "-Wno-invalid-offsetof", - # TODO(crbug.com/1494809): Evaluate and possibly enable. + # TODO(crbug.com/40286317): Evaluate and possibly enable. "-Wno-vla-extension", - # TODO(https://crbug.com/1490607): Fix and re-enable. + # TODO(crbug.com/40284799): Fix and re-enable. "-Wno-thread-safety-reference-return", ] @@ -1941,7 +1944,7 @@ config("default_warnings") { if (!is_nacl) { cflags_cc += [ - # TODO(https://crbug.com/1513724): Fix and re-enable. + # TODO(crbug.com/41486292): Fix and re-enable. "-Wno-c++11-narrowing-const-reference", ] } @@ -2139,7 +2142,7 @@ config("no_chromium_code") { # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", - # TODO(https://crbug.com/1202159): Clean up and enable. + # TODO(crbug.com/40762742): Clean up and enable. "-Wno-misleading-indentation", ] } @@ -2202,7 +2205,7 @@ config("no_rtti") { # (de)allocate memory on a different heap, which would spell trouble if pointers # to heap-allocated memory are passed over shared library boundaries. config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. + # TODO(crbug.com/40118868): Revisit after target_os flip is completed. if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { ldflags = [ "-rdynamic" ] } @@ -2460,13 +2463,16 @@ if (is_win) { # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] + if (is_official_build) { + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/. + # -O2 enables string tail merge optimization in lld. + "-Wl,-O3", + ] + } + + common_optimize_on_ldflags += [ "-Wl,--gc-sections" ] } # We cannot rely on errno being set after math functions, @@ -2559,9 +2565,26 @@ config("default_stack_frames") { } # Default "optimization on" config. +# +# High-end Android: As of April 2024, `-O2` appears to be a good default, +# particularly since a selection of "hot" targets are already using `-O3`. +# Enabling `-O3` for all targets does not change performance much (according +# to Speedometer), but regresses binary size. Using `-O3` as the default: +# - Decreases Speedometer 2.1 score by 0.2% [0]. +# - Increases Speedometer 3.0 score by 0.1% [1]. +# - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size +# in M124 is 178MB). +# ... over `-O2`. +# +# [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000 +# [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 +# [2]: https://crrev.com/c/5447532 config("optimize") { if (is_win) { cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2637,9 +2660,9 @@ config("no_optimize") { } } -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. +# Turns up the optimization level. Used to explicitly enable -O2 instead of +# -Os for select targets on platforms that use optimize_for_size. No-op +# elsewhere. config("optimize_max") { if (is_nacl && is_nacl_irt) { # The NaCl IRT is a special case and always wants its own config. @@ -2657,6 +2680,9 @@ config("optimize_max") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2669,9 +2695,9 @@ config("optimize_max") { # This config can be used to override the default settings for per-component # and whole-program optimization, optimizing the particular target for speed # instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. +# except that we use -O3 instead of -O2 on non-IRT platforms. # -# TODO(crbug.com/621335) - rework how all of these configs are related +# TODO(crbug.com/41259697) - rework how all of these configs are related # so that we don't need this disclaimer. config("optimize_speed") { if (is_nacl && is_nacl_irt) { @@ -2690,6 +2716,9 @@ config("optimize_speed") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2932,7 +2961,7 @@ config("symbols") { # sections" there. Maybe just a bug in nacl_switch_32.S. _enable_gdb_index = symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && + current_os != "zos" && use_lld && # Disable on non-fission 32-bit Android because it pushes # libcomponents_unittests over the 4gb size limit. !(is_android && !use_debug_fission && current_cpu != "x64" && @@ -2951,16 +2980,17 @@ config("symbols") { configs = [] - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { + # Compress debug on 32-bit ARM to stay under 4GB file size limit. + # https://b/243982712, https://crbug.com/1354616, https://crbug.com/334073642 + if (symbol_level == 2 && !use_debug_fission && !is_nacl && + (is_chromeos_device || is_android) && + (current_cpu == "arm" || current_cpu == "x86")) { configs += [ "//build/config:compress_debug_sections" ] } if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. + # TODO(crbug.com/40117949): Investigate missing debug info on mac. # Make sure we don't use constructor homing on mac. cflags += [ "-Xclang", diff --git a/other/AVX2/build/config/compiler/BUILD.gn b/other/AVX2/build/config/compiler/BUILD.gn index 3cecc28c..0cb0edfa 100644 --- a/other/AVX2/build/config/compiler/BUILD.gn +++ b/other/AVX2/build/config/compiler/BUILD.gn @@ -20,7 +20,6 @@ import("//build/config/ui.gni") import("//build/config/unwind.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/cros/cros_config.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -68,10 +67,6 @@ declare_args() { # Requires profiling to be set to true. enable_full_stack_frames_for_profiling = false - # 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 = "" - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ use_polly = false @@ -149,7 +144,7 @@ declare_args() { # # Flag discussion: https://crbug.com/977230 # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and + # TODO(crbug.com/40721698): This regresses binary size by ~1MB on Android and # needs to be evaluated before enabling it there as well. init_stack_vars = !(is_android && is_official_build) @@ -202,7 +197,7 @@ declare_args() { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. + # TODO(crbug.com/40244196): Remove if the upstream default ever changes. # # This greatly reduces the size of debug builds, at the cost of # debugging information which is required by some specialized @@ -212,19 +207,9 @@ declare_args() { declare_args() { # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # 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. - # - # lld doesn't have the bug. use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) + !(is_android && use_order_profiling) && use_lld } if (is_android) { @@ -251,10 +236,8 @@ declare_args() { (clang_use_default_sample_profile || clang_sample_profile_path != "")) } -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") +assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"), + "rbe with locally built clang only works on linux") # default_include_dirs --------------------------------------------------------- # @@ -335,12 +318,13 @@ config("compiler") { # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr # operations (e.g. dereferencing) into defined behavior. This avoids deletion # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 + # The older NaCl toolchain does not support the flag. And, we still want UBSan + # to catch undefined behavior related to nullptrs, so do not add this flag if + # UBSan is enabled. GCC seems to have some bugs compiling constexpr code when + # this is defined, so only enable it if using_clang. + # See: https://gcc.gnu.org/PR97913 # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { + if ((!is_nacl || is_nacl_saigo) && !is_ubsan && is_clang) { cflags += [ "-fno-delete-null-pointer-checks" ] } @@ -531,35 +515,6 @@ config("compiler") { # Linux-specific compiler flags setup. # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # 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. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - if (use_icf && (!is_apple || use_lld)) { ldflags += [ "-Wl,--icf=all" ] } @@ -627,9 +582,9 @@ config("compiler") { } } - # TODO(crbug.com/1488374): This causes binary size growth and potentially + # TODO(crbug.com/40283598): This causes binary size growth and potentially # other problems. - # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + # TODO(crbug.com/40284925): This isn't supported by Cronet's mainline llvm version. if (default_toolchain != "//build/toolchain/cros:target" && !llvm_android_mainline) { cflags += [ @@ -645,7 +600,7 @@ config("compiler") { } } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. + # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=fast" ] } else { @@ -740,6 +695,19 @@ config("compiler") { # example by disabling the optimize configuration. # TODO(pcc): Make this conditional on is_official_build rather than on gn # flags for specific features. + # + # High-end Android: While Full LTO provides a small performance improvement + # (according to Speedometer), it also results in an unacceptable increase in + # build time. Thin LTO appears to provide the best build time-optimization + # tradeoff. As of April 2024, Full LTO: + # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours + # with Thin LTO) on Chromium builders. + # - Increases Speedometer 2.1 score by 1.1% [0]. + # - Increases Speedometer 3.0 score by 1.2% [1]. + # ... over Thin LTO. + # + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000 if (!is_debug && use_thin_lto && is_a_target_toolchain) { assert(use_lld, "LTO is only supported with lld") @@ -773,6 +741,16 @@ config("compiler") { # binary size than the default setting of 100. # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # should be able to better manage binary size increases on its own. + # + # For high-end Android, 30 seems to be the right trade-off between performance + # and binary size, at least based on Speedometer. For example, increasing + # `import_instr_limit`to 50 improves Speedometer 2.1 score by 0.7% [0], while + # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size + # increases by about 2MB [2] (or 1.1%: the arm64 native code size in M124 is + # 178MB). + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000 + # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442 import_instr_limit = 30 if (is_win) { @@ -800,8 +778,10 @@ config("compiler") { # FIXME(inglorion): maybe tune these? # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. import_instr_limit = 30 - } else if (is_android && optimize_for_size) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win + } else if (is_android && (optimize_for_size || use_order_profiling)) { + # Reduce inlining for the orderfile instrumented build to mitigate + # crbug.com/330761384. + # TODO(crbug.com/40219076): Investigate if we can get the > 6% perf win # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. import_instr_limit = 30 } @@ -817,7 +797,22 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] } - # TODO(https://crbug.com/1211155): investigate why this isn't effective on + # TODO(crbug.com/335365324): Enable on other platforms. + if (is_android && !optimize_for_size) { + # Ideally the compiler would handle this automatically with PGO (see + # comments at https://crrev.com/c/5440500). + # + # Android binary size impact (as of April 2024): The arm64 native code + # size increases by ~627KB (or 0.34%: the arm64 native code size in + # M124 is 178MB). + cflags += [ + "-mllvm", + "-inlinehint-threshold=360", + ] + ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ] + } + + # TODO(crbug.com/40182783): investigate why this isn't effective on # arm32. if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] @@ -871,7 +866,7 @@ config("compiler") { ldflags += [ "-Wl,--no-rosegment" ] } - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by + # TODO(crbug.com/40242425): Cleanup undefined symbol errors caught by # --no-undefined-version. if (use_lld && !is_win && !is_mac && !is_ios) { ldflags += [ "-Wl,--undefined-version" ] @@ -895,8 +890,6 @@ config("compiler") { if (is_clang && !is_nacl && show_includes) { if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ "/clang:-H", "/clang:-fshow-skipped-includes", @@ -1074,10 +1067,10 @@ config("compiler") { # consistently apply in both Chromium and non-Chromium code *and* non-NaCl # and NaCl code. # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` + # TODO(crbug.com/40511454): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # TODO(crbug.com/40275904): Switch saigo to hardened mode once # it's rolled in. if (is_nacl_saigo) { defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] @@ -1511,7 +1504,7 @@ config("compiler_codegen") { if (current_cpu == "arm64" && !is_win && is_clang) { # Disable outlining everywhere on arm64 except Win. For more information see # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. + # TODO(crbug.com/40890229): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1597,7 +1590,7 @@ config("compiler_deterministic") { # Tells the compiler not to use absolute paths when passing the default # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. + # really need it and it can mess up the RBE cache entries. if (is_clang && (!is_nacl || is_nacl_saigo)) { cflags += [ "-no-canonical-prefixes" ] @@ -1605,7 +1598,7 @@ config("compiler_deterministic") { # with a relative path and pass relative paths to built-in # libraries. Not needed on Windows because we call the linker # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner + # We don't link on RBE, so this change is just for cleaner # internal linker invocations, for people who work on the build. if (!is_win) { ldflags += [ "-no-canonical-prefixes" ] @@ -1702,7 +1695,7 @@ config("runtime_library") { configs += [ "//build/config/clang:compiler_builtins" ] } - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia + # TODO(crbug.com/40570904): Come up with a better name for is POSIX + Fuchsia # configuration. if (is_posix || is_fuchsia) { configs += [ "//build/config/posix:runtime_library" ] @@ -1889,41 +1882,47 @@ config("default_warnings") { if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. + # Currently RBE can not handle case sensitiveness for windows well. cflags += [ "-Wno-nonportable-include-path" ] } if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474434): fix and reenable + # TODO(crbug.com/42050603): fix and reenable "-Wno-missing-field-initializers", # TODO(https://crbug.com/324953188): fix and reenable "-Wno-extra-qualification", + + # TODO(https://crbug.com/332931387): fix and reenable + "-Wno-unused-but-set-variable", ] } cflags += [ + # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now. + "-Wno-cast-function-type", + # Ignore warnings about MSVC optimization pragmas. # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 "-Wno-ignored-pragma-optimize", - # TODO(crbug.com/1343975) Evaluate and possibly enable. + # TODO(crbug.com/40231599) Evaluate and possibly enable. "-Wno-deprecated-builtins", - # TODO(crbug.com/1352183) Evaluate and possibly enable. + # TODO(crbug.com/40234766) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", - # TODO(crbug.com/1412713) Evaluate and possibly enable. + # TODO(crbug.com/40255410) Evaluate and possibly enable. "-Wno-deprecated-this-capture", - # TODO(https://crbug.com/1491833): Fix and re-enable. + # TODO(crbug.com/40285259): Fix and re-enable. "-Wno-invalid-offsetof", - # TODO(crbug.com/1494809): Evaluate and possibly enable. + # TODO(crbug.com/40286317): Evaluate and possibly enable. "-Wno-vla-extension", - # TODO(https://crbug.com/1490607): Fix and re-enable. + # TODO(crbug.com/40284799): Fix and re-enable. "-Wno-thread-safety-reference-return", ] @@ -1934,7 +1933,7 @@ config("default_warnings") { if (!is_nacl) { cflags_cc += [ - # TODO(https://crbug.com/1513724): Fix and re-enable. + # TODO(crbug.com/41486292): Fix and re-enable. "-Wno-c++11-narrowing-const-reference", ] } @@ -2132,7 +2131,7 @@ config("no_chromium_code") { # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", - # TODO(https://crbug.com/1202159): Clean up and enable. + # TODO(crbug.com/40762742): Clean up and enable. "-Wno-misleading-indentation", ] } @@ -2195,7 +2194,7 @@ config("no_rtti") { # (de)allocate memory on a different heap, which would spell trouble if pointers # to heap-allocated memory are passed over shared library boundaries. config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. + # TODO(crbug.com/40118868): Revisit after target_os flip is completed. if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { ldflags = [ "-rdynamic" ] } @@ -2445,13 +2444,16 @@ if (is_win) { # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] + if (is_official_build) { + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/. + # -O2 enables string tail merge optimization in lld. + "-Wl,-O3", + ] + } + + common_optimize_on_ldflags += [ "-Wl,--gc-sections" ] } # We cannot rely on errno being set after math functions, @@ -2544,9 +2546,26 @@ config("default_stack_frames") { } # Default "optimization on" config. +# +# High-end Android: As of April 2024, `-O2` appears to be a good default, +# particularly since a selection of "hot" targets are already using `-O3`. +# Enabling `-O3` for all targets does not change performance much (according +# to Speedometer), but regresses binary size. Using `-O3` as the default: +# - Decreases Speedometer 2.1 score by 0.2% [0]. +# - Increases Speedometer 3.0 score by 0.1% [1]. +# - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size +# in M124 is 178MB). +# ... over `-O2`. +# +# [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000 +# [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 +# [2]: https://crrev.com/c/5447532 config("optimize") { if (is_win) { cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2622,9 +2641,9 @@ config("no_optimize") { } } -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. +# Turns up the optimization level. Used to explicitly enable -O2 instead of +# -Os for select targets on platforms that use optimize_for_size. No-op +# elsewhere. config("optimize_max") { if (is_nacl && is_nacl_irt) { # The NaCl IRT is a special case and always wants its own config. @@ -2642,6 +2661,9 @@ config("optimize_max") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2654,9 +2676,9 @@ config("optimize_max") { # This config can be used to override the default settings for per-component # and whole-program optimization, optimizing the particular target for speed # instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. +# except that we use -O3 instead of -O2 on non-IRT platforms. # -# TODO(crbug.com/621335) - rework how all of these configs are related +# TODO(crbug.com/41259697) - rework how all of these configs are related # so that we don't need this disclaimer. config("optimize_speed") { if (is_nacl && is_nacl_irt) { @@ -2675,6 +2697,9 @@ config("optimize_speed") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2917,7 +2942,7 @@ config("symbols") { # sections" there. Maybe just a bug in nacl_switch_32.S. _enable_gdb_index = symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && + current_os != "zos" && use_lld && # Disable on non-fission 32-bit Android because it pushes # libcomponents_unittests over the 4gb size limit. !(is_android && !use_debug_fission && current_cpu != "x64" && @@ -2936,16 +2961,17 @@ config("symbols") { configs = [] - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { + # Compress debug on 32-bit ARM to stay under 4GB file size limit. + # https://b/243982712, https://crbug.com/1354616, https://crbug.com/334073642 + if (symbol_level == 2 && !use_debug_fission && !is_nacl && + (is_chromeos_device || is_android) && + (current_cpu == "arm" || current_cpu == "x86")) { configs += [ "//build/config:compress_debug_sections" ] } if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. + # TODO(crbug.com/40117949): Investigate missing debug info on mac. # Make sure we don't use constructor homing on mac. cflags += [ "-Xclang", diff --git a/other/AVX512/build/config/compiler/BUILD.gn b/other/AVX512/build/config/compiler/BUILD.gn index 37c1cd90..6993549e 100644 --- a/other/AVX512/build/config/compiler/BUILD.gn +++ b/other/AVX512/build/config/compiler/BUILD.gn @@ -20,7 +20,6 @@ import("//build/config/ui.gni") import("//build/config/unwind.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/cros/cros_config.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -68,10 +67,6 @@ declare_args() { # Requires profiling to be set to true. enable_full_stack_frames_for_profiling = false - # 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 = "" - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ use_polly = false @@ -149,7 +144,7 @@ declare_args() { # # Flag discussion: https://crbug.com/977230 # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and + # TODO(crbug.com/40721698): This regresses binary size by ~1MB on Android and # needs to be evaluated before enabling it there as well. init_stack_vars = !(is_android && is_official_build) @@ -202,7 +197,7 @@ declare_args() { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. + # TODO(crbug.com/40244196): Remove if the upstream default ever changes. # # This greatly reduces the size of debug builds, at the cost of # debugging information which is required by some specialized @@ -212,19 +207,9 @@ declare_args() { declare_args() { # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # 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. - # - # lld doesn't have the bug. use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) + !(is_android && use_order_profiling) && use_lld } if (is_android) { @@ -251,10 +236,8 @@ declare_args() { (clang_use_default_sample_profile || clang_sample_profile_path != "")) } -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") +assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"), + "rbe with locally built clang only works on linux") # default_include_dirs --------------------------------------------------------- # @@ -335,12 +318,13 @@ config("compiler") { # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr # operations (e.g. dereferencing) into defined behavior. This avoids deletion # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 + # The older NaCl toolchain does not support the flag. And, we still want UBSan + # to catch undefined behavior related to nullptrs, so do not add this flag if + # UBSan is enabled. GCC seems to have some bugs compiling constexpr code when + # this is defined, so only enable it if using_clang. + # See: https://gcc.gnu.org/PR97913 # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { + if ((!is_nacl || is_nacl_saigo) && !is_ubsan && is_clang) { cflags += [ "-fno-delete-null-pointer-checks" ] } @@ -531,35 +515,6 @@ config("compiler") { # Linux-specific compiler flags setup. # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # 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. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - if (use_icf && (!is_apple || use_lld)) { ldflags += [ "-Wl,--icf=all" ] } @@ -627,9 +582,9 @@ config("compiler") { } } - # TODO(crbug.com/1488374): This causes binary size growth and potentially + # TODO(crbug.com/40283598): This causes binary size growth and potentially # other problems. - # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + # TODO(crbug.com/40284925): This isn't supported by Cronet's mainline llvm version. if (default_toolchain != "//build/toolchain/cros:target" && !llvm_android_mainline) { cflags += [ @@ -645,7 +600,7 @@ config("compiler") { } } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. + # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=fast" ] } else { @@ -740,6 +695,19 @@ config("compiler") { # example by disabling the optimize configuration. # TODO(pcc): Make this conditional on is_official_build rather than on gn # flags for specific features. + # + # High-end Android: While Full LTO provides a small performance improvement + # (according to Speedometer), it also results in an unacceptable increase in + # build time. Thin LTO appears to provide the best build time-optimization + # tradeoff. As of April 2024, Full LTO: + # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours + # with Thin LTO) on Chromium builders. + # - Increases Speedometer 2.1 score by 1.1% [0]. + # - Increases Speedometer 3.0 score by 1.2% [1]. + # ... over Thin LTO. + # + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000 if (!is_debug && use_thin_lto && is_a_target_toolchain) { assert(use_lld, "LTO is only supported with lld") @@ -773,6 +741,16 @@ config("compiler") { # binary size than the default setting of 100. # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # should be able to better manage binary size increases on its own. + # + # For high-end Android, 30 seems to be the right trade-off between performance + # and binary size, at least based on Speedometer. For example, increasing + # `import_instr_limit`to 50 improves Speedometer 2.1 score by 0.7% [0], while + # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size + # increases by about 2MB [2] (or 1.1%: the arm64 native code size in M124 is + # 178MB). + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000 + # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442 import_instr_limit = 30 if (is_win) { @@ -800,8 +778,10 @@ config("compiler") { # FIXME(inglorion): maybe tune these? # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. import_instr_limit = 30 - } else if (is_android && optimize_for_size) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win + } else if (is_android && (optimize_for_size || use_order_profiling)) { + # Reduce inlining for the orderfile instrumented build to mitigate + # crbug.com/330761384. + # TODO(crbug.com/40219076): Investigate if we can get the > 6% perf win # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. import_instr_limit = 30 } @@ -817,7 +797,22 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] } - # TODO(https://crbug.com/1211155): investigate why this isn't effective on + # TODO(crbug.com/335365324): Enable on other platforms. + if (is_android && !optimize_for_size) { + # Ideally the compiler would handle this automatically with PGO (see + # comments at https://crrev.com/c/5440500). + # + # Android binary size impact (as of April 2024): The arm64 native code + # size increases by ~627KB (or 0.34%: the arm64 native code size in + # M124 is 178MB). + cflags += [ + "-mllvm", + "-inlinehint-threshold=360", + ] + ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ] + } + + # TODO(crbug.com/40182783): investigate why this isn't effective on # arm32. if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] @@ -871,7 +866,7 @@ config("compiler") { ldflags += [ "-Wl,--no-rosegment" ] } - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by + # TODO(crbug.com/40242425): Cleanup undefined symbol errors caught by # --no-undefined-version. if (use_lld && !is_win && !is_mac && !is_ios) { ldflags += [ "-Wl,--undefined-version" ] @@ -895,8 +890,6 @@ config("compiler") { if (is_clang && !is_nacl && show_includes) { if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ "/clang:-H", "/clang:-fshow-skipped-includes", @@ -1074,10 +1067,10 @@ config("compiler") { # consistently apply in both Chromium and non-Chromium code *and* non-NaCl # and NaCl code. # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` + # TODO(crbug.com/40511454): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # TODO(crbug.com/40275904): Switch saigo to hardened mode once # it's rolled in. if (is_nacl_saigo) { defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] @@ -1201,7 +1194,7 @@ config("compiler_cpu_abi") { "-mf16c", "-mlzcnt", "-mbmi2", - "-mtune=haswell", + "-mtune=skylake-avx512", "-ffp-contract=fast", ] ldflags += [ "-m64", "-Wl,-O3", "-Wl,-mllvm,-march=skylake-avx512", "-Wl,-mllvm,-fp-contract=fast", "-Wl,-mllvm,-import-instr-limit=30", ] @@ -1516,7 +1509,7 @@ config("compiler_codegen") { if (current_cpu == "arm64" && !is_win && is_clang) { # Disable outlining everywhere on arm64 except Win. For more information see # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. + # TODO(crbug.com/40890229): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1602,7 +1595,7 @@ config("compiler_deterministic") { # Tells the compiler not to use absolute paths when passing the default # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. + # really need it and it can mess up the RBE cache entries. if (is_clang && (!is_nacl || is_nacl_saigo)) { cflags += [ "-no-canonical-prefixes" ] @@ -1610,7 +1603,7 @@ config("compiler_deterministic") { # with a relative path and pass relative paths to built-in # libraries. Not needed on Windows because we call the linker # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner + # We don't link on RBE, so this change is just for cleaner # internal linker invocations, for people who work on the build. if (!is_win) { ldflags += [ "-no-canonical-prefixes" ] @@ -1707,7 +1700,7 @@ config("runtime_library") { configs += [ "//build/config/clang:compiler_builtins" ] } - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia + # TODO(crbug.com/40570904): Come up with a better name for is POSIX + Fuchsia # configuration. if (is_posix || is_fuchsia) { configs += [ "//build/config/posix:runtime_library" ] @@ -1894,41 +1887,47 @@ config("default_warnings") { if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. + # Currently RBE can not handle case sensitiveness for windows well. cflags += [ "-Wno-nonportable-include-path" ] } if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474434): fix and reenable + # TODO(crbug.com/42050603): fix and reenable "-Wno-missing-field-initializers", # TODO(https://crbug.com/324953188): fix and reenable "-Wno-extra-qualification", + + # TODO(https://crbug.com/332931387): fix and reenable + "-Wno-unused-but-set-variable", ] } cflags += [ + # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now. + "-Wno-cast-function-type", + # Ignore warnings about MSVC optimization pragmas. # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 "-Wno-ignored-pragma-optimize", - # TODO(crbug.com/1343975) Evaluate and possibly enable. + # TODO(crbug.com/40231599) Evaluate and possibly enable. "-Wno-deprecated-builtins", - # TODO(crbug.com/1352183) Evaluate and possibly enable. + # TODO(crbug.com/40234766) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", - # TODO(crbug.com/1412713) Evaluate and possibly enable. + # TODO(crbug.com/40255410) Evaluate and possibly enable. "-Wno-deprecated-this-capture", - # TODO(https://crbug.com/1491833): Fix and re-enable. + # TODO(crbug.com/40285259): Fix and re-enable. "-Wno-invalid-offsetof", - # TODO(crbug.com/1494809): Evaluate and possibly enable. + # TODO(crbug.com/40286317): Evaluate and possibly enable. "-Wno-vla-extension", - # TODO(https://crbug.com/1490607): Fix and re-enable. + # TODO(crbug.com/40284799): Fix and re-enable. "-Wno-thread-safety-reference-return", ] @@ -1939,7 +1938,7 @@ config("default_warnings") { if (!is_nacl) { cflags_cc += [ - # TODO(https://crbug.com/1513724): Fix and re-enable. + # TODO(crbug.com/41486292): Fix and re-enable. "-Wno-c++11-narrowing-const-reference", ] } @@ -2137,7 +2136,7 @@ config("no_chromium_code") { # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", - # TODO(https://crbug.com/1202159): Clean up and enable. + # TODO(crbug.com/40762742): Clean up and enable. "-Wno-misleading-indentation", ] } @@ -2200,7 +2199,7 @@ config("no_rtti") { # (de)allocate memory on a different heap, which would spell trouble if pointers # to heap-allocated memory are passed over shared library boundaries. config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. + # TODO(crbug.com/40118868): Revisit after target_os flip is completed. if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { ldflags = [ "-rdynamic" ] } @@ -2456,13 +2455,16 @@ if (is_win) { # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] + if (is_official_build) { + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/. + # -O2 enables string tail merge optimization in lld. + "-Wl,-O3", + ] + } + + common_optimize_on_ldflags += [ "-Wl,--gc-sections" ] } # We cannot rely on errno being set after math functions, @@ -2555,9 +2557,26 @@ config("default_stack_frames") { } # Default "optimization on" config. +# +# High-end Android: As of April 2024, `-O2` appears to be a good default, +# particularly since a selection of "hot" targets are already using `-O3`. +# Enabling `-O3` for all targets does not change performance much (according +# to Speedometer), but regresses binary size. Using `-O3` as the default: +# - Decreases Speedometer 2.1 score by 0.2% [0]. +# - Increases Speedometer 3.0 score by 0.1% [1]. +# - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size +# in M124 is 178MB). +# ... over `-O2`. +# +# [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000 +# [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 +# [2]: https://crrev.com/c/5447532 config("optimize") { if (is_win) { cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2633,9 +2652,9 @@ config("no_optimize") { } } -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. +# Turns up the optimization level. Used to explicitly enable -O2 instead of +# -Os for select targets on platforms that use optimize_for_size. No-op +# elsewhere. config("optimize_max") { if (is_nacl && is_nacl_irt) { # The NaCl IRT is a special case and always wants its own config. @@ -2653,6 +2672,9 @@ config("optimize_max") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2665,9 +2687,9 @@ config("optimize_max") { # This config can be used to override the default settings for per-component # and whole-program optimization, optimizing the particular target for speed # instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. +# except that we use -O3 instead of -O2 on non-IRT platforms. # -# TODO(crbug.com/621335) - rework how all of these configs are related +# TODO(crbug.com/41259697) - rework how all of these configs are related # so that we don't need this disclaimer. config("optimize_speed") { if (is_nacl && is_nacl_irt) { @@ -2686,6 +2708,9 @@ config("optimize_speed") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2928,7 +2953,7 @@ config("symbols") { # sections" there. Maybe just a bug in nacl_switch_32.S. _enable_gdb_index = symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && + current_os != "zos" && use_lld && # Disable on non-fission 32-bit Android because it pushes # libcomponents_unittests over the 4gb size limit. !(is_android && !use_debug_fission && current_cpu != "x64" && @@ -2947,16 +2972,17 @@ config("symbols") { configs = [] - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { + # Compress debug on 32-bit ARM to stay under 4GB file size limit. + # https://b/243982712, https://crbug.com/1354616, https://crbug.com/334073642 + if (symbol_level == 2 && !use_debug_fission && !is_nacl && + (is_chromeos_device || is_android) && + (current_cpu == "arm" || current_cpu == "x86")) { configs += [ "//build/config:compress_debug_sections" ] } if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. + # TODO(crbug.com/40117949): Investigate missing debug info on mac. # Make sure we don't use constructor homing on mac. cflags += [ "-Xclang", diff --git a/other/CrOS/build/config/compiler/BUILD.gn b/other/CrOS/build/config/compiler/BUILD.gn index 706e7a13..a84e0634 100644 --- a/other/CrOS/build/config/compiler/BUILD.gn +++ b/other/CrOS/build/config/compiler/BUILD.gn @@ -20,7 +20,6 @@ import("//build/config/ui.gni") import("//build/config/unwind.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/cros/cros_config.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -68,10 +67,6 @@ declare_args() { # Requires profiling to be set to true. enable_full_stack_frames_for_profiling = false - # 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 = "" - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ use_polly = false @@ -149,7 +144,7 @@ declare_args() { # # Flag discussion: https://crbug.com/977230 # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and + # TODO(crbug.com/40721698): This regresses binary size by ~1MB on Android and # needs to be evaluated before enabling it there as well. init_stack_vars = !(is_android && is_official_build) @@ -202,7 +197,7 @@ declare_args() { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. + # TODO(crbug.com/40244196): Remove if the upstream default ever changes. # # This greatly reduces the size of debug builds, at the cost of # debugging information which is required by some specialized @@ -212,19 +207,9 @@ declare_args() { declare_args() { # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # 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. - # - # lld doesn't have the bug. use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) + !(is_android && use_order_profiling) && use_lld } if (is_android) { @@ -251,10 +236,8 @@ declare_args() { (clang_use_default_sample_profile || clang_sample_profile_path != "")) } -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") +assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"), + "rbe with locally built clang only works on linux") # default_include_dirs --------------------------------------------------------- # @@ -335,12 +318,13 @@ config("compiler") { # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr # operations (e.g. dereferencing) into defined behavior. This avoids deletion # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 + # The older NaCl toolchain does not support the flag. And, we still want UBSan + # to catch undefined behavior related to nullptrs, so do not add this flag if + # UBSan is enabled. GCC seems to have some bugs compiling constexpr code when + # this is defined, so only enable it if using_clang. + # See: https://gcc.gnu.org/PR97913 # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { + if ((!is_nacl || is_nacl_saigo) && !is_ubsan && is_clang) { cflags += [ "-fno-delete-null-pointer-checks" ] } @@ -531,35 +515,6 @@ config("compiler") { # Linux-specific compiler flags setup. # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # 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. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - if (use_icf && (!is_apple || use_lld)) { ldflags += [ "-Wl,--icf=all" ] } @@ -627,9 +582,9 @@ config("compiler") { } } - # TODO(crbug.com/1488374): This causes binary size growth and potentially + # TODO(crbug.com/40283598): This causes binary size growth and potentially # other problems. - # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + # TODO(crbug.com/40284925): This isn't supported by Cronet's mainline llvm version. if (default_toolchain != "//build/toolchain/cros:target" && !llvm_android_mainline) { cflags += [ @@ -645,7 +600,7 @@ config("compiler") { } } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. + # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=off" ] } else { @@ -740,6 +695,19 @@ config("compiler") { # example by disabling the optimize configuration. # TODO(pcc): Make this conditional on is_official_build rather than on gn # flags for specific features. + # + # High-end Android: While Full LTO provides a small performance improvement + # (according to Speedometer), it also results in an unacceptable increase in + # build time. Thin LTO appears to provide the best build time-optimization + # tradeoff. As of April 2024, Full LTO: + # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours + # with Thin LTO) on Chromium builders. + # - Increases Speedometer 2.1 score by 1.1% [0]. + # - Increases Speedometer 3.0 score by 1.2% [1]. + # ... over Thin LTO. + # + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000 if (!is_debug && use_thin_lto && is_a_target_toolchain) { assert(use_lld, "LTO is only supported with lld") @@ -773,6 +741,16 @@ config("compiler") { # binary size than the default setting of 100. # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # should be able to better manage binary size increases on its own. + # + # For high-end Android, 30 seems to be the right trade-off between performance + # and binary size, at least based on Speedometer. For example, increasing + # `import_instr_limit`to 50 improves Speedometer 2.1 score by 0.7% [0], while + # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size + # increases by about 2MB [2] (or 1.1%: the arm64 native code size in M124 is + # 178MB). + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000 + # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442 import_instr_limit = 30 if (is_win) { @@ -800,8 +778,10 @@ config("compiler") { # FIXME(inglorion): maybe tune these? # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. import_instr_limit = 30 - } else if (is_android && optimize_for_size) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win + } else if (is_android && (optimize_for_size || use_order_profiling)) { + # Reduce inlining for the orderfile instrumented build to mitigate + # crbug.com/330761384. + # TODO(crbug.com/40219076): Investigate if we can get the > 6% perf win # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. import_instr_limit = 30 } @@ -817,7 +797,22 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] } - # TODO(https://crbug.com/1211155): investigate why this isn't effective on + # TODO(crbug.com/335365324): Enable on other platforms. + if (is_android && !optimize_for_size) { + # Ideally the compiler would handle this automatically with PGO (see + # comments at https://crrev.com/c/5440500). + # + # Android binary size impact (as of April 2024): The arm64 native code + # size increases by ~627KB (or 0.34%: the arm64 native code size in + # M124 is 178MB). + cflags += [ + "-mllvm", + "-inlinehint-threshold=360", + ] + ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ] + } + + # TODO(crbug.com/40182783): investigate why this isn't effective on # arm32. if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] @@ -871,7 +866,7 @@ config("compiler") { ldflags += [ "-Wl,--no-rosegment" ] } - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by + # TODO(crbug.com/40242425): Cleanup undefined symbol errors caught by # --no-undefined-version. if (use_lld && !is_win && !is_mac && !is_ios) { ldflags += [ "-Wl,--undefined-version" ] @@ -895,8 +890,6 @@ config("compiler") { if (is_clang && !is_nacl && show_includes) { if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ "/clang:-H", "/clang:-fshow-skipped-includes", @@ -1073,10 +1066,10 @@ config("compiler") { # consistently apply in both Chromium and non-Chromium code *and* non-NaCl # and NaCl code. # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` + # TODO(crbug.com/40511454): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # TODO(crbug.com/40275904): Switch saigo to hardened mode once # it's rolled in. if (is_nacl_saigo) { defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] @@ -1498,7 +1491,7 @@ config("compiler_codegen") { if (current_cpu == "arm64" && !is_win && is_clang) { # Disable outlining everywhere on arm64 except Win. For more information see # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. + # TODO(crbug.com/40890229): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1584,7 +1577,7 @@ config("compiler_deterministic") { # Tells the compiler not to use absolute paths when passing the default # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. + # really need it and it can mess up the RBE cache entries. if (is_clang && (!is_nacl || is_nacl_saigo)) { cflags += [ "-no-canonical-prefixes" ] @@ -1592,7 +1585,7 @@ config("compiler_deterministic") { # with a relative path and pass relative paths to built-in # libraries. Not needed on Windows because we call the linker # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner + # We don't link on RBE, so this change is just for cleaner # internal linker invocations, for people who work on the build. if (!is_win) { ldflags += [ "-no-canonical-prefixes" ] @@ -1689,7 +1682,7 @@ config("runtime_library") { configs += [ "//build/config/clang:compiler_builtins" ] } - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia + # TODO(crbug.com/40570904): Come up with a better name for is POSIX + Fuchsia # configuration. if (is_posix || is_fuchsia) { configs += [ "//build/config/posix:runtime_library" ] @@ -1876,41 +1869,47 @@ config("default_warnings") { if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. + # Currently RBE can not handle case sensitiveness for windows well. cflags += [ "-Wno-nonportable-include-path" ] } if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474434): fix and reenable + # TODO(crbug.com/42050603): fix and reenable "-Wno-missing-field-initializers", # TODO(https://crbug.com/324953188): fix and reenable "-Wno-extra-qualification", + + # TODO(https://crbug.com/332931387): fix and reenable + "-Wno-unused-but-set-variable", ] } cflags += [ + # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now. + "-Wno-cast-function-type", + # Ignore warnings about MSVC optimization pragmas. # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 "-Wno-ignored-pragma-optimize", - # TODO(crbug.com/1343975) Evaluate and possibly enable. + # TODO(crbug.com/40231599) Evaluate and possibly enable. "-Wno-deprecated-builtins", - # TODO(crbug.com/1352183) Evaluate and possibly enable. + # TODO(crbug.com/40234766) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", - # TODO(crbug.com/1412713) Evaluate and possibly enable. + # TODO(crbug.com/40255410) Evaluate and possibly enable. "-Wno-deprecated-this-capture", - # TODO(https://crbug.com/1491833): Fix and re-enable. + # TODO(crbug.com/40285259): Fix and re-enable. "-Wno-invalid-offsetof", - # TODO(crbug.com/1494809): Evaluate and possibly enable. + # TODO(crbug.com/40286317): Evaluate and possibly enable. "-Wno-vla-extension", - # TODO(https://crbug.com/1490607): Fix and re-enable. + # TODO(crbug.com/40284799): Fix and re-enable. "-Wno-thread-safety-reference-return", ] @@ -1921,7 +1920,7 @@ config("default_warnings") { if (!is_nacl) { cflags_cc += [ - # TODO(https://crbug.com/1513724): Fix and re-enable. + # TODO(crbug.com/41486292): Fix and re-enable. "-Wno-c++11-narrowing-const-reference", ] } @@ -2119,7 +2118,7 @@ config("no_chromium_code") { # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", - # TODO(https://crbug.com/1202159): Clean up and enable. + # TODO(crbug.com/40762742): Clean up and enable. "-Wno-misleading-indentation", ] } @@ -2182,7 +2181,7 @@ config("no_rtti") { # (de)allocate memory on a different heap, which would spell trouble if pointers # to heap-allocated memory are passed over shared library boundaries. config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. + # TODO(crbug.com/40118868): Revisit after target_os flip is completed. if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { ldflags = [ "-rdynamic" ] } @@ -2422,13 +2421,16 @@ if (is_win) { # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] + if (is_official_build) { + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/. + # -O2 enables string tail merge optimization in lld. + "-Wl,-O3", + ] + } + + common_optimize_on_ldflags += [ "-Wl,--gc-sections" ] } # We cannot rely on errno being set after math functions, @@ -2489,6 +2491,11 @@ config("march_i8mm_f16") { } } +config("march_sve2") { + cflags = [ "-march=armv9-a+sve2" ] + asmflags = cflags +} + config("default_stack_frames") { if (!is_win) { if (enable_frame_pointers) { @@ -2516,9 +2523,26 @@ config("default_stack_frames") { } # Default "optimization on" config. +# +# High-end Android: As of April 2024, `-O2` appears to be a good default, +# particularly since a selection of "hot" targets are already using `-O3`. +# Enabling `-O3` for all targets does not change performance much (according +# to Speedometer), but regresses binary size. Using `-O3` as the default: +# - Decreases Speedometer 2.1 score by 0.2% [0]. +# - Increases Speedometer 3.0 score by 0.1% [1]. +# - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size +# in M124 is 178MB). +# ... over `-O2`. +# +# [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000 +# [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 +# [2]: https://crrev.com/c/5447532 config("optimize") { if (is_win) { cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2594,9 +2618,9 @@ config("no_optimize") { } } -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. +# Turns up the optimization level. Used to explicitly enable -O2 instead of +# -Os for select targets on platforms that use optimize_for_size. No-op +# elsewhere. config("optimize_max") { if (is_nacl && is_nacl_irt) { # The NaCl IRT is a special case and always wants its own config. @@ -2614,6 +2638,9 @@ config("optimize_max") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2626,9 +2653,9 @@ config("optimize_max") { # This config can be used to override the default settings for per-component # and whole-program optimization, optimizing the particular target for speed # instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. +# except that we use -O3 instead of -O2 on non-IRT platforms. # -# TODO(crbug.com/621335) - rework how all of these configs are related +# TODO(crbug.com/41259697) - rework how all of these configs are related # so that we don't need this disclaimer. config("optimize_speed") { if (is_nacl && is_nacl_irt) { @@ -2647,6 +2674,9 @@ config("optimize_speed") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2889,7 +2919,7 @@ config("symbols") { # sections" there. Maybe just a bug in nacl_switch_32.S. _enable_gdb_index = symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && + current_os != "zos" && use_lld && # Disable on non-fission 32-bit Android because it pushes # libcomponents_unittests over the 4gb size limit. !(is_android && !use_debug_fission && current_cpu != "x64" && @@ -2908,16 +2938,17 @@ config("symbols") { configs = [] - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { + # Compress debug on 32-bit ARM to stay under 4GB file size limit. + # https://b/243982712, https://crbug.com/1354616, https://crbug.com/334073642 + if (symbol_level == 2 && !use_debug_fission && !is_nacl && + (is_chromeos_device || is_android) && + (current_cpu == "arm" || current_cpu == "x86")) { configs += [ "//build/config:compress_debug_sections" ] } if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. + # TODO(crbug.com/40117949): Investigate missing debug info on mac. # Make sure we don't use constructor homing on mac. cflags += [ "-Xclang", diff --git a/other/SSE2/build/config/compiler/BUILD.gn b/other/SSE2/build/config/compiler/BUILD.gn index 66b7aa39..d60e9e3e 100644 --- a/other/SSE2/build/config/compiler/BUILD.gn +++ b/other/SSE2/build/config/compiler/BUILD.gn @@ -20,7 +20,6 @@ import("//build/config/ui.gni") import("//build/config/unwind.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/cros/cros_config.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -68,10 +67,6 @@ declare_args() { # Requires profiling to be set to true. enable_full_stack_frames_for_profiling = false - # 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 = "" - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ use_polly = false @@ -149,7 +144,7 @@ declare_args() { # # Flag discussion: https://crbug.com/977230 # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and + # TODO(crbug.com/40721698): This regresses binary size by ~1MB on Android and # needs to be evaluated before enabling it there as well. init_stack_vars = !(is_android && is_official_build) @@ -202,7 +197,7 @@ declare_args() { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. + # TODO(crbug.com/40244196): Remove if the upstream default ever changes. # # This greatly reduces the size of debug builds, at the cost of # debugging information which is required by some specialized @@ -212,19 +207,9 @@ declare_args() { declare_args() { # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # 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. - # - # lld doesn't have the bug. use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) + !(is_android && use_order_profiling) && use_lld } if (is_android) { @@ -251,10 +236,8 @@ declare_args() { (clang_use_default_sample_profile || clang_sample_profile_path != "")) } -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") +assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"), + "rbe with locally built clang only works on linux") # default_include_dirs --------------------------------------------------------- # @@ -335,12 +318,13 @@ config("compiler") { # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr # operations (e.g. dereferencing) into defined behavior. This avoids deletion # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 + # The older NaCl toolchain does not support the flag. And, we still want UBSan + # to catch undefined behavior related to nullptrs, so do not add this flag if + # UBSan is enabled. GCC seems to have some bugs compiling constexpr code when + # this is defined, so only enable it if using_clang. + # See: https://gcc.gnu.org/PR97913 # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { + if ((!is_nacl || is_nacl_saigo) && !is_ubsan && is_clang) { cflags += [ "-fno-delete-null-pointer-checks" ] } @@ -531,35 +515,6 @@ config("compiler") { # Linux-specific compiler flags setup. # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # 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. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - if (use_icf && (!is_apple || use_lld)) { ldflags += [ "-Wl,--icf=all" ] } @@ -627,9 +582,9 @@ config("compiler") { } } - # TODO(crbug.com/1488374): This causes binary size growth and potentially + # TODO(crbug.com/40283598): This causes binary size growth and potentially # other problems. - # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + # TODO(crbug.com/40284925): This isn't supported by Cronet's mainline llvm version. if (default_toolchain != "//build/toolchain/cros:target" && !llvm_android_mainline) { cflags += [ @@ -645,7 +600,7 @@ config("compiler") { } } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. + # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=off" ] } else { @@ -740,6 +695,19 @@ config("compiler") { # example by disabling the optimize configuration. # TODO(pcc): Make this conditional on is_official_build rather than on gn # flags for specific features. + # + # High-end Android: While Full LTO provides a small performance improvement + # (according to Speedometer), it also results in an unacceptable increase in + # build time. Thin LTO appears to provide the best build time-optimization + # tradeoff. As of April 2024, Full LTO: + # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours + # with Thin LTO) on Chromium builders. + # - Increases Speedometer 2.1 score by 1.1% [0]. + # - Increases Speedometer 3.0 score by 1.2% [1]. + # ... over Thin LTO. + # + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000 if (!is_debug && use_thin_lto && is_a_target_toolchain) { assert(use_lld, "LTO is only supported with lld") @@ -773,6 +741,16 @@ config("compiler") { # binary size than the default setting of 100. # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # should be able to better manage binary size increases on its own. + # + # For high-end Android, 30 seems to be the right trade-off between performance + # and binary size, at least based on Speedometer. For example, increasing + # `import_instr_limit`to 50 improves Speedometer 2.1 score by 0.7% [0], while + # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size + # increases by about 2MB [2] (or 1.1%: the arm64 native code size in M124 is + # 178MB). + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000 + # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442 import_instr_limit = 30 if (is_win) { @@ -800,8 +778,10 @@ config("compiler") { # FIXME(inglorion): maybe tune these? # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. import_instr_limit = 30 - } else if (is_android && optimize_for_size) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win + } else if (is_android && (optimize_for_size || use_order_profiling)) { + # Reduce inlining for the orderfile instrumented build to mitigate + # crbug.com/330761384. + # TODO(crbug.com/40219076): Investigate if we can get the > 6% perf win # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. import_instr_limit = 30 } @@ -817,7 +797,22 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] } - # TODO(https://crbug.com/1211155): investigate why this isn't effective on + # TODO(crbug.com/335365324): Enable on other platforms. + if (is_android && !optimize_for_size) { + # Ideally the compiler would handle this automatically with PGO (see + # comments at https://crrev.com/c/5440500). + # + # Android binary size impact (as of April 2024): The arm64 native code + # size increases by ~627KB (or 0.34%: the arm64 native code size in + # M124 is 178MB). + cflags += [ + "-mllvm", + "-inlinehint-threshold=360", + ] + ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ] + } + + # TODO(crbug.com/40182783): investigate why this isn't effective on # arm32. if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] @@ -871,7 +866,7 @@ config("compiler") { ldflags += [ "-Wl,--no-rosegment" ] } - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by + # TODO(crbug.com/40242425): Cleanup undefined symbol errors caught by # --no-undefined-version. if (use_lld && !is_win && !is_mac && !is_ios) { ldflags += [ "-Wl,--undefined-version" ] @@ -895,8 +890,6 @@ config("compiler") { if (is_clang && !is_nacl && show_includes) { if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ "/clang:-H", "/clang:-fshow-skipped-includes", @@ -1073,10 +1066,10 @@ config("compiler") { # consistently apply in both Chromium and non-Chromium code *and* non-NaCl # and NaCl code. # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` + # TODO(crbug.com/40511454): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # TODO(crbug.com/40275904): Switch saigo to hardened mode once # it's rolled in. if (is_nacl_saigo) { defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] @@ -1501,7 +1494,7 @@ config("compiler_codegen") { if (current_cpu == "arm64" && !is_win && is_clang) { # Disable outlining everywhere on arm64 except Win. For more information see # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. + # TODO(crbug.com/40890229): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1587,7 +1580,7 @@ config("compiler_deterministic") { # Tells the compiler not to use absolute paths when passing the default # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. + # really need it and it can mess up the RBE cache entries. if (is_clang && (!is_nacl || is_nacl_saigo)) { cflags += [ "-no-canonical-prefixes" ] @@ -1595,7 +1588,7 @@ config("compiler_deterministic") { # with a relative path and pass relative paths to built-in # libraries. Not needed on Windows because we call the linker # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner + # We don't link on RBE, so this change is just for cleaner # internal linker invocations, for people who work on the build. if (!is_win) { ldflags += [ "-no-canonical-prefixes" ] @@ -1692,7 +1685,7 @@ config("runtime_library") { configs += [ "//build/config/clang:compiler_builtins" ] } - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia + # TODO(crbug.com/40570904): Come up with a better name for is POSIX + Fuchsia # configuration. if (is_posix || is_fuchsia) { configs += [ "//build/config/posix:runtime_library" ] @@ -1879,41 +1872,47 @@ config("default_warnings") { if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. + # Currently RBE can not handle case sensitiveness for windows well. cflags += [ "-Wno-nonportable-include-path" ] } if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474434): fix and reenable + # TODO(crbug.com/42050603): fix and reenable "-Wno-missing-field-initializers", # TODO(https://crbug.com/324953188): fix and reenable "-Wno-extra-qualification", + + # TODO(https://crbug.com/332931387): fix and reenable + "-Wno-unused-but-set-variable", ] } cflags += [ + # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now. + "-Wno-cast-function-type", + # Ignore warnings about MSVC optimization pragmas. # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 "-Wno-ignored-pragma-optimize", - # TODO(crbug.com/1343975) Evaluate and possibly enable. + # TODO(crbug.com/40231599) Evaluate and possibly enable. "-Wno-deprecated-builtins", - # TODO(crbug.com/1352183) Evaluate and possibly enable. + # TODO(crbug.com/40234766) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", - # TODO(crbug.com/1412713) Evaluate and possibly enable. + # TODO(crbug.com/40255410) Evaluate and possibly enable. "-Wno-deprecated-this-capture", - # TODO(https://crbug.com/1491833): Fix and re-enable. + # TODO(crbug.com/40285259): Fix and re-enable. "-Wno-invalid-offsetof", - # TODO(crbug.com/1494809): Evaluate and possibly enable. + # TODO(crbug.com/40286317): Evaluate and possibly enable. "-Wno-vla-extension", - # TODO(https://crbug.com/1490607): Fix and re-enable. + # TODO(crbug.com/40284799): Fix and re-enable. "-Wno-thread-safety-reference-return", ] @@ -1924,7 +1923,7 @@ config("default_warnings") { if (!is_nacl) { cflags_cc += [ - # TODO(https://crbug.com/1513724): Fix and re-enable. + # TODO(crbug.com/41486292): Fix and re-enable. "-Wno-c++11-narrowing-const-reference", ] } @@ -2122,7 +2121,7 @@ config("no_chromium_code") { # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", - # TODO(https://crbug.com/1202159): Clean up and enable. + # TODO(crbug.com/40762742): Clean up and enable. "-Wno-misleading-indentation", ] } @@ -2185,7 +2184,7 @@ config("no_rtti") { # (de)allocate memory on a different heap, which would spell trouble if pointers # to heap-allocated memory are passed over shared library boundaries. config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. + # TODO(crbug.com/40118868): Revisit after target_os flip is completed. if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { ldflags = [ "-rdynamic" ] } @@ -2425,13 +2424,16 @@ if (is_win) { # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] + if (is_official_build) { + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/. + # -O2 enables string tail merge optimization in lld. + "-Wl,-O3", + ] + } + + common_optimize_on_ldflags += [ "-Wl,--gc-sections" ] } # We cannot rely on errno being set after math functions, @@ -2492,6 +2494,11 @@ config("march_i8mm_f16") { } } +config("march_sve2") { + cflags = [ "-march=armv9-a+sve2" ] + asmflags = cflags +} + config("default_stack_frames") { if (!is_win) { if (enable_frame_pointers) { @@ -2519,9 +2526,26 @@ config("default_stack_frames") { } # Default "optimization on" config. +# +# High-end Android: As of April 2024, `-O2` appears to be a good default, +# particularly since a selection of "hot" targets are already using `-O3`. +# Enabling `-O3` for all targets does not change performance much (according +# to Speedometer), but regresses binary size. Using `-O3` as the default: +# - Decreases Speedometer 2.1 score by 0.2% [0]. +# - Increases Speedometer 3.0 score by 0.1% [1]. +# - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size +# in M124 is 178MB). +# ... over `-O2`. +# +# [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000 +# [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 +# [2]: https://crrev.com/c/5447532 config("optimize") { if (is_win) { cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2597,9 +2621,9 @@ config("no_optimize") { } } -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. +# Turns up the optimization level. Used to explicitly enable -O2 instead of +# -Os for select targets on platforms that use optimize_for_size. No-op +# elsewhere. config("optimize_max") { if (is_nacl && is_nacl_irt) { # The NaCl IRT is a special case and always wants its own config. @@ -2617,6 +2641,9 @@ config("optimize_max") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2629,9 +2656,9 @@ config("optimize_max") { # This config can be used to override the default settings for per-component # and whole-program optimization, optimizing the particular target for speed # instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. +# except that we use -O3 instead of -O2 on non-IRT platforms. # -# TODO(crbug.com/621335) - rework how all of these configs are related +# TODO(crbug.com/41259697) - rework how all of these configs are related # so that we don't need this disclaimer. config("optimize_speed") { if (is_nacl && is_nacl_irt) { @@ -2650,6 +2677,9 @@ config("optimize_speed") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2892,7 +2922,7 @@ config("symbols") { # sections" there. Maybe just a bug in nacl_switch_32.S. _enable_gdb_index = symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && + current_os != "zos" && use_lld && # Disable on non-fission 32-bit Android because it pushes # libcomponents_unittests over the 4gb size limit. !(is_android && !use_debug_fission && current_cpu != "x64" && @@ -2911,16 +2941,17 @@ config("symbols") { configs = [] - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { + # Compress debug on 32-bit ARM to stay under 4GB file size limit. + # https://b/243982712, https://crbug.com/1354616, https://crbug.com/334073642 + if (symbol_level == 2 && !use_debug_fission && !is_nacl && + (is_chromeos_device || is_android) && + (current_cpu == "arm" || current_cpu == "x86")) { configs += [ "//build/config:compress_debug_sections" ] } if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. + # TODO(crbug.com/40117949): Investigate missing debug info on mac. # Make sure we don't use constructor homing on mac. cflags += [ "-Xclang", diff --git a/other/SSE3/build/config/compiler/BUILD.gn b/other/SSE3/build/config/compiler/BUILD.gn index e85e337e..e0634c5b 100644 --- a/other/SSE3/build/config/compiler/BUILD.gn +++ b/other/SSE3/build/config/compiler/BUILD.gn @@ -20,7 +20,6 @@ import("//build/config/ui.gni") import("//build/config/unwind.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/cros/cros_config.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -68,10 +67,6 @@ declare_args() { # Requires profiling to be set to true. enable_full_stack_frames_for_profiling = false - # 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 = "" - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ use_polly = false @@ -149,7 +144,7 @@ declare_args() { # # Flag discussion: https://crbug.com/977230 # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and + # TODO(crbug.com/40721698): This regresses binary size by ~1MB on Android and # needs to be evaluated before enabling it there as well. init_stack_vars = !(is_android && is_official_build) @@ -202,7 +197,7 @@ declare_args() { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. + # TODO(crbug.com/40244196): Remove if the upstream default ever changes. # # This greatly reduces the size of debug builds, at the cost of # debugging information which is required by some specialized @@ -212,19 +207,9 @@ declare_args() { declare_args() { # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # 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. - # - # lld doesn't have the bug. use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) + !(is_android && use_order_profiling) && use_lld } if (is_android) { @@ -251,10 +236,8 @@ declare_args() { (clang_use_default_sample_profile || clang_sample_profile_path != "")) } -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") +assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"), + "rbe with locally built clang only works on linux") # default_include_dirs --------------------------------------------------------- # @@ -335,12 +318,13 @@ config("compiler") { # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr # operations (e.g. dereferencing) into defined behavior. This avoids deletion # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 + # The older NaCl toolchain does not support the flag. And, we still want UBSan + # to catch undefined behavior related to nullptrs, so do not add this flag if + # UBSan is enabled. GCC seems to have some bugs compiling constexpr code when + # this is defined, so only enable it if using_clang. + # See: https://gcc.gnu.org/PR97913 # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { + if ((!is_nacl || is_nacl_saigo) && !is_ubsan && is_clang) { cflags += [ "-fno-delete-null-pointer-checks" ] } @@ -531,35 +515,6 @@ config("compiler") { # Linux-specific compiler flags setup. # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # 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. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - if (use_icf && (!is_apple || use_lld)) { ldflags += [ "-Wl,--icf=all" ] } @@ -627,9 +582,9 @@ config("compiler") { } } - # TODO(crbug.com/1488374): This causes binary size growth and potentially + # TODO(crbug.com/40283598): This causes binary size growth and potentially # other problems. - # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + # TODO(crbug.com/40284925): This isn't supported by Cronet's mainline llvm version. if (default_toolchain != "//build/toolchain/cros:target" && !llvm_android_mainline) { cflags += [ @@ -645,7 +600,7 @@ config("compiler") { } } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. + # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=off" ] } else { @@ -740,6 +695,19 @@ config("compiler") { # example by disabling the optimize configuration. # TODO(pcc): Make this conditional on is_official_build rather than on gn # flags for specific features. + # + # High-end Android: While Full LTO provides a small performance improvement + # (according to Speedometer), it also results in an unacceptable increase in + # build time. Thin LTO appears to provide the best build time-optimization + # tradeoff. As of April 2024, Full LTO: + # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours + # with Thin LTO) on Chromium builders. + # - Increases Speedometer 2.1 score by 1.1% [0]. + # - Increases Speedometer 3.0 score by 1.2% [1]. + # ... over Thin LTO. + # + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000 if (!is_debug && use_thin_lto && is_a_target_toolchain) { assert(use_lld, "LTO is only supported with lld") @@ -773,6 +741,16 @@ config("compiler") { # binary size than the default setting of 100. # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # should be able to better manage binary size increases on its own. + # + # For high-end Android, 30 seems to be the right trade-off between performance + # and binary size, at least based on Speedometer. For example, increasing + # `import_instr_limit`to 50 improves Speedometer 2.1 score by 0.7% [0], while + # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size + # increases by about 2MB [2] (or 1.1%: the arm64 native code size in M124 is + # 178MB). + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000 + # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442 import_instr_limit = 30 if (is_win) { @@ -800,8 +778,10 @@ config("compiler") { # FIXME(inglorion): maybe tune these? # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. import_instr_limit = 30 - } else if (is_android && optimize_for_size) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win + } else if (is_android && (optimize_for_size || use_order_profiling)) { + # Reduce inlining for the orderfile instrumented build to mitigate + # crbug.com/330761384. + # TODO(crbug.com/40219076): Investigate if we can get the > 6% perf win # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. import_instr_limit = 30 } @@ -817,7 +797,22 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] } - # TODO(https://crbug.com/1211155): investigate why this isn't effective on + # TODO(crbug.com/335365324): Enable on other platforms. + if (is_android && !optimize_for_size) { + # Ideally the compiler would handle this automatically with PGO (see + # comments at https://crrev.com/c/5440500). + # + # Android binary size impact (as of April 2024): The arm64 native code + # size increases by ~627KB (or 0.34%: the arm64 native code size in + # M124 is 178MB). + cflags += [ + "-mllvm", + "-inlinehint-threshold=360", + ] + ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ] + } + + # TODO(crbug.com/40182783): investigate why this isn't effective on # arm32. if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] @@ -871,7 +866,7 @@ config("compiler") { ldflags += [ "-Wl,--no-rosegment" ] } - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by + # TODO(crbug.com/40242425): Cleanup undefined symbol errors caught by # --no-undefined-version. if (use_lld && !is_win && !is_mac && !is_ios) { ldflags += [ "-Wl,--undefined-version" ] @@ -895,8 +890,6 @@ config("compiler") { if (is_clang && !is_nacl && show_includes) { if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ "/clang:-H", "/clang:-fshow-skipped-includes", @@ -1073,10 +1066,10 @@ config("compiler") { # consistently apply in both Chromium and non-Chromium code *and* non-NaCl # and NaCl code. # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` + # TODO(crbug.com/40511454): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # TODO(crbug.com/40275904): Switch saigo to hardened mode once # it's rolled in. if (is_nacl_saigo) { defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] @@ -1496,7 +1489,7 @@ config("compiler_codegen") { if (current_cpu == "arm64" && !is_win && is_clang) { # Disable outlining everywhere on arm64 except Win. For more information see # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. + # TODO(crbug.com/40890229): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1582,7 +1575,7 @@ config("compiler_deterministic") { # Tells the compiler not to use absolute paths when passing the default # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. + # really need it and it can mess up the RBE cache entries. if (is_clang && (!is_nacl || is_nacl_saigo)) { cflags += [ "-no-canonical-prefixes" ] @@ -1590,7 +1583,7 @@ config("compiler_deterministic") { # with a relative path and pass relative paths to built-in # libraries. Not needed on Windows because we call the linker # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner + # We don't link on RBE, so this change is just for cleaner # internal linker invocations, for people who work on the build. if (!is_win) { ldflags += [ "-no-canonical-prefixes" ] @@ -1687,7 +1680,7 @@ config("runtime_library") { configs += [ "//build/config/clang:compiler_builtins" ] } - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia + # TODO(crbug.com/40570904): Come up with a better name for is POSIX + Fuchsia # configuration. if (is_posix || is_fuchsia) { configs += [ "//build/config/posix:runtime_library" ] @@ -1874,41 +1867,47 @@ config("default_warnings") { if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. + # Currently RBE can not handle case sensitiveness for windows well. cflags += [ "-Wno-nonportable-include-path" ] } if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474434): fix and reenable + # TODO(crbug.com/42050603): fix and reenable "-Wno-missing-field-initializers", # TODO(https://crbug.com/324953188): fix and reenable "-Wno-extra-qualification", + + # TODO(https://crbug.com/332931387): fix and reenable + "-Wno-unused-but-set-variable", ] } cflags += [ + # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now. + "-Wno-cast-function-type", + # Ignore warnings about MSVC optimization pragmas. # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 "-Wno-ignored-pragma-optimize", - # TODO(crbug.com/1343975) Evaluate and possibly enable. + # TODO(crbug.com/40231599) Evaluate and possibly enable. "-Wno-deprecated-builtins", - # TODO(crbug.com/1352183) Evaluate and possibly enable. + # TODO(crbug.com/40234766) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", - # TODO(crbug.com/1412713) Evaluate and possibly enable. + # TODO(crbug.com/40255410) Evaluate and possibly enable. "-Wno-deprecated-this-capture", - # TODO(https://crbug.com/1491833): Fix and re-enable. + # TODO(crbug.com/40285259): Fix and re-enable. "-Wno-invalid-offsetof", - # TODO(crbug.com/1494809): Evaluate and possibly enable. + # TODO(crbug.com/40286317): Evaluate and possibly enable. "-Wno-vla-extension", - # TODO(https://crbug.com/1490607): Fix and re-enable. + # TODO(crbug.com/40284799): Fix and re-enable. "-Wno-thread-safety-reference-return", ] @@ -1919,7 +1918,7 @@ config("default_warnings") { if (!is_nacl) { cflags_cc += [ - # TODO(https://crbug.com/1513724): Fix and re-enable. + # TODO(crbug.com/41486292): Fix and re-enable. "-Wno-c++11-narrowing-const-reference", ] } @@ -2117,7 +2116,7 @@ config("no_chromium_code") { # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", - # TODO(https://crbug.com/1202159): Clean up and enable. + # TODO(crbug.com/40762742): Clean up and enable. "-Wno-misleading-indentation", ] } @@ -2180,7 +2179,7 @@ config("no_rtti") { # (de)allocate memory on a different heap, which would spell trouble if pointers # to heap-allocated memory are passed over shared library boundaries. config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. + # TODO(crbug.com/40118868): Revisit after target_os flip is completed. if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { ldflags = [ "-rdynamic" ] } @@ -2417,13 +2416,16 @@ if (is_win) { # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] + if (is_official_build) { + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/. + # -O2 enables string tail merge optimization in lld. + "-Wl,-O3", + ] + } + + common_optimize_on_ldflags += [ "-Wl,--gc-sections" ] } # We cannot rely on errno being set after math functions, @@ -2484,6 +2486,11 @@ config("march_i8mm_f16") { } } +config("march_sve2") { + cflags = [ "-march=armv9-a+sve2" ] + asmflags = cflags +} + config("default_stack_frames") { if (!is_win) { if (enable_frame_pointers) { @@ -2511,9 +2518,26 @@ config("default_stack_frames") { } # Default "optimization on" config. +# +# High-end Android: As of April 2024, `-O2` appears to be a good default, +# particularly since a selection of "hot" targets are already using `-O3`. +# Enabling `-O3` for all targets does not change performance much (according +# to Speedometer), but regresses binary size. Using `-O3` as the default: +# - Decreases Speedometer 2.1 score by 0.2% [0]. +# - Increases Speedometer 3.0 score by 0.1% [1]. +# - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size +# in M124 is 178MB). +# ... over `-O2`. +# +# [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000 +# [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 +# [2]: https://crrev.com/c/5447532 config("optimize") { if (is_win) { cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2589,9 +2613,9 @@ config("no_optimize") { } } -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. +# Turns up the optimization level. Used to explicitly enable -O2 instead of +# -Os for select targets on platforms that use optimize_for_size. No-op +# elsewhere. config("optimize_max") { if (is_nacl && is_nacl_irt) { # The NaCl IRT is a special case and always wants its own config. @@ -2609,6 +2633,9 @@ config("optimize_max") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2621,9 +2648,9 @@ config("optimize_max") { # This config can be used to override the default settings for per-component # and whole-program optimization, optimizing the particular target for speed # instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. +# except that we use -O3 instead of -O2 on non-IRT platforms. # -# TODO(crbug.com/621335) - rework how all of these configs are related +# TODO(crbug.com/41259697) - rework how all of these configs are related # so that we don't need this disclaimer. config("optimize_speed") { if (is_nacl && is_nacl_irt) { @@ -2642,6 +2669,9 @@ config("optimize_speed") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2884,7 +2914,7 @@ config("symbols") { # sections" there. Maybe just a bug in nacl_switch_32.S. _enable_gdb_index = symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && + current_os != "zos" && use_lld && # Disable on non-fission 32-bit Android because it pushes # libcomponents_unittests over the 4gb size limit. !(is_android && !use_debug_fission && current_cpu != "x64" && @@ -2903,16 +2933,17 @@ config("symbols") { configs = [] - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { + # Compress debug on 32-bit ARM to stay under 4GB file size limit. + # https://b/243982712, https://crbug.com/1354616, https://crbug.com/334073642 + if (symbol_level == 2 && !use_debug_fission && !is_nacl && + (is_chromeos_device || is_android) && + (current_cpu == "arm" || current_cpu == "x86")) { configs += [ "//build/config:compress_debug_sections" ] } if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. + # TODO(crbug.com/40117949): Investigate missing debug info on mac. # Make sure we don't use constructor homing on mac. cflags += [ "-Xclang", diff --git a/other/SSE4.1/build/config/compiler/BUILD.gn b/other/SSE4.1/build/config/compiler/BUILD.gn index bd8ca630..d50c5cfe 100644 --- a/other/SSE4.1/build/config/compiler/BUILD.gn +++ b/other/SSE4.1/build/config/compiler/BUILD.gn @@ -20,7 +20,6 @@ import("//build/config/ui.gni") import("//build/config/unwind.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/cros/cros_config.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -68,10 +67,6 @@ declare_args() { # Requires profiling to be set to true. enable_full_stack_frames_for_profiling = false - # 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 = "" - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ use_polly = false @@ -149,7 +144,7 @@ declare_args() { # # Flag discussion: https://crbug.com/977230 # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and + # TODO(crbug.com/40721698): This regresses binary size by ~1MB on Android and # needs to be evaluated before enabling it there as well. init_stack_vars = !(is_android && is_official_build) @@ -202,7 +197,7 @@ declare_args() { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. + # TODO(crbug.com/40244196): Remove if the upstream default ever changes. # # This greatly reduces the size of debug builds, at the cost of # debugging information which is required by some specialized @@ -212,19 +207,9 @@ declare_args() { declare_args() { # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # 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. - # - # lld doesn't have the bug. use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) + !(is_android && use_order_profiling) && use_lld } if (is_android) { @@ -251,10 +236,8 @@ declare_args() { (clang_use_default_sample_profile || clang_sample_profile_path != "")) } -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") +assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"), + "rbe with locally built clang only works on linux") # default_include_dirs --------------------------------------------------------- # @@ -335,12 +318,13 @@ config("compiler") { # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr # operations (e.g. dereferencing) into defined behavior. This avoids deletion # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 + # The older NaCl toolchain does not support the flag. And, we still want UBSan + # to catch undefined behavior related to nullptrs, so do not add this flag if + # UBSan is enabled. GCC seems to have some bugs compiling constexpr code when + # this is defined, so only enable it if using_clang. + # See: https://gcc.gnu.org/PR97913 # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { + if ((!is_nacl || is_nacl_saigo) && !is_ubsan && is_clang) { cflags += [ "-fno-delete-null-pointer-checks" ] } @@ -531,35 +515,6 @@ config("compiler") { # Linux-specific compiler flags setup. # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # 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. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - if (use_icf && (!is_apple || use_lld)) { ldflags += [ "-Wl,--icf=all" ] } @@ -627,9 +582,9 @@ config("compiler") { } } - # TODO(crbug.com/1488374): This causes binary size growth and potentially + # TODO(crbug.com/40283598): This causes binary size growth and potentially # other problems. - # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + # TODO(crbug.com/40284925): This isn't supported by Cronet's mainline llvm version. if (default_toolchain != "//build/toolchain/cros:target" && !llvm_android_mainline) { cflags += [ @@ -645,7 +600,7 @@ config("compiler") { } } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. + # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=off" ] } else { @@ -740,6 +695,19 @@ config("compiler") { # example by disabling the optimize configuration. # TODO(pcc): Make this conditional on is_official_build rather than on gn # flags for specific features. + # + # High-end Android: While Full LTO provides a small performance improvement + # (according to Speedometer), it also results in an unacceptable increase in + # build time. Thin LTO appears to provide the best build time-optimization + # tradeoff. As of April 2024, Full LTO: + # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours + # with Thin LTO) on Chromium builders. + # - Increases Speedometer 2.1 score by 1.1% [0]. + # - Increases Speedometer 3.0 score by 1.2% [1]. + # ... over Thin LTO. + # + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000 if (!is_debug && use_thin_lto && is_a_target_toolchain) { assert(use_lld, "LTO is only supported with lld") @@ -773,6 +741,16 @@ config("compiler") { # binary size than the default setting of 100. # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # should be able to better manage binary size increases on its own. + # + # For high-end Android, 30 seems to be the right trade-off between performance + # and binary size, at least based on Speedometer. For example, increasing + # `import_instr_limit`to 50 improves Speedometer 2.1 score by 0.7% [0], while + # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size + # increases by about 2MB [2] (or 1.1%: the arm64 native code size in M124 is + # 178MB). + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000 + # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442 import_instr_limit = 30 if (is_win) { @@ -800,8 +778,10 @@ config("compiler") { # FIXME(inglorion): maybe tune these? # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. import_instr_limit = 30 - } else if (is_android && optimize_for_size) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win + } else if (is_android && (optimize_for_size || use_order_profiling)) { + # Reduce inlining for the orderfile instrumented build to mitigate + # crbug.com/330761384. + # TODO(crbug.com/40219076): Investigate if we can get the > 6% perf win # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. import_instr_limit = 30 } @@ -817,7 +797,22 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] } - # TODO(https://crbug.com/1211155): investigate why this isn't effective on + # TODO(crbug.com/335365324): Enable on other platforms. + if (is_android && !optimize_for_size) { + # Ideally the compiler would handle this automatically with PGO (see + # comments at https://crrev.com/c/5440500). + # + # Android binary size impact (as of April 2024): The arm64 native code + # size increases by ~627KB (or 0.34%: the arm64 native code size in + # M124 is 178MB). + cflags += [ + "-mllvm", + "-inlinehint-threshold=360", + ] + ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ] + } + + # TODO(crbug.com/40182783): investigate why this isn't effective on # arm32. if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] @@ -871,7 +866,7 @@ config("compiler") { ldflags += [ "-Wl,--no-rosegment" ] } - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by + # TODO(crbug.com/40242425): Cleanup undefined symbol errors caught by # --no-undefined-version. if (use_lld && !is_win && !is_mac && !is_ios) { ldflags += [ "-Wl,--undefined-version" ] @@ -895,8 +890,6 @@ config("compiler") { if (is_clang && !is_nacl && show_includes) { if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ "/clang:-H", "/clang:-fshow-skipped-includes", @@ -1073,10 +1066,10 @@ config("compiler") { # consistently apply in both Chromium and non-Chromium code *and* non-NaCl # and NaCl code. # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` + # TODO(crbug.com/40511454): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # TODO(crbug.com/40275904): Switch saigo to hardened mode once # it's rolled in. if (is_nacl_saigo) { defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] @@ -1498,7 +1491,7 @@ config("compiler_codegen") { if (current_cpu == "arm64" && !is_win && is_clang) { # Disable outlining everywhere on arm64 except Win. For more information see # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. + # TODO(crbug.com/40890229): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1584,7 +1577,7 @@ config("compiler_deterministic") { # Tells the compiler not to use absolute paths when passing the default # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. + # really need it and it can mess up the RBE cache entries. if (is_clang && (!is_nacl || is_nacl_saigo)) { cflags += [ "-no-canonical-prefixes" ] @@ -1592,7 +1585,7 @@ config("compiler_deterministic") { # with a relative path and pass relative paths to built-in # libraries. Not needed on Windows because we call the linker # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner + # We don't link on RBE, so this change is just for cleaner # internal linker invocations, for people who work on the build. if (!is_win) { ldflags += [ "-no-canonical-prefixes" ] @@ -1689,7 +1682,7 @@ config("runtime_library") { configs += [ "//build/config/clang:compiler_builtins" ] } - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia + # TODO(crbug.com/40570904): Come up with a better name for is POSIX + Fuchsia # configuration. if (is_posix || is_fuchsia) { configs += [ "//build/config/posix:runtime_library" ] @@ -1876,41 +1869,47 @@ config("default_warnings") { if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. + # Currently RBE can not handle case sensitiveness for windows well. cflags += [ "-Wno-nonportable-include-path" ] } if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474434): fix and reenable + # TODO(crbug.com/42050603): fix and reenable "-Wno-missing-field-initializers", # TODO(https://crbug.com/324953188): fix and reenable "-Wno-extra-qualification", + + # TODO(https://crbug.com/332931387): fix and reenable + "-Wno-unused-but-set-variable", ] } cflags += [ + # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now. + "-Wno-cast-function-type", + # Ignore warnings about MSVC optimization pragmas. # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 "-Wno-ignored-pragma-optimize", - # TODO(crbug.com/1343975) Evaluate and possibly enable. + # TODO(crbug.com/40231599) Evaluate and possibly enable. "-Wno-deprecated-builtins", - # TODO(crbug.com/1352183) Evaluate and possibly enable. + # TODO(crbug.com/40234766) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", - # TODO(crbug.com/1412713) Evaluate and possibly enable. + # TODO(crbug.com/40255410) Evaluate and possibly enable. "-Wno-deprecated-this-capture", - # TODO(https://crbug.com/1491833): Fix and re-enable. + # TODO(crbug.com/40285259): Fix and re-enable. "-Wno-invalid-offsetof", - # TODO(crbug.com/1494809): Evaluate and possibly enable. + # TODO(crbug.com/40286317): Evaluate and possibly enable. "-Wno-vla-extension", - # TODO(https://crbug.com/1490607): Fix and re-enable. + # TODO(crbug.com/40284799): Fix and re-enable. "-Wno-thread-safety-reference-return", ] @@ -1921,7 +1920,7 @@ config("default_warnings") { if (!is_nacl) { cflags_cc += [ - # TODO(https://crbug.com/1513724): Fix and re-enable. + # TODO(crbug.com/41486292): Fix and re-enable. "-Wno-c++11-narrowing-const-reference", ] } @@ -2119,7 +2118,7 @@ config("no_chromium_code") { # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", - # TODO(https://crbug.com/1202159): Clean up and enable. + # TODO(crbug.com/40762742): Clean up and enable. "-Wno-misleading-indentation", ] } @@ -2182,7 +2181,7 @@ config("no_rtti") { # (de)allocate memory on a different heap, which would spell trouble if pointers # to heap-allocated memory are passed over shared library boundaries. config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. + # TODO(crbug.com/40118868): Revisit after target_os flip is completed. if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { ldflags = [ "-rdynamic" ] } @@ -2421,13 +2420,16 @@ if (is_win) { # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] + if (is_official_build) { + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/. + # -O2 enables string tail merge optimization in lld. + "-Wl,-O3", + ] + } + + common_optimize_on_ldflags += [ "-Wl,--gc-sections" ] } # We cannot rely on errno being set after math functions, @@ -2488,6 +2490,11 @@ config("march_i8mm_f16") { } } +config("march_sve2") { + cflags = [ "-march=armv9-a+sve2" ] + asmflags = cflags +} + config("default_stack_frames") { if (!is_win) { if (enable_frame_pointers) { @@ -2515,9 +2522,26 @@ config("default_stack_frames") { } # Default "optimization on" config. +# +# High-end Android: As of April 2024, `-O2` appears to be a good default, +# particularly since a selection of "hot" targets are already using `-O3`. +# Enabling `-O3` for all targets does not change performance much (according +# to Speedometer), but regresses binary size. Using `-O3` as the default: +# - Decreases Speedometer 2.1 score by 0.2% [0]. +# - Increases Speedometer 3.0 score by 0.1% [1]. +# - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size +# in M124 is 178MB). +# ... over `-O2`. +# +# [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000 +# [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 +# [2]: https://crrev.com/c/5447532 config("optimize") { if (is_win) { cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2593,9 +2617,9 @@ config("no_optimize") { } } -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. +# Turns up the optimization level. Used to explicitly enable -O2 instead of +# -Os for select targets on platforms that use optimize_for_size. No-op +# elsewhere. config("optimize_max") { if (is_nacl && is_nacl_irt) { # The NaCl IRT is a special case and always wants its own config. @@ -2613,6 +2637,9 @@ config("optimize_max") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2625,9 +2652,9 @@ config("optimize_max") { # This config can be used to override the default settings for per-component # and whole-program optimization, optimizing the particular target for speed # instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. +# except that we use -O3 instead of -O2 on non-IRT platforms. # -# TODO(crbug.com/621335) - rework how all of these configs are related +# TODO(crbug.com/41259697) - rework how all of these configs are related # so that we don't need this disclaimer. config("optimize_speed") { if (is_nacl && is_nacl_irt) { @@ -2646,6 +2673,9 @@ config("optimize_speed") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2888,7 +2918,7 @@ config("symbols") { # sections" there. Maybe just a bug in nacl_switch_32.S. _enable_gdb_index = symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && + current_os != "zos" && use_lld && # Disable on non-fission 32-bit Android because it pushes # libcomponents_unittests over the 4gb size limit. !(is_android && !use_debug_fission && current_cpu != "x64" && @@ -2907,16 +2937,17 @@ config("symbols") { configs = [] - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { + # Compress debug on 32-bit ARM to stay under 4GB file size limit. + # https://b/243982712, https://crbug.com/1354616, https://crbug.com/334073642 + if (symbol_level == 2 && !use_debug_fission && !is_nacl && + (is_chromeos_device || is_android) && + (current_cpu == "arm" || current_cpu == "x86")) { configs += [ "//build/config:compress_debug_sections" ] } if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. + # TODO(crbug.com/40117949): Investigate missing debug info on mac. # Make sure we don't use constructor homing on mac. cflags += [ "-Xclang", diff --git a/src/build/config/compiler/BUILD.gn b/src/build/config/compiler/BUILD.gn index 89e37eec..9f38aa1f 100644 --- a/src/build/config/compiler/BUILD.gn +++ b/src/build/config/compiler/BUILD.gn @@ -20,7 +20,6 @@ import("//build/config/ui.gni") import("//build/config/unwind.gni") import("//build/toolchain/cc_wrapper.gni") import("//build/toolchain/cros/cros_config.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/rbe.gni") import("//build/toolchain/toolchain.gni") import("//build_overrides/build.gni") @@ -68,10 +67,6 @@ declare_args() { # Requires profiling to be set to true. enable_full_stack_frames_for_profiling = false - # 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 = "" - # Whether to enable LLVM's Polly optimizations. See https://polly.llvm.org/ use_polly = false @@ -149,7 +144,7 @@ declare_args() { # # Flag discussion: https://crbug.com/977230 # - # TODO(crbug.com/1131993): This regresses binary size by ~1MB on Android and + # TODO(crbug.com/40721698): This regresses binary size by ~1MB on Android and # needs to be evaluated before enabling it there as well. init_stack_vars = !(is_android && is_official_build) @@ -202,7 +197,7 @@ declare_args() { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # TODO(crbug.com/1379070): Remove if the upstream default ever changes. + # TODO(crbug.com/40244196): Remove if the upstream default ever changes. # # This greatly reduces the size of debug builds, at the cost of # debugging information which is required by some specialized @@ -212,19 +207,9 @@ declare_args() { declare_args() { # Set to true to use icf, Identical Code Folding. - # - # icf=all is broken in older golds, see - # https://sourceware.org/bugzilla/show_bug.cgi?id=17704 - # 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. - # - # lld doesn't have the bug. use_icf = (is_posix || is_fuchsia) && !is_debug && !using_sanitizer && !use_clang_coverage && current_os != "zos" && - !(is_android && use_order_profiling) && - (use_lld || (use_gold && (is_chromeos || !(current_cpu == "x86" || - current_cpu == "x64")))) + !(is_android && use_order_profiling) && use_lld } if (is_android) { @@ -251,10 +236,8 @@ declare_args() { (clang_use_default_sample_profile || clang_sample_profile_path != "")) } -assert(!(llvm_force_head_revision && use_goma), - "can't use goma with trunk clang") -assert(!(llvm_force_head_revision && use_remoteexec), - "can't use rbe with trunk clang") +assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"), + "rbe with locally built clang only works on linux") # default_include_dirs --------------------------------------------------------- # @@ -335,12 +318,13 @@ config("compiler") { # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr # operations (e.g. dereferencing) into defined behavior. This avoids deletion # of some security-critical code: see https://crbug.com/1139129. - # Nacl does not support the flag. And, we still want UBSAN to catch undefined - # behavior related to nullptrs, so do not add this flag if UBSAN is enabled. - # GCC seems to have some bugs compiling constexpr code when this is defined, - # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913 + # The older NaCl toolchain does not support the flag. And, we still want UBSan + # to catch undefined behavior related to nullptrs, so do not add this flag if + # UBSan is enabled. GCC seems to have some bugs compiling constexpr code when + # this is defined, so only enable it if using_clang. + # See: https://gcc.gnu.org/PR97913 # TODO(mpdenton): remove is_clang once GCC bug is fixed. - if (!is_nacl && !is_ubsan && is_clang) { + if ((!is_nacl || is_nacl_saigo) && !is_ubsan && is_clang) { cflags += [ "-fno-delete-null-pointer-checks" ] } @@ -531,35 +515,6 @@ config("compiler") { # Linux-specific compiler flags setup. # ------------------------------------ - if (use_gold) { - ldflags += [ "-fuse-ld=gold" ] - if (!is_android) { - # On Android, this isn't needed. gcc in the NDK knows to look next to - # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed - # above. - if (gold_path != "") { - ldflags += [ "-B$gold_path" ] - } - - ldflags += [ - # 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. - "-Wl,--threads", - "-Wl,--thread-count=4", - ] - } - - # TODO(thestig): Make this flag work with GN. - #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) { - # ldflags += [ - # "-Wl,--detect-odr-violations", - # ] - #} - } - if (use_icf && (!is_apple || use_lld)) { ldflags += [ "-Wl,--icf=all" ] } @@ -627,9 +582,9 @@ config("compiler") { } } - # TODO(crbug.com/1488374): This causes binary size growth and potentially + # TODO(crbug.com/40283598): This causes binary size growth and potentially # other problems. - # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + # TODO(crbug.com/40284925): This isn't supported by Cronet's mainline llvm version. if (default_toolchain != "//build/toolchain/cros:target" && !llvm_android_mainline) { cflags += [ @@ -645,7 +600,7 @@ config("compiler") { } } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. + # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=off" ] } else { @@ -740,6 +695,19 @@ config("compiler") { # example by disabling the optimize configuration. # TODO(pcc): Make this conditional on is_official_build rather than on gn # flags for specific features. + # + # High-end Android: While Full LTO provides a small performance improvement + # (according to Speedometer), it also results in an unacceptable increase in + # build time. Thin LTO appears to provide the best build time-optimization + # tradeoff. As of April 2024, Full LTO: + # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours + # with Thin LTO) on Chromium builders. + # - Increases Speedometer 2.1 score by 1.1% [0]. + # - Increases Speedometer 3.0 score by 1.2% [1]. + # ... over Thin LTO. + # + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000 if (!is_debug && use_thin_lto && is_a_target_toolchain) { assert(use_lld, "LTO is only supported with lld") @@ -773,6 +741,16 @@ config("compiler") { # binary size than the default setting of 100. # TODO(gbiv): We ideally shouldn't need to specify this; ThinLTO # should be able to better manage binary size increases on its own. + # + # For high-end Android, 30 seems to be the right trade-off between performance + # and binary size, at least based on Speedometer. For example, increasing + # `import_instr_limit`to 50 improves Speedometer 2.1 score by 0.7% [0], while + # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size + # increases by about 2MB [2] (or 1.1%: the arm64 native code size in M124 is + # 178MB). + # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000 + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000 + # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442 import_instr_limit = 30 if (is_win) { @@ -800,8 +778,10 @@ config("compiler") { # FIXME(inglorion): maybe tune these? # TODO(b/271459198): Revert limit on amd64 to 30 when fixed. import_instr_limit = 30 - } else if (is_android && optimize_for_size) { - # TODO(crbug.com/1308318): Investigate if we can get the > 6% perf win + } else if (is_android && (optimize_for_size || use_order_profiling)) { + # Reduce inlining for the orderfile instrumented build to mitigate + # crbug.com/330761384. + # TODO(crbug.com/40219076): Investigate if we can get the > 6% perf win # of import_instr_limit 30 with a binary size hit smaller than ~2 MiB. import_instr_limit = 30 } @@ -817,7 +797,22 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ] } - # TODO(https://crbug.com/1211155): investigate why this isn't effective on + # TODO(crbug.com/335365324): Enable on other platforms. + if (is_android && !optimize_for_size) { + # Ideally the compiler would handle this automatically with PGO (see + # comments at https://crrev.com/c/5440500). + # + # Android binary size impact (as of April 2024): The arm64 native code + # size increases by ~627KB (or 0.34%: the arm64 native code size in + # M124 is 178MB). + cflags += [ + "-mllvm", + "-inlinehint-threshold=360", + ] + ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ] + } + + # TODO(crbug.com/40182783): investigate why this isn't effective on # arm32. if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] @@ -871,7 +866,7 @@ config("compiler") { ldflags += [ "-Wl,--no-rosegment" ] } - # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by + # TODO(crbug.com/40242425): Cleanup undefined symbol errors caught by # --no-undefined-version. if (use_lld && !is_win && !is_mac && !is_ios) { ldflags += [ "-Wl,--undefined-version" ] @@ -895,8 +890,6 @@ config("compiler") { if (is_clang && !is_nacl && show_includes) { if (is_win) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ "/clang:-H", "/clang:-fshow-skipped-includes", @@ -1073,10 +1066,10 @@ config("compiler") { # consistently apply in both Chromium and non-Chromium code *and* non-NaCl # and NaCl code. # - # TODO(https://crbug.com/702997): Move this back to the `runtime_library` + # TODO(crbug.com/40511454): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # TODO(crbug.com/40275904): Switch saigo to hardened mode once # it's rolled in. if (is_nacl_saigo) { defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] @@ -1503,7 +1496,7 @@ config("compiler_codegen") { if (current_cpu == "arm64" && !is_win && is_clang) { # Disable outlining everywhere on arm64 except Win. For more information see # crbug.com/931297 for Android and crbug.com/1410297 for iOS. - # TODO(crbug.com/1411363): Enable this on Windows if possible. + # TODO(crbug.com/40890229): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1589,7 +1582,7 @@ config("compiler_deterministic") { # Tells the compiler not to use absolute paths when passing the default # paths to the tools it invokes. We don't want this because we don't - # really need it and it can mess up the goma cache entries. + # really need it and it can mess up the RBE cache entries. if (is_clang && (!is_nacl || is_nacl_saigo)) { cflags += [ "-no-canonical-prefixes" ] @@ -1597,7 +1590,7 @@ config("compiler_deterministic") { # with a relative path and pass relative paths to built-in # libraries. Not needed on Windows because we call the linker # directly there, not through the compiler driver. - # We don't link on goma, so this change is just for cleaner + # We don't link on RBE, so this change is just for cleaner # internal linker invocations, for people who work on the build. if (!is_win) { ldflags += [ "-no-canonical-prefixes" ] @@ -1694,7 +1687,7 @@ config("runtime_library") { configs += [ "//build/config/clang:compiler_builtins" ] } - # TODO(crbug.com/830987): Come up with a better name for is POSIX + Fuchsia + # TODO(crbug.com/40570904): Come up with a better name for is POSIX + Fuchsia # configuration. if (is_posix || is_fuchsia) { configs += [ "//build/config/posix:runtime_library" ] @@ -1881,41 +1874,47 @@ config("default_warnings") { if (!is_nacl || is_nacl_saigo) { if (is_win) { # TODO(thakis): https://crbug.com/617318 - # Currently goma can not handle case sensitiveness for windows well. + # Currently RBE can not handle case sensitiveness for windows well. cflags += [ "-Wno-nonportable-include-path" ] } if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474434): fix and reenable + # TODO(crbug.com/42050603): fix and reenable "-Wno-missing-field-initializers", # TODO(https://crbug.com/324953188): fix and reenable "-Wno-extra-qualification", + + # TODO(https://crbug.com/332931387): fix and reenable + "-Wno-unused-but-set-variable", ] } cflags += [ + # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now. + "-Wno-cast-function-type", + # Ignore warnings about MSVC optimization pragmas. # TODO(thakis): Only for no_chromium_code? http://crbug.com/912662 "-Wno-ignored-pragma-optimize", - # TODO(crbug.com/1343975) Evaluate and possibly enable. + # TODO(crbug.com/40231599) Evaluate and possibly enable. "-Wno-deprecated-builtins", - # TODO(crbug.com/1352183) Evaluate and possibly enable. + # TODO(crbug.com/40234766) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", - # TODO(crbug.com/1412713) Evaluate and possibly enable. + # TODO(crbug.com/40255410) Evaluate and possibly enable. "-Wno-deprecated-this-capture", - # TODO(https://crbug.com/1491833): Fix and re-enable. + # TODO(crbug.com/40285259): Fix and re-enable. "-Wno-invalid-offsetof", - # TODO(crbug.com/1494809): Evaluate and possibly enable. + # TODO(crbug.com/40286317): Evaluate and possibly enable. "-Wno-vla-extension", - # TODO(https://crbug.com/1490607): Fix and re-enable. + # TODO(crbug.com/40284799): Fix and re-enable. "-Wno-thread-safety-reference-return", ] @@ -1926,7 +1925,7 @@ config("default_warnings") { if (!is_nacl) { cflags_cc += [ - # TODO(https://crbug.com/1513724): Fix and re-enable. + # TODO(crbug.com/41486292): Fix and re-enable. "-Wno-c++11-narrowing-const-reference", ] } @@ -2124,7 +2123,7 @@ config("no_chromium_code") { # Disabled for similar reasons as -Wunused-variable. "-Wno-unused-but-set-variable", - # TODO(https://crbug.com/1202159): Clean up and enable. + # TODO(crbug.com/40762742): Clean up and enable. "-Wno-misleading-indentation", ] } @@ -2187,7 +2186,7 @@ config("no_rtti") { # (de)allocate memory on a different heap, which would spell trouble if pointers # to heap-allocated memory are passed over shared library boundaries. config("export_dynamic") { - # TODO(crbug.com/1052397): Revisit after target_os flip is completed. + # TODO(crbug.com/40118868): Revisit after target_os flip is completed. if (is_linux || is_chromeos_lacros || export_libcxxabi_from_executables) { ldflags = [ "-rdynamic" ] } @@ -2430,13 +2429,16 @@ if (is_win) { # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } - common_optimize_on_ldflags += [ - # Specifically tell the linker to perform optimizations. - # See http://lwn.net/Articles/192624/ . - # -O2 enables string tail merge optimization in gold and lld. - "-Wl,-O3", - "-Wl,--gc-sections", - ] + if (is_official_build) { + common_optimize_on_ldflags += [ + # Specifically tell the linker to perform optimizations. + # See http://lwn.net/Articles/192624/. + # -O2 enables string tail merge optimization in lld. + "-Wl,-O3", + ] + } + + common_optimize_on_ldflags += [ "-Wl,--gc-sections" ] } # We cannot rely on errno being set after math functions, @@ -2529,9 +2531,26 @@ config("default_stack_frames") { } # Default "optimization on" config. +# +# High-end Android: As of April 2024, `-O2` appears to be a good default, +# particularly since a selection of "hot" targets are already using `-O3`. +# Enabling `-O3` for all targets does not change performance much (according +# to Speedometer), but regresses binary size. Using `-O3` as the default: +# - Decreases Speedometer 2.1 score by 0.2% [0]. +# - Increases Speedometer 3.0 score by 0.1% [1]. +# - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size +# in M124 is 178MB). +# ... over `-O2`. +# +# [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000 +# [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 +# [2]: https://crrev.com/c/5447532 config("optimize") { if (is_win) { cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2607,9 +2626,9 @@ config("no_optimize") { } } -# Turns up the optimization level. On Windows, this implies whole program -# optimization and link-time code generation which is very expensive and should -# be used sparingly. +# Turns up the optimization level. Used to explicitly enable -O2 instead of +# -Os for select targets on platforms that use optimize_for_size. No-op +# elsewhere. config("optimize_max") { if (is_nacl && is_nacl_irt) { # The NaCl IRT is a special case and always wants its own config. @@ -2627,6 +2646,9 @@ config("optimize_max") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2639,9 +2661,9 @@ config("optimize_max") { # This config can be used to override the default settings for per-component # and whole-program optimization, optimizing the particular target for speed # instead of code size. This config is exactly the same as "optimize_max" -# except that we use -O3 instead of -O2 on non-win, non-IRT platforms. +# except that we use -O3 instead of -O2 on non-IRT platforms. # -# TODO(crbug.com/621335) - rework how all of these configs are related +# TODO(crbug.com/41259697) - rework how all of these configs are related # so that we don't need this disclaimer. config("optimize_speed") { if (is_nacl && is_nacl_irt) { @@ -2660,6 +2682,9 @@ config("optimize_speed") { # Favor speed over size, /O2 must be before the common flags. # /O2 implies /Ot, /Oi, and /GF. cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + if (is_clang) { + cflags += [ "/clang:-O3" ] + } } else if (optimize_for_fuzzing) { cflags = [ "-O3" ] + common_optimize_on_cflags } else { @@ -2902,7 +2927,7 @@ config("symbols") { # sections" there. Maybe just a bug in nacl_switch_32.S. _enable_gdb_index = symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && + current_os != "zos" && use_lld && # Disable on non-fission 32-bit Android because it pushes # libcomponents_unittests over the 4gb size limit. !(is_android && !use_debug_fission && current_cpu != "x64" && @@ -2921,16 +2946,17 @@ config("symbols") { configs = [] - # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS - # https://b/243982712. - if (symbol_level == 2 && is_chromeos_device && !use_debug_fission && - !is_nacl && current_cpu == "arm") { + # Compress debug on 32-bit ARM to stay under 4GB file size limit. + # https://b/243982712, https://crbug.com/1354616, https://crbug.com/334073642 + if (symbol_level == 2 && !use_debug_fission && !is_nacl && + (is_chromeos_device || is_android) && + (current_cpu == "arm" || current_cpu == "x86")) { configs += [ "//build/config:compress_debug_sections" ] } if (is_clang && (!is_nacl || is_nacl_saigo) && current_os != "zos") { if (is_apple) { - # TODO(https://crbug.com/1050118): Investigate missing debug info on mac. + # TODO(crbug.com/40117949): Investigate missing debug info on mac. # Make sure we don't use constructor homing on mac. cflags += [ "-Xclang", diff --git a/src/v8/BUILD.gn b/src/v8/BUILD.gn index 77a443f3..bb2558c5 100644 --- a/src/v8/BUILD.gn +++ b/src/v8/BUILD.gn @@ -333,7 +333,7 @@ declare_args() { # Sets -DV8_COMPRESS_ZONES. v8_enable_zone_compression = "" - # Enable the experimental V8 sandbox. + # Enable the V8 sandbox. # Sets -DV8_ENABLE_SANDBOX. v8_enable_sandbox = "" @@ -404,9 +404,7 @@ declare_args() { # when this is set to 'false', one can run V8 in jitless mode at runtime by # passing the `--jitless` flag; but then you miss out on compile-time # optimizations. - # iOS (non-simulator) does not have executable pages for 3rd party - # applications yet so disable jit. - v8_jitless = v8_enable_lite_mode || target_is_ios_device + v8_jitless = v8_enable_lite_mode # Enable Sparkplug # Sets -DV8_ENABLE_SPARKPLUG. @@ -428,6 +426,13 @@ declare_args() { # Whether custom embedder snapshots may extend (= allocate new objects in) # ReadOnlySpace. v8_enable_extensible_ro_snapshot = true + + # Use sticky mark-bits for separating object generations. + v8_enable_sticky_mark_bits = false + + # Always move prototype transitions to the start of the transition tree + # (see issue 332914927). + v8_move_prototype_transitions_first = false } # Derived defaults. @@ -866,7 +871,6 @@ external_v8_defines = [ "V8_ENABLE_CHECKS", "V8_COMPRESS_POINTERS", "V8_COMPRESS_POINTERS_IN_SHARED_CAGE", - "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE", "V8_31BIT_SMIS_ON_64BIT_ARCH", "V8_COMPRESS_ZONES", "V8_ENABLE_SANDBOX", @@ -878,6 +882,14 @@ external_v8_defines = [ "V8_ENABLE_CONSERVATIVE_STACK_SCANNING", "V8_ENABLE_DIRECT_LOCAL", "V8_MINORMS_STRING_SHORTCUTTING", + "V8_HAVE_TARGET_OS", + "V8_TARGET_OS_ANDROID", + "V8_TARGET_OS_FUCHSIA", + "V8_TARGET_OS_IOS", + "V8_TARGET_OS_LINUX", + "V8_TARGET_OS_MACOS", + "V8_TARGET_OS_WIN", + "V8_TARGET_OS_CHROMEOS", ] enabled_external_v8_defines = [] @@ -889,8 +901,6 @@ if (v8_enable_pointer_compression) { enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS" ] if (v8_enable_pointer_compression_shared_cage) { enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS_IN_SHARED_CAGE" ] - } else { - enabled_external_v8_defines += [ "V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE" ] } } if (v8_enable_pointer_compression || v8_enable_31bit_smis_on_64bit_arch) { @@ -926,6 +936,34 @@ if (v8_enable_direct_local) { if (v8_shortcut_strings_in_minor_ms) { enabled_external_v8_defines += [ "V8_MINORMS_STRING_SHORTCUTTING" ] } + +# V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in +# mksnapshot. We additionally set V8_HAVE_TARGET_OS to determine that a +# target OS has in fact been set; otherwise we internally assume that target +# OS == host OS (see v8config.h). +if (target_os == "android") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_ANDROID" ] +} else if (target_os == "fuchsia") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_FUCHSIA" ] +} else if (target_os == "ios") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_IOS" ] +} else if (target_os == "linux") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_LINUX" ] +} else if (target_os == "mac") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_MACOS" ] +} else if (target_os == "win") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_WIN" ] +} else if (target_os == "chromeos") { + enabled_external_v8_defines += [ "V8_HAVE_TARGET_OS" ] + enabled_external_v8_defines += [ "V8_TARGET_OS_CHROMEOS" ] +} + disabled_external_v8_defines = external_v8_defines - enabled_external_v8_defines # Put defines that are used in public headers here; public headers are @@ -1022,6 +1060,11 @@ config("features") { defines += [ "CPPGC_ALLOW_ALLOCATIONS_IN_PREFINALIZERS" ] } + if (v8_enable_pointer_compression && + !v8_enable_pointer_compression_shared_cage) { + defines += [ "V8_COMPRESS_POINTERS_IN_MULTIPLE_CAGES" ] + } + if (v8_embedder_string != "") { defines += [ "V8_EMBEDDER_STRING=\"$v8_embedder_string\"" ] } @@ -1253,6 +1296,12 @@ config("features") { if (v8_enable_local_off_stack_check) { defines += [ "V8_ENABLE_LOCAL_OFF_STACK_CHECK" ] } + if (v8_enable_sticky_mark_bits) { + defines += [ "V8_ENABLE_STICKY_MARK_BITS" ] + } + if (v8_move_prototype_transitions_first) { + defines += [ "V8_MOVE_PROTOYPE_TRANSITIONS_FIRST" ] + } } config("toolchain") { @@ -1385,20 +1434,10 @@ config("toolchain") { defines += [ "CAN_USE_RVV_INSTRUCTIONS" ] defines += [ "RVV_VLEN=${riscv_rvv_vlen}" ] } - if (riscv_use_zba || target_is_simulator) { - defines += [ "CAN_USE_ZBA_INSTRUCTIONS" ] - } - if (riscv_use_zbb || target_is_simulator) { - defines += [ "CAN_USE_ZBB_INSTRUCTIONS" ] - } - if (riscv_use_zbs || target_is_simulator) { - defines += [ "CAN_USE_ZBS_INSTRUCTIONS" ] - } } if (v8_current_cpu == "riscv64") { defines += [ "V8_TARGET_ARCH_RISCV64" ] defines += [ "__riscv_xlen=64" ] - defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] if (!is_clang) { cflags += [ "-ffp-contract=off" ] } @@ -1407,7 +1446,6 @@ config("toolchain") { if (v8_current_cpu == "riscv32") { defines += [ "V8_TARGET_ARCH_RISCV32" ] defines += [ "__riscv_xlen=32" ] - defines += [ "CAN_USE_FPU_INSTRUCTIONS" ] } if (v8_current_cpu == "x86") { @@ -1436,33 +1474,6 @@ config("toolchain") { defines += [ "V8_ANDROID_LOG_STDOUT" ] } - # V8_TARGET_OS_ defines. The target OS may differ from host OS e.g. in - # mksnapshot. We additionally set V8_HAVE_TARGET_OS to determine that a - # target OS has in fact been set; otherwise we internally assume that target - # OS == host OS (see v8config.h). - if (target_os == "android") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_ANDROID" ] - } else if (target_os == "fuchsia") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_FUCHSIA" ] - } else if (target_os == "ios") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_IOS" ] - } else if (target_os == "linux") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_LINUX" ] - } else if (target_os == "mac") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_MACOS" ] - } else if (target_os == "win") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_WIN" ] - } else if (target_os == "chromeos") { - defines += [ "V8_HAVE_TARGET_OS" ] - defines += [ "V8_TARGET_OS_CHROMEOS" ] - } - # TODO(infra): Support v8_enable_prof on Windows. # TODO(infra): Add support for compiling with simulators. @@ -1722,6 +1733,10 @@ config("toolchain") { # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108517 "-Wno-nonnull", + + # Disable dangling pointer warnings, which are often false positives when + # using scopes. + "-Wno-dangling-pointer", ] } @@ -2063,6 +2078,7 @@ torque_files = [ "src/objects/js-atomics-synchronization.tq", "src/objects/js-collection-iterator.tq", "src/objects/js-collection.tq", + "src/objects/js-disposable-stack.tq", "src/objects/js-function.tq", "src/objects/js-generator.tq", "src/objects/js-iterator-helpers.tq", @@ -2731,6 +2747,7 @@ action("v8_dump_build_config") { "verify_csa=$v8_enable_verify_csa", "verify_heap=$v8_enable_verify_heap", "verify_predictable=$v8_enable_verify_predictable", + "memory_corruption_api=$v8_enable_memory_corruption_api", ] } @@ -3086,6 +3103,7 @@ v8_header_set("v8_headers") { "include/v8-promise.h", "include/v8-proxy.h", "include/v8-regexp.h", + "include/v8-sandbox.h", "include/v8-script.h", "include/v8-snapshot.h", "include/v8-statistics.h", @@ -3192,7 +3210,6 @@ v8_header_set("v8_internal_headers") { sources = [ ### gcmole(all) ### "$target_gen_dir/builtins-generated/bytecodes-builtins-list.h", - "//base/trace_event/common/trace_event_common.h", "include/cppgc/common.h", "include/v8-inspector-protocol.h", "include/v8-inspector.h", @@ -3331,13 +3348,11 @@ v8_header_set("v8_internal_headers") { "src/compiler/const-tracking-let-helpers.h", "src/compiler/constant-folding-reducer.h", "src/compiler/control-equivalence.h", - "src/compiler/control-flow-optimizer.h", "src/compiler/control-path-state.h", "src/compiler/csa-load-elimination.h", "src/compiler/dead-code-elimination.h", "src/compiler/decompression-optimizer.h", "src/compiler/diamond.h", - "src/compiler/effect-control-linearizer.h", "src/compiler/escape-analysis-reducer.h", "src/compiler/escape-analysis.h", "src/compiler/fast-api-calls.h", @@ -3415,7 +3430,6 @@ v8_header_set("v8_internal_headers") { "src/compiler/simplified-operator-reducer.h", "src/compiler/simplified-operator.h", "src/compiler/state-values-utils.h", - "src/compiler/store-store-elimination.h", "src/compiler/string-builder-optimizer.h", "src/compiler/turbofan.h", "src/compiler/turboshaft/analyzer-iterator.h", @@ -3443,6 +3457,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/graph-visualizer.h", "src/compiler/turboshaft/graph.h", "src/compiler/turboshaft/index.h", + "src/compiler/turboshaft/instruction-selection-normalization-reducer.h", "src/compiler/turboshaft/instruction-selection-phase.h", "src/compiler/turboshaft/js-generic-lowering-reducer.h", "src/compiler/turboshaft/late-escape-analysis-reducer.h", @@ -3481,7 +3496,7 @@ v8_header_set("v8_internal_headers") { "src/compiler/turboshaft/snapshot-table.h", "src/compiler/turboshaft/stack-check-lowering-reducer.h", "src/compiler/turboshaft/store-store-elimination-phase.h", - "src/compiler/turboshaft/store-store-elimination-reducer.h", + "src/compiler/turboshaft/store-store-elimination-reducer-inl.h", "src/compiler/turboshaft/structural-optimization-reducer.h", "src/compiler/turboshaft/tracing.h", "src/compiler/turboshaft/type-assertions-phase.h", @@ -3641,6 +3656,7 @@ v8_header_set("v8_internal_headers") { "src/heap/incremental-marking-job.h", "src/heap/incremental-marking.h", "src/heap/index-generator.h", + "src/heap/large-page-inl.h", "src/heap/large-page.h", "src/heap/large-spaces.h", "src/heap/linear-allocation-area.h", @@ -3666,7 +3682,9 @@ v8_header_set("v8_internal_headers") { "src/heap/marking.h", "src/heap/memory-allocator.h", "src/heap/memory-balancer.h", + "src/heap/memory-chunk-inl.h", "src/heap/memory-chunk-layout.h", + "src/heap/memory-chunk-metadata-inl.h", "src/heap/memory-chunk-metadata.h", "src/heap/memory-chunk.h", "src/heap/memory-measurement-inl.h", @@ -3679,6 +3697,7 @@ v8_header_set("v8_internal_headers") { "src/heap/mutable-page.h", "src/heap/new-spaces-inl.h", "src/heap/new-spaces.h", + "src/heap/object-lock-inl.h", "src/heap/object-lock.h", "src/heap/object-stats.h", "src/heap/objects-visiting-inl.h", @@ -3721,7 +3740,7 @@ v8_header_set("v8_internal_headers") { "src/init/bootstrapper.h", "src/init/heap-symbols.h", "src/init/icu_util.h", - "src/init/isolate-allocator.h", + "src/init/isolate-group.h", "src/init/setup-isolate.h", "src/init/startup-data-util.h", "src/init/v8.h", @@ -3731,7 +3750,7 @@ v8_header_set("v8_internal_headers") { "src/interpreter/bytecode-array-random-iterator.h", "src/interpreter/bytecode-array-writer.h", "src/interpreter/bytecode-decoder.h", - "src/interpreter/bytecode-flags.h", + "src/interpreter/bytecode-flags-and-tokens.h", "src/interpreter/bytecode-generator.h", "src/interpreter/bytecode-jump-table.h", "src/interpreter/bytecode-label.h", @@ -3845,6 +3864,8 @@ v8_header_set("v8_internal_headers") { "src/objects/js-collection-iterator-inl.h", "src/objects/js-collection-iterator.h", "src/objects/js-collection.h", + "src/objects/js-disposable-stack-inl.h", + "src/objects/js-disposable-stack.h", "src/objects/js-function-inl.h", "src/objects/js-function.h", "src/objects/js-generator-inl.h", @@ -3987,6 +4008,7 @@ v8_header_set("v8_internal_headers") { "src/objects/value-serializer.h", "src/objects/visitors-inl.h", "src/objects/visitors.h", + "src/objects/waiter-queue-node.h", "src/parsing/expression-scope.h", "src/parsing/func-name-inferrer.h", "src/parsing/import-assertions.h", @@ -4060,6 +4082,13 @@ v8_header_set("v8_internal_headers") { "src/sandbox/code-pointer-table-inl.h", "src/sandbox/code-pointer-table.h", "src/sandbox/code-pointer.h", + "src/sandbox/compactible-external-entity-table-inl.h", + "src/sandbox/compactible-external-entity-table.h", + "src/sandbox/external-buffer-inl.h", + "src/sandbox/external-buffer-table-inl.h", + "src/sandbox/external-buffer-table.h", + "src/sandbox/external-buffer-tag.h", + "src/sandbox/external-buffer.h", "src/sandbox/external-entity-table-inl.h", "src/sandbox/external-entity-table.h", "src/sandbox/external-pointer-inl.h", @@ -4105,6 +4134,7 @@ v8_header_set("v8_internal_headers") { "src/strings/char-predicates-inl.h", "src/strings/char-predicates.h", "src/strings/string-builder-inl.h", + "src/strings/string-builder.h", "src/strings/string-case.h", "src/strings/string-hasher-inl.h", "src/strings/string-hasher.h", @@ -4122,6 +4152,7 @@ v8_header_set("v8_internal_headers") { "src/third_party/utf8-decoder/utf8-decoder.h", "src/torque/runtime-macro-shims.h", "src/tracing/trace-event.h", + "src/tracing/trace-event-no-perfetto.h", "src/tracing/traced-value.h", "src/tracing/tracing-category-observer.h", "src/utils/address-map.h", @@ -4163,7 +4194,7 @@ v8_header_set("v8_internal_headers") { } if (v8_use_perfetto) { - sources -= [ "//base/trace_event/common/trace_event_common.h" ] + sources -= [ "src/tracing/trace-event-no-perfetto.h" ] sources += [ "src/tracing/code-data-source.h", "src/tracing/code-trace-context.h", @@ -4260,6 +4291,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/baseline/liftoff-assembler.h", "src/wasm/baseline/liftoff-compiler.h", "src/wasm/baseline/liftoff-register.h", + "src/wasm/baseline/liftoff-varstate.h", "src/wasm/baseline/parallel-move-inl.h", "src/wasm/baseline/parallel-move.h", "src/wasm/canonical-types.h", @@ -4300,6 +4332,7 @@ v8_header_set("v8_internal_headers") { "src/wasm/wasm-builtin-list.h", "src/wasm/wasm-code-manager.h", "src/wasm/wasm-debug.h", + "src/wasm/wasm-deopt-data.h", "src/wasm/wasm-disassembler-impl.h", "src/wasm/wasm-disassembler.h", "src/wasm/wasm-engine.h", @@ -4755,6 +4788,11 @@ v8_header_set("v8_internal_headers") { } } + frameworks = [] + if (is_ios) { + frameworks += [ "BrowserEngineKit.framework" ] + } + public_deps = [ ":torque_runtime_support", ":v8_flags", @@ -4809,11 +4847,9 @@ v8_compiler_sources = [ "src/compiler/const-tracking-let-helpers.cc", "src/compiler/constant-folding-reducer.cc", "src/compiler/control-equivalence.cc", - "src/compiler/control-flow-optimizer.cc", "src/compiler/csa-load-elimination.cc", "src/compiler/dead-code-elimination.cc", "src/compiler/decompression-optimizer.cc", - "src/compiler/effect-control-linearizer.cc", "src/compiler/escape-analysis-reducer.cc", "src/compiler/escape-analysis.cc", "src/compiler/fast-api-calls.cc", @@ -4880,7 +4916,6 @@ v8_compiler_sources = [ "src/compiler/simplified-operator-reducer.cc", "src/compiler/simplified-operator.cc", "src/compiler/state-values-utils.cc", - "src/compiler/store-store-elimination.cc", "src/compiler/string-builder-optimizer.cc", "src/compiler/turbofan-enabled.cc", "src/compiler/type-cache.cc", @@ -5135,6 +5170,7 @@ v8_source_set("v8_turboshaft") { "src/maglev/maglev-graph-printer.cc", "src/maglev/maglev-interpreter-frame-state.cc", "src/maglev/maglev-ir.cc", + "src/maglev/maglev-phi-representation-selector.cc", ] } @@ -5218,6 +5254,7 @@ v8_source_set("v8_base_without_compiler") { "src/builtins/builtins-console.cc", "src/builtins/builtins-dataview.cc", "src/builtins/builtins-date.cc", + "src/builtins/builtins-disposable-stack.cc", "src/builtins/builtins-error.cc", "src/builtins/builtins-function.cc", "src/builtins/builtins-global.cc", @@ -5411,7 +5448,7 @@ v8_source_set("v8_base_without_compiler") { "src/ic/stub-cache.cc", "src/init/bootstrapper.cc", "src/init/icu_util.cc", - "src/init/isolate-allocator.cc", + "src/init/isolate-group.cc", "src/init/startup-data-util.cc", "src/init/v8.cc", "src/interpreter/bytecode-array-builder.cc", @@ -5419,7 +5456,7 @@ v8_source_set("v8_base_without_compiler") { "src/interpreter/bytecode-array-random-iterator.cc", "src/interpreter/bytecode-array-writer.cc", "src/interpreter/bytecode-decoder.cc", - "src/interpreter/bytecode-flags.cc", + "src/interpreter/bytecode-flags-and-tokens.cc", "src/interpreter/bytecode-generator.cc", "src/interpreter/bytecode-label.cc", "src/interpreter/bytecode-node.cc", @@ -5471,6 +5508,7 @@ v8_source_set("v8_base_without_compiler") { "src/objects/js-collator.cc", "src/objects/js-date-time-format.cc", "src/objects/js-display-names.cc", + "src/objects/js-disposable-stack.cc", "src/objects/js-duration-format.cc", "src/objects/js-function.cc", "src/objects/js-list-format.cc", @@ -5519,6 +5557,7 @@ v8_source_set("v8_base_without_compiler") { "src/objects/type-hints.cc", "src/objects/value-serializer.cc", "src/objects/visitors.cc", + "src/objects/waiter-queue-node.cc", "src/parsing/func-name-inferrer.cc", "src/parsing/import-assertions.cc", "src/parsing/literal-buffer.cc", @@ -5598,6 +5637,7 @@ v8_source_set("v8_base_without_compiler") { "src/runtime/runtime-weak-refs.cc", "src/runtime/runtime.cc", "src/sandbox/code-pointer-table.cc", + "src/sandbox/external-buffer-table.cc", "src/sandbox/external-pointer-table.cc", "src/sandbox/sandbox.cc", "src/sandbox/testing.cc", @@ -5748,6 +5788,7 @@ v8_source_set("v8_base_without_compiler") { "src/wasm/value-type.cc", "src/wasm/wasm-code-manager.cc", "src/wasm/wasm-debug.cc", + "src/wasm/wasm-deopt-data.cc", "src/wasm/wasm-disassembler.cc", "src/wasm/wasm-engine.cc", "src/wasm/wasm-external-refs.cc", @@ -6247,7 +6288,10 @@ v8_source_set("torque_base") { ":v8_shared_internal_headers", ] - public_deps = [ ":v8_libbase" ] + public_deps = [ + ":v8_config_headers", + ":v8_libbase", + ] # The use of exceptions for Torque in violation of the Chromium style-guide # is justified by the fact that it is only used from the non-essential @@ -6410,6 +6454,9 @@ v8_component("v8_libbase") { "src/base/strings.h", "src/base/sys-info.cc", "src/base/sys-info.h", + "src/base/template-meta-programming/algorithm.h", + "src/base/template-meta-programming/functional.h", + "src/base/template-meta-programming/list.h", "src/base/template-utils.h", "src/base/threaded-list.h", "src/base/timezone-cache.h", @@ -6516,7 +6563,6 @@ v8_component("v8_libbase") { sources += [ "src/base/debug/stack_trace_posix.cc", "src/base/platform/platform-darwin.cc", - "src/base/platform/platform-ios.cc", ] } else if (is_win) { # TODO(infra): Add support for cygwin. @@ -6601,7 +6647,6 @@ if (v8_use_libm_trig_functions) { v8_component("v8_libplatform") { sources = [ - "//base/trace_event/common/trace_event_common.h", "include/libplatform/libplatform-export.h", "include/libplatform/libplatform.h", "include/libplatform/v8-tracing.h", @@ -6628,6 +6673,7 @@ v8_component("v8_libplatform") { "src/libplatform/tracing/tracing-controller.cc", "src/libplatform/worker-thread.cc", "src/libplatform/worker-thread.h", + "src/tracing/trace-event-no-perfetto.h", ] configs = [ ":internal_config_base" ] @@ -6648,12 +6694,12 @@ v8_component("v8_libplatform") { if (v8_use_perfetto) { sources -= [ - "//base/trace_event/common/trace_event_common.h", "src/libplatform/tracing/trace-buffer.cc", "src/libplatform/tracing/trace-buffer.h", "src/libplatform/tracing/trace-object.cc", "src/libplatform/tracing/trace-writer.cc", "src/libplatform/tracing/trace-writer.h", + "src/tracing/trace-event-no-perfetto.h", ] sources += [ "src/libplatform/tracing/trace-event-listener.h" ] } @@ -6976,7 +7022,7 @@ v8_source_set("cppgc_base") { ] if (cppgc_is_standalone && !v8_use_perfetto) { - sources += [ "//base/trace_event/common/trace_event_common.h" ] + sources += [ "src/tracing/trace-event-no-perfetto.h" ] } else { public_deps += [ ":v8_tracing" ] } @@ -7126,7 +7172,10 @@ if (current_toolchain == v8_snapshot_toolchain) { sources += [ "src/deoptimizer/deoptimizer-cfi-empty.cc" ] } - configs = [ ":internal_config" ] + configs = [ + ":internal_config", + ":disable_icf", + ] deps = [ ":v8_base_without_compiler", @@ -7141,6 +7190,23 @@ if (current_toolchain == v8_snapshot_toolchain) { "//build/win:default_exe_manifest", ] } + + # This config disables a link time optimization "ICF", which may merge + # different functions into one if the function signature and body of them are + # identical. + # + # ICF breaks 1:1 mappings of the external references for V8 snapshot, so we + # disable it while taking a V8 snapshot. + config("disable_icf") { + visibility = [ ":*" ] # Only targets in this file can depend on this. + if (is_win) { + ldflags = [ "/OPT:NOICF" ] # link.exe, but also lld-link.exe. + } else if (is_apple && !use_lld) { + ldflags = [ "-Wl,-no_deduplicate" ] # ld64. + } else if (use_gold || use_lld) { + ldflags = [ "-Wl,--icf=none" ] + } + } } if (current_toolchain == v8_snapshot_toolchain) { @@ -7358,8 +7424,10 @@ group("v8_fuzzers") { ":v8_simple_multi_return_fuzzer", ":v8_simple_wasm_async_fuzzer", ":v8_simple_wasm_code_fuzzer", + ":v8_simple_wasm_compile_all_fuzzer", ":v8_simple_wasm_compile_fuzzer", ":v8_simple_wasm_compile_simd_fuzzer", + ":v8_simple_wasm_compile_wasmgc_fuzzer", ":v8_simple_wasm_fuzzer", ":v8_simple_wasm_init_expr_fuzzer", ":v8_simple_wasm_streaming_fuzzer", @@ -7628,11 +7696,25 @@ v8_executable("cppgc_hello_world") { } template("v8_fuzzer") { - name = target_name - forward_variables_from(invoker, "*") - v8_executable("v8_simple_" + name) { + fuzzer_name = target_name + + v8_source_set(fuzzer_name) { + sources = invoker.sources + + deps = [ ":fuzzer_support" ] + if (defined(invoker.deps)) { + deps += invoker.deps + } + + configs = [ + ":external_config", + ":internal_config_base", + ] + } + + v8_executable("v8_simple_${fuzzer_name}") { deps = [ - ":" + name, + ":${fuzzer_name}", "//build/win:default_exe_manifest", ] @@ -7642,61 +7724,21 @@ template("v8_fuzzer") { } } -v8_source_set("json_fuzzer") { - sources = [ "test/fuzzer/json.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] -} - v8_fuzzer("json_fuzzer") { -} - -v8_source_set("parser_fuzzer") { - sources = [ "test/fuzzer/parser.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] + sources = [ "test/fuzzer/json.cc" ] } v8_fuzzer("parser_fuzzer") { -} - -v8_source_set("regexp_fuzzer") { - sources = [ "test/fuzzer/regexp.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] + sources = [ "test/fuzzer/parser.cc" ] } v8_fuzzer("regexp_fuzzer") { + sources = [ "test/fuzzer/regexp.cc" ] } if (v8_enable_webassembly) { - v8_source_set("multi_return_fuzzer") { - sources = [ "test/fuzzer/multi-return.cc" ] - - deps = [ ":fuzzer_support" ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - v8_fuzzer("multi_return_fuzzer") { + sources = [ "test/fuzzer/multi-return.cc" ] } v8_source_set("wasm_test_common") { @@ -7727,67 +7769,11 @@ if (v8_enable_webassembly) { ] } - v8_source_set("wasm_fuzzer") { - sources = [ "test/fuzzer/wasm.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_fuzzer") { - } - - v8_source_set("wasm_async_fuzzer") { - sources = [ "test/fuzzer/wasm-async.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_async_fuzzer") { - } - - v8_source_set("wasm_code_fuzzer") { - sources = [ - "test/common/wasm/test-signatures.h", - "test/fuzzer/wasm-code.cc", - ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] - } - - v8_fuzzer("wasm_code_fuzzer") { - } - - v8_source_set("lib_wasm_fuzzer_common") { + v8_source_set("wasm_fuzzer_common") { sources = [ "test/fuzzer/wasm-fuzzer-common.cc", "test/fuzzer/wasm-fuzzer-common.h", + "tools/wasm/mjsunit-module-disassembler-impl.h", ] deps = [ @@ -7810,100 +7796,71 @@ if (v8_enable_webassembly) { ] } - v8_source_set("wasm_compile_fuzzer") { + template("v8_wasm_fuzzer") { + forward_variables_from(invoker, "*") + v8_fuzzer(target_name) { + deps = [ + ":wasm_fuzzer_common", + ":wasm_test_common", + ] + } + } + + v8_wasm_fuzzer("wasm_fuzzer") { + sources = [ "test/fuzzer/wasm.cc" ] + } + + v8_wasm_fuzzer("wasm_async_fuzzer") { + sources = [ "test/fuzzer/wasm-async.cc" ] + } + + v8_wasm_fuzzer("wasm_code_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-code.cc", + ] + } + + v8_wasm_fuzzer("wasm_compile_all_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile-all.cc", + ] + } + + v8_wasm_fuzzer("wasm_compile_fuzzer") { sources = [ "test/common/wasm/test-signatures.h", "test/fuzzer/wasm-compile.cc", ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] } - v8_fuzzer("wasm_compile_fuzzer") { - } - - v8_source_set("wasm_compile_simd_fuzzer") { + v8_wasm_fuzzer("wasm_compile_simd_fuzzer") { sources = [ "test/common/wasm/test-signatures.h", "test/fuzzer/wasm-compile-simd.cc", ] + } - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", + v8_wasm_fuzzer("wasm_compile_wasmgc_fuzzer") { + sources = [ + "test/common/wasm/test-signatures.h", + "test/fuzzer/wasm-compile-wasmgc.cc", ] } - v8_fuzzer("wasm_compile_simd_fuzzer") { - } - - v8_source_set("wasm_streaming_fuzzer") { + v8_wasm_fuzzer("wasm_streaming_fuzzer") { sources = [ "test/fuzzer/wasm-streaming.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] } - v8_fuzzer("wasm_streaming_fuzzer") { - } - - v8_source_set("wasm_init_expr_fuzzer") { + v8_wasm_fuzzer("wasm_init_expr_fuzzer") { sources = [ "test/fuzzer/wasm-init-expr.cc" ] - - deps = [ - ":fuzzer_support", - ":lib_wasm_fuzzer_common", - ":wasm_test_common", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] } - - v8_fuzzer("wasm_init_expr_fuzzer") { - } -} - -v8_source_set("inspector_fuzzer") { - sources = [ "test/fuzzer/inspector-fuzzer.cc" ] - - deps = [ - ":fuzzer_support", - "test/inspector:inspector_test", - ] - - configs = [ - ":external_config", - ":internal_config_base", - ] } v8_fuzzer("inspector_fuzzer") { + sources = [ "test/fuzzer/inspector-fuzzer.cc" ] + deps = [ "test/inspector:inspector_test" ] } # Target to build all generated .cc files. @@ -7920,334 +7877,6 @@ group("v8_generated_cc_files") { # Protobuf targets, used only when building outside of chromium. if (!build_with_chromium && v8_use_perfetto) { - # This config is applied to the autogenerated .pb.{cc,h} files in - # proto_library.gni. This config is propagated up to the source sets - # that depend on generated proto headers. - config("protobuf_gen_config") { - defines = [ - "GOOGLE_PROTOBUF_NO_RTTI", - "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", - ] - cflags = [ - "-Wno-unknown-warning-option", - "-Wno-deprecated", - "-Wno-undef", - "-Wno-zero-as-null-pointer-constant", - "-Wno-thread-safety-attributes", - ] - include_dirs = [ "third_party/protobuf/src" ] - } - - # Configuration used to build libprotobuf_* and the protoc compiler. - config("protobuf_config") { - # Apply the lighter supressions and macro definitions from above. - configs = [ ":protobuf_gen_config" ] - - if (!is_win) { - defines = [ "HAVE_PTHREAD=1" ] - } - if (is_clang) { - cflags = [ - "-Wno-unused-private-field", - "-Wno-unused-function", - "-Wno-inconsistent-missing-override", - "-Wno-unknown-warning-option", - "-Wno-enum-compare-switch", - "-Wno-user-defined-warnings", - "-Wno-tautological-constant-compare", - ] - } - if (is_win && is_clang) { - cflags += [ "-Wno-microsoft-unqualified-friend" ] - } - } - - source_set("protobuf_lite") { - sources = [ - "third_party/protobuf/src/google/protobuf/any_lite.cc", - "third_party/protobuf/src/google/protobuf/arena.cc", - "third_party/protobuf/src/google/protobuf/arena.h", - "third_party/protobuf/src/google/protobuf/arena_impl.h", - "third_party/protobuf/src/google/protobuf/arenastring.h", - "third_party/protobuf/src/google/protobuf/extension_set.cc", - "third_party/protobuf/src/google/protobuf/extension_set.h", - "third_party/protobuf/src/google/protobuf/generated_enum_util.cc", - "third_party/protobuf/src/google/protobuf/generated_enum_util.h", - "third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc", - "third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h", - "third_party/protobuf/src/google/protobuf/generated_message_util.cc", - "third_party/protobuf/src/google/protobuf/generated_message_util.h", - "third_party/protobuf/src/google/protobuf/has_bits.h", - "third_party/protobuf/src/google/protobuf/implicit_weak_message.cc", - "third_party/protobuf/src/google/protobuf/implicit_weak_message.h", - "third_party/protobuf/src/google/protobuf/inlined_string_field.h", - "third_party/protobuf/src/google/protobuf/io/coded_stream.cc", - "third_party/protobuf/src/google/protobuf/io/coded_stream.h", - "third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h", - "third_party/protobuf/src/google/protobuf/io/io_win32.cc", - "third_party/protobuf/src/google/protobuf/io/io_win32.h", - "third_party/protobuf/src/google/protobuf/io/strtod.cc", - "third_party/protobuf/src/google/protobuf/io/strtod.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc", - "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h", - "third_party/protobuf/src/google/protobuf/map.h", - "third_party/protobuf/src/google/protobuf/map_entry_lite.h", - "third_party/protobuf/src/google/protobuf/map_field_lite.h", - "third_party/protobuf/src/google/protobuf/map_type_handler.h", - "third_party/protobuf/src/google/protobuf/message_lite.cc", - "third_party/protobuf/src/google/protobuf/message_lite.h", - "third_party/protobuf/src/google/protobuf/repeated_field.cc", - "third_party/protobuf/src/google/protobuf/repeated_field.h", - "third_party/protobuf/src/google/protobuf/stubs/bytestream.cc", - "third_party/protobuf/src/google/protobuf/stubs/bytestream.h", - "third_party/protobuf/src/google/protobuf/stubs/callback.h", - "third_party/protobuf/src/google/protobuf/stubs/casts.h", - "third_party/protobuf/src/google/protobuf/stubs/common.cc", - "third_party/protobuf/src/google/protobuf/stubs/common.h", - "third_party/protobuf/src/google/protobuf/stubs/fastmem.h", - "third_party/protobuf/src/google/protobuf/stubs/hash.h", - "third_party/protobuf/src/google/protobuf/stubs/int128.cc", - "third_party/protobuf/src/google/protobuf/stubs/int128.h", - "third_party/protobuf/src/google/protobuf/stubs/logging.h", - "third_party/protobuf/src/google/protobuf/stubs/macros.h", - "third_party/protobuf/src/google/protobuf/stubs/map_util.h", - "third_party/protobuf/src/google/protobuf/stubs/mutex.h", - "third_party/protobuf/src/google/protobuf/stubs/once.h", - "third_party/protobuf/src/google/protobuf/stubs/platform_macros.h", - "third_party/protobuf/src/google/protobuf/stubs/port.h", - "third_party/protobuf/src/google/protobuf/stubs/status.cc", - "third_party/protobuf/src/google/protobuf/stubs/status.h", - "third_party/protobuf/src/google/protobuf/stubs/status_macros.h", - "third_party/protobuf/src/google/protobuf/stubs/statusor.cc", - "third_party/protobuf/src/google/protobuf/stubs/statusor.h", - "third_party/protobuf/src/google/protobuf/stubs/stl_util.h", - "third_party/protobuf/src/google/protobuf/stubs/stringpiece.cc", - "third_party/protobuf/src/google/protobuf/stubs/stringpiece.h", - "third_party/protobuf/src/google/protobuf/stubs/stringprintf.cc", - "third_party/protobuf/src/google/protobuf/stubs/stringprintf.h", - "third_party/protobuf/src/google/protobuf/stubs/structurally_valid.cc", - "third_party/protobuf/src/google/protobuf/stubs/strutil.cc", - "third_party/protobuf/src/google/protobuf/stubs/strutil.h", - "third_party/protobuf/src/google/protobuf/stubs/template_util.h", - "third_party/protobuf/src/google/protobuf/stubs/time.cc", - "third_party/protobuf/src/google/protobuf/stubs/time.h", - "third_party/protobuf/src/google/protobuf/wire_format_lite.cc", - "third_party/protobuf/src/google/protobuf/wire_format_lite.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - # This target should be used only by the protoc compiler and by test targets. - source_set("protobuf_full") { - deps = [ ":protobuf_lite" ] - sources = [ - "third_party/protobuf/src/google/protobuf/any.cc", - "third_party/protobuf/src/google/protobuf/any.h", - "third_party/protobuf/src/google/protobuf/any.pb.cc", - "third_party/protobuf/src/google/protobuf/any.pb.h", - "third_party/protobuf/src/google/protobuf/api.pb.cc", - "third_party/protobuf/src/google/protobuf/api.pb.h", - "third_party/protobuf/src/google/protobuf/compiler/importer.cc", - "third_party/protobuf/src/google/protobuf/compiler/importer.h", - "third_party/protobuf/src/google/protobuf/compiler/parser.cc", - "third_party/protobuf/src/google/protobuf/compiler/parser.h", - "third_party/protobuf/src/google/protobuf/descriptor.cc", - "third_party/protobuf/src/google/protobuf/descriptor.h", - "third_party/protobuf/src/google/protobuf/descriptor.pb.cc", - "third_party/protobuf/src/google/protobuf/descriptor.pb.h", - "third_party/protobuf/src/google/protobuf/descriptor_database.cc", - "third_party/protobuf/src/google/protobuf/descriptor_database.h", - "third_party/protobuf/src/google/protobuf/duration.pb.cc", - "third_party/protobuf/src/google/protobuf/duration.pb.h", - "third_party/protobuf/src/google/protobuf/dynamic_message.cc", - "third_party/protobuf/src/google/protobuf/dynamic_message.h", - "third_party/protobuf/src/google/protobuf/empty.pb.cc", - "third_party/protobuf/src/google/protobuf/empty.pb.h", - "third_party/protobuf/src/google/protobuf/extension_set_heavy.cc", - "third_party/protobuf/src/google/protobuf/field_mask.pb.cc", - "third_party/protobuf/src/google/protobuf/field_mask.pb.h", - "third_party/protobuf/src/google/protobuf/generated_enum_reflection.h", - "third_party/protobuf/src/google/protobuf/generated_message_reflection.cc", - "third_party/protobuf/src/google/protobuf/generated_message_reflection.h", - "third_party/protobuf/src/google/protobuf/io/gzip_stream.cc", - "third_party/protobuf/src/google/protobuf/io/gzip_stream.h", - "third_party/protobuf/src/google/protobuf/io/printer.cc", - "third_party/protobuf/src/google/protobuf/io/printer.h", - "third_party/protobuf/src/google/protobuf/io/tokenizer.cc", - "third_party/protobuf/src/google/protobuf/io/tokenizer.h", - "third_party/protobuf/src/google/protobuf/map_entry.h", - "third_party/protobuf/src/google/protobuf/map_field.cc", - "third_party/protobuf/src/google/protobuf/map_field.h", - "third_party/protobuf/src/google/protobuf/map_field_inl.h", - "third_party/protobuf/src/google/protobuf/message.cc", - "third_party/protobuf/src/google/protobuf/message.h", - "third_party/protobuf/src/google/protobuf/metadata.h", - "third_party/protobuf/src/google/protobuf/reflection.h", - "third_party/protobuf/src/google/protobuf/reflection_internal.h", - "third_party/protobuf/src/google/protobuf/reflection_ops.cc", - "third_party/protobuf/src/google/protobuf/reflection_ops.h", - "third_party/protobuf/src/google/protobuf/service.cc", - "third_party/protobuf/src/google/protobuf/service.h", - "third_party/protobuf/src/google/protobuf/source_context.pb.cc", - "third_party/protobuf/src/google/protobuf/source_context.pb.h", - "third_party/protobuf/src/google/protobuf/struct.pb.cc", - "third_party/protobuf/src/google/protobuf/struct.pb.h", - "third_party/protobuf/src/google/protobuf/stubs/mathlimits.cc", - "third_party/protobuf/src/google/protobuf/stubs/mathlimits.h", - "third_party/protobuf/src/google/protobuf/stubs/mathutil.h", - "third_party/protobuf/src/google/protobuf/stubs/substitute.cc", - "third_party/protobuf/src/google/protobuf/stubs/substitute.h", - "third_party/protobuf/src/google/protobuf/text_format.cc", - "third_party/protobuf/src/google/protobuf/text_format.h", - "third_party/protobuf/src/google/protobuf/timestamp.pb.cc", - "third_party/protobuf/src/google/protobuf/timestamp.pb.h", - "third_party/protobuf/src/google/protobuf/type.pb.cc", - "third_party/protobuf/src/google/protobuf/type.pb.h", - "third_party/protobuf/src/google/protobuf/unknown_field_set.cc", - "third_party/protobuf/src/google/protobuf/unknown_field_set.h", - "third_party/protobuf/src/google/protobuf/util/field_comparator.cc", - "third_party/protobuf/src/google/protobuf/util/field_comparator.h", - "third_party/protobuf/src/google/protobuf/util/field_mask_util.cc", - "third_party/protobuf/src/google/protobuf/util/field_mask_util.h", - "third_party/protobuf/src/google/protobuf/util/internal/constants.h", - "third_party/protobuf/src/google/protobuf/util/internal/datapiece.cc", - "third_party/protobuf/src/google/protobuf/util/internal/datapiece.h", - "third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/error_listener.cc", - "third_party/protobuf/src/google/protobuf/util/internal/error_listener.h", - "third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc", - "third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_escaping.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_escaping.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc", - "third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.h", - "third_party/protobuf/src/google/protobuf/util/internal/location_tracker.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_location_tracker.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_source.h", - "third_party/protobuf/src/google/protobuf/util/internal/object_writer.cc", - "third_party/protobuf/src/google/protobuf/util/internal/object_writer.h", - "third_party/protobuf/src/google/protobuf/util/internal/proto_writer.cc", - "third_party/protobuf/src/google/protobuf/util/internal/proto_writer.h", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc", - "third_party/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/structured_objectwriter.h", - "third_party/protobuf/src/google/protobuf/util/internal/type_info.cc", - "third_party/protobuf/src/google/protobuf/util/internal/type_info.h", - "third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc", - "third_party/protobuf/src/google/protobuf/util/internal/type_info_test_helper.h", - "third_party/protobuf/src/google/protobuf/util/internal/utility.cc", - "third_party/protobuf/src/google/protobuf/util/internal/utility.h", - "third_party/protobuf/src/google/protobuf/util/json_util.cc", - "third_party/protobuf/src/google/protobuf/util/json_util.h", - "third_party/protobuf/src/google/protobuf/util/message_differencer.cc", - "third_party/protobuf/src/google/protobuf/util/message_differencer.h", - "third_party/protobuf/src/google/protobuf/util/time_util.cc", - "third_party/protobuf/src/google/protobuf/util/time_util.h", - "third_party/protobuf/src/google/protobuf/util/type_resolver.h", - "third_party/protobuf/src/google/protobuf/util/type_resolver_util.cc", - "third_party/protobuf/src/google/protobuf/util/type_resolver_util.h", - "third_party/protobuf/src/google/protobuf/wire_format.cc", - "third_party/protobuf/src/google/protobuf/wire_format.h", - "third_party/protobuf/src/google/protobuf/wrappers.pb.cc", - "third_party/protobuf/src/google/protobuf/wrappers.pb.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - if (current_toolchain == host_toolchain) { - source_set("protoc_lib") { - deps = [ ":protobuf_full" ] - sources = [ - "third_party/protobuf/src/google/protobuf/compiler/code_generator.cc", - "third_party/protobuf/src/google/protobuf/compiler/code_generator.h", - "third_party/protobuf/src/google/protobuf/compiler/command_line_interface.cc", - "third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_message_layout_helper.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc", - "third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h", - "third_party/protobuf/src/google/protobuf/compiler/plugin.cc", - "third_party/protobuf/src/google/protobuf/compiler/plugin.h", - "third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc", - "third_party/protobuf/src/google/protobuf/compiler/plugin.pb.h", - "third_party/protobuf/src/google/protobuf/compiler/subprocess.cc", - "third_party/protobuf/src/google/protobuf/compiler/subprocess.h", - "third_party/protobuf/src/google/protobuf/compiler/zip_writer.cc", - "third_party/protobuf/src/google/protobuf/compiler/zip_writer.h", - ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ - "//build/config/compiler:no_chromium_code", - ":protobuf_config", - ] - if (is_win) { - configs -= [ "//build/config/win:lean_and_mean" ] - } - public_configs = [ ":protobuf_gen_config" ] - } - - executable("protoc") { - deps = [ - ":protoc_lib", - "//build/win:default_exe_manifest", - ] - sources = [ "src/protobuf/protobuf-compiler-main.cc" ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - } - } # host_toolchain - v8_component("v8_libperfetto") { configs = [ ":v8_tracing_config" ] public_configs = [ "//third_party/perfetto/gn:public_config" ]