Skip to content

Closure symbols no longer contain hashes and also collide #12400

Closed
@alexcrichton

Description

@alexcrichton

With this code:

fn foo(a: ||) {}

fn main() {
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
    foo(|| println!("hello!"));
}

I inspected the disassembly via:

$ rustc foo.rs --emit=ir
$ cat foo.ll | grep 'define.*closure'
define internal void @_ZN4main7closureE1(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE2(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE3(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE4(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE5(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE6(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE7(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE8(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE9(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE10(i8*) unnamed_addr #5 {
define internal void @_ZN4main7closureE(i8*) unnamed_addr #5 {

LLVM is silently renaming our closure symbols by appending numbers at the end of them. This is causing the symbols to not be able to get de-mangled (they don't end in E). Additionally, there is no hash information about the type or the crate which I think we expect in all of our symbols.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions