update BUILD.gns

This commit is contained in:
Alexander Frick 2024-05-12 05:53:15 -05:00
parent 93699e0976
commit 013db737ce
8 changed files with 484 additions and 418 deletions

View file

@ -803,7 +803,7 @@ config("compiler") {
# FIXME(inglorion): maybe tune these?
# TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
import_instr_limit = 30
} else if (is_android) {
} else if (is_android && optimize_for_size) {
# TODO(crbug.com/1308318): 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
@ -1097,6 +1097,12 @@ config("compiler") {
} else {
defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
}
# Enable libstdc++ hardening lightweight assertions. Those have a low
# performance penalty but are considered a bare minimum for security.
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1762,6 +1768,9 @@ config("treat_warnings_as_errors") {
# Note we apply the actual lint flags in config("compiler"). All warnings
# are suppressed in third-party crates.
rustflags = [ "-Dwarnings" ]
# TODO(https://crbug.com/326247202): Fix unused imports and remove this flag.
rustflags += [ "-Aunused-imports" ]
}
# default_warnings ------------------------------------------------------------
@ -1809,6 +1818,12 @@ config("default_warnings") {
# When compiling Objective-C, warns if a selector named via @selector has
# not been defined in any visible interface.
cflags += [ "-Wundeclared-selector" ]
# Blink builds use a higher deployment target than non-Blink builds, so
# suppress deprecation warnings in these builds.
if (use_blink) {
cflags += [ "-Wno-deprecated-declarations" ]
}
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
@ -1896,8 +1911,6 @@ config("default_warnings") {
}
cflags += [
"-Wenum-compare-conditional",
# Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize",
@ -1921,6 +1934,11 @@ config("default_warnings") {
"-Wno-thread-safety-reference-return",
]
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
]
if (!is_nacl) {
cflags_cc += [
# TODO(https://crbug.com/1513724): Fix and re-enable.
@ -1990,35 +2008,6 @@ config("prevent_unsafe_narrowing") {
}
}
# unsafe_buffer_warning -------------------------------------------------------
# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
# have been unable to fix yet. We use this list to be able to make progress and
# enable the warning on code that we do control/own.
#
# WARNING: This will disable all warnings in the files. ONLY USE THIS for
# third-party code which we do not control/own. Fix the warnings instead in
# our own code.
if (is_clang) {
unsafe_buffer_warning_header_allowlist =
[ "third_party/googletest/src/googletest/include/gtest" ]
}
# Enables warnings on pointer arithmetic/indexing or calls to functions
# annotated with `UNSAFE_BUFFER_USAGE`.
config("unsafe_buffer_warning") {
if (is_clang) {
cflags = [ "-Wunsafe-buffer-usage" ]
foreach(h, unsafe_buffer_warning_header_allowlist) {
if (is_win) {
cflags += [ "/clang:--system-header-prefix=$h" ]
} else {
cflags += [ "--system-header-prefix=$h" ]
}
}
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)
@ -2236,9 +2225,7 @@ config("export_dynamic") {
config("thin_archive") {
# The macOS and iOS default linker ld64 does not support reading thin
# archives.
# TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
# confuses lldb.
if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
if ((is_posix && !is_nacl && (!is_apple || use_lld)) || is_fuchsia) {
arflags = [ "-T" ]
} else if (is_win && use_lld) {
arflags = [ "/llvmlibthin" ]
@ -2336,7 +2323,6 @@ if (is_win) {
common_optimize_on_ldflags = []
common_optimize_on_cflags += [
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Zc:inline", # Remove unreferenced COMDAT (faster links).
]
@ -2570,24 +2556,16 @@ config("default_stack_frames") {
# Default "optimization on" config.
config("optimize") {
if (is_win) {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=3" ]
} else {
# PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
cflags = [ "/O2", "-Xclang", "-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.
rustflags = [ "-Copt-level=3" ]
}
# 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.
rustflags = [ "-Copt-level=3" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
# -Os in clang is more of a size-conscious -O2 than "size at any cost" (AKA -Oz).
# -Os in clang is more of a size-conscious -O2 than "size at any cost"
# (AKA -Oz).
if (is_fuchsia) {
cflags = [ "-O3" ] + common_optimize_on_cflags

View file

@ -800,7 +800,7 @@ config("compiler") {
# FIXME(inglorion): maybe tune these?
# TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
import_instr_limit = 30
} else if (is_android) {
} else if (is_android && optimize_for_size) {
# TODO(crbug.com/1308318): 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
@ -1087,6 +1087,12 @@ config("compiler") {
} else {
defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
}
# Enable libstdc++ hardening lightweight assertions. Those have a low
# performance penalty but are considered a bare minimum for security.
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1205,11 +1211,6 @@ config("compiler_cpu_abi") {
"-msse3",
]
}
} else if (target_cpu == "arm64") {
if (!is_android && !is_nacl) {
cflags += [ "-O3", ]
ldflags += [ "-Wl,-O3", ]
}
} else if (current_cpu == "arm") {
if (is_clang && !is_android && !is_nacl &&
!(is_chromeos_lacros && is_chromeos_device)) {
@ -1760,6 +1761,9 @@ config("treat_warnings_as_errors") {
# Note we apply the actual lint flags in config("compiler"). All warnings
# are suppressed in third-party crates.
rustflags = [ "-Dwarnings" ]
# TODO(https://crbug.com/326247202): Fix unused imports and remove this flag.
rustflags += [ "-Aunused-imports" ]
}
# default_warnings ------------------------------------------------------------
@ -1807,6 +1811,12 @@ config("default_warnings") {
# When compiling Objective-C, warns if a selector named via @selector has
# not been defined in any visible interface.
cflags += [ "-Wundeclared-selector" ]
# Blink builds use a higher deployment target than non-Blink builds, so
# suppress deprecation warnings in these builds.
if (use_blink) {
cflags += [ "-Wno-deprecated-declarations" ]
}
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
@ -1894,8 +1904,6 @@ config("default_warnings") {
}
cflags += [
"-Wenum-compare-conditional",
# Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize",
@ -1919,6 +1927,11 @@ config("default_warnings") {
"-Wno-thread-safety-reference-return",
]
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
]
if (!is_nacl) {
cflags_cc += [
# TODO(https://crbug.com/1513724): Fix and re-enable.
@ -1988,35 +2001,6 @@ config("prevent_unsafe_narrowing") {
}
}
# unsafe_buffer_warning -------------------------------------------------------
# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
# have been unable to fix yet. We use this list to be able to make progress and
# enable the warning on code that we do control/own.
#
# WARNING: This will disable all warnings in the files. ONLY USE THIS for
# third-party code which we do not control/own. Fix the warnings instead in
# our own code.
if (is_clang) {
unsafe_buffer_warning_header_allowlist =
[ "third_party/googletest/src/googletest/include/gtest" ]
}
# Enables warnings on pointer arithmetic/indexing or calls to functions
# annotated with `UNSAFE_BUFFER_USAGE`.
config("unsafe_buffer_warning") {
if (is_clang) {
cflags = [ "-Wunsafe-buffer-usage" ]
foreach(h, unsafe_buffer_warning_header_allowlist) {
if (is_win) {
cflags += [ "/clang:--system-header-prefix=$h" ]
} else {
cflags += [ "--system-header-prefix=$h" ]
}
}
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)
@ -2234,9 +2218,7 @@ config("export_dynamic") {
config("thin_archive") {
# The macOS and iOS default linker ld64 does not support reading thin
# archives.
# TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
# confuses lldb.
if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
if ((is_posix && !is_nacl && (!is_apple || use_lld)) || is_fuchsia) {
arflags = [ "-T" ]
} else if (is_win && use_lld) {
arflags = [ "/llvmlibthin" ]
@ -2334,7 +2316,6 @@ if (is_win) {
common_optimize_on_ldflags = []
common_optimize_on_cflags += [
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Zc:inline", # Remove unreferenced COMDAT (faster links).
]
@ -2358,9 +2339,9 @@ if (is_win) {
"/clang:-mssse3",
"/clang:-msse4.1",
"/clang:-msse4.2",
"/clang:-mpclmul",
"/clang:-maes",
"/clang:-mavx",
"/clang:-maes",
"/clang:-mpclmul",
"/clang:-mavx2",
"/clang:-mfma",
"/clang:-mf16c",
@ -2559,24 +2540,16 @@ config("default_stack_frames") {
# Default "optimization on" config.
config("optimize") {
if (is_win) {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+avx,+avx2,+fma,+f16c,+aes" ]
} else {
# PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
cflags = [ "/O2", "-Xclang", "-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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+avx,+avx2,+fma,+f16c,+aes" ]
}
# 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.
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.
# -Os in clang is more of a size-conscious -O2 than "size at any cost" (AKA -Oz).
# -Os in clang is more of a size-conscious -O2 than "size at any cost"
# (AKA -Oz).
if (is_fuchsia) {
cflags = [ "-O3" ] + common_optimize_on_cflags

View file

@ -800,7 +800,7 @@ config("compiler") {
# FIXME(inglorion): maybe tune these?
# TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
import_instr_limit = 30
} else if (is_android) {
} else if (is_android && optimize_for_size) {
# TODO(crbug.com/1308318): 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
@ -1086,6 +1086,12 @@ config("compiler") {
} else {
defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
}
# Enable libstdc++ hardening lightweight assertions. Those have a low
# performance penalty but are considered a bare minimum for security.
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1178,10 +1184,9 @@ config("compiler_cpu_abi") {
"-O3",
"-msse3",
"-mssse3",
"-msse4",
"-msse4.1",
]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4", "-msse4.1", ]
ldflags += [ "-m64", "-Wl,-O3", "-msse3", "-mssse3", "-msse4.1", ]
} else if (current_cpu == "x86") {
cflags += [ "-m32" ]
ldflags += [ "-m32", "-Wl,-O3", "-msse3", ]
@ -1193,11 +1198,6 @@ config("compiler_cpu_abi") {
"-msse3",
]
}
} else if (target_cpu == "arm64") {
if (!is_android && !is_nacl) {
cflags += [ "-O3", ]
ldflags += [ "-Wl,-O3", ]
}
} else if (current_cpu == "arm") {
if (is_clang && !is_android && !is_nacl &&
!(is_chromeos_lacros && is_chromeos_device)) {
@ -1748,6 +1748,9 @@ config("treat_warnings_as_errors") {
# Note we apply the actual lint flags in config("compiler"). All warnings
# are suppressed in third-party crates.
rustflags = [ "-Dwarnings" ]
# TODO(https://crbug.com/326247202): Fix unused imports and remove this flag.
rustflags += [ "-Aunused-imports" ]
}
# default_warnings ------------------------------------------------------------
@ -1795,6 +1798,12 @@ config("default_warnings") {
# When compiling Objective-C, warns if a selector named via @selector has
# not been defined in any visible interface.
cflags += [ "-Wundeclared-selector" ]
# Blink builds use a higher deployment target than non-Blink builds, so
# suppress deprecation warnings in these builds.
if (use_blink) {
cflags += [ "-Wno-deprecated-declarations" ]
}
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
@ -1882,8 +1891,6 @@ config("default_warnings") {
}
cflags += [
"-Wenum-compare-conditional",
# Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize",
@ -1907,6 +1914,11 @@ config("default_warnings") {
"-Wno-thread-safety-reference-return",
]
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
]
if (!is_nacl) {
cflags_cc += [
# TODO(https://crbug.com/1513724): Fix and re-enable.
@ -1976,35 +1988,6 @@ config("prevent_unsafe_narrowing") {
}
}
# unsafe_buffer_warning -------------------------------------------------------
# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
# have been unable to fix yet. We use this list to be able to make progress and
# enable the warning on code that we do control/own.
#
# WARNING: This will disable all warnings in the files. ONLY USE THIS for
# third-party code which we do not control/own. Fix the warnings instead in
# our own code.
if (is_clang) {
unsafe_buffer_warning_header_allowlist =
[ "third_party/googletest/src/googletest/include/gtest" ]
}
# Enables warnings on pointer arithmetic/indexing or calls to functions
# annotated with `UNSAFE_BUFFER_USAGE`.
config("unsafe_buffer_warning") {
if (is_clang) {
cflags = [ "-Wunsafe-buffer-usage" ]
foreach(h, unsafe_buffer_warning_header_allowlist) {
if (is_win) {
cflags += [ "/clang:--system-header-prefix=$h" ]
} else {
cflags += [ "--system-header-prefix=$h" ]
}
}
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)
@ -2222,9 +2205,7 @@ config("export_dynamic") {
config("thin_archive") {
# The macOS and iOS default linker ld64 does not support reading thin
# archives.
# TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
# confuses lldb.
if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
if ((is_posix && !is_nacl && (!is_apple || use_lld)) || is_fuchsia) {
arflags = [ "-T" ]
} else if (is_win && use_lld) {
arflags = [ "/llvmlibthin" ]
@ -2322,7 +2303,6 @@ if (is_win) {
common_optimize_on_ldflags = []
common_optimize_on_cflags += [
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Zc:inline", # Remove unreferenced COMDAT (faster links).
]
@ -2538,24 +2518,16 @@ config("default_stack_frames") {
# Default "optimization on" config.
config("optimize") {
if (is_win) {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1" ]
} else {
# PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
cflags = [ "/O2", "-Xclang", "-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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1" ]
}
# 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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
# -Os in clang is more of a size-conscious -O2 than "size at any cost" (AKA -Oz).
# -Os in clang is more of a size-conscious -O2 than "size at any cost"
# (AKA -Oz).
if (is_fuchsia) {
cflags = [ "-O3" ] + common_optimize_on_cflags

View file

@ -800,7 +800,7 @@ config("compiler") {
# FIXME(inglorion): maybe tune these?
# TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
import_instr_limit = 30
} else if (is_android) {
} else if (is_android && optimize_for_size) {
# TODO(crbug.com/1308318): 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
@ -1086,6 +1086,12 @@ config("compiler") {
} else {
defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
}
# Enable libstdc++ hardening lightweight assertions. Those have a low
# performance penalty but are considered a bare minimum for security.
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1195,11 +1201,6 @@ config("compiler_cpu_abi") {
"-msse2",
]
}
} else if (target_cpu == "arm64") {
if (!is_android && !is_nacl) {
cflags += [ "-O3", ]
ldflags += [ "-Wl,-O3", ]
}
} else if (current_cpu == "arm") {
if (is_clang && !is_android && !is_nacl &&
!(is_chromeos_lacros && is_chromeos_device)) {
@ -1750,6 +1751,9 @@ config("treat_warnings_as_errors") {
# Note we apply the actual lint flags in config("compiler"). All warnings
# are suppressed in third-party crates.
rustflags = [ "-Dwarnings" ]
# TODO(https://crbug.com/326247202): Fix unused imports and remove this flag.
rustflags += [ "-Aunused-imports" ]
}
# default_warnings ------------------------------------------------------------
@ -1797,6 +1801,12 @@ config("default_warnings") {
# When compiling Objective-C, warns if a selector named via @selector has
# not been defined in any visible interface.
cflags += [ "-Wundeclared-selector" ]
# Blink builds use a higher deployment target than non-Blink builds, so
# suppress deprecation warnings in these builds.
if (use_blink) {
cflags += [ "-Wno-deprecated-declarations" ]
}
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
@ -1884,8 +1894,6 @@ config("default_warnings") {
}
cflags += [
"-Wenum-compare-conditional",
# Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize",
@ -1909,6 +1917,11 @@ config("default_warnings") {
"-Wno-thread-safety-reference-return",
]
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
]
if (!is_nacl) {
cflags_cc += [
# TODO(https://crbug.com/1513724): Fix and re-enable.
@ -1978,35 +1991,6 @@ config("prevent_unsafe_narrowing") {
}
}
# unsafe_buffer_warning -------------------------------------------------------
# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
# have been unable to fix yet. We use this list to be able to make progress and
# enable the warning on code that we do control/own.
#
# WARNING: This will disable all warnings in the files. ONLY USE THIS for
# third-party code which we do not control/own. Fix the warnings instead in
# our own code.
if (is_clang) {
unsafe_buffer_warning_header_allowlist =
[ "third_party/googletest/src/googletest/include/gtest" ]
}
# Enables warnings on pointer arithmetic/indexing or calls to functions
# annotated with `UNSAFE_BUFFER_USAGE`.
config("unsafe_buffer_warning") {
if (is_clang) {
cflags = [ "-Wunsafe-buffer-usage" ]
foreach(h, unsafe_buffer_warning_header_allowlist) {
if (is_win) {
cflags += [ "/clang:--system-header-prefix=$h" ]
} else {
cflags += [ "--system-header-prefix=$h" ]
}
}
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)
@ -2224,9 +2208,7 @@ config("export_dynamic") {
config("thin_archive") {
# The macOS and iOS default linker ld64 does not support reading thin
# archives.
# TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
# confuses lldb.
if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
if ((is_posix && !is_nacl && (!is_apple || use_lld)) || is_fuchsia) {
arflags = [ "-T" ]
} else if (is_win && use_lld) {
arflags = [ "/llvmlibthin" ]
@ -2324,7 +2306,6 @@ if (is_win) {
common_optimize_on_ldflags = []
common_optimize_on_cflags += [
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Zc:inline", # Remove unreferenced COMDAT (faster links).
]
@ -2462,6 +2443,55 @@ if (is_win) {
common_optimize_on_cflags += [ "-fno-math-errno" ]
}
config("march_crc") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8-a+crc" ]
asmflags = cflags
}
}
config("march_dotprod") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+dotprod" ]
asmflags = cflags
}
}
config("march_fp16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+fp16" ]
asmflags = cflags
}
}
config("march_dotprod_fp16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+fp16+dotprod" ]
asmflags = cflags
}
}
config("march_dotprod_i8mm_sve") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+dotprod+i8mm+sve" ]
asmflags = cflags
}
}
config("march_i8mm") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+i8mm" ]
asmflags = cflags
}
}
config("march_i8mm_f16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+i8mm+fp16" ]
asmflags = cflags
}
}
config("default_stack_frames") {
if (!is_win) {
if (enable_frame_pointers) {
@ -2491,24 +2521,16 @@ config("default_stack_frames") {
# Default "optimization on" config.
config("optimize") {
if (is_win) {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse2" ]
} else {
# PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
cflags = [ "/O2", "-Xclang", "-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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse2" ]
}
# 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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse2" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
# -Os in clang is more of a size-conscious -O2 than "size at any cost" (AKA -Oz).
# -Os in clang is more of a size-conscious -O2 than "size at any cost"
# (AKA -Oz).
if (is_fuchsia) {
cflags = [ "-O3" ] + common_optimize_on_cflags

View file

@ -800,7 +800,7 @@ config("compiler") {
# FIXME(inglorion): maybe tune these?
# TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
import_instr_limit = 30
} else if (is_android) {
} else if (is_android && optimize_for_size) {
# TODO(crbug.com/1308318): 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
@ -1086,6 +1086,12 @@ config("compiler") {
} else {
defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
}
# Enable libstdc++ hardening lightweight assertions. Those have a low
# performance penalty but are considered a bare minimum for security.
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1190,11 +1196,6 @@ config("compiler_cpu_abi") {
"-msse3",
]
}
} else if (target_cpu == "arm64") {
if (!is_android && !is_nacl) {
cflags += [ "-O3", ]
ldflags += [ "-Wl,-O3", ]
}
} else if (current_cpu == "arm") {
if (is_clang && !is_android && !is_nacl &&
!(is_chromeos_lacros && is_chromeos_device)) {
@ -1745,6 +1746,9 @@ config("treat_warnings_as_errors") {
# Note we apply the actual lint flags in config("compiler"). All warnings
# are suppressed in third-party crates.
rustflags = [ "-Dwarnings" ]
# TODO(https://crbug.com/326247202): Fix unused imports and remove this flag.
rustflags += [ "-Aunused-imports" ]
}
# default_warnings ------------------------------------------------------------
@ -1792,6 +1796,12 @@ config("default_warnings") {
# When compiling Objective-C, warns if a selector named via @selector has
# not been defined in any visible interface.
cflags += [ "-Wundeclared-selector" ]
# Blink builds use a higher deployment target than non-Blink builds, so
# suppress deprecation warnings in these builds.
if (use_blink) {
cflags += [ "-Wno-deprecated-declarations" ]
}
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
@ -1879,8 +1889,6 @@ config("default_warnings") {
}
cflags += [
"-Wenum-compare-conditional",
# Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize",
@ -1904,6 +1912,11 @@ config("default_warnings") {
"-Wno-thread-safety-reference-return",
]
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
]
if (!is_nacl) {
cflags_cc += [
# TODO(https://crbug.com/1513724): Fix and re-enable.
@ -1973,35 +1986,6 @@ config("prevent_unsafe_narrowing") {
}
}
# unsafe_buffer_warning -------------------------------------------------------
# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
# have been unable to fix yet. We use this list to be able to make progress and
# enable the warning on code that we do control/own.
#
# WARNING: This will disable all warnings in the files. ONLY USE THIS for
# third-party code which we do not control/own. Fix the warnings instead in
# our own code.
if (is_clang) {
unsafe_buffer_warning_header_allowlist =
[ "third_party/googletest/src/googletest/include/gtest" ]
}
# Enables warnings on pointer arithmetic/indexing or calls to functions
# annotated with `UNSAFE_BUFFER_USAGE`.
config("unsafe_buffer_warning") {
if (is_clang) {
cflags = [ "-Wunsafe-buffer-usage" ]
foreach(h, unsafe_buffer_warning_header_allowlist) {
if (is_win) {
cflags += [ "/clang:--system-header-prefix=$h" ]
} else {
cflags += [ "--system-header-prefix=$h" ]
}
}
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)
@ -2219,9 +2203,7 @@ config("export_dynamic") {
config("thin_archive") {
# The macOS and iOS default linker ld64 does not support reading thin
# archives.
# TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
# confuses lldb.
if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
if ((is_posix && !is_nacl && (!is_apple || use_lld)) || is_fuchsia) {
arflags = [ "-T" ]
} else if (is_win && use_lld) {
arflags = [ "/llvmlibthin" ]
@ -2319,7 +2301,6 @@ if (is_win) {
common_optimize_on_ldflags = []
common_optimize_on_cflags += [
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Zc:inline", # Remove unreferenced COMDAT (faster links).
]
@ -2454,6 +2435,55 @@ if (is_win) {
common_optimize_on_cflags += [ "-fno-math-errno" ]
}
config("march_crc") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8-a+crc" ]
asmflags = cflags
}
}
config("march_dotprod") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+dotprod" ]
asmflags = cflags
}
}
config("march_fp16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+fp16" ]
asmflags = cflags
}
}
config("march_dotprod_fp16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+fp16+dotprod" ]
asmflags = cflags
}
}
config("march_dotprod_i8mm_sve") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+dotprod+i8mm+sve" ]
asmflags = cflags
}
}
config("march_i8mm") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+i8mm" ]
asmflags = cflags
}
}
config("march_i8mm_f16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+i8mm+fp16" ]
asmflags = cflags
}
}
config("default_stack_frames") {
if (!is_win) {
if (enable_frame_pointers) {
@ -2483,24 +2513,16 @@ config("default_stack_frames") {
# Default "optimization on" config.
config("optimize") {
if (is_win) {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3" ]
} else {
# PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
cflags = [ "/O2", "-Xclang", "-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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3" ]
}
# 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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
# -Os in clang is more of a size-conscious -O2 than "size at any cost" (AKA -Oz).
# -Os in clang is more of a size-conscious -O2 than "size at any cost"
# (AKA -Oz).
if (is_fuchsia) {
cflags = [ "-O3" ] + common_optimize_on_cflags

View file

@ -800,7 +800,7 @@ config("compiler") {
# FIXME(inglorion): maybe tune these?
# TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
import_instr_limit = 30
} else if (is_android) {
} else if (is_android && optimize_for_size) {
# TODO(crbug.com/1308318): 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
@ -1086,6 +1086,12 @@ config("compiler") {
} else {
defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
}
# Enable libstdc++ hardening lightweight assertions. Those have a low
# performance penalty but are considered a bare minimum for security.
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1192,11 +1198,6 @@ config("compiler_cpu_abi") {
"-msse3",
]
}
} else if (target_cpu == "arm64") {
if (!is_android && !is_nacl) {
cflags += [ "-O3", ]
ldflags += [ "-Wl,-O3", ]
}
} else if (current_cpu == "arm") {
if (is_clang && !is_android && !is_nacl &&
!(is_chromeos_lacros && is_chromeos_device)) {
@ -1747,6 +1748,9 @@ config("treat_warnings_as_errors") {
# Note we apply the actual lint flags in config("compiler"). All warnings
# are suppressed in third-party crates.
rustflags = [ "-Dwarnings" ]
# TODO(https://crbug.com/326247202): Fix unused imports and remove this flag.
rustflags += [ "-Aunused-imports" ]
}
# default_warnings ------------------------------------------------------------
@ -1794,6 +1798,12 @@ config("default_warnings") {
# When compiling Objective-C, warns if a selector named via @selector has
# not been defined in any visible interface.
cflags += [ "-Wundeclared-selector" ]
# Blink builds use a higher deployment target than non-Blink builds, so
# suppress deprecation warnings in these builds.
if (use_blink) {
cflags += [ "-Wno-deprecated-declarations" ]
}
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
@ -1881,8 +1891,6 @@ config("default_warnings") {
}
cflags += [
"-Wenum-compare-conditional",
# Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize",
@ -1906,6 +1914,11 @@ config("default_warnings") {
"-Wno-thread-safety-reference-return",
]
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
]
if (!is_nacl) {
cflags_cc += [
# TODO(https://crbug.com/1513724): Fix and re-enable.
@ -1975,35 +1988,6 @@ config("prevent_unsafe_narrowing") {
}
}
# unsafe_buffer_warning -------------------------------------------------------
# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
# have been unable to fix yet. We use this list to be able to make progress and
# enable the warning on code that we do control/own.
#
# WARNING: This will disable all warnings in the files. ONLY USE THIS for
# third-party code which we do not control/own. Fix the warnings instead in
# our own code.
if (is_clang) {
unsafe_buffer_warning_header_allowlist =
[ "third_party/googletest/src/googletest/include/gtest" ]
}
# Enables warnings on pointer arithmetic/indexing or calls to functions
# annotated with `UNSAFE_BUFFER_USAGE`.
config("unsafe_buffer_warning") {
if (is_clang) {
cflags = [ "-Wunsafe-buffer-usage" ]
foreach(h, unsafe_buffer_warning_header_allowlist) {
if (is_win) {
cflags += [ "/clang:--system-header-prefix=$h" ]
} else {
cflags += [ "--system-header-prefix=$h" ]
}
}
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)
@ -2221,9 +2205,7 @@ config("export_dynamic") {
config("thin_archive") {
# The macOS and iOS default linker ld64 does not support reading thin
# archives.
# TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
# confuses lldb.
if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
if ((is_posix && !is_nacl && (!is_apple || use_lld)) || is_fuchsia) {
arflags = [ "-T" ]
} else if (is_win && use_lld) {
arflags = [ "/llvmlibthin" ]
@ -2321,7 +2303,6 @@ if (is_win) {
common_optimize_on_ldflags = []
common_optimize_on_cflags += [
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Zc:inline", # Remove unreferenced COMDAT (faster links).
]
@ -2458,6 +2439,55 @@ if (is_win) {
common_optimize_on_cflags += [ "-fno-math-errno" ]
}
config("march_crc") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8-a+crc" ]
asmflags = cflags
}
}
config("march_dotprod") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+dotprod" ]
asmflags = cflags
}
}
config("march_fp16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+fp16" ]
asmflags = cflags
}
}
config("march_dotprod_fp16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+fp16+dotprod" ]
asmflags = cflags
}
}
config("march_dotprod_i8mm_sve") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+dotprod+i8mm+sve" ]
asmflags = cflags
}
}
config("march_i8mm") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+i8mm" ]
asmflags = cflags
}
}
config("march_i8mm_f16") {
if (!is_win || is_clang) {
cflags = [ "-march=armv8.2-a+i8mm+fp16" ]
asmflags = cflags
}
}
config("default_stack_frames") {
if (!is_win) {
if (enable_frame_pointers) {
@ -2487,24 +2517,16 @@ config("default_stack_frames") {
# Default "optimization on" config.
config("optimize") {
if (is_win) {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1" ]
} else {
# PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
cflags = [ "/O2", "-Xclang", "-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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1" ]
}
# 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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1" ]
} else if (optimize_for_size || is_chromeos) {
# Favor size over speed.
# -Os in clang is more of a size-conscious -O2 than "size at any cost" (AKA -Oz).
# -Os in clang is more of a size-conscious -O2 than "size at any cost"
# (AKA -Oz).
if (is_fuchsia) {
cflags = [ "-O3" ] + common_optimize_on_cflags

View file

@ -800,7 +800,7 @@ config("compiler") {
# FIXME(inglorion): maybe tune these?
# TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
import_instr_limit = 30
} else if (is_android) {
} else if (is_android && optimize_for_size) {
# TODO(crbug.com/1308318): 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
@ -1086,6 +1086,12 @@ config("compiler") {
} else {
defines += [ "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE" ]
}
# Enable libstdc++ hardening lightweight assertions. Those have a low
# performance penalty but are considered a bare minimum for security.
if (use_safe_libstdcxx) {
defines += [ "_GLIBCXX_ASSERTIONS=1" ]
}
}
# The BUILDCONFIG file sets this config on targets by default, which means when
@ -1197,11 +1203,6 @@ config("compiler_cpu_abi") {
"-msse3",
]
}
} else if (target_cpu == "arm64") {
if (!is_android && !is_nacl) {
cflags += [ "-O3", ]
ldflags += [ "-Wl,-O3", ]
}
} else if (current_cpu == "arm") {
if (is_clang && !is_android && !is_nacl &&
!(is_chromeos_lacros && is_chromeos_device)) {
@ -1752,6 +1753,9 @@ config("treat_warnings_as_errors") {
# Note we apply the actual lint flags in config("compiler"). All warnings
# are suppressed in third-party crates.
rustflags = [ "-Dwarnings" ]
# TODO(https://crbug.com/326247202): Fix unused imports and remove this flag.
rustflags += [ "-Aunused-imports" ]
}
# default_warnings ------------------------------------------------------------
@ -1799,6 +1803,12 @@ config("default_warnings") {
# When compiling Objective-C, warns if a selector named via @selector has
# not been defined in any visible interface.
cflags += [ "-Wundeclared-selector" ]
# Blink builds use a higher deployment target than non-Blink builds, so
# suppress deprecation warnings in these builds.
if (use_blink) {
cflags += [ "-Wno-deprecated-declarations" ]
}
}
# Suppress warnings about ABI changes on ARM (Clang doesn't give this
@ -1886,8 +1896,6 @@ config("default_warnings") {
}
cflags += [
"-Wenum-compare-conditional",
# Ignore warnings about MSVC optimization pragmas.
# TODO(thakis): Only for no_chromium_code? http://crbug.com/912662
"-Wno-ignored-pragma-optimize",
@ -1911,6 +1919,11 @@ config("default_warnings") {
"-Wno-thread-safety-reference-return",
]
cflags_cc += [
# TODO(crbug.com/328490295): Fix and re-enable for C flags.
"-Wenum-compare-conditional",
]
if (!is_nacl) {
cflags_cc += [
# TODO(https://crbug.com/1513724): Fix and re-enable.
@ -1980,35 +1993,6 @@ config("prevent_unsafe_narrowing") {
}
}
# unsafe_buffer_warning -------------------------------------------------------
# Paths of third-party headers that violate Wunsafe-buffer-usage, but which we
# have been unable to fix yet. We use this list to be able to make progress and
# enable the warning on code that we do control/own.
#
# WARNING: This will disable all warnings in the files. ONLY USE THIS for
# third-party code which we do not control/own. Fix the warnings instead in
# our own code.
if (is_clang) {
unsafe_buffer_warning_header_allowlist =
[ "third_party/googletest/src/googletest/include/gtest" ]
}
# Enables warnings on pointer arithmetic/indexing or calls to functions
# annotated with `UNSAFE_BUFFER_USAGE`.
config("unsafe_buffer_warning") {
if (is_clang) {
cflags = [ "-Wunsafe-buffer-usage" ]
foreach(h, unsafe_buffer_warning_header_allowlist) {
if (is_win) {
cflags += [ "/clang:--system-header-prefix=$h" ]
} else {
cflags += [ "--system-header-prefix=$h" ]
}
}
}
}
# chromium_code ---------------------------------------------------------------
#
# Toggles between higher and lower warnings for code that is (or isn't)
@ -2226,9 +2210,7 @@ config("export_dynamic") {
config("thin_archive") {
# The macOS and iOS default linker ld64 does not support reading thin
# archives.
# TODO(crbug.com/1221615): Enable on is_apple if use_lld once that no longer
# confuses lldb.
if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) {
if ((is_posix && !is_nacl && (!is_apple || use_lld)) || is_fuchsia) {
arflags = [ "-T" ]
} else if (is_win && use_lld) {
arflags = [ "/llvmlibthin" ]
@ -2326,7 +2308,6 @@ if (is_win) {
common_optimize_on_ldflags = []
common_optimize_on_cflags += [
"/Ob2", # Both explicit and auto inlining.
"/Oy-", # Disable omitting frame pointers, must be after /O2.
"/Zc:inline", # Remove unreferenced COMDAT (faster links).
]
@ -2545,24 +2526,16 @@ config("default_stack_frames") {
# Default "optimization on" config.
config("optimize") {
if (is_win) {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
# /O1 implies /Os and /GF.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+avx,+aes" ]
} else {
# PGO requires all translation units to be compiled with /O2. The actual
# optimization level will be decided based on the profiling data.
cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags
cflags = [ "/O2", "-Xclang", "-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.
rustflags = [ "-Copt-level=3", "-Ctarget-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+avx,+aes" ]
}
# 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.
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.
# -Os in clang is more of a size-conscious -O2 than "size at any cost" (AKA -Oz).
# -Os in clang is more of a size-conscious -O2 than "size at any cost"
# (AKA -Oz).
if (is_fuchsia) {
cflags = [ "-O3" ] + common_optimize_on_cflags

View file

@ -337,10 +337,12 @@ declare_args() {
# Sets -DV8_ENABLE_SANDBOX.
v8_enable_sandbox = ""
# Expose the memory corruption API to JavaScript. Useful for testing the sandbox.
# WARNING This will expose builtins that (by design) cause memory corruption.
# Sets -DV8_EXPOSE_MEMORY_CORRUPTION_API
v8_expose_memory_corruption_api = false
# Enable the memory corruption API. Useful for testing the sandbox.
# The memory corruption API is only exposed to JavaScript if sandbox testing
# mode is enabled at runtime, for example via --sandbox-fuzzing.
# WARNING This will enable builtins that (by design) cause memory corruption.
# Sets -DV8_ENABLE_MEMORY_CORRUPTION_API
v8_enable_memory_corruption_api = false
# Experimental feature for collecting per-class zone memory stats.
# Requires use_rtti = true
@ -605,24 +607,26 @@ assert(
if (v8_builtins_profiling_log_file == "default") {
v8_builtins_profiling_log_file = ""
# Don't use existing profile when
# * v8_enable_builtins_optimization is disabled,
# * generating a new one (i.e. v8_enable_builtins_profiling),
# * is_debug or dcheck_always_on because they add more checks to the
# builtins control flow which we don't want to generate,
# * !v8_enable_sandbox because it affects the way how external pointer values
# are accessed,
# * v8_enable_webassembly because it changes the set of opcodes which affects
# graphs hashes,
# The existing profile can be used only when
# * `v8_enable_builtins_optimization` - this switch enables builtins PGO,
# * `!v8_enable_builtins_profiling` - don't use the profiles when generating
# a new one,
# * `!is_debug && !dcheck_always_on` - these modes add more checks to
# the builtins control flow which makes the builtins code different,
# * `v8_enable_pointer_compression` - it changes the objects layouts,
# * `v8_enable_sandbox && v8_enable_external_code_space` because they affect
# the way how external pointer values are accessed,
# * `v8_enable_webassembly` because it changes the set of opcodes which
# affects graphs hashes.
if (v8_enable_builtins_optimization && !v8_enable_builtins_profiling &&
!is_debug && !dcheck_always_on && v8_enable_webassembly) {
# This is about function arguments evaluation order, which makes node IDs
# not predictable for subgraphs like Op1(Op2(), Op3()) and as a result
# different graph hashes.
# This is about function arguments evaluation order on the machine building
# mksnapshot, which makes node IDs not predictable for subgraphs like
# Op1(Op2(), Op3()) and as a result different graph hashes.
# Clang uses left-to-right order everywhere except Windows, otherwise the
# order is right-to-left.
# TODO(crbug.com/v8/13647): Remove once this issue is fixed in CSA.
if (!is_clang || is_win) {
if (!is_clang || host_os == "win") {
pgo_profile_suffix = "-rl"
} else {
pgo_profile_suffix = ""
@ -680,7 +684,7 @@ assert(!v8_enable_sandbox || v8_enable_external_code_space,
assert(!v8_enable_sandbox || !v8_enable_third_party_heap,
"The sandbox is incompatible with the third-party heap")
assert(!v8_expose_memory_corruption_api || v8_enable_sandbox,
assert(!v8_enable_memory_corruption_api || v8_enable_sandbox,
"The Memory Corruption API requires the sandbox")
assert(
@ -873,6 +877,7 @@ external_v8_defines = [
"V8_IS_TSAN",
"V8_ENABLE_CONSERVATIVE_STACK_SCANNING",
"V8_ENABLE_DIRECT_LOCAL",
"V8_MINORMS_STRING_SHORTCUTTING",
]
enabled_external_v8_defines = []
@ -1206,8 +1211,8 @@ config("features") {
if (v8_advanced_bigint_algorithms) {
defines += [ "V8_ADVANCED_BIGINT_ALGORITHMS" ]
}
if (v8_expose_memory_corruption_api) {
defines += [ "V8_EXPOSE_MEMORY_CORRUPTION_API" ]
if (v8_enable_memory_corruption_api) {
defines += [ "V8_ENABLE_MEMORY_CORRUPTION_API" ]
}
if (v8_enable_pointer_compression_8gb) {
defines += [ "V8_COMPRESS_POINTERS_8GB" ]
@ -1703,6 +1708,20 @@ config("toolchain") {
# Fix build with older versions of GCC
# Ported from v8 bazel: https://crrev.com/c/3368869
"-Wno-stringop-overflow",
# Fix a number of bogus errors with gcc12
# TODO(miladfarca): re-evaluate for future gcc upgrades
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111499
"-Wno-stringop-overread",
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104336
"-Wno-restrict",
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
"-Wno-array-bounds",
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108517
"-Wno-nonnull",
]
}
@ -1730,7 +1749,7 @@ config("always_turbofanimize") {
# TODO(crbug.com/621335) Rework this so that we don't have the confusion
# between "optimize_speed" and "optimize_max".
if (((is_posix && !is_android) || is_fuchsia) && !using_sanitizer) {
if (((is_posix && !is_android) || is_fuchsia || is_win) && !using_sanitizer) {
configs += [ "//build/config/compiler:optimize_speed" ]
} else {
configs += [ "//build/config/compiler:optimize_max" ]
@ -2729,6 +2748,7 @@ generated_file("v8_generate_features_json") {
v8_enable_31bit_smis_on_64bit_arch = v8_enable_31bit_smis_on_64bit_arch
v8_enable_conservative_stack_scanning =
v8_enable_conservative_stack_scanning
v8_enable_direct_handle = v8_enable_direct_handle
v8_enable_direct_local = v8_enable_direct_local
v8_enable_extensible_ro_snapshot = v8_enable_extensible_ro_snapshot
v8_enable_gdbjit = v8_enable_gdbjit
@ -2897,6 +2917,7 @@ v8_source_set("v8_initializers") {
"src/interpreter/interpreter-intrinsics-generator.h",
"src/numbers/integer-literal-inl.h",
"src/numbers/integer-literal.h",
"third_party/v8/codegen/fp16-inl.h",
]
if (v8_enable_webassembly) {
@ -3153,6 +3174,7 @@ v8_header_set("v8_flags") {
sources = [
"src/flags/flag-definitions.h",
"src/flags/flags-impl.h",
"src/flags/flags.h",
]
@ -3376,6 +3398,7 @@ v8_header_set("v8_internal_headers") {
"src/compiler/per-isolate-compiler-cache.h",
"src/compiler/persistent-map.h",
"src/compiler/phase.h",
"src/compiler/pipeline-data-inl.h",
"src/compiler/pipeline-statistics.h",
"src/compiler/pipeline.h",
"src/compiler/processed-feedback.h",
@ -3421,6 +3444,7 @@ v8_header_set("v8_internal_headers") {
"src/compiler/turboshaft/graph.h",
"src/compiler/turboshaft/index.h",
"src/compiler/turboshaft/instruction-selection-phase.h",
"src/compiler/turboshaft/js-generic-lowering-reducer.h",
"src/compiler/turboshaft/late-escape-analysis-reducer.h",
"src/compiler/turboshaft/late-load-elimination-reducer.h",
"src/compiler/turboshaft/layered-hash-map.h",
@ -3433,6 +3457,7 @@ v8_header_set("v8_internal_headers") {
"src/compiler/turboshaft/machine-lowering-phase.h",
"src/compiler/turboshaft/machine-lowering-reducer-inl.h",
"src/compiler/turboshaft/machine-optimization-reducer.h",
"src/compiler/turboshaft/maglev-early-lowering-reducer-inl.h",
"src/compiler/turboshaft/maglev-graph-building-phase.h",
"src/compiler/turboshaft/memory-optimization-reducer.h",
"src/compiler/turboshaft/operation-matcher.h",
@ -3572,7 +3597,6 @@ v8_header_set("v8_internal_headers") {
"src/heap/allocation-stats.h",
"src/heap/array-buffer-sweeper.h",
"src/heap/base-space.h",
"src/heap/basic-memory-chunk.h",
"src/heap/code-range.h",
"src/heap/code-stats.h",
"src/heap/collection-barrier.h",
@ -3642,9 +3666,8 @@ v8_header_set("v8_internal_headers") {
"src/heap/marking.h",
"src/heap/memory-allocator.h",
"src/heap/memory-balancer.h",
"src/heap/memory-chunk-header.h",
"src/heap/memory-chunk-inl.h",
"src/heap/memory-chunk-layout.h",
"src/heap/memory-chunk-metadata.h",
"src/heap/memory-chunk.h",
"src/heap/memory-measurement-inl.h",
"src/heap/memory-measurement.h",
@ -3652,6 +3675,8 @@ v8_header_set("v8_internal_headers") {
"src/heap/minor-gc-job.h",
"src/heap/minor-mark-sweep-inl.h",
"src/heap/minor-mark-sweep.h",
"src/heap/mutable-page-inl.h",
"src/heap/mutable-page.h",
"src/heap/new-spaces-inl.h",
"src/heap/new-spaces.h",
"src/heap/object-lock.h",
@ -4247,6 +4272,7 @@ v8_header_set("v8_internal_headers") {
"src/wasm/function-body-decoder-impl.h",
"src/wasm/function-body-decoder.h",
"src/wasm/function-compiler.h",
"src/wasm/fuzzing/random-module-generation.h",
"src/wasm/graph-builder-interface.h",
"src/wasm/inlining-tree.h",
"src/wasm/jump-table-assembler.h",
@ -4671,6 +4697,17 @@ v8_header_set("v8_internal_headers") {
"src/baseline/riscv/baseline-compiler-riscv-inl.h",
]
}
if (v8_enable_webassembly) {
# Trap handling is enabled on riscv64 Linux and in simulators on
# x64 on Linux.
if ((current_cpu == "riscv64" && is_linux) ||
(current_cpu == "x64" && is_linux)) {
sources += [ "src/trap-handler/handler-inside-posix.h" ]
}
if (current_cpu == "x64" && is_linux) {
sources += [ "src/trap-handler/trap-handler-simulator.h" ]
}
}
} else if (v8_current_cpu == "riscv32") {
sources += [
### gcmole(riscv32) ###
@ -5299,7 +5336,6 @@ v8_source_set("v8_base_without_compiler") {
"src/handles/traced-handles.cc",
"src/heap/allocation-observer.cc",
"src/heap/array-buffer-sweeper.cc",
"src/heap/basic-memory-chunk.cc",
"src/heap/code-range.cc",
"src/heap/code-stats.cc",
"src/heap/collection-barrier.cc",
@ -5341,13 +5377,14 @@ v8_source_set("v8_base_without_compiler") {
"src/heap/marking.cc",
"src/heap/memory-allocator.cc",
"src/heap/memory-balancer.cc",
"src/heap/memory-chunk-header.cc",
"src/heap/memory-chunk-layout.cc",
"src/heap/memory-chunk-metadata.cc",
"src/heap/memory-chunk.cc",
"src/heap/memory-measurement.cc",
"src/heap/memory-reducer.cc",
"src/heap/minor-gc-job.cc",
"src/heap/minor-mark-sweep.cc",
"src/heap/mutable-page.cc",
"src/heap/new-spaces.cc",
"src/heap/object-stats.cc",
"src/heap/objects-visiting.cc",
@ -5728,6 +5765,12 @@ v8_source_set("v8_base_without_compiler") {
"src/wasm/well-known-imports.cc",
"src/wasm/wrappers.cc",
]
if (!is_official_build) {
sources += [
### gcmole(all) ###
"src/wasm/fuzzing/random-module-generation.cc",
]
}
}
if (v8_enable_third_party_heap) {
@ -5978,6 +6021,20 @@ v8_source_set("v8_base_without_compiler") {
"src/execution/riscv/simulator-riscv.cc",
"src/regexp/riscv/regexp-macro-assembler-riscv.cc",
]
if (v8_enable_webassembly) {
# Trap handling is enabled on riscv64 Linux and in simulators on
# x64 on Linux.
if ((current_cpu == "riscv64" && is_linux) ||
(current_cpu == "x64" && is_linux)) {
sources += [
"src/trap-handler/handler-inside-posix.cc",
"src/trap-handler/handler-outside-posix.cc",
]
}
if (current_cpu == "x64" && is_linux) {
sources += [ "src/trap-handler/handler-outside-simulator.cc" ]
}
}
} else if (v8_current_cpu == "riscv32") {
sources += [
### gcmole(riscv32) ###
@ -6358,7 +6415,6 @@ v8_component("v8_libbase") {
"src/base/timezone-cache.h",
"src/base/utils/random-number-generator.cc",
"src/base/utils/random-number-generator.h",
"src/base/v8-fallthrough.h",
"src/base/vector.h",
"src/base/virtual-address-space-page-allocator.cc",
"src/base/virtual-address-space-page-allocator.h",
@ -7303,7 +7359,9 @@ group("v8_fuzzers") {
":v8_simple_wasm_async_fuzzer",
":v8_simple_wasm_code_fuzzer",
":v8_simple_wasm_compile_fuzzer",
":v8_simple_wasm_compile_simd_fuzzer",
":v8_simple_wasm_fuzzer",
":v8_simple_wasm_init_expr_fuzzer",
":v8_simple_wasm_streaming_fuzzer",
]
}
@ -7496,6 +7554,13 @@ v8_executable("v8_hello_world") {
":v8_libplatform",
"//build/win:default_exe_manifest",
]
# Need to workaround a link error when using devtoolset
# https://bugzilla.redhat.com/show_bug.cgi?id=2268188
if ((v8_current_cpu == "ppc64" || v8_current_cpu == "s390x") && is_linux &&
!is_clang) {
libs = [ "stdc++" ]
}
}
v8_executable("v8_sample_process") {
@ -7766,6 +7831,27 @@ if (v8_enable_webassembly) {
v8_fuzzer("wasm_compile_fuzzer") {
}
v8_source_set("wasm_compile_simd_fuzzer") {
sources = [
"test/common/wasm/test-signatures.h",
"test/fuzzer/wasm-compile-simd.cc",
]
deps = [
":fuzzer_support",
":lib_wasm_fuzzer_common",
":wasm_test_common",
]
configs = [
":external_config",
":internal_config_base",
]
}
v8_fuzzer("wasm_compile_simd_fuzzer") {
}
v8_source_set("wasm_streaming_fuzzer") {
sources = [ "test/fuzzer/wasm-streaming.cc" ]
@ -7783,6 +7869,24 @@ if (v8_enable_webassembly) {
v8_fuzzer("wasm_streaming_fuzzer") {
}
v8_source_set("wasm_init_expr_fuzzer") {
sources = [ "test/fuzzer/wasm-init-expr.cc" ]
deps = [
":fuzzer_support",
":lib_wasm_fuzzer_common",
":wasm_test_common",
]
configs = [
":external_config",
":internal_config_base",
]
}
v8_fuzzer("wasm_init_expr_fuzzer") {
}
}
v8_source_set("inspector_fuzzer") {