| # 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 |
| visibility = [ |
| "//build/*", |
| "//examples/*", |
| "//garnet/*", |
| "//sdk/*", |
| "//src/bringup/*", |
| "//src/camera/*", |
| "//src/cobalt/*", |
| "//src/connectivity/bluetooth/*", |
| "//src/connectivity/ethernet/*", |
| "//src/connectivity/lib/at-commands/*", |
| "//src/connectivity/location/*", |
| "//src/connectivity/lowpan/*", |
| "//src/connectivity/management/*", |
| "//src/connectivity/network/net-cli/ffx:*", |
| "//src/connectivity/network/netstack:networking_metrics_rustlib", |
| "//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/*", |
| "//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/*", |
| ] |
| } |