]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_session/session.rs
Auto merge of #68298 - Mark-Simulacrum:binary-depdep-fix, r=petrochenkov
[rust.git] / src / librustc_session / session.rs
index 28acbd5713f12582aaa32330eb261cc5378c8739..d979247b46d3af81bb97d307a6575d966f0c3d97 100644 (file)
@@ -9,7 +9,7 @@
 use crate::filesearch;
 use crate::lint;
 use crate::search_paths::{PathKind, SearchPath};
-use crate::utils::duration_to_secs_str;
+use rustc_data_structures::profiling::duration_to_secs_str;
 use rustc_errors::ErrorReported;
 
 use rustc_data_structures::base_n;
@@ -398,9 +398,6 @@ pub fn verbose(&self) -> bool {
     pub fn time_passes(&self) -> bool {
         self.opts.debugging_opts.time_passes || self.opts.debugging_opts.time
     }
-    pub fn time_extended(&self) -> bool {
-        self.opts.debugging_opts.time_passes
-    }
     pub fn instrument_mcount(&self) -> bool {
         self.opts.debugging_opts.instrument_mcount
     }
@@ -941,15 +938,8 @@ pub fn build_session_with_source_map(
         .last()
         .unwrap_or(false);
     let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow);
-
     let can_emit_warnings = !(warnings_allow || cap_lints_allow);
 
-    let treat_err_as_bug = sopts.debugging_opts.treat_err_as_bug;
-    let dont_buffer_diagnostics = sopts.debugging_opts.dont_buffer_diagnostics;
-    let report_delayed_bugs = sopts.debugging_opts.report_delayed_bugs;
-
-    let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace;
-
     let write_dest = match diagnostics_output {
         DiagnosticOutput::Default => None,
         DiagnosticOutput::Raw(write) => Some(write),
@@ -958,14 +948,7 @@ pub fn build_session_with_source_map(
 
     let diagnostic_handler = rustc_errors::Handler::with_emitter_and_flags(
         emitter,
-        rustc_errors::HandlerFlags {
-            can_emit_warnings,
-            treat_err_as_bug,
-            report_delayed_bugs,
-            dont_buffer_diagnostics,
-            external_macro_backtrace,
-            ..Default::default()
-        },
+        sopts.debugging_opts.diagnostic_handler_flags(can_emit_warnings),
     );
 
     build_session_(sopts, local_crate_source_file, diagnostic_handler, source_map, lint_caps)
@@ -1044,6 +1027,12 @@ fn build_session_(
         CguReuseTracker::new_disabled()
     };
 
+    let prof = SelfProfilerRef::new(
+        self_profiler,
+        sopts.debugging_opts.time_passes || sopts.debugging_opts.time,
+        sopts.debugging_opts.time_passes,
+    );
+
     let sess = Session {
         target: target_cfg,
         host,
@@ -1063,7 +1052,7 @@ fn build_session_(
         imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
         incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
         cgu_reuse_tracker,
-        prof: SelfProfilerRef::new(self_profiler),
+        prof,
         perf_stats: PerfStats {
             symbol_hash_time: Lock::new(Duration::from_secs(0)),
             decode_def_path_tables_time: Lock::new(Duration::from_secs(0)),
@@ -1135,6 +1124,32 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
                   See https://github.com/rust-lang/rust/issues/61002 for details.",
         );
     }
+
+    // Sanitizers can only be used on some tested platforms.
+    if let Some(ref sanitizer) = sess.opts.debugging_opts.sanitizer {
+        const ASAN_SUPPORTED_TARGETS: &[&str] =
+            &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
+        const TSAN_SUPPORTED_TARGETS: &[&str] =
+            &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
+        const LSAN_SUPPORTED_TARGETS: &[&str] =
+            &["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
+        const MSAN_SUPPORTED_TARGETS: &[&str] = &["x86_64-unknown-linux-gnu"];
+
+        let supported_targets = match *sanitizer {
+            Sanitizer::Address => ASAN_SUPPORTED_TARGETS,
+            Sanitizer::Thread => TSAN_SUPPORTED_TARGETS,
+            Sanitizer::Leak => LSAN_SUPPORTED_TARGETS,
+            Sanitizer::Memory => MSAN_SUPPORTED_TARGETS,
+        };
+
+        if !supported_targets.contains(&&*sess.opts.target_triple.triple()) {
+            sess.err(&format!(
+                "{:?}Sanitizer only works with the `{}` target",
+                sanitizer,
+                supported_targets.join("` or `")
+            ));
+        }
+    }
 }
 
 /// Hash value constructed out of all the `-C metadata` arguments passed to the