incr.comp.: Make sure cargo check is compatible with incremental compilation.

6f0a36d
Opened by Michael Woerister at 2023-04-05 17:42:25

So far incremental compilation did not bring any benefit for cargo check because incremental compilation only cached post-trans artifacts and the whole point of cargo check is to exit from compilation before the costly trans and LLVM parts.

With https://github.com/rust-lang/rust/pull/46004 this has changed and we'll keep adding more and more things to this pre-trans cache. As a consequence we should make sure that cargo check works in conjunction with CARGO_INCREMENTAL=1. It already might but we've never tested it and have no regression tests.

cc @nikomatsakis @rust-lang/cargo

  1. I just verified that CARGO_INCREMENTAL=1 cargo check is indeed passing -Z incremental, so I think we're good there! (once -Z incremental-queries isn't necessary I think).

    AFAIK we don't have a lot of tests in this regard though, it may be worth adding a few to Cargo maybe? (unsure though)

    Alex Crichton at 2017-11-17 13:57:16

  2. it may be worth adding a few to Cargo maybe?

    If it's not too much trouble, that would certainly help. And cargo would have to make sure to use a different cache directory for check builds than it uses for regular builds (or make sure that the crate disambiguator is different when building with check, which probably already is the case).

    I was mostly thinking of making sure that incr. comp. works well together with the other commandline options that cargo check invokes rustc with (just --emit=metadata?).

    Michael Woerister at 2017-11-17 14:04:49

  3. So, I've verified that everything works as expected. Would be great to have a regression test for this though.

    Michael Woerister at 2017-12-19 13:08:28

  4. rustc-perf runs every benchmark under one or more incremental + check combinations. Is that sufficient?

    Nicholas Nethercote at 2018-05-22 05:55:13

  5. I'd prefer a proper test in src/test/incremental.

    Michael Woerister at 2018-05-22 07:33:03