Bug 2060428 - Move the remaining Rust build settings into configure r=firefox-build-system-reviewers,sergesanspaille
While we're at it, make the dependency on `CARGOFLAGS` explicit. Differential Revision: https://phabricator.services.mozilla.com/D320786
This commit is contained in:
committed by
ahochheiden@mozilla.com
parent
f13b979d7e
commit
3c9f9a3dfa
@@ -370,3 +370,13 @@ def bindgen_cflags(base_flags, extra_flags):
|
||||
|
||||
|
||||
set_config("BINDGEN_SYSTEM_FLAGS", bindgen_cflags)
|
||||
|
||||
|
||||
# Force the target down to all bindgen callers, even those that may not
|
||||
# read BINDGEN_SYSTEM_FLAGS some way or another.
|
||||
@depends(bindgen_cflags)
|
||||
def bindgen_extra_clang_args(flags):
|
||||
return [f for f in flags or [] if f.startswith("--target=")]
|
||||
|
||||
|
||||
set_config("BINDGEN_EXTRA_CLANG_ARGS", bindgen_extra_clang_args)
|
||||
|
||||
@@ -611,6 +611,9 @@ set_define("MOZ_DEBUG_RUST", debug_rust)
|
||||
option(env="RUSTFLAGS", nargs=1, help="Rust compiler flags")
|
||||
set_config("RUSTFLAGS", depends("RUSTFLAGS")(lambda flags: flags))
|
||||
|
||||
option(env="CARGOFLAGS", nargs=1, help="Flags to pass to cargo")
|
||||
set_config("CARGOFLAGS", depends("CARGOFLAGS")(lambda flags: flags))
|
||||
|
||||
|
||||
# Rust compiler flags
|
||||
# ==============================================================
|
||||
@@ -954,3 +957,18 @@ def clippy_wrapper(build_env, host_os_arch):
|
||||
|
||||
|
||||
set_config("MOZ_CARGO_CLIPPY_WRAPPER", clippy_wrapper)
|
||||
|
||||
|
||||
# Enable link-time optimization for release builds, but not when doing
|
||||
# cross-language LTO.
|
||||
# Never enable when sancov is enabled to work around https://github.com/rust-lang/rust/issues/90300.
|
||||
# Never enable when coverage is enabled to work around https://github.com/rust-lang/rust/issues/90045.
|
||||
set_config(
|
||||
"RUST_LTO_ELIGIBLE",
|
||||
True,
|
||||
when=~developer_options
|
||||
& ~debug_rust
|
||||
& ~lto.rust_lto
|
||||
& ~rust_sancov_flags
|
||||
& ~code_coverage,
|
||||
)
|
||||
|
||||
@@ -81,25 +81,15 @@ endif
|
||||
# These flags are passed via `cargo rustc` and only apply to the final rustc
|
||||
# invocation (i.e., only the top-level crate, not its dependencies).
|
||||
cargo_rustc_flags = $(CARGO_RUSTCFLAGS)
|
||||
ifndef DEVELOPER_OPTIONS
|
||||
ifndef MOZ_DEBUG_RUST
|
||||
ifdef RUST_LTO_ELIGIBLE
|
||||
# Enable link-time optimization for release builds, but not when linking
|
||||
# gkrust_gtest. And not when doing cross-language LTO.
|
||||
ifndef MOZ_LTO_RUST_CROSS
|
||||
# Never enable when sancov is enabled to work around https://github.com/rust-lang/rust/issues/90300.
|
||||
ifeq (,$(RUST_SANCOV_FLAGS))
|
||||
# Never enable when coverage is enabled to work around https://github.com/rust-lang/rust/issues/90045.
|
||||
ifndef MOZ_CODE_COVERAGE
|
||||
# gkrust_gtest.
|
||||
ifeq (,$(findstring gkrust_gtest,$(RUST_LIBRARY_FILE)))
|
||||
cargo_rustc_flags += -Clto$(if $(filter full,$(MOZ_LTO_RUST_CROSS)),=fat)
|
||||
cargo_rustc_flags += -Clto
|
||||
endif
|
||||
# We need -Cembed-bitcode=yes for all crates when using -Clto.
|
||||
RUSTFLAGS += -Cembed-bitcode=yes
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef CARGO_INCREMENTAL
|
||||
export CARGO_INCREMENTAL
|
||||
@@ -243,9 +233,7 @@ endef
|
||||
$(foreach san,ASAN TSAN UBSAN,$(eval $(call sanitizer_options,$(san))))
|
||||
endif
|
||||
|
||||
# Force the target down to all bindgen callers, even those that may not
|
||||
# read BINDGEN_SYSTEM_FLAGS some way or another.
|
||||
export BINDGEN_EXTRA_CLANG_ARGS:=$(filter --target=%,$(BINDGEN_SYSTEM_FLAGS))
|
||||
export BINDGEN_EXTRA_CLANG_ARGS
|
||||
export CARGO_TARGET_DIR
|
||||
export RUSTFLAGS
|
||||
export RUSTC
|
||||
|
||||
Reference in New Issue
Block a user