Skip to content

pub static disappears if only used from asm #13365

Closed
@kmcallister

Description

@kmcallister
#[feature(asm)];

#[no_mangle]
pub static arr: [u8, ..16] = [0, ..16];

fn main() {
    unsafe {
        asm!("movups arr, %xmm0" ::: "xmm0");
    }
}
$ rustc -v
rustc 0.10-pre (68a4f7d 2014-02-24 12:42:02 -0800)
host: x86_64-unknown-linux-gnu

$ rustc -O foo.rs
error: linking with `cc` failed: exit code: 1
note: cc arguments: [...]
note: foo.o: In function `main::hcaa4d83fe49d03ddnaa::v0.0':
foo.rs:(.text+0x29): undefined reference to `arr'
collect2: error: ld returned 1 exit status

error: aborting due to previous error

Adding an unused constraint "r"(&arr) fixes it, as does passing &arr to test::black_box (which does basically that).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions