Skip to content

Subtree sync for rustc_codegen_cranelift - #162470

Open
bjorn3 wants to merge 34 commits into
rust-lang:mainfrom
bjorn3:sync_cg_clif-2026-09-08
Open

Subtree sync for rustc_codegen_cranelift#162470
bjorn3 wants to merge 34 commits into
rust-lang:mainfrom
bjorn3:sync_cg_clif-2026-09-08

Conversation

@bjorn3

@bjorn3 bjorn3 commented Sep 8, 2026

Copy link
Copy Markdown
Member

The main highlight this time is an update to Cranelift 0.135, which should fix crates like linkme on macOS.

r? @ghost

@rustbot label +A-codegen +A-cranelift +T-compiler +subtree-sync

bjorn3 and others added 30 commits August 19, 2026 19:39
so that we can specify more than one i32 of padding.
Remove LD_STATIC_TLS_EXTRA workaround from FreeBSD CI
make `pad_i32` of `PassMode::cast` an integer

so that we can specify more than one i32 of padding. This PR only adds the functionality but does not yet use it: there should be no functional changes.

This is needed for the ABI of `Complex<{ float }>` on 32-bit powerpc. Other mechanisms, e.g. using `PassMode::prefixed` don't appear to work.

More discussion is in [#t-compiler/help > power complex abi](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/power.20complex.20abi/with/613294420).
Co-Authored-By: Mads Marquart <mads@marquart.dk>
* Implement Reborrow as a recursive operation

If Reborrow finds '&'a mut T' fields then it inserts
a Deref and borrow of the T, and likewise if it finds a
'T: Reborrow' field then the field type is recursed into.

This makes Reborrow always produce the correct borrow checking logic at
the cost of most probably being inconsiderately expensive. The thinking
is that performance will be a followup consideration.
* PhantomDeref
* Simpler deref test

* Add more PhantomDeref unreachability assertions
* Write out lifetime omission
* Document ProjectionElem::PhantomDeref
* Comment half of reborrow tests
* fix PhantomDeref conflicting with AccessDepth::Shallow
* Recheck CoerceShared in borrowck TypeChecker to ensure its lifetimes make sense
* Fix rebase
* Changes... but where to?
* Typo fix

* Improve comment
* Use fully_perform_op to evaluate CoerceShared trait in borrowck
* More CoerceShared comment
* Comment rest of Reborrow tests

Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
…ce, r=oli-obk

fix(reborrow): recursive implementation

If Reborrow finds '&'a mut T' fields where 'a is the Reborrowed type's first lifetime parameter (currently the only lifetime that is allowed to reborrow) then it inserts a Deref and borrow of the T, and likewise if it finds a 'T: Reborrow' field then the field type is recursed into.

This makes Reborrow always produce the correct borrow checking logic at the cost of most probably being inconsiderately expensive. The thinking is that performance will be a followup consideration.

r? @oli-obk
I added this flag back in 2017 to enable benchmarking of the saturating
semantics when it was newly implemented and still experimental. But
saturation has been the official semantics for float<->int `as` casts
for years now. A flag for turning it off no longer serves any purpose,
it's just `-Zplease-miscompile-casts` now.
…eature, r=Amanieu

support `#[target_feature(enable = ...)]` on `#[naked]` functions

fixes rust-lang#136280

Instructions that are part of a target feature require a special directive on some targets. This PR adds those for the most common targets.

This is very WIP, but I'm hoping to collect some feedback on what is (not) supported and how to report that to users.

r? @ghost

cc @taiki-e @Amanieu
…ncs, r=folkertdev

Make sin, cos, exp, exp2, log, log2, log10 generic

Rebased and smaller version of rust-lang#153934

Following `fabs`, make the `sin`, `cos`, `exp`, `exp2`, `log`, `log2` and `log10` intrinsics generic over the float type, rather than having four variants per float type.

The first two commits are purely stylistic:
- reorganised Cranelift code to make following changes simpler
- moved a misplaced comment in `compiler/rustc_codegen_llvm/src/intrinsic.rs` that caused `x fmt` to give up

The last commit actually makes them generic! Most code is a bit simpler, ~~and this will also hopefully simplify adding support for these intrinsics for the future [`bf16` type](rust-lang#160859 :)

Unfortunately both GCC and Cranelift backend changes are a bit churny. Their code is a bit, opaque, to put it kindly, and I didn't want to refactor those here.

r? @folkertdev
cc @RalfJung
…RalfJung

Remove -Zsaturating-float-casts flag

I added this flag back in 2017 (rust-lang#45205) to enable benchmarking of the saturating semantics when it was newly implemented and still experimental. But saturation has been the official semantics for float<->int `as` casts for years now. A flag for turning it off no longer serves any purpose, it's just `-Zplease-miscompile-casts` now.
Facilitates scalable vector support in inline assembly.
…O is enabled

The parallel frontend makes the cookies nondeterministic in their
current form, resulting in nondeterministic outputs when bitcode is
emitted or LTO is used.

Causes minor diagnostic regression for inline asm in release builds.
…s, r=petrochenkov

Restrict LLVM inline asm location cookie usage. Fixes rust-lang#150451

The parallel frontend makes the cookies nondeterministic in their current form, resulting in nondeterministic outputs when bitcode is emitted or LTO is used.

Causes minor diagnostic regression for inline asm in release builds. See rust-lang#150451 for details.

Fixes rust-lang#150451

r? bjorn3
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-codegen Area: Code generation A-cranelift Things relevant to the [future] cranelift backend subtree-sync PR updates a subtree (miri, clippy, etc). Ignored by no-merges check labels Sep 8, 2026
@bjorn3

bjorn3 commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

@bors r+ p=1 subtree sync

@rust-bors

rust-bors Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 951ad7b has been approved by bjorn3

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-review Status: Awaiting review from the assignee but also interested parties. labels Sep 8, 2026
@rust-bors

rust-bors Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

rust-bors Bot pushed a commit that referenced this pull request Sep 8, 2026
Subtree sync for rustc_codegen_cranelift

The main highlight this time is an update to Cranelift 0.135, which should fix crates like linkme on macOS.

r? @ghost

@rustbot label +A-codegen +A-cranelift +T-compiler +subtree-sync
@JonathanBrouwer

JonathanBrouwer commented Sep 8, 2026

Copy link
Copy Markdown
Member

@bors yield
Yielding to enclosing rollup

@rust-bors

rust-bors Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

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

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 8, 2026
…bjorn3

Subtree sync for rustc_codegen_cranelift

The main highlight this time is an update to Cranelift 0.135, which should fix crates like linkme on macOS.

r? @ghost

@rustbot label +A-codegen +A-cranelift +T-compiler +subtree-sync
rust-bors Bot pushed a commit that referenced this pull request Sep 8, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #162470 (Subtree sync for rustc_codegen_cranelift)
 - #160505 (delegation: supporting inherent impls)
 - #160651 (mir: validate `Move` call arguments are locals or box derefs)
 - #161806 (Add tests and docs for `#[derive(GenericTypeVisitable)]`)
 - #161912 (run `extern "tail"` with `byval` argument test)
 - #162435 (windows-gnu: document libgcc requirement)
 - #162439 (Update books)
 - #162451 (Add regression test for item-local diagnostic attribute lint levels)
 - #162459 (docs(time): replace "method" with "function")
 - #162465 (Fix my duplicate thanks entry)
@bjorn3

bjorn3 commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

@bors r-

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 8, 2026
@rust-bors

rust-bors Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This PR was contained in a rollup (#162472), which was unapproved.

View changes since this unapproval

@bjorn3

bjorn3 commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

For some reason that rustc_private I removed in the last commit results in an unused feature warning when testing in the cg_clif repo, but is necessary when testing in this repo.
Edit: asking on zulip: https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/weird.20const.20function.20stability.20error.20for.20cg_clif/with/622512126

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-aarch64-gnu-llvm-21-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: `align_of` is not yet stable as a const intrinsic
##[error]   --> example/mini_core.rs:774:26
    |
774 |     const ALIGN: usize = intrinsics::align_of::<Self>();
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: add `#![feature(rustc_private)]` to the crate attributes to enable
    |
 18 + #![feature(rustc_private)]
    |

error: aborting due to 2 previous errors

"/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/dist/rustc-clif" "-Zannotate-moves" "-Zrandomize-layout" "-Zunstable-options" "--check-cfg=cfg(bootstrap)" "-Zmacro-backtrace" "-Csplit-debuginfo=off" "-Clink-arg=-L/usr/lib/llvm-21/lib" "-Cllvm-args=-import-instr-limit=10" "-Clink-args=-Wl,-z,origin" "-Clink-args=-Wl,-rpath,$ORIGIN/../lib" "-Alinker-messages" "-L" "crate=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/example" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/example" "-Cdebuginfo=2" "--target" "aarch64-unknown-linux-gnu" "-Cpanic=abort" "--check-cfg=cfg(jit)" "--check-cfg=cfg(target_has_reliable_f128)" "--edition=2024" "example/mini_core.rs" "--crate-type" "lib,dylib" exited with status ExitStatus(unix_wait_status(256))
Bootstrap failed while executing `--stage 2 test --skip tidy --skip intrinsic-test --skip src/tools/rust-analyzer --skip tests --skip library --skip tidyselftest`
Currently active steps:
test::CodegenCranelift { compilers: RustcPrivateCompilers { build_compiler: Compiler { stage: 1, host: aarch64-unknown-linux-gnu, forced_compiler: false }, target_compiler: Compiler { stage: 2, host: aarch64-unknown-linux-gnu, forced_compiler: false } }, target: aarch64-unknown-linux-gnu } at src/bootstrap/src/core/build_steps/test.rs:4393
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout -Zembed-metadata=no --locked --color=always --profile=release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/test.rs:4407:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:4451:26

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:20:11
  local time: Tue Sep  8 11:58:20 UTC 2026
  network time: Tue, 08 Sep 2026 11:58:20 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

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

Labels

A-codegen Area: Code generation A-cranelift Things relevant to the [future] cranelift backend S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. subtree-sync PR updates a subtree (miri, clippy, etc). Ignored by no-merges check 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.