Skip to content

Linking hello world program fails under Windows when other MingW is in PATH #17726

Closed
@catch22

Description

@catch22

Building the hello world program fails with the following message:

error: linking with `gcc` failed: exit code: 1
note: gcc '-m64' [snip]
note: C:\Tools\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib(native-4e7c5e5c.o):(.text+0x89): undefined reference to `_Unwind_Resume'
C:\Tools\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib(native-4e7c5e5c.o):(.text+0x5bb): undefined reference to `_Unwind_Resume'
C:\Tools\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib(native-4e7c5e5c.o):(.text+0x12c8): undefined reference to `_Unwind_Resume'
C:\Tools\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib(native-4e7c5e5c.o):(.text+0x1396): undefined reference to `_Unwind_Resume'
C:\Tools\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib(native-4e7c5e5c.o):(.text+0x1463): undefined reference to `_Unwind_Resume'
C:\Tools\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib(native-4e7c5e5c.o):(.text+0x1781): more undefined references to `_Unwind_Resume' follow
c:/tools/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Tools\Rust\bin\rustlib\x86_64-w64-mingw32\lib\libnative-4e7c5e5c.rlib(native-4e7c5e5c.o): bad reloc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit status

It appears that rustc picks up another MingW's version of ld rather than the one it ships with. The same error also appears if the rust binary directory is the first item in my PATH. The only way around it is to either remove my MingW's bin directory from the PATH or by prefixing rustlib/...mingw/gcc/bin to the PATH. Both solutions seem to be quite hackish -- I just wanted to check if this is the desired behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-driverArea: rustc_driver that ties everything together into the `rustc` compilerA-linkageArea: linking into static, shared libraries and binariesO-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions