Skip to content

Build a new incr comp session dir from scratch every time#159287

Draft
bjorn3 wants to merge 5 commits into
rust-lang:mainfrom
bjorn3:incr_comp_session_from_scratch
Draft

Build a new incr comp session dir from scratch every time#159287
bjorn3 wants to merge 5 commits into
rust-lang:mainfrom
bjorn3:incr_comp_session_from_scratch

Conversation

@bjorn3

@bjorn3 bjorn3 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Rather than copying the old incr comp dir and then modifying it. This saves a copy/hardlink for files that are modified. And it removes the need for accurate work product tracking to avoid accumulating cruft, which is non-trivial. We don't accurately track the pre-LTO bitcode files for ThinLTO for example.

Based on #159225
Part of rust-lang/compiler-team#908

bjorn3 added 5 commits July 8, 2026 19:45
Previously we would still try to rename the incr comp session dir after
deleting it.
In both cases the incr comp session dir should no longer be accessed.
This will allow introducing a separate incr comp session dir for the
post LTO artifacts in the future. In addition it statically encodes the
lifetime of the incr comp session rather than requiring an enum behind a
mutex stored in the Session.
Rather than copying the old incr comp dir and then modifying it. This
saves a copy/hardlink for files that are modified. And it removes the
need for accurate work product tracking to avoid accumulating cruft,
which is non-trivial. We don't accurately track the pre-LTO bitcode
files for ThinLTO for example.

FIXME cleanup
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 14, 2026
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
error[E0308]: mismatched types
   --> src/librustdoc/doctest.rs:262:9
    |
261 |     } = match result {
    |               ------ this expression has type `(Result<Option<CreateRunnableDocTests>, String>, Option<...>)`
262 |         Ok(Some(collector)) => collector,
    |         ^^^^^^^^^^^^^^^^^^^ expected `(Result<Option<...>, ...>, ...)`, found `Result<_, _>`
    |
    = note: expected tuple `(std::result::Result<std::option::Option<CreateRunnableDocTests>, std::string::String>, std::option::Option<IncrCompSession>)`
                found enum `std::result::Result<_, _>`
    = note: the full name for the type has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/build/rustdoc/e2ade74941381a74/out/rustdoc-e2ade74941381a74.long-type-5676048101907234966.txt'
    = note: consider using `--verbose` to print the full type name to the console

error[E0308]: mismatched types
   --> src/librustdoc/doctest.rs:263:9
    |
261 |     } = match result {
    |               ------ this expression has type `(Result<Option<CreateRunnableDocTests>, String>, Option<...>)`
262 |         Ok(Some(collector)) => collector,
263 |         Ok(None) => return,
    |         ^^^^^^^^ expected `(Result<Option<...>, ...>, ...)`, found `Result<_, _>`
    |
    = note: expected tuple `(std::result::Result<std::option::Option<CreateRunnableDocTests>, std::string::String>, std::option::Option<IncrCompSession>)`
                found enum `std::result::Result<_, _>`
    = note: the full name for the type has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/build/rustdoc/e2ade74941381a74/out/rustdoc-e2ade74941381a74.long-type-5676048101907234966.txt'
    = note: consider using `--verbose` to print the full type name to the console

error[E0308]: mismatched types
   --> src/librustdoc/doctest.rs:264:9
    |
261 |     } = match result {
    |               ------ this expression has type `(Result<Option<CreateRunnableDocTests>, String>, Option<...>)`
...
264 |         Err(error) => {
    |         ^^^^^^^^^^ expected `(Result<Option<...>, ...>, ...)`, found `Result<_, _>`
    |
    = note: expected tuple `(std::result::Result<std::option::Option<CreateRunnableDocTests>, std::string::String>, std::option::Option<IncrCompSession>)`
                found enum `std::result::Result<_, _>`
    = note: the full name for the type has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/build/rustdoc/e2ade74941381a74/out/rustdoc-e2ade74941381a74.long-type-5676048101907234966.txt'
    = note: consider using `--verbose` to print the full type name to the console

error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
   --> src/librustdoc/lib.rs:858:27
    |
852 |                 interface::run_compiler(config, |compiler| {
    |                                                 ---------- this function should return `Result` or `Option` to accept `?`
...
858 |                         })?;
    |                           ^ cannot use the `?` operator in a closure that returns `(std::result::Result<(), _>, std::option::Option<IncrCompSession>)`

error[E0308]: mismatched types
   --> src/librustdoc/lib.rs:852:17
    |
850 |               return wrap_return(
    |                      ----------- arguments to this function are incorrect
851 |                   dcx,
852 | /                 interface::run_compiler(config, |compiler| {
853 | |                     // construct a phony "crate" without actually running the parser
854 | |                     // allows us to use other compiler infrastructure like dep-info
855 | |                     let file =
...   |
886 | |                     })
887 | |                 }),
    | |__________________^ expected `Result<(), String>`, found `(Result<(), _>, Option<IncrCompSession>)`
    |
    = note: expected enum `std::result::Result<(), std::string::String>`
              found tuple `(std::result::Result<(), _>, std::option::Option<IncrCompSession>)`
note: function defined here
   --> src/librustdoc/lib.rs:720:15
    |
720 | pub(crate) fn wrap_return(dcx: DiagCtxtHandle<'_>, res: Result<(), String>) {
    |               ^^^^^^^^^^^                          -----------------------

error[E0308]: mismatched types
   --> src/librustdoc/lib.rs:930:9
    |
930 | /         rustc_interface::create_and_enter_global_ctxt(compiler, krate, |tcx| {
931 | |             if sess.dcx().has_errors().is_some() {
932 | |                 sess.dcx().fatal("Compilation failed, aborting rustdoc");
...   |
995 | |         })
    | |          ^- help: consider using a semicolon here: `;`
    | |__________|
    |            expected `()`, found `((), Option<IncrCompSession>)`
    |
    = note: expected unit type `()`
                   found tuple `((), std::option::Option<IncrCompSession>)`
note: return type inferred to be `()` here
   --> src/librustdoc/lib.rs:926:13
    |
926 |             return;
    |             ^^^^^^

@bjorn3 bjorn3 added the A-incr-comp Area: Incremental compilation label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-incr-comp Area: Incremental compilation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants