Skip to content

Symbol mangling happens despite #[no_mangle] or #[link_name] #35052

@jjpe

Description

@jjpe

I see symbols being mangled despite using #[no_mangle] or #[link_name = "foo"]. Specifically, the symbols are being prepended by _, i.e. foo gets mangled to _foo rather than being accessible as foo.

I tried this code:

#[no_mangle]
pub static mut foo: std::os::raw::c_int = 0;

and

#[link_name = "foo"]
pub static mut foo: std::os::raw::c_int = 0;

Meta

OS: OS X 10.10

rustc --version --verbose: I tried both

rustc 1.10.0 (cfcb716cf 2016-07-03) binary: rustc commit-hash: cfcb716cf0961a7e3a4eceac828d94805cf8140b commit-date: 2016-07-03 host: x86_64-apple-darwin release: 1.10.0

and

rustc 1.12.0-nightly (9316ae515 2016-07-24) binary: rustc commit-hash: 9316ae515e2f8f3f497fb4f1559910c1eef2433d commit-date: 2016-07-24 host: x86_64-apple-darwin release: 1.12.0-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-enhancementCategory: An issue proposing an enhancement or a PR with one.O-macosOperating system: macOST-langRelevant to the language team

    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