Commit Graph

5165 Commits

Author SHA1 Message Date
bjorn3 296501b2fa Fix rustc test suite 2025-11-05 11:07:47 +00:00
bjorn3 bb6f965464 Rustup to rustc 1.93.0-nightly (f15a7f385 2025-11-04) 2025-11-05 10:21:42 +00:00
bjorn3 ca44758e50 Fix a bunch of clippy lints in the build system 2025-10-28 16:08:46 +00:00
bjorn3 eaa91b8f04 Bunch of clippy fixes 2025-10-28 16:05:34 +00:00
bjorn3 bbedad249c Error when combining check mode and jit mode 2025-10-28 15:34:36 +00:00
bjorn3 022bb60b8e Rustup to rustc 1.93.0-nightly (adaa83897 2025-10-27) 2025-10-28 15:17:46 +00:00
bjorn3 6f1899c373 Sync from rust adaa838976 2025-10-28 15:11:14 +00:00
bjorn3 5aabbb6321 Fix dev release after renaming the default branch to main 2025-10-24 19:54:43 +00:00
bjorn3 b548b29e10 Skip codegen_crate call in check mode 2025-10-24 10:25:13 +00:00
bjorn3 bc6f1ef74a Rustup to rustc 1.92.0-nightly (1d23d0680 2025-10-22) 2025-10-23 11:43:38 +00:00
bjorn3 2e8f8d5414 Sync from rust 1d23d06800 2025-10-23 11:36:50 +00:00
Camille Gillot cc27b04473 Replace NullOp::SizeOf and NullOp::AlignOf by lang items. 2025-10-23 00:38:28 +00:00
bors 0eae3a2bed Auto merge of #147687 - cjgillot:noshallow-init-box, r=nnethercote
Forbid ShallowInitBox after box deref elaboration.

MIR currently contains a `ShallowInitBox` rvalue. Its principal usage is to allow for in-place initialization of boxes. Having it is necessary for drop elaboration to be correct with that in-place initialization.

As part of analysis->runtime MIR lowering, we canonicalize deref of boxes to use the stored raw pointer. But we did not perform the same change to the construction of the box.

This PR replaces `ShallowInitBox` by the pointer manipulation it represents.

Alternatives:
- fully remove `ShallowInitBox` and implement `Box` in-place initialization differently;
- remove the `ElaborateBoxDeref` pass and keep dereferencing `Box` in runtime MIR.
2025-10-22 09:53:50 +00:00
Camille Gillot 9d63e8c135 Elaborate ShallowInitBox too. 2025-10-22 00:52:52 +00:00
Oli Scherer 6031dfdaed Allow unsizing pattern types with pointer base 2025-10-21 11:22:51 +00:00
bjorn3 a20a4c2513 Update to Cranelift 0.125 2025-10-21 09:22:56 +00:00
Matthias Krüger 71068af640 Rollup merge of #145724 - folkertdev:track-caller-drop-no-mangle, r=fee1-dead
the `#[track_caller]` shim should not inherit `#[no_mangle]`

fixes https://github.com/rust-lang/rust/issues/143162

builds on https://github.com/rust-lang/rust/pull/143293 which introduced a mechanism to strip attributes from shims.

cc `@Jules-Bertholet` `@workingjubilee` `@bjorn3`

---

Summary:

This PR fixes an interaction between `#[track_caller]`, `#[no_mangle]`, and casting to a function pointer.

A function annotated with `#[track_caller]` internally has a hidden extra argument for the panic location. The `#[track_caller]` attribute is only allowed on `extern "Rust"` functions. When a function is annotated with both `#[no_mangle]` and `#[track_caller]`, the exported symbol has the signature that includes the extra panic location argument. This works on stable rust today:

```rust
extern "Rust" {
    #[track_caller]
    fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static>;
}

mod provides {
    use std::panic::Location;
    #[track_caller] // UB if we did not have this!
    #[no_mangle]
    fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static> {
        Location::caller()
    }
}
```

When a `#[track_caller]` function is converted to a function pointer, a shim is added to drop the additional argument. So this is a valid program:

```rust
#[track_caller]
fn foo() {}

fn main() {
    let f = foo as fn();
    f();
}
```

The issue arises when `foo` is additionally annotated with `#[no_mangle]`, the generated shim currently inherits this attribute, also exporting a symbol named `foo`, but one without the hidden panic location argument. The linker rightfully complains about a duplicate symbol.

The solution of this PR is to have the generated shim drop the `#[no_mangle]` attribute.
2025-10-18 08:08:36 +02:00
bjorn3 ca23203edb Fix rustc test suite 2025-10-17 11:35:42 +00:00
bjorn3 2d8a0c1816 Rustup to rustc 1.92.0-nightly (53a741fc4 2025-10-16) 2025-10-17 10:54:47 +00:00
bjorn3 48fc410b72 Sync from rust 53a741fc4b 2025-10-17 10:35:32 +00:00
Matthias Krüger c15f855f5a Rollup merge of #147576 - Mark-Simulacrum:fix-offset-zst, r=nnethercote,RalfJung
Fix ICE on offsetted ZST pointer

I'm not sure this is the *right* fix, but it's simple enough and does roughly what I'd expect. Like with the previous optimization to codegen usize rather than a zero-sized static, there's no guarantee that we continue returning a particular value from the offsetting.

A grep for `const_usize.*align` found the same code copied to rustc_codegen_gcc and cranelift but a quick skim didn't find other cases of similar 'optimization'. That said, I'm not convinced I caught everything, it's not trivial to search for this.

Closes rust-lang/rust#147516
2025-10-16 19:35:24 +02:00
Mark Rousskov 10ee204ff7 Fix ICE on offsetted ZST pointer
A grep for `const_usize.*align` found the same code copied to
rustc_codegen_gcc but I don't see other cases where we get this wrong.
2025-10-15 20:06:46 -04:00
bors a63c039af8 Auto merge of #143548 - Diggsey:db-limit-extern-crate-usage, r=oli-obk
Restrict sysroot crate imports to those defined in this repo.

It's common to import dependencies from the sysroot via `extern crate` rather than use an explicit cargo dependency, when it's necessary to use the same dependency version as used by rustc itself. However, this is dangerous for crates.io crates, since rustc may not pull in the dependency on some targets, or may pull in multiple versions. In both cases, the `extern crate` fails to resolve.

To address this, re-export all such dependencies from the appropriate `rustc_*` crates, and use this alias from crates which would otherwise need to use `extern crate`.

See https://github.com/rust-lang/rust/pull/143492 for an example of the kind of issue that can occur.
2025-10-15 13:32:03 +00:00
Diggory Blake f3d5c10e9e Restrict sysroot crate imports to those defined in this repo.
It's common to import dependencies from the sysroot via `extern crate`
rather than use an explicit cargo dependency, when it's necessary to use
the same dependency version as used by rustc itself. However, this is
dangerous for crates.io crates, since rustc may not pull in the
dependency on some targets, or may pull in multiple versions. In both
cases, the `extern crate` fails to resolve.

To address this, re-export all such dependencies from the appropriate
`rustc_*` crates, and use this alias from crates which would otherwise
need to use `extern crate`.
2025-10-15 13:17:25 +01:00
Matthias Krüger 4629f3152f Rollup merge of #147526 - bjorn3:alloc_shim_weak_shape, r=petrochenkov,RalfJung
Move computation of allocator shim contents to cg_ssa

In the future this should make it easier to use weak symbols for the allocator shim on platforms that properly support weak symbols. And it would allow reusing the allocator shim code for handling default implementations of the upcoming externally implementable items feature on platforms that don't properly support weak symbols.

