blob: 023c6334b4e16004e535c081dff3c8c72e489bfb [file] [log] [blame]
# Copyright 2016 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/clang/clang.gni")
import("//build/config/clang/crash_diagnostics.gni")
import("//build/config/clang/stack_size_section.gni")
import("//build/config/clang/time_trace.gni")
import("//build/config/compiler.gni")
import("//build/config/fuchsia_cxx_version.gni")
import("//build/config/linker.gni")
import("//build/config/lto/config.gni")
import("//build/toolchain/ccache.gni")
import("//build/toolchain/concurrent_jobs.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/rbe.gni")
import("//build/toolchain/toolchain_environment.gni")
import("//build/toolchain/variant.gni")
if (support_rust) {
import("//build/rust/config.gni")
}
declare_args() {
if (is_fuchsia) {
# Controls whether the compiler emits full stack frames for function calls.
# This reduces performance but increases the ability to generate good
# stack traces, especially when we have bugs around unwind table generation.
# It applies only for Fuchsia targets (see below where it is unset).
#
# TODO(https://fxbug.dev/42107277): Theoretically unwind tables should be good enough so we can
# remove this option when the issues are addressed.
enable_frame_pointers = is_debug
}
# Controls whether to promote warnings to errors.
deny_warnings = true
}
# No frame pointers for host compiles.
if (!is_fuchsia) {
enable_frame_pointers = false
}
if (zircon_toolchain != false) {
import("//build/config/zircon/levels.gni")
enable_frame_pointers = zx_assert_level > 0
}
config("language") {
cflags_c = [ "-std=c11" ]
cflags_cc = [ "-std=c++$fuchsia_cxx_version" ]
if (fuchsia_cxx_version < 20) {
# TODO(https://fxbug.dev/42064981): libc++ now marks the C++20
# synchronization primitives as deprecated in older C++ standards which
# affects Fuchsia since we use these primitives across the codebase. We
# temporarily suppress these warnings until C++20 becomes the default.
defines = [ "_LIBCPP_DISABLE_DEPRECATION_WARNINGS" ]
}
if (current_os == "mac") {
# macOS needs this to not complain about C++17isms that older macOS
# system libc++ doesn't support. But we use our own toolchain's static
# libc++ anyway.
cflags_cc += [ "-faligned-allocation" ]
# libc++ headers mark some symbols as unavailable on macOS by default
# because the system libc++ doesn't support them. But we use our own
# toolchain's static libc++ anyway.
defines += [ "_LIBCPP_DISABLE_AVAILABILITY" ]
}
}
config("color_diagnostics") {
# GCC correctly defaults this from the terminal, so leave it alone.
if (!is_gcc) {
cflags = [ "-fcolor-diagnostics" ]
asmflags = cflags
ldflags = cflags
# The macOS linker does not support `--color-diagnostics`.
if (current_os != "mac") {
ldflags += [ "-Wl,--color-diagnostics" ]
}
}
}
config("crash_diagnostics") {
if (!is_gcc) {
cflags = [
"-fcrash-diagnostics-dir=" +
rebase_path(crash_diagnostics_dir, root_build_dir),
"-fcrash-diagnostics=all",
]
if (clang_enable_error_reproducers) {
cflags += [ "-gen-reproducer=error" ]
}
ldflags = cflags
asmflags = cflags
}
}
config("stack-size-section") {
if (!is_gcc && stack_size_section) {
cflags = [ "-fstack-size-section" ]
asmflags = cflags
ldflags = cflags
}
}
config("time-trace") {
if (!is_gcc && time_trace) {
cflags = [ "-ftime-trace" ]
asmflags = cflags
ldflags = cflags
}
}
config("compiler") {
cflags = []
cflags_cc = [ "-fvisibility-inlines-hidden" ]
cflags_objcc = [ "-fvisibility-inlines-hidden" ]
configs = [
":color_diagnostics",
":crash_diagnostics",
":time-trace",
":toolchain_version_stamp",
":stack-size-section",
]
if (!is_gcc) {
configs += [
":clang_defaults",
":ffp_contract",
]
}
if (current_os == "fuchsia") {
configs += [ "//build/config/fuchsia:compiler" ]
} else {
if (current_os == "linux") {
configs += [ "//build/config/linux:compiler" ]
} else if (current_os == "mac") {
configs += [ "//build/config/mac:compiler" ]
} else if (current_cpu == "wasm32" && current_os == "unknown") {
configs += [ "//build/config/wasm:compiler" ]
}
}
asmflags = cflags
}
config("cpu_baseline") {
if (current_cpu != "wasm32") {
configs = [ "//build/config/$current_cpu" ]
}
}
# These flags are enabled by default in Fuchsia's Clang toolchain, but we set
# them explicitly to support other Clang toolchains and Clang-based tools.
config("clang_defaults") {
if (clang_embed_bitcode) {
cflags += [
"-Xclang",
"-fembed-bitcode=all",
]
}
if (current_cpu == "x64") {
asmflags = [ "-Wa,--mrelax-relocations=yes" ]
}
}
# -ffast-math enables 4 sets of optimizations:
# no-math-errno, no-rounding-math, unsafe-math-optimizations, finite-math-only
# This config sets the first 3. Use one of the subsequent configs to disable/enable the last one.
config("fast-math-baseline") {
cflags = [
"-fno-math-errno",
"-fno-rounding-math",
# Enables six targeted optimizations: approx-func, associative-math,
# reciprocal-math, no-signed-zeros, no-trapping-math and fp-contract=fast
"-funsafe-math-optimizations",
# -ffinite-math-only is set (or cleared) elsewhere.
]
}
# Disables finite-math-only, but sets all other fast-math optimizations.
# Allow inf/nan to be used (while avoiding UB), with the other float-based optimizations.
config("fast-math") {
configs = [ ":fast-math-baseline" ]
cflags = [
"-fno-finite-math-only", # Implies honor-infinities and honor-nans.
]
}
# Enables finite-math-only, along with all other fast-math optimizations.
# To be used when inf/nan are guaranteed to NOT be encountered.
config("fast-math-no-inf-nan") {
configs = [ ":fast-math-baseline" ]
cflags = [
"-ffinite-math-only", # Implies no-honor-infinities and no-honor-nans.
]
}
config("ffp_contract") {
# TODO(https://fxbug.dev/42169939): This was the default for -ffp-model=precise until
# LLVM revision f04e387055e495e3e14570087d68e93593cf2918 when Clang switched
# to -ffp-contract=on.
cflags = [ "-ffp-contract=off" ]
asmflags = cflags
}
# We want to force a recompile and relink of the world whenever our toolchain
# changes since artifacts from an older version of the toolchain may or may not
# be compatible with newer ones.
#
# To achieve this, we insert an unused flag in the compile line.
config("toolchain_version_stamp") {
if (clang_prefix == default_clang_prefix) {
clang_version = read_file(
"//prebuilt/third_party/clang/${host_platform}/.versions/clang.cipd_version",
"json")
defines = [ "TOOLCHAIN_VERSION=${clang_version.instance_id}" ]
}
if (support_rust) {
rustflags = [ "--cfg=__rust_toolchain=\"${rustc_version_string}\"" ]
}
}
config("relative_paths") {
if (is_gcc) {
if (use_goma) {
# TODO(https://fxbug.dev/42101823): `-fdebug-prefix-map` is also used by Goma to canonicalize
# build commands, allowing it to reuse compilation results for users running
# out of different working directories. However, it only supports a single
# "-fdebug-prefix-map" prefix. Attempting to provide more than one causes
# canonicalization to fail, meaning that builds running out of different
# directories won't share cache results. For now, we just provide a single
# debug-prefix-map, even though more would be ideal.
# Map "/some/dir/fuchsia" to "../..".
cflags = [ "-fdebug-prefix-map=" + rebase_path("//") + "=" +
rebase_path("//", root_build_dir) ]
} else {
# Relativize paths without leaking the build output directory in debug info.
# Note: with multiple prefix map options, the mappings are checked in
# reverse-order, and *stops* after the first match is applied.
# Thus, longest prefix matches should be near the tail of this list.
cflags = [
# Map "/some/dir/fuchsia" to "../..".
"-ffile-prefix-map=" + rebase_path("//") + "=" +
rebase_path("//", root_build_dir),
# Map "/some/dir/fuchsia/out" to "..".
"-ffile-prefix-map=" + rebase_path("$root_build_dir/..") + "=..",
# Map "/some/dir/fuchsia/out/my-build.my-arch" to ".".
"-ffile-prefix-map=" + rebase_path(root_build_dir) + "=.",
]
}
} else {
# Make builds independent of the absolute file path. -ffile-prefix-map= can
# be used to the same effect, but it requires putting the absolute path to
# the build directory in the compile command, thus making it dependent on
# the absolute path of build directory. -ffile-compilation-dir is designed
# to address this issue, making both debug info and coverage mapping
# independent of the absolute path of the build directory.
cflags = [ "-ffile-compilation-dir=." ]
}
# This makes sure that include directories in the toolchain are represented
# as relative to the build directory (because that's how we invoke the
# compiler), rather than absolute. This can affect __FILE__ expansions
# (e.g. assertions in system headers). We normally run a compiler that's
# someplace within the source tree, so its absolute installation path will
# have a prefix matching `absolute_path` and hence be mapped to
# `relative_path` in the debugging information, so this should actually be
# superfluous for purposes of the debugging information.
cflags += [ "-no-canonical-prefixes" ]
asmflags = cflags
ldflags = cflags
if (current_os == "win") {
ldflags += [
# This embeds just "name.pdb" in the binary instead of the absolute
# path to the PDB file.
"-Wl,/pdbaltpath:%_PDB%",
# This embeds a fake Windows-style absolute path rather than the real
# build-time absolute path in the PDB file. Windows apparently
# requires an absolute path here, so we use an arbitrary fake one for
# reproducibility.
"-Wl,/pdbsourcepath:c:\\src",
]
}
# `-Zremap-cwd-prefix` ensures that absolute paths do not leak into
# outputs for universal reproducibility while keeping the command line
# free of absolute paths for remote caching benefit.
# Available since: https://github.com/rust-lang/rust/pull/87320
rustflags = [ "-Zremap-cwd-prefix=." ]
}
config("debug") {
}
config("release") {
defines = [ "NDEBUG=1" ]
}
config("exceptions") {
cflags_cc = [ "-fexceptions" ]
cflags_objcc = cflags_cc
ldflags = cflags_cc
}
config("no_exceptions") {
cflags_cc = [ "-fno-exceptions" ]
cflags_objcc = cflags_cc
ldflags = cflags_cc
}
config("rtti") {
cflags_cc = [ "-frtti" ]
cflags_objcc = cflags_cc
ldflags = cflags_cc
}
config("no_rtti") {
cflags_cc = [ "-fno-rtti" ]
if (is_kernel && is_fuchsia && !is_gcc) {
cflags_cc += [
# Remove the unused rtti component from vtables.
"-Xclang",
"-fexperimental-omit-vtable-rtti",
]
}
cflags_objcc = cflags_cc
ldflags = cflags_cc
}
config("default_include_dirs") {
include_dirs = [
"//",
root_gen_dir,
]
}
variant("linker_gc") {
cflags = [
"-fdata-sections",
"-ffunction-sections",
]
ldflags = cflags
if (current_os == "mac") {
ldflags += [ "-Wl,-dead_strip" ]
} else if (current_os == "win") {
ldflags += [ "-Wl,/opt:ref" ]
} else {
ldflags += [ "-Wl,--gc-sections" ]
}
}
config("default_linker_gc") {
configs = [ ":linker_gc" ]
}
config("linker_string_merging") {
if (current_os == "win") {
ldflags = [ "-Wl,/opt:lldtailmerge" ]
} else if (current_os != "mac") {
ldflags = [ "-Wl,-O2" ]
}
}
# Disable remote linking for C++ executables.
# This can be useful on large targets that OOM remotely.
config("no_remote_link") {
if (link_rbe_enable) {
ldflags = [ "--remote-flag=--local" ]
}
}
config("download_outputs") {
# Override global settings that may disable downloading of outputs.
# This is useful for targets that are known to be needed for local actions.
if (rust_rbe_enable) {
rustflags = [ "--remote-flag=--download_regex=.*" ]
}
if (cxx_rbe_enable) {
cflags = [ "--remote-flag=--download_regex=.*" ]
}
if (link_rbe_enable) {
ldflags = [ "--remote-flag=--download_regex=.*" ]
}
}
# Each optimize_$optimize config below corresponds to a single setting that's
# controlled by the optimize argument. The default_optimize level is set to
# optimize_$optimize for convenience, but individual targets can override their
# optimization level by remove default_optimize and manually applying one of
# the configs below.
config("optimize_none") {
cflags = [ "-O0" ]
ldflags = cflags
rustflags = [ "-Copt-level=0" ]
}
# This is the default optimization level for "debug" builds.
config("optimize_debug") {
cflags = [ "-Og" ]
ldflags = cflags
# Rust doesn't recognize opt level "g", the closest is "1".
# See: https://doc.rust-lang.org/rustc/codegen-options/index.html#opt-level
rustflags = [ "-Copt-level=1" ]
}
config("optimize_default") {
cflags = [ "-O2" ]
ldflags = cflags
rustflags = [ "-Copt-level=2" ]
}
config("optimize_size") {
# GCC doesn't have -Oz
if (!is_gcc && use_oz) {
cflags = [ "-Oz" ]
} else {
# TODO(https://fxbug.dev/42165168): We would ideally be using -Oz by default but that
# currently frequently results in binaries that are larger than -Oz.
cflags = [ "-Os" ]
}
ldflags = cflags
if (clang_ml_inliner) {
cflags += [
# `release` uses AOT model embedded inside the compiler.
"-mllvm",
"-enable-ml-inliner=release",
]
}
if (use_oz) {
rustflags = [ "-Copt-level=z" ]
} else {
# TODO(https://fxbug.dev/42165168): We would ideally be using -Oz by default but that
# currently frequently results in binaries that are larger than -Oz.
rustflags = [ "-Copt-level=s" ]
}
configs = [ ":linker_string_merging" ]
}
# This is the default optimization level for "non-debug" builds.
config("optimize_size_lto") {
if (zircon_toolchain != false) {
configs = [ ":optimize_default" ]
} else {
# Primarily optimize for size.
configs = [ ":optimize_size" ]
}
_is_not_instrumented = toolchain_variant.tags + [ "instrumented" ] -
[ "instrumented" ] == toolchain_variant.tags
not_needed([ "_is_not_instrumented" ])
# Enable LTO for Fuchsia targets.
# Do not enable LTO for the kernel.
# Do not enable LTO for the instrumented variants.
# Do not enable LTO (here) for the lto or thinlto variants.
if (is_fuchsia && toolchain_environment != "kernel" && _is_not_instrumented &&
!is_lto_variant) {
# Enable LTO for the binaries that are generated by Clang.
configs += [ "//build/config/lto:lto-clang" ]
}
}
config("optimize_speed") {
cflags = [ "-O3" ]
ldflags = cflags
rustflags = [ "-Copt-level=3" ]
configs = [ ":linker_string_merging" ]
}
config("optimize_sanitizer") {
# Instrumentation adds overhead that is greatly improved by optimization.
# -O1 is well-tested with the instrumentation modes and does not degrade the
# comprehensibility of backtraces produced by sanitizer failures.
cflags = [ "-O1" ]
ldflags = cflags
rustflags = [ "-Copt-level=1" ]
}
config("optimize_profile") {
if (zircon_toolchain != false) {
# For Zircon artifacts, this must always enable optimizations
# to ensure userboot.so is compiled with -O2
# See https://fxbug.dev/42146384 for more context.
configs = [ ":optimize_default" ]
} else {
cflags = [ "-O1" ]
ldflags = cflags
rustflags = [ "-Copt-level=1" ]
}
}
config("optimize_coverage") {
if (zircon_toolchain != false) {
# For Zircon artifacts, this must always enable optimizations
# to ensure userboot.so is compiled with -O2
# See https://fxbug.dev/42146384 for more context.
configs = [ ":optimize_default" ]
} else {
cflags = [ "-O1" ]
ldflags = cflags
rustflags = [ "-Copt-level=1" ]
}
}
config("default_optimize") {
configs = [ ":optimize_${optimize}" ]
}
# Each of the debuginfo_$debuginfo configs below corresponds to a single setting
# that controls the amount of debugging information used and is controlled by
# the debuginfo argument. The default_debuginfo level is set to
# debuginfo_$debuginfo for convenience, but individual targets can override
# their debuginfo level by manually applying one of the configs below.
config("debuginfo_none") {
cflags = [ "-g0" ]
if (current_os != "win") {
asmflags = cflags
}
ldflags = cflags
rustflags = [ "-Cdebuginfo=0" ]
}
config("debuginfo_backtrace") {
cflags = [ "-g1" ]
if (current_os != "win") {
asmflags = cflags
}
ldflags = cflags
rustflags = [ "-Cdebuginfo=1" ]
}
config("debuginfo_debug") {
cflags = [
"-g3",
# Add command-line details to each TU's DW_AT_producer to aid build
# diagnosis working backwards from debug files. Clang aliases this switch
# to -grecord-command-line, but both compilers accept this spelling for it.
"-grecord-gcc-switches",
]
if (current_os != "win") {
asmflags = cflags
}
ldflags = cflags
rustflags = [ "-Cdebuginfo=2" ]
}
config("dwarf_version") {
cflags = [ "-gdwarf-${dwarf_version}" ]
asmflags = cflags
ldflags = cflags
}
config("compress_debuginfo") {
if (compress_debuginfo != "none") {
gz_flag = "-gz=${compress_debuginfo}"
cflags = [ gz_flag ]
asmflags = cflags
ldflags = cflags
# rustc driver invokes LLD directly when targeting Fuchsia, so we need to
# use the linker spelling of this flag, whereas on other targets rustc
# invokes Clang so we use the same spelling as for C/C++.
if (is_fuchsia) {
rustflags =
[ "-Clink-arg=--compress-debug-sections=${compress_debuginfo}" ]
} else {
rustflags = [ "-Clink-arg=${gz_flag}" ]
}
}
}
config("default_debuginfo") {
cflags = []
ldflags = []
configs = [ ":debuginfo_${debuginfo}" ]
if (current_os != "win" && current_cpu != "wasm32") {
configs += [
":dwarf_version",
":compress_debuginfo",
]
if (!is_gcc) {
# This option forces Clang to only emit class type information when
# constructors are emitted which can significantly reduce debug info
# size. Eventually, this option will enabled by default in Clang when
# -fno-standalone-debug is used.
cflags += [
"-Xclang",
"-debug-info-kind=constructor",
]
}
} else if (debuginfo != "none" && current_os == "win") {
# TODO(https://fxbug.dev/42132853): This produces the .pdb file, but it doesn't seem
# to get the DWARF data out of the main output file.
ldflags += [ "-Wl,/debug:full" ]
}
}
config("default_frame_pointers") {
if (enable_frame_pointers) {
configs = [ ":frame_pointers" ]
} else {
configs = [ ":no_frame_pointers" ]
}
}
config("frame_pointers") {
cflags = [
"-fno-omit-frame-pointer",
"-momit-leaf-frame-pointer",
]
ldflags = cflags
rustflags = [ "-Cforce-frame-pointers" ]
if (zircon_toolchain != false) {
defines = [ "WITH_FRAME_POINTERS=1" ]
}
}
group("frame_pointers_deps") {
# Implicit dependencies for frame_pointers config
}
config("no_frame_pointers") {
cflags = [ "-fomit-frame-pointer" ]
ldflags = cflags
# rustc automatically does this for release builds, and there's no way to
# force it for non-release.
if (zircon_toolchain != false) {
defines = [ "WITH_FRAME_POINTERS=0" ]
}
}
group("no_frame_pointers_deps") {
# Implicit dependencies for no_frame_pointers config
}
config("suppress_iterator_warnings") {
defines = [ "_LIBCPP_DISABLE_DEPRECATION_WARNINGS" ]
visibility = [
"//third_party/flatbuffers/*",
"//third_party/grpc/*",
]
}
config("default_warnings") {
cflags = [
"-Wall",
"-Wextra",
"-Wconversion",
"-Wextra-semi",
"-Wimplicit-fallthrough",
"-Wnewline-eof",
"-Wstrict-prototypes",
"-Wwrite-strings",
"-Wno-sign-conversion",
"-Wno-unused-parameter",
"-Wnonportable-system-include-path",
# TODO(https://fxbug.dev/42142861): Disable "-Wmissing-field-initializers" which
# warns when designated initializers are used on some (but not all)
# fields in C++, but not C.
#
# There is ongoing discussion about whether it should apply to C++ or not.
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96868 for details.
"-Wno-missing-field-initializers",
# TODO(https://fxbug.dev/324268041): Disable "-Wextra-qualification" which
# warns when an extra qualifier appears on a member.
"-Wno-extra-qualification",
# TODO(https://fxbug.dev/330769701): Disable "-Wcast-fuction-type-strict"
# and "-Wcast-function-type-mismatch" which enforce an exact type match
# between a function pointer and the target function.
"-Wno-cast-function-type-strict",
"-Wno-cast-function-type-mismatch",
"-Wno-unknown-warning-option",
]
cflags_cc = []
if (fuchsia_cxx_version == 20) {
# TODO(https://fxbug.dev/42064981): Remove these after we switch to C++20.
cflags_cc += [
"-Wc++20-compat",
"-Wno-error=c++20-compat",
# TODO(https://fxbug.dev/42073532): The use of implicit capture of this via [=] has
# been deprecated in C++20, but we cannot address this because adding an
# explicit capture of 'this' to capture '*this' by reference is a C++20
# extension and not valid in C++17.
"-Wno-deprecated-this-capture",
]
}
if (is_gcc) {
# GCC is pedantic about which flags apply to which language.
cflags -= [
"-Wstrict-prototypes",
"-Wextra-semi",
]
cflags_c = [ "-Wstrict-prototypes" ]
cflags_cc += [ "-Wextra-semi" ]
# GCC doesn't support these flags
cflags -= [
"-Wnewline-eof",
"-Wnonportable-system-include-path",
]
cflags += [
# TODO(https://fxbug.dev/42052174): -Warray-bounds has false positives in GCC 12.
# When https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105762 is fixed,
# remove this.
"-Wno-array-bounds",
# gcc will never catch anything that clang will not with this warning.
# Moreover, most folks don't build with gcc. We just disable this
# warning on gcc to make it easier to see actual errors.
"-Wno-deprecated-declarations",
# TODO(https://fxbug.dev/42076979): -Wstringop-overread has false positives in GCC
# 13. Needs to be pursued upstream.
"-Wno-stringop-overread",
]
}
# TODO(https://fxbug.dev/331282813): Disable "-Wdeprecated-pragma" which
# warns for deprecated std::errc constants.
configs = [ ":Wno-deprecated-pragma" ]
}
# Code that goes into the SDK or otherwise contributes to the SDK surface area
# in source form will be compiled in many different environments. As such, we
# should compile it with stricter warnings in fuchsia.git.
config("sdk_extra_warnings") {
cflags_cc = [
"-Wnon-virtual-dtor",
"-Wctad-maybe-unsupported",
]
# TODO(https://fxbug.dev/42071929): Add -Wshadow
}
# Same as `sdk_extra_warnings`, but intended to be added to the configuration of
# test targets that exercise SDK headers, to verify that the public headers of
# SDK libraries build under a stricter set of warnings.
config("test_exercising_sdk_headers") {
configs = [ ":sdk_extra_warnings" ]
}
# TODO(https://fxbug.dev/42136088): clean up instances of this outside of third party code.
config("Wno-unused-function") {
cflags = [ "-Wno-unused-function" ]
visibility = [
"//src/devices/i2c/drivers/intel-i2c:intel-i2c-driver",
"//zircon/third_party/uapp/dash",
"//zircon/third_party/ulib/musl/ldso",
"//zircon/third_party/ulib/musl/src/network",
"//zircon/third_party/ulib/musl/src/time",
]
}
config("Wno-strict-prototypes") {
cflags = [ "-Wno-strict-prototypes" ]
}
config("Wno-undef") {
cflags = [ "-Wno-undef" ]
visibility = [ "//third_party/googletest:*" ]
}
config("Wno-bitfield-conversion") {
cflags = [ "-Wno-bitfield-conversion" ]
visibility = [ "//src/lib/vulkan:*" ]
}
# TODO(https://fxbug.dev/42085293): Remove the use of variable length arrays.
#
# NOTE: Do not add this to public_configs under any circumstances. Public
# configs are viral and will infect unsuspecting targets.
config("Wno-vla-cxx-extension") {
if (!is_gcc) {
cflags_cc = [
# TODO(https://fxbug.dev/42084851): Remove -Wno-unknown-warning-option after the next Clang roll.
"-Wno-unknown-warning-option",
"-Wno-vla-cxx-extension",
]
}
visibility = [
"//sdk/lib/fdio:*",
"//sdk/lib/fdio/tests:*",
"//sdk/lib/ld:*",
"//sdk/lib/zxio:*",
"//src/bringup/bin/console:*",
"//src/bringup/bin/console-launcher:*",
"//src/bringup/bin/dlog:*",
"//src/camera/bin/camera-gym/controller_parser:*",
"//src/camera/bin/factory_cli:*",
"//src/camera/drivers/hw_accel/task:*",
"//src/camera/lib/raw_formats:*",
"//src/connectivity/bluetooth/core/bt-host/fidl:*",
"//src/connectivity/bluetooth/core/bt-host/socket:*",
"//src/connectivity/bluetooth/hci/transport/usb:*",
"//src/connectivity/ethernet/drivers/ethernet/netdevice-migration:*",
"//src/connectivity/ethernet/drivers/gvnic:*",
"//src/connectivity/network/netstack/udp_serde:*",
"//src/connectivity/network/tests/benchmarks/udp-serde:*",
"//src/connectivity/network/tests/external_network:*",
"//src/connectivity/network/tests/socket:*",
"//src/connectivity/telephony/drivers/qmi-usb-transport:*",
"//src/connectivity/wlan/drivers/lib/log/cpp/test:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac:*",
"//src/connectivity/wlan/lib/mlme/cpp:*",
"//src/developer/adb/bin/adb-file-sync:*",
"//src/developer/debug/debug_agent/test_data:*",
"//src/developer/ffx/lib/fuchsia-controller:*",
"//src/developer/memory/metrics/tests:*",
"//src/devices/block/bin/gpt:*",
"//src/devices/block/bin/iochk:*",
"//src/devices/block/drivers/aml-sdmmc:*",
"//src/devices/block/drivers/zxcrypt:*",
"//src/devices/spi/bin/spiutil:*",
"//src/devices/usb/bin/usbctl:*",
"//src/graphics/display/drivers/amlogic-display:*",
"//src/graphics/display/drivers/coordinator:*",
"//src/graphics/display/drivers/intel-i915:*",
"//src/graphics/lib/compute/spinel/platforms/vk/tests/spinel_vk_tests:*",
"//src/graphics/lib/magma/src/libmagma_virt:*",
"//src/media/audio/examples/effects:*",
"//src/media/drivers/amlogic_decoder:*",
"//src/performance/experimental/profiler:*",
"//src/performance/lib/gperftools:*",
"//src/performance/lib/trace_converters:*",
"//src/starnix/tests/syscalls/cpp:*",
"//src/storage/blobfs/test:*",
"//src/storage/fs_test:*",
"//src/storage/fxfs:*",
"//src/storage/gpt:*",
"//src/storage/lib/block_client/cpp:*",
"//src/storage/lib/fs_management/cpp:*",
"//src/storage/lib/vfs/cpp:*",
"//src/storage/lib/vfs/cpp/journal:*",
"//src/storage/minfs:*",
"//src/storage/minfs/test:*",
"//src/sys/bin/psutils:*",
"//src/ui/input/drivers/hid:*",
"//src/ui/input/drivers/hid-input-report:*",
"//src/ui/scenic/lib/flatland/renderer/tests:*",
"//third_party/openweave-core/src/lib/profiles:*",
"//tools/fidl/fidlc:*",
"//vendor/arm/camera/driver/fuchsia/wrappers:*",
"//vendor/google/starnix/android:*",
"//zircon/system/ulib/runtests-utils:*",
"//zircon/system/ulib/test-utils:*",
"//zircon/system/ulib/zxtest:*",
]
}
# TODO(https://fxbug.dev/42136089): clean up instances of this outside of third party code.
#
# NOTE: Do not add this to public_configs under any circumstances. Public
# configs are viral and will infect unsuspecting targets.
config("Wno-conversion") {
cflags = [ "-Wno-conversion" ]
# To trim this list:
# $ scripts/gn/trim_visibility.py --target="//build/config:Wno-conversion"
visibility = [
"//sdk/lib/media/audio/cpp:*",
"//sdk/lib/media/cpp:*",
"//sdk/lib/sys/cpp/tests:*",
"//sdk/lib/sys/service/cpp:*",
"//sdk/lib/syslog/streams/cpp:*",
"//src/cobalt/bin/system-metrics:*",
"//src/cobalt/bin/testapp:*",
"//src/connectivity/bluetooth/hci/transport/uart:*",
"//src/connectivity/bluetooth/hci/vendor/broadcom:*",
"//src/connectivity/bluetooth/hci/vendor/intel:*",
"//src/connectivity/bluetooth/hci/virtual:*",
"//src/connectivity/network/tools/nc/third_party/openbsd-netcat:*",
"//src/connectivity/openthread/drivers/ot-radio:*",
"//src/connectivity/openthread/tests/fake-drivers/fake-ot-radio:*",
"//src/connectivity/telephony/drivers/qmi-fake-transport:*",
"//src/connectivity/telephony/drivers/qmi-usb-transport:*",
"//src/connectivity/wlan/drivers/testing:*",
"//src/connectivity/wlan/drivers/testing/lib/sim-env:*",
"//src/connectivity/wlan/drivers/testing/lib/sim-env/test:*",
"//src/connectivity/wlan/drivers/testing/lib/sim-fake-ap:*",
"//src/connectivity/wlan/drivers/testing/lib/sim-fake-ap/test:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/chipset:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/msgbuf:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/msgbuf/test:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/pcie:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/sdio:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/sdio/test:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/sim:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/sim/test:*",
"//src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/test:*",
"//src/connectivity/wlan/drivers/wlanif:*",
"//src/connectivity/wlan/drivers/wlanif/test:*",
"//src/connectivity/wlan/drivers/wlanphy:*",
"//src/connectivity/wlan/drivers/wlansoftmac:*",
"//src/connectivity/wlan/lib/common/cpp:*",
"//src/connectivity/wlan/lib/mlme/cpp:*",
"//src/connectivity/wlan/lib/mlme/cpp/tests:*",
"//src/connectivity/wlan/testing/wlantap-driver:*",
"//src/developer/debug/debug_agent:*",
"//src/developer/debug/debug_agent/integration_tests:*",
"//src/developer/debug/zxdb/client:*",
"//src/developer/debug/zxdb/console:*",
"//src/developer/debug/zxdb/debug_adapter:*",
"//src/developer/debug/zxdb/expr:*",
"//src/developer/debug/zxdb/symbols:*",
"//src/developer/ffx/lib/buildid/cpp:*",
"//src/developer/forensics/exceptions/tests:*",
"//src/developer/forensics/feedback_data/tests:*",
"//src/developer/memory/metrics:*",
"//src/developer/memory/monitor/tests:*",
"//src/devices/block/drivers/ftl:*",
"//src/devices/block/drivers/ftl/tests:*",
"//src/devices/board/drivers/x86:*",
"//src/devices/bus/drivers/pci:*",
"//src/devices/bus/drivers/pci/test:*",
"//src/devices/bus/drivers/platform/test:*",
"//src/devices/bus/lib/virtio:*",
"//src/devices/cpu/drivers/aml-cpu-legacy:*",
"//src/devices/i2c/drivers/intel-i2c:*",
"//src/devices/lib/amlogic:*",
"//src/devices/lib/fidl-metadata/test:*",
"//src/devices/lib/goldfish/pipe_io:*",
"//src/devices/nand/drivers/intel-spi-flash:*",
"//src/devices/nand/drivers/ram-nand:*",
"//src/devices/pci/testing:*",
"//src/devices/power/drivers/fusb302:*",
"//src/devices/power/drivers/ti-ina231:*",
"//src/devices/pwm/drivers/aml-pwm:*",
"//src/devices/rtc/drivers/intel-rtc:*",
"//src/devices/spi/drivers/aml-spi:*",
"//src/devices/tee/drivers/optee:*",
"//src/devices/temperature/drivers/shtv3:*",
"//src/devices/testing/fake-msi:*",
"//src/devices/testing/goldfish/fake_pipe:*",
"//src/devices/tpm/drivers/cr50-spi:*",
"//src/devices/tpm/drivers/tpm:*",
"//src/devices/usb/drivers/xhci:*",
"//src/diagnostics/validator/inspect/lib/cpp:*",
"//src/firmware/gigaboot/lib",
"//src/firmware/gigaboot/src",
"//src/graphics/display/drivers/fake:*",
"//src/graphics/display/drivers/goldfish-display:*",
"//src/graphics/display/lib/designware-hdmi:*",
"//src/graphics/display/lib/designware-hdmi/test:*",
"//src/graphics/drivers/misc/goldfish:*",
"//src/graphics/drivers/misc/goldfish_address_space:*",
"//src/graphics/drivers/misc/goldfish_sync:*",
"//src/graphics/lib/compute/svg:*",
"//src/lib/backoff:*",
"//src/lib/chunked-compression:*",
"//src/lib/cobalt/cpp:*",
"//src/lib/containers/cpp:*",
"//src/lib/ddk:*",
"//src/lib/elflib:*",
"//src/lib/fidl/cpp/tests/dispatcher:*",
"//src/lib/fidl/llcpp/tests:*",
"//src/lib/fidl/llcpp/tests/conformance:*",
"//src/lib/fidl/llcpp/tests/integration:*",
"//src/lib/fidl/llcpp/tests/wire_types:*",
"//src/lib/fsl/socket:*",
"//src/lib/fsl/vmo:*",
"//src/lib/icu/tools/extractor:*",
"//src/lib/json_parser:*",
"//src/lib/line_input:*",
"//src/lib/listnode:*",
"//src/lib/process_builder:*",
"//src/lib/ui/scenic/cpp:*",
"//src/lib/usb_bulk/cpp:*",
"//src/lib/vmo_store:*",
"//src/lib/vulkan/tests:*",
"//src/media/audio/audio_core/v1:*",
"//src/media/audio/drivers/aml-g12-tdm/test:*",
"//src/media/audio/drivers/codecs/tas27xx:*",
"//src/media/audio/drivers/codecs/tas5720:*",
"//src/media/audio/drivers/intel-hda/controller:*",
"//src/media/audio/drivers/lib/audio-utils:*",
"//src/media/audio/drivers/lib/intel-hda:*",
"//src/media/drivers/amlogic_decoder/third_party/libvpx:*",
"//src/media/drivers/amlogic_decoder/third_party/vp9_adapt_probs:*",
"//src/media/lib/codec_impl/unit_tests:*",
"//src/media/lib/extend_bits/unit_tests:*",
"//src/media/sounds/soundplayer:*",
"//src/performance/lib/gperftools:*",
"//src/performance/lib/gperftools/tests:*",
"//src/performance/lib/perfmon:*",
"//src/performance/lib/trace_converters:*",
"//src/security/bin/tee_manager:*",
"//src/storage/lib/vfs/cpp:*",
"//src/sys/pkg/lib/far/cpp:*",
"//src/ui/a11y/bin/a11y_manager/tests:*",
"//src/ui/a11y/bin/a11y_manager/tests/util:*",
"//src/ui/a11y/lib/annotation:*",
"//src/ui/a11y/lib/configuration:*",
"//src/ui/a11y/lib/configuration/tests:*",
"//src/ui/a11y/lib/gesture_manager/recognizers/tests:*",
"//src/ui/a11y/lib/magnifier/tests:*",
"//src/ui/a11y/lib/screen_reader:*",
"//src/ui/a11y/lib/screen_reader/focus/tests/mocks:*",
"//src/ui/a11y/lib/screen_reader/i18n:*",
"//src/ui/a11y/lib/screen_reader/i18n/tests:*",
"//src/ui/a11y/lib/screen_reader/tests:*",
"//src/ui/a11y/lib/semantics:*",
"//src/ui/a11y/lib/semantics/tests:*",
"//src/ui/a11y/lib/semantics/tests/mocks:*",
"//src/ui/a11y/lib/semantics/util/tests:*",
"//src/ui/a11y/lib/util:*",
"//src/ui/backlight/drivers/ti-lp8556:*",
"//src/ui/bin/root_presenter:*",
"//src/ui/bin/root_presenter/tests:*",
"//src/ui/examples/escher/common:*",
"//src/ui/input/drivers/buttons:*",
"//src/ui/input/drivers/goodix:*",
"//src/ui/input/drivers/pc-ps2:*",
"//src/ui/input/lib/hid:*",
"//src/ui/input/lib/hid-input-report:*",
"//src/ui/lib/escher/test:*",
"//src/ui/lib/escher/test/common:*",
"//src/ui/lib/yuv:*",
"//src/ui/scenic/bin:*",
"//src/virtualization/third_party/fdt:*",
"//third_party/acpica/*",
"//third_party/crashpad/src/*",
"//third_party/glfw/*",
"//third_party/iperf/*",
"//third_party/libc-tests/*",
"//third_party/mesa/*",
"//third_party/micro-ecc/*",
"//third_party/modp_b64:*",
"//third_party/ogg/*",
"//third_party/opus/*",
"//third_party/rust_crates/compat/brotli:*",
"//third_party/tpm2-tss/*",
"//third_party/zstd:*",
"//tools/bootserver_old:*",
"//tools/fidlcat:*",
"//tools/fidlcat/interception_tests:*",
"//tools/fidlcat/lib:*",
"//tools/netprotocol:*",
"//tools/symbolizer:*",
"//tools/vboot_reference:*",
"//vendor/*",
"//zircon/system/ulib/c/*",
"//zircon/system/ulib/image-format:*",
"//zircon/system/ulib/ktrace:*",
"//zircon/system/ulib/tftp:*",
"//zircon/system/ulib/trace:*",
"//zircon/system/ulib/trace-engine:*",
"//zircon/third_party/dev/ethernet/e1000:*",
"//zircon/third_party/lib/jitterentropy",
"//zircon/third_party/uapp/dash:*",
"//zircon/third_party/uapp/fsck-msdosfs:*",
"//zircon/third_party/uapp/mkfs-msdosfs:*",
"//zircon/third_party/ulib/cksum:*",
"//zircon/third_party/ulib/linenoise:*",
"//zircon/third_party/ulib/musl:*",
"//zircon/third_party/ulib/musl/ldso",
"//zircon/third_party/ulib/musl/src/complex",
"//zircon/third_party/ulib/musl/src/dirent",
"//zircon/third_party/ulib/musl/src/env",
"//zircon/third_party/ulib/musl/src/internal",
"//zircon/third_party/ulib/musl/src/ipc",
"//zircon/third_party/ulib/musl/src/legacy",
"//zircon/third_party/ulib/musl/src/locale",
"//zircon/third_party/ulib/musl/src/math",
"//zircon/third_party/ulib/musl/src/multibyte",
"//zircon/third_party/ulib/musl/src/network",
"//zircon/third_party/ulib/musl/src/passwd",
"//zircon/third_party/ulib/musl/src/prng",
"//zircon/third_party/ulib/musl/src/process",
"//zircon/third_party/ulib/musl/src/regex",
"//zircon/third_party/ulib/musl/src/sched",
"//zircon/third_party/ulib/musl/src/stdio",
"//zircon/third_party/ulib/musl/src/stdlib",
"//zircon/third_party/ulib/musl/src/string:*",
"//zircon/third_party/ulib/musl/src/time",
"//zircon/third_party/ulib/musl/src/unistd",
"//zircon/third_party/ulib/musl/third_party/complex",
"//zircon/third_party/ulib/musl/third_party/math",
"//zircon/third_party/ulib/musl/third_party/tre",
"//zircon/tools/lz4:*",
]
}
config("Wno-extra-semi") {
cflags = [ "-Wno-extra-semi" ]
}
config("Wno-implicit-fallthrough") {
cflags = [ "-Wno-implicit-fallthrough" ]
visibility = [
"//src/lib/fxl:third_party",
"//third_party/rust_crates/compat/brotli",
"//zircon/third_party/dev/ethernet/e1000:e1000_third_party",
"//zircon/third_party/uapp/dash",
"//zircon/third_party/ulib/boringssl",
"//zircon/third_party/ulib/lz4",
"//zircon/tools/lz4",
]
}
# Config to suppress Wno-unused-but-set-parameter warning in the third party code
# that doesn't comply with.
config("Wno-unused-but-set-parameter") {
cflags = [ "-Wno-unused-but-set-parameter" ]
visibility = [
"//third_party/*",
"//vendor/*",
"//zircon/third_party/uapp/dash",
]
}
# Config to suppress Wunused-but-set-variable warning in the third party code
# that doesn't comply with.
config("Wno-unused-but-set-variable") {
cflags = [ "-Wno-unused-but-set-variable" ]
visibility = [
"//src/connectivity/network/tools/nc/third_party/openbsd-netcat/*",
"//src/connectivity/wlan/drivers/third_party/*",
"//src/devices/power/drivers/fusb302/*",
"//src/devices/usb/drivers/xhci/*",
"//src/media/audio/drivers/usb-audio/*",
"//src/storage/fvm/driver/*",
"//third_party/*",
"//vendor/*",
"//zircon/third_party/uapp/dash",
]
}
# Config to suppress Wbitwise-instead-of-logical warning in the third party code
# that doesn't comply with.
config("Wno-bitwise-instead-of-logical") {
cflags = [ "-Wno-bitwise-instead-of-logical" ]
visibility = [ "//third_party/zstd:*" ]
}
config("Wno-defaulted-function-deleted") {
cflags = [ "-Wno-defaulted-function-deleted" ]
visibility = [ "//src/lib/vulkan/*" ]
}
config("Wno-missing-prototypes") {
cflags_c = [ "-Wno-missing-prototypes" ]
visibility = [
"//third_party/tpm2-tss:tss2-mu",
"//zircon/third_party/ulib/lz4",
]
}
config("Wno-missing-declarations") {
visibility = [ "//zircon/third_party/ulib/lz4" ]
cflags = [ "-Wno-missing-declarations" ]
}
config("symbol_visibility_hidden") {
# Disable libc++ visibility annotations to make sure that the compiler option
# has effect on symbols defined in libc++ headers. Note that we don't want to
# disable these annotations altogether to ensure that our toolchain is usable
# outside of our build since not every user uses hidden visibility by default.
defines = [ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" ]
cflags = [ "-fvisibility=hidden" ]
if (zircon_toolchain != false) {
cflags_cc = [ "-fvisibility-inlines-hidden" ]
}
}
config("symbol_no_undefined") {
if (current_os == "mac") {
ldflags = [ "-Wl,-undefined,error" ]
} else {
ldflags = [ "-Wl,--no-undefined" ]
}
}
config("shared_library_config") {
if (current_os == "fuchsia") {
configs = [ "//build/config/fuchsia:shared_library_config" ]
} else if (current_os == "linux") {
cflags = [ "-fPIC" ]
} else if (current_os == "mac") {
configs = [ "//build/config/mac:mac_dynamic_flags" ]
}
}
config("executable_config") {
configs = []
if (current_os == "fuchsia") {
configs += [ "//build/config/fuchsia:executable_config" ]
} else if (current_os == "mac") {
configs += [
"//build/config/mac:mac_dynamic_flags",
"//build/config/mac:mac_executable_flags",
]
}
}
config("default_libs") {
configs = []
if (current_os == "mac") {
configs += [ "//build/config/mac:default_libs" ]
}
}
config("werror") {
if (!use_ccache) {
cflags = [
"-Werror",
# Do not add -Wno-error= options to this config.
]
asmflags = [ "-Wa,--fatal-warnings" ]
cflags += asmflags
if (current_os == "win") {
ldflags = [ "-Wl,/WX" ]
}
# New versions of C++ often include new deprecations, so treat them as
# warnings by default.
if ((defined(experimental_cxx_version) && experimental_cxx_version >= 20) ||
# TODO(https://fxbug.dev/327227416): Remove after addressing
# Xcode-specific deprecation warnings.
is_mac) {
cflags += [ "-Wno-error=deprecated-declarations" ]
}
}
# Set a few lints to always be denied, regardless of the deny_warnings build arg.
rustflags = [
"-Dderef-nullptr",
"-Dinvalid-value",
"-Dunused-must-use",
]
# TODO(https://fxbug.dev/42069541): Remove blanket allow once lint is actionable.
rustflags += [ "-Awhere_clauses_object_safety" ]
# TODO(https://fxbug.dev/327271893) Remove blanket allow once lint is actionable.
rustflags += [
"-Aunknown_lints",
"-Anon_local_definitions",
]
if (deny_warnings) {
rustflags += [ "-Dwarnings" ]
}
}
config("no-template-backtrace-limit") {
cflags_cc = [ "-ftemplate-backtrace-limit=0" ]
}
config("no-stack-protector") {
cflags = [ "-fno-stack-protector" ]
}
variant("no-safe-stack") {
if (!is_gcc) {
cflags = [ "-fno-sanitize=safe-stack" ]
}
}
config("no-shadow-call-stack") {
if ((current_cpu == "arm64" || current_cpu == "riscv64") && !is_gcc) {
cflags = [ "-fno-sanitize=shadow-call-stack" ]
}
}
variant("no-compiler-abi") {
configs = [
":no-safe-stack",
":no-shadow-call-stack",
":no-stack-protector",
]
if (!is_gcc) {
ldflags = [
# Make sure libc++ is not linked in. Header-only use is OK.
"-nostdlib++",
]
}
}
config("no_profile") {
# The difference between this config and removing //build/config/profile is
# the dynamic linker setting which is necessary for it to use at runtime with
# the libraries it was linked against.
cflags = [
"-fno-profile-instr-generate",
"-fno-coverage-mapping",
]
}
config("icf") {
# This changes C/C++ semantics and might be incompatible with third-party
# code that relies on function pointers comparison.
if (current_os == "win" && (linker == "lld" || !is_gcc)) {
ldflags = [ "-Wl,/opt:icf=all" ]
} else if (linker == "gold" || linker == "lld") {
ldflags = [ "-Wl,--icf=all" ]
}
}
# "_ALL_SOURCE" is used by some system headers to expose more features (say in fcntl.h) beyond those
# strictly defined in standard.
config("all_source") {
defines = [ "_ALL_SOURCE" ]
}
config("auto_var_init") {
if (!is_gcc) {
# Automatically initialize variables with a pattern.
cflags = [ "-ftrivial-auto-var-init=pattern" ]
}
}
config("thread_safety_annotations") {
if (!is_gcc) {
cflags = [
"-Wthread-safety",
# TODO(https://fxbug.dev/42085252): Clang is catching instances of these in the kernel and drivers.
# Temporarily disable them for now to facilitate the roll then come back and
# fix them.
"-Wno-unknown-warning-option",
"-Wno-thread-safety-reference-return",
]
defines = [ "_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1" ]
}
}
config("zero-call-used-regs") {
# TODO(fxrev.dev/710262): Enable on arm64 when there's performance data.
if (current_cpu == "x64") {
cflags = [ "-fzero-call-used-regs=used-gpr" ]
defines = [ "ZERO_CALL_USED_REGS" ]
}
}
# libc++ removed a number of transitive includes between version 14 and 15
# but those were later re-added and conditionally gated on a new define in
# https://reviews.llvm.org/D128661. In Fuchsia, we have already done the
# cleanup so we can remove these transitive includes unconditionally to
# avoid regressions.
#
# Note: This is going to become the default in future libc++ versions.
config("libcpp_remove_transitive_includes") {
defines = [ "_LIBCPP_REMOVE_TRANSITIVE_INCLUDES" ]
}
# Infinite loops are undefined behavior in C++ and thus can be optimized away
# by the compiler. This config inhibits that optimization.
config("no-finite-loops") {
cflags = [ "-fno-finite-loops" ]
}
if (current_toolchain == default_toolchain) {
import("//build/toolchain/default_concurrent_jobs.gni")
# Tools that must be executed locally.
pool("local") {
depth = default_concurrent_jobs.local
}
# For actions that consume exceptionally large amounts of memory.
# The largest LTO link actions may fall into this category.
# See https://fxbug.dev/42062387 for context.
pool("highmem") {
depth = 1
}
}
config("tlsdesc") {
have_tlsdesc = 0
if (is_gcc) {
# TLSDESC is opt-in or opt-out via -mtls-dialect=... under GCC.
if (current_cpu == "arm64") {
cflags = [ "-mtls-dialect=desc" ]
have_tlsdesc = 1
} else if (current_cpu == "x64") {
cflags = [ "-mtls-dialect=gnu2" ]
have_tlsdesc = 1
}
} else {
# TLSDESC is either always on or always off (so far) under Clang.
if (current_cpu == "arm64") {
have_tlsdesc = 1
}
}
defines = [
"WANT_TLSDESC=1",
"HAVE_TLSDESC=$have_tlsdesc",
]
}
config("no-tlsdesc") {
have_tlsdesc = 0
if (is_gcc) {
# TLSDESC is opt-in or opt-out via -mtls-dialect=... under GCC.
if (current_cpu == "arm64") {
cflags = [ "-mtls-dialect=traditional" ]
} else if (current_cpu == "x64") {
cflags = [ "-mtls-dialect=gnu" ]
}
} else {
# TLSDESC is either always on or always off (so far) under Clang.
if (current_cpu == "arm64") {
have_tlsdesc = 1
}
}
defines = [
"WANT_TLSDESC=0",
"HAVE_TLSDESC=$have_tlsdesc",
]
}
# TODO(https://fxbug.dev/331282813): Disable "-Wdeprecated-pragma" which
# warns for deprecated std::errc constants.
config("Wno-deprecated-pragma") {
cflags = [ "-Wno-deprecated-pragma" ]
}