diff options
| author | Michael Goulet <michael@errs.io> | 2023-02-08 20:01:25 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-08 20:01:25 -0800 |
| commit | 32bb73eedef784a3a4a3225805e0977014cd5c72 (patch) | |
| tree | c606c24a7b6e337da12e23bde88b383ce582c178 /compiler | |
| parent | 04f770839d66d6881af44e28de69589dd6f8133e (diff) | |
| parent | f95b553eb4b6a2a0bf45e48c0cc5e9f635ba1e0c (diff) | |
| download | rust-32bb73eedef784a3a4a3225805e0977014cd5c72.tar.gz rust-32bb73eedef784a3a4a3225805e0977014cd5c72.zip | |
Rollup merge of #107761 - oli-obk:miri_🪵, r=TaKO8Ki
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.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/tests.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_log/src/lib.rs | 21 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 2 |
4 files changed, 6 insertions, 34 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index a392d70f100..bdf2978cee2 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -229,10 +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)) => { @@ -1251,16 +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 +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(); diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 52a4e0e7418..5165ee424e3 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -758,7 +758,6 @@ fn test_unstable_options_tracking_hash() { tracked!(link_only, true); tracked!(llvm_plugins, vec![String::from("plugin_name")]); tracked!(location_detail, LocationDetail { file: true, line: false, column: false }); - tracked!(log_backtrace, Some("filter".to_string())); tracked!(maximal_hir_to_mir_coverage, true); tracked!(merge_functions, Some(MergeFunctions::Disabled)); tracked!(mir_emit_retag, true); diff --git a/compiler/rustc_log/src/lib.rs b/compiler/rustc_log/src/lib.rs index fc1cabd2de9..019fdc30dce 100644 --- a/compiler/rustc_log/src/lib.rs +++ b/compiler/rustc_log/src/lib.rs @@ -54,25 +54,12 @@ use tracing_subscriber::fmt::{ use tracing_subscriber::layer::SubscriberExt; pub fn init_rustc_env_logger() -> Result<(), Error> { - init_rustc_env_logger_with_backtrace_option(&None) -} - -pub fn init_rustc_env_logger_with_backtrace_option( - backtrace_target: &Option<String>, -) -> Result<(), Error> { - init_env_logger_with_backtrace_option("RUSTC_LOG", backtrace_target) + init_env_logger("RUSTC_LOG") } /// In contrast to `init_rustc_env_logger` this allows you to choose an env var /// other than `RUSTC_LOG`. pub fn init_env_logger(env: &str) -> Result<(), Error> { - init_env_logger_with_backtrace_option(env, &None) -} - -pub fn init_env_logger_with_backtrace_option( - env: &str, - backtrace_target: &Option<String>, -) -> Result<(), Error> { let filter = match env::var(env) { Ok(env) => EnvFilter::new(env), _ => EnvFilter::default().add_directive(Directive::from(LevelFilter::WARN)), @@ -106,8 +93,8 @@ pub fn init_env_logger_with_backtrace_option( let layer = layer.with_thread_ids(true).with_thread_names(true); let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer); - match backtrace_target { - Some(str) => { + match env::var(format!("{env}_BACKTRACE")) { + Ok(str) => { let fmt_layer = tracing_subscriber::fmt::layer() .with_writer(io::stderr) .without_time() @@ -115,7 +102,7 @@ pub fn init_env_logger_with_backtrace_option( let subscriber = subscriber.with(fmt_layer); tracing::subscriber::set_global_default(subscriber).unwrap(); } - None => { + Err(_) => { tracing::subscriber::set_global_default(subscriber).unwrap(); } }; diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 0db4d85ff4b..61cb81aec3d 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1413,8 +1413,6 @@ options! { "what location details should be tracked when using caller_location, either \ `none`, or a comma separated list of location details, for which \ valid options are `file`, `line`, and `column` (default: `file,line,column`)"), - log_backtrace: Option<String> = (None, parse_opt_string, [TRACKED], - "add a backtrace along with logging"), ls: bool = (false, parse_bool, [UNTRACKED], "list the symbols defined by a library crate (default: no)"), macro_backtrace: bool = (false, parse_bool, [UNTRACKED], |
