Creating a lib crate with an empty distributed slice:
#[linkme::distributed_slice]
pub static SYSTEMS_SLICE: [fn()];
...and linking to that crate from a bin crate without adding any entries to the distributed slice causes lld-link (LLD 18.1.3) to exit with code 0xC0000005:
= note: PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.␍
Stack dump:␍
0. Program arguments: rust-lld -flavor link @C:\\Users\\lucien\\AppData\\Local\\Temp\\rustcPGJUjr\\linker-arguments␍
Exception Code: 0xC0000005␍
#0 0x00007ff7ea401646 (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0x501646)␍
#1 0x00007ff7ea0821f7 (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0x1821f7)␍
#2 0x00007ff7ea075521 (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0x175521)␍
#3 0x00007ff7e9fb6ba2 (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0xb6ba2)␍
#4 0x00007ff7e9fabd7c (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0xabd7c)␍
#5 0x00007ff7e9fab30e (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0xab30e)␍
#6 0x00007ff7e9f9e589 (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0x9e589)␍
#7 0x00007ff7e9f9eb57 (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0x9eb57)␍
#8 0x00007ff7ec1e3458 (C:\Users\lucien\.rustup\toolchains\1.88-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\bin\rust-lld.exe+0x22e3458)␍
#9 0x00007ffb18d2e8d7 (C:\WINDOWS\System32\KERNEL32.DLL+0x2e8d7)␍
#10 0x00007ffb18f3c34c (C:\WINDOWS\SYSTEM32\ntdll.dll+0x3c34c)␍
Adding a dummy entry to the slice within the crate defining the slice stops the error from happening:
#[linkme::distributed_slice(SYSTEMS_SLICE)]
static DUMMY_SYSTEM: fn() = || {};
Creating a lib crate with an empty distributed slice:
...and linking to that crate from a bin crate without adding any entries to the distributed slice causes lld-link (LLD 18.1.3) to exit with code
0xC0000005:Adding a dummy entry to the slice within the crate defining the slice stops the error from happening: