StephanTLavavej / mingw-distro

MinGW distro build scripts.
492 stars 55 forks source link

mingw-w64 7.0.0 linker errors caused by _FORTIFY_SOURCE #71

Closed StephanTLavavej closed 7 months ago

StephanTLavavej commented 4 years ago

When building with mingw-w64 7.0.0, several components (coreutils, gdb, and sed) fail to link:

  CCLD     sed/sed.exe
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: sed/sed-compile.o:compile.c:(.text+0x1476): undefined reference to `__chk_fail'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: sed/sed-execute.o:execute.c:(.text+0x3445): undefined reference to `__chk_fail'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: sed/sed-regexp.o:regexp.c:(.text+0x23b): undefined reference to `__chk_fail'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libsed.a(localcharset.o):localcharset.c:(.text+0x151): undefined reference to `__chk_fail'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libsed.a(strerror.o):strerror.c:(.text+0xa9): undefined reference to `__memcpy_chk'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libsed.a(strerror.o):strerror.c:(.text+0xc1): undefined reference to `__chk_fail'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libsed.a(nl_langinfo.o):nl_langinfo.c:(.text+0x2a3): undefined reference to `__memmove_chk'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libsed.a(nl_langinfo.o):nl_langinfo.c:(.text+0x449): undefined reference to `__chk_fail'
c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libsed.a(nl_langinfo.o):nl_langinfo.c:(.text+0x461): undefined reference to `__memcpy_chk'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:2454: sed/sed.exe] Error 1

See https://github.com/msys2/MINGW-packages/issues/5803. The workaround is to compile with -D_FORTIFY_SOURCE=0.

StephanTLavavej commented 2 years ago

Still repros with mingw-w64 9.0.0, so I don't think the upstream project(s) are properly aware of this yet.

StephanTLavavej commented 7 months ago

No longer repros with GCC 13.2.0 and mingw-w64 11.0.1.