Skip to content

Panic in LLVM when using #[linkage] even with supported targets #33992

Closed
@mattico

Description

@mattico
λ cargo new test-linkage
λ cd test-linkage
λ cat src/lib.rs
#![feature(linkage)]

#[linkage = "extern_weak"]
pub static TEST: bool = false;

λ env RUST_BACKTRACE=1 cargo build --verbose # OR
λ env RUST_BACKTRACE=1 cargo build --verbose --target x86_64-unknown-linux-gnu
   Compiling test-linkage v0.1.0 (file:///C:/Users/Matt%20Ickstadt/Code/Rust/test-linkage)
     Running `rustc src\lib.rs --crate-name test_linkage --crate-type lib -g --out-dir "C:\Users\Matt Ickstadt\Code\Rust\test-linkage\target\x86_64-unknown-linux-gnu\debug" --emit=dep-info,link --target x86_64-unknown-linux-gnu -L "dependency=C:\Users\Matt Ickstadt\Code\Rust\test-linkage\target\x86_64-unknown-linux-gnu\debug" -L "dependency=C:\Users\Matt Ickstadt\Code\Rust\test-linkage\target\x86_64-unknown-linux-gnu\debug\deps"`
Don't know how to emit these
UNREACHABLE executed at C:/bot/slave/nightly-dist-rustc-win-gnu-32/build/src/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:336!

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
error: Could not compile `test-linkage`.

Caused by:
  Process didn't exit successfully: `rustc src\lib.rs --crate-name test_linkage --crate-type lib -g --out-dir C:\Users\Matt Ickstadt\Code\Rust\test-linkage\target\x86_64-unknown-linux-gnu\debug --emit=dep-info,link --target x86_64-unknown-linux-gnu -L dependency=C:\Users\Matt Ickstadt\Code\Rust\test-linkage\target\x86_64-unknown-linux-gnu\debug -L dependency=C:\Users\Matt Ickstadt\Code\Rust\test-linkage\target\x86_64-unknown-linux-gnu\debug\deps` (exit code: 3)

Nothing too unexpected, since most targets don't support weak linkage. The error message could be a bit better though, rather than panicing in LLVM.

I was a bit surprised that this problem persists when cross compiling to supported targets, but I suppose that its an LLVM limitation, and a very niche one at that.

cc #29603

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions