blob: 3d7afca01428eb18754d94de05cf23a110c9b9b4 [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(ZX-2361): 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/master/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_cc = [ "-fvisibility-inlines-hidden" ]
cflags_objcc = [ "-fvisibility-inlines-hidden" ]
configs = [
":color_diagnostics",
":toolchain_version_stamp",
":rust_panic_cfg",
]
if (current_os == "fuchsia") {
configs += [ "//build/config/fuchsia:compiler" ]
} else {
cflags_cc += [ "-stdlib=libc++" ]
if (current_os == "linux") {
configs += [ "//build/config/linux:compiler" ]
} else if (current_os == "mac") {
configs += [ "//build/config/mac:compiler" ]
}
}
configs += [
":crash-diagnostics-dir",
":time-trace",
]
}
# 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(54161): Keep in sync with //zircon/public/gn/config:relative_paths
# until build unification completes.
if (is_gcc) {
if (use_goma) {
# TODO(TC-585): `-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(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(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(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",
"-Wno-unused-parameter",
"-Wno-unknown-warning-option",
"-Wno-sign-conversion",
# TODO(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(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(37765): Keep this flag here while it is enabled in ZN to keep the
# flags unified.
"-Wno-address-of-packed-member",
# TODO(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(49143): Temporarily disable this warning until we disable it
# individually for affected third_party libraries.
"-Wno-deprecated-declarations",
]
cflags_cc = [
# TODO(38640): Keep this flag here while it is enabled in ZN to keep the
# flags unified.
"-Wno-deprecated-copy",
# TODO(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(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(fxb/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/test/*",
"//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(fxb/58161): clean up instances of this outside of third party code.
config("Wno-unused-function") {
cflags = [ "-Wno-unused-function" ]
visibility = [
"//sdk/lib/fdio/*",
"//src/bringup/bin/netsvc/*",
"//src/media/audio/drivers/usb-audio/*",
"//third_party/*",
"//zircon/kernel/lib/console/*",
"//zircon/kernel/vm/*",
"//zircon/system/ulib/fs-management/*",
"//zircon/system/ulib/fs/metrics/*",
"//zircon/third_party/*",
]
}
# TODO(fxb/58162): clean up instances of this outside of third party code.
config("Wno-conversion") {
cflags = [ "-Wno-conversion" ]
visibility = [
"//garnet/bin/catapult_converter:converter",
"//garnet/bin/cpuperf:session_result_spec",
"//garnet/bin/cpuperf/print:cpuperf_print",
"//garnet/bin/trace2json:lib",
"//garnet/lib/debugger_utils:debugger_utils",
"//garnet/lib/perfmon:perfmon",
"//garnet/lib/trace_converters:chromium",
"//garnet/public/lib/fostr:fostr",
"//garnet/public/lib/fostr:fostr_shared",
"//sdk/lib/fidl/cpp/*",
"//sdk/lib/syslog/cpp:cpp",
"//sdk/lib/syslog/cpp:cpp_sdk",
"//sdk/lib/syslog/cpp:logging_cpp_unittests",
"//src/camera/bin/camera-gym/assets:convert_image",
"//src/connectivity/management/reachability/core:ext_ping",
"//src/connectivity/network/tools/sockscripter:sockscripter_test",
"//src/connectivity/network/tools/sockscripter:src",
"//src/connectivity/openthread/third_party/*",
"//src/connectivity/wlan/drivers/third_party/*",
"//src/developer/debug/ipc:agent",
"//src/developer/debug/ipc:shared",
"//src/developer/debug/ipc:tests",
"//src/developer/debug/shared:shared",
"//src/developer/debug/shared:tests",
"//src/developer/debug/third_party/libunwindstack:libunwindstack",
"//src/developer/debug/zxdb/client:client",
"//src/developer/debug/zxdb/client:test_support",
"//src/developer/debug/zxdb/client:tests",
"//src/developer/debug/zxdb/common:common",
"//src/developer/debug/zxdb/console:console",
"//src/developer/debug/zxdb/console:tests",
"//src/developer/debug/zxdb/expr:expr",
"//src/developer/debug/zxdb/expr:tests",
"//src/developer/debug/zxdb/symbols:symbols",
"//src/developer/debug/zxdb/symbols:test_support",
"//src/developer/debug/zxdb/symbols:tests",
"//src/devices/block/drivers/block-verity:geometry",
"//src/firmware/lib/zbi:in_tree",
"//src/firmware/lib/zbi:zbi",
"//src/firmware/lib/zbi:zbi_sdk",
"//src/graphics/lib/compute/common:common",
"//src/graphics/lib/compute/hotsort/hotsort_gen:hotsort_gen",
"//src/graphics/lib/compute/hotsort/platforms/vk/targets:hotsort_modules_to_literals",
"//src/graphics/lib/compute/spinel:spinel",
"//src/graphics/lib/compute/spinel/ext/geometry:geometry",
"//src/graphics/lib/compute/spinel/platforms/vk/targets:spinel_modules_to_literals",
"//src/graphics/lib/compute/svg:svg",
"//src/graphics/lib/compute/svg:yxml",
"//src/graphics/lib/compute/tests:common",
"//src/graphics/lib/compute/tests:common_test_utils",
"//src/graphics/lib/compute/tests:common_unittests",
"//src/graphics/lib/compute/tests/common/spinel:spinel_utils",
"//src/graphics/lib/compute/tests/common/svg:svg",
"//src/graphics/lib/compute/tests/common/svg:unittests",
"//src/graphics/lib/compute/tests/mock_spinel:mock_spinel",
"//src/graphics/lib/magma/src/magma_util:allocator",
"//src/graphics/lib/magma/src/magma_util:macros",
"//src/graphics/lib/magma/src/magma_util:status",
"//src/graphics/lib/magma/src/magma_util/platform/zircon:buffer",
"//src/graphics/lib/magma/src/magma_util/platform/zircon:trace",
"//src/lib/chunked-compression:chunked",
"//src/lib/containers/cpp:cpp",
"//src/lib/elflib:elflib",
"//src/lib/files:files",
"//src/lib/fxl:fxl",
"//src/lib/fxl:memory",
"//src/lib/fxl:strings",
"//src/lib/icu/tools/extractor:icu_data_extractor",
"//src/lib/json_parser:json_parser_unittests_bin",
"//src/lib/line_input:line_input",
"//src/lib/line_input:line_input_example",
"//src/lib/usb_bulk/cpp:usb_bulk",
"//src/media/audio/effects/test_effects:test_effects",
"//src/media/audio/examples/effects:audio_effects_example",
"//src/media/codec/codecs/sw/low_layer/aac:libFraunhoferAAC",
"//src/storage/blobfs:blobfs",
"//src/storage/volume_image/ftl/*",
"//src/storage/volume_image/fvm:fvm",
"//src/storage/volume_image/utils:fd",
"//src/storage/volume_image/utils:guid",
"//src/storage/volume_image/utils:lz4",
"//src/sys/pkg/lib/far:far",
"//src/ui/lib/escher/*",
"//src/ui/lib/glm_workaround/*",
"//src/ui/lib/yuv:yuv",
"//src/virtualization/buildtools:mkromfs",
"//src/virtualization/tests:logger",
"//src/virtualization/third_party/fdt:fdt",
"//third_party/*",
"//tools/bootserver_old:bootserver",
"//tools/loglistener:loglistener",
"//tools/netprotocol:common",
"//tools/netprotocol:netcp",
"//tools/vboot_reference:cgpt",
"//tools/vboot_reference:futility",
"//zircon/public/lib/cksum:cksum",
"//zircon/public/lib/cmdline:cmdline",
"//zircon/public/lib/cmpctmalloc:cmpctmalloc",
"//zircon/public/lib/elfload:elfload",
"//zircon/public/lib/fidl_base:fidl_base",
"//zircon/public/lib/fidl_base:fidl_base_sdk",
"//zircon/public/lib/fit:fit",
"//zircon/public/lib/fit:fit_sdk",
"//zircon/public/lib/fit:fit_sdk_generate_api",
"//zircon/public/lib/gfx:gfx",
"//zircon/public/lib/hwreg:hwreg",
"//zircon/public/lib/kcmdline:kcmdline",
"//zircon/public/lib/lz4:lz4",
"//zircon/public/lib/pretty:pretty",
"//zircon/public/lib/tftp:tftp",
"//zircon/public/lib/usbhost-static:usbhost",
"//zircon/public/lib/zbi:zbi",
"//zircon/public/lib/zxtest:zxtest",
"//zircon/system/ulib/driver-info:driver",
"//zircon/system/ulib/elf-search:elf",
"//zircon/system/ulib/fs:fs",
"//zircon/system/ulib/fs-host:fs",
"//zircon/system/ulib/ftl:ftl",
"//zircon/system/ulib/ftl-mtd:ftl",
"//zircon/system/ulib/fvm:fvm",
"//zircon/system/ulib/fvm-host:fvm",
"//zircon/system/ulib/fzl:fzl",
"//zircon/system/ulib/hid-parser:hid",
"//zircon/system/ulib/inspector:inspector",
"//zircon/system/ulib/log:log",
"//zircon/system/ulib/minfs:minfs",
"//zircon/system/ulib/mini-process:subprocess",
"//zircon/system/ulib/syslog:syslog",
"//zircon/system/ulib/trace-engine:trace",
"//zircon/system/ulib/trace-reader:trace",
"//zircon/system/ulib/trace-test-utils:trace",
"//zircon/system/ulib/trace/*",
"//zircon/system/ulib/unittest:unittest",
"//zircon/third_party/*",
"//zircon/tools/blobfs:blobfs",
"//zircon/tools/fidl:compiler",
"//zircon/tools/fvm:fvm",
"//zircon/tools/kazoo:kazoo_lib",
"//zircon/tools/ktrace-dump:ktrace",
"//zircon/tools/merkleroot:merkleroot",
"//zircon/tools/minfs:minfs",
"//zircon/tools/mtd-redundant-storage:mtd",
"//zircon/tools/xdc-server:xdc",
]
}
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" ]
}
# IMPORTANT: Keep the configs below in sync with //zircon/public/gn/config/BUILD.zircon.gn
# TODO(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" ]
}
}
config("all_source") {
defines = [ "_ALL_SOURCE" ]
}
config("thread_safety_annotations") {
if (!is_gcc) {
cflags = [ "-Wthread-safety" ]
defines = [ "_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS" ]
}
}