update all compiler build.gns

This commit is contained in:
Alexander Frick 2023-08-11 00:27:01 -05:00
parent aed36482ba
commit 9fed21dc57
7 changed files with 1024 additions and 312 deletions

View file

@ -184,6 +184,13 @@ declare_args() {
# Allow projects that wish to stay on C++17 to override Chromium's default.
# TODO(crbug.com/1402249): evaluate removing this end of 2023
use_cxx17 = false
# Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
# shadow call stack in register x18. Hence, x18 must not be used by the OS
# or libraries. We assume that to be the case for high end Android
# configurations. For more details see
# https://clang.llvm.org/docs/ShadowCallStack.html
enable_shadow_call_stack = false
}
declare_args() {
@ -215,7 +222,12 @@ if (is_android || (is_chromeos_ash && is_chromeos_device)) {
# another variable.
chrome_orderfile_path = default_chrome_orderfile
} else if (is_chromeos_ash && is_chromeos_device) {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
if (chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp") {
chrome_orderfile_path = "//chromeos/profiles/chromeos.arm.orderfile.txt"
} else {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
}
}
}
}
@ -263,6 +275,7 @@ config("compiler") {
cflags_cc = []
cflags_objc = []
cflags_objcc = []
rustflags = []
ldflags = []
defines = []
configs = []
@ -325,28 +338,44 @@ config("compiler") {
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
# Stack protection.
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# Stack protection. ShadowCallStack and Stack protector address the same
# problems. Therefore, we only enable one or the other. Clang advertises SCS as
# a stronger alternative to StackProtector, so we give SCS precedence over SP.
if (enable_shadow_call_stack) {
# On Aarch64, SCS requires the x18 register to be unused because it will hold
# a pointer to the shadow stack. For Android we know that Clang doesn't use
# x18 by default. On other OSs adding "-ffixed-x18" might be required.
assert(is_android)
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
scs_parameters = [
"-fsanitize=shadow-call-stack",
"-fno-stack-protector",
]
cflags += scs_parameters
ldflags += scs_parameters
} else {
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
}
}
}
@ -458,6 +487,7 @@ config("compiler") {
asmflags += [ "-fPIC" ]
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
rustflags += [ "-Crelocation-model=pic" ]
if (!is_clang) {
# Use pipes for communicating between sub-processes. Faster.
@ -749,6 +779,11 @@ config("compiler") {
# arm32.
if (!is_android || current_cpu == "arm64") {
cflags += [ "-fwhole-program-vtables" ]
# whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
# behaviour.
rustflags += [ "-Zsplit-lto-unit" ]
if (!is_win) {
ldflags += [ "-fwhole-program-vtables" ]
}
@ -865,6 +900,24 @@ config("compiler") {
}
}
if (clang_embed_bitcode) {
assert(!use_thin_lto,
"clang_embed_bitcode is only supported in non-ThinLTO builds")
cflags += [
"-Xclang",
"-fembed-bitcode=all",
]
}
if (lld_emit_indexes_and_imports) {
assert(use_thin_lto,
"lld_emit_indexes_and_imports is only supported with ThinLTO builds")
ldflags += [
"-Wl,--save-temps=import",
"-Wl,--thinlto-emit-index-files",
]
}
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
@ -877,9 +930,38 @@ config("compiler") {
asmflags += cflags_c
}
if (is_chromeos_device && !is_nacl) {
# On ChromeOS devices, we want to ensure we're using Chrome's allocator
# symbols for all C++ new/delete operator overloads. PartitionAlloc
# and other local allocators should always take precedence over system or
# preloaded allocators. These are the mangled symbol names.
# See b/280115910 for details.
ldflags += [
"-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
"-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
"-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
"-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
"-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
"-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
]
}
# Rust compiler flags setup.
# ---------------------------
rustflags = [
rustflags += [
# Overflow checks are optional in Rust, but even if switched
# off they do not cause undefined behavior (the overflowing
# behavior is defined). Because containers are bounds-checked
@ -917,6 +999,13 @@ config("compiler") {
# Full RUSTC optimizations.
"-Copt-level=3", "-Ctarget-feature=+aes,+avx,-pclmul",
]
if (!is_win || force_rustc_color_output) {
# Colorize error output. The analogous flag is passed for clang. This must
# be platform-gated since rustc will unconditionally output ANSI escape
# sequences, ignoring the platform, when stderr is not a terminal.
rustflags += [ "--color=always" ]
}
if (rust_abi_target != "") {
rustflags += [ "--target=$rust_abi_target" ]
}
@ -927,20 +1016,15 @@ config("compiler") {
if (is_official_build) {
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", ]
}
}
# Defers LTO optimization to the linker, for use when:
# * Having the C++ toolchain do the linking against Rust staticlibs, and it
# will be using LTO.
# * Having Rust toolchain invoke the linker, and you're linking Rust and C++
# together, so this defers LTO to the linker.
#
# Otherwise, Rust does LTO during compilation.
#
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html
config("rust_defer_lto_to_linker") {
if (!is_debug && use_thin_lto && is_a_target_toolchain) {
rustflags = [ "-Clinker-plugin-lto", "-Copt-level=3", ]
if (!rust_prebuilt_stdlib) {
# When building against the Chromium Rust stdlib (which we compile) always
# abort instead of unwinding when panic occurs. In official builds, panics
# abort immediately (this is configured in the stdlib) to keep binary size
# down. So we unconditionally match behaviour in unofficial too.
rustflags += [
"-Cpanic=abort",
"-Zpanic_abort_tests",
]
}
}
@ -960,6 +1044,9 @@ config("thinlto_optimize_default") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -990,6 +1077,9 @@ config("thinlto_optimize_max") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -1308,7 +1398,7 @@ config("compiler_cpu_abi") {
ldflags += [ "-m64" ]
}
} else if (current_cpu == "riscv64") {
if (is_clang) {
if (is_clang && !is_android) {
cflags += [ "--target=riscv64-linux-gnu" ]
ldflags += [ "--target=riscv64-linux-gnu" ]
}
@ -2102,6 +2192,7 @@ if (is_win) {
"-mllvm:-polly",
"-mllvm:-polly-detect-profitability-min-per-loop-insts=40",
"-mllvm:-polly-invariant-load-hoisting",
"-mllvm:-polly-run-dce",
"-mllvm:-polly-vectorizer=stripmine",
]
}
@ -2117,7 +2208,6 @@ if (is_win) {
# TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
}
} else {
common_optimize_on_cflags = []
common_optimize_on_ldflags = []
@ -2134,6 +2224,7 @@ if (is_win) {
"-Wl,-mllvm,-polly",
"-Wl,-mllvm,-polly-detect-profitability-min-per-loop-insts=40",
"-Wl,-mllvm,-polly-invariant-load-hoisting",
"-Wl,-mllvm,-polly-run-dce",
"-Wl,-mllvm,-polly-vectorizer=stripmine",
]
}
@ -2639,10 +2730,18 @@ config("symbols") {
# This config guarantees to hold symbol for stack trace which are shown to user
# when crash happens in unittests running on buildbot.
config("minimal_symbols") {
rustflags = []
if (is_win) {
# Functions, files, and line tables only.
cflags = []
if (is_clang) {
cflags += [
# Disable putting the compiler command line into the debug info to
# prevent some types of non-determinism.
"-gno-codeview-command-line",
]
}
if (is_clang && use_lld && use_ghash) {
cflags += [ "-gcodeview-ghash" ]
ldflags = [ "/DEBUG:GHASH" ]
@ -2666,15 +2765,18 @@ config("minimal_symbols") {
# at least 10.11.
# TODO(thakis): Remove this once mac_deployment_target is 10.11.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
} else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
# On aix -gdwarf causes linker failures due to thread_local variables.
# Recent clang versions default to DWARF5 on Linux, and Android is about
# to switch. TODO: Adopt that in controlled way.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
}
if (use_dwarf5 && !is_nacl) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
}
# The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
@ -2706,7 +2808,7 @@ config("minimal_symbols") {
asmflags = cflags
}
rustflags = [ "-Cdebuginfo=1", "-Copt-level=3", ]
rustflags += [ "-Cdebuginfo=1", "-Copt-level=3", ]
}
# This configuration contains function names only. That is, the compiler is

View file

@ -184,6 +184,13 @@ declare_args() {
# Allow projects that wish to stay on C++17 to override Chromium's default.
# TODO(crbug.com/1402249): evaluate removing this end of 2023
use_cxx17 = false
# Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
# shadow call stack in register x18. Hence, x18 must not be used by the OS
# or libraries. We assume that to be the case for high end Android
# configurations. For more details see
# https://clang.llvm.org/docs/ShadowCallStack.html
enable_shadow_call_stack = false
}
declare_args() {
@ -215,7 +222,12 @@ if (is_android || (is_chromeos_ash && is_chromeos_device)) {
# another variable.
chrome_orderfile_path = default_chrome_orderfile
} else if (is_chromeos_ash && is_chromeos_device) {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
if (chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp") {
chrome_orderfile_path = "//chromeos/profiles/chromeos.arm.orderfile.txt"
} else {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
}
}
}
}
@ -263,6 +275,7 @@ config("compiler") {
cflags_cc = []
cflags_objc = []
cflags_objcc = []
rustflags = []
ldflags = []
defines = []
configs = []
@ -325,28 +338,44 @@ config("compiler") {
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
# Stack protection.
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# Stack protection. ShadowCallStack and Stack protector address the same
# problems. Therefore, we only enable one or the other. Clang advertises SCS as
# a stronger alternative to StackProtector, so we give SCS precedence over SP.
if (enable_shadow_call_stack) {
# On Aarch64, SCS requires the x18 register to be unused because it will hold
# a pointer to the shadow stack. For Android we know that Clang doesn't use
# x18 by default. On other OSs adding "-ffixed-x18" might be required.
assert(is_android)
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
scs_parameters = [
"-fsanitize=shadow-call-stack",
"-fno-stack-protector",
]
cflags += scs_parameters
ldflags += scs_parameters
} else {
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
}
}
}
@ -458,6 +487,7 @@ config("compiler") {
asmflags += [ "-fPIC" ]
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
rustflags += [ "-Crelocation-model=pic" ]
if (!is_clang) {
# Use pipes for communicating between sub-processes. Faster.
@ -575,9 +605,9 @@ config("compiler") {
# TODO(crbug.com/1235145): Investigate why/if this should be needed.
if (is_win) {
cflags += [ "/clang:-ffp-contract=off" ]
cflags += [ "/clang:-ffp-contract=fast" ]
} else {
cflags += [ "-ffp-contract=off" ]
cflags += [ "-ffp-contract=fast" ]
}
}
@ -749,6 +779,11 @@ config("compiler") {
# arm32.
if (!is_android || current_cpu == "arm64") {
cflags += [ "-fwhole-program-vtables" ]
# whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
# behaviour.
rustflags += [ "-Zsplit-lto-unit" ]
if (!is_win) {
ldflags += [ "-fwhole-program-vtables" ]
}
@ -856,6 +891,24 @@ config("compiler") {
}
}
if (clang_embed_bitcode) {
assert(!use_thin_lto,
"clang_embed_bitcode is only supported in non-ThinLTO builds")
cflags += [
"-Xclang",
"-fembed-bitcode=all",
]
}
if (lld_emit_indexes_and_imports) {
assert(use_thin_lto,
"lld_emit_indexes_and_imports is only supported with ThinLTO builds")
ldflags += [
"-Wl,--save-temps=import",
"-Wl,--thinlto-emit-index-files",
]
}
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
@ -868,9 +921,38 @@ config("compiler") {
asmflags += cflags_c
}
if (is_chromeos_device && !is_nacl) {
# On ChromeOS devices, we want to ensure we're using Chrome's allocator
# symbols for all C++ new/delete operator overloads. PartitionAlloc
# and other local allocators should always take precedence over system or
# preloaded allocators. These are the mangled symbol names.
# See b/280115910 for details.
ldflags += [
"-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
"-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
"-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
"-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
"-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
"-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
]
}
# Rust compiler flags setup.
# ---------------------------
rustflags = [
rustflags += [
# Overflow checks are optional in Rust, but even if switched
# off they do not cause undefined behavior (the overflowing
# behavior is defined). Because containers are bounds-checked
@ -908,6 +990,13 @@ config("compiler") {
# Full RUSTC optimizations.
"-Copt-level=3", "-Ctarget-feature=+aes,+avx,-pclmul",
]
if (!is_win || force_rustc_color_output) {
# Colorize error output. The analogous flag is passed for clang. This must
# be platform-gated since rustc will unconditionally output ANSI escape
# sequences, ignoring the platform, when stderr is not a terminal.
rustflags += [ "--color=always" ]
}
if (rust_abi_target != "") {
rustflags += [ "--target=$rust_abi_target" ]
}
@ -918,20 +1007,15 @@ config("compiler") {
if (is_official_build) {
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", ]
}
}
# Defers LTO optimization to the linker, for use when:
# * Having the C++ toolchain do the linking against Rust staticlibs, and it
# will be using LTO.
# * Having Rust toolchain invoke the linker, and you're linking Rust and C++
# together, so this defers LTO to the linker.
#
# Otherwise, Rust does LTO during compilation.
#
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html
config("rust_defer_lto_to_linker") {
if (!is_debug && use_thin_lto && is_a_target_toolchain) {
rustflags = [ "-Clinker-plugin-lto" ]
if (!rust_prebuilt_stdlib) {
# When building against the Chromium Rust stdlib (which we compile) always
# abort instead of unwinding when panic occurs. In official builds, panics
# abort immediately (this is configured in the stdlib) to keep binary size
# down. So we unconditionally match behaviour in unofficial too.
rustflags += [
"-Cpanic=abort",
"-Zpanic_abort_tests",
]
}
}
@ -951,6 +1035,9 @@ config("thinlto_optimize_default") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -981,6 +1068,9 @@ config("thinlto_optimize_max") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -1283,7 +1373,7 @@ config("compiler_cpu_abi") {
ldflags += [ "-m64" ]
}
} else if (current_cpu == "riscv64") {
if (is_clang) {
if (is_clang && !is_android) {
cflags += [ "--target=riscv64-linux-gnu" ]
ldflags += [ "--target=riscv64-linux-gnu" ]
}
@ -2579,10 +2669,18 @@ config("symbols") {
# This config guarantees to hold symbol for stack trace which are shown to user
# when crash happens in unittests running on buildbot.
config("minimal_symbols") {
rustflags = []
if (is_win) {
# Functions, files, and line tables only.
cflags = []
if (is_clang) {
cflags += [
# Disable putting the compiler command line into the debug info to
# prevent some types of non-determinism.
"-gno-codeview-command-line",
]
}
if (is_clang && use_lld && use_ghash) {
cflags += [ "-gcodeview-ghash" ]
ldflags = [ "/DEBUG:GHASH" ]
@ -2606,15 +2704,18 @@ config("minimal_symbols") {
# at least 10.11.
# TODO(thakis): Remove this once mac_deployment_target is 10.11.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
} else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
# On aix -gdwarf causes linker failures due to thread_local variables.
# Recent clang versions default to DWARF5 on Linux, and Android is about
# to switch. TODO: Adopt that in controlled way.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
}
if (use_dwarf5 && !is_nacl) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
}
# The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
@ -2646,7 +2747,7 @@ config("minimal_symbols") {
asmflags = cflags
}
rustflags = [ "-Cdebuginfo=1" ]
rustflags += [ "-Cdebuginfo=1" ]
}
# This configuration contains function names only. That is, the compiler is

View file

@ -184,6 +184,13 @@ declare_args() {
# Allow projects that wish to stay on C++17 to override Chromium's default.
# TODO(crbug.com/1402249): evaluate removing this end of 2023
use_cxx17 = false
# Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
# shadow call stack in register x18. Hence, x18 must not be used by the OS
# or libraries. We assume that to be the case for high end Android
# configurations. For more details see
# https://clang.llvm.org/docs/ShadowCallStack.html
enable_shadow_call_stack = false
}
declare_args() {
@ -215,7 +222,12 @@ if (is_android || (is_chromeos_ash && is_chromeos_device)) {
# another variable.
chrome_orderfile_path = default_chrome_orderfile
} else if (is_chromeos_ash && is_chromeos_device) {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
if (chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp") {
chrome_orderfile_path = "//chromeos/profiles/chromeos.arm.orderfile.txt"
} else {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
}
}
}
}
@ -263,6 +275,7 @@ config("compiler") {
cflags_cc = []
cflags_objc = []
cflags_objcc = []
rustflags = []
ldflags = []
defines = []
configs = []
@ -325,28 +338,44 @@ config("compiler") {
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
# Stack protection.
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# Stack protection. ShadowCallStack and Stack protector address the same
# problems. Therefore, we only enable one or the other. Clang advertises SCS as
# a stronger alternative to StackProtector, so we give SCS precedence over SP.
if (enable_shadow_call_stack) {
# On Aarch64, SCS requires the x18 register to be unused because it will hold
# a pointer to the shadow stack. For Android we know that Clang doesn't use
# x18 by default. On other OSs adding "-ffixed-x18" might be required.
assert(is_android)
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
scs_parameters = [
"-fsanitize=shadow-call-stack",
"-fno-stack-protector",
]
cflags += scs_parameters
ldflags += scs_parameters
} else {
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
}
}
}
@ -458,6 +487,7 @@ config("compiler") {
asmflags += [ "-fPIC" ]
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
rustflags += [ "-Crelocation-model=pic" ]
if (!is_clang) {
# Use pipes for communicating between sub-processes. Faster.
@ -749,6 +779,11 @@ config("compiler") {
# arm32.
if (!is_android || current_cpu == "arm64") {
cflags += [ "-fwhole-program-vtables" ]
# whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
# behaviour.
rustflags += [ "-Zsplit-lto-unit" ]
if (!is_win) {
ldflags += [ "-fwhole-program-vtables" ]
}
@ -856,6 +891,24 @@ config("compiler") {
}
}
if (clang_embed_bitcode) {
assert(!use_thin_lto,
"clang_embed_bitcode is only supported in non-ThinLTO builds")
cflags += [
"-Xclang",
"-fembed-bitcode=all",
]
}
if (lld_emit_indexes_and_imports) {
assert(use_thin_lto,
"lld_emit_indexes_and_imports is only supported with ThinLTO builds")
ldflags += [
"-Wl,--save-temps=import",
"-Wl,--thinlto-emit-index-files",
]
}
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
@ -868,9 +921,38 @@ config("compiler") {
asmflags += cflags_c
}
if (is_chromeos_device && !is_nacl) {
# On ChromeOS devices, we want to ensure we're using Chrome's allocator
# symbols for all C++ new/delete operator overloads. PartitionAlloc
# and other local allocators should always take precedence over system or
# preloaded allocators. These are the mangled symbol names.
# See b/280115910 for details.
ldflags += [
"-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
"-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
"-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
"-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
"-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
"-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
]
}
# Rust compiler flags setup.
# ---------------------------
rustflags = [
rustflags += [
# Overflow checks are optional in Rust, but even if switched
# off they do not cause undefined behavior (the overflowing
# behavior is defined). Because containers are bounds-checked
@ -908,6 +990,13 @@ config("compiler") {
# Full RUSTC optimizations.
"-Copt-level=3", "-Ctune-cpu=haswell", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul",
]
if (!is_win || force_rustc_color_output) {
# Colorize error output. The analogous flag is passed for clang. This must
# be platform-gated since rustc will unconditionally output ANSI escape
# sequences, ignoring the platform, when stderr is not a terminal.
rustflags += [ "--color=always" ]
}
if (rust_abi_target != "") {
rustflags += [ "--target=$rust_abi_target" ]
}
@ -918,20 +1007,15 @@ config("compiler") {
if (is_official_build) {
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
}
}
# Defers LTO optimization to the linker, for use when:
# * Having the C++ toolchain do the linking against Rust staticlibs, and it
# will be using LTO.
# * Having Rust toolchain invoke the linker, and you're linking Rust and C++
# together, so this defers LTO to the linker.
#
# Otherwise, Rust does LTO during compilation.
#
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html
config("rust_defer_lto_to_linker") {
if (!is_debug && use_thin_lto && is_a_target_toolchain) {
rustflags = [ "-Clinker-plugin-lto", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
if (!rust_prebuilt_stdlib) {
# When building against the Chromium Rust stdlib (which we compile) always
# abort instead of unwinding when panic occurs. In official builds, panics
# abort immediately (this is configured in the stdlib) to keep binary size
# down. So we unconditionally match behaviour in unofficial too.
rustflags += [
"-Cpanic=abort",
"-Zpanic_abort_tests",
]
}
}
@ -951,6 +1035,9 @@ config("thinlto_optimize_default") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -981,6 +1068,9 @@ config("thinlto_optimize_max") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -1300,7 +1390,7 @@ config("compiler_cpu_abi") {
ldflags += [ "-m64" ]
}
} else if (current_cpu == "riscv64") {
if (is_clang) {
if (is_clang && !is_android) {
cflags += [ "--target=riscv64-linux-gnu" ]
ldflags += [ "--target=riscv64-linux-gnu" ]
}
@ -2144,7 +2234,6 @@ if (is_win) {
# TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
}
} else {
common_optimize_on_cflags = []
common_optimize_on_ldflags = []
@ -2699,10 +2788,18 @@ config("symbols") {
# This config guarantees to hold symbol for stack trace which are shown to user
# when crash happens in unittests running on buildbot.
config("minimal_symbols") {
rustflags = []
if (is_win) {
# Functions, files, and line tables only.
cflags = []
if (is_clang) {
cflags += [
# Disable putting the compiler command line into the debug info to
# prevent some types of non-determinism.
"-gno-codeview-command-line",
]
}
if (is_clang && use_lld && use_ghash) {
cflags += [ "-gcodeview-ghash" ]
ldflags = [ "/DEBUG:GHASH" ]
@ -2726,15 +2823,18 @@ config("minimal_symbols") {
# at least 10.11.
# TODO(thakis): Remove this once mac_deployment_target is 10.11.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
} else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
# On aix -gdwarf causes linker failures due to thread_local variables.
# Recent clang versions default to DWARF5 on Linux, and Android is about
# to switch. TODO: Adopt that in controlled way.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
}
if (use_dwarf5 && !is_nacl) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
}
# The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
@ -2766,7 +2866,7 @@ config("minimal_symbols") {
asmflags = cflags
}
rustflags = [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
rustflags += [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ]
}
# This configuration contains function names only. That is, the compiler is

View file

@ -184,6 +184,13 @@ declare_args() {
# Allow projects that wish to stay on C++17 to override Chromium's default.
# TODO(crbug.com/1402249): evaluate removing this end of 2023
use_cxx17 = false
# Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
# shadow call stack in register x18. Hence, x18 must not be used by the OS
# or libraries. We assume that to be the case for high end Android
# configurations. For more details see
# https://clang.llvm.org/docs/ShadowCallStack.html
enable_shadow_call_stack = false
}
declare_args() {
@ -215,7 +222,12 @@ if (is_android || (is_chromeos_ash && is_chromeos_device)) {
# another variable.
chrome_orderfile_path = default_chrome_orderfile
} else if (is_chromeos_ash && is_chromeos_device) {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
if (chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp") {
chrome_orderfile_path = "//chromeos/profiles/chromeos.arm.orderfile.txt"
} else {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
}
}
}
}
@ -263,6 +275,7 @@ config("compiler") {
cflags_cc = []
cflags_objc = []
cflags_objcc = []
rustflags = []
ldflags = []
defines = []
configs = []
@ -325,28 +338,44 @@ config("compiler") {
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
# Stack protection.
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# Stack protection. ShadowCallStack and Stack protector address the same
# problems. Therefore, we only enable one or the other. Clang advertises SCS as
# a stronger alternative to StackProtector, so we give SCS precedence over SP.
if (enable_shadow_call_stack) {
# On Aarch64, SCS requires the x18 register to be unused because it will hold
# a pointer to the shadow stack. For Android we know that Clang doesn't use
# x18 by default. On other OSs adding "-ffixed-x18" might be required.
assert(is_android)
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
scs_parameters = [
"-fsanitize=shadow-call-stack",
"-fno-stack-protector",
]
cflags += scs_parameters
ldflags += scs_parameters
} else {
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
}
}
}
@ -458,6 +487,7 @@ config("compiler") {
asmflags += [ "-fPIC" ]
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
rustflags += [ "-Crelocation-model=pic" ]
if (!is_clang) {
# Use pipes for communicating between sub-processes. Faster.
@ -749,6 +779,11 @@ config("compiler") {
# arm32.
if (!is_android || current_cpu == "arm64") {
cflags += [ "-fwhole-program-vtables" ]
# whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
# behaviour.
rustflags += [ "-Zsplit-lto-unit" ]
if (!is_win) {
ldflags += [ "-fwhole-program-vtables" ]
}
@ -856,6 +891,24 @@ config("compiler") {
}
}
if (clang_embed_bitcode) {
assert(!use_thin_lto,
"clang_embed_bitcode is only supported in non-ThinLTO builds")
cflags += [
"-Xclang",
"-fembed-bitcode=all",
]
}
if (lld_emit_indexes_and_imports) {
assert(use_thin_lto,
"lld_emit_indexes_and_imports is only supported with ThinLTO builds")
ldflags += [
"-Wl,--save-temps=import",
"-Wl,--thinlto-emit-index-files",
]
}
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
@ -868,9 +921,38 @@ config("compiler") {
asmflags += cflags_c
}
if (is_chromeos_device && !is_nacl) {
# On ChromeOS devices, we want to ensure we're using Chrome's allocator
# symbols for all C++ new/delete operator overloads. PartitionAlloc
# and other local allocators should always take precedence over system or
# preloaded allocators. These are the mangled symbol names.
# See b/280115910 for details.
ldflags += [
"-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
"-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
"-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
"-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
"-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
"-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
]
}
# Rust compiler flags setup.
# ---------------------------
rustflags = [
rustflags += [
# Overflow checks are optional in Rust, but even if switched
# off they do not cause undefined behavior (the overflowing
# behavior is defined). Because containers are bounds-checked
@ -908,6 +990,13 @@ config("compiler") {
# Full RUSTC optimizations.
"-Copt-level=3", "-Ctarget-feature=+sse4.1",
]
if (!is_win || force_rustc_color_output) {
# Colorize error output. The analogous flag is passed for clang. This must
# be platform-gated since rustc will unconditionally output ANSI escape
# sequences, ignoring the platform, when stderr is not a terminal.
rustflags += [ "--color=always" ]
}
if (rust_abi_target != "") {
rustflags += [ "--target=$rust_abi_target" ]
}
@ -918,20 +1007,15 @@ config("compiler") {
if (is_official_build) {
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", "-Ctarget-feature=+sse4.1", ]
}
}
# Defers LTO optimization to the linker, for use when:
# * Having the C++ toolchain do the linking against Rust staticlibs, and it
# will be using LTO.
# * Having Rust toolchain invoke the linker, and you're linking Rust and C++
# together, so this defers LTO to the linker.
#
# Otherwise, Rust does LTO during compilation.
#
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html
config("rust_defer_lto_to_linker") {
if (!is_debug && use_thin_lto && is_a_target_toolchain) {
rustflags = [ "-Clinker-plugin-lto", "-Copt-level=3", "-Ctarget-feature=+sse4.1", ]
if (!rust_prebuilt_stdlib) {
# When building against the Chromium Rust stdlib (which we compile) always
# abort instead of unwinding when panic occurs. In official builds, panics
# abort immediately (this is configured in the stdlib) to keep binary size
# down. So we unconditionally match behaviour in unofficial too.
rustflags += [
"-Cpanic=abort",
"-Zpanic_abort_tests",
]
}
}
@ -951,6 +1035,9 @@ config("thinlto_optimize_default") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -981,6 +1068,9 @@ config("thinlto_optimize_max") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -1297,7 +1387,7 @@ config("compiler_cpu_abi") {
ldflags += [ "-m64" ]
}
} else if (current_cpu == "riscv64") {
if (is_clang) {
if (is_clang && !is_android) {
cflags += [ "--target=riscv64-linux-gnu" ]
ldflags += [ "--target=riscv64-linux-gnu" ]
}
@ -2139,11 +2229,11 @@ if (is_win) {
# TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
}
} else {
common_optimize_on_cflags = []
common_optimize_on_ldflags = []
common_optimize_on_cflags += [
"-freroll-loops",
"-mllvm", "-enable-gvn-hoist",
"-O3",
]
@ -2665,10 +2755,18 @@ config("symbols") {
# This config guarantees to hold symbol for stack trace which are shown to user
# when crash happens in unittests running on buildbot.
config("minimal_symbols") {
rustflags = []
if (is_win) {
# Functions, files, and line tables only.
cflags = []
if (is_clang) {
cflags += [
# Disable putting the compiler command line into the debug info to
# prevent some types of non-determinism.
"-gno-codeview-command-line",
]
}
if (is_clang && use_lld && use_ghash) {
cflags += [ "-gcodeview-ghash" ]
ldflags = [ "/DEBUG:GHASH" ]
@ -2692,15 +2790,18 @@ config("minimal_symbols") {
# at least 10.11.
# TODO(thakis): Remove this once mac_deployment_target is 10.11.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
} else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
# On aix -gdwarf causes linker failures due to thread_local variables.
# Recent clang versions default to DWARF5 on Linux, and Android is about
# to switch. TODO: Adopt that in controlled way.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
}
if (use_dwarf5 && !is_nacl) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
}
# The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
@ -2732,7 +2833,7 @@ config("minimal_symbols") {
asmflags = cflags
}
rustflags = [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+sse4.1", ]
rustflags += [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+sse4.1", ]
}
# This configuration contains function names only. That is, the compiler is

View file

@ -184,6 +184,13 @@ declare_args() {
# Allow projects that wish to stay on C++17 to override Chromium's default.
# TODO(crbug.com/1402249): evaluate removing this end of 2023
use_cxx17 = false
# Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
# shadow call stack in register x18. Hence, x18 must not be used by the OS
# or libraries. We assume that to be the case for high end Android
# configurations. For more details see
# https://clang.llvm.org/docs/ShadowCallStack.html
enable_shadow_call_stack = false
}
declare_args() {
@ -215,7 +222,12 @@ if (is_android || (is_chromeos_ash && is_chromeos_device)) {
# another variable.
chrome_orderfile_path = default_chrome_orderfile
} else if (is_chromeos_ash && is_chromeos_device) {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
if (chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp") {
chrome_orderfile_path = "//chromeos/profiles/chromeos.arm.orderfile.txt"
} else {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
}
}
}
}
@ -263,6 +275,7 @@ config("compiler") {
cflags_cc = []
cflags_objc = []
cflags_objcc = []
rustflags = []
ldflags = []
defines = []
configs = []
@ -325,28 +338,44 @@ config("compiler") {
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
# Stack protection.
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# Stack protection. ShadowCallStack and Stack protector address the same
# problems. Therefore, we only enable one or the other. Clang advertises SCS as
# a stronger alternative to StackProtector, so we give SCS precedence over SP.
if (enable_shadow_call_stack) {
# On Aarch64, SCS requires the x18 register to be unused because it will hold
# a pointer to the shadow stack. For Android we know that Clang doesn't use
# x18 by default. On other OSs adding "-ffixed-x18" might be required.
assert(is_android)
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
scs_parameters = [
"-fsanitize=shadow-call-stack",
"-fno-stack-protector",
]
cflags += scs_parameters
ldflags += scs_parameters
} else {
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
}
}
}
@ -458,6 +487,7 @@ config("compiler") {
asmflags += [ "-fPIC" ]
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
rustflags += [ "-Crelocation-model=pic" ]
if (!is_clang) {
# Use pipes for communicating between sub-processes. Faster.
@ -581,11 +611,6 @@ config("compiler") {
}
}
# Rust compiler setup (for either clang or rustc).
if (enable_rust) {
defines += [ "RUST_ENABLED" ]
}
# C11/C++11 compiler flags setup.
# ---------------------------
if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) ||
@ -715,14 +740,10 @@ config("compiler") {
# of "all" which means number of hardware threads) is faster.
ldflags += [ "-Wl,--thinlto-jobs=all" ]
if (is_apple) {
_object_path_suffix = ""
if (is_ios) {
_object_path_suffix = ",persist"
}
ldflags += [
"-Wl,-cache_path_lto," +
rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
"-Wcrl,object_path_lto" + _object_path_suffix,
"-Wcrl,object_path_lto",
]
} else {
ldflags +=
@ -735,9 +756,8 @@ config("compiler") {
# ARM was originally set lower than x86 to keep the size
# bloat of ThinLTO to <10%, but that's potentially no longer true.
# FIXME(inglorion): maybe tune these?
if (target_cpu == "arm" || target_cpu == "arm64") {
import_instr_limit = 30
}
# TODO(b/271459198): Revert limit on amd64 to 30 when fixed.
import_instr_limit = 30
} else if (is_android) {
# 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.
@ -759,6 +779,11 @@ config("compiler") {
# arm32.
if (!is_android || current_cpu == "arm64") {
cflags += [ "-fwhole-program-vtables" ]
# whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
# behaviour.
rustflags += [ "-Zsplit-lto-unit" ]
if (!is_win) {
ldflags += [ "-fwhole-program-vtables" ]
}
@ -866,6 +891,24 @@ config("compiler") {
}
}
if (clang_embed_bitcode) {
assert(!use_thin_lto,
"clang_embed_bitcode is only supported in non-ThinLTO builds")
cflags += [
"-Xclang",
"-fembed-bitcode=all",
]
}
if (lld_emit_indexes_and_imports) {
assert(use_thin_lto,
"lld_emit_indexes_and_imports is only supported with ThinLTO builds")
ldflags += [
"-Wl,--save-temps=import",
"-Wl,--thinlto-emit-index-files",
]
}
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
@ -878,9 +921,38 @@ config("compiler") {
asmflags += cflags_c
}
if (is_chromeos_device && !is_nacl) {
# On ChromeOS devices, we want to ensure we're using Chrome's allocator
# symbols for all C++ new/delete operator overloads. PartitionAlloc
# and other local allocators should always take precedence over system or
# preloaded allocators. These are the mangled symbol names.
# See b/280115910 for details.
ldflags += [
"-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
"-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
"-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
"-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
"-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
"-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
]
}
# Rust compiler flags setup.
# ---------------------------
rustflags = [
rustflags += [
# Overflow checks are optional in Rust, but even if switched
# off they do not cause undefined behavior (the overflowing
# behavior is defined). Because containers are bounds-checked
@ -899,9 +971,10 @@ config("compiler") {
# to compile dylibs on Android, such as for constructing unit test APKs.
"-Cdefault-linker-libraries",
# Turn warnings into the "deny" lint level, which produce compiler errors.
# The equivalent of -Werror for clang/gcc.
"-Dwarnings",
# Require `unsafe` blocks even in `unsafe` fns. This is intended to become
# an error by default eventually; see
# https://github.com/rust-lang/rust/issues/71668
"-Dunsafe_op_in_unsafe_fn",
# To make Rust .d files compatible with ninja
"-Zdep-info-omit-d-target",
@ -917,34 +990,32 @@ config("compiler") {
# Full RUSTC optimizations.
"-Copt-level=3", "-Ctarget-feature=+sse2",
]
if (!is_win || force_rustc_color_output) {
# Colorize error output. The analogous flag is passed for clang. This must
# be platform-gated since rustc will unconditionally output ANSI escape
# sequences, ignoring the platform, when stderr is not a terminal.
rustflags += [ "--color=always" ]
}
if (rust_abi_target != "") {
rustflags += [ "--target=$rust_abi_target" ]
}
if (!use_thin_lto || !use_chromium_rust_toolchain) {
# Don't include bitcode if it won't be used, or can't be used. When
# use_thin_lto is true, we will try to apply LTO to any objects that have
# the appropriate bitcode. But we have to use Chromium's toolchain in order
# to use LTO with rust code. Chromium's rustc will have an LLVM backend that
# matches the C++ clang compiler.
if (!use_thin_lto) {
# Don't include bitcode if it won't be used.
rustflags += [ "-Cembed-bitcode=no" ]
}
if (is_official_build) {
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", "-Ctarget-feature=+sse2", ]
}
}
# Defers LTO optimization to the linker, for use when:
# * Having the C++ toolchain do the linking against Rust staticlibs, and it
# will be using LTO.
# * Having Rust toolchain invoke the linker, and you're linking Rust and C++
# together, so this defers LTO to the linker.
#
# Otherwise, Rust does LTO during compilation.
#
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html
config("rust_defer_lto_to_linker") {
if (!is_debug && use_thin_lto && is_a_target_toolchain) {
rustflags = [ "-Clinker-plugin-lto", "-Copt-level=3", "-Ctarget-feature=+sse2", ]
if (!rust_prebuilt_stdlib) {
# When building against the Chromium Rust stdlib (which we compile) always
# abort instead of unwinding when panic occurs. In official builds, panics
# abort immediately (this is configured in the stdlib) to keep binary size
# down. So we unconditionally match behaviour in unofficial too.
rustflags += [
"-Cpanic=abort",
"-Zpanic_abort_tests",
]
}
}
@ -964,6 +1035,9 @@ config("thinlto_optimize_default") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -994,6 +1068,9 @@ config("thinlto_optimize_max") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -1310,7 +1387,7 @@ config("compiler_cpu_abi") {
ldflags += [ "-m64" ]
}
} else if (current_cpu == "riscv64") {
if (is_clang) {
if (is_clang && !is_android) {
cflags += [ "--target=riscv64-linux-gnu" ]
ldflags += [ "--target=riscv64-linux-gnu" ]
}
@ -1345,7 +1422,7 @@ config("compiler_codegen") {
configs += [ "//build/config/nacl:compiler_codegen" ]
}
if (current_cpu == "arm64" && !is_win) {
if (current_cpu == "arm64" && !is_win && is_clang) {
# Disable outlining everywhere on arm64 except Win. For more information see
# crbug.com/931297 for Android and crbug.com/1410297 for iOS.
# TODO(crbug.com/1411363): Enable this on Windows if possible.
@ -1774,6 +1851,15 @@ config("chromium_code") {
cflags += [ "-Wextra" ]
}
if (treat_warnings_as_errors) {
# Turn rustc warnings into the "deny" lint level, which produce compiler
# errors. The equivalent of -Werror for clang/gcc.
#
# Note we apply the actual lint flags in config("compiler"). All warnings
# are suppressed in third-party crates.
rustflags = [ "-Dwarnings" ]
}
# In Chromium code, we define __STDC_foo_MACROS in order to get the
# C99 macros on Mac and Linux.
defines = [
@ -1813,8 +1899,8 @@ config("chromium_code") {
]
# TODO(thakis): Enable this more often, https://crbug.com/346399
# use_libfuzzer: https://crbug.com/1063180
if ((!is_nacl || is_nacl_saigo) && !use_libfuzzer) {
# use_fuzzing_engine_with_lpm: https://crbug.com/1063180
if ((!is_nacl || is_nacl_saigo) && !use_fuzzing_engine_with_lpm) {
cflags += [ "-Wunreachable-code-aggressive" ]
}
@ -2145,7 +2231,6 @@ if (is_win) {
# TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
}
} else {
common_optimize_on_cflags = []
common_optimize_on_ldflags = []
@ -2473,10 +2558,12 @@ 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",
"Only atom, bigcore and arm are valid Chrome OS profiles.")
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.")
_clang_sample_profile =
"//chromeos/profiles/${chromeos_afdo_platform}.afdo.prof"
}
@ -2698,10 +2785,18 @@ config("symbols") {
# This config guarantees to hold symbol for stack trace which are shown to user
# when crash happens in unittests running on buildbot.
config("minimal_symbols") {
rustflags = []
if (is_win) {
# Functions, files, and line tables only.
cflags = []
if (is_clang) {
cflags += [
# Disable putting the compiler command line into the debug info to
# prevent some types of non-determinism.
"-gno-codeview-command-line",
]
}
if (is_clang && use_lld && use_ghash) {
cflags += [ "-gcodeview-ghash" ]
ldflags = [ "/DEBUG:GHASH" ]
@ -2725,15 +2820,18 @@ config("minimal_symbols") {
# at least 10.11.
# TODO(thakis): Remove this once mac_deployment_target is 10.11.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
} else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
# On aix -gdwarf causes linker failures due to thread_local variables.
# Recent clang versions default to DWARF5 on Linux, and Android is about
# to switch. TODO: Adopt that in controlled way.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
}
if (use_dwarf5 && !is_nacl) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
}
# The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
@ -2765,7 +2863,7 @@ config("minimal_symbols") {
asmflags = cflags
}
rustflags = [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+sse2", ]
rustflags += [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+sse2", ]
}
# This configuration contains function names only. That is, the compiler is
@ -2833,9 +2931,12 @@ if (is_chromeos_ash && is_chromeos_device) {
if (is_android || (is_chromeos_ash && is_chromeos_device)) {
# Use orderfile for linking Chrome on Android and Chrome OS.
# This config enables using an orderfile for linking in LLD.
# TODO: Consider using call graph sort instead, at least on Android.
config("chrome_orderfile_config") {
if (chrome_orderfile_path != "" && !enable_call_graph_profile_sort) {
# Don't try to use an orderfile with call graph sorting, except on Android,
# where we care about memory used by code, so we still want to mandate
# ordering.
if (chrome_orderfile_path != "" &&
(is_android || !enable_call_graph_profile_sort)) {
assert(use_lld)
_rebased_orderfile = rebase_path(chrome_orderfile_path, root_build_dir)
ldflags = [

View file

@ -184,6 +184,13 @@ declare_args() {
# Allow projects that wish to stay on C++17 to override Chromium's default.
# TODO(crbug.com/1402249): evaluate removing this end of 2023
use_cxx17 = false
# Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
# shadow call stack in register x18. Hence, x18 must not be used by the OS
# or libraries. We assume that to be the case for high end Android
# configurations. For more details see
# https://clang.llvm.org/docs/ShadowCallStack.html
enable_shadow_call_stack = false
}
declare_args() {
@ -215,7 +222,12 @@ if (is_android || (is_chromeos_ash && is_chromeos_device)) {
# another variable.
chrome_orderfile_path = default_chrome_orderfile
} else if (is_chromeos_ash && is_chromeos_device) {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
if (chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp") {
chrome_orderfile_path = "//chromeos/profiles/chromeos.arm.orderfile.txt"
} else {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
}
}
}
}
@ -263,6 +275,7 @@ config("compiler") {
cflags_cc = []
cflags_objc = []
cflags_objcc = []
rustflags = []
ldflags = []
defines = []
configs = []
@ -325,28 +338,44 @@ config("compiler") {
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
# Stack protection.
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# Stack protection. ShadowCallStack and Stack protector address the same
# problems. Therefore, we only enable one or the other. Clang advertises SCS as
# a stronger alternative to StackProtector, so we give SCS precedence over SP.
if (enable_shadow_call_stack) {
# On Aarch64, SCS requires the x18 register to be unused because it will hold
# a pointer to the shadow stack. For Android we know that Clang doesn't use
# x18 by default. On other OSs adding "-ffixed-x18" might be required.
assert(is_android)
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
scs_parameters = [
"-fsanitize=shadow-call-stack",
"-fno-stack-protector",
]
cflags += scs_parameters
ldflags += scs_parameters
} else {
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
}
}
}
@ -458,6 +487,7 @@ config("compiler") {
asmflags += [ "-fPIC" ]
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
rustflags += [ "-Crelocation-model=pic" ]
if (!is_clang) {
# Use pipes for communicating between sub-processes. Faster.
@ -749,6 +779,11 @@ config("compiler") {
# arm32.
if (!is_android || current_cpu == "arm64") {
cflags += [ "-fwhole-program-vtables" ]
# whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
# behaviour.
rustflags += [ "-Zsplit-lto-unit" ]
if (!is_win) {
ldflags += [ "-fwhole-program-vtables" ]
}
@ -856,6 +891,24 @@ config("compiler") {
}
}
if (clang_embed_bitcode) {
assert(!use_thin_lto,
"clang_embed_bitcode is only supported in non-ThinLTO builds")
cflags += [
"-Xclang",
"-fembed-bitcode=all",
]
}
if (lld_emit_indexes_and_imports) {
assert(use_thin_lto,
"lld_emit_indexes_and_imports is only supported with ThinLTO builds")
ldflags += [
"-Wl,--save-temps=import",
"-Wl,--thinlto-emit-index-files",
]
}
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
@ -868,9 +921,38 @@ config("compiler") {
asmflags += cflags_c
}
if (is_chromeos_device && !is_nacl) {
# On ChromeOS devices, we want to ensure we're using Chrome's allocator
# symbols for all C++ new/delete operator overloads. PartitionAlloc
# and other local allocators should always take precedence over system or
# preloaded allocators. These are the mangled symbol names.
# See b/280115910 for details.
ldflags += [
"-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
"-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
"-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
"-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
"-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
"-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
]
}
# Rust compiler flags setup.
# ---------------------------
rustflags = [
rustflags += [
# Overflow checks are optional in Rust, but even if switched
# off they do not cause undefined behavior (the overflowing
# behavior is defined). Because containers are bounds-checked
@ -908,6 +990,13 @@ config("compiler") {
# Full RUSTC optimizations.
"-Copt-level=3", "-Ctarget-feature=+sse3",
]
if (!is_win || force_rustc_color_output) {
# Colorize error output. The analogous flag is passed for clang. This must
# be platform-gated since rustc will unconditionally output ANSI escape
# sequences, ignoring the platform, when stderr is not a terminal.
rustflags += [ "--color=always" ]
}
if (rust_abi_target != "") {
rustflags += [ "--target=$rust_abi_target" ]
}
@ -918,20 +1007,15 @@ config("compiler") {
if (is_official_build) {
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", "-Ctarget-feature=+sse3", ]
}
}
# Defers LTO optimization to the linker, for use when:
# * Having the C++ toolchain do the linking against Rust staticlibs, and it
# will be using LTO.
# * Having Rust toolchain invoke the linker, and you're linking Rust and C++
# together, so this defers LTO to the linker.
#
# Otherwise, Rust does LTO during compilation.
#
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html
config("rust_defer_lto_to_linker") {
if (!is_debug && use_thin_lto && is_a_target_toolchain) {
rustflags = [ "-Clinker-plugin-lto", "-Copt-level=3", "-Ctarget-feature=+sse3", ]
if (!rust_prebuilt_stdlib) {
# When building against the Chromium Rust stdlib (which we compile) always
# abort instead of unwinding when panic occurs. In official builds, panics
# abort immediately (this is configured in the stdlib) to keep binary size
# down. So we unconditionally match behaviour in unofficial too.
rustflags += [
"-Cpanic=abort",
"-Zpanic_abort_tests",
]
}
}
@ -951,6 +1035,9 @@ config("thinlto_optimize_default") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -981,6 +1068,9 @@ config("thinlto_optimize_max") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -1297,7 +1387,7 @@ config("compiler_cpu_abi") {
ldflags += [ "-m64" ]
}
} else if (current_cpu == "riscv64") {
if (is_clang) {
if (is_clang && !is_android) {
cflags += [ "--target=riscv64-linux-gnu" ]
ldflags += [ "--target=riscv64-linux-gnu" ]
}
@ -2141,7 +2231,6 @@ if (is_win) {
# TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
}
} else {
common_optimize_on_cflags = []
common_optimize_on_ldflags = []
@ -2696,10 +2785,18 @@ config("symbols") {
# This config guarantees to hold symbol for stack trace which are shown to user
# when crash happens in unittests running on buildbot.
config("minimal_symbols") {
rustflags = []
if (is_win) {
# Functions, files, and line tables only.
cflags = []
if (is_clang) {
cflags += [
# Disable putting the compiler command line into the debug info to
# prevent some types of non-determinism.
"-gno-codeview-command-line",
]
}
if (is_clang && use_lld && use_ghash) {
cflags += [ "-gcodeview-ghash" ]
ldflags = [ "/DEBUG:GHASH" ]
@ -2723,15 +2820,18 @@ config("minimal_symbols") {
# at least 10.11.
# TODO(thakis): Remove this once mac_deployment_target is 10.11.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
} else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
# On aix -gdwarf causes linker failures due to thread_local variables.
# Recent clang versions default to DWARF5 on Linux, and Android is about
# to switch. TODO: Adopt that in controlled way.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
}
if (use_dwarf5 && !is_nacl) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
}
# The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
@ -2763,7 +2863,7 @@ config("minimal_symbols") {
asmflags = cflags
}
rustflags = [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+sse3", ]
rustflags += [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+sse3", ]
}
# This configuration contains function names only. That is, the compiler is

View file

@ -184,6 +184,13 @@ declare_args() {
# Allow projects that wish to stay on C++17 to override Chromium's default.
# TODO(crbug.com/1402249): evaluate removing this end of 2023
use_cxx17 = false
# Enable ShadowCallStack for compiled binaries. SCS stores a pointer to a
# shadow call stack in register x18. Hence, x18 must not be used by the OS
# or libraries. We assume that to be the case for high end Android
# configurations. For more details see
# https://clang.llvm.org/docs/ShadowCallStack.html
enable_shadow_call_stack = false
}
declare_args() {
@ -215,7 +222,12 @@ if (is_android || (is_chromeos_ash && is_chromeos_device)) {
# another variable.
chrome_orderfile_path = default_chrome_orderfile
} else if (is_chromeos_ash && is_chromeos_device) {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
if (chromeos_afdo_platform == "arm" ||
chromeos_afdo_platform == "arm-exp") {
chrome_orderfile_path = "//chromeos/profiles/chromeos.arm.orderfile.txt"
} else {
chrome_orderfile_path = "//chromeos/profiles/chromeos.orderfile.txt"
}
}
}
}
@ -263,6 +275,7 @@ config("compiler") {
cflags_cc = []
cflags_objc = []
cflags_objcc = []
rustflags = []
ldflags = []
defines = []
configs = []
@ -325,28 +338,44 @@ config("compiler") {
# --------------------------------
cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
# Stack protection.
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# Stack protection. ShadowCallStack and Stack protector address the same
# problems. Therefore, we only enable one or the other. Clang advertises SCS as
# a stronger alternative to StackProtector, so we give SCS precedence over SP.
if (enable_shadow_call_stack) {
# On Aarch64, SCS requires the x18 register to be unused because it will hold
# a pointer to the shadow stack. For Android we know that Clang doesn't use
# x18 by default. On other OSs adding "-ffixed-x18" might be required.
assert(is_android)
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
scs_parameters = [
"-fsanitize=shadow-call-stack",
"-fno-stack-protector",
]
cflags += scs_parameters
ldflags += scs_parameters
} else {
if (is_apple) {
# The strong variant of the stack protector significantly increases
# binary size, so only enable it in debug mode.
if (is_debug) {
cflags += [ "-fstack-protector-strong" ]
} else {
cflags += [ "-fstack-protector" ]
}
} else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) {
# TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
# See also https://crbug.com/533294
if (current_os != "zos") {
cflags += [ "--param=ssp-buffer-size=4" ]
}
# The x86 toolchain currently has problems with stack-protector.
if (is_android && current_cpu == "x86") {
cflags += [ "-fno-stack-protector" ]
} else if (current_os != "aix") {
# Not available on aix.
cflags += [ "-fstack-protector" ]
}
}
}
@ -458,6 +487,7 @@ config("compiler") {
asmflags += [ "-fPIC" ]
cflags += [ "-fPIC" ]
ldflags += [ "-fPIC" ]
rustflags += [ "-Crelocation-model=pic" ]
if (!is_clang) {
# Use pipes for communicating between sub-processes. Faster.
@ -572,6 +602,13 @@ config("compiler") {
ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
}
}
# TODO(crbug.com/1235145): Investigate why/if this should be needed.
if (is_win) {
cflags += [ "/clang:-ffp-contract=off" ]
} else {
cflags += [ "-ffp-contract=off" ]
}
}
# C11/C++11 compiler flags setup.
@ -742,6 +779,11 @@ config("compiler") {
# arm32.
if (!is_android || current_cpu == "arm64") {
cflags += [ "-fwhole-program-vtables" ]
# whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
# behaviour.
rustflags += [ "-Zsplit-lto-unit" ]
if (!is_win) {
ldflags += [ "-fwhole-program-vtables" ]
}
@ -849,6 +891,24 @@ config("compiler") {
}
}
if (clang_embed_bitcode) {
assert(!use_thin_lto,
"clang_embed_bitcode is only supported in non-ThinLTO builds")
cflags += [
"-Xclang",
"-fembed-bitcode=all",
]
}
if (lld_emit_indexes_and_imports) {
assert(use_thin_lto,
"lld_emit_indexes_and_imports is only supported with ThinLTO builds")
ldflags += [
"-Wl,--save-temps=import",
"-Wl,--thinlto-emit-index-files",
]
}
# Pass the same C/C++ flags to the objective C/C++ compiler.
cflags_objc += cflags_c
cflags_objcc += cflags_cc
@ -861,9 +921,38 @@ config("compiler") {
asmflags += cflags_c
}
if (is_chromeos_device && !is_nacl) {
# On ChromeOS devices, we want to ensure we're using Chrome's allocator
# symbols for all C++ new/delete operator overloads. PartitionAlloc
# and other local allocators should always take precedence over system or
# preloaded allocators. These are the mangled symbol names.
# See b/280115910 for details.
ldflags += [
"-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
"-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
"-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
"-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
"-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
"-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothrow_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothrow_t",
]
}
# Rust compiler flags setup.
# ---------------------------
rustflags = [
rustflags += [
# Overflow checks are optional in Rust, but even if switched
# off they do not cause undefined behavior (the overflowing
# behavior is defined). Because containers are bounds-checked
@ -901,6 +990,13 @@ config("compiler") {
# Full RUSTC optimizations.
"-Copt-level=3", "-Ctarget-feature=+aes,+avx,-pclmul",
]
if (!is_win || force_rustc_color_output) {
# Colorize error output. The analogous flag is passed for clang. This must
# be platform-gated since rustc will unconditionally output ANSI escape
# sequences, ignoring the platform, when stderr is not a terminal.
rustflags += [ "--color=always" ]
}
if (rust_abi_target != "") {
rustflags += [ "--target=$rust_abi_target" ]
}
@ -911,20 +1007,15 @@ config("compiler") {
if (is_official_build) {
rustflags += [ "-Ccodegen-units=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,-pclmul", ]
}
}
# Defers LTO optimization to the linker, for use when:
# * Having the C++ toolchain do the linking against Rust staticlibs, and it
# will be using LTO.
# * Having Rust toolchain invoke the linker, and you're linking Rust and C++
# together, so this defers LTO to the linker.
#
# Otherwise, Rust does LTO during compilation.
#
# https://doc.rust-lang.org/rustc/linker-plugin-lto.html
config("rust_defer_lto_to_linker") {
if (!is_debug && use_thin_lto && is_a_target_toolchain) {
rustflags = [ "-Clinker-plugin-lto", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,-pclmul", ]
if (!rust_prebuilt_stdlib) {
# When building against the Chromium Rust stdlib (which we compile) always
# abort instead of unwinding when panic occurs. In official builds, panics
# abort immediately (this is configured in the stdlib) to keep binary size
# down. So we unconditionally match behaviour in unofficial too.
rustflags += [
"-Cpanic=abort",
"-Zpanic_abort_tests",
]
}
}
@ -944,6 +1035,9 @@ config("thinlto_optimize_default") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -974,6 +1068,9 @@ config("thinlto_optimize_max") {
# ldflags += [ "-Wl,-mllvm,-enable-pre=false", ]
}
# We always point Rust to a linker that performs LTO, so we don't want Rust
# to preemptively do so during compilation too or they conflict. But we do
# want Rust to generate LTO metadata in order for the linker to do its job.
rustflags = [ "-Clinker-plugin-lto=yes" ]
}
}
@ -1292,7 +1389,7 @@ config("compiler_cpu_abi") {
ldflags += [ "-m64" ]
}
} else if (current_cpu == "riscv64") {
if (is_clang) {
if (is_clang && !is_android) {
cflags += [ "--target=riscv64-linux-gnu" ]
ldflags += [ "--target=riscv64-linux-gnu" ]
}
@ -2136,7 +2233,6 @@ if (is_win) {
# TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
}
} else {
common_optimize_on_cflags = []
common_optimize_on_ldflags = []
@ -2691,10 +2787,18 @@ config("symbols") {
# This config guarantees to hold symbol for stack trace which are shown to user
# when crash happens in unittests running on buildbot.
config("minimal_symbols") {
rustflags = []
if (is_win) {
# Functions, files, and line tables only.
cflags = []
if (is_clang) {
cflags += [
# Disable putting the compiler command line into the debug info to
# prevent some types of non-determinism.
"-gno-codeview-command-line",
]
}
if (is_clang && use_lld && use_ghash) {
cflags += [ "-gcodeview-ghash" ]
ldflags = [ "/DEBUG:GHASH" ]
@ -2718,15 +2822,18 @@ config("minimal_symbols") {
# at least 10.11.
# TODO(thakis): Remove this once mac_deployment_target is 10.11.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
} else if (!use_dwarf5 && !is_nacl && current_os != "aix") {
# On aix -gdwarf causes linker failures due to thread_local variables.
# Recent clang versions default to DWARF5 on Linux, and Android is about
# to switch. TODO: Adopt that in controlled way.
cflags += [ "-gdwarf-4" ]
rustflags += [ "-Zdwarf-version=4" ]
}
if (use_dwarf5 && !is_nacl) {
cflags += [ "-gdwarf-5" ]
rustflags += [ "-Zdwarf-version=5" ]
}
# The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
@ -2758,7 +2865,7 @@ config("minimal_symbols") {
asmflags = cflags
}
rustflags = [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,-pclmul", ]
rustflags += [ "-Cdebuginfo=1", "-Copt-level=3", "-Ctarget-feature=+aes,+avx,-pclmul", ]
}
# This configuration contains function names only. That is, the compiler is