Bug 1954359 - Don't pass LTO flags when compiling C/C++ sources from rust with GCC. r=firefox-build-system-reviewers,sergesanspaille

Differential Revision: https://phabricator.services.mozilla.com/D242082
This commit is contained in:
Mike Hommey
2025-03-19 07:06:18 +00:00
parent b91028cf5d
commit bddda2f167

View File

@@ -208,8 +208,12 @@ export CXXFLAGS_$(rust_host_cc_env_name)=$(HOST_CXX_BASE_FLAGS) $(COMPUTED_HOST_
# The cc crate will fill in for those flags anyways, but we do need the PGO and # The cc crate will fill in for those flags anyways, but we do need the PGO and
# LTO flags to fill in for what the cc crate doesn't handle # LTO flags to fill in for what the cc crate doesn't handle
# (e.g. -pgo-temporal-instrumentation) # (e.g. -pgo-temporal-instrumentation)
export CFLAGS_$(rust_cc_env_name)=$(CC_BASE_FLAGS) $(MOZ_LTO_CFLAGS) $(COMPUTED_CFLAGS) $(filter-out -fprofile-generate%,$(PGO_CFLAGS)) -DMOZILLA_CONFIG_H # We can't use LTO flags with GCC, though: https://github.com/rust-lang/rust/issues/138681
export CXXFLAGS_$(rust_cc_env_name)=$(CXX_BASE_FLAGS) $(MOZ_LTO_CFLAGS) $(COMPUTED_CXXFLAGS) $(filter-out -fprofile-generate%,$(PGO_CFLAGS)) -DMOZILLA_CONFIG_H ifneq (,$(filter clang%,$(CC_TYPE)))
RUST_LTO_CFLAGS=$(MOZ_LTO_CFLAGS)
endif
export CFLAGS_$(rust_cc_env_name)=$(CC_BASE_FLAGS) $(RUST_LTO_CFLAGS) $(COMPUTED_CFLAGS) $(filter-out -fprofile-generate%,$(PGO_CFLAGS)) -DMOZILLA_CONFIG_H
export CXXFLAGS_$(rust_cc_env_name)=$(CXX_BASE_FLAGS) $(RUST_LTO_CFLAGS) $(COMPUTED_CXXFLAGS) $(filter-out -fprofile-generate%,$(PGO_CFLAGS)) -DMOZILLA_CONFIG_H
else else
# Because cargo doesn't allow to distinguish builds happening for build # Because cargo doesn't allow to distinguish builds happening for build
# scripts/procedural macros vs. those happening for the rust target, # scripts/procedural macros vs. those happening for the rust target,