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

Build failure with MinGW-w64 gcc 5.2.0 #29649

Closed
alexcrichton opened this issue Nov 5, 2015 · 8 comments
Closed

Build failure with MinGW-w64 gcc 5.2.0 #29649

alexcrichton opened this issue Nov 5, 2015 · 8 comments
Labels

Comments

@alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Nov 5, 2015

Updated description

We need to document that the standard MSYS2 package for gcc will not work when building Rust, you have to install a custom toolchain with a known good version and the win32 threading model, not the pthread threading model.

Original report

Looks related to #29177, perhaps the gcc_eh library picked up new dependencies in 5.2.0?

cc @vadimcn

error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-Wl,--large-address-aware" "C:\\msys64\\home\\ale\\rust2\\i686-pc-windows-gnu\\stage1\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\dllcrt2.o" "C:\\msys64\\home\\ale\\rust2\\i686-pc-windows-gnu\\stage1\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\rsbegin.o" "-L" "C:\\msys64\\home\\ale\\rust2\\i686-pc-windows-gnu\\stage1\\lib\\rustlib\\i686-pc-windows-gnu\\lib" "i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib\\std-71b07a99.0.o" "-o" "i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib\\std-71b07a99.dll" "i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib\\std-71b07a99.metadata.o" "-nodefaultlibs" "-L" "i686-pc-windows-gnu/rt" "-L" "C:\\msys64\\home\\ale\\rust2\\i686-pc-windows-gnu\\llvm\\Release/lib" "-L" "C:\\msys64\\home\\ale\\rust2\\i686-pc-windows-gnu\\stage1\\lib\\rustlib\\i686-pc-windows-gnu\\lib" "-L" "C:\\msys64\\home\\ale\\rust2\\.rust\\lib\\i686-pc-windows-gnu" "-L" "C:\\msys64\\home\\ale\\rust2\\lib\\i686-pc-windows-gnu" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "backtrace" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-l" "gcc_eh" "-l" "gcc_eh" "-l" "ws2_32" "-l" "userenv" "-l" "shell32" "-l" "advapi32" "-Wl,--whole-archive" "C:\\msys64\\tmp\\rustc.hZLinbW19bbD\\libcollections-71b07a99.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "C:\\msys64\\tmp\\rustc.hZLinbW19bbD\\liballoc-71b07a99.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "C:\\msys64\\tmp\\rustc.hZLinbW19bbD\\librustc_unicode-71b07a99.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "C:\\msys64\\tmp\\rustc.hZLinbW19bbD\\liballoc_jemalloc-71b07a99.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "C:\\msys64\\tmp\\rustc.hZLinbW19bbD\\liblibc-71b07a99.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "C:\\msys64\\tmp\\rustc.hZLinbW19bbD\\librand-71b07a99.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "C:\\msys64\\tmp\\rustc.hZLinbW19bbD\\libcore-71b07a99.rlib" "-Wl,--no-whole-archive" "-shared" "-l" "compiler-rt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "C:\\msys64\\home\\ale\\rust2\\i686-pc-windows-gnu\\stage1\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\rsend.o"
note: C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2.o):(.text+0x1a4b): undefined reference to `pthread_once'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1a3): undefined reference to `pthread_mutex_init'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0xf99): undefined reference to `pthread_once'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0xfa5): undefined reference to `pthread_mutex_lock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x10b4): undefined reference to `pthread_once'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x10c0): undefined reference to `pthread_mutex_lock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x118b): undefined reference to `pthread_once'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1197): undefined reference to `pthread_mutex_lock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x11f9): undefined reference to `pthread_mutex_unlock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1228): undefined reference to `pthread_mutex_unlock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x12af): undefined reference to `pthread_once'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x12bb): undefined reference to `pthread_mutex_lock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x12f7): undefined reference to `pthread_mutex_unlock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x13b6): undefined reference to `pthread_mutex_unlock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0xfc4): undefined reference to `pthread_mutex_unlock'
C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.2.0/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x10df): undefined reference to `pthread_mutex_unlock'
collect2.exe: error: ld returned 1 exit status

error: aborting due to previous error

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
/home/ale/rust2/mk/target.mk:231: recipe for target 'i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/stamp.std' failed
make: *** [i686-pc-windows-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/stamp.std] Error 3
@vadimcn

This comment has been minimized.

Copy link
Contributor

@vadimcn vadimcn commented Nov 5, 2015

Huh. Could this be due to the difference between the 'win32' and 'posix' flavors of mingw-w64? If it's the latter,we are probably missing libpthread link dependency.

@alexcrichton

This comment has been minimized.

Copy link
Member Author

@alexcrichton alexcrichton commented Nov 5, 2015

Oh, right, of course!

Hm that kinda sucks though because it means that the default gcc packages in MinGW are no longer usable to build Rust. Does MSYS2 provide win32 threaded gcc implementations?

@vadimcn

This comment has been minimized.

Copy link
Contributor

@vadimcn vadimcn commented Nov 5, 2015

Nope, the only way (that I've found) to install win32-threaded gcc is through mingw-builds installer.
I suppose we could detect gcc flavor in configure and pass --cfg use_libpthread to rustc. This would be prone to bit-rot though.

@alexcrichton

This comment has been minimized.

Copy link
Member Author

@alexcrichton alexcrichton commented Nov 5, 2015

Hm ok, in that case I'm gonna switch this to a docs bug, we basically need to document that using an external package is not only recommended but it's the only option in a case like this as it's not something upstream's gonna fix (unlike the LLVM-wont-build-and-may-segfault bug)

@alexcrichton alexcrichton added A-docs and removed A-build labels Nov 5, 2015
@DanielKeep

This comment has been minimized.

Copy link
Contributor

@DanielKeep DanielKeep commented Nov 6, 2015

Same problem here with 4.9.0. I haven't touched my install in ages.

@steveklabnik

This comment has been minimized.

Copy link
Member

@steveklabnik steveklabnik commented Nov 17, 2015

Can someone help me out here? I'm assuming this needs to be in the README, yeah? What exactly do we need to say?

@vadimcn

This comment has been minimized.

Copy link
Contributor

@vadimcn vadimcn commented Nov 18, 2015

Basically, we need to remove this line (and the next) and instead instruct devs to download mingw-builds installer, and choose the threads=win32,exceptions=dwarf/seh flavor (and probably version < 5.0 for now - because of #28260). Finally, they'll need to add its \mingw32\bin (or ...\mingw64\bin - depending on bit-ness) to search path.

@davidkazlauskas

This comment has been minimized.

Copy link

@davidkazlauskas davidkazlauskas commented Dec 12, 2015

I'm building MXE ( http://mxe.cc/ ) and I'd like to link with some code cross compiled with rust. My MXE is mingw-gcc build is posix threads and dwarf exceptions. Is it a good idea to if I call some code from a dll that has win32 threading model ( rust ) from a code with posix model or it doesn't matter?

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 4, 2016
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 4, 2016
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 5, 2016
@bors bors closed this in #30698 Jan 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.