Commit Graph

3845 Commits

Author SHA1 Message Date
Jacob Pratt
f08302065b Rollup merge of #157691 - cezarbbb:staticlib-move-symbol-edit, r=petrochenkov
Move symbol hiding code to a new file

Move the symbol visibility editing code (`apply_hide` and helpers) from
`archive.rs` into a new `symbol_edit.rs` module.

This is a pure code move with no functional changes — extracted to reduce
the size of `archive.rs` and to provide a natural home for future symbol
editing logic (e.g. renaming, rust-lang/rust#156950).

Requested in https://github.com/rust-lang/rust/pull/156950#discussion_r3382313460.

r? @petrochenkov
2026-06-11 00:34:17 -04:00
bors
485ec3fbcc Auto merge of #157480 - nikic:captures-metadata, r=RalfJung
Set !captures metadata for store of &Freeze

When a `&Freeze` reference is stored (with retag), emit `!captures !{!"address", !"read_provenance"}` metadata to indicate that it's UB to write through the stored pointer.

Related to https://github.com/rust-lang/rust/issues/146844.

r? @ghost
2026-06-10 11:12:13 +00:00
cezarbbb
8ee1dfa887 Move symbol hiding code to a new file 2026-06-10 11:04:36 +08:00
Nikita Popov
a3a6342542 Set !captures metadata for store of &Freeze
When a `&Freeze` reference is stored (with retag), emit
`!captures !{!"address", !"read_provenance"}` metadata to indicate
that it's UB to write through the stored pointer.
2026-06-09 17:39:01 +02:00
bjorn3
993bda7e9d Fix rust-analyzer-proc-macro-srv 2026-06-09 15:39:28 +02:00
Jonathan Brouwer
87749cea75 Rollup merge of #157588 - scottmcm:copy-nsuw, r=saethlin
Use `mul nuw nsw` in `intrinsics::copy`

Essentially the same as rust-lang/rust#157560, just for `copy` instead of `copy_nonoverlapping`.

> Yeah, in fact both copy and copy_nonoverlapping could use this since we know the result must be at most isize::MAX else it cannot be inbounds.
> ~ https://github.com/rust-lang/rust/pull/157560#issuecomment-4642072687

r? saethlin
2026-06-08 09:41:58 +02:00
Jonathan Brouwer
d7bcfdb13f Rollup merge of #155338 - cezarbbb:staticlib-symbol-hygiene, r=petrochenkov
Staticlib hide internal symbols

According to issue rust-lang/rust#104707, when building a staticlib, all Rust internal symbols — mangled symbols, `#[rustc_std_internal_symbol]` items, allocator shims, etc. — leak out of the static archive. In contrast, cdylib correctly exports only `#[no_mangle]` symbols via a linker version script.

`-Zstaticlib-hide-internal-symbols` directly post-processes ELF object files in the archive: parsing the `SHT_SYMTAB` sections and setting `STV_HIDDEN` visibility on any `GLOBAL/WEAK` defined symbol that is not in the exported symbol set, without changing the binding. This is an in-place modification (only writing the st_other byte per matching entry), with zero overhead.

Supported on ELF targets (Linux, BSD, etc.) and Apple targets (macOS, iOS, etc.). On unsupported targets (Windows), a warning is emitted and the flag has no effect.

**Update**: The rename counterpart (`-Zstaticlib-rename-internal-symbols`) is in rust-lang/rust#156950.

The test code are as follows:

1.a std rust staticlib:
```rust
use std::collections::HashMap;
use std::panic::{catch_unwind, AssertUnwindSafe};

#[no_mangle]
pub extern "C" fn my_add(a: i32, b: i32) -> i32 { a + b }

#[no_mangle]
pub extern "C" fn my_hash_lookup(key: u64) -> u64 {
    let mut map = HashMap::new();
    for i in 0..100u64 { map.insert(i, i.wrapping_mul(2654435761)); }
    *map.get(&key).unwrap_or(&0)
}

pub fn internal_reverse(s: &str) -> String { s.chars().rev().collect() }

#[no_mangle]
pub extern "C" fn my_format_number(n: i32) -> i32 {
    let s = format!("number: {}", n); s.len() as i32
}

#[no_mangle]
pub extern "C" fn my_safe_div(a: i32, b: i32) -> i32 {
    match catch_unwind(AssertUnwindSafe(|| {
        if b == 0 { panic!("division by zero!"); }
        a / b
    })) {
        Ok(result) => result,
        Err(_) => -1,
    }
}

#[no_mangle]
pub extern "C" fn my_uncaught_panic() { panic!("uncaught panic across FFI"); }
```

1.b downstream c program:
```c
extern int my_add(int a, int b);
extern unsigned long my_hash_lookup(unsigned long key);
extern int my_format_number(int n);
extern int my_safe_div(int a, int b);
extern void my_uncaught_panic(void);

int main() {
    int failures = 0;
    if (my_add(10, 20) != 30) failures++;
    if (my_hash_lookup(5) != 5UL * 2654435761UL) failures++;
    if (my_format_number(42) != 10) failures++;
    if (my_safe_div(100, 5) != 20) failures++;
    if (my_safe_div(100, 0) != -1) failures++;
    pid_t pid = fork();
    if (pid == 0) { alarm(5); my_uncaught_panic(); _exit(0); }
    else { waitpid(pid, &status, 0); }
    return failures;
}
```

The test results with different compiler flags(which might cause binary size reduction) are as follows:
1.c result with `-Zstaticlib-hide-internal-symbols`
```
  settings                   OFF        ON  -Zsave     ALL    OFF.dynsym ON.dynsym
  ------------------------------------------------------------------------
  default                 1.7M      1.5M  204K (12%)    1735       5    1730
  lto_thin                616K      584K  33K (5%)     246       5     241
  lto_fat                 525K      525K    0 (0%)       6       5       1
  opt_s                   1.7M      1.5M  204K (12%)    1735       5    1730
  opt_z                   1.7M      1.5M  204K (12%)    1735       5    1730
  lto_thin_z              602K      570K  32K (5%)     246       5     241
  lto_fat_z               514K      514K    0 (0%)       6       5       1
  full                    514K      514K    0 (0%)       6       5       1
```

1.d result with `-Zstaticlib-hide-internal-symbols + -Zstaticlib-rename-internal-symbols`
```
  settings                   OFF        ON  -Zsave     ALL    OFF.dynsym ON.dynsym
  ------------------------------------------------------------------------
  default                 1.7M      1.5M  162K (9%)    1735       5    1730
  lto_thin                616K      599K  18K (2%)     246       5     241
  lto_fat                 525K      535K  -1% (-1%)       6       5       1
  opt_s                   1.7M      1.5M  162K (9%)    1735       5    1730
  opt_z                   1.7M      1.5M  162K (9%)    1735       5    1730
  lto_thin_z              602K      585K  18K (2%)     246       5     241
  lto_fat_z               514K      524K  -1% (-1%)       6       5       1
  full                    514K      523K  -1% (-1%)       6       5       1
```

2.a no_std rust staticlib
```rust
#![no_std]
#![feature(core_intrinsics)]

use core::panic::PanicInfo;

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! { loop {} }

#[no_mangle]
pub extern "C" fn embedded_add(a: i32, b: i32) -> i32 { a.wrapping_add(b) }

#[no_mangle]
pub extern "C" fn embedded_checksum(data: *const u8, len: usize) -> u8 {
    if data.is_null() { return 0; }
    let slice = unsafe { core::slice::from_raw_parts(data, len) };
    let mut sum: u8 = 0;
    for &byte in slice { sum = sum.wrapping_add(byte); }
    sum
}

fn internal_helper() -> i32 { 42 }
#[no_mangle]
pub extern "C" fn call_internal() -> i32 { internal_helper() }

#[no_mangle]
pub extern "C" fn embedded_trigger_abort() { core::intrinsics::abort(); }
```
2.b downstream c program
```c
extern int embedded_add(int a, int b);
extern unsigned char embedded_checksum(const unsigned char *data, unsigned long len);
extern int call_internal(void);
extern void embedded_trigger_abort(void);

int main() {
    int failures = 0;
    if (embedded_add(10, 20) != 30) failures++;
    unsigned char data[] = {1, 2, 3};
    if (embedded_checksum(data, 3) != 6) failures++;
    if (call_internal() != 42) failures++;
    pid_t pid = fork();
    if (pid == 0) { embedded_trigger_abort(); _exit(0); }
    else { waitpid(pid, &status, 0); }
    return failures;
}
```

The test results with different compiler flags(which might cause binary size reduction) are as follows:
2.c result with `-Zstaticlib-hide-internal-symbols`
```
  settings                   OFF        ON  -Zsave     ALL    OFF.dynsym ON.dynsym
  ------------------------------------------------------------------------
  default                 485K      429K  56K (11%)     490       4     486
  lto_thin                180K      180K    0 (0%)       4       4       0
  lto_fat                 179K      179K    0 (0%)       4       4       0
  opt_s                   485K      429K  56K (11%)     490       4     486
  opt_z                   485K      429K  56K (11%)     490       4     486
  lto_thin_z              180K      180K    0 (0%)       4       4       0
  lto_fat_z               179K      179K    0 (0%)       4       4       0
  full                    179K      179K    0 (0%)       4       4       0
```

2.d result with `-Zstaticlib-hide-internal-symbols + -Zstaticlib-rename-internal-symbols`
```
  settings                   OFF        ON  -Zsave     ALL    OFF.dynsym ON.dynsym
  ------------------------------------------------------------------------
  default                 485K      447K  39K (7%)     490       4     486
  lto_thin                180K      189K  -5% (-5%)       4       4       0
  lto_fat                 179K      189K  -5% (-5%)       4       4       0
  opt_s                   485K      448K  38K (7%)     490       4     486
  opt_z                   485K      448K  38K (7%)     490       4     486
  lto_thin_z              180K      189K  -5% (-5%)       4       4       0
  lto_fat_z               179K      189K  -5% (-5%)       4       4       0
  full                    179K      189K  -5% (-5%)       4       4       0
```

Test results show that this compiler option is beneficial for scenarios where LTO cannot be enabled.

r? @bjorn3 @petrochenkov
2026-06-08 09:41:54 +02:00
cezarbbb
6caae67115 add -Zstaticlib-hide-internal-symbols 2026-06-08 08:33:13 +08:00
Scott McMurray
871664e02a Also use mul nuw nsw in intrinsics::copy
Essentially the same as 157560, just for `copy` instead of `copy_nonoverlapping`.
2026-06-07 16:57:55 -07:00
Jacob Pratt
753665aff6 Rollup merge of #157560 - scottmcm:mul_nuw_nsw_in_memcpy, r=saethlin
In `copy_nonoverlapping`, use `mul nuw nsw` to compute the byte size

Seems like we might as well?  Adding these flags means the optimizer can tell the limited range on the count of items -- like how we use these flags (rust-lang/rust#136575) when calculating `size_of_val` for a slice.

Today we use a wrapping multiplication, which mean that `copy_nonoverlapping::<u32>(src, dst, 0x40000000_00000001)` appears like 4 bytes -- a perfectly reasonable size! -- once it gets to the `memcpy` call.

If I'm understanding <https://doc.rust-lang.org/std/ptr/fn.copy_nonoverlapping.html#safety> properly, this is just exploiting existing UB, since `src` and `dst` must each be inside an allocation, and those allocations can be at most `isize::MAX` bytes.  (Plus, fundamentally, to be non-overlapping there's not enough space in the address space to be bigger than `isize::MAX`.)

cc @RalfJung to make sure this is ok, as requested last he found out I was newly exploiting some UB in codegen 🙃
r? codegen
2026-06-07 17:47:55 -04:00
bjorn3
f484629863 Assert incr comp in copy_cgu_workproduct_to_incr_comp_cache_dir
It was already only called when incr comp is enabled and this allows
cleaning up the callers a bit.
2026-06-07 13:24:14 +00:00
bjorn3
9419baeee8 Use WorkProductMap instead of FxIndexMap
This is an UnordMap internally. Iteration order for the work product map
should not matter aside from the place it is serialized where sorting by
WorkProductId is sufficient.
2026-06-07 13:24:12 +00:00
Scott McMurray
4af2ca0a93 In copy_nonoverlapping, use mul nuw nsw to compute the byte count 2026-06-06 21:57:35 -07:00
bjorn3
f9f9adbf39 Introduce -Zdisable-incr-comp-backend-caching
This disables caching of compiled objects by the codegen backend during
incremental compilation. This is useful for iterating on a codegen
backend without having to run the entire rustc frontend from scratch
every time when recompiling the standard library. Currently cg_clif has
the CG_CLIF_DISABLE_INCR_CACHE env var that does this, but once cg_clif
switches to the codegen coordinator of cg_ssa, it will no longer be
possible for cg_clif to implement this. It has to be implemented in
cg_ssa.
2026-06-04 16:53:16 +02:00
Jacob Pratt
fa82c8dc3e Rollup merge of #156210 - BorrowSanitizer:codegen-emit-retag-2, r=saethlin
Emit retags in codegen to support BorrowSanitizer (part 2)

Tracking issue: rust-lang/rust#154760
[Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/593004012)

This is one of several PRs that will add experimental support for emitting retags as function calls in codegen. Each PR will be a minimal, improved slice of the changes in rust-lang/rust#155965.

This PR adds a new unstable flag `-Zcodegen-emit-retag`, which will enable experimental retag calls in generated code. This flag is a nop for now, but the relevant methods have been added to codegen_ssa, and they are called wherever retags are necessary. Subsequent PRs will complete this implementation.

This does not depend on rust-lang/rust#156208.

r? @RalfJung
2026-06-03 21:49:45 -04:00
Jonathan Brouwer
f764d7cf02 Rollup merge of #157336 - JarlEvanson:mem-replace-with-default, r=JonathanBrouwer
Enable `clippy::mem_replace_with_default`

Enables `clippy::mem_replace_with_default` and fixes the errors that occur as a result.

Closes rust-lang/rust#157245.
2026-06-03 14:27:16 +02:00
Jonathan Brouwer
266eb48e34 Rollup merge of #156928 - bjorn3:emscripten_always_wasm_eh, r=TaKO8Ki
Remove -Zemscripten-wasm-eh

This was necessary when transitioning from JS to wasm exception handling on Emscripten. Enough time has probably passed that we no longer need to support JS exception handling on Emscripten. This enables cleaning up a fair bit of code.

This is the final step of https://github.com/rust-lang/rust/issues/112195.
2026-06-03 14:27:09 +02:00
Jonathan Brouwer
cccb16ea98 Rollup merge of #157311 - jdonszelmann:weak-linkage-eii, r=bjorn3
Use weak linkage for EII defaults

hard to find a test for this, but weak seems more correct (after private discussion with @bjorn3)

Also changes a log statement to make it a lil easier to see what's going on.

r? @bjorn3
2026-06-03 14:27:08 +02:00
Jonathan Brouwer
25b195f403 Rollup merge of #157263 - petrochenkov:arentry, r=bjorn3
rustc_codegen_ssa: Refactor `ArchiveEntry` to include entry kind

Needed for https://github.com/rust-lang/rust/pull/155338 in particular.

r? @bjorn3
2026-06-03 14:27:07 +02:00
Jarl Evanson
3dacac8f4b compiler: fix clippy::mem_replace_with_default warnings 2026-06-02 20:37:47 +00:00
bjorn3
9b7623a162 Remove -Zemscripten-wasm-eh
This was necessary when transitioning from JS to wasm exception handling
on Emscripten. Enough time has probably passed that we no longer need to
support JS exception handling on Emscripten. This enables cleaning up a
fair bit of code.
2026-06-02 19:56:40 +02:00
Vadim Petrochenkov
d39ecc046e rustc_codegen_ssa: check whether add_archive argument is a rlib 2026-06-02 18:53:11 +03:00
Vadim Petrochenkov
0e1bd7ccf9 rustc_codegen_ssa: Refactor ArchiveEntry to include entry kind 2026-06-02 18:53:11 +03:00
Jana Dönszelmann
bef59cd138 Use weak linkage (otherwise we can't compile .so files with eiis in them) 2026-06-02 14:57:40 +02:00
Jonathan Brouwer
99bb120cf8 Rollup merge of #157130 - alexcrichton:refactor-cast-target-internals, r=nnethercote
Use a `ArrayVec` in `CastTarget`

This commit switches a fixed-size list of `[Option<Reg>; 8]` to instead
holding `ArrayVec<Reg, 8>` in the `CastTarget` type used when
calculating ABIs. This is inspired by [discussion on Zulip][link] where
I'm hoping to in the near future extend the usage of this to possibly
beyond 8 elements for a new WebAssembly ABI taking advantage of
multi-value. For now though this mostly just switches to
array/slice-like idioms of accessors rather than dealing with
`Option<Reg>` as the unit.

[link]: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20.60ArgAbi.3A.3Amake_direct_deprecated.60/with/598607139
2026-06-02 13:20:49 +02:00
bors
4a31759ad1 Auto merge of #157266 - JonathanBrouwer:rollup-EIe7NPQ, r=JonathanBrouwer
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#156085 (miri: require (almost) all 1-ZST arguments to be actually passed)
 - rust-lang/rust#155193 (Check arguments of attributes where no arguments are expected)
 - rust-lang/rust#156516 (nix: remove some unneeded variables)
 - rust-lang/rust#156562 (Resolving Windows environment test failures)
 - rust-lang/rust#156588 (Don't drop uninit memory when `MapWindows::clone` panics)
 - rust-lang/rust#156673 (Privacy: small cleanups)
 - rust-lang/rust#156817 (Add `#[unsafe_eii]` to unsafe EII UI tests)
 - rust-lang/rust#156924 (Use #[panic_handler] rather than #[lang = "panic_impl"])
 - rust-lang/rust#157055 (LLVM 23: Run AssignGUIDPass in some places)
 - rust-lang/rust#157108 (Add Xtensa va_arg assembly coverage)
 - rust-lang/rust#157220 (cg_ssa: a bit less `immediate_or_packed_pair`)
 - rust-lang/rust#157241 (Trace `?id.local_def_index` instead of `id` in `def_path_hash`)
 - rust-lang/rust#157242 (Tune backport Zulip messages)
2026-06-01 22:40:01 +00:00
bors
6bdf43094f Auto merge of #157094 - khyperia:UnevaluatedConstKind, r=BoxyUwU
introduce UnevaluatedConstKind

(no rush on this, boxy, if you get this notif, I know you're on break after rustweek)

Partially fixes https://github.com/rust-lang/project-const-generics/issues/98

- does not unify GCE `ConstKind::Expr` into Unevaluated, which is part of that issue
- does not do more advanced refactoring to take advantage of the new kind repr, only refactoring when things are very obviously able to take advantage
- does not change MIR's UnevaluatedConst to use UnevaluatedConstKind, as there's currently no benefit, and doing so instead overcomplicates many places. Possibly could be done in a followup, or I can do it here if desired.
- more advanced potentially behavior-changing changes can be done in a followup, as this diff is big enough as it is, IMO. same with merging GCE Exprs into Unevaluated.
  - (... but if this takes a while to get reviewed, I might plop some more stuff into this PR)
- I think it would be cute to rename UnevaluatedConst to AliasConst or something, to better reflect the parallels to AliasTy, but shrug, haha

r? @BoxyUwU
2026-06-01 19:27:54 +00:00
Jonathan Brouwer
78ef36cbbf Rollup merge of #157220 - scottmcm:less-from-packed-pair, r=dianqk
cg_ssa: a bit less `immediate_or_packed_pair`

This is one of the things that made cg_clif not use cg_ssa, IIRC, so let's take the opportunities to avoid it where we can.

r? codegen
2026-06-01 19:35:52 +02:00
Alex Crichton
c668b83eed Use a ArrayVec in CastTarget
This commit switches a fixed-size list of `[Option<Reg>; 8]` to instead
holding `ArrayVec<Reg, 8>` in the `CastTarget` type used when
calculating ABIs. This is inspired by [discussion on Zulip][link] where
I'm hoping to in the near future extend the usage of this to possibly
beyond 8 elements for a new WebAssembly ABI taking advantage of
multi-value. For now though this mostly just switches to
array/slice-like idioms of accessors rather than dealing with
`Option<Reg>` as the unit.

[link]: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20.60ArgAbi.3A.3Amake_direct_deprecated.60/with/598607139
2026-06-01 07:34:12 -07:00
Scott McMurray
dfc475d018 cg_ssa: a bit less immediate_or_packed_pair
This is one of the things that made cg_clif not use cg_ssa, IIRC, so let's take the opportunities to avoid it where we can.
2026-05-31 13:19:56 -07:00
Camille Gillot
a27155e691 Remove async_fut.
This is now unused.
2026-05-31 16:02:15 +00:00
Jonathan Brouwer
a5f745740f Rollup merge of #156887 - zamazan4ik:rename-debuginfo-for-profiling-switch, r=folkertdev
Rename `-Zdebuginfo-for-profiling` switch

The PR was raised from this [comment](https://github.com/rust-lang/rust/pull/155942#discussion_r3188023601) from another stabilization PR: https://github.com/rust-lang/rust/pull/155942

I renamed `-Zdebug-info-for-profiling` into `-Zdebuginfo-for-profiling` before stabilization to be consistent with other `debuginfo`-related Rustc flags like `-C split-debuginfo` and `-C debuginfo`.

One important note is that Clang has the [flag](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fdebug-info-for-profiling) under `-fdebug-info-for-profiling`. I decided that consistency with other Rustc flags is more important here than to be consistent with Clang.

r? folkertdev (as was proposed [here](https://github.com/rust-lang/rust/pull/155942#issuecomment-4527927374))
2026-05-30 18:01:55 +02:00
Jonathan Brouwer
cf39dc63f4 Rollup merge of #157139 - scottmcm:abi-range-inclusive, r=oli-obk
compiler: `ops::RangeInclusive` → `range::RangeInclusive`

The type's been stable for over 6 weeks now, so let's use it!  It's better for cases like this one where it's stored in a data structure.

Probably won't be materially faster, but does make the variant slightly smaller and lets some more things be `Copy`.  And deletes a whole bunch of parens from things being fields instead of methods 😄

r? compiler
2026-05-30 11:40:21 +02:00
Jonathan Brouwer
b8c03eeded Rollup merge of #157051 - bjorn3:lto_refactors20, r=saethlin
Allow two object files for a single CGU in CompiledModule

cg_clif needs this as it passes inline assembly to an external assembler, producing a separate object file. Currently it emits multiple CompiledModules, but this is not compatible with using the codegen coordinator of cg_ssa.
2026-05-30 11:40:16 +02:00
Scott McMurray
f7cf361f3c compiler: ops::RangeInclusive → range::RangeInclusive
The type's been stable for over 6 weeks now, so let's use it!  It's better for cases like this one where it's stored in a data structure.

Probably won't be materially faster, but does make the variant slightly smaller and lets some more things be `Copy`.
2026-05-29 21:57:45 -07:00
Jonathan Brouwer
0357abe7a4 Rollup merge of #157068 - kjetilkjeka:remove-ptx-linker-flavor, r=petrochenkov
NVPTX: Remove the unstable ptx linker flavor

Remove the ptx linker flavor as specified in [this accepted MCP](https://github.com/rust-lang/compiler-team/issues/990)

Fixes rust-lang/rust#156954

@rustbot label +O-NVPTX
2026-05-29 21:03:26 +02:00
Kjetil Kjeka
ec46eac2ad NVPTX: Remove the deprecated ptx linker flavor 2026-05-29 11:39:51 +02:00
Jonathan Brouwer
ff278757bd Rollup merge of #157050 - bjorn3:lto_refactors19, r=lqd
Couple of changes to help with moving LTO to the link phase

Part of https://github.com/rust-lang/compiler-team/issues/908
2026-05-29 09:06:20 +02:00
khyperia
8777302dee introduce UnevaluatedConstKind 2026-05-29 07:57:04 +02:00
bjorn3
e731b4e5f9 Allow two object files for a single CGU in CompiledModule
cg_clif needs this as it passes inline assembly to an external assembler,
producing a separate object file. Currently it emits multiple
CompiledModules, but this is not compatible with using the codegen
coordinator of cg_ssa.
2026-05-28 09:20:02 +00:00
bjorn3
32b61075f5 Implement ModuleBufferMethods for Infallible
This would be useful for codegen backends that don't support LTO, yet do
want to implement WriteBackendMethods.
2026-05-28 09:16:54 +00:00
bjorn3
3ef6839930 Inline a small function 2026-05-28 09:16:49 +00:00
bjorn3
9f8820be29 Support implementing ExtraBackendMethods and WriteBackendMethods independently 2026-05-28 09:15:36 +00:00
Guillaume Gomez
dc05df7ebe Rollup merge of #157022 - RalfJung:inline-intrinsics-v2, r=oli-obk
MIR inlining: allow backends to opt-in to inlining intrinsics

This is the same as https://github.com/rust-lang/rust/pull/156398. Github stopped processing updates on that other branch.

r? @oli-obk
2026-05-27 20:45:10 +02:00
Ralf Jung
59428e76e8 MIR inlining: allow backends to opt-in to inlining intrinsics 2026-05-27 13:59:25 +02:00
Jonathan Brouwer
aa9d13374b Rollup merge of #156814 - cezarbbb:fix-issue-156714, r=jieyouxu
Extend macOS deployment target mismatch filter to cover dylib and new ld formats

The `deployment_mismatch` filter in `report_linker_output` only matched the old ld64 format for object files. With linker-messages promoted to warn-by-default in rust-lang/rust#153968, unfiltered deployment target warnings from dylibs and the new Apple linker (ld_prime) now surface as noise for users who never set `MACOSX_DEPLOYMENT_TARGET`.

Fixes rust-lang/rust#156714.

At present, the filter works only covered the specific format:

`ld: warning: object file (...) was built for newer 'macOS' version (...) than being linked (...)`

This was fine because linker-messages was `Allow-by-default` — nobody saw the other formats anyway. Then rust-lang/rust#153968 promoted it to Warn, and the gaps became visible.

Broadens the filter to cover all known ld deployment target version mismatch formats:

`ld: warning: object file (...)` — old ld64, already handled
`ld: warning: dylib (...)` — old ld64, was missing
All Apple platforms (`iOS`, `tvOS`, `watchOS`, `xrOS`, etc.), not just `macOS`
`ld: building for <platform>-A.B, but linking with dylib '...' which was built for newer version C.D` — new linker (ld_prime, Xcode 15+), the exact format from rust-lang/rust#156714

All matched messages are downgraded to `linker_info` (Allow-by-default), consistent with the existing behavior for the object file case.
2026-05-27 08:14:26 +02:00
cezarbbb
52bedb4c05 Suppress macOS deployment target linker warnings from ld_prime 2026-05-27 11:32:09 +08:00
Alexander Zaitsev
bcf900133d feat: rename debug-info-for-profiling switch 2026-05-24 20:17:07 +02:00
bors
23a3312d92 Auto merge of #156116 - scottmcm:tweak-layout-of-alternative, r=dianqk
Stop needing materialized places for most intrinsics



Today even to return a constant from `size_of_val` it takes an `alloca`.  That's wasteful.

This updates the cg_ssa traits to allow returning an `OperandValue` instead, which is possible for the vast majority of intrinsics -- this PR moves all but 5 over to doing that in LLVM.

The first commit adds a test to help show the difference here.

cc https://github.com/rust-lang/compiler-team/issues/970 https://github.com/rust-lang/rust/issues/153250
2026-05-23 19:23:06 +00:00
Scott McMurray
d3d3485dd4 Let intrinsics use the SSA operand path 2026-05-22 22:02:06 -07:00