update compiler build.gns

This commit is contained in:
Alexander Frick 2024-10-03 07:43:39 -05:00
parent 1220b3f467
commit c7471c965b
9 changed files with 865 additions and 382 deletions

View file

@ -435,7 +435,11 @@ config("compiler") {
# links.
ldflags += [ "-Wl,--build-id=sha1" ]
} else if (current_os != "aix" && current_os != "zos") {
ldflags += [ "-Wl,--build-id" ]
if (use_lld && !is_nacl) {
ldflags += [ "-Wl,--build-id=fast" ]
} else {
ldflags += [ "-Wl,--build-id" ]
}
}
if (!is_android) {
@ -541,6 +545,13 @@ config("compiler") {
# but for now it looks like our build might rely on it
# (https://crbug.com/829795).
cflags += [ "-fmerge-all-constants" ]
# TODO(crbug.com/345541122): investigate the fuchsia binary size increase.
if (is_win) {
cflags += [ "/Zc:sizedDealloc" ]
} else {
cflags += [ "-fsized-deallocation" ]
}
}
if (use_lld) {
@ -562,7 +573,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
if (is_clang && !is_nacl && current_os != "zos") {
if (is_clang && !is_nacl) {
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@ -591,14 +602,14 @@ config("compiler") {
if (default_toolchain != "//build/toolchain/cros:target" &&
!llvm_android_mainline) {
cflags += [
"-mllvm",
"-split-threshold-for-reg-with-hint=0",
# "-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" ]
# ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
} else {
ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
# ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
}
}
}
@ -664,6 +675,12 @@ config("compiler") {
} else {
cflags_cc += [ "/std:c++20" ]
}
if (!is_clang) {
# Required for the __cplusplus macro definition to match the C++ version
# on MSVC. clang-cl defines it by default and doesn't need this flag.
# See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
cflags_cc += [ "/Zc:__cplusplus" ]
}
} else if (!is_nacl) {
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
@ -679,7 +696,7 @@ config("compiler") {
}
}
if (is_clang && current_os != "zos") {
if (is_clang) {
# C++17 removes trigraph support, but clang still warns that it ignores
# them when seeing them. Don't.
cflags_cc += [ "-Wno-trigraphs" ]
@ -754,7 +771,7 @@ config("compiler") {
# [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
import_instr_limit = 100
if (is_win) {
ldflags += [
@ -780,13 +797,11 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# 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 || use_order_profiling)) {
# Reduce inlining for the orderfile instrumented build to mitigate
# crbug.com/330761384.
import_instr_limit = 100
} else if (is_android && optimize_for_size) {
# 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
import_instr_limit = 100
}
ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
@ -800,8 +815,7 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
}
# TODO(crbug.com/335365324): Enable on other platforms.
if (is_android && !optimize_for_size) {
if (!optimize_for_size) {
# Ideally the compiler would handle this automatically with PGO (see
# comments at https://crrev.com/c/5440500).
#
@ -812,7 +826,11 @@ config("compiler") {
"-mllvm",
"-inlinehint-threshold=360",
]
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
if (is_win) {
ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
} else {
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
}
}
# TODO(crbug.com/40182783): investigate why this isn't effective on
@ -1036,7 +1054,7 @@ config("compiler") {
]
if (current_cpu == "arm64") {
rustflags += [ "-Cllvm-args=-fp-contract=fast", ]
rustflags += [ "-Cllvm-args=-fp-contract=fast", "-Ctarget-feature=+neon", ]
}
if (!is_win || force_rustc_color_output) {
@ -1205,7 +1223,7 @@ config("compiler_cpu_abi") {
"-maes",
"-mavx",
]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4", "-msse4.1", "-msse4.2", "-mpclmul", "-maes", "-mavx", "-Wl,-mllvm,-import-instr-limit=30", ]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4", "-msse4.1", "-msse4.2", "-mpclmul", "-maes", "-mavx", "-Wl,-mllvm,-import-instr-limit=100", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
@ -1588,7 +1606,13 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
# Convert absolute paths to relative paths. Expands to, for example:
# -file-prefix-map /path/to/chromium/src=../..
swiftflags += [
"-file-prefix-map",
rebase_path("//.", "") + "=" + rebase_path("//.", root_build_dir),
]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1628,7 +1652,8 @@ config("compiler_deterministic") {
}
config("clang_revision") {
if (is_clang && clang_base_path == default_clang_base_path) {
if (is_clang && clang_base_path == default_clang_base_path &&
current_os != "zos") {
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@ -1685,6 +1710,34 @@ config("compiler_arm") {
}
}
config("libcxx_module") {
if (use_libcxx_modules) {
modulemap = rebase_path("//third_party/libc++/src/include/module.modulemap",
root_build_dir)
cflags_cc = [
"-fmodules",
"-fmodule-map-file=" + modulemap,
"-fno-implicit-module-maps",
"-fbuiltin-module-map",
"-fmodules-cache-path=" +
rebase_path("$libcxx_module_prefix/module_cache", root_build_dir),
"-Xclang",
"-fmodules-local-submodule-visibility", # required for builtins
# TODO(crbug.com/1456385): Figure out if this can be removed.
"-Wno-modules-ambiguous-internal-linkage",
# TODO(crbug.com/40440396): Clean up.
"-Wno-modules-import-nested-redundant",
# Needed to allow using builtin modules when the headers are
# unnecessarily using extern "C".
"-Wno-module-import-in-extern-c",
]
}
}
# runtime_library -------------------------------------------------------------
#
# Sets the runtime library and associated options.
@ -1914,9 +1967,6 @@ config("default_warnings") {
# TODO(https://crbug.com/324953188): fix and reenable
"-Wno-extra-qualification",
# TODO(https://crbug.com/332931387): fix and reenable
"-Wno-unused-but-set-variable",
]
}
@ -1924,16 +1974,9 @@ config("default_warnings") {
# 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/40231599) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
# TODO(crbug.com/40234766) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/40255410) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
@ -1957,6 +2000,9 @@ config("default_warnings") {
# TODO(crbug.com/41486292): Fix and re-enable.
"-Wno-c++11-narrowing-const-reference",
]
# TODO(crbug.com/344680447): Fix and re-enable.
cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
}
}
@ -1972,6 +2018,11 @@ config("default_warnings") {
}
}
# TODO(crbug.com/354162568): Clean up and enable.
if (llvm_force_head_revision && is_apple && use_lld) {
ldflags += [ "-Wl,--no-warn-duplicate-rpath" ]
}
# Rust warnings
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
@ -2361,7 +2412,6 @@ if (is_win) {
]
common_optimize_on_ldflags += [
"-mllvm:-enable-interleaved-mem-accesses",
"-mllvm:-aggressive-ext-opt",
"-mllvm:-enable-gvn-hoist",
]
@ -2406,7 +2456,6 @@ if (is_win) {
}
common_optimize_on_cflags += [
"-mllvm", "-enable-interleaved-mem-accesses",
"-mllvm", "-aggressive-ext-opt",
"-mllvm", "-enable-gvn-hoist",
"-O3",
@ -2420,7 +2469,6 @@ if (is_win) {
}
common_optimize_on_ldflags += [
"-Wl,-mllvm,-enable-interleaved-mem-accesses",
"-Wl,-mllvm,-aggressive-ext-opt",
"-Wl,-mllvm,-enable-gvn-hoist",
"-Wl,-O3",
@ -2591,14 +2639,17 @@ config("default_stack_frames") {
# [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" ]
}
# clang-cl's /O2 corresponds to clang's -O3, and really want -O3 for
# consistency with the other platforms.
cflags = [
"/O2",
"-Xclang", "-O3",
"/clang:-O3",
] + common_optimize_on_cflags
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
# The `-O3` for clang turns on extra optimizations compared to the standard
# `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
# to use.
rustflags = [ "-Copt-level=3" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
@ -2780,12 +2831,10 @@ if (is_clang && is_a_target_toolchain) {
if (is_android || is_castos) {
_clang_sample_profile = "//chrome/android/profiles/afdo.prof"
} else {
assert(
chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp",
"Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
assert(chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm",
"Only 'atom', 'bigcore', and 'arm' are valid ChromeOS profiles.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2908,7 +2957,8 @@ config("symbols") {
}
# On aix -gdwarf causes linker failures due to thread_local variables.
if (!is_nacl && current_os != "aix") {
# On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE.
if (!is_nacl && current_os != "aix" && current_os != "zos") {
if (use_dwarf5) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
@ -2992,13 +3042,12 @@ config("symbols") {
# 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) &&
if (symbol_level == 2 && !use_debug_fission && !is_nacl && !is_win &&
(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_clang && (!is_nacl || is_nacl_saigo)) {
if (is_apple) {
# TODO(crbug.com/40117949): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@ -3082,7 +3131,7 @@ config("minimal_symbols") {
cflags += [ "-g1" ]
}
if (!is_nacl && is_clang && !is_tsan && !is_asan) {
if (!is_nacl && is_clang && !is_tsan && !is_asan && current_os != "zos") {
# See comment for -gdwarf-aranges in config("symbols").
cflags += [ "-gdwarf-aranges" ]
}

View file

@ -432,7 +432,11 @@ config("compiler") {
# links.
ldflags += [ "-Wl,--build-id=sha1" ]
} else if (current_os != "aix" && current_os != "zos") {
ldflags += [ "-Wl,--build-id" ]
if (use_lld && !is_nacl) {
ldflags += [ "-Wl,--build-id=fast" ]
} else {
ldflags += [ "-Wl,--build-id" ]
}
}
if (!is_android) {
@ -538,6 +542,13 @@ config("compiler") {
# but for now it looks like our build might rely on it
# (https://crbug.com/829795).
cflags += [ "-fmerge-all-constants" ]
# TODO(crbug.com/345541122): investigate the fuchsia binary size increase.
if (is_win) {
cflags += [ "/Zc:sizedDealloc" ]
} else {
cflags += [ "-fsized-deallocation" ]
}
}
if (use_lld) {
@ -559,7 +570,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
if (is_clang && !is_nacl && current_os != "zos") {
if (is_clang && !is_nacl) {
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@ -588,14 +599,14 @@ config("compiler") {
if (default_toolchain != "//build/toolchain/cros:target" &&
!llvm_android_mainline) {
cflags += [
"-mllvm",
"-split-threshold-for-reg-with-hint=0",
# "-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" ]
# ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
} else {
ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
# ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
}
}
}
@ -661,6 +672,12 @@ config("compiler") {
} else {
cflags_cc += [ "/std:c++20" ]
}
if (!is_clang) {
# Required for the __cplusplus macro definition to match the C++ version
# on MSVC. clang-cl defines it by default and doesn't need this flag.
# See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
cflags_cc += [ "/Zc:__cplusplus" ]
}
} else if (!is_nacl) {
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
@ -676,7 +693,7 @@ config("compiler") {
}
}
if (is_clang && current_os != "zos") {
if (is_clang) {
# C++17 removes trigraph support, but clang still warns that it ignores
# them when seeing them. Don't.
cflags_cc += [ "-Wno-trigraphs" ]
@ -751,7 +768,7 @@ config("compiler") {
# [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
import_instr_limit = 100
if (is_win) {
ldflags += [
@ -777,13 +794,11 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# 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 || use_order_profiling)) {
# Reduce inlining for the orderfile instrumented build to mitigate
# crbug.com/330761384.
import_instr_limit = 100
} else if (is_android && optimize_for_size) {
# 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
import_instr_limit = 100
}
ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
@ -797,8 +812,7 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
}
# TODO(crbug.com/335365324): Enable on other platforms.
if (is_android && !optimize_for_size) {
if (!optimize_for_size) {
# Ideally the compiler would handle this automatically with PGO (see
# comments at https://crrev.com/c/5440500).
#
@ -809,7 +823,11 @@ config("compiler") {
"-mllvm",
"-inlinehint-threshold=360",
]
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
if (is_win) {
ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
} else {
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
}
}
# TODO(crbug.com/40182783): investigate why this isn't effective on
@ -1086,6 +1104,16 @@ config("compiler") {
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
# 64-bit Android sometimes defines __ARM_NEON but not __ARM_NEON__.
# 32-bit Android builds and macOS, however, define __ARM_NEON__,
# and code typically checks for this.
#
# Reduce confusion by making the __ARM_NEON__ #define always available,
# as NEON is a mandatory part of ARMv8 anyway.
if (current_cpu == "arm64") {
defines += [ "__ARM_NEON__=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1192,7 +1220,7 @@ config("compiler_cpu_abi") {
"-mtune=haswell",
"-ffp-contract=fast",
]
ldflags += [ "-m64", "-Wl,-O3", "-Wl,-mllvm,-march=haswell", "-Wl,-mllvm,-fp-contract=fast", "-Wl,-mllvm,-import-instr-limit=30", ]
ldflags += [ "-m64", "-Wl,-O3", "-Wl,-mllvm,-march=haswell", "-Wl,-mllvm,-fp-contract=fast", "-Wl,-mllvm,-import-instr-limit=100", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
@ -1567,7 +1595,13 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
# Convert absolute paths to relative paths. Expands to, for example:
# -file-prefix-map /path/to/chromium/src=../..
swiftflags += [
"-file-prefix-map",
rebase_path("//.", "") + "=" + rebase_path("//.", root_build_dir),
]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1607,7 +1641,8 @@ config("compiler_deterministic") {
}
config("clang_revision") {
if (is_clang && clang_base_path == default_clang_base_path) {
if (is_clang && clang_base_path == default_clang_base_path &&
current_os != "zos") {
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@ -1664,6 +1699,34 @@ config("compiler_arm") {
}
}
config("libcxx_module") {
if (use_libcxx_modules) {
modulemap = rebase_path("//third_party/libc++/src/include/module.modulemap",
root_build_dir)
cflags_cc = [
"-fmodules",
"-fmodule-map-file=" + modulemap,
"-fno-implicit-module-maps",
"-fbuiltin-module-map",
"-fmodules-cache-path=" +
rebase_path("$libcxx_module_prefix/module_cache", root_build_dir),
"-Xclang",
"-fmodules-local-submodule-visibility", # required for builtins
# TODO(crbug.com/1456385): Figure out if this can be removed.
"-Wno-modules-ambiguous-internal-linkage",
# TODO(crbug.com/40440396): Clean up.
"-Wno-modules-import-nested-redundant",
# Needed to allow using builtin modules when the headers are
# unnecessarily using extern "C".
"-Wno-module-import-in-extern-c",
]
}
}
# runtime_library -------------------------------------------------------------
#
# Sets the runtime library and associated options.
@ -1893,9 +1956,6 @@ config("default_warnings") {
# TODO(https://crbug.com/324953188): fix and reenable
"-Wno-extra-qualification",
# TODO(https://crbug.com/332931387): fix and reenable
"-Wno-unused-but-set-variable",
]
}
@ -1903,16 +1963,9 @@ config("default_warnings") {
# 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/40231599) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
# TODO(crbug.com/40234766) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/40255410) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
@ -1936,6 +1989,9 @@ config("default_warnings") {
# TODO(crbug.com/41486292): Fix and re-enable.
"-Wno-c++11-narrowing-const-reference",
]
# TODO(crbug.com/344680447): Fix and re-enable.
cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
}
}
@ -1951,6 +2007,11 @@ config("default_warnings") {
}
}
# TODO(crbug.com/354162568): Clean up and enable.
if (llvm_force_head_revision && is_apple && use_lld) {
ldflags += [ "-Wl,--no-warn-duplicate-rpath" ]
}
# Rust warnings
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
@ -2562,14 +2623,17 @@ config("default_stack_frames") {
# [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" ]
}
# clang-cl's /O2 corresponds to clang's -O3, and really want -O3 for
# consistency with the other platforms.
cflags = [
"/O2",
"-Xclang", "-O3",
"/clang:-O3",
] + common_optimize_on_cflags
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
# The `-O3` for clang turns on extra optimizations compared to the standard
# `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
# to use.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+avx,+avx2,+fma,+f16c,+aes" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
@ -2751,12 +2815,10 @@ if (is_clang && is_a_target_toolchain) {
if (is_android || is_castos) {
_clang_sample_profile = "//chrome/android/profiles/afdo.prof"
} else {
assert(
chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp",
"Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
assert(chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm",
"Only 'atom', 'bigcore', and 'arm' are valid ChromeOS profiles.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2879,7 +2941,8 @@ config("symbols") {
}
# On aix -gdwarf causes linker failures due to thread_local variables.
if (!is_nacl && current_os != "aix") {
# On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE.
if (!is_nacl && current_os != "aix" && current_os != "zos") {
if (use_dwarf5) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
@ -2963,13 +3026,12 @@ config("symbols") {
# 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) &&
if (symbol_level == 2 && !use_debug_fission && !is_nacl && !is_win &&
(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_clang && (!is_nacl || is_nacl_saigo)) {
if (is_apple) {
# TODO(crbug.com/40117949): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@ -3053,7 +3115,7 @@ config("minimal_symbols") {
cflags += [ "-g1" ]
}
if (!is_nacl && is_clang && !is_tsan && !is_asan) {
if (!is_nacl && is_clang && !is_tsan && !is_asan && current_os != "zos") {
# See comment for -gdwarf-aranges in config("symbols").
cflags += [ "-gdwarf-aranges" ]
}

View file

@ -432,7 +432,11 @@ config("compiler") {
# links.
ldflags += [ "-Wl,--build-id=sha1" ]
} else if (current_os != "aix" && current_os != "zos") {
ldflags += [ "-Wl,--build-id" ]
if (use_lld && !is_nacl) {
ldflags += [ "-Wl,--build-id=fast" ]
} else {
ldflags += [ "-Wl,--build-id" ]
}
}
if (!is_android) {
@ -538,6 +542,13 @@ config("compiler") {
# but for now it looks like our build might rely on it
# (https://crbug.com/829795).
cflags += [ "-fmerge-all-constants" ]
# TODO(crbug.com/345541122): investigate the fuchsia binary size increase.
if (is_win) {
cflags += [ "/Zc:sizedDealloc" ]
} else {
cflags += [ "-fsized-deallocation" ]
}
}
if (use_lld) {
@ -559,7 +570,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
if (is_clang && !is_nacl && current_os != "zos") {
if (is_clang && !is_nacl) {
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@ -588,14 +599,14 @@ config("compiler") {
if (default_toolchain != "//build/toolchain/cros:target" &&
!llvm_android_mainline) {
cflags += [
"-mllvm",
"-split-threshold-for-reg-with-hint=0",
# "-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" ]
# ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
} else {
ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
# ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
}
}
}
@ -661,6 +672,12 @@ config("compiler") {
} else {
cflags_cc += [ "/std:c++20" ]
}
if (!is_clang) {
# Required for the __cplusplus macro definition to match the C++ version
# on MSVC. clang-cl defines it by default and doesn't need this flag.
# See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
cflags_cc += [ "/Zc:__cplusplus" ]
}
} else if (!is_nacl) {
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
@ -676,7 +693,7 @@ config("compiler") {
}
}
if (is_clang && current_os != "zos") {
if (is_clang) {
# C++17 removes trigraph support, but clang still warns that it ignores
# them when seeing them. Don't.
cflags_cc += [ "-Wno-trigraphs" ]
@ -751,7 +768,7 @@ config("compiler") {
# [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
import_instr_limit = 100
if (is_win) {
ldflags += [
@ -777,13 +794,11 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# 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 || use_order_profiling)) {
# Reduce inlining for the orderfile instrumented build to mitigate
# crbug.com/330761384.
import_instr_limit = 100
} else if (is_android && optimize_for_size) {
# 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
import_instr_limit = 100
}
ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
@ -797,8 +812,7 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
}
# TODO(crbug.com/335365324): Enable on other platforms.
if (is_android && !optimize_for_size) {
if (!optimize_for_size) {
# Ideally the compiler would handle this automatically with PGO (see
# comments at https://crrev.com/c/5440500).
#
@ -809,7 +823,11 @@ config("compiler") {
"-mllvm",
"-inlinehint-threshold=360",
]
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
if (is_win) {
ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
} else {
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
}
}
# TODO(crbug.com/40182783): investigate why this isn't effective on
@ -1086,6 +1104,16 @@ config("compiler") {
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
# 64-bit Android sometimes defines __ARM_NEON but not __ARM_NEON__.
# 32-bit Android builds and macOS, however, define __ARM_NEON__,
# and code typically checks for this.
#
# Reduce confusion by making the __ARM_NEON__ #define always available,
# as NEON is a mandatory part of ARMv8 anyway.
if (current_cpu == "arm64") {
defines += [ "__ARM_NEON__=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1197,7 +1225,7 @@ config("compiler_cpu_abi") {
"-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", ]
ldflags += [ "-m64", "-Wl,-O3", "-Wl,-mllvm,-march=skylake-avx512", "-Wl,-mllvm,-fp-contract=fast", "-Wl,-mllvm,-import-instr-limit=100", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
@ -1572,7 +1600,13 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
# Convert absolute paths to relative paths. Expands to, for example:
# -file-prefix-map /path/to/chromium/src=../..
swiftflags += [
"-file-prefix-map",
rebase_path("//.", "") + "=" + rebase_path("//.", root_build_dir),
]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1612,7 +1646,8 @@ config("compiler_deterministic") {
}
config("clang_revision") {
if (is_clang && clang_base_path == default_clang_base_path) {
if (is_clang && clang_base_path == default_clang_base_path &&
current_os != "zos") {
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@ -1669,6 +1704,34 @@ config("compiler_arm") {
}
}
config("libcxx_module") {
if (use_libcxx_modules) {
modulemap = rebase_path("//third_party/libc++/src/include/module.modulemap",
root_build_dir)
cflags_cc = [
"-fmodules",
"-fmodule-map-file=" + modulemap,
"-fno-implicit-module-maps",
"-fbuiltin-module-map",
"-fmodules-cache-path=" +
rebase_path("$libcxx_module_prefix/module_cache", root_build_dir),
"-Xclang",
"-fmodules-local-submodule-visibility", # required for builtins
# TODO(crbug.com/1456385): Figure out if this can be removed.
"-Wno-modules-ambiguous-internal-linkage",
# TODO(crbug.com/40440396): Clean up.
"-Wno-modules-import-nested-redundant",
# Needed to allow using builtin modules when the headers are
# unnecessarily using extern "C".
"-Wno-module-import-in-extern-c",
]
}
}
# runtime_library -------------------------------------------------------------
#
# Sets the runtime library and associated options.
@ -1898,9 +1961,6 @@ config("default_warnings") {
# TODO(https://crbug.com/324953188): fix and reenable
"-Wno-extra-qualification",
# TODO(https://crbug.com/332931387): fix and reenable
"-Wno-unused-but-set-variable",
]
}
@ -1908,16 +1968,9 @@ config("default_warnings") {
# 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/40231599) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
# TODO(crbug.com/40234766) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/40255410) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
@ -1941,6 +1994,9 @@ config("default_warnings") {
# TODO(crbug.com/41486292): Fix and re-enable.
"-Wno-c++11-narrowing-const-reference",
]
# TODO(crbug.com/344680447): Fix and re-enable.
cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
}
}
@ -1956,6 +2012,11 @@ config("default_warnings") {
}
}
# TODO(crbug.com/354162568): Clean up and enable.
if (llvm_force_head_revision && is_apple && use_lld) {
ldflags += [ "-Wl,--no-warn-duplicate-rpath" ]
}
# Rust warnings
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
@ -2573,14 +2634,17 @@ config("default_stack_frames") {
# [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" ]
}
# clang-cl's /O2 corresponds to clang's -O3, and really want -O3 for
# consistency with the other platforms.
cflags = [
"/O2",
"-Xclang", "-O3",
"/clang:-O3",
] + common_optimize_on_cflags
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
# The `-O3` for clang turns on extra optimizations compared to the standard
# `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
# to use.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+avx,+avx2,+fma,+f16c,+aes" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
@ -2762,12 +2826,10 @@ if (is_clang && is_a_target_toolchain) {
if (is_android || is_castos) {
_clang_sample_profile = "//chrome/android/profiles/afdo.prof"
} else {
assert(
chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp",
"Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
assert(chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm",
"Only 'atom', 'bigcore', and 'arm' are valid ChromeOS profiles.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2890,7 +2952,8 @@ config("symbols") {
}
# On aix -gdwarf causes linker failures due to thread_local variables.
if (!is_nacl && current_os != "aix") {
# On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE.
if (!is_nacl && current_os != "aix" && current_os != "zos") {
if (use_dwarf5) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
@ -2974,13 +3037,12 @@ config("symbols") {
# 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) &&
if (symbol_level == 2 && !use_debug_fission && !is_nacl && !is_win &&
(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_clang && (!is_nacl || is_nacl_saigo)) {
if (is_apple) {
# TODO(crbug.com/40117949): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@ -3064,7 +3126,7 @@ config("minimal_symbols") {
cflags += [ "-g1" ]
}
if (!is_nacl && is_clang && !is_tsan && !is_asan) {
if (!is_nacl && is_clang && !is_tsan && !is_asan && current_os != "zos") {
# See comment for -gdwarf-aranges in config("symbols").
cflags += [ "-gdwarf-aranges" ]
}

View file

@ -432,7 +432,11 @@ config("compiler") {
# links.
ldflags += [ "-Wl,--build-id=sha1" ]
} else if (current_os != "aix" && current_os != "zos") {
ldflags += [ "-Wl,--build-id" ]
if (use_lld && !is_nacl) {
ldflags += [ "-Wl,--build-id=fast" ]
} else {
ldflags += [ "-Wl,--build-id" ]
}
}
if (!is_android) {
@ -538,6 +542,13 @@ config("compiler") {
# but for now it looks like our build might rely on it
# (https://crbug.com/829795).
cflags += [ "-fmerge-all-constants" ]
# TODO(crbug.com/345541122): investigate the fuchsia binary size increase.
if (is_win) {
cflags += [ "/Zc:sizedDealloc" ]
} else {
cflags += [ "-fsized-deallocation" ]
}
}
if (use_lld) {
@ -559,7 +570,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
if (is_clang && !is_nacl && current_os != "zos") {
if (is_clang && !is_nacl) {
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@ -588,14 +599,14 @@ config("compiler") {
if (default_toolchain != "//build/toolchain/cros:target" &&
!llvm_android_mainline) {
cflags += [
"-mllvm",
"-split-threshold-for-reg-with-hint=0",
# "-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" ]
# ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
} else {
ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
# ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
}
}
}
@ -661,6 +672,12 @@ config("compiler") {
} else {
cflags_cc += [ "/std:c++20" ]
}
if (!is_clang) {
# Required for the __cplusplus macro definition to match the C++ version
# on MSVC. clang-cl defines it by default and doesn't need this flag.
# See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
cflags_cc += [ "/Zc:__cplusplus" ]
}
} else if (!is_nacl) {
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
@ -676,7 +693,7 @@ config("compiler") {
}
}
if (is_clang && current_os != "zos") {
if (is_clang) {
# C++17 removes trigraph support, but clang still warns that it ignores
# them when seeing them. Don't.
cflags_cc += [ "-Wno-trigraphs" ]
@ -751,7 +768,7 @@ config("compiler") {
# [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
import_instr_limit = 100
if (is_win) {
ldflags += [
@ -777,13 +794,11 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# 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 || use_order_profiling)) {
# Reduce inlining for the orderfile instrumented build to mitigate
# crbug.com/330761384.
import_instr_limit = 100
} else if (is_android && optimize_for_size) {
# 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
import_instr_limit = 100
}
ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
@ -797,8 +812,7 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
}
# TODO(crbug.com/335365324): Enable on other platforms.
if (is_android && !optimize_for_size) {
if (!optimize_for_size) {
# Ideally the compiler would handle this automatically with PGO (see
# comments at https://crrev.com/c/5440500).
#
@ -809,7 +823,11 @@ config("compiler") {
"-mllvm",
"-inlinehint-threshold=360",
]
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
if (is_win) {
ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
} else {
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
}
}
# TODO(crbug.com/40182783): investigate why this isn't effective on
@ -1085,6 +1103,16 @@ config("compiler") {
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
# 64-bit Android sometimes defines __ARM_NEON but not __ARM_NEON__.
# 32-bit Android builds and macOS, however, define __ARM_NEON__,
# and code typically checks for this.
#
# Reduce confusion by making the __ARM_NEON__ #define always available,
# as NEON is a mandatory part of ARMv8 anyway.
if (current_cpu == "arm64") {
defines += [ "__ARM_NEON__=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1179,7 +1207,7 @@ config("compiler_cpu_abi") {
"-mssse3",
"-msse4.1",
]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4.1", ]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4.1", "-Wl,-mllvm,-import-instr-limit=100", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
@ -1554,7 +1582,13 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
# Convert absolute paths to relative paths. Expands to, for example:
# -file-prefix-map /path/to/chromium/src=../..
swiftflags += [
"-file-prefix-map",
rebase_path("//.", "") + "=" + rebase_path("//.", root_build_dir),
]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1594,7 +1628,8 @@ config("compiler_deterministic") {
}
config("clang_revision") {
if (is_clang && clang_base_path == default_clang_base_path) {
if (is_clang && clang_base_path == default_clang_base_path &&
current_os != "zos") {
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@ -1651,6 +1686,34 @@ config("compiler_arm") {
}
}
config("libcxx_module") {
if (use_libcxx_modules) {
modulemap = rebase_path("//third_party/libc++/src/include/module.modulemap",
root_build_dir)
cflags_cc = [
"-fmodules",
"-fmodule-map-file=" + modulemap,
"-fno-implicit-module-maps",
"-fbuiltin-module-map",
"-fmodules-cache-path=" +
rebase_path("$libcxx_module_prefix/module_cache", root_build_dir),
"-Xclang",
"-fmodules-local-submodule-visibility", # required for builtins
# TODO(crbug.com/1456385): Figure out if this can be removed.
"-Wno-modules-ambiguous-internal-linkage",
# TODO(crbug.com/40440396): Clean up.
"-Wno-modules-import-nested-redundant",
# Needed to allow using builtin modules when the headers are
# unnecessarily using extern "C".
"-Wno-module-import-in-extern-c",
]
}
}
# runtime_library -------------------------------------------------------------
#
# Sets the runtime library and associated options.
@ -1880,9 +1943,6 @@ config("default_warnings") {
# TODO(https://crbug.com/324953188): fix and reenable
"-Wno-extra-qualification",
# TODO(https://crbug.com/332931387): fix and reenable
"-Wno-unused-but-set-variable",
]
}
@ -1890,16 +1950,9 @@ config("default_warnings") {
# 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/40231599) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
# TODO(crbug.com/40234766) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/40255410) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
@ -1923,6 +1976,9 @@ config("default_warnings") {
# TODO(crbug.com/41486292): Fix and re-enable.
"-Wno-c++11-narrowing-const-reference",
]
# TODO(crbug.com/344680447): Fix and re-enable.
cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
}
}
@ -1938,6 +1994,11 @@ config("default_warnings") {
}
}
# TODO(crbug.com/354162568): Clean up and enable.
if (llvm_force_head_revision && is_apple && use_lld) {
ldflags += [ "-Wl,--no-warn-duplicate-rpath" ]
}
# Rust warnings
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
@ -2370,7 +2431,7 @@ if (is_win) {
common_optimize_on_ldflags += [
"-Wl,-mllvm,-aggressive-ext-opt",
"-Wl,-mllvm,-enable-gvn-hoist",
"-Wl,-mllvm,-import-instr-limit=30",
"-Wl,-mllvm,-import-instr-limit=100",
"-Wl,-O3",
]
@ -2539,14 +2600,17 @@ config("default_stack_frames") {
# [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" ]
}
# clang-cl's /O2 corresponds to clang's -O3, and really want -O3 for
# consistency with the other platforms.
cflags = [
"/O2",
"-Xclang", "-O3",
"/clang:-O3",
] + common_optimize_on_cflags
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
# The `-O3` for clang turns on extra optimizations compared to the standard
# `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
# to use.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
@ -2728,12 +2792,10 @@ if (is_clang && is_a_target_toolchain) {
if (is_android || is_castos) {
_clang_sample_profile = "//chrome/android/profiles/afdo.prof"
} else {
assert(
chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp",
"Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
assert(chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm",
"Only 'atom', 'bigcore', and 'arm' are valid ChromeOS profiles.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2856,7 +2918,8 @@ config("symbols") {
}
# On aix -gdwarf causes linker failures due to thread_local variables.
if (!is_nacl && current_os != "aix") {
# On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE.
if (!is_nacl && current_os != "aix" && current_os != "zos") {
if (use_dwarf5) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
@ -2940,13 +3003,12 @@ config("symbols") {
# 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) &&
if (symbol_level == 2 && !use_debug_fission && !is_nacl && !is_win &&
(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_clang && (!is_nacl || is_nacl_saigo)) {
if (is_apple) {
# TODO(crbug.com/40117949): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@ -3030,7 +3092,7 @@ config("minimal_symbols") {
cflags += [ "-g1" ]
}
if (!is_nacl && is_clang && !is_tsan && !is_asan) {
if (!is_nacl && is_clang && !is_tsan && !is_asan && current_os != "zos") {
# See comment for -gdwarf-aranges in config("symbols").
cflags += [ "-gdwarf-aranges" ]
}

View file

@ -432,7 +432,11 @@ config("compiler") {
# links.
ldflags += [ "-Wl,--build-id=sha1" ]
} else if (current_os != "aix" && current_os != "zos") {
ldflags += [ "-Wl,--build-id" ]
if (use_lld && !is_nacl) {
ldflags += [ "-Wl,--build-id=fast" ]
} else {
ldflags += [ "-Wl,--build-id" ]
}
}
if (!is_android) {
@ -538,6 +542,13 @@ config("compiler") {
# but for now it looks like our build might rely on it
# (https://crbug.com/829795).
cflags += [ "-fmerge-all-constants" ]
# TODO(crbug.com/345541122): investigate the fuchsia binary size increase.
if (is_win) {
cflags += [ "/Zc:sizedDealloc" ]
} else {
cflags += [ "-fsized-deallocation" ]
}
}
if (use_lld) {
@ -559,7 +570,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
if (is_clang && !is_nacl && current_os != "zos") {
if (is_clang && !is_nacl) {
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@ -588,14 +599,14 @@ config("compiler") {
if (default_toolchain != "//build/toolchain/cros:target" &&
!llvm_android_mainline) {
cflags += [
"-mllvm",
"-split-threshold-for-reg-with-hint=0",
# "-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" ]
# ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
} else {
ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
# ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
}
}
}
@ -661,6 +672,12 @@ config("compiler") {
} else {
cflags_cc += [ "/std:c++20" ]
}
if (!is_clang) {
# Required for the __cplusplus macro definition to match the C++ version
# on MSVC. clang-cl defines it by default and doesn't need this flag.
# See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
cflags_cc += [ "/Zc:__cplusplus" ]
}
} else if (!is_nacl) {
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
@ -676,7 +693,7 @@ config("compiler") {
}
}
if (is_clang && current_os != "zos") {
if (is_clang) {
# C++17 removes trigraph support, but clang still warns that it ignores
# them when seeing them. Don't.
cflags_cc += [ "-Wno-trigraphs" ]
@ -751,7 +768,7 @@ config("compiler") {
# [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
import_instr_limit = 100
if (is_win) {
ldflags += [
@ -777,13 +794,11 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# 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 || use_order_profiling)) {
# Reduce inlining for the orderfile instrumented build to mitigate
# crbug.com/330761384.
import_instr_limit = 100
} else if (is_android && optimize_for_size) {
# 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
import_instr_limit = 100
}
ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
@ -797,8 +812,7 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
}
# TODO(crbug.com/335365324): Enable on other platforms.
if (is_android && !optimize_for_size) {
if (!optimize_for_size) {
# Ideally the compiler would handle this automatically with PGO (see
# comments at https://crrev.com/c/5440500).
#
@ -809,7 +823,11 @@ config("compiler") {
"-mllvm",
"-inlinehint-threshold=360",
]
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
if (is_win) {
ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
} else {
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
}
}
# TODO(crbug.com/40182783): investigate why this isn't effective on
@ -1085,6 +1103,16 @@ config("compiler") {
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
# 64-bit Android sometimes defines __ARM_NEON but not __ARM_NEON__.
# 32-bit Android builds and macOS, however, define __ARM_NEON__,
# and code typically checks for this.
#
# Reduce confusion by making the __ARM_NEON__ #define always available,
# as NEON is a mandatory part of ARMv8 anyway.
if (current_cpu == "arm64") {
defines += [ "__ARM_NEON__=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1180,7 +1208,7 @@ config("compiler_cpu_abi") {
"-msse",
"-msse2",
]
ldflags += [ "-m64", "-Wl,-O3", "-mmmx", "-mfxsr", "-msse", "-msse2", "-Wl,-mllvm,-import-instr-limit=30", ]
ldflags += [ "-m64", "-Wl,-O3", "-mmmx", "-mfxsr", "-msse", "-msse2", "-Wl,-mllvm,-import-instr-limit=100", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-mmmx", "-mfxsr", "-msse", "-msse2", ]
@ -1557,7 +1585,13 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
# Convert absolute paths to relative paths. Expands to, for example:
# -file-prefix-map /path/to/chromium/src=../..
swiftflags += [
"-file-prefix-map",
rebase_path("//.", "") + "=" + rebase_path("//.", root_build_dir),
]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1597,7 +1631,8 @@ config("compiler_deterministic") {
}
config("clang_revision") {
if (is_clang && clang_base_path == default_clang_base_path) {
if (is_clang && clang_base_path == default_clang_base_path &&
current_os != "zos") {
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@ -1654,6 +1689,34 @@ config("compiler_arm") {
}
}
config("libcxx_module") {
if (use_libcxx_modules) {
modulemap = rebase_path("//third_party/libc++/src/include/module.modulemap",
root_build_dir)
cflags_cc = [
"-fmodules",
"-fmodule-map-file=" + modulemap,
"-fno-implicit-module-maps",
"-fbuiltin-module-map",
"-fmodules-cache-path=" +
rebase_path("$libcxx_module_prefix/module_cache", root_build_dir),
"-Xclang",
"-fmodules-local-submodule-visibility", # required for builtins
# TODO(crbug.com/1456385): Figure out if this can be removed.
"-Wno-modules-ambiguous-internal-linkage",
# TODO(crbug.com/40440396): Clean up.
"-Wno-modules-import-nested-redundant",
# Needed to allow using builtin modules when the headers are
# unnecessarily using extern "C".
"-Wno-module-import-in-extern-c",
]
}
}
# runtime_library -------------------------------------------------------------
#
# Sets the runtime library and associated options.
@ -1883,9 +1946,6 @@ config("default_warnings") {
# TODO(https://crbug.com/324953188): fix and reenable
"-Wno-extra-qualification",
# TODO(https://crbug.com/332931387): fix and reenable
"-Wno-unused-but-set-variable",
]
}
@ -1893,16 +1953,9 @@ config("default_warnings") {
# 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/40231599) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
# TODO(crbug.com/40234766) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/40255410) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
@ -1926,6 +1979,9 @@ config("default_warnings") {
# TODO(crbug.com/41486292): Fix and re-enable.
"-Wno-c++11-narrowing-const-reference",
]
# TODO(crbug.com/344680447): Fix and re-enable.
cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
}
}
@ -1941,6 +1997,11 @@ config("default_warnings") {
}
}
# TODO(crbug.com/354162568): Clean up and enable.
if (llvm_force_head_revision && is_apple && use_lld) {
ldflags += [ "-Wl,--no-warn-duplicate-rpath" ]
}
# Rust warnings
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
@ -2542,14 +2603,17 @@ config("default_stack_frames") {
# [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" ]
}
# clang-cl's /O2 corresponds to clang's -O3, and really want -O3 for
# consistency with the other platforms.
cflags = [
"/O2",
"-Xclang", "-O3",
"/clang:-O3",
] + common_optimize_on_cflags
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
# The `-O3` for clang turns on extra optimizations compared to the standard
# `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
# to use.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse2" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
@ -2731,12 +2795,10 @@ if (is_clang && is_a_target_toolchain) {
if (is_android || is_castos) {
_clang_sample_profile = "//chrome/android/profiles/afdo.prof"
} else {
assert(
chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp",
"Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
assert(chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm",
"Only 'atom', 'bigcore', and 'arm' are valid ChromeOS profiles.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2859,7 +2921,8 @@ config("symbols") {
}
# On aix -gdwarf causes linker failures due to thread_local variables.
if (!is_nacl && current_os != "aix") {
# On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE.
if (!is_nacl && current_os != "aix" && current_os != "zos") {
if (use_dwarf5) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
@ -2943,13 +3006,12 @@ config("symbols") {
# 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) &&
if (symbol_level == 2 && !use_debug_fission && !is_nacl && !is_win &&
(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_clang && (!is_nacl || is_nacl_saigo)) {
if (is_apple) {
# TODO(crbug.com/40117949): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@ -3033,7 +3095,7 @@ config("minimal_symbols") {
cflags += [ "-g1" ]
}
if (!is_nacl && is_clang && !is_tsan && !is_asan) {
if (!is_nacl && is_clang && !is_tsan && !is_asan && current_os != "zos") {
# See comment for -gdwarf-aranges in config("symbols").
cflags += [ "-gdwarf-aranges" ]
}

View file

@ -432,7 +432,11 @@ config("compiler") {
# links.
ldflags += [ "-Wl,--build-id=sha1" ]
} else if (current_os != "aix" && current_os != "zos") {
ldflags += [ "-Wl,--build-id" ]
if (use_lld && !is_nacl) {
ldflags += [ "-Wl,--build-id=fast" ]
} else {
ldflags += [ "-Wl,--build-id" ]
}
}
if (!is_android) {
@ -538,6 +542,13 @@ config("compiler") {
# but for now it looks like our build might rely on it
# (https://crbug.com/829795).
cflags += [ "-fmerge-all-constants" ]
# TODO(crbug.com/345541122): investigate the fuchsia binary size increase.
if (is_win) {
cflags += [ "/Zc:sizedDealloc" ]
} else {
cflags += [ "-fsized-deallocation" ]
}
}
if (use_lld) {
@ -559,7 +570,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
if (is_clang && !is_nacl && current_os != "zos") {
if (is_clang && !is_nacl) {
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@ -588,14 +599,14 @@ config("compiler") {
if (default_toolchain != "//build/toolchain/cros:target" &&
!llvm_android_mainline) {
cflags += [
"-mllvm",
"-split-threshold-for-reg-with-hint=0",
# "-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" ]
# ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
} else {
ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
# ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
}
}
}
@ -661,6 +672,12 @@ config("compiler") {
} else {
cflags_cc += [ "/std:c++20" ]
}
if (!is_clang) {
# Required for the __cplusplus macro definition to match the C++ version
# on MSVC. clang-cl defines it by default and doesn't need this flag.
# See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
cflags_cc += [ "/Zc:__cplusplus" ]
}
} else if (!is_nacl) {
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
@ -676,7 +693,7 @@ config("compiler") {
}
}
if (is_clang && current_os != "zos") {
if (is_clang) {
# C++17 removes trigraph support, but clang still warns that it ignores
# them when seeing them. Don't.
cflags_cc += [ "-Wno-trigraphs" ]
@ -751,7 +768,7 @@ config("compiler") {
# [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
import_instr_limit = 100
if (is_win) {
ldflags += [
@ -777,13 +794,11 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# 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 || use_order_profiling)) {
# Reduce inlining for the orderfile instrumented build to mitigate
# crbug.com/330761384.
import_instr_limit = 100
} else if (is_android && optimize_for_size) {
# 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
import_instr_limit = 100
}
ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
@ -797,8 +812,7 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
}
# TODO(crbug.com/335365324): Enable on other platforms.
if (is_android && !optimize_for_size) {
if (!optimize_for_size) {
# Ideally the compiler would handle this automatically with PGO (see
# comments at https://crrev.com/c/5440500).
#
@ -809,7 +823,11 @@ config("compiler") {
"-mllvm",
"-inlinehint-threshold=360",
]
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
if (is_win) {
ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
} else {
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
}
}
# TODO(crbug.com/40182783): investigate why this isn't effective on
@ -1085,6 +1103,16 @@ config("compiler") {
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
# 64-bit Android sometimes defines __ARM_NEON but not __ARM_NEON__.
# 32-bit Android builds and macOS, however, define __ARM_NEON__,
# and code typically checks for this.
#
# Reduce confusion by making the __ARM_NEON__ #define always available,
# as NEON is a mandatory part of ARMv8 anyway.
if (current_cpu == "arm64") {
defines += [ "__ARM_NEON__=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1177,7 +1205,7 @@ config("compiler_cpu_abi") {
"-O3",
"-msse3",
]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-Wl,-mllvm,-import-instr-limit=30", ]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-Wl,-mllvm,-import-instr-limit=100", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
@ -1552,7 +1580,13 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
# Convert absolute paths to relative paths. Expands to, for example:
# -file-prefix-map /path/to/chromium/src=../..
swiftflags += [
"-file-prefix-map",
rebase_path("//.", "") + "=" + rebase_path("//.", root_build_dir),
]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1592,7 +1626,8 @@ config("compiler_deterministic") {
}
config("clang_revision") {
if (is_clang && clang_base_path == default_clang_base_path) {
if (is_clang && clang_base_path == default_clang_base_path &&
current_os != "zos") {
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@ -1649,6 +1684,34 @@ config("compiler_arm") {
}
}
config("libcxx_module") {
if (use_libcxx_modules) {
modulemap = rebase_path("//third_party/libc++/src/include/module.modulemap",
root_build_dir)
cflags_cc = [
"-fmodules",
"-fmodule-map-file=" + modulemap,
"-fno-implicit-module-maps",
"-fbuiltin-module-map",
"-fmodules-cache-path=" +
rebase_path("$libcxx_module_prefix/module_cache", root_build_dir),
"-Xclang",
"-fmodules-local-submodule-visibility", # required for builtins
# TODO(crbug.com/1456385): Figure out if this can be removed.
"-Wno-modules-ambiguous-internal-linkage",
# TODO(crbug.com/40440396): Clean up.
"-Wno-modules-import-nested-redundant",
# Needed to allow using builtin modules when the headers are
# unnecessarily using extern "C".
"-Wno-module-import-in-extern-c",
]
}
}
# runtime_library -------------------------------------------------------------
#
# Sets the runtime library and associated options.
@ -1878,9 +1941,6 @@ config("default_warnings") {
# TODO(https://crbug.com/324953188): fix and reenable
"-Wno-extra-qualification",
# TODO(https://crbug.com/332931387): fix and reenable
"-Wno-unused-but-set-variable",
]
}
@ -1888,16 +1948,9 @@ config("default_warnings") {
# 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/40231599) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
# TODO(crbug.com/40234766) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/40255410) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
@ -1921,6 +1974,9 @@ config("default_warnings") {
# TODO(crbug.com/41486292): Fix and re-enable.
"-Wno-c++11-narrowing-const-reference",
]
# TODO(crbug.com/344680447): Fix and re-enable.
cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
}
}
@ -1936,6 +1992,11 @@ config("default_warnings") {
}
}
# TODO(crbug.com/354162568): Clean up and enable.
if (llvm_force_head_revision && is_apple && use_lld) {
ldflags += [ "-Wl,--no-warn-duplicate-rpath" ]
}
# Rust warnings
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
@ -2534,14 +2595,17 @@ config("default_stack_frames") {
# [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" ]
}
# clang-cl's /O2 corresponds to clang's -O3, and really want -O3 for
# consistency with the other platforms.
cflags = [
"/O2",
"-Xclang", "-O3",
"/clang:-O3",
] + common_optimize_on_cflags
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
# The `-O3` for clang turns on extra optimizations compared to the standard
# `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
# to use.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
@ -2723,12 +2787,10 @@ if (is_clang && is_a_target_toolchain) {
if (is_android || is_castos) {
_clang_sample_profile = "//chrome/android/profiles/afdo.prof"
} else {
assert(
chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp",
"Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
assert(chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm",
"Only 'atom', 'bigcore', and 'arm' are valid ChromeOS profiles.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2851,7 +2913,8 @@ config("symbols") {
}
# On aix -gdwarf causes linker failures due to thread_local variables.
if (!is_nacl && current_os != "aix") {
# On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE.
if (!is_nacl && current_os != "aix" && current_os != "zos") {
if (use_dwarf5) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
@ -2935,13 +2998,12 @@ config("symbols") {
# 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) &&
if (symbol_level == 2 && !use_debug_fission && !is_nacl && !is_win &&
(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_clang && (!is_nacl || is_nacl_saigo)) {
if (is_apple) {
# TODO(crbug.com/40117949): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@ -3025,7 +3087,7 @@ config("minimal_symbols") {
cflags += [ "-g1" ]
}
if (!is_nacl && is_clang && !is_tsan && !is_asan) {
if (!is_nacl && is_clang && !is_tsan && !is_asan && current_os != "zos") {
# See comment for -gdwarf-aranges in config("symbols").
cflags += [ "-gdwarf-aranges" ]
}

View file

@ -432,7 +432,11 @@ config("compiler") {
# links.
ldflags += [ "-Wl,--build-id=sha1" ]
} else if (current_os != "aix" && current_os != "zos") {
ldflags += [ "-Wl,--build-id" ]
if (use_lld && !is_nacl) {
ldflags += [ "-Wl,--build-id=fast" ]
} else {
ldflags += [ "-Wl,--build-id" ]
}
}
if (!is_android) {
@ -538,6 +542,13 @@ config("compiler") {
# but for now it looks like our build might rely on it
# (https://crbug.com/829795).
cflags += [ "-fmerge-all-constants" ]
# TODO(crbug.com/345541122): investigate the fuchsia binary size increase.
if (is_win) {
cflags += [ "/Zc:sizedDealloc" ]
} else {
cflags += [ "-fsized-deallocation" ]
}
}
if (use_lld) {
@ -559,7 +570,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
if (is_clang && !is_nacl && current_os != "zos") {
if (is_clang && !is_nacl) {
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@ -588,14 +599,14 @@ config("compiler") {
if (default_toolchain != "//build/toolchain/cros:target" &&
!llvm_android_mainline) {
cflags += [
"-mllvm",
"-split-threshold-for-reg-with-hint=0",
# "-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" ]
# ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
} else {
ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
# ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
}
}
}
@ -661,6 +672,12 @@ config("compiler") {
} else {
cflags_cc += [ "/std:c++20" ]
}
if (!is_clang) {
# Required for the __cplusplus macro definition to match the C++ version
# on MSVC. clang-cl defines it by default and doesn't need this flag.
# See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
cflags_cc += [ "/Zc:__cplusplus" ]
}
} else if (!is_nacl) {
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
@ -676,7 +693,7 @@ config("compiler") {
}
}
if (is_clang && current_os != "zos") {
if (is_clang) {
# C++17 removes trigraph support, but clang still warns that it ignores
# them when seeing them. Don't.
cflags_cc += [ "-Wno-trigraphs" ]
@ -751,7 +768,7 @@ config("compiler") {
# [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
import_instr_limit = 100
if (is_win) {
ldflags += [
@ -777,13 +794,11 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# 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 || use_order_profiling)) {
# Reduce inlining for the orderfile instrumented build to mitigate
# crbug.com/330761384.
import_instr_limit = 100
} else if (is_android && optimize_for_size) {
# 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
import_instr_limit = 100
}
ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
@ -797,8 +812,7 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
}
# TODO(crbug.com/335365324): Enable on other platforms.
if (is_android && !optimize_for_size) {
if (!optimize_for_size) {
# Ideally the compiler would handle this automatically with PGO (see
# comments at https://crrev.com/c/5440500).
#
@ -809,7 +823,11 @@ config("compiler") {
"-mllvm",
"-inlinehint-threshold=360",
]
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
if (is_win) {
ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
} else {
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
}
}
# TODO(crbug.com/40182783): investigate why this isn't effective on
@ -1085,6 +1103,16 @@ config("compiler") {
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
# 64-bit Android sometimes defines __ARM_NEON but not __ARM_NEON__.
# 32-bit Android builds and macOS, however, define __ARM_NEON__,
# and code typically checks for this.
#
# Reduce confusion by making the __ARM_NEON__ #define always available,
# as NEON is a mandatory part of ARMv8 anyway.
if (current_cpu == "arm64") {
defines += [ "__ARM_NEON__=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1179,7 +1207,7 @@ config("compiler_cpu_abi") {
"-mssse3",
"-msse4.1",
]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4.1", "-Wl,-mllvm,-import-instr-limit=30", ]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4.1", "-Wl,-mllvm,-import-instr-limit=100", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
@ -1554,7 +1582,13 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
# Convert absolute paths to relative paths. Expands to, for example:
# -file-prefix-map /path/to/chromium/src=../..
swiftflags += [
"-file-prefix-map",
rebase_path("//.", "") + "=" + rebase_path("//.", root_build_dir),
]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1594,7 +1628,8 @@ config("compiler_deterministic") {
}
config("clang_revision") {
if (is_clang && clang_base_path == default_clang_base_path) {
if (is_clang && clang_base_path == default_clang_base_path &&
current_os != "zos") {
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@ -1651,6 +1686,34 @@ config("compiler_arm") {
}
}
config("libcxx_module") {
if (use_libcxx_modules) {
modulemap = rebase_path("//third_party/libc++/src/include/module.modulemap",
root_build_dir)
cflags_cc = [
"-fmodules",
"-fmodule-map-file=" + modulemap,
"-fno-implicit-module-maps",
"-fbuiltin-module-map",
"-fmodules-cache-path=" +
rebase_path("$libcxx_module_prefix/module_cache", root_build_dir),
"-Xclang",
"-fmodules-local-submodule-visibility", # required for builtins
# TODO(crbug.com/1456385): Figure out if this can be removed.
"-Wno-modules-ambiguous-internal-linkage",
# TODO(crbug.com/40440396): Clean up.
"-Wno-modules-import-nested-redundant",
# Needed to allow using builtin modules when the headers are
# unnecessarily using extern "C".
"-Wno-module-import-in-extern-c",
]
}
}
# runtime_library -------------------------------------------------------------
#
# Sets the runtime library and associated options.
@ -1880,9 +1943,6 @@ config("default_warnings") {
# TODO(https://crbug.com/324953188): fix and reenable
"-Wno-extra-qualification",
# TODO(https://crbug.com/332931387): fix and reenable
"-Wno-unused-but-set-variable",
]
}
@ -1890,16 +1950,9 @@ config("default_warnings") {
# 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/40231599) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
# TODO(crbug.com/40234766) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/40255410) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
@ -1923,6 +1976,9 @@ config("default_warnings") {
# TODO(crbug.com/41486292): Fix and re-enable.
"-Wno-c++11-narrowing-const-reference",
]
# TODO(crbug.com/344680447): Fix and re-enable.
cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
}
}
@ -1938,6 +1994,11 @@ config("default_warnings") {
}
}
# TODO(crbug.com/354162568): Clean up and enable.
if (llvm_force_head_revision && is_apple && use_lld) {
ldflags += [ "-Wl,--no-warn-duplicate-rpath" ]
}
# Rust warnings
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
@ -2538,14 +2599,17 @@ config("default_stack_frames") {
# [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" ]
}
# clang-cl's /O2 corresponds to clang's -O3, and really want -O3 for
# consistency with the other platforms.
cflags = [
"/O2",
"-Xclang", "-O3",
"/clang:-O3",
] + common_optimize_on_cflags
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
# The `-O3` for clang turns on extra optimizations compared to the standard
# `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
# to use.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
@ -2727,12 +2791,10 @@ if (is_clang && is_a_target_toolchain) {
if (is_android || is_castos) {
_clang_sample_profile = "//chrome/android/profiles/afdo.prof"
} else {
assert(
chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp",
"Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
assert(chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm",
"Only 'atom', 'bigcore', and 'arm' are valid ChromeOS profiles.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2855,7 +2917,8 @@ config("symbols") {
}
# On aix -gdwarf causes linker failures due to thread_local variables.
if (!is_nacl && current_os != "aix") {
# On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE.
if (!is_nacl && current_os != "aix" && current_os != "zos") {
if (use_dwarf5) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
@ -2939,13 +3002,12 @@ config("symbols") {
# 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) &&
if (symbol_level == 2 && !use_debug_fission && !is_nacl && !is_win &&
(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_clang && (!is_nacl || is_nacl_saigo)) {
if (is_apple) {
# TODO(crbug.com/40117949): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@ -3029,7 +3091,7 @@ config("minimal_symbols") {
cflags += [ "-g1" ]
}
if (!is_nacl && is_clang && !is_tsan && !is_asan) {
if (!is_nacl && is_clang && !is_tsan && !is_asan && current_os != "zos") {
# See comment for -gdwarf-aranges in config("symbols").
cflags += [ "-gdwarf-aranges" ]
}

View file

@ -432,7 +432,11 @@ config("compiler") {
# links.
ldflags += [ "-Wl,--build-id=sha1" ]
} else if (current_os != "aix" && current_os != "zos") {
ldflags += [ "-Wl,--build-id" ]
if (use_lld && !is_nacl) {
ldflags += [ "-Wl,--build-id=fast" ]
} else {
ldflags += [ "-Wl,--build-id" ]
}
}
if (!is_android) {
@ -538,6 +542,13 @@ config("compiler") {
# but for now it looks like our build might rely on it
# (https://crbug.com/829795).
cflags += [ "-fmerge-all-constants" ]
# TODO(crbug.com/345541122): investigate the fuchsia binary size increase.
if (is_win) {
cflags += [ "/Zc:sizedDealloc" ]
} else {
cflags += [ "-fsized-deallocation" ]
}
}
if (use_lld) {
@ -559,7 +570,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
if (is_clang && !is_nacl && current_os != "zos") {
if (is_clang && !is_nacl) {
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@ -588,14 +599,14 @@ config("compiler") {
if (default_toolchain != "//build/toolchain/cros:target" &&
!llvm_android_mainline) {
cflags += [
"-mllvm",
"-split-threshold-for-reg-with-hint=0",
# "-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" ]
# ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
} else {
ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
# ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
}
}
}
@ -661,6 +672,12 @@ config("compiler") {
} else {
cflags_cc += [ "/std:c++20" ]
}
if (!is_clang) {
# Required for the __cplusplus macro definition to match the C++ version
# on MSVC. clang-cl defines it by default and doesn't need this flag.
# See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
cflags_cc += [ "/Zc:__cplusplus" ]
}
} else if (!is_nacl) {
# TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
# gnu11/gnu++11 or c11/c++11; we technically don't need this toolchain any
@ -676,7 +693,7 @@ config("compiler") {
}
}
if (is_clang && current_os != "zos") {
if (is_clang) {
# C++17 removes trigraph support, but clang still warns that it ignores
# them when seeing them. Don't.
cflags_cc += [ "-Wno-trigraphs" ]
@ -751,7 +768,7 @@ config("compiler") {
# [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
import_instr_limit = 100
if (is_win) {
ldflags += [
@ -777,13 +794,11 @@ config("compiler") {
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# 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 || use_order_profiling)) {
# Reduce inlining for the orderfile instrumented build to mitigate
# crbug.com/330761384.
import_instr_limit = 100
} else if (is_android && optimize_for_size) {
# 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
import_instr_limit = 100
}
ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
@ -797,8 +812,7 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
}
# TODO(crbug.com/335365324): Enable on other platforms.
if (is_android && !optimize_for_size) {
if (!optimize_for_size) {
# Ideally the compiler would handle this automatically with PGO (see
# comments at https://crrev.com/c/5440500).
#
@ -809,7 +823,11 @@ config("compiler") {
"-mllvm",
"-inlinehint-threshold=360",
]
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
if (is_win) {
ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
} else {
ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
}
}
# TODO(crbug.com/40182783): investigate why this isn't effective on
@ -1085,6 +1103,16 @@ config("compiler") {
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
# 64-bit Android sometimes defines __ARM_NEON but not __ARM_NEON__.
# 32-bit Android builds and macOS, however, define __ARM_NEON__,
# and code typically checks for this.
#
# Reduce confusion by making the __ARM_NEON__ #define always available,
# as NEON is a mandatory part of ARMv8 anyway.
if (current_cpu == "arm64") {
defines += [ "__ARM_NEON__=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1184,7 +1212,7 @@ config("compiler_cpu_abi") {
"-maes",
"-mavx",
]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4", "-msse4.1", "-msse4.2", "-mpclmul", "-maes", "-mavx", "-Wl,-mllvm,-import-instr-limit=30", ]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4", "-msse4.1", "-msse4.2", "-mpclmul", "-maes", "-mavx", "-Wl,-mllvm,-import-instr-limit=100", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
@ -1559,7 +1587,13 @@ config("compiler_deterministic") {
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
# and -fcoverage-compilation-dir=.
cflags += [ "-ffile-compilation-dir=." ]
swiftflags += [ "-file-compilation-dir=." ]
# Convert absolute paths to relative paths. Expands to, for example:
# -file-prefix-map /path/to/chromium/src=../..
swiftflags += [
"-file-prefix-map",
rebase_path("//.", "") + "=" + rebase_path("//.", root_build_dir),
]
}
if (!is_win) {
# We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
@ -1599,7 +1633,8 @@ config("compiler_deterministic") {
}
config("clang_revision") {
if (is_clang && clang_base_path == default_clang_base_path) {
if (is_clang && clang_base_path == default_clang_base_path &&
current_os != "zos") {
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@ -1656,6 +1691,34 @@ config("compiler_arm") {
}
}
config("libcxx_module") {
if (use_libcxx_modules) {
modulemap = rebase_path("//third_party/libc++/src/include/module.modulemap",
root_build_dir)
cflags_cc = [
"-fmodules",
"-fmodule-map-file=" + modulemap,
"-fno-implicit-module-maps",
"-fbuiltin-module-map",
"-fmodules-cache-path=" +
rebase_path("$libcxx_module_prefix/module_cache", root_build_dir),
"-Xclang",
"-fmodules-local-submodule-visibility", # required for builtins
# TODO(crbug.com/1456385): Figure out if this can be removed.
"-Wno-modules-ambiguous-internal-linkage",
# TODO(crbug.com/40440396): Clean up.
"-Wno-modules-import-nested-redundant",
# Needed to allow using builtin modules when the headers are
# unnecessarily using extern "C".
"-Wno-module-import-in-extern-c",
]
}
}
# runtime_library -------------------------------------------------------------
#
# Sets the runtime library and associated options.
@ -1885,9 +1948,6 @@ config("default_warnings") {
# TODO(https://crbug.com/324953188): fix and reenable
"-Wno-extra-qualification",
# TODO(https://crbug.com/332931387): fix and reenable
"-Wno-unused-but-set-variable",
]
}
@ -1895,16 +1955,9 @@ config("default_warnings") {
# 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/40231599) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
# TODO(crbug.com/40234766) Evaluate and possibly enable.
"-Wno-bitfield-constant-conversion",
# TODO(crbug.com/40255410) Evaluate and possibly enable.
"-Wno-deprecated-this-capture",
@ -1928,6 +1981,9 @@ config("default_warnings") {
# TODO(crbug.com/41486292): Fix and re-enable.
"-Wno-c++11-narrowing-const-reference",
]
# TODO(crbug.com/344680447): Fix and re-enable.
cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
}
}
@ -1943,6 +1999,11 @@ config("default_warnings") {
}
}
# TODO(crbug.com/354162568): Clean up and enable.
if (llvm_force_head_revision && is_apple && use_lld) {
ldflags += [ "-Wl,--no-warn-duplicate-rpath" ]
}
# Rust warnings
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
@ -2547,14 +2608,17 @@ config("default_stack_frames") {
# [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" ]
}
# clang-cl's /O2 corresponds to clang's -O3, and really want -O3 for
# consistency with the other platforms.
cflags = [
"/O2",
"-Xclang", "-O3",
"/clang:-O3",
] + common_optimize_on_cflags
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
# suggests not using an explicit `-Copt-level` at all, and the default is
# to optimize for performance like `/O2` for clang.
# The `-O3` for clang turns on extra optimizations compared to the standard
# `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
# to use.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+avx,+aes" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
@ -2736,12 +2800,10 @@ if (is_clang && is_a_target_toolchain) {
if (is_android || is_castos) {
_clang_sample_profile = "//chrome/android/profiles/afdo.prof"
} else {
assert(
chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp",
"Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
assert(chromeos_afdo_platform == "atom" ||
chromeos_afdo_platform == "bigcore" ||
chromeos_afdo_platform == "arm",
"Only 'atom', 'bigcore', and 'arm' are valid ChromeOS profiles.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2864,7 +2926,8 @@ config("symbols") {
}
# On aix -gdwarf causes linker failures due to thread_local variables.
if (!is_nacl && current_os != "aix") {
# On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE.
if (!is_nacl && current_os != "aix" && current_os != "zos") {
if (use_dwarf5) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
@ -2948,13 +3011,12 @@ config("symbols") {
# 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) &&
if (symbol_level == 2 && !use_debug_fission && !is_nacl && !is_win &&
(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_clang && (!is_nacl || is_nacl_saigo)) {
if (is_apple) {
# TODO(crbug.com/40117949): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@ -3038,7 +3100,7 @@ config("minimal_symbols") {
cflags += [ "-g1" ]
}
if (!is_nacl && is_clang && !is_tsan && !is_asan) {
if (!is_nacl && is_clang && !is_tsan && !is_asan && current_os != "zos") {
# See comment for -gdwarf-aranges in config("symbols").
cflags += [ "-gdwarf-aranges" ]
}

@ -1 +1 @@
Subproject commit 968a3dcb02fedeb0cd4b3414fc534b9641b847db
Subproject commit f42b530b898a447a567b1a94e50f63dc163a1ba3