Emit option_env!("DEFMT_LOG") in log macros so rustc depinfo can track it#938
Conversation
DEFMT_LOGDEFMT_LOG
b663d7b to
bc87d7c
Compare
DEFMT_LOGoption_env!("DEFMT_LOG") in log macros so rustc depinfo can track it
|
Hey @kaspar030, thank you for the PR! That sounds like a good improvement. Did you test if this patch in fact results in sccache to pick up the changed environment variable? Also I am wondering how that impacts build-time, since suddenly you have |
Yes it does! One can also observe the depinfo entries: With this branch: here is a Without this branch, there's no
I did a quick test with both this branch and defmt from crates.io, on my box (16core zen3), our https server example builds in ~13.5 sec. This is only a quick test but results look very similar. with this changewithout this change(Don't get confused, we're wrapping |
|
Is there anything I can do here? I actually consider this a fix to a correctness bug - defmt users are compile time affected by an environment variable, but don't use the rustc facilities to mention that. |
In Ariel OS, we've seen sccache not picking up changes to
DEFMT_LOG.Like,
DEFMT_LOG=debug, run, see debug output of all cratesDEFMT_LOG=infoWith sccache disabled, the second build only shows info messages.
With sccache enabled, we still see
debugmessages for all but the application crate.While cargo seems to rebuild
defmt-macros, sccache seems to not pick that up for users of defmt. I think this is because the proc macro reads the env "at runtime" (usingstd::env::var()), which sccache cannot see.sccacheuses rustc'sdepinfo, which does emit the use of env variables at compile time when read usingenv!()oroption_env!(). So, emitting a plainoption_env!("DEFMT_LOG")next to the log macros fixes the issue.