commit 49943ea220c0b2d15a692b540d496a7e298f395c
parent 35c0b153f76adfb93a6ab6b236b2a08409016c96
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Wed, 12 Nov 2025 01:39:01 +0000
Bug 1992321 - Don't prevent mozilla-config.h inclusion in all rust-built C++. r=glandium,jnicol
There were two things that needed it:
* glslopt, which does it explicitly now (bug 1998927).
* whatsys, which relied on the min() macro from windows.h which we undefine
via NOMINMAX, which is fixed too (bug 1998928).
So this should be good to go now.
Differential Revision: https://phabricator.services.mozilla.com/D271601
Diffstat:
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/config/makefiles/rust.mk b/config/makefiles/rust.mk
@@ -197,11 +197,8 @@ CXX_BASE_FLAGS += -DUNICODE
endif
ifneq (1,$(PASS_ONLY_BASE_CFLAGS_TO_RUST))
-# -DMOZILLA_CONFIG_H is added to prevent mozilla-config.h from injecting anything
-# in C/C++ compiles from rust. That's not needed in the other branch because the
-# base flags don't force-include mozilla-config.h.
-export CFLAGS_$(rust_host_cc_env_name)=$(HOST_CC_BASE_FLAGS) $(COMPUTED_HOST_CFLAGS) -DMOZILLA_CONFIG_H
-export CXXFLAGS_$(rust_host_cc_env_name)=$(HOST_CXX_BASE_FLAGS) $(COMPUTED_HOST_CXXFLAGS) -DMOZILLA_CONFIG_H
+export CFLAGS_$(rust_host_cc_env_name)=$(HOST_CC_BASE_FLAGS) $(COMPUTED_HOST_CFLAGS)
+export CXXFLAGS_$(rust_host_cc_env_name)=$(HOST_CXX_BASE_FLAGS) $(COMPUTED_HOST_CXXFLAGS)
# We exclude -fprofile-generate from the PGO flags because on non-cross compiles,
# that affects build scripts, and they fail to link because the linker flags are
# not adequate, and also, we don't want to run instrumented build scripts.
@@ -212,8 +209,8 @@ export CXXFLAGS_$(rust_host_cc_env_name)=$(HOST_CXX_BASE_FLAGS) $(COMPUTED_HOST_
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
+export CFLAGS_$(rust_cc_env_name)=$(CC_BASE_FLAGS) $(RUST_LTO_CFLAGS) $(COMPUTED_CFLAGS) $(filter-out -fprofile-generate%,$(PGO_CFLAGS))
+export CXXFLAGS_$(rust_cc_env_name)=$(CXX_BASE_FLAGS) $(RUST_LTO_CFLAGS) $(COMPUTED_CXXFLAGS) $(filter-out -fprofile-generate%,$(PGO_CFLAGS))
else
# Because cargo doesn't allow to distinguish builds happening for build
# scripts/procedural macros vs. those happening for the rust target,
diff --git a/gfx/wr/swgl/build.rs b/gfx/wr/swgl/build.rs
@@ -204,15 +204,13 @@ fn main() {
build
.flag("/std:c++17")
.flag("/EHs-")
- .flag("/GR-")
- .flag("/UMOZILLA_CONFIG_H");
+ .flag("/GR-");
} else {
build
.flag("-std=c++17")
.flag("-fno-exceptions")
.flag("-fno-rtti")
- .flag("-fno-math-errno")
- .flag("-UMOZILLA_CONFIG_H");
+ .flag("-fno-math-errno");
}
// SWGL relies heavily on inlining for performance so override -Oz with -O2
if tool.args().contains(&"-Oz".into()) {