Skip to content

extern_weak linkage on definition not rejected #137627

Open
@matthiaskrgr

Description

@matthiaskrgr

I tried this code:

#![feature(linkage)]
#![crate_type = "rlib"]

#[linkage = "extern_weak"]
pub static EXTERN: u32 = 42;

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (617aad8c2 2025-02-24)
binary: rustc
commit-hash: 617aad8c2e8783f6df8e5d1f8bb1e4bcdc70aa7b
commit-date: 2025-02-24
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0
Backtrace

error: rustc interrupted by SIGILL, printing backtrace

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-19054624313a00ee.so(+0x37010df) [0x7cb3fc7010df]
/usr/lib/libc.so.6(+0x3dcd0) [0x7cb3f8e4bcd0]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(+0x8bd2096) [0x7cb3f7dd2096]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(_ZN4llvm10AsmPrinter18emitGlobalVariableEPKNS_14GlobalVariableE+0x35a) [0x7cb3f70e40da]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(_ZN4llvm10AsmPrinter14doFinalizationERNS_6ModuleE+0x219) [0x7cb3f70e546d]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(_ZN4llvm13FPPassManager14doFinalizationERNS_6ModuleE+0x2a) [0x7cb3f702a2ea]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.20.1-rust-1.87.0-nightly(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x3ff) [0x7cb3f7634493]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-19054624313a00ee.so(+0x5bb8b82) [0x7cb3febb8b82]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-19054624313a00ee.so(+0x5bb86e1) [0x7cb3febb86e1]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-19054624313a00ee.so(+0x5bb5e33) [0x7cb3febb5e33]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-19054624313a00ee.so(+0x5bb5ae8) [0x7cb3febb5ae8]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-19054624313a00ee.so(_RINvNtNtCs5JDsLVAy2fO_3std3sys9backtrace28___rust_begin_short_backtraceNCINvXs0_Cs2p9PGD2gg2l_18rustc_codegen_llvmNtB1g_18LlvmCodegenBackendNtNtNtCsjc85tVovh2m_17rustc_codegen_ssa6traits7backend19ExtraBackendMethods18spawn_named_threadNCINvNtNtB2k_4back5write10spawn_workB1O_E0uE0uEB1g_+0x2eb) [0x7cb3febb452b]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-19054624313a00ee.so(+0x5bad822) [0x7cb3febad822]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-19054624313a00ee.so(+0x5bad2ab) [0x7cb3febad2ab]
/usr/lib/libc.so.6(+0x9570a) [0x7cb3f8ea370a]
/usr/lib/libc.so.6(+0x119aac) [0x7cb3f8f27aac]

note: we would appreciate a report at https://github.com/rust-lang/rust
[1]    4158672 illegal hardware instruction  RUST_BACKTRACE=full rustc a.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.F-linkage#![feature(linkage)]`I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions