Modifying and testing libraries without re-bootstrapping

(I put this in the “libs” category, but it’s really about the build system.)

When working in std (or crates it’s a facade for) my workflow is something like:

  • Make additions/changes in src/libcollections and src/libcollectionstest
  • Run make check-stage1-collectionstest
  • Wait 18 minutes or so for the entire compiler to rebuild
  • Watch tests fail
  • Repeat

This is not great.

As far as I understand, the compiler is rebuilt in case my changes would affect its behaviour, in order to test that new behaviour. But I often don’t care about that, I’d like to modify and test libcollections independently, as if it were separate from the compiler.

Is there a way to run these unit tests without rebuilding the compiler? If not, could we add one? I’ve tried make check-stage0-collectionstest, but it fails with:

x86_64-unknown-linux-gnu/stage0/test/collectionstesttest-x86_64-unknown-linux-gnu: symbol lookup error: x86_64-unknown-linux-gnu/stage0/test/collectionstesttest-x86_64-unknown-linux-gnu: undefined symbol: _ZN3vec12Vec$LT$T$GT$5drain14_MSG_FILE_LINE20hac99776d0c7cff38AiiE
6 Likes

I’m battling this right now as well. If the collection tests were not split out, I think we could just use NO_REBUILD=1 and have only the impl & tests recompiled correctly together.

Maybe we could add an option to the makefiles similar to NO_REBUILD that would skip re-building previous stages. If there are changes, just rebuild from stage1, not stage0.

I wish I could compile in 18 minutes. I’m running on a 7-year old macbook pro… compilation for me is closer to an hour. An entire night if I try all stages. I’m only working on testing stories until I have the time to order/build my replacement desktop.

Edit: So I was an idiot and initially called ./configure with --enable-debug… don’t do that unless you really need to. Recompiling changes in src/librustc_typeck and running a single test went from 32 minutes to 9. It still takes well over an hour to do a full compilation though (timing it now).

1 Like

Eddyb is working on making stage0 tests work in PR #26405. (And pasting his fix in the makefile will work)

Not sure about testing, but this script builds libstd only from your compiler source: https://gist.github.com/jethrogb/e64bf2958aadae6bdcfd

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.