Hi, I was wondering if there's anyway to test a new language item without rebuilding the compiler from stage 0 every time. Since it's a new lang item, it's my understanding that it has to be annotated with
#[cfg(not(bootstrap))] so that it can be processed in stage 1. I'm concerned with compile times for testing this feature; and if adding the feature will slow down compile times for as long as it's not in the beta release, so was wondering if there's anyway to test libcore requiring stage 1 without recompiling or for my specific use case of adding a lang item
I might be misunderstanding what you mean, but:
When you add a lang item, it recompiles stage0 std because there have been changes to those files - the result artefact isn't really different because the lang item will have to be annotated with
#[cfg_attr(not(bootstrap), lang = ".."] to compile successfully (otherwise the beta compiler that we start with doesn't recognize the lang item) and so there's no semantic change.
Then, when compiling stage1 std, the result is different - we're now compiling with a rustc that knows about that new lang item.
Adding a new lang item results in stage0 std being recompiled - it's potentially possible that this isn't necessary because with only the addition of the lang item then it isn't meaningfully different (but detecting that probably isn't worth it). However, there isn't anything inherent about adding a lang item that will slow down compile times until it is in beta - any change to std will require stage0 std be recompiled, that's why it always happens when you do a local build (it just doesn't get rebuilt unnecessarily unless you change std, most of the time you don't change std when working on rustc) and always gets built in CI. There's nothing about the fact that the lang item isn't in the beta toolchain that would require std be compiled any more or less - it always needs compiled.
Does that make sense?
(credit for image: @mark-i-m)
hmmmm I think it kind of makes sense, will have to let it stir for a bit for it to sink in
you can also use
--keep-stage 0 which will skip rebuilding std. That has the potential to break things though, it doesn't actually check whether std should be recompiled. https://rustc-dev-guide.rust-lang.org/building/suggested.html?highlight=keep-stage#incremental-builds-with---keep-stage