In addition to make this possible, the alloc error handler is now handled in a way such that it is possible to avoid using the allocator shim when liballoc is compiled without `no_global_oom_handling` if you use `#[alloc_error_handler]`. Previously this was only possible if you avoided liballoc entirely or compiled it with `no_global_oom_handling`. You still need to avoid libstd and to define the symbol that indicates that avoiding the allocator shim is unstable.
2025-10-14 19:47:29 +02:00
bors cb72965f4d Auto merge of #145513 - beepster4096:erasedereftemps, r=saethlin,cjgillot
Validate CopyForDeref and DerefTemps better and remove them from runtime MIR

(split from my WIP rust-lang/rust#145344)

This PR:
- Removes `Rvalue::CopyForDeref` and `LocalInfo::DerefTemp` from runtime MIR
    - Using a new mir pass `EraseDerefTemps`
    - `CopyForDeref(x)` is turned into `Use(Copy(x))`
    - `DerefTemp` is turned into `Boring`
        - Not sure if this part is actually necessary, it made more sense in rust-lang/rust#145344 with `DerefTemp` storing actual data that I wanted to keep from having to be kept in sync with the rest of the body in runtime MIR
- Checks in validation that `CopyForDeref` and `DerefTemp` are only used together
- Removes special handling for `CopyForDeref` from many places
- Removes `CopyForDeref` from `custom_mir` reverting rust-lang/rust#111587
    - In runtime MIR simple copies can be used instead
    - In post cleanup analysis MIR it was already wrong to use due to the lack of support for creating `DerefTemp` locals
    - Possibly this should be its own PR?
 - Adds an argument to `deref_finder` to avoid creating new `DerefTemp`s and `CopyForDeref` in runtime MIR.
     - Ideally we would just avoid making intermediate derefs instead of fixing it at the end of a pass / during shim building
 - Removes some usages of `deref_finder` that I found out don't actually do anything

r? oli-obk
2025-10-12 02:34:20 +00:00
bjorn3 b453c19e91 Move computation of allocator shim contents to cg_ssa
In the future this should make it easier to use weak symbols for the
allocator shim on platforms that properly support weak symbols. And it
would allow reusing the allocator shim code for handling default
implementations of the upcoming externally implementable items feature
on platforms that don't properly support weak symbols.
2025-10-10 13:04:55 +00:00
bjorn3 67b7b7f66b Support #[alloc_error_handler] without the allocator shim
Currently it is possible to avoid linking the allocator shim when
__rust_no_alloc_shim_is_unstable_v2 is defined when linking rlibs
directly as some build systems need. However this requires liballoc to
be compiled with --cfg no_global_oom_handling, which places huge
restrictions on what functions you can call and makes it impossible to
use libstd. Or alternatively you have to define
__rust_alloc_error_handler and (when using libstd)
__rust_alloc_error_handler_should_panic
using #[rustc_std_internal_symbol]. With this commit you can either use
libstd and define __rust_alloc_error_handler_should_panic or not use
libstd and use #[alloc_error_handler] instead. Both options are still
unstable though.

Eventually the alloc_error_handler may either be removed entirely
(though the PR for that has been stale for years now) or we may start
using weak symbols for it instead. For the latter case this commit is a
prerequisite anyway.
2025-10-10 13:04:53 +00:00
Camille Gillot 0f2b4700b0 Remove StatementKind::Deinit. 2025-10-10 12:57:24 +00:00
yukang 0e4df746ad prefer to use repeat_n over repeat and take 2025-10-09 01:24:55 +08:00
beepster4096 7201c1b95f remove DerefTemp and CopyFromDeref from runtime mir 2025-10-06 10:57:27 -07:00
bjorn3 7f0b2bb7d2 Fix rustc test suite 2025-10-06 10:29:01 +00:00
bjorn3 c7b4a1d58a Rustup to rustc 1.92.0-nightly (839222065 2025-10-05) 2025-10-06 10:11:18 +00:00
bjorn3 d89c480985 Sync from rust 839222065a 2025-10-06 10:00:12 +00:00
Folkert de Vries dd7c7d028d use codegen_instance_attrs in some additional places 2025-10-02 20:53:13 +02:00
bors cc00f45f28 Auto merge of #147055 - beepster4096:subtype_is_not_a_projection, r=lcnr
Turn ProjectionElem::Subtype into CastKind::Subtype

I noticed that drop elaboration can't, in general, handle `ProjectionElem::SubType`. It creates a disjoint move path that overlaps with other move paths. (`Subslice` does too, and I'm working on a different PR to make that special case less fragile.) If its skipped and treated as the same move path as its parent then `MovePath.place` has multiple possible projections. (It would probably make sense to remove all `Subtype` projections for the canonical place but it doesn't make sense to have this special case for a problem that doesn't actually occur in real MIR.)

