]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki
authorMichael Goulet <michael@errs.io>
Thu, 9 Feb 2023 04:01:25 +0000 (20:01 -0800)
committerGitHub <noreply@github.com>
Thu, 9 Feb 2023 04:01:25 +0000 (20:01 -0800)
Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion

fixes https://github.com/rust-lang/miri/issues/2778

this was introduced in https://github.com/rust-lang/rust/pull/104645, so this PR reverts the flag-part and uses an env var instead.

1  2 
compiler/rustc_driver_impl/src/lib.rs

index a392d70f100a4826ddc9e6227c7c20bcabbdbccc,86807098723aa567d0f31cf39fd5081528792309..bdf2978cee2587f90fd93661ca1d6151965293cd
@@@ -229,10 -229,6 +229,6 @@@ fn run_compiler
          registry: diagnostics_registry(),
      };
  
-     if !tracing::dispatcher::has_been_set() {
-         init_rustc_env_logger_with_backtrace_option(&config.opts.unstable_opts.log_backtrace);
-     }
      match make_input(config.opts.error_format, &matches.free) {
          Err(reported) => return Err(reported),
          Ok(Some(input)) => {
                  }
              }
  
 -            let mut gctxt = queries.global_ctxt()?;
 +            // Make sure name resolution and macro expansion is run.
 +            queries.global_ctxt()?;
 +
              if callbacks.after_expansion(compiler, queries) == Compilation::Stop {
                  return early_exit();
              }
  
              // Make sure the `output_filenames` query is run for its side
              // effects of writing the dep-info and reporting errors.
 -            gctxt.enter(|tcx| tcx.output_filenames(()));
 +            queries.global_ctxt()?.enter(|tcx| tcx.output_filenames(()));
  
              if sess.opts.output_types.contains_key(&OutputType::DepInfo)
                  && sess.opts.output_types.len() == 1
                  return early_exit();
              }
  
 -            gctxt.enter(|tcx| {
 +            queries.global_ctxt()?.enter(|tcx| {
                  let result = tcx.analysis(());
                  if sess.opts.unstable_opts.save_analysis {
                      let crate_name = tcx.crate_name(LOCAL_CRATE);
                  result
              })?;
  
 -            drop(gctxt);
 -
              if callbacks.after_analysis(compiler, queries) == Compilation::Stop {
                  return early_exit();
              }
@@@ -1200,9 -1196,11 +1196,9 @@@ pub fn report_ice(info: &panic::PanicIn
      if !info.payload().is::<rustc_errors::ExplicitBug>()
          && !info.payload().is::<rustc_errors::DelayedBugPanic>()
      {
 -        let mut d = rustc_errors::Diagnostic::new(rustc_errors::Level::Bug, "unexpected panic");
 -        handler.emit_diagnostic(&mut d);
 +        handler.emit_err(session_diagnostics::Ice);
      }
  
 -    handler.emit_note(session_diagnostics::Ice);
      handler.emit_note(session_diagnostics::IceBugReport { bug_report_url });
      handler.emit_note(session_diagnostics::IceVersion {
          version: util::version_str!().unwrap_or("unknown_version"),
@@@ -1251,16 -1249,7 +1247,7 @@@ pub fn install_ice_hook() 
  /// This allows tools to enable rust logging without having to magically match rustc's
  /// tracing crate version.
  pub fn init_rustc_env_logger() {
-     init_rustc_env_logger_with_backtrace_option(&None);
- }
- /// This allows tools to enable rust logging without having to magically match rustc's
- /// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to
- /// choose a target module you wish to show backtraces along with its logging.
- pub fn init_rustc_env_logger_with_backtrace_option(backtrace_target: &Option<String>) {
-     if let Err(error) = rustc_log::init_rustc_env_logger_with_backtrace_option(backtrace_target) {
-         early_error(ErrorOutputType::default(), &error.to_string());
-     }
+     init_env_logger("RUSTC_LOG");
  }
  
  /// This allows tools to enable rust logging without having to magically match rustc's
@@@ -1324,6 -1313,7 +1311,7 @@@ mod signal_handler 
  pub fn main() -> ! {
      let start_time = Instant::now();
      let start_rss = get_resident_set_size();
+     init_rustc_env_logger();
      signal_handler::install();
      let mut callbacks = TimePassesCallbacks::default();
      install_ice_hook();