Commit graph

4960 commits

Author SHA1 Message Date
bjorn3
da831be403 Rustup to rustc 1.89.0-nightly (45acf54ee 2025-06-16) 2025-06-17 12:00:57 +00:00
bjorn3
7ed06e50b3 Sync from rust 45acf54eea 2025-06-17 11:53:24 +00:00
beetrees
e3916036f9 Fix RISC-V C function ABI when passing/returning structs containing floats 2025-06-16 10:14:07 +01:00
bjorn3
b7cfe2f4db Use the new --debug flag of abi-cafe
As opposed to patching abi-cafe itself.
2025-06-16 08:23:24 +00:00
bjorn3
1ade48fde9 Rustup to rustc 1.89.0-nightly (586ad391f 2025-06-15) 2025-06-16 08:15:58 +00:00
bjorn3
ab385a9916 Sync from rust 586ad391f5 2025-06-16 08:10:49 +00:00
León Orell Valerian Liehr
262e8210a5 Rollup merge of #142389 - beetrees:cranelift-arg-ext, r=bjorn3
Apply ABI attributes on return types in `rustc_codegen_cranelift`

- The [x86-64 System V ABI standard](https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build) doesn't sign/zero-extend integer arguments or return types.
- But the de-facto standard as implemented by Clang and GCC is to sign/zero-extend arguments to 32 bits (but not return types).
- Additionally, Apple targets [sign/zero-extend both arguments and return values to 32 bits](https://developer.apple.com/documentation/xcode/writing-64-bit-intel-code-for-apple-platforms#Pass-arguments-to-functions-correctly).
- However, the `rustc_target` ABI adjustment code currently [unconditionally extends both arguments and return values to 32 bits](https://github.com/rust-lang/rust/blame/e703dff8fe220b78195c53478e83fb2f68d8499c/compiler/rustc_target/src/callconv/x86_64.rs#L240) on all targets.
- This doesn't cause a miscompilation when compiling with LLVM as LLVM will ignore the `signext`/`zeroext` attribute when applied to return types on non-Apple x86-64 targets.
- Cranelift, however, does not have a similar special case, requiring `rustc` to set the argument extension attribute correctly.
- However, `rustc_codegen_cranelift` doesn't currently apply ABI attributes to return types at all, meaning `rustc_codegen_cranelift` will currently miscompile `i8`/`u8`/`i16`/`u16` returns on x86-64 Apple targets as those targets require sign/zero-extension of return types.

This PR fixes the bug(s) by making the `rustc_target` x86-64 System V ABI only mark return types as sign/zero-extended on Apple platforms, while also making `rustc_codegen_cranelift` apply ABI attributes to return types. The RISC-V and s390x C ABIs also require sign/zero extension of return types, so this will fix those targets when building with `rustc_codegen_cranelift` too.

r? `````@bjorn3`````
2025-06-15 23:51:56 +02:00
León Orell Valerian Liehr
9795908dea Rollup merge of #141769 - bjorn3:codegen_metadata_module_rework, r=workingjubilee,saethlin
Move metadata object generation for dylibs to the linker code

This deduplicates some code between codegen backends and may in the future allow adding extra metadata that is only known at link time.

Prerequisite of https://github.com/rust-lang/rust/issues/96708.
2025-06-15 23:51:54 +02:00
bjorn3
aafdccfd9e
Merge pull request #1582 from rust-lang/update_abi_cafe
Update to abi-cafe 1.0
2025-06-15 15:25:20 +02:00
bjorn3
8a39619343 Use the new abi-cafe-rules.toml support 2025-06-15 12:15:26 +00:00
bjorn3
3e59f14fb2 Update to abi-cafe 1.0 2025-06-15 11:19:04 +00:00
bjorn3
600a8a7f63 Rustup to rustc 1.89.0-nightly (8da623945 2025-06-13) 2025-06-14 09:42:41 +00:00
bjorn3
2f2a0b9fc8 Sync from rust 8da623945f 2025-06-14 09:37:32 +00:00
Matthias Krüger
8b24077171 Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errors
Unimplement unsized_locals

Implements https://github.com/rust-lang/compiler-team/issues/630

Tracking issue here: https://github.com/rust-lang/rust/issues/111942

Note that this just removes the feature, not the implementation, and does not touch `unsized_fn_params`. This is because it is required to support `Box<dyn FnOnce()>: FnOnce()`.

There may be more that should be removed (possibly in follow up prs)
- the `forget_unsized` function and `forget` intrinsic.
- the `unsized_locals` test directory; I've just fixed up the tests for now
- various codegen support for unsized values and allocas

cc ``@JakobDegen`` ``@oli-obk`` ``@Noratrieb`` ``@programmerjake`` ``@bjorn3``

``@rustbot`` label F-unsized_locals

Fixes rust-lang/rust#79409
2025-06-14 11:27:10 +02:00
bors
393e46edab Auto merge of #142443 - matthiaskrgr:rollup-l1l6d0v, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#128425 (Make `missing_fragment_specifier` an unconditional error)
 - rust-lang/rust#135927 (retpoline and retpoline-external-thunk flags (target modifiers) to enable retpoline-related target features)
 - rust-lang/rust#140770 (add `extern "custom"` functions)
 - rust-lang/rust#142176 (tests: Split dont-shuffle-bswaps along opt-levels and arches)
 - rust-lang/rust#142248 (Add supported asm types for LoongArch32)
 - rust-lang/rust#142267 (assert more in release in `rustc_ast_lowering`)
 - rust-lang/rust#142274 (Update the stdarch submodule)
 - rust-lang/rust#142276 (Update dependencies in `library/Cargo.lock`)
 - rust-lang/rust#142308 (Upgrade `object`, `addr2line`, and `unwinding` in the standard library)

Failed merges:

 - rust-lang/rust#140920 (Extract some shared code from codegen backend target feature handling)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-gnu
try-job: dist-i586-gnu-i586-i686-musl
try-job: test-various
2025-06-13 17:44:15 +00:00
mejrs
a6ecde32b9 Unimplement unsized_locals 2025-06-13 01:16:36 +02:00
Folkert de Vries
dcc48749e2 add extern "custom" functions 2025-06-12 20:27:10 +02:00
bjorn3
9594d67bcf Rustup to rustc 1.89.0-nightly (e703dff8f 2025-06-11) 2025-06-12 16:48:29 +00:00
bjorn3
047a10643b Sync from rust e703dff8fe 2025-06-12 16:18:26 +00:00
Ralf Jung
a9fd42e536 intrinsics: rename min_align_of to align_of 2025-06-12 17:50:25 +02:00
beetrees
2457bb2cfb Apply ABI attributes on return types in rustc_codegen_cranelift 2025-06-12 00:47:01 +01:00
bjorn3
30c48bcb55 Use Operand::constant() in a couple of places
Also reduce visibility of a function
2025-06-10 09:39:50 +00:00
Jubilee Young
d5e9833af3 Remove rustc's notion of "preferred" alignment AKA __alignof
In PR 90877 T-lang decided not to remove `intrinsics::pref_align_of`.
However, the intrinsic and its supporting code
1.  is a nightly feature, so can be removed at compiler/libs discretion
2.  requires considerable effort in the compiler to support, as it
    necessarily complicates every single site reasoning about alignment
3.  has been justified based on relevance to codegen, but it is only a
    requirement for C++ (not C, not Rust) stack frame layout for AIX,
    in ways Rust would not consider even with increased C++ interop
4.  is only used by rustc to overalign some globals, not correctness
5.  can be adequately replaced by other rules for globals, as it mostly
    affects alignments for a few types under 16 bytes of alignment
6.  has only one clear benefactor: automating C -> Rust translation
    for GNU extensions like `__alignof`
7.  such code was likely intended to be `alignof` or `_Alignof`,
    because the GNU extension is a "false friend" of the C keyword,
    which makes the choice to support such a mapping very questionable
8.  makes it easy to do incorrect codegen in the compiler by its mere
    presence as usual Rust rules of alignment (e.g. `size == align * N`)
    do not hold with preferred alignment

The implementation is clearly damaging the code quality of the compiler.
Thus it is within the compiler team's purview to simply rip it out.
If T-lang wishes to have this intrinsic restored for c2rust's benefit,
it would have to use a radically different implementation that somehow
does not cause internal incorrectness.

Until then, remove the intrinsic and its supporting code, as one tool
and an ill-considered GCC extension cannot justify risking correctness.

Because we touch a fair amount of the compiler to change this at all,
and unfortunately the duplication of AbiAndPrefAlign is deep-rooted,
we keep an "AbiAlign" type which we can wean code off later.
2025-06-08 16:41:46 -07:00
bjorn3
7988b8c0b3 Rustup to rustc 1.89.0-nightly (cdd545be1 2025-06-07) 2025-06-08 11:42:13 +00:00
bjorn3
d0040227d9 Sync from rust cdd545be1b 2025-06-08 10:29:24 +00:00
Ralf Jung
18b12218a4 intrinsics: use const generic to set atomic ordering 2025-06-07 21:45:58 +02:00
bjorn3
4e3bf2da2f Rustup to rustc 1.89.0-nightly (44f415c1d 2025-06-06) 2025-06-07 14:18:29 +00:00
bjorn3
46e0b2158e Sync from rust 44f415c1d6 2025-06-07 13:48:38 +00:00
bors
83be7a8960 Auto merge of #141964 - sayantn:update-stdarch, r=Amanieu
Update stdarch submodule

Updates the stdarch submodule.

## Merged PRs

 - rust-lang/stdarch#1797
 - rust-lang/stdarch#1758
 - rust-lang/stdarch#1798
 - rust-lang/stdarch#1811
 - rust-lang/stdarch#1810
 - rust-lang/stdarch#1807
 - rust-lang/stdarch#1806
 - rust-lang/stdarch#1812
 - rust-lang/stdarch#1795
 - rust-lang/stdarch#1796
 - rust-lang/stdarch#1813
 - rust-lang/stdarch#1816
 - rust-lang/stdarch#1818
 - rust-lang/stdarch#1820
 - rust-lang/stdarch#1819

r? `@Amanieu`
`@rustbot` label T-libs-api

Closes rust-lang/rust#111137
2025-06-07 12:25:59 +00:00
Guillaume Gomez
363003951c Rollup merge of #142103 - scottmcm:fieldidx-in-interp, r=oli-obk
Update `InterpCx::project_field` to take `FieldIdx`

As suggested by Ralf in https://github.com/rust-lang/rust/pull/142005#discussion_r2125839015
2025-06-06 23:53:18 +02:00
Scott McMurray
2192d869d0 Update InterpCx::project_field to take FieldIdx
As suggested by Ralf in 142005.
2025-06-05 19:15:56 -07:00
Oli Scherer
59549af369 Replace some Option<Span> with Span and use DUMMY_SP instead of None 2025-06-05 14:14:59 +00:00
bjorn3
bcac194b24 Rustup to rustc 1.89.0-nightly (4b27a04cc 2025-06-04) 2025-06-05 09:35:09 +00:00
bjorn3
8f889f843b Sync from rust 4b27a04cc8 2025-06-05 09:28:46 +00:00
Scott McMurray
57d0559160 Change tag_field to FieldIdx in Variants::Multiple
It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.
2025-06-03 23:42:21 -07:00
bors
112e5e8721 Auto merge of #141984 - matthiaskrgr:rollup-wy6j9ca, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#137725 (Add `iter` macro)
 - rust-lang/rust#141455 (std: abort the process on failure to allocate a TLS key)
 - rust-lang/rust#141569 (Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`)
 - rust-lang/rust#141698 (Use the informative error as the main const eval error message)
 - rust-lang/rust#141925 (Remove bootstrap cfgs from library/)
 - rust-lang/rust#141943 (Remove pre-expansion AST stats.)
 - rust-lang/rust#141945 (Remove `Path::is_ident`.)
 - rust-lang/rust#141957 (Add missing `dyn` keywords to tests that do not test for them Part 2)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-03 23:15:53 +00:00
Matthias Krüger
582ad1f6f3 Rollup merge of #141569 - workingjubilee:canonicalize-abi, r=bjorn3
Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi`

Our `conv_from_spec_abi`, `adjust_abi`, and `is_abi_supported` combine to give us a very confusing way of reasoning about what _actual_ calling convention we want to lower our code to and whether we want to compile the resulting code at all. Instead of leaving this code as a miniature adventure game in which someone tries to combine stateful mutations into a Rube Goldberg machine that will let them escape the maze and arrive at the promised land of codegen, we let `AbiMap` devour this complexity. Once you have an `AbiMap`, you can answer which `ExternAbi`s will lower to what `CanonAbi`s (and whether they will lower at all).

Removed:
- `conv_from_spec_abi` replaced by `AbiMap::canonize_abi`
- `adjust_abi` replaced by same
- `Conv::PreserveAll` as unused
- `Conv::Cold` as unused
- `enum Conv` replaced by `enum CanonAbi`

target-spec.json changes:
- If you have a target-spec.json then now your "entry-abi" key will be specified in terms of one of the `"{abi}"` strings Rust recognizes, e.g.
```json
    "entry-abi": "C",
    "entry-abi": "win64",
    "entry-abi": "aapcs",
```
2025-06-03 21:53:36 +02:00
bors
decbfcda13 Auto merge of #141229 - tgross35:builtins-josh-subtree, r=Kobzol
Merge `compiler-builtins` as a Josh subtree

Use the Josh [1] utility to add `compiler-builtins` as a subtree, which
will allow us to stop using crates.io for updates. This is intended to
help resolve some problems when unstable features change and require
code changes in `compiler-builtins`, which sometimes gets trapped in a
bootstrap cycle.

This was done using `josh-filter` built from the r24.10.04 tag:

    git fetch https://github.com/rust-lang/compiler-builtins.git 233434412fe7eced8f1ddbfeddabef1d55e493bd
    josh-filter ":prefix=library/compiler-builtins" FETCH_HEAD
    git merge --allow-unrelated FILTERED_HEAD

The HEAD in the `compiler-builtins` repository is 233434412f ("fix an if
statement that can be collapsed").

[1]: https://github.com/josh-project/josh
2025-06-03 19:52:05 +00:00
Jubilee Young
12be26f928 cg_clif: convert to CanonAbi 2025-06-03 10:04:19 -07:00
sayantn
b97136c817 Add impl for llvm.roundeven in cg_clif
- remove unused `llvm.aarch64.neon.frintn` from cg_clif
2025-06-03 20:37:10 +05:30
bjorn3
2974c99566 Move metadata object generation for dylibs to the linker code
This deduplicates some code between codegen backends and may in the
future allow adding extra metadata that is only known at link time.
2025-06-03 10:04:34 +00:00
bjorn3
ad43500e96 Only borrow EncodedMetadata in codegen_crate
And move passing it to the linker to the driver code.
2025-06-03 10:04:34 +00:00
bjorn3
814ef9f080 Rustup to rustc 1.89.0-nightly (5d707b07e 2025-06-02) 2025-06-03 08:51:18 +00:00
bjorn3
bc74556fa4 Rustup to rustc 1.89.0-nightly (70b3f4666 2025-05-30) 2025-05-31 13:43:30 +00:00
bjorn3
26242be173 Sync from rust 70b3f4666e 2025-05-31 13:37:50 +00:00
Ralf Jung
99e783d4e9 atomic_load intrinsic: use const generic parameter for ordering 2025-05-28 22:57:55 +02:00
Trevor Gross
ea26272c94 clif: Provide better output messages for failed copies 2025-05-28 15:15:43 +00:00
bjorn3
2357fb6578 Merge branch 'sync_from_rust' 2025-05-25 18:55:47 +00:00
bjorn3
4f24d142d9 Merge commit '979dcf8e2f' into sync_cg_clif-2025-05-25 2025-05-25 18:51:16 +00:00
bjorn3
979dcf8e2f Rustup to rustc 1.89.0-nightly (5e16c6620 2025-05-24) 2025-05-25 18:39:17 +00:00