The only reason this doesn't break is that `Subtype` is always the sole projection of the local its applied to. For the same reason, it works fine as a `CastKind` so I figured that makes more sense than documenting and validating this hidden invariant.

cc rust-lang/rust#112651, rust-lang/rust#133258

r? Icnr (bc you've been the main person dealing with `Subtype` it looks like)
2025-10-02 01:54:48 +00:00
bjorn3 b038641a28 Use #[ignore] rather than commenting out for disabling sysroot tests 2025-10-01 14:38:26 +00:00
bjorn3 fdaf80466e Add note about FreeBSD TLS problems to Readme.md 2025-10-01 13:37:35 +00:00
bjorn3 ed6fbc28e3 Stop building rtstartup
It is no longer used by rustc on 64bit MinGW and we don't support 32bit
MinGW anyway.
2025-10-01 13:17:17 +00:00
bjorn3 d0475ed72c Merge pull request rust-lang/rustc_codegen_cranelift#1598 from rust-lang/compiler_builtins_compare_type
Use the correct return type for compiler-builtins float compares
2025-10-01 14:55:34 +02:00
bjorn3 775ae5e655 Merge pull request rust-lang/rustc_codegen_cranelift#1599 from rust-lang/fix_freebsd_ci
Fix FreeBSD CI
2025-10-01 14:54:16 +02:00
bjorn3 992c2c6b01 Use the correct return type for compiler-builtins float compares 2025-10-01 12:02:09 +00:00
bjorn3 099e5d2572 Update Cirrus CI to FreeBSD 14.2 2025-10-01 11:51:52 +00:00
bjorn3 160c1091fb Fix rustc test suite 2025-10-01 10:30:11 +00:00
bjorn3 d923ff4f4b Rustup to rustc 1.92.0-nightly (fa3155a64 2025-09-30) 2025-10-01 10:17:28 +00:00
bjorn3 1c36e8b562 Sync from rust fa3155a644 2025-10-01 10:07:04 +00:00
bjorn3 6b3ada06c3 Use rustc --print host-tuple 2025-10-01 10:00:48 +00:00
bors 46ce2bf9ed Auto merge of #147145 - Zalathar:rollup-s7kcs3w, r=Zalathar
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#147100 (tests: Remove ignore-android directive for fixed issue)
 - rust-lang/rust#147116 (compiler: remove AbiAlign inside TargetDataLayout)
 - rust-lang/rust#147134 (remove explicit deref of AbiAlign for most methods)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-29 08:43:49 +00:00
Jubilee Young 5569e6b205 remove explicit deref of AbiAlign for most methods
Much of the compiler calls functions on Align projected from AbiAlign.
AbiAlign impls Deref to its inner Align, so we can simplify these away.
Also, it will minimize disruption when AbiAlign is removed.

For now, preserve usages that might resolve to PartialOrd or PartialEq,
as those have odd inference.
2025-09-28 15:02:14 -07:00
Antoni Boucher de53737f63 Add a leading dash to linker plugin arguments in the gcc codegen 2025-09-28 13:57:33 -04:00