Skip to content

Private lang items should be exported symbols #11591

Closed
@huonw

Description

@huonw
// lang_lib.rs
#[no_std];
#[crate_type="lib"];

#[lang="fail_"]
fn fail(_: *i8, _: *i8, _: uint) -> ! { loop {} }
// lang_bin.rs
#[no_std];

extern mod lang_lib;

#[no_mangle]
pub extern "C" fn rust_stack_exhausted() {}

#[start]
fn main(_: int, _: **u8) -> int {
    1 % 1
}

Fails to compile with linking errors:

error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'lang_bin' 'lang_bin.o' '-Wl,--as-needed' '-L.' '-L/home/huon/projects/test-rust/.rust' '-L/home/huon/projects/test-rust' '-L/home/huon/.rust' '-L.' '-llang_lib-18b73ee1-0.0' '-lmorestack' '-Wl,-rpath,$ORIGIN/.' '-Wl,-rpath,$ORIGIN/../../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/home/huon/projects/test-rust' '-Wl,-rpath,/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib'
note: lang_bin.o: In function `main::h1f6a57660259bd57ag::v0.0':
lang_bin.rc:(.text+0xe8): undefined reference to `fail::h1cf66c4f37e71757ac::v0.0'
collect2: error: ld returned 1 exit status

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binaries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions