Stream: t-compiler/const-eval

Topic: RUST_LOG logging


RalfJ (Oct 31 2018 at 08:29, on Zulip):

I am try to make miri set RUST_LOG based on MIRI_LOG, so I don't have to always set both. However, I do not even understand how we can have two logging "things" in the same project, isn't that stuff supposed to be global? @Oli any idea what is going on here?

oli (Oct 31 2018 at 08:29, on Zulip):

jop

oli (Oct 31 2018 at 08:30, on Zulip):

rustc uses a different log crate

oli (Oct 31 2018 at 08:30, on Zulip):

thus, different global statics

RalfJ (Oct 31 2018 at 08:30, on Zulip):

Also miri contains some funny code to change the logging format, but rustc doesn't, so messages look very different depending on where they come from

oli (Oct 31 2018 at 08:30, on Zulip):

thus completely separate logging

RalfJ (Oct 31 2018 at 08:30, on Zulip):

rustc uses a different log crate

different crate? so extern crate log; is not the same thing for both?

oli (Oct 31 2018 at 08:30, on Zulip):

I wrote the funny miri code, feel free to nuke it, it's usefulness is not existing anymore

oli (Oct 31 2018 at 08:30, on Zulip):

rustc uses a different log crate

different crate? so extern crate log; is not the same thing for both?

oli (Oct 31 2018 at 08:31, on Zulip):

yea

RalfJ (Oct 31 2018 at 08:31, on Zulip):

woah. how that?

oli (Oct 31 2018 at 08:31, on Zulip):

"it's complicated" and I forget a lot of the details

oli (Oct 31 2018 at 08:31, on Zulip):

but it's a mess

oli (Oct 31 2018 at 08:31, on Zulip):

crates.io log vs rustc-distributed log

RalfJ (Oct 31 2018 at 08:31, on Zulip):

sounds like it

RalfJ (Oct 31 2018 at 08:31, on Zulip):

but okay I guess this means I need a hook on the rustc side to rebuild the logger, cant do it from miri

oli (Oct 31 2018 at 08:32, on Zulip):

we used to use the rustd log, but it caused all kinds of problems

oli (Oct 31 2018 at 08:32, on Zulip):

"rebuild"?

oli (Oct 31 2018 at 08:32, on Zulip):

we already are calling rustc_driver::init_logger()

RalfJ (Oct 31 2018 at 08:34, on Zulip):

I am changing RUST_LOG during execution

RalfJ (Oct 31 2018 at 08:34, on Zulip):

but the change isnt picked up

RalfJ (Oct 31 2018 at 08:35, on Zulip):

so I need to to reread the config

oli (Oct 31 2018 at 08:36, on Zulip):

yea, just call rustc_driver::init_logger() I think

oli (Oct 31 2018 at 08:36, on Zulip):

or make the change before the first call to it

RalfJ (Oct 31 2018 at 08:56, on Zulip):

I want to do the change late so that it applies to as little of rustc's own stuff as possible

RalfJ (Oct 31 2018 at 08:56, on Zulip):

though with the query-based architecture, that's kind of hard

RalfJ (Oct 31 2018 at 09:01, on Zulip):
thread 'main' panicked at 'env_logger::init should not be called after logger initialized: SetLoggerError(())', libcore/result.rs:1009:5

:(

oli (Oct 31 2018 at 09:06, on Zulip):

uhm

oli (Oct 31 2018 at 09:06, on Zulip):

just don't call it at program start

RalfJ (Oct 31 2018 at 09:06, on Zulip):

but then we will get no logging at all for that even if we want to, right?

oli (Oct 31 2018 at 09:07, on Zulip):

or make it if env::var("RUST_LOG") { rustc_driver::init_logger() }

oli (Oct 31 2018 at 09:07, on Zulip):

and create a second RUST_LATE_LOG for miri to turn it on later if RUST_LOG wasn't already specified

oli (Oct 31 2018 at 09:08, on Zulip):

(and convert the env var from RUST_LATE_LOG to RUST_LOG then)

RalfJ (Oct 31 2018 at 09:17, on Zulip):

Hm. For now I just do the setting a bit earlier

RalfJ (Oct 31 2018 at 09:17, on Zulip):

with all these queries, we wouldn't get a clean separation between the miri execution and the CTFE executions anyway, right?

RalfJ (Oct 31 2018 at 09:18, on Zulip):

the latter can happen arbitrarily late

RalfJ (Oct 31 2018 at 09:18, on Zulip):

so we'd have to switch every time we fire a query, or so...

oli (Oct 31 2018 at 09:20, on Zulip):

hmm... I think we're late enough in the process for that not to happen

oli (Oct 31 2018 at 09:20, on Zulip):

maybe a few times

oli (Oct 31 2018 at 09:20, on Zulip):

once the collector is done, there should be little that we need that hasn't already been cached

RalfJ (Oct 31 2018 at 09:22, on Zulip):

collector? where is that done?

RalfJ (Oct 31 2018 at 09:23, on Zulip):

for now I got this: https://github.com/solson/miri/pull/502/files

oli (Oct 31 2018 at 09:25, on Zulip):

part of the compiler steps. It's basically the driving force behind everything

RalfJ (Oct 31 2018 at 09:26, on Zulip):

I mean, where in src/bin/miri.rs is that done?

RalfJ (Oct 31 2018 at 09:26, on Zulip):

as in, where would then be a good place to initialize logging? :D

oli (Oct 31 2018 at 09:27, on Zulip):

oh, I'd init logging where the miri interpretation is triggered

oli (Oct 31 2018 at 09:28, on Zulip):

so in https://github.com/solson/miri/pull/502/files#diff-c3d602c5c8035a16699ce9c015bfeceaR113

RalfJ (Oct 31 2018 at 09:52, on Zulip):

that seems to work, great :)

Last update: Nov 15 2019 at 20:05UTC