Hi, dear friends,

When compiling GNU cross toolchain on MSYS2/MinGW-w64. I encounter the
following problem:

E:\Note\Tool\gcc-x86_64-elf-release-install\x86_64-elf\bin\ar.exe:
libgcov.a: error reading _gcov_merge_add.o: file truncated
make[1]: *** [Makefile:939: libgcov.a] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory
'/c/Users/Administrator/Tool/gcc-x86_64-elf-release-build/x86_64-elf/libgcc'
make: *** [Makefile:13696: all-target-libgcc] Error 2

At last I figured out that this is because MinGW-w64 's global commit
flag is not set to "commit".
The solution is to write new binmode.c and commode.c, and use
following commands to generate binmode.o and commode.o, and copy these
2 object files to /mingw64/lib directory, and maybe override the
original binmode.o
gcc -c -O2 binmode.c -o binmode.o
gcc -c -O2 commode.c -o commode.o

And when linking, add the following LDFLAGS:
LDFLAGS+=" -Wl,$(gcc -print-file-name=binmode.o) -Wl,$(gcc
-print-file-name=commode.o)"

I believe this is a regression, because some years ago, there was no
such problem.

Reference:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/link-options?view=msvc-170
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-170
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fflush?view=msvc-170
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/flushall?view=msvc-170
// #include <corecrt_internal_stdio.h>

int _commode = 0x0800; // _IOCOMMIT
#include <fcntl.h>

int _fmode = _O_BINARY; 
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to