rust/compiler/rustc_codegen_llvm/src
bors c8b7f32434 Auto merge of #140176 - dpaoliello:arm64ecdec, r=wesleywiser
Fix linking statics on Arm64EC

Arm64EC builds recently started to fail due to the linker not finding a symbol:
```
symbols.o : error LNK2001: unresolved external symbol #_ZN3std9panicking11EMPTY_PANIC17hc8d2b903527827f1E (EC Symbol)
          C:\Code\hello-world\target\arm64ec-pc-windows-msvc\debug\deps\hello_world.exe : fatal error LNK1120: 1 unresolved externals
```

It turns out that `EMPTY_PANIC` is a new static variable that was being exported then imported from the standard library, but when exporting LLVM didn't prepend the name with `#` (as only functions are prefixed with this character), whereas Rust was prefixing with `#` when attempting to import it.

The fix is to have Rust not prefix statics with `#` when importing.

Adding tests discovered another issue: we need to correctly mark static exported from dylibs with `DATA`, otherwise MSVC's linker assumes they are functions and complains that there is no exit thunk for them.

CI found another bug: we only apply `DllImport` to non-local statics that aren't foreign items (i.e., in an `extern` block), that is we want to use `DllImport` for statics coming from other Rust crates. However, `__rust_no_alloc_shim_is_unstable` is a static generated by the Rust compiler if required, but downstream crates consider it a foreign item since it is declared in an `extern "Rust"` block, thus they do not apply `DllImport` to it and so fails to link if it is exported by the previous crate as `DATA`. The fix is to apply `DllImport` to foreign items that are marked with the `rustc_std_internal_symbol` attribute (i.e., we assume they aren't actually foreign and will be in some Rust crate).

Fixes #138541

---
try-job: dist-aarch64-msvc
try-job: dist-x86_64-msvc
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
2025-05-09 00:43:28 +00:00
..
back Initial support for dynamically linked crates 2025-05-04 22:03:15 +03:00
builder add custom enzyme markers to target methods 2025-04-25 11:09:52 +05:30
coverageinfo Rename Instance::new to Instance::new_raw and add a note that it is raw 2025-05-05 13:17:35 +00:00
debuginfo Initial support for dynamically linked crates 2025-05-04 22:03:15 +03:00
llvm remove noinline attribute and add alwaysinline after AD pass 2025-04-28 21:10:32 +05:30
abi.rs Update the minimum external LLVM to 19 2025-04-05 11:44:38 -07:00
allocator.rs Remove implicit #[no_mangle] for #[rustc_std_internal_symbol] 2025-03-17 14:08:09 +00:00
asm.rs Pass &mut self to codegen_global_asm 2025-04-14 09:38:04 +00:00
attributes.rs remove noinline attribute and add alwaysinline after AD pass 2025-04-28 21:10:32 +05:30
base.rs Pass &mut self to codegen_global_asm 2025-04-14 09:38:04 +00:00
builder.rs Rollup merge of #139261 - RalfJung:msvc-align-mitigation, r=oli-obk 2025-04-24 11:40:35 +02:00
callee.rs Merge two operations that were always performed together 2025-02-20 11:24:00 +00:00
common.rs Reuse address-space computation from global alloc 2025-04-11 09:28:47 +00:00
consts.rs [Arm64EC] Only decorate functions with # 2025-05-07 10:36:12 -07:00
context.rs remove noinline attribute and add alwaysinline after AD pass 2025-04-28 21:10:32 +05:30
declare.rs Make allocator shim creation mostly use safe code 2025-02-24 15:11:29 +00:00
errors.rs KCFI: Add KCFI arity indicator support 2025-04-05 04:05:04 +00:00
intrinsic.rs Rename Instance::new to Instance::new_raw and add a note that it is raw 2025-05-05 13:17:35 +00:00
lib.rs Implement the internal feature cfg_target_has_reliable_f16_f128 2025-04-27 19:58:44 +00:00
llvm_util.rs Added apxf target feature support, under flag apx_target_feature 2025-05-06 23:28:27 +05:30
mono_item.rs Rename is_like_osx to is_like_darwin 2025-03-25 21:53:52 +01:00
type_.rs remove noinline attribute and add alwaysinline after AD pass 2025-04-28 21:10:32 +05:30
type_of.rs rename BackendRepr::Vector → SimdVector 2025-02-28 17:17:45 +01:00
va_arg.rs Rename is_like_osx to is_like_darwin 2025-03-25 21:53:52 +01:00
value.rs Add warn(unreachable_pub) to rustc_codegen_llvm. 2024-08-16 08:46:57 +10:00