rust-lang / rust-lang/rust

extern_weak linkage on definition not rejected

Open
#137,627 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-linkage A-LLVM C-bug F-linkage I-crash
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the provided nightly rustc command and minimal Rust snippet, using the backtrace as a starting clue. Trace how rustc handles #[linkage = "extern_weak"] on the static definition. Done means the invalid definition is rejected with a compiler diagnostic instead of reaching the SIGILL.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.