Skip to content

Truly independent web browser

Meta: Run Rust debug assertions in sanitizer builds

Andreas Klingfd128f7998f3
diff --git a/Meta/CMake/rust_crate.cmake b/Meta/CMake/rust_crate.cmake
index 9d1ff249876..bac43d64dc7 100644
--- a/Meta/CMake/rust_crate.cmake
+++ b/Meta/CMake/rust_crate.cmake
@@ -388,6 +388,12 @@ function(_rust_crate_common_setup)
list(APPEND cargo_env "CARGO_TARGET_${target_upper}_RUSTFLAGS=${RUSTC_TARGET_FLAGS}")
+ # The optimized builds otherwise leave out every debug assertion, which then runs only in unit tests. A sanitizer
+ # build is one that is run to find bugs, so it checks them too.
+ if (ENABLE_ADDRESS_SANITIZER OR ENABLE_UNDEFINED_SANITIZER)
+ list(APPEND cargo_env "CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS=true")
+ endif()
+
if (RUSTC_WRAPPER)
list(APPEND cargo_env
"RUSTC_WRAPPER=${RUSTC_WRAPPER}"