mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1672306 - Don't enable rust "global" LTO when cross LTO is enabled. r=firefox-build-system-reviewers,dmajor
This avoids a sort of duplication of work between both, because the linker will eventually LTO-compile everything, so we technically don't really need the extra step of the rust compiler doing an intermediate LTO on the static libraries it produces. Differential Revision: https://phabricator.services.mozilla.com/D94224
This commit is contained in:
parent
38f9a7cc9f
commit
6504260166
@ -264,6 +264,6 @@ set_config('MOZ_LTO', lto.enabled)
|
||||
set_define('MOZ_LTO', lto.enabled)
|
||||
set_config('MOZ_LTO_CFLAGS', lto.cflags)
|
||||
set_config('MOZ_LTO_LDFLAGS', lto.ldflags)
|
||||
set_config('MOZ_LTO_RUST', lto.rust_lto)
|
||||
set_config('MOZ_LTO_RUST_CROSS', lto.rust_lto)
|
||||
add_old_configure_assignment('MOZ_LTO_CFLAGS', lto.cflags)
|
||||
add_old_configure_assignment('MOZ_LTO_LDFLAGS', lto.ldflags)
|
||||
|
@ -59,7 +59,8 @@ cargo_rustc_flags = $(CARGO_RUSTCFLAGS)
|
||||
ifndef DEVELOPER_OPTIONS
|
||||
ifndef MOZ_DEBUG_RUST
|
||||
# Enable link-time optimization for release builds, but not when linking
|
||||
# gkrust_gtest.
|
||||
# gkrust_gtest. And not when doing cross-language LTO.
|
||||
ifndef MOZ_LTO_RUST_CROSS
|
||||
ifeq (,$(findstring gkrust_gtest,$(RUST_LIBRARY_FILE)))
|
||||
cargo_rustc_flags += -Clto
|
||||
endif
|
||||
@ -70,6 +71,7 @@ RUSTFLAGS += -Cembed-bitcode=yes
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef CARGO_INCREMENTAL
|
||||
export CARGO_INCREMENTAL
|
||||
@ -194,7 +196,7 @@ ifdef MOZ_PGO_RUST
|
||||
rust_pgo_flags := $(if $(MOZ_PROFILE_GENERATE),-C profile-generate=$(topobjdir)) $(if $(MOZ_PROFILE_USE),-C profile-use=$(PGO_PROFILE_PATH))
|
||||
endif
|
||||
|
||||
$(target_rust_ltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS) $(if $(MOZ_LTO_RUST),-Clinker-plugin-lto) $(rust_pgo_flags)
|
||||
$(target_rust_ltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS) $(if $(MOZ_LTO_RUST_CROSS),-Clinker-plugin-lto) $(rust_pgo_flags)
|
||||
$(target_rust_nonltoable): RUSTFLAGS:=$(rustflags_override) $(rustflags_sancov) $(RUSTFLAGS)
|
||||
|
||||
TARGET_RECIPES := $(target_rust_ltoable) $(target_rust_nonltoable)
|
||||
@ -306,12 +308,12 @@ $(RUST_LIBRARY_FILE): force-cargo-library-build
|
||||
# When we are building in --enable-release mode; we add an additional check to confirm
|
||||
# that we are not importing any networking-related functions in rust code. This reduces
|
||||
# the chance of proxy bypasses originating from rust code.
|
||||
# The check only works when rust code is built with -Clto but without MOZ_LTO_RUST.
|
||||
# The check only works when rust code is built with -Clto but without MOZ_LTO_RUST_CROSS.
|
||||
# Sanitizers and sancov also fail because compiler-rt hooks network functions.
|
||||
ifndef MOZ_PROFILE_GENERATE
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
ifeq (,$(rustflags_sancov)$(MOZ_ASAN)$(MOZ_TSAN)$(MOZ_UBSAN))
|
||||
ifndef MOZ_LTO_RUST
|
||||
ifndef MOZ_LTO_RUST_CROSS
|
||||
ifneq (,$(filter -Clto,$(cargo_rustc_flags)))
|
||||
$(call py_action,check_binary,--target --networking $@)
|
||||
endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user