diff --git a/build/moz.configure/lto-pgo.configure b/build/moz.configure/lto-pgo.configure index 7db7b66f140a..c4436d24db36 100644 --- a/build/moz.configure/lto-pgo.configure +++ b/build/moz.configure/lto-pgo.configure @@ -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) diff --git a/config/makefiles/rust.mk b/config/makefiles/rust.mk index 584319b6d572..a5d451b0dc1b 100644 --- a/config/makefiles/rust.mk +++ b/config/makefiles/rust.mk @@ -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