Skip to content

Subtree cg_gcc sync (2026-07-24) - #159844

Merged
rust-bors[bot] merged 224 commits into
rust-lang:mainfrom
GuillaumeGomez:subtree-update_cg_gcc_2026-07-24
Aug 3, 2026
Merged

Subtree cg_gcc sync (2026-07-24)#159844
rust-bors[bot] merged 224 commits into
rust-lang:mainfrom
GuillaumeGomez:subtree-update_cg_gcc_2026-07-24

Conversation

@GuillaumeGomez

@GuillaumeGomez GuillaumeGomez commented Jul 24, 2026

Copy link
Copy Markdown
Member

hoodmane and others added 30 commits April 28, 2026 09:56
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.
…_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.
rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
…24, r=GuillaumeGomez

Subtree cg_gcc sync (2026-07-24)



cc @antoyo @bjorn3

r? ghost
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors yield
Scheduling

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #159789.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 3, 2026
…cc_2026-07-24, r=GuillaumeGomez

Subtree cg_gcc sync (2026-07-24)

cc @antoyo @bjorn3

r? ghost
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors try jobs=dist-i686-linux,dist-aarch64-linux
Debugging stuck CI builds

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
…24, r=<try>

Subtree cg_gcc sync (2026-07-24)


try-job: dist-i686-linux
try-job: dist-aarch64-linux
@Kobzol

Kobzol commented Aug 3, 2026

Copy link
Copy Markdown
Member

It wasn't stuck, this PR invalidated the Docker image, so it would take much longer to build.

@JonathanBrouwer

JonathanBrouwer commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Oh sorry :c
The LLVM build hadn't produced any output for more than an hour tho, which I found to be suspicious, but that might just be github not showing the output live correctly then?

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors rollup=iffy Invalidates docker image causing long builds

rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #159844 (Subtree cg_gcc sync (2026-07-24))
 - #159326 (Deny multiple EII impls on a single item)
 - #159535 (Optimize slice::contains for bytewise types)
 - #159595 (Promote loongarch32-unknown-none* to Tier 2)
 - #160007 (allow `-Ldependency` search paths for panic runtimes)
 - #160320 (point at trait definition when it is used as a derive macro)
 - #160369 (When suggesting method names, prefer *exact* doc aliases over similar names)
 - #160406 (`DepKind` cleanups)
 - #160424 (Use `thread::available_parallelism` as the default limit for backend parallelism)
 - #159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests)
 - #159303 (Fix ICE for direct inline const generic defaults)
 - #159977 (Add regression test for bool indexing codegen)
 - #160165 (reject `...` without pattern post-expansion)
 - #160295 (Fix rustdoc ICE when checking if a generic arg can be elided)
 - #160305 (Linkify C-SKY targets in `platform-support.md`)
 - #160314 (fix borrowck ICE for consts with fn pointer type)
 - #160322 (ElaborateBoxDeref: remove unnecessary projection)
 - #160338 (Add regression test for supertrait associated type normalization through dyn)
 - #160340 (Add regression test for unused_parens on contract clauses)
 - #160371 (Add doc aliases for transpositions `read_exact_buf` and `read_exact_buf_at`)
 - #160384 (Add PR body notes for Cargo lock file maintenance)
@rust-bors

This comment has been minimized.

@Kobzol

Kobzol commented Aug 3, 2026

Copy link
Copy Markdown
Member

Oh sorry :c The LLVM build hadn't produced any output for more than an hour tho, which I found to be suspicious, but that might just be github not showing the output live correctly then?

Don't worry, the Docker cache was saved, so the next time should be faster :) It is possible that only the logs got delayed, but maybe the job was indeed also stuck, hard to tell.

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: f671346 (f671346cb1c4ed925f370cf9dcedc537b639ff26)
Base parent: 7c329d6 (7c329d6c76e11ca40c5673818ab0439c1be8962c)

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 3, 2026
@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: GuillaumeGomez
Duration: 3h 16m 27s
Pushing 5048696 to main...

@rust-bors
rust-bors Bot merged commit 5048696 into rust-lang:main Aug 3, 2026
15 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 7c329d6 (parent) -> 5048696 (this PR)

Test differences

Show 3 test diffs

3 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 504869653f510b279c542e65ccd1ea9710c119ba --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-illumos: 1h 56m -> 1h 15m (-35.2%)
  2. x86_64-gnu-nopt: 2h 20m -> 1h 31m (-34.8%)
  3. dist-various-2: 44m 46s -> 30m 23s (-32.2%)
  4. i686-msvc-1: 2h 21m -> 3h 4m (+30.5%)
  5. x86_64-gnu-next-trait-solver-polonius: 41m 23s -> 52m 52s (+27.7%)
  6. x86_64-gnu-distcheck: 2h 17m -> 1h 40m (-26.8%)
  7. x86_64-gnu-gcc-core-tests: 11m 17s -> 14m 15s (+26.3%)
  8. x86_64-gnu-llvm-21-1: 55m 54s -> 41m 47s (-25.2%)
  9. dist-loongarch64-linux: 1h 29m -> 1h 52m (+25.1%)
  10. x86_64-msvc-ext2: 1h 7m -> 1h 23m (+24.4%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@GuillaumeGomez
GuillaumeGomez deleted the subtree-update_cg_gcc_2026-07-24 branch August 3, 2026 19:10
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5048696): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary -0.9%, secondary -1.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.5% [0.4%, 0.5%] 3
Regressions ❌
(secondary)
0.5% [0.4%, 0.5%] 2
Improvements ✅
(primary)
-4.9% [-4.9%, -4.9%] 1
Improvements ✅
(secondary)
-4.1% [-5.5%, -2.6%] 2
All ❌✅ (primary) -0.9% [-4.9%, 0.5%] 4

Cycles

Results (primary -0.3%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.9% [0.4%, 1.4%] 5
Regressions ❌
(secondary)
1.4% [0.6%, 2.2%] 5
Improvements ✅
(primary)
-1.1% [-2.1%, -0.6%] 7
Improvements ✅
(secondary)
-0.9% [-1.5%, -0.4%] 6
All ❌✅ (primary) -0.3% [-2.1%, 1.4%] 12

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 491.018s -> 491.182s (0.03%)
Artifact size: 390.29 MiB -> 390.23 MiB (-0.02%)

rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
…2026-07-24, r=GuillaumeGomez"

This reverts commit 5048696, reversing
changes made to 7c329d6.
@RalfJung

RalfJung commented Aug 3, 2026

Copy link
Copy Markdown
Member

Seems like this broke PR CI, x86_64-gnu-gcc now fails everywhere. Can you either quickly fix that or revert?

Also how is it even possible that this was allowed to land if it does not pass CI?

@antoyo

antoyo commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Can you either quickly fix that or revert?

The revert PR is up.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Seems like this broke PR CI, x86_64-gnu-gcc now fails everywhere. Can you either quickly fix that or revert?

Also how is it even possible that this was allowed to land if it does not pass CI?

I was very surprised by that too. Asked on zulip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc has-merge-commits PR has merge commits, merge with caution. merged-by-bors This PR was explicitly merged by bors. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.