Skip to content

program without libc (without std lib) leads to cryptic error #17346

Open
@phil-opp

Description

@phil-opp

The code at http://doc.rust-lang.org/guide-unsafe.html#avoiding-the-standard-library requires libc. It isn't possible to remove this line or to replace it with the platform independent rlibc. The following error occurs (playpen: http://is.gd/GWl8YT):

error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'out' 'out.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-nodefaultlibs' '-Wl,--gc-sections' '-pie' '-Wl,--as-needed' '-Wl,-O1' '-L' '/home/rust/.rust' '-L' '/home/rust' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lcompiler-rt'
note: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../lib/Scrt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../lib/Scrt1.o: In function `_start':
(.text+0x19): undefined reference to `__libc_csu_init'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../lib/Scrt1.o: In function `_start':
(.text+0x25): undefined reference to `__libc_start_main'
collect2: error: ld returned 1 exit status

error: aborting due to previous error

I want to use libcore, that doesn't require libc (http://doc.rust-lang.org/core/). The libcore code example in the guide (http://doc.rust-lang.org/guide-unsafe.html#using-libcore) has no libc dependency, but the playpen link in the top right of the code example reinserts it and removing it leads to the same error as above (http://is.gd/sxVAr0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-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