Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends - #159999
Merged
rust-bors[bot] merged 1 commit intoJul 31, 2026
Merged
Conversation
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
Author
|
r? @bjorn3 |
Member
|
@bors r+ |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jul 31, 2026
…nvalidation, r=bjorn3 Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends This was quite the detective hunt. Antoyo reached out to me that when using the GCC codegen backend by default (`--set rust.codegen-backends=["gcc"]`), the stdlib is invalidated after every rebuild. I did some digging, and found out this: - The `Builder::cargo` step manually invalidates the target directory if any of the used codegen backends is dirty, because apparently the used codegen backend is not tracked by `-Zbinary-dep-depinfo` yet. - It does so by getting all paths from `<sysroot>/lib/rustlib/<target>/codegen-backends` via the `Builder::codegen_backends` function, and if any such path is newer than the output directory, the output directory is deleted. - The intention was for this function to return codegen backends, i.e. `.so/.dll` files. However, since the GCC codegen backend has additional dependencies (libgccjit), the `codegen-backends` contains a `lib` subdirectory. And bootstrap was checking the mtime of this *directory*, which was always considered dirty. So I changed the function to only return the actual codegen backends, which fixes the issue. In theory, we should also be checking all the nested contents of the `lib` directory, i.e. the libgccjit dylibs, but I think that if they change, the GCC codegen backend itself should also change, in the vast majority of cases, so I consider this to be a worthy fix in the meantime. CC @antoyo @bjorn3
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jul 31, 2026
…nvalidation, r=bjorn3 Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends This was quite the detective hunt. Antoyo reached out to me that when using the GCC codegen backend by default (`--set rust.codegen-backends=["gcc"]`), the stdlib is invalidated after every rebuild. I did some digging, and found out this: - The `Builder::cargo` step manually invalidates the target directory if any of the used codegen backends is dirty, because apparently the used codegen backend is not tracked by `-Zbinary-dep-depinfo` yet. - It does so by getting all paths from `<sysroot>/lib/rustlib/<target>/codegen-backends` via the `Builder::codegen_backends` function, and if any such path is newer than the output directory, the output directory is deleted. - The intention was for this function to return codegen backends, i.e. `.so/.dll` files. However, since the GCC codegen backend has additional dependencies (libgccjit), the `codegen-backends` contains a `lib` subdirectory. And bootstrap was checking the mtime of this *directory*, which was always considered dirty. So I changed the function to only return the actual codegen backends, which fixes the issue. In theory, we should also be checking all the nested contents of the `lib` directory, i.e. the libgccjit dylibs, but I think that if they change, the GCC codegen backend itself should also change, in the vast majority of cases, so I consider this to be a worthy fix in the meantime. CC @antoyo @bjorn3
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jul 31, 2026
…nvalidation, r=bjorn3 Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends This was quite the detective hunt. Antoyo reached out to me that when using the GCC codegen backend by default (`--set rust.codegen-backends=["gcc"]`), the stdlib is invalidated after every rebuild. I did some digging, and found out this: - The `Builder::cargo` step manually invalidates the target directory if any of the used codegen backends is dirty, because apparently the used codegen backend is not tracked by `-Zbinary-dep-depinfo` yet. - It does so by getting all paths from `<sysroot>/lib/rustlib/<target>/codegen-backends` via the `Builder::codegen_backends` function, and if any such path is newer than the output directory, the output directory is deleted. - The intention was for this function to return codegen backends, i.e. `.so/.dll` files. However, since the GCC codegen backend has additional dependencies (libgccjit), the `codegen-backends` contains a `lib` subdirectory. And bootstrap was checking the mtime of this *directory*, which was always considered dirty. So I changed the function to only return the actual codegen backends, which fixes the issue. In theory, we should also be checking all the nested contents of the `lib` directory, i.e. the libgccjit dylibs, but I think that if they change, the GCC codegen backend itself should also change, in the vast majority of cases, so I consider this to be a worthy fix in the meantime. CC @antoyo @bjorn3
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 31, 2026
…uwer Rollup of 21 pull requests Successful merges: - #160100 (Add "system" option to `override-allocator` directive) - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler) - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends) - #160233 (Bubble bad path error while parsing field to avoid unecessary second error) - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`) - #154202 (rustfmt: Format `cfg_select!`) - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules) - #159520 (Suggest `Vec<T>` instead of `[T]`) - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser) - #160066 (rustc_middle: lint attribute cleanups) - #160085 (Remove various superfluous lint attributes) - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters) - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver) - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`) - #160157 (Remove outdated comments from `va_list.rs`) - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint) - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type) - #160244 (Rename splat to rustc_splat in error messages) - #160246 (dont fire `unused_mut` on `&pin mut self`) - #160247 (Configure backport nominations for rustfmt) - #160274 (renovate: update lock files weekly)
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 31, 2026
…uwer Rollup of 22 pull requests Successful merges: - #160100 (Add "system" option to `override-allocator` directive) - #160220 (Refactor: shrink region ext traits) - #159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler) - #159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends) - #160233 (Bubble bad path error while parsing field to avoid unecessary second error) - #160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`) - #154202 (rustfmt: Format `cfg_select!`) - #159520 (Suggest `Vec<T>` instead of `[T]`) - #159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts) - #160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser) - #160066 (rustc_middle: lint attribute cleanups) - #160085 (Remove various superfluous lint attributes) - #160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters) - #160119 (fix query cycle in `coroutine_hidden_types` for the next solver) - #160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`) - #160157 (Remove outdated comments from `va_list.rs`) - #160159 (More accurately check for interior mutability in `invalid_reference_casting` lint) - #160208 (rustdoc: Fix crash when trying to list attributes on an opaque type) - #160244 (Rename splat to rustc_splat in error messages) - #160246 (dont fire `unused_mut` on `&pin mut self`) - #160247 (Configure backport nominations for rustfmt) - #160274 (renovate: update lock files weekly)
rust-timer
added a commit
that referenced
this pull request
Jul 31, 2026
Rollup merge of #159999 - Kobzol:bootstrap-codegen-backend-invalidation, r=bjorn3 Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends This was quite the detective hunt. Antoyo reached out to me that when using the GCC codegen backend by default (`--set rust.codegen-backends=["gcc"]`), the stdlib is invalidated after every rebuild. I did some digging, and found out this: - The `Builder::cargo` step manually invalidates the target directory if any of the used codegen backends is dirty, because apparently the used codegen backend is not tracked by `-Zbinary-dep-depinfo` yet. - It does so by getting all paths from `<sysroot>/lib/rustlib/<target>/codegen-backends` via the `Builder::codegen_backends` function, and if any such path is newer than the output directory, the output directory is deleted. - The intention was for this function to return codegen backends, i.e. `.so/.dll` files. However, since the GCC codegen backend has additional dependencies (libgccjit), the `codegen-backends` contains a `lib` subdirectory. And bootstrap was checking the mtime of this *directory*, which was always considered dirty. So I changed the function to only return the actual codegen backends, which fixes the issue. In theory, we should also be checking all the nested contents of the `lib` directory, i.e. the libgccjit dylibs, but I think that if they change, the GCC codegen backend itself should also change, in the vast majority of cases, so I consider this to be a worthy fix in the meantime. CC @antoyo @bjorn3
github-actions Bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Aug 3, 2026
…uwer Rollup of 22 pull requests Successful merges: - rust-lang/rust#160100 (Add "system" option to `override-allocator` directive) - rust-lang/rust#160220 (Refactor: shrink region ext traits) - rust-lang/rust#159675 (rustc: Support `--jobs` options for limiting parallelism in various parts of the compiler) - rust-lang/rust#159999 (Fix invalidation of stdlib in bootstrap when using non-LLVM codegen backends) - rust-lang/rust#160233 (Bubble bad path error while parsing field to avoid unecessary second error) - rust-lang/rust#160272 (rustc_metadata: Move native library search code to `rustc_codegen_ssa`) - rust-lang/rust#154202 (rustfmt: Format `cfg_select!`) - rust-lang/rust#159520 (Suggest `Vec<T>` instead of `[T]`) - rust-lang/rust#159710 (Add rustdoc/cargo PGO profiles to reproducible artifacts) - rust-lang/rust#160034 (Move "macro only" check for `#[allow_internal_unsafe/unstable]` to attribute parser) - rust-lang/rust#160066 (rustc_middle: lint attribute cleanups) - rust-lang/rust#160085 (Remove various superfluous lint attributes) - rust-lang/rust#160113 (Coalesce `rustc_on_unimplemented` attributes and lint malformed filters) - rust-lang/rust#160119 (fix query cycle in `coroutine_hidden_types` for the next solver) - rust-lang/rust#160147 (tests: Remove `-Zthreads` options from tests in `ui/parallel-rustc`) - rust-lang/rust#160157 (Remove outdated comments from `va_list.rs`) - rust-lang/rust#160159 (More accurately check for interior mutability in `invalid_reference_casting` lint) - rust-lang/rust#160208 (rustdoc: Fix crash when trying to list attributes on an opaque type) - rust-lang/rust#160244 (Rename splat to rustc_splat in error messages) - rust-lang/rust#160246 (dont fire `unused_mut` on `&pin mut self`) - rust-lang/rust#160247 (Configure backport nominations for rustfmt) - rust-lang/rust#160274 (renovate: update lock files weekly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This was quite the detective hunt. Antoyo reached out to me that when using the GCC codegen backend by default (
--set rust.codegen-backends=["gcc"]), the stdlib is invalidated after every rebuild.I did some digging, and found out this:
Builder::cargostep manually invalidates the target directory if any of the used codegen backends is dirty, because apparently the used codegen backend is not tracked by-Zbinary-dep-depinfoyet.<sysroot>/lib/rustlib/<target>/codegen-backendsvia theBuilder::codegen_backendsfunction, and if any such path is newer than the output directory, the output directory is deleted..so/.dllfiles. However, since the GCC codegen backend has additional dependencies (libgccjit), thecodegen-backendscontains alibsubdirectory. And bootstrap was checking the mtime of this directory, which was always considered dirty.So I changed the function to only return the actual codegen backends, which fixes the issue. In theory, we should also be checking all the nested contents of the
libdirectory, i.e. the libgccjit dylibs, but I think that if they change, the GCC codegen backend itself should also change, in the vast majority of cases, so I consider this to be a worthy fix in the meantime.CC @antoyo @bjorn3