Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust is broken #4133

Closed
crab2313 opened this issue Jul 31, 2018 · 5 comments
Closed

rust is broken #4133

crab2313 opened this issue Jul 31, 2018 · 5 comments

Comments

@crab2313
Copy link

rustc is broken and can't compile an empty program like this:

fn main() {}
$ rustc a.rs
error: linking with `gcc` failed: exit code: 1
  |
  = note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\crt2.o" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-L" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "a.0.o" "-o" "a.exe" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librand-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcollections-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_unicode-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc_system-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-570da8f8.rlib" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-570da8f8.rlib" "-l" "ws2_32" "-l" "userenv" "-l" "shell32" "-l" "advapi32" "-l" "gcc_eh" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-lpthread" "C:\\msys64\\mingw64\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\mingw64\lib\rustlib\x86_64-pc-windows-gnu\lib\crt2.o:crtexe.c:(.rdata$.refptr.__onexitbegin[.refptr.__onexitbegin]+0x0): undefined reference to `__onexitbegin'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\mingw64\lib\rustlib\x86_64-pc-windows-gnu\lib\crt2.o:crtexe.c:(.rdata$.refptr.__onexitend[.refptr.__onexitend]+0x0): undefined reference to `__onexitend'
collect2.exe: error: ld returned 1 exit status


error: aborting due to previous error


thread 'rustc' has overflowed its stack
Segmentation fault

@Zapeth
Copy link
Contributor

Zapeth commented Sep 11, 2018

Having the same issue when trying to build packages for this project -> https://github.com/jwilm/racerd with the additional linker error:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-gccmain.o):gccmain.c:(.data+0x0): undefined reference to __CTOR_END__

Found a relevant issue in the rust repo -> rust-lang/rust#48272

Also, it would be nice to have a newer version of rustc, 1.15 is relatively old now.

@Alexpux
Copy link
Member

Alexpux commented Oct 29, 2018

Rust 1.29.2 in repo now

@Alexpux Alexpux closed this as completed Oct 30, 2018
@gkorland
Copy link

gkorland commented Aug 6, 2019

@Zapeth @Alexpux @crab2313 did you find a solution for this issue?

I'm running the following and still getting this error - rustc 1.35.0 (3c235d560 2019-05-20)

>cargo build --target x86_64-pc-windows-gnu

= note: /usr/bin/x86_64-w64-mingw32-ld: /home/guy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/crt2.o:crtexe.c:(.rdata$.refptr.__onexitbegin[.refptr.__onexitbegin]+0x0): undefined reference to `__onexitbegin'
          /usr/bin/x86_64-w64-mingw32-ld: /home/guy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/crt2.o:crtexe.c:(.rdata$.refptr.__onexitend[.refptr.__onexitend]+0x0): undefined reference to `__onexitend'
          collect2: error: ld returned 1 exit status

@mati865
Copy link
Collaborator

mati865 commented Aug 6, 2019

@gkorland it's rust-lang/rust#47048 and it applies only to Rust installed using official packages so you are asking in wrong repo.

You will have to find crt2.o, dllcrt2.o, libmingwex.a and libmsvcrt.a from your MinGW toolchain and copy those libs to ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib every time you update Rust.

@gkorland
Copy link

gkorland commented Aug 7, 2019

@mati865 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants