_FORTIFY_SOURCE and libtool

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

_FORTIFY_SOURCE and libtool

Liu Hao-2
As GCC sets `-D_FORTIFY_SOURCE=2` (maybe it's MSYS2 or `makepkg` well I
don't really care about which one it is), those `__*_chk()` functions
are now required when building GCC and its libraries. Unfortunately,
mingw-w64 does not provide these (it relies libssp to provide them), so
the build now fails with undefined references.

I tried adding `-fstack-protector` into `LDFLAGS` and adding `-lssp`
into `LIBS` when configuring GCC, but neither worked for me. The build
process errorred out when building either libiberty or libcpp.

Tampering with GCC builtin specs may be a solution, but I am not sure
whether libtool likes that. It ignores default libraries and always
attempts to link against everything at its own disposal.

I am not sure whether libssp is (rather, can be made) available when
building libiberty. Or this _FORTIFY_SOURCE thing should be disabled
when building GCC for mingw-w64.

Any suggestions will be appreciated.


Build logs:

```
libtool: link:
/e/GitHub/MINGW-packages/mingw-w64-gcc-git/src/build-x86_64-w64-mingw32/./prev-gcc/xgcc
-B/e/GitHub/MINGW-packages/mingw-w64-gcc-git/src/build-x86_64-w64-mingw32/./prev-gcc/
-B/mingw64/x86_64-w64-mingw32/bin/ -L/mingw64/x86_64-w64-mingw32/lib
-L/mingw64/lib -isystem /mingw64/x86_64-w64-mingw32/include -isystem
/mingw64/include -B/mingw64/x86_64-w64-mingw32/bin/
-B/mingw64/x86_64-w64-mingw32/lib/ -isystem
/mingw64/x86_64-w64-mingw32/include -isystem
/mingw64/x86_64-w64-mingw32/sys-include   -fno-checking -shared
.libs/lto-plugin.o   -L/mingw64/x86_64-w64-mingw32/lib -L/mingw64/lib
-static-libgcc ../libiberty/libiberty.a -static-libstdc++ -static-libgcc
-Wl,--stack -Wl,12582912   -o .libs/liblto_plugin-0.dll
-Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker
.libs/liblto_plugin.dll.a
C:\MinGW\MSYS2\mingw64\x86_64-w64-mingw32\bin\ld.exe:
../libiberty/libiberty.a(simple-object-coff.o):simple-object-coff.c:(.text+0xb3a):
undefined reference to `__memcpy_chk'
C:\MinGW\MSYS2\mingw64\x86_64-w64-mingw32\bin\ld.exe:
../libiberty/libiberty.a(simple-object-mach-o.o):simple-object-mach-o.c:(.text+0xc91):
undefined reference to `__strncpy_chk'
C:\MinGW\MSYS2\mingw64\x86_64-w64-mingw32\bin\ld.exe:
../libiberty/libiberty.a(simple-object-xcoff.o):simple-object-xcoff.c:(.text+0x7b5):
undefined reference to `__memcpy_chk'
C:\MinGW\MSYS2\mingw64\x86_64-w64-mingw32\bin\ld.exe:
../libiberty/libiberty.a(xstrerror.o):xstrerror.c:(.text+0x4a):
undefined reference to `__chk_fail'

```


--
Best regards,
LH_Mouse


signature.asc (849 bytes) Download Attachment