Bug 1923542 - Pass -fno-sized-deallocation and -fno-aligned-new C++ compiler flags through rust even when only passing base flags. r=firefox-build-system-reviewers,sergesanspaille

Differential Revision: https://phabricator.services.mozilla.com/D225009
This commit is contained in:
Mike Hommey 2024-10-09 20:17:30 +00:00
parent a4878cac12
commit b52439b6c6
2 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,10 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# The following flags are explicitly passed to C++ compiler invocations from rust
# even when only passing base flags. If you add more similarly important flags,
# please consider whether they should be handled the same way.
# See config/makefiles/rust.mk.
# We support C++14, but we don't want to enable the sized deallocation
# facilities in C++14 yet.
check_and_add_flag("-fno-sized-deallocation", compiler=cxx_compiler)

View File

@ -204,10 +204,13 @@ else
# This means C code built by rust is not going to be covered by sanitizers
# and coverage. But at least we control what compiler is being used,
# rather than relying on cc-rs guesses, which, sometimes fail us.
# -fno-sized-deallocation is important, though, as -fsized-deallocation may be the
# compiler default and we don't want it to be used
# (see build/moz.configure/flags.configure). Likewise with -fno-aligned-new.
export CFLAGS_$(rust_host_cc_env_name)=$(HOST_CC_BASE_FLAGS)
export CXXFLAGS_$(rust_host_cc_env_name)=$(HOST_CXX_BASE_FLAGS)
export CFLAGS_$(rust_cc_env_name)=$(CC_BASE_FLAGS)
export CXXFLAGS_$(rust_cc_env_name)=$(CXX_BASE_FLAGS)
export CXXFLAGS_$(rust_cc_env_name)=$(CXX_BASE_FLAGS) $(filter -fno-aligned-new -fno-sized-deallocation,$(COMPUTED_CXXFLAGS))
endif
# When host == target, cargo will compile build scripts with sanitizers enabled