diff --git a/config/rules.mk b/config/rules.mk index 6f2ddb65146e..2702ad58bb1e 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -906,7 +906,7 @@ cargo_target_flag := --target=$(RUST_TARGET) # Permit users to pass flags to cargo from their mozconfigs (e.g. --color=always). cargo_build_flags = $(CARGOFLAGS) -ifndef MOZ_DEBUG +ifndef MOZ_DEBUG_RUST cargo_build_flags += --release endif cargo_build_flags += --frozen @@ -936,8 +936,8 @@ endif ifndef MOZ_OPTIMIZE rustflags = -C opt-level=0 # Unfortunately, -C opt-level=0 implies -C debug-assertions, so we need -# to explicitly disable them when MOZ_DEBUG is not set. -ifndef MOZ_DEBUG +# to explicitly disable them when MOZ_DEBUG_RUST is not set. +ifndef MOZ_DEBUG_RUST rustflags += -C debug-assertions=no endif rustflags_override = RUSTFLAGS='$(rustflags)' diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index d235784f75d7..afe61cb3bfb1 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -88,7 +88,7 @@ Gecko_IsInDocument(RawGeckoNodeBorrowed aNode) return aNode->IsInComposedDoc(); } -#ifdef DEBUG +#ifdef MOZ_DEBUG_RUST bool Gecko_FlattenedTreeParentIsParent(RawGeckoNodeBorrowed aNode) { diff --git a/moz.configure b/moz.configure index 42d9b9573b97..9e241dfbec91 100644 --- a/moz.configure +++ b/moz.configure @@ -103,6 +103,20 @@ js_option('--enable-debug', add_old_configure_assignment('MOZ_DEBUG', depends('--enable-debug')(lambda v: bool(v))) +imply_option('--enable-rust-debug', + depends('--enable-debug')(lambda v: bool(v) or None)) + +js_option('--enable-rust-debug', + help='Build Rust code with debug assertions turned on.') + +@depends('--enable-rust-debug') +def debug_rust(debug): + if debug: + return True + +set_config('MOZ_DEBUG_RUST', debug_rust) +set_define('MOZ_DEBUG_RUST', debug_rust) + include('build/moz.configure/pkg.configure') # Make this assignment here rather than in pkg.configure to avoid # requiring this file in unit tests. diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index 5b07dafdddcc..347f48ae9674 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -425,7 +425,7 @@ def cargo_output_directory(context, target_var): # in those directories. The directory structure depends not only # on the target, but also what sort of build we are doing. rust_build_kind = 'release' - if context.config.substs.get('MOZ_DEBUG'): + if context.config.substs.get('MOZ_DEBUG_RUST'): rust_build_kind = 'debug' return mozpath.join(context.config.substs[target_var], rust_build_kind) diff --git a/xpcom/string/nsSubstring.cpp b/xpcom/string/nsSubstring.cpp index 3a89e50c3857..a244a791568e 100644 --- a/xpcom/string/nsSubstring.cpp +++ b/xpcom/string/nsSubstring.cpp @@ -378,6 +378,10 @@ void Gecko_IncrementStringAdoptCount(void* aData) { MOZ_LOG_CTOR(aData, "StringAdopt", 1); } +#elif defined(MOZ_DEBUG_RUST) +void Gecko_IncrementStringAdoptCount(void *aData) +{ +} #endif void Gecko_FinalizeCString(nsACString* aThis)