Skip to content

-Z lto fails to compile in Windows #12471

Closed
@lifthrasiir

Description

@lifthrasiir

This simple code:

fn main() { println!("hi"); }

fails to compile with rustc foo.rs -Z lto in Windows with MinGW:

> rustc foo.rs -Z lto
error: linking with `gcc` failed: exit code: 1
note: gcc arguments: '-m32' '-L<rust>\rustlib\i686-pc-mingw32\lib' '-o' 'foo' 'foo.o' '-shared-libgcc' '-LC:\Users\<username>\.rust' '-LC:\Users\<username>' '-lgcc_s' '-lws2_32' '-lpsapi' '-liphlpapi' '-lmorestack' '-lcompiler-rt'
note: Cannot export __rust_crate_map_toplevel: symbol not found
foo.o:(.text+0x244f3): undefined reference to `rust_try'
foo.o:(.text+0x80653): undefined reference to `rust_valgrind_stack_deregister'
foo.o:(.text+0x82c36): undefined reference to `rust_swap_registers'
(... omitted ...)
<mingw>/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: foo.o: bad reloc address 0x4 in section `.data'
collect2.exe: error: ld returned 1 exit status

error: aborting due to previous error

Undefined references are C symbols from libstd, libgreen and librustuv, which rlibs are not linked against. Tested with the unofficial Windows nightly 0.10-pre (cae5999 2014-02-18 19:26:50 -0800) but I guess this issue is not really related to the nightlies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions