From a27cae0f5fd8176b6c92f572e15beb9dae4de316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 6 Sep 2026 14:43:18 +0200 Subject: [PATCH] Cache sanitizer set in `Session` --- compiler/rustc_session/src/session.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 66d91a74e99..6b851250eae 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -422,6 +422,9 @@ pub struct Session { /// Config specifying targets' pointer authentication preference. pub pointer_auth_config: Option, + + /// Cached sanitizer set. + sanitizers: SanitizerSet, } #[derive(Clone, Copy)] @@ -1175,10 +1178,7 @@ impl Session { } pub fn sanitizers(&self) -> SanitizerSet { - self.opts - .unstable_opts - .sanitizer - .combine_with_defaults(self.target.options.default_sanitizers) + self.sanitizers } pub fn pointer_authentication(&self) -> bool { @@ -1385,6 +1385,9 @@ pub fn build_session( let pointer_auth_config: Option = PointerAuthConfig::from_raw(&sopts.unstable_opts.pointer_authentication, &target); + let sanitizers = + sopts.unstable_opts.sanitizer.combine_with_defaults(target.options.default_sanitizers); + let sess = Session { target, host, @@ -1420,6 +1423,7 @@ pub fn build_session( mir_opt_bisect_eval_count: AtomicUsize::new(0), removed_rustc_main_attr: AtomicBool::new(false), pointer_auth_config, + sanitizers, }; validate_commandline_args_with_session_available(&sess);