https://sourceware.org/bugzilla/show_bug.cgi?id=24074
Bug ID: 24074 Summary: ld fails silently when linking MinGW 64-bit app with BOINC libs Product: binutils Version: 2.25 Status: UNCONFIRMED Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: bugzi...@poradnik-webmastera.com Target Milestone: --- Created attachment 11520 --> https://sourceware.org/bugzilla/attachment.cgi?id=11520&action=edit Captured logs I was trying to link 64-bit MinGW app using crosscompiler on CentOS Linux. Unfortunately it failed, and ld did not produce any error message - I only got "collect2: error: ld returned 1 exit status". This does not happen when linking 32-bit MinGW toolchain. Here are details how to reproduce this, and results of my attempts to investigate this: - System: CentOS Linux release 7.6.1810 (Core) - MinGW Binutils version: /usr/bin/x86_64-w64-mingw32-ld --version GNU ld (GNU Binutils) 2.25 Copyright (C) 2014 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. - Installed MinGW 64bit toolchain from EPEL repo (mingw64-gcc-c++.x86_64, version 4.9.3-1.el7) - Compiled gcc 8.2.0 for MinGW, configured in following way: /root/gcc-8.2.0-mingw64/bin/x86_64-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=/root/gcc-8.2.0-mingw64/bin/x86_64-w64-mingw32-gcc COLLECT_LTO_WRAPPER=/root/gcc-8.2.0-mingw64/libexec/gcc/x86_64-w64-mingw32/8.2.0/lto-wrapper Target: x86_64-w64-mingw32 Configured with: ../gcc-8.2.0-src/configure --prefix=/root/gcc-8.2.0-mingw64 --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --with-gnu-as --with-gnu-ld --verbose --without-newlib --disable-multilib --disable-plugin --with-system-zlib --disable-nls --without-included-gettext --disable-win32-registry --enable-languages=c,c++ --enable-threads=posix --enable-libgomp --target=x86_64-w64-mingw32 --with-sysroot=/usr/x86_64-w64-mingw32/sys-root --with-gxx-include-dir=/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++ --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld Thread model: posix gcc version 8.2.0 (GCC) - Cloned latest BOINC vesion from https://github.com/BOINC/boinc - Compiled BOINC libs for MinGW 64-bit target: cd <repo>/lib mkdir -p /root/boinc82/mingw64/ make -f Makefile.mingw CC=/root/gcc-8.2.0-mingw64/bin/x86_64-w64-mingw32-gcc CXX=/root/gcc-8.2.0-mingw64/bin/x86_64-w64-mingw32-g++ AR=x86_64-w64-mingw32-ar RANLIB=x86_64-w64-mingw32-ranlib BOINC_PREFIX=/root/boinc82/mingw64/ make -f Makefile.mingw CC=/root/gcc-8.2.0-mingw64/bin/x86_64-w64-mingw32-gcc CXX=/root/gcc-8.2.0-mingw64/bin/x86_64-w64-mingw32-g++ AR=x86_64-w64-mingw32-ar RANLIB=x86_64-w64-mingw32-ranlib BOINC_PREFIX=/root/boinc82/mingw64/ install - created file a.cpp with: [code] extern "C" { int boinc_init(); } int main() { boinc_init(); return 0; } [/code] - comiled it: x86_64-w64-mingw32-g++ -c -o a.o a.cpp -pthread - linked: x86_64-w64-mingw32-g++ -static a.o -o test -pthread /root/boinc82/mingw64//lib/libboinc_api.a /root/boinc82/mingw64//lib/libboinc.a; echo $? collect2: error: ld returned 1 exit status 1 - I tried to add -Wl,--verbose to see more details. Output seems valid for me, it ends as follow. Full output is attached. attempt to open /root/gcc-8.2.0-mingw64/lib/gcc/x86_64-w64-mingw32/8.2.0/crtend.o succeeded /root/gcc-8.2.0-mingw64/lib/gcc/x86_64-w64-mingw32/8.2.0/crtend.ocollect2: error: ld returned 1 exit status - I also tried to use strace -f <cmd>, output attached. It seems that read operation at line 22467 returned some unexpected data, and ld started cleanup sequence (series of munmap, close calls follows): [pid 18361] lseek(8, 167936, SEEK_SET) = 167936 [pid 18361] read(8, "NSs6assignEPKc\0_ZNKSt6vectorISsS"..., 4096) = 4096 [pid 18361] read(8, "\0\0\0\0\0\0\0\0\0\0\275\0\0\0\0\0\t\0Z\1\0\0\0\0\0\0\0\0\0\0\0\0"..., 122880) = 122880 [pid 18361] read(8, "\0\0\2\0\0\0\2\0\0\0 \24\0\0\0\0\0\0\304\1\0\0\0\0\0\0\2\0\0\0\2\0"..., 4096) = 4096 [pid 18361] munmap(0x7ff9ccca6000, 23789568) = 0 [pid 18361] munmap(0x7ff9d5d69000, 270336) = 0 [pid 18361] munmap(0x7ff9ceae6000, 622592) = 0 [pid 18361] close(8) = 0 - I also tried to run this under gdb: gdb --args x86_64-w64-mingw32-g++ -static a.o -o test -pthread /root/boinc82/mingw64//lib/libboinc_api.a /root/boinc82/mingw64//lib/libboinc.a b exit b _exit set follow-fork-mode child set detach-on-fork on set follow-exec-mode same r Starting program: /root/gcc-8.2.0-mingw64/bin/x86_64-w64-mingw32-g++ -static a.o -o test -pthread /root/boinc82/mingw64//lib/libboinc_api.a /root/boinc82/mingw64//lib/libboinc.a [New process 18471] process 18471 is executing new program: /root/gcc-8.2.0-mingw64/libexec/gcc/x86_64-w64-mingw32/8.2.0/collect2 [New process 18472] process 18472 is executing new program: /usr/bin/x86_64-w64-mingw32-ld [Switching to process 18472] Breakpoint 1, __GI_exit (status=1) at exit.c:98 98 { Missing separate debuginfos, use: debuginfo-install libgcc-4.8.5-36.el7.x86_64 zlib-1.2.7-18.el7.x86_64 (gdb) bt #0 __GI_exit (status=1) at exit.c:98 #1 0x00000000004cb12f in xexit (code=code@entry=1) at ../../libiberty/xexit.c:51 #2 0x0000000000418160 in ldwrite () at ../../ld/ldwrite.c:590 #3 0x0000000000403bed in main (argc=57, argv=0x7fffffffd938) at ../../ld/ldmain.c:427 (gdb) -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils