Skip to content

Symbol names for generics are not stable across crates #32554

Closed
@dotdash

Description

@dotdash

Given this:
cgu.rs

#![crate_type="lib"]
pub fn id<T>(t: T) -> T {
  t
}
pub fn user() {
  id(0);
}

a.rs

#![crate_type="lib"]
extern crate cgu;
pub fn user() {
  cgu::id(0);
}

We get two different symbol names for the monomorphizations of id.

cgu.ll

define internal i32 @_ZN3cgu2id17h7cbc0f1ce1830012E(i32) unnamed_addr #0 {
entry-block:
  %dropflag_hint_6 = alloca i8
  %t = alloca i32
  store i8 61, i8* %dropflag_hint_6
  store i32 %0, i32* %t
  %1 = load i32, i32* %t
  ret i32 %1
}

a.ll

define internal i32 @_ZN3cgu2id17h8a873a51d5137f87E(i32) unnamed_addr #0 {
entry-block:
  %t = alloca i32
  store i32 %0, i32* %t
  %1 = load i32, i32* %t
  ret i32 %1
}

cc @nikomatsakis @michaelwoerister

Metadata

Metadata

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