Subtree cg_gcc sync (2026-07-24) - #159844
Open
GuillaumeGomez wants to merge 224 commits into
Open
Conversation
Previously this was not correctly implemented. Each funclet may need its own terminate block, so this changes the `terminate_block` into a `terminate_blocks` `IndexVec` which can have a terminate_block for each funclet. We key on the first basic block of the funclet -- in particular, this is the start block for the old case of the top level terminate function. Rather than using a catchswitch/catchpad pair, I used a cleanuppad. The reason for the pair is to avoid catching foreign exceptions on MSVC. On wasm, it seems that the catchswitch/catchpad pair is optimized back into a single cleanuppad and a catch_all instruction is emitted which will catch foreign exceptions. Because the new logic is only used on wasm, it seemed better to take the simpler approach seeing as they do the same thing.
…update_cg_gcc_2026-04-29
…_2026-04-29, r=antoyo GCC backend subtree sync r? ghost
This way they also apply to the allocator shim.
Submission to the Apple App Store for iOS no longer requires embedding bitcode, but even back when it did, it needed LLVM bitcode, so GCC wouldn't work anyway.
This is necessary to fix incremental LTO in cg_gcc as well as to do some LTO refactorings I want to do. The actual fix for cg_gcc will be done on the cg_gcc repo to test it in CI.
Move most flags from module_codegen to new_context
`rustc_error_messages` currently depends on `rustc_ast`/`rustc_ast_pretty`. This is odd, because `rustc_error_messages` feels like a very low-level module but `rustc_ast`/`rustc_ast_pretty` do not. The reason is that a few AST types impl `IntoDiagArg` via pretty-printing. `rustc_error_messages` can define `IntoDiagArg` and then impl it for the AST types. But if we invert the dependency we hit a problem with the orphan rule: `rustc_ast` must impl `IntoDiagArg` for the AST types, but that requires calling pretty-printing code which is in `rustc_ast_pretty`, a downstream crate. This commit avoids this problem by just removing the `IntoDiagArg` impls for these AST types. There aren't that many of them, and we can just use `String` in the relevant error structs and use the pretty printer in the downstream crates that construct the error structs. There are plenty of existing examples where `String` is used in error structs. There is now no dependency between `rustc_ast*` and `rustc_error_messages`.
…and, r=bjorn3 Fix: On wasm targets, call `panic_in_cleanup` if panic occurs in cleanup Relies on rust-lang/llvm-project#194. Reland of rust-lang#151771. Previously this was not correctly implemented. Each funclet may need its own terminate block, so this changes the `terminate_block` into a `terminate_blocks` `IndexVec` which can have a terminate_block for each funclet. We key on the first basic block of the funclet -- in particular, this is the start block for the old case of the top level terminate function. Rather than using a catchswitch/catchpad pair, I used a cleanuppad. The reason for the pair is to avoid catching foreign exceptions on MSVC. On wasm, it seems that the catchswitch/catchpad pair is optimized back into a single cleanuppad and a catch_all instruction is emitted which will catch foreign exceptions. Because the new logic is only used on wasm, it seemed better to take the simpler approach seeing as they do the same thing. - [ ] Add test for rust-lang#153948
Pass Session to optimize_and_codegen_fat_lto This is necessary to fix incremental LTO in cg_gcc as well as to do some LTO refactorings I want to do. The actual fix for cg_gcc will be done on the cg_gcc repo to test it in CI.
…henkov Add rlib digest to identify Rust object files This adds a metadata entry to `rlib` archives that lists which members are Rust object files instead of relying on the filename heuristic in `looks_like_rust_object.file`. I also added a fallback to the old behavior for `rlibs` built by older compilers. Part of rust-lang#138243.
Rustup to rustc 1.97.0-nightly (e95e732 2026-05-05)
Handle all modules being serialized during LTO
CrateInfo is only necessary during linking and non-local LTO.
While it was previously defined in Session, it is only ever used with OutputFilenames methods.
…lfJung,scottmcm,saethlin change the type of the argument of `drop_in_place` lang item to `&mut _` We used to special case `core::ptr::drop_in_place` when computing LLVM argument attributes with this hack: https://github.com/rust-lang/rust/blob/db5e2dc248fe5bb26f70d7baec46a3bca9fa3e1d/compiler/rustc_ty_utils/src/abi.rs#L383-L392 This is because even though `drop_in_place` takes a `*mut T` it is semantically a `&mut T` (remember how `&mut Self` is passed to `Drop::drop`). This is apparently relevant for perf. This PR replaces this hack with a simpler solution -- it makes `drop_in_place` a thin wrapper around newly added `core::ptr::drop_glue`, which is the actual lang item and takes a `&mut T`: https://github.com/rust-lang/rust/blob/d2563d5003bbecff1efc40c1f5673ceec603825b/library/core/src/ptr/mod.rs#L810-L833 ------ The rest of the PR is blessing tests and cleaning up things which are not necessary after this change. One thing that is a bit awkward is that now that `drop_glue` is the actual lang item, a lot of the comments referring to `drop_in_place` are outdated. Should I try fixing that? I've also changed `async_drop_in_place` to take a `&mut T`, and it simplified the code handling it a bit. (since it's unstable we don't need to introduce a wrapper) ------- cc @RalfJung Closes rust-lang#154274
Move CrateInfo computation after codegen_crate CrateInfo is only necessary during linking and non-local LTO. Part of rust-lang/compiler-team#908
…-obk Move invocation_temp into OutputFilenames While it was previously defined in Session, it is only ever used with OutputFilenames methods.
Member
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 2, 2026
…24, r=<try> Subtree cg_gcc sync (2026-07-24) try-job: dist-x86_64-linux
Contributor
|
💔 Test for ed61017 failed: CI. Failed job:
|
Member
|
@bors r- |
Contributor
|
This pull request was unapproved. |
Member
Author
|
The |
Member
Author
|
Let's try again when we build our own @bors try jobs=dist-x86_64-linux |
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 2, 2026
…24, r=<try> Subtree cg_gcc sync (2026-07-24) try-job: dist-x86_64-linux
Contributor
|
💔 Test for 5b3ef4e failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
bjorn3
reviewed
Aug 2, 2026
Member
Author
|
Let's try again with the correct decompression command. ^^' @bors try jobs=dist-x86_64-linux |
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 2, 2026
…24, r=<try> Subtree cg_gcc sync (2026-07-24) try-job: dist-x86_64-linux
Member
Author
|
It's blocked in the documentation part, so I guess a flaky issue? Just in case... @bors try cancel |
Contributor
|
Try build cancelled. Cancelled workflows: |
Member
Author
|
@bors try jobs=dist-x86_64-linux |
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Aug 2, 2026
…24, r=<try> Subtree cg_gcc sync (2026-07-24) try-job: dist-x86_64-linux
Contributor
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.
View all comments
cc @antoyo @bjorn3
r? ghost