blob: ade2fde3fed5c1c67a9054e932880d90e8169bc5 [file] [log] [blame]
# Copyright 2021 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/rust/config.gni")
declare_args() {
# 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
# Enable incremental rust compilation. Takes a path to the directory to use
# as the cache.
rust_incremental = ""
}
# 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("panic_cfg") {
rustflags = [ "--cfg=rust_panic=\"${rust_panic}\"" ]
}
# 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("analysis") {
rustflags = [ "-Zsave-analysis" ]
}
config("edition_2018") {
rustflags = [ "--edition=2018" ]
}
config("edition_2015") {
rustflags = [ "--edition=2015" ]
}
config("opt_level_z") {
rustflags = [ "-Copt-level=z" ]
}
config("no_features") {
rustflags = [ "-Zallow-features=" ]
}
config("incremental") {
if (rust_incremental != "") {
rustflags = [ "-Cincremental=" + rust_incremental ]
}
}
config("netstack3_only_specialization_feature") {
rustflags = [
"-Zallow-features=min_specialization,specialization",
"-Aincomplete-features",
]
}
config("2018_idioms") {
rustflags = [ "-Wrust-2018-idioms" ]
}
config("target") {
rustflags = [
"--target",
rust_target,
"--cap-lints=$rust_cap_lints",
]
}
config("panic_abort") {
rustflags = [
"-Cpanic=abort",
"-Cforce-unwind-tables=yes",
"-Zpanic_abort_tests",
]
}
config("v0_symbol_mangling") {
if (rust_v0_symbol_mangling) {
rustflags = [ "-Zsymbol-mangling-version=v0" ]
}
}
# TODO(fxbug.dev/76297) Remove this to re-enable mutable-noalias.
config("no_mutable_noalias") {
rustflags = [ "-Zmutable-noalias=off" ]
}
config("allow_unknown_lints") {
rustflags = [ "-Aunknown-lints" ]
}
# TODO(fxbug.dev/67118) remove this allowance
config("allow_redundant_semicolons") {
rustflags = [ "-Aredundant-semicolons" ]
}
# TODO(fxbug.dev/68148) remove this allowance
config("allow_unused_extern_crates") {
rustflags = [ "-Aunused-extern-crates" ]
}
# TODO(fxbug.dev/69442) remove this allowance
config("allow_legacy_derive_helpers") {
rustflags = [ "-Alegacy-derive-helpers" ]
}
config("deny_unused_results") {
rustflags = [ "-Dunused_results" ]
}
config("allow_unused_results") {
rustflags = [ "-Aunused_results" ]
# This visibility list allows for targets to opt out of allowing unused results.
#
# There is currently no platform mandate to adopt the unused_results lint and it's opt-in for
# developers that want to use it. See https://fxbug.dev/73468 for more context.
#
# To adopt the lint, add the following to your rust target:
# configs -= ["//build/config/rust:allow_unused_results"]
# The visibility list below can be used to enforce the list on certain areas of the tree while
# we evaluate wider adoption.
#
# To update this list run:
# $ scripts/gn/gen_visibility_globs.py \
# --all=//build/config/rust:deny_unused_results \
# --allow=//build/config/rust:allow_unused_results \
# --ignore-suffix=-rustc,_banjo_rust
# TODO(https://fxbug.dev/73468): remove all references to src/connectivity/network and friends.
visibility = [
"//build/*",
"//examples/*",
"//garnet/*",
"//sdk/*",
"//src/bringup/*",
"//src/camera/*",
"//src/cobalt/*",
"//src/connectivity/bluetooth/*",
"//src/connectivity/ethernet/*",
"//src/connectivity/lib/at-commands/*",
"//src/connectivity/lib/internet-checksum/*",
"//src/connectivity/lib/net-types/*",
"//src/connectivity/location/*",
"//src/connectivity/lowpan/*",
"//src/connectivity/management/*",
"//src/connectivity/network/netstack:networking_metrics_rustlib",
"//src/connectivity/network/netstack3/*",
"//src/connectivity/openthread/*",
"//src/connectivity/overnet/*",
"//src/connectivity/ppp/*",
"//src/connectivity/telephony/*",
"//src/connectivity/weave/*",
"//src/connectivity/wlan/*",
"//src/developer/*",
"//src/devices/*",
"//src/diagnostics/*",
"//src/experiences/*",
"//src/factory/*",
"//src/fonts/*",
"//src/graphics/*",
"//src/hwinfo/*",
"//src/identity/*",
"//src/intl/*",
"//src/lib/analytics/*",
"//src/lib/assembly/*",
"//src/lib/async-utils/*",
"//src/lib/by_addr/*",
"//src/lib/cobalt/*",
"//src/lib/cstr/*",
"//src/lib/cutex/*",
"//src/lib/diagnostics/*",
"//src/lib/directed_graph/*",
"//src/lib/error/*",
"//src/lib/fable/*",
"//src/lib/fake-clock/*",
"//src/lib/fdio/*",
"//src/lib/fidl/*",
"//src/lib/fidl_table_validation/*",
"//src/lib/from-enum/*",
"//src/lib/fuchsia-async-macro/*",
"//src/lib/fuchsia-async-testloop/*",
"//src/lib/fuchsia-async/*",
"//src/lib/fuchsia-component-test/*",
"//src/lib/fuchsia-component/*",
"//src/lib/fuchsia-hyper/*",
"//src/lib/fuchsia-runtime/*",
"//src/lib/fuchsia-system-alloc/*",
"//src/lib/fuchsia-url/*",
"//src/lib/fuchsia/*",
"//src/lib/fuzzing/*",
"//src/lib/http-sse/*",
"//src/lib/http-uri-ext/*",
"//src/lib/icu/*",
"//src/lib/icu_data/*",
"//src/lib/intl/*",
"//src/lib/isolated_devmgr/*",
"//src/lib/libdoc/*",
"//src/lib/mapped-vmo/*",
"//src/lib/mdns/*",
"//src/lib/mpmc/*",
"//src/lib/mundane/*",
"//src/lib/network/ethernet/*",
"//src/lib/network/packet/*",
"//src/lib/process_builder/*",
"//src/lib/pty/*",
"//src/lib/scoped_task/*",
"//src/lib/shared-buffer/*",
"//src/lib/storage/*",
"//src/lib/syslog/*",
"//src/lib/tcp-stream-ext/*",
"//src/lib/test_executor/*",
"//src/lib/test_util/*",
"//src/lib/testing/*",
"//src/lib/trace/*",
"//src/lib/ui/*",
"//src/lib/usb_bulk/*",
"//src/lib/waitgroup/*",
"//src/lib/watch_handler/*",
"//src/lib/zerocopy/*",
"//src/lib/zircon/*",
"//src/media/*",
"//src/modular/*",
"//src/power/*",
"//src/proc/*",
"//src/recovery/*",
"//src/security/*",
"//src/session/*",
"//src/storage/*",
"//src/sys/*",
"//src/testing/*",
"//src/tests/*",
"//src/ui/*",
"//src/virtualization/*",
"//third_party/*",
"//tools/*",
"//vendor/*",
"//zircon/*",
]
}