Skip to content

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

Open
GuillaumeGomez wants to merge 223 commits into
rust-lang:mainfrom
GuillaumeGomez:subtree-update_cg_gcc_2026-07-24
Open

Subtree cg_gcc sync (2026-07-24)#159844
GuillaumeGomez wants to merge 223 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.
@rustbot

rustbot commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

The license issue has resolved, so here comes the new updated version of the PR. :)

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Very conflict-prone so let's give it a high priority.

@bors r+ p=6

@rust-bors

rust-bors Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

📌 Commit fe87d15 has been approved by GuillaumeGomez

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
…cc_2026-07-24, r=GuillaumeGomez

Subtree cg_gcc sync (2026-07-24)

cc @antoyo @bjorn3

r? ghost
rust-bors Bot pushed a commit that referenced this pull request Aug 2, 2026
Rollup of 6 pull requests

Successful merges:

 - #159844 (Subtree cg_gcc sync (2026-07-24))
 - #156527 (Move `std::io` tests to `alloctests` & add prelude)
 - #159525 (Stabilize passing 128-bit integers via vector registers with `asm!` on x86)
 - #160342 (Specialize `advance_by` method of `Fuse`)
 - #106643 (Allow only implementing `Read::read_buf`)
 - #159729 (allocations are allowed to grow (but not shrink))
@jhpratt

jhpratt commented Aug 2, 2026

Copy link
Copy Markdown
Member

@bors try jobs=dist-x86_64-linux

Investigating the cause of #160361, which failed in the vicinity of some gcc stuff. Nothing else seems plausible.

@rust-bors

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
@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 2, 2026
@rust-bors

rust-bors Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

💔 Test for ed61017 failed: CI. Failed job:

@jhpratt

jhpratt commented Aug 2, 2026

Copy link
Copy Markdown
Member

@bors r-

@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 2, 2026
@rust-bors

rust-bors Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

View changes since this unapproval

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

The configure step is failing. Interesting.

@rustbot rustbot added A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Aug 2, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Let's try again when we build our own make.

@bors try jobs=dist-x86_64-linux

@rust-bors

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
@rust-bors

rust-bors Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 5b3ef4e failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#19 0.094   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#19 0.094                                  Dload  Upload   Total   Spent    Left  Speed
#19 0.094 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0 2293k    0 14588    0     0  40197      0  0:00:58 --:--:--  0:00xzcat: :58(stdin): File format not recognized 4
#19 0.457 0187tar: This does not look like a tar archive
#19 0.457 tar: Exiting with failure status due to previous errors
#19 0.505 
  1 2293k    1 33327    0     0  81017      0  0:00:28 --:--:--  0:00:28 80890
#19 0.506 curl: (23) Failed writing body (3537 != 16384)
#19 ERROR: process "/bin/sh -c ./build-gcc.sh && yum remove -y gcc gcc-c++" did not complete successfully: exit code: 2
---
#18 0.085   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#18 0.085                                  Dload  Upload   Total   Spent    Left  Speed
#18 0.085 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0xzcat: (stdin): File format not recognized
#18 0.478 tar: This does not look like a tar archive
#18 0.478 tar: Exiting with failure status due to previous errors
#18 0.527 
  1 2293k    1 33327    0     0  75424      0  0:00:31 --:--:--  0:00:31 75400
#18 0.528 curl: (23) Failed writing body (3537 != 16384)
#18 ERROR: process "/bin/sh -c ./build-gcc.sh && yum remove -y gcc gcc-c++" did not complete successfully: exit code: 2
---
#16 0.096   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#16 0.096                                  Dload  Upload   Total   Spent    Left  Speed
#16 0.096 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0xzcat: (stdin): File format not recognized
#16 0.420 tar: This does not look like a tar archive
#16 0.420 tar: Exiting with failure status due to previous errors
#16 0.468 
  1 2293k    1 33327    0     0  89487      0  0:00:26 --:--:--  0:00:26 89348
#16 0.468 curl: (23) Failed writing body (3537 != 16384)
#16 ERROR: process "/bin/sh -c ./build-gcc.sh && yum remove -y gcc gcc-c++" did not complete successfully: exit code: 2
---
#16 0.097   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#16 0.097                                  Dload  Upload   Total   Spent    Left  Speed
#16 0.097 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0 2293k    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0xzcat: (stdin): File format not recognized
#16 0.413 tar: This does not look like a tar archive
#16 0.413 tar: Exiting with failure status due to previous errors
#16 0.462 
  1 2293k    1 33307    0     0  91231      0  0:00:25 --:--:--  0:00:25 91002
#16 0.462 curl: (23) Failed writing body (3557 != 16384)
#16 ERROR: process "/bin/sh -c ./build-gcc.sh && yum remove -y gcc gcc-c++" did not complete successfully: exit code: 2
---
#16 0.098   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#16 0.098                                  Dload  Upload   Total   Spent    Left  Speed
#16 0.098 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0 2293k    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0xzcat: (stdin): File format not recognized
#16 0.411 tar: This does not look like a tar archive
#16 0.411 tar: Exiting with failure status due to previous errors
#16 0.460 
  1 2293k    1 33327    0     0  92077      0  0:00:25 --:--:--  0:00:25 92063
#16 0.460 curl: (23) Failed writing body (3537 != 16384)
#16 ERROR: process "/bin/sh -c ./build-gcc.sh && yum remove -y gcc gcc-c++" did not complete successfully: exit code: 2

source shared.sh

# We need to install a newer version of `make` to be able to build `gcc`.
curl https://ci-mirrors.rust-lang.org/rustc/gcc/make-4.4.1.tar.gz | xzcat | tar xf -

@bjorn3 bjorn3 Aug 2, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xzcat would require an xz archive, right? This is a gzip archive.

View changes since the review

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. 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. 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.