diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2024-01-26 13:38:42 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2024-02-22 12:48:48 +0000 |
commit | ada9ddbf8c604585ac344b72f7bb63ac27c84726 (patch) | |
tree | b541471f60775e79ce2a664f01f2cff4765dc6b2 /chromium/build/config/compiler/BUILD.gn | |
parent | bccd0c89f058482e730b73829d80bb6e8defa4c9 (diff) |
BASELINE: Update Chromium to 120.0.6099.272
Change-Id: Id1e3f32155016fcdca5b92e1739d85c6093bcf84
Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/534618
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/build/config/compiler/BUILD.gn')
-rw-r--r-- | chromium/build/config/compiler/BUILD.gn | 266 |
1 files changed, 180 insertions, 86 deletions
diff --git a/chromium/build/config/compiler/BUILD.gn b/chromium/build/config/compiler/BUILD.gn index 06812fb9c21..80bc79e5fb3 100644 --- a/chromium/build/config/compiler/BUILD.gn +++ b/chromium/build/config/compiler/BUILD.gn @@ -14,11 +14,12 @@ import("//build/config/coverage/coverage.gni") import("//build/config/dcheck_always_on.gni") import("//build/config/gclient_args.gni") import("//build/config/host_byteorder.gni") +import("//build/config/pch.gni") import("//build/config/rust.gni") -import("//build/config/sanitizers/sanitizers.gni") 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") @@ -86,6 +87,10 @@ declare_args() { # the needed gcov profiling data. auto_profile_path = "" + # Optimize for coverage guided fuzzing (balance between speed and number of + # branches) + optimize_for_fuzzing = false + # Path to an AFDO profile to use while building with clang, if any. Empty # implies none. clang_sample_profile_path = "" @@ -128,6 +133,11 @@ declare_args() { (is_chromeos || is_android || is_win || is_linux || is_mac || (is_ios && use_lld)) && is_official_build + # Whether to enable thin lto incremental builds. + # See: https://clang.llvm.org/docs/ThinLTO.html#incremental + # The cache can lead to non-determinism: https://crbug.com/1486045 + thin_lto_enable_cache = true + # Initialize all local variables with a pattern. This flag will fill # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the # rest with 0xAA. This makes behavior of uninitialized memory bugs consistent, @@ -146,10 +156,10 @@ declare_args() { # final binary. When enabled, the separated text sections with prefix # '.text.hot', '.text.unlikely', '.text.startup' and '.text.exit' will not be # merged to '.text' section. This allows us to identify the hot code section - # ('.text.hot') in the binary which may be mlocked or mapped to huge page to - # reduce TLB misses which gives performance improvement on cpu usage. - # The gold linker by default has text section splitting enabled. - use_text_section_splitting = false + # ('.text.hot') in the binary, which allows our data collection pipelines to + # more easily identify code that we assume to be hot/cold that doesn't turn + # out to be such in the field. + use_text_section_splitting = is_chromeos # Enable DWARF v5. use_dwarf5 = false @@ -370,10 +380,6 @@ config("compiler") { } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) { # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it. # See also https://crbug.com/533294 - if (current_os != "zos") { - cflags += [ "--param=ssp-buffer-size=4" ] - } - # The x86 toolchain currently has problems with stack-protector. if (is_android && current_cpu == "x86") { cflags += [ "-fno-stack-protector" ] @@ -481,6 +487,11 @@ config("compiler") { asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ] cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ] } + + # dsymutil is not available in the system, on bots, for rustc to call. Our + # linker_driver.py script runs dsymutil itself, which is set to be the + # linker for Rust targets as well. + rustflags += [ "-Csplit-debuginfo=unpacked" ] } # Linux/Android/Fuchsia common flags setup. @@ -605,6 +616,24 @@ config("compiler") { } } + # TODO(crbug.com/1488374): This causes binary size growth and potentially + # other problems. + # TODO(crbug.com/1491036): This isn't supported by Cronet's mainline llvm version. + if (default_toolchain != "//build/toolchain/cros:target" && + !llvm_android_mainline) { + cflags += [ + "-mllvm", + "-split-threshold-for-reg-with-hint=0", + ] + if (use_thin_lto && is_a_target_toolchain) { + if (is_win) { + ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ] + } else { + ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ] + } + } + } + # TODO(crbug.com/1235145): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=off" ] @@ -661,8 +690,7 @@ config("compiler") { } } else if (is_win) { cflags_c += [ "/std:c11" ] - if ((defined(use_cxx17) && use_cxx17) || - (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) { + if (defined(use_cxx17) && use_cxx17) { cflags_cc += [ "/std:c++17" ] } else { cflags_cc += [ "/std:c++20" ] @@ -709,9 +737,26 @@ config("compiler") { "-fsplit-lto-unit", ] - # Limit the size of the ThinLTO cache to the lesser of 10% of - # available disk space, 40GB and 100000 files. - cache_policy = "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000" + if (thin_lto_enable_cache) { + # Limit the size of the ThinLTO cache to the lesser of 10% of + # available disk space, 40GB and 100000 files. + cache_policy = + "cache_size=10%:cache_size_bytes=40g:cache_size_files=100000" + cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir) + if (is_win) { + ldflags += [ + "/lldltocache:$cache_dir", + "/lldltocachepolicy:$cache_policy", + ] + } else { + if (is_apple) { + ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ] + } else { + ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ] + } + ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ] + } + } # An import limit of 30 has better performance (per speedometer) and lower # binary size than the default setting of 100. @@ -723,9 +768,6 @@ config("compiler") { ldflags += [ "/opt:lldltojobs=all", "-mllvm:-import-instr-limit=$import_instr_limit", - "/lldltocache:" + - rebase_path("$root_out_dir/thinlto-cache", root_build_dir), - "/lldltocachepolicy:$cache_policy", "-mllvm:-disable-auto-upgrade-debug-info", ] } else { @@ -740,19 +782,6 @@ config("compiler") { # TODO(thakis): Check if '=0' (that is, number of cores, instead # of "all" which means number of hardware threads) is faster. ldflags += [ "-Wl,--thinlto-jobs=all" ] - if (is_apple) { - ldflags += [ - "-Wl,-cache_path_lto," + - rebase_path("$root_out_dir/thinlto-cache", root_build_dir), - "-Wcrl,object_path_lto", - ] - } else { - ldflags += - [ "-Wl,--thinlto-cache-dir=" + - rebase_path("$root_out_dir/thinlto-cache", root_build_dir) ] - } - - ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ] if (is_chromeos) { # ARM was originally set lower than x86 to keep the size @@ -768,6 +797,9 @@ config("compiler") { ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ] + if (is_apple) { + ldflags += [ "-Wcrl,object_path_lto" ] + } if (!is_chromeos) { # TODO(https://crbug.com/972449): turn on for ChromeOS when that # toolchain has this flag. @@ -782,13 +814,18 @@ config("compiler") { if (!is_android || current_cpu == "arm64") { cflags += [ "-fwhole-program-vtables" ] - # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match - # behaviour. Rust needs to know the linker will be doing LTO in this case - # or it rejects the Zsplit-lto-unit flag. - rustflags += [ - "-Zsplit-lto-unit", - "-Clinker-plugin-lto=yes", - ] + if (toolchain_supports_rust_thin_lto) { + # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match + # behaviour. Rust needs to know the linker will be doing LTO in this case + # or it rejects the Zsplit-lto-unit flag. + rustflags += [ + "-Zsplit-lto-unit", + "-Clinker-plugin-lto=yes", + ] + } else { + # Don't include bitcode if it won't be used. + rustflags += [ "-Cembed-bitcode=no" ] + } if (!is_win) { ldflags += [ "-fwhole-program-vtables" ] @@ -808,6 +845,9 @@ config("compiler") { if (compiler_timing) { if (is_clang && !is_nacl) { cflags += [ "-ftime-trace" ] + if (use_lld && is_mac) { + ldflags += [ "-Wl,--time-trace" ] + } } else if (is_win) { cflags += [ # "Documented" here: @@ -1020,7 +1060,13 @@ config("compiler") { # TODO(https://crbug.com/702997): Move this back to the `runtime_library` # config when NaCl is removed. if (use_safe_libcxx) { - defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] + # TODO(https://crbug.com/1465186): Switch saigo to hardened mode once + # it's rolled in. + if (is_nacl_saigo) { + defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ] + } else { + defines += [ "_LIBCPP_ENABLE_SAFE_MODE=1" ] + } } } @@ -1036,10 +1082,15 @@ config("thinlto_optimize_default") { ldflags = [ "-Wl,--lto-O" + lto_opt_level ] } - # We always point Rust to a linker that performs LTO, so we don't want Rust - # to preemptively do so during compilation too or they conflict. But we do - # want Rust to generate LTO metadata in order for the linker to do its job. - rustflags = [ "-Clinker-plugin-lto=yes" ] + if (toolchain_supports_rust_thin_lto) { + # We always point Rust to a linker that performs LTO, so we don't want Rust + # to preemptively do so during compilation too or they conflict. But we do + # want Rust to generate LTO metadata in order for the linker to do its job. + rustflags = [ "-Clinker-plugin-lto=yes" ] + } else { + # Don't include bitcode if it won't be used. + rustflags = [ "-Cembed-bitcode=no" ] + } } } @@ -1065,10 +1116,15 @@ config("thinlto_optimize_max") { ldflags = [ "-Wl,--lto-O" + lto_opt_level ] } - # We always point Rust to a linker that performs LTO, so we don't want Rust - # to preemptively do so during compilation too or they conflict. But we do - # want Rust to generate LTO metadata in order for the linker to do its job. - rustflags = [ "-Clinker-plugin-lto=yes" ] + if (toolchain_supports_rust_thin_lto) { + # We always point Rust to a linker that performs LTO, so we don't want Rust + # to preemptively do so during compilation too or they conflict. But we do + # want Rust to generate LTO metadata in order for the linker to do its job. + rustflags = [ "-Clinker-plugin-lto=yes" ] + } else { + # Don't include bitcode if it won't be used. + rustflags = [ "-Cembed-bitcode=no" ] + } } } @@ -1087,12 +1143,6 @@ config("compiler_cpu_abi") { configs += [ "//build/config/chromeos:compiler_cpu_abi" ] } - # TODO(https://crbug.com/1383873): Remove this once figured out. - if (is_apple && current_cpu == "arm64") { - cflags += [ "-fno-global-isel" ] - ldflags += [ "-fno-global-isel" ] - } - if ((is_posix && !is_apple) || is_fuchsia) { # CPU architecture. We may or may not be doing a cross compile now, so for # simplicity we always explicitly set the architecture. @@ -1101,6 +1151,17 @@ config("compiler_cpu_abi") { "-m64", "-msse3", ] + + # Minimum SIMD support for devices running lacros. + # See https://crbug.com/1475858 + if (is_chromeos_lacros) { + cflags += [ + "-mssse3", + "-msse4", + "-msse4.1", + "-msse4.2", + ] + } ldflags += [ "-m64" ] } else if (current_cpu == "x86") { cflags += [ "-m32" ] @@ -1637,6 +1698,32 @@ config("runtime_library") { } } +# treat_warnings_as_errors ---------------------------------------------------- +# +# Adding this config causes the compiler to treat warnings as fatal errors. +# This is used as a subconfig of both chromium_code and no_chromium_code, and +# is broken out separately so nocompile tests can force-enable this setting +# independently of the default warning flags. +config("treat_warnings_as_errors") { + if (is_win) { + cflags = [ "/WX" ] + } else { + cflags = [ "-Werror" ] + + # The compiler driver can sometimes (rarely) emit warnings before calling + # the actual linker. Make sure these warnings are treated as errors as + # well. + ldflags = [ "-Werror" ] + } + + # Turn rustc warnings into the "deny" lint level, which produce compiler + # errors. The equivalent of -Werror for clang/gcc. + # + # Note we apply the actual lint flags in config("compiler"). All warnings + # are suppressed in third-party crates. + rustflags = [ "-Dwarnings" ] +} + # default_warnings ------------------------------------------------------------ # # Collects all warning flags that are used by default. This is used as a @@ -1647,11 +1734,9 @@ config("default_warnings") { cflags_c = [] cflags_cc = [] ldflags = [] + configs = [] if (is_win) { - if (treat_warnings_as_errors) { - cflags += [ "/WX" ] - } if (fatal_linker_warnings) { arflags = [ "/WX" ] ldflags = [ "/WX" ] @@ -1760,11 +1845,8 @@ config("default_warnings") { cflags += [ "-Wno-nonportable-include-path" ] } - if (is_fuchsia && llvm_force_head_revision) { + if (is_fuchsia) { cflags_cc += [ - # TODO(https://crbug.com/1474032): fix and reenable - "-Wno-deprecated-literal-operator", - # TODO(https://crbug.com/1474434): fix and reenable "-Wno-missing-field-initializers", ] @@ -1788,6 +1870,18 @@ config("default_warnings") { # TODO(crbug.com/1412713) Evaluate and possibly enable. "-Wno-deprecated-this-capture", + + # TODO(https://crbug.com/1491833): Fix and re-enable. + "-Wno-invalid-offsetof", + + # TODO(crbug.com/1494809): Evaluate and possibly enable. + "-Wno-vla-extension", + + # TODO(https://crbug.com/1490607): Fix and re-enable. + "-Wno-thread-safety-reference-return", + + # TODO(crbug.com/1495100): Evaluate and possibly enable. + "-Wno-delayed-template-parsing-in-cxx20", ] } } @@ -1795,7 +1889,7 @@ config("default_warnings") { # Some builders, such as Cronet, use a different version of Clang than # Chromium. This can cause minor errors when compiling Chromium changes. We # want to avoid these errors. - if (use_lenient_compiler_flags) { + if (llvm_android_mainline) { cflags += [ "-Wno-error=unknown-warning-option", "-Wno-error=unused-command-line-argument", @@ -1867,28 +1961,11 @@ config("chromium_code") { } } else { cflags = [ "-Wall" ] - if (treat_warnings_as_errors) { - cflags += [ "-Werror" ] - - # The compiler driver can sometimes (rarely) emit warnings before calling - # the actual linker. Make sure these warnings are treated as errors as - # well. - ldflags = [ "-Werror" ] - } if (is_clang) { # Enable extra warnings for chromium_code when we control the compiler. cflags += [ "-Wextra" ] } - if (treat_warnings_as_errors) { - # Turn rustc warnings into the "deny" lint level, which produce compiler - # errors. The equivalent of -Werror for clang/gcc. - # - # Note we apply the actual lint flags in config("compiler"). All warnings - # are suppressed in third-party crates. - rustflags = [ "-Dwarnings" ] - } - # In Chromium code, we define __STDC_foo_MACROS in order to get the # C99 macros on Mac and Linux. defines = [ @@ -1905,9 +1982,10 @@ config("chromium_code") { # disabled, so only do that for Release build. fortify_level = "2" - # ChromeOS supports a high-quality _FORTIFY_SOURCE=3 implementation - # with a few custom glibc patches. Use that if it's available. - if (is_chromeos_ash) { + # ChromeOS's toolchain supports a high-quality _FORTIFY_SOURCE=3 + # implementation with a few custom glibc patches. Use that if it's + # available. + if (is_chromeos_device && !lacros_use_chromium_toolchain) { fortify_level = "3" } defines += [ "_FORTIFY_SOURCE=" + fortify_level ] @@ -1952,6 +2030,9 @@ config("chromium_code") { ":default_warnings", ":noshadowing", ] + if (treat_warnings_as_errors) { + configs += [ ":treat_warnings_as_errors" ] + } } config("no_chromium_code") { @@ -1968,12 +2049,6 @@ config("no_chromium_code") { "/wd4267", # TODO(jschuh): size_t to int. ] } else { - # GCC may emit unsuppressible warnings so don't add -Werror for no chromium - # code. crbug.com/589724 - if (treat_warnings_as_errors && is_clang) { - cflags += [ "-Werror" ] - ldflags = [ "-Werror" ] - } if (is_clang && !is_nacl) { # TODO(thakis): Remove !is_nacl once # https://codereview.webrtc.org/1552863002/ made its way into chromium. @@ -2007,6 +2082,12 @@ config("no_chromium_code") { rustflags = [ "--cap-lints=allow" ] configs = [ ":default_warnings" ] + + # GCC may emit unsuppressible warnings so only apply this config when + # building with clang. crbug.com/589724 + if (treat_warnings_as_errors && is_clang) { + configs += [ ":treat_warnings_as_errors" ] + } } # noshadowing ----------------------------------------------------------------- @@ -2198,6 +2279,11 @@ if (is_win) { common_optimize_on_ldflags += [ "/OPT:REF" ] # Remove unreferenced data. # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772 } + + if (is_clang) { + # See below. + common_optimize_on_cflags += [ "/clang:-fno-math-errno" ] + } } else { common_optimize_on_cflags = [] common_optimize_on_ldflags = [] @@ -2246,6 +2332,14 @@ if (is_win) { "-Wl,--gc-sections", ] } + + # We cannot rely on errno being set after math functions, + # especially since glibc does not set it. Thus, use -fno-math-errno + # so that the compiler knows it can inline math functions. + # Note that this is different from -ffast-math (even though -ffast-math + # implies -fno-math-errno), which also allows a number of unsafe + # optimizations. + common_optimize_on_cflags += [ "-fno-math-errno" ] } config("default_stack_frames") { |