Skip to content

Assembly private symbols redefinition error #27395

@JustAPerson

Description

@JustAPerson

On playpen nightly

#![crate_type="lib"]
#![feature(asm)]

fn main() {
    unsafe {
        routine()
    }
}

pub unsafe fn routine() {
    asm!("mov ecx, 0xFF
          .loop:
          loop .loop"
          : // no outputs
          : // no inputs
          : "ecx"
          : "intel");
}

pub unsafe fn routine2() {
    routine(); // causes inlining, duplicating the symbol improperly
}
<anon>:11:5: 17:22 error: <inline asm>:3:11: error: invalid symbol redefinition
          .loop:
          ^

<anon>:11     asm!("mov cx, 0xFF
<anon>:12           .loop:
<anon>:13           loop .loop"
<anon>:14           : // no outputs
<anon>:15           : // no inputs
<anon>:16           : "ecx"
          ...
error: aborting due to previous error
playpen: application terminated with error code 101

The following two conditions are necessary to trigger this:

  • Generating a library ( #![crate_type="lib"] )
  • At least -C opt-level=2

Without both of these, the error does not occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions