Skip to content

special link_name confuses LLVM #155776

@usamoi

Description

@usamoi

Inspired by #155495, I tried this code:

unsafe extern "C" {
    #[link_name = "\0"]
    safe fn hack();
}

pub fn main() {
    hack();
}

I expected to see this happen: rustc works or emits errors

Instead, this happened:

rustc: /checkout/src/llvm-project/llvm/lib/IR/Value.cpp:346: void llvm::Value::setNameImpl(const Twine &): Assertion `!NameRef.contains(0) && "Null bytes are not allowed in names"' failed.

Also, I tried this code:

unsafe extern "C" {
    #[link_name = ""]
    safe fn hack();
}

pub fn main() {
    hack();
}

I expected to see this happen:

rust-lld: error: undefined symbol: 

or rustc emits errors.

Instead, this happened:

rust-lld: error: undefined symbol: anon.ba0403d3885badc6dc2b3e34422528cb.0

Meta

There must be llvm.assertions = true in bootstrap.toml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions