mingw-distro icon indicating copy to clipboard operation
mingw-distro copied to clipboard

mingw-w64 7.0.0 linker errors caused by _FORTIFY_SOURCE

Open StephanTLavavej opened this issue 5 years ago • 1 comments

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 avatar Nov 26 '19 05:11 StephanTLavavej

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

StephanTLavavej avatar Oct 17 '21 21:10 StephanTLavavej

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

StephanTLavavej avatar Jan 14 '24 06:01 StephanTLavavej