blob: 3047cc1e1a4189c81f35504401af235fbfdaf1fb [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/time_trace.gni")
import("//build/config/compiler.gni")
import("//build/config/linker.gni")
import("//build/rust/config.gni")
import("//build/toolchain/ccache.gni")
import("//build/toolchain/goma.gni")
import("//build/unification/global_variables.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(fxbug.dev/32216): 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 the rust compiler uses v0 symbol mangling scheme
# (see https://github.com/rust-lang/rfcs/blob/HEAD/text/2603-rust-symbol-name-mangling-v0.md).
# The v0 symbol mangling scheme requires upstream LLVM support when demangling,
# so it is not on by default.
# TODO(fxbug.dev/57302): Enable v0 mangling by default.
rust_v0_symbol_mangling = false
}
# No frame pointers for host compiles.
if (!is_fuchsia) {
enable_frame_pointers = false
}
# Turns on the rust compilation analysis generator. This will produce a
# directory $OUT/save-analysis-temp, which will dump all the source analysis
# that the compiler collected while analyzing the source. This config is
# included conditionally, see //build/config/BUILDCONFIG.gn for details.
config("rust_analysis") {
rustflags = [ "-Zsave-analysis" ]
}
config("rust_edition_2018") {
rustflags = [ "--edition=2018" ]
}
config("rust_edition_2015") {
rustflags = [ "--edition=2015" ]
}
config("rust_opt_level_z") {
rustflags = [ "-Copt-level=z" ]
}
config("rust_no_features") {
rustflags = [ "-Zallow-features=" ]
}
config("netstack3_only_specialization_feature") {
rustflags = [
"-Zallow-features=specialization",
"-Aincomplete-features",
]
}
config("rust_2018_idioms") {
rustflags = [ "-Wrust-2018-idioms" ]
}
config("rust_target") {
rustflags = [
"--target",
rust_target,
"--cap-lints=$rust_cap_lints",
]
}
config("rust_panic_abort") {
rustflags = [
"-Cpanic=abort",
"-Cforce-unwind-tables=yes",
"-Zpanic_abort_tests",
]
}
config("rust_v0_symbol_mangling") {
if (rust_v0_symbol_mangling) {
rustflags = [ "-Zsymbol-mangling-version=v0" ]
}
}
config("language") {
cflags_c = [ "-std=c11" ]
cflags_cc = [ "-std=c++17" ]
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-dir") {
if (!is_gcc && crash_diagnostics_dir != "") {
cflags = [ "-fcrash-diagnostics-dir=" +
rebase_path(crash_diagnostics_dir, root_build_dir) ]
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 = [
":clang_defaults",
":color_diagnostics",
":crash-diagnostics-dir",
":rust_panic_cfg",
":time-trace",
":toolchain_version_stamp",
]
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" ]
}
}
asmflags = cflags
}
# 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") {
cflags = [ "-fexperimental-new-pass-manager" ]
asmflags = cflags
ldflags = cflags
if (current_cpu == "x64") {
asmflags += [ "-Wa,--mrelax-relocations=yes" ]
}
}
# 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}" ]
}
rustflags = [ "--cfg=__rust_toolchain=\"${rustc_version_string}\"" ]
}
config("relative_paths") {
# TODO(fxbug.dev/54161): Keep in sync with //zircon/public/gn/config:relative_paths
# until build unification completes.
if (is_gcc) {
if (use_goma) {
# TODO(fxbug.dev/27308): `-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("$zx/..") + "=" +
rebase_path("$zx/..", root_build_dir) ]
} else {
cflags = [
# Map "/some/dir/fuchsia/out/my-build.my-arch" to ".".
"-fdebug-prefix-map=" + rebase_path(root_build_dir) + "=.",
# Map "/some/dir/fuchsia/out" to "..".
"-fdebug-prefix-map=" + rebase_path("$root_build_dir/..") + "=..",
# Map "/some/dir/fuchsia" to "../..".
"-fdebug-prefix-map=" + rebase_path("$zx/..") + "=" +
rebase_path("$zx/..", root_build_dir),
]
}
} else {
# Make builds independent of the absolute file path. -fdebug-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. -fdebug-compilation-dir is
# designed to address this issue, making both debug info and the compile
# command itself independent of the absolute path of the build directory.
cflags = [
"-fdebug-compilation-dir",
".",
]
}
if (!is_gcc) {
# 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",
]
}
rustflags = [
"--remap-path-prefix",
rebase_path("//") + "=" + rebase_path("//", root_build_dir),
]
}
config("debug") {
# TODO(phosek): remove this config when nothing refers on it.
}
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" ]
cflags_objcc = cflags_cc
ldflags = cflags_cc
}
config("default_include_dirs") {
include_dirs = [
"//",
root_gen_dir,
]
}
config("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("linker_string_merging") {
if (current_os == "win") {
ldflags = [ "-Wl,/opt:lldtailmerge" ]
} else if (current_os != "mac") {
ldflags = [ "-Wl,-O2" ]
}
}
# 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.
#
# The linker_gc_$optimize configs are an exact parallel. default_linker_gc
# is separate from default_optimize so it can be removed separately.
# NOTE: Keep in sync with //zircon/public/gn/config/BUILD.gn
config("optimize_none") {
cflags = [ "-O0" ]
ldflags = cflags
rustflags = [ "-Copt-level=0" ]
}
config("optimize_debug") {
if (false) {
# TODO(phosek): consider different settings to improve performance.
# -Og is what the compiler documents as "optimize the debugging
# experience", but zxdb team has reported Clang's -Og is problematic.
# This should have a bug# for a detailed bug about -Og and/or Rust-O1
# making debugging difficult in known specific reproducible ways.
cflags = [ "-Og" ]
ldflags = cflags
rustflags = [ "-Copt-level=1" ]
} else {
configs = [ ":optimize_none" ]
}
}
config("optimize_default") {
cflags = [ "-O2" ]
ldflags = cflags
rustflags = [ "-Copt-level=2" ]
}
config("optimize_size") {
if (is_gcc) {
cflags = [ "-Os" ]
} else {
cflags = [ "-Oz" ]
}
ldflags = cflags
rustflags = [ "-Copt-level=z" ]
configs = [ ":linker_string_merging" ]
}
config("optimize_speed") {
cflags = [ "-O3" ]
ldflags = cflags
# TODO(phosek): this should be the same as for C/C++.
rustflags = [ "-Copt-level=z" ]
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") {
# TODO(fxbug.dev/51509): Perhaps use a different default.
configs = [ ":optimize_none" ]
}
config("default_optimize") {
configs = [ ":optimize_${optimize}" ]
}
config("linker_gc_none") {
# No linker GC when wholly unoptimized.
}
# Linker GC is a good default for most cases.
config("linker_gc_debug") {
configs = [ ":linker_gc" ]
}
config("linker_gc_default") {
configs = [ ":linker_gc" ]
}
config("linker_gc_size") {
configs = [ ":linker_gc" ]
}
config("linker_gc_speed") {
configs = [ ":linker_gc" ]
}
config("linker_gc_sanitizer") {
configs = [ ":linker_gc" ]
}
config("linker_gc_profile") {
# TODO(fxbug.dev/51509): See if we can enable linker GC for profile.
}
config("default_linker_gc") {
configs = [ ":linker_gc_$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.
# NOTE: Keep in sync with //zircon/public/gn/config/BUILD.gn
config("debuginfo_none") {
cflags = [ "-g0" ]
asmflags = cflags
ldflags = cflags
rustflags = [ "-Cdebuginfo=0" ]
}
config("debuginfo_backtrace") {
cflags = [ "-g1" ]
asmflags = cflags
ldflags = cflags
rustflags = [ "-Cdebuginfo=1" ]
}
config("debuginfo_debug") {
cflags = [ "-g3" ]
asmflags = cflags
ldflags = cflags
rustflags = [ "-Cdebuginfo=2" ]
}
config("default_debuginfo") {
configs = [ ":debuginfo_${debuginfo}" ]
if (debuginfo != "none" && current_os == "win") {
# TODO(fxbug.dev/55244): 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" ]
ldflags = cflags
rustflags = [ "-Cforce-frame-pointers" ]
}
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.
}
config("default_warnings") {
cflags = [
"-Wall",
"-Wextra",
"-Wnewline-eof",
"-Wconversion",
"-Wno-unused-parameter",
"-Wno-unknown-warning-option",
"-Wno-sign-conversion",
# TODO(fxbug.dev/35965): Temporarily disable C99 designator warnings introduced in
# https://reviews.llvm.org/D59754. After the new Clang toolchain lands
# and we do some cleanup, this will be re-enabled.
"-Wno-unknown-warning-option",
"-Wno-c99-designator",
# TODO(fxbug.dev/37215): Temporarily disable this warning until we roll toolchain.
# Then we can re-enable it and cleanup instances it appears.
"-Wno-int-in-bool-context",
# TODO(fxbug.dev/37765): Keep this flag here while it is enabled in ZN to keep the
# flags unified.
"-Wno-address-of-packed-member",
# TODO(fxbug.dev/43681): Temporarily disable this warning until we roll toolchain,
# then come back and fix the instances this appears after rolling.
"-Wno-range-loop-analysis",
# TODO(fxbug.dev/49143): Temporarily disable this warning until we disable it
# individually for affected third_party libraries.
"-Wno-deprecated-declarations",
]
cflags_cc = [
# TODO(fxbug.dev/38640): Keep this flag here while it is enabled in ZN to keep the
# flags unified.
"-Wno-deprecated-copy",
# TODO(fxbug.dev/45689): Temporarily disable this warning until we roll toolchain,
# then come back and fix the instances this appears after rolling.
"-Wno-non-c-typedef-for-linkage",
# TODO(fxbug.dev/56202): Temporarily disable this warning until we roll toolchain,
# then come back and fix the instances this appears after rolling.
"-Wno-unknown-warning-option",
"-Wno-suggest-override",
]
}
# TODO(fxbug.dev/58160): clean up instances of this outside of third party code.
config("Wno-reorder-init-list") {
cflags = [ "-Wno-reorder-init-list" ]
visibility = [
"//garnet/examples/intl/wisdom/tests/*",
"//src/developer/memory/metrics/tests/*",
"//src/graphics/examples/vkcube/*",
"//src/graphics/lib/compute/tests/*",
"//src/graphics/tests/vkext/*",
"//src/lib/elflib/*",
"//src/lib/vulkan/tests/*",
"//src/modular/bin/basemgr/*",
"//src/modular/tests/*",
"//third_party/*",
]
}
# TODO(fxbug.dev/58161): clean up instances of this outside of third party code.
config("Wno-unused-function") {
cflags = [ "-Wno-unused-function" ]
visibility = [
"//src/devices/board/drivers/x86:platform-bus-x86",
"//src/devices/i2c/drivers/aml-i2c:aml-i2c",
"//src/devices/i2c/drivers/intel-i2c",
"//zircon/third_party/uapp/dash",
]
}
# TODO(fxbug.dev/58162): clean up instances of this outside of third party code.
config("Wno-conversion") {
cflags = [ "-Wno-conversion" ]
visibility = [
"//examples/cowsay/*",
"//examples/dotmatrix_display/*",
"//examples/fortune/*",
"//garnet/bin/catapult_converter/*",
"//garnet/bin/cpuperf/*",
"//garnet/bin/cpuperf_provider/*",
"//garnet/bin/hwstress/*",
"//garnet/bin/insntrace/*",
"//garnet/bin/insntrace/tests/*",
"//garnet/bin/ktrace_provider/*",
"//garnet/bin/run_test_component/*",
"//garnet/bin/sched/*",
"//garnet/bin/sshd-host/*",
"//garnet/bin/test_runner/report_result/*",
"//garnet/bin/thermd/*",
"//garnet/bin/time/*",
"//garnet/bin/trace/*",
"//garnet/bin/trace2json/*",
"//garnet/bin/trace_manager/*",
"//garnet/bin/ui/benchmarks/*",
"//garnet/bin/ui/benchmarks/transparency_benchmark/*",
"//garnet/lib/debugger_utils/*",
"//garnet/lib/loader/*",
"//garnet/lib/perfmon/*",
"//garnet/lib/profiler/*",
"//garnet/lib/trace_converters/*",
"//garnet/public/lib/fostr/*",
"//garnet/public/lib/test_runner/cpp/*",
"//sdk/lib/media/audio/cpp/*",
"//sdk/lib/media/cpp/*",
"//sdk/lib/sys/cpp/*",
"//sdk/lib/sys/service/cpp/*",
"//sdk/lib/syslog/streams/cpp/*",
"//sdk/lib/ui/scenic/cpp/*",
"//sdk/lib/vfs/cpp/*",
"//src/bringup/bin/bootsvc/*",
"//src/bringup/bin/netsvc/*",
"//src/bringup/bin/ptysvc/*",
"//src/bringup/bin/virtcon/*",
"//src/camera/bin/camera-gym/*",
"//src/camera/bin/camera-gym/assets/*",
"//src/camera/bin/device/*",
"//src/camera/bin/factory/*",
"//src/camera/bin/factory_cli/*",
"//src/camera/drivers/bus/aml_mipicsi/*",
"//src/camera/drivers/controller/*",
"//src/camera/drivers/hw_accel/gdc/*",
"//src/camera/drivers/hw_accel/ge2d/*",
"//src/camera/drivers/sensors/imx227/*",
"//src/camera/drivers/test_utils/*",
"//src/camera/drivers/usb_video/*",
"//src/camera/lib/image_writer/*",
"//src/camera/lib/stream_utils/*",
"//src/camera/lib/virtual_camera/*",
"//src/cobalt/bin/system-metrics/*",
"//src/cobalt/bin/testapp/*",
"//src/cobalt/bin/testing/*",
"//src/connectivity/bluetooth/core/bt-host/*",
"//src/connectivity/bluetooth/examples/bt-le-heart-rate-peripheral/*",
"//src/connectivity/bluetooth/hci/transport/uart/*",
"//src/connectivity/bluetooth/hci/transport/usb/*",
"//src/connectivity/bluetooth/hci/vendor/broadcom/*",
"//src/connectivity/bluetooth/hci/vendor/intel/*",
"//src/connectivity/bluetooth/tools/bt-hci-tool/*",
"//src/connectivity/bluetooth/tools/bt-intel-tool/*",
"//src/connectivity/openthread/drivers/ot-radio/*",
"//src/connectivity/openthread/ot-stack/*",
"//src/connectivity/openthread/tests/fake-drivers/fake-ot-radio/*",
"//src/connectivity/openthread/third_party/*",
"//src/connectivity/telephony/drivers/qmi-fake-transport/*",
"//src/connectivity/telephony/drivers/qmi-usb-transport/*",
"//src/connectivity/telephony/tests/driver-unit/*",
"//src/connectivity/telephony/tests/fake-drivers/*",
"//src/connectivity/weave/adaptation/*",
"//src/connectivity/weave/weavestack/*",
"//src/connectivity/wlan/drivers/realtek/rtl88xx/*",
"//src/connectivity/wlan/drivers/testing/lib/sim-env/*",
"//src/connectivity/wlan/drivers/third_party/*",
"//src/connectivity/wlan/drivers/wlanif/*",
"//src/connectivity/wlan/drivers/wlanphy/*",
"//src/connectivity/wlan/lib/common/cpp/*",
"//src/connectivity/wlan/lib/mlme/cpp/*",
"//src/connectivity/wlan/testing/wlantap-driver/*",
"//src/developer/cmd/*",
"//src/developer/debug/debug_agent/*",
"//src/developer/debug/ipc/*",
"//src/developer/debug/shared/*",
"//src/developer/debug/third_party/libunwindstack/*",
"//src/developer/debug/zxdb/client/*",
"//src/developer/debug/zxdb/common/*",
"//src/developer/debug/zxdb/console/*",
"//src/developer/debug/zxdb/expr/*",
"//src/developer/debug/zxdb/symbols/*",
"//src/developer/forensics/crash_reports/*",
"//src/developer/forensics/exceptions/limbo_client/*",
"//src/developer/forensics/feedback_data/*",
"//src/developer/forensics/last_reboot/*",
"//src/developer/forensics/testing/stubs/*",
"//src/developer/forensics/utils/*",
"//src/developer/memory/mem/*",
"//src/developer/memory/metrics/*",
"//src/developer/memory/metrics/tests/*",
"//src/developer/memory/monitor/*",
"//src/developer/system_monitor/*",
"//src/developer/system_monitor/bin/harvester/*",
"//src/devices/bin/acpidump/*",
"//src/devices/bin/driver_host/*",
"//src/devices/bin/driver_manager/*",
"//src/devices/bin/tee-test/*",
"//src/devices/block/drivers/ahci/*",
"//src/devices/block/drivers/block-verity/*",
"//src/devices/block/drivers/core/*",
"//src/devices/block/drivers/ftl/*",
"//src/devices/block/drivers/nvme/*",
"//src/devices/block/drivers/pci-sdhci/*",
"//src/devices/block/drivers/ums-function/*",
"//src/devices/block/drivers/usb-mass-storage/*",
"//src/devices/block/drivers/virtio/*",
"//src/devices/board/drivers/machina/*",
"//src/devices/board/drivers/x86/*",
"//src/devices/bus/drivers/pci/*",
"//src/devices/clock/bin/clock/*",
"//src/devices/i2c/bin/i2c/*",
"//src/devices/i2c/drivers/aml-i2c/*",
"//src/devices/lib/amlogic/*",
"//src/devices/lib/as370/*",
"//src/devices/lib/dev-operation/*",
"//src/devices/lib/qcom/*",
"//src/devices/lib/thermal/*",
"//src/devices/nand/bin/nand-util/*",
"//src/devices/nand/drivers/aml-rawnand/*",
"//src/devices/nand/drivers/broker/test/*",
"//src/devices/nand/drivers/skip-block/*",
"//src/devices/pci/lib/pci/*",
"//src/devices/rtc/drivers/intel-rtc/*",
"//src/devices/rtc/lib/rtc/*",
"//src/devices/serial/drivers/ftdi/test/*",
"//src/devices/serial/drivers/usb-cdc-acm/*",
"//src/devices/sysmem/drivers/sysmem/*",
"//src/devices/tee/drivers/optee/*",
"//src/devices/testing/fake-msi/*",
"//src/devices/tests/libdriver-integration-test/*",
"//src/devices/thermal/drivers/astro-thermistor/test/*",
"//src/devices/usb/bin/lsusb/*",
"//src/devices/usb/drivers/mt-musb-host/*",
"//src/devices/usb/drivers/usb-bus/*",
"//src/devices/usb/drivers/usb-hub/*",
"//src/devices/usb/lib/usb/*",
"//src/diagnostics/dlog/*",
"//src/diagnostics/validator/inspect/lib/cpp/*",
"//src/graphics/display/drivers/*",
"//src/graphics/display/drivers/display/*",
"//src/graphics/display/drivers/ssd1306/*",
"//src/graphics/display/testing/*",
"//src/graphics/drivers/misc/goldfish/*",
"//src/graphics/drivers/misc/goldfish_address_space/*",
"//src/graphics/drivers/msd-arm-mali/src/*",
"//src/graphics/drivers/msd-arm-mali/tests/integration/*",
"//src/graphics/drivers/msd-arm-mali/tests/unit_tests/*",
"//src/graphics/drivers/msd-img-rgx/mtk/*",
"//src/graphics/drivers/msd-img-rgx/no_hardware/*",
"//src/graphics/drivers/msd-intel-gen/*",
"//src/graphics/drivers/msd-intel-gen/tests/integration/*",
"//src/graphics/drivers/msd-qcom-adreno/*",
"//src/graphics/drivers/msd-vsi-vip/src/*",
"//src/graphics/drivers/msd-vsi-vip/tests/integration/*",
"//src/graphics/drivers/msd-vsi-vip/tests/unit_tests/*",
"//src/graphics/drivers/virtio/*",
"//src/graphics/examples/vkcube/*",
"//src/graphics/examples/vkprimer/*",
"//src/graphics/lib/compute/common/*",
"//src/graphics/lib/compute/hotsort/hotsort_gen/*",
"//src/graphics/lib/compute/hotsort/platforms/vk/*",
"//src/graphics/lib/compute/spinel/*",
"//src/graphics/lib/compute/svg/*",
"//src/graphics/lib/compute/tests/*",
"//src/graphics/lib/magma/src/libmagma/*",
"//src/graphics/lib/magma/src/magma_util/*",
"//src/graphics/lib/magma/src/magma_util/platform/zircon/*",
"//src/graphics/lib/magma/src/sys_driver/*",
"//src/graphics/lib/magma/src/tools/*",
"//src/graphics/lib/magma/tests/helper/*",
"//src/graphics/lib/magma/tests/integration/*",
"//src/graphics/lib/magma/tests/mock/*",
"//src/graphics/lib/magma/tests/unit_tests/*",
"//src/graphics/tests/benchmark/*",
"//src/graphics/tests/common/*",
"//src/graphics/tests/goldfish_benchmark/*",
"//src/graphics/tests/vkext/*",
"//src/graphics/tests/vkloop/*",
"//src/graphics/tests/vkpriority/*",
"//src/graphics/tests/vkreadback/*",
"//src/graphics/tests/vkvalidation/*",
"//src/lib/backoff/*",
"//src/lib/chunked-compression/*",
"//src/lib/cobalt/cpp/*",
"//src/lib/containers/cpp/*",
"//src/lib/ddk/*",
"//src/lib/elflib/*",
"//src/lib/fidl_codec/*",
"//src/lib/files/*",
"//src/lib/fsl/socket/*",
"//src/lib/fsl/vmo/*",
"//src/lib/fxl/*",
"//src/lib/icu/tools/extractor/*",
"//src/lib/inet/*",
"//src/lib/json_parser/*",
"//src/lib/line_input/*",
"//src/lib/listnode/*",
"//src/lib/process_builder/*",
"//src/lib/ui/input/*",
"//src/lib/ui/scenic/cpp/*",
"//src/lib/url/*",
"//src/lib/usb_bulk/cpp/*",
"//src/lib/vulkan/imagepipe_view/*",
"//src/lib/vulkan/swapchain/*",
"//src/lib/vulkan/tests/*",
"//src/media/audio/audio_core/*",
"//src/media/audio/audio_core/mixer/*",
"//src/media/audio/audio_core/test/hardware/*",
"//src/media/audio/drivers/aml-g12-tdm/test/*",
"//src/media/audio/drivers/intel-hda/controller/*",
"//src/media/audio/drivers/test/*",
"//src/media/audio/drivers/virtual_audio/*",
"//src/media/audio/effects/test_effects/*",
"//src/media/audio/examples/effects/*",
"//src/media/audio/examples/fx/*",
"//src/media/audio/examples/simple_sine/*",
"//src/media/audio/examples/sync_sine/*",
"//src/media/audio/examples/tones/*",
"//src/media/audio/lib/analysis/*",
"//src/media/audio/lib/clock/*",
"//src/media/audio/lib/effects_loader/*",
"//src/media/audio/lib/format/*",
"//src/media/audio/lib/simple-audio-stream/*",
"//src/media/audio/lib/test/*",
"//src/media/audio/lib/timeline/*",
"//src/media/audio/lib/wav/*",
"//src/media/audio/tools/audio-capture-timestamp-validator/*",
"//src/media/audio/tools/audio-driver-ctl/*",
"//src/media/audio/tools/signal_generator/*",
"//src/media/audio/tools/virtual_audio_util/*",
"//src/media/audio/tools/vol/*",
"//src/media/audio/tools/wav_recorder/*",
"//src/media/codec/codecs/*",
"//src/media/codec/examples/encode_camera/*",
"//src/media/codec/examples/encode_file/*",
"//src/media/codec/examples/use_media_decoder/*",
"//src/media/drivers/amlogic_decoder/*",
"//src/media/lib/codec_impl/*",
"//src/media/lib/test/*",
"//src/media/playback/mediaplayer/*",
"//src/media/playback/mediaplayer/demux/*",
"//src/media/playback/mediaplayer/graph/*",
"//src/media/playback/mediaplayer/metrics/*",
"//src/media/sounds/soundplayer/*",
"//src/modular/bin/sessionctl/*",
"//src/modular/bin/sessionmgr/*",
"//src/modular/lib/async/cpp/*",
"//src/modular/lib/fidl/*",
"//src/modular/lib/integration_testing/cpp/*",
"//src/recovery/factory_reset/*",
"//src/security/tee_manager/*",
"//src/security/zxcrypt/*",
"//src/storage/bin/dd/*",
"//src/storage/blobfs/*",
"//src/storage/blobfs/test/*",
"//src/storage/lib/watchdog/*",
"//src/storage/minfs/*",
"//src/storage/volume_image/ftl/*",
"//src/storage/volume_image/utils/*",
"//src/sys/appmgr/*",
"//src/sys/bin/psutils/*",
"//src/sys/lib/chrealm/*",
"//src/sys/pkg/lib/far/*",
"//src/sys/sysmgr/*",
"//src/sys/time/lib/network_time/*",
"//src/sys/time/network_time_service/*",
"//src/sys/tools/log/*",
"//src/testing/loadbench/*",
"//src/ui/a11y/bin/a11y_manager/tests/util/*",
"//src/ui/a11y/lib/annotation/*",
"//src/ui/a11y/lib/semantics/util/tests/*",
"//src/ui/a11y/lib/util/*",
"//src/ui/bin/activity/*",
"//src/ui/bin/root_presenter/*",
"//src/ui/examples/*",
"//src/ui/examples/bouncing_ball/*",
"//src/ui/examples/embedder/*",
"//src/ui/input/drivers/ft8201/*",
"//src/ui/input/drivers/hid/*",
"//src/ui/input/drivers/pc-ps2/*",
"//src/ui/input/lib/hid-input-report/*",
"//src/ui/scenic/lib/display/*",
"//src/ui/scenic/lib/gfx/*",
"//src/ui/scenic/lib/scenic/util/*",
"//src/ui/scenic/lib/scheduling/*",
"//src/ui/scenic/lib/watchdog/*",
"//src/ui/tools/simple-touch/*",
"//src/ui/tools/tiles_ctl/*",
"//src/virtualization/bin/guest/*",
"//src/virtualization/bin/guest_manager/*",
"//src/virtualization/bin/vmm/*",
"//src/virtualization/bin/vmm/device/*",
"//src/virtualization/buildtools/*",
"//src/virtualization/lib/vsh/*",
"//src/virtualization/tests/*",
"//src/virtualization/third_party/fdt/*",
"//src/zircon/tests/evil/*",
"//third_party/*",
"//tools/bootserver_old/*",
"//tools/fidlcat/*",
"//tools/loglistener/*",
"//tools/netprotocol/*",
"//tools/vboot_reference/*",
"//vendor/*",
"//zircon/kernel/dev/coresight/*",
"//zircon/kernel/lib/heap/cmpctmalloc/*",
"//zircon/system/ulib/audio-utils-legacy/*",
"//zircon/system/ulib/audio-utils/*",
"//zircon/system/ulib/cobalt-client/*",
"//zircon/system/ulib/disk_inspector/*",
"//zircon/system/ulib/driver-info/*",
"//zircon/system/ulib/edid/*",
"//zircon/system/ulib/elf-search/*",
"//zircon/system/ulib/framebuffer/*",
"//zircon/system/ulib/fs-host/*",
"//zircon/system/ulib/fs/*",
"//zircon/system/ulib/ftl/*",
"//zircon/system/ulib/fvm/*",
"//zircon/system/ulib/fzl/*",
"//zircon/system/ulib/gpt/*",
"//zircon/system/ulib/hid-parser/*",
"//zircon/system/ulib/hid/*",
"//zircon/system/ulib/image-format/*",
"//zircon/system/ulib/inet6/*",
"//zircon/system/ulib/inspect/*",
"//zircon/system/ulib/inspector/*",
"//zircon/system/ulib/intel-hda/*",
"//zircon/system/ulib/kcounter/*",
"//zircon/system/ulib/kernel-mexec/*",
"//zircon/system/ulib/ktrace/*",
"//zircon/system/ulib/launchpad/*",
"//zircon/system/ulib/log/*",
"//zircon/system/ulib/logger/*",
"//zircon/system/ulib/memfs/*",
"//zircon/system/ulib/mini-process/*",
"//zircon/system/ulib/profile/*",
"//zircon/system/ulib/ramdevice-client/*",
"//zircon/system/ulib/runtests-utils/*",
"//zircon/system/ulib/storage-metrics/*",
"//zircon/system/ulib/sysconfig-client/*",
"//zircon/system/ulib/syslog/*",
"//zircon/system/ulib/sysmem-version/*",
"//zircon/system/ulib/task-utils/*",
"//zircon/system/ulib/tee-client-api/*",
"//zircon/system/ulib/trace-engine/*",
"//zircon/system/ulib/trace-reader/*",
"//zircon/system/ulib/trace-test-utils/*",
"//zircon/system/ulib/trace/*",
"//zircon/system/ulib/unittest/*",
"//zircon/system/ulib/virtio/*",
"//zircon/system/ulib/zbi-bootfs/*",
"//zircon/system/ulib/zxio/*",
"//zircon/system/utest/msd/*",
"//zircon/third_party/*",
"//zircon/tools/blobfs/*",
"//zircon/tools/fvm/*",
"//zircon/tools/ktrace-dump/*",
"//zircon/tools/lz4/*",
"//zircon/tools/merkleroot/*",
"//zircon/tools/minfs/*",
"//zircon/tools/mtd-redundant-storage/*",
"//zircon/tools/xdc-server/*",
]
}
# TODO(fxbug.dev/58162): clean up instances of this outside of third party code.
# This is the same as "Wno-conversion" above but without a visibility list.
# This in turn allows us to have generated code depend on this config. Having
# an explicit allowlist for generated code (e.g. fidl_cpp template expansions)
# is not practical.
# Please use with care, or not at all.
config("Wno-conversion-generated") {
cflags = [ "-Wno-conversion" ]
}
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" ]
}
config("symbol_no_undefined") {
if (current_os == "mac") {
ldflags = [ "-Wl,-undefined,error" ]
} else {
ldflags = [ "-Wl,--no-undefined" ]
}
}
config("shared_library_config") {
configs = []
cflags = []
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("no-shadow-call-stack") {
if (current_cpu == "arm64") {
cflags = [ "-fsanitize=no-shadow-call-stack" ]
}
}
# Defines a Rust cfg flag with the value of the rust_panic build arg.
# Useful for changing behavior of code based on panic behavior.
config("rust_panic_cfg") {
rustflags = [ "--cfg=rust_panic=\"${rust_panic}\"" ]
}
config("werror") {
if (!use_ccache) {
cflags = [
"-Werror",
# Declarations marked as deprecated should cause build failures, rather
# they should emit warnings to notify developers about the use of
# deprecated interfaces.
"-Wno-error=deprecated-declarations",
# Do not add additional -Wno-error to this config.
]
}
rustflags = [ "-Dwarnings" ]
}
config("temporarily_disable_ubsan_do_not_use") {
cflags = [ "-fno-sanitize=undefined" ]
}
config("no_stack_protector") {
cflags = [ "-fno-stack-protector" ]
}
config("no_sanitizers") {
cflags = [
"-fno-sanitize=all",
"-fsanitize-coverage=0",
]
configs = [ ":no_stack_protector" ]
}
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",
]
}
# IMPORTANT: Keep the configs below in sync with //zircon/public/gn/config/BUILD.zircon.gn
# TODO(fxbug.dev/54322): Remove above comment after build unification.
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("thread_safety_annotations") {
if (!is_gcc) {
cflags = [ "-Wthread-safety" ]
defines = [ "_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS" ]
}
}