On Thu, 2020-07-09 at 00:07 +0200, Sandro Mani wrote:
I'm working on updating the mingw toolchain [1], and am hitting the situation [2] where I build with -fstack-protector in the ldflags, can confirm that -lssp and -lssp_nonshared are automatically added to the ldflags (seen via gcc -v [3] and strace), but I still get i.e. with this minimal testcase:
#include <dirent.h> int main () { return closedir (NULL); }
$ i686-w64-mingw32-gcc -o test.exe test.c -fstack-protector /usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/bin/ld: /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/libmingwex.a(lib32_libmingwex_a-dirent.o):(.text+0x22f): undefined reference to `__strcpy_chk' collect2: error: ld returned 1 exit status
Perhaps mingw-crt should be built with -fno-stack-protector?
OTOH, if I write
$ i686-w64-mingw32-gcc -o test.exe test.c -fstack-protector /usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll
it links correctly.
The only other thing which came to mind to verify is that the import library references the correct dll, and this appears to be the case:
$ i686-w64-mingw32-dlltool -I /usr/i686-w64-mingw32/sys-root/mingw/lib/libssp.dll.a libssp-0.dll
I'd appreciate any pointers as I'm pretty much in the dark here.
[1] https://copr.fedorainfracloud.org/coprs/smani/mingw-7.0.0/builds/
[2] Specifically when building mingw-gdb, which adds -D_FORTIFY_SOURCES=2 internally, hence adding -fstack-protector to the ldflags
[3] I.e. I gtt COLLECT_GCC_OPTIONS='-v' '-o' 'test.exe' '-fstack-protector' '-mtune=generic' '-march=pentiumpro' /usr/libexec/gcc/i686-w64-mingw32/10.1.1/collect2 -plugin /usr/libexec/gcc/i686-w64-mingw32/10.1.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/i686-w64-mingw32/10.1.1/lto-wrapper -plugin-opt=-fresolution=/tmp/cckKHr8u.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=/usr/i686-w64-mingw32/sys-root -m i386pe -Bdynamic -o test.exe /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o /usr/lib/gcc/i686-w64-mingw32/10.1.1/crtbegin.o -L/usr/lib/gcc/i686-w64-mingw32/10.1.1 -L/usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/lib/../lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib -L/usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib /tmp/ccpeowDx.o /usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll -lssp_nonshared -lssp -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i686-w64-mingw32/10.1.1/crtend.o
I've worked around this for now by symlinking bin/libssp-0.dll over lib/libssp.dll.a, not having any other ideas. I've also added -fstack-protector to the mingwXX_ldflags, as the mingwXX_cflags contain -D_FORTIFY_SOURCES=2.
So now the toolchain update is pushed, I'll keep an eye on failures during the upcoming mass rebuild.
Sandro
On 09.07.20 14:36, Yaakov Selkowitz wrote:
On Thu, 2020-07-09 at 00:07 +0200, Sandro Mani wrote:
I'm working on updating the mingw toolchain [1], and am hitting the situation [2] where I build with -fstack-protector in the ldflags, can confirm that -lssp and -lssp_nonshared are automatically added to the ldflags (seen via gcc -v [3] and strace), but I still get i.e. with this minimal testcase:
#include <dirent.h> int main () { return closedir (NULL); }
$ i686-w64-mingw32-gcc -o test.exe test.c -fstack-protector /usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/bin/ld: /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/libmingwex.a(lib32_libmingwex_a-dirent.o):(.text+0x22f): undefined reference to `__strcpy_chk' collect2: error: ld returned 1 exit status
Perhaps mingw-crt should be built with -fno-stack-protector?
OTOH, if I write
$ i686-w64-mingw32-gcc -o test.exe test.c -fstack-protector /usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll
it links correctly.
The only other thing which came to mind to verify is that the import library references the correct dll, and this appears to be the case:
$ i686-w64-mingw32-dlltool -I /usr/i686-w64-mingw32/sys-root/mingw/lib/libssp.dll.a libssp-0.dll
I'd appreciate any pointers as I'm pretty much in the dark here.
[1]https://copr.fedorainfracloud.org/coprs/smani/mingw-7.0.0/builds/
[2] Specifically when building mingw-gdb, which adds -D_FORTIFY_SOURCES=2 internally, hence adding -fstack-protector to the ldflags
[3] I.e. I gtt COLLECT_GCC_OPTIONS='-v' '-o' 'test.exe' '-fstack-protector' '-mtune=generic' '-march=pentiumpro' /usr/libexec/gcc/i686-w64-mingw32/10.1.1/collect2 -plugin /usr/libexec/gcc/i686-w64-mingw32/10.1.1/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/i686-w64-mingw32/10.1.1/lto-wrapper -plugin-opt=-fresolution=/tmp/cckKHr8u.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=/usr/i686-w64-mingw32/sys-root -m i386pe -Bdynamic -o test.exe /usr/i686-w64-mingw32/sys-root/mingw/lib/../lib/crt2.o /usr/lib/gcc/i686-w64-mingw32/10.1.1/crtbegin.o -L/usr/lib/gcc/i686-w64-mingw32/10.1.1 -L/usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/lib/../lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib/../lib -L/usr/lib/gcc/i686-w64-mingw32/10.1.1/../../../../i686-w64-mingw32/lib -L/usr/i686-w64-mingw32/sys-root/mingw/lib /tmp/ccpeowDx.o /usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll -lssp_nonshared -lssp -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/i686-w64-mingw32/10.1.1/crtend.o
On 7/19/20 4:35 PM, Sandro Mani wrote:
So now the toolchain update is pushed, I'll keep an eye on failures during the upcoming mass rebuild.
An internal compiler error occurred during the mingw-wine-gecko rebuild.
https://koji.fedoraproject.org/koji/taskinfo?taskID=48000438
I rebuilt using gcc 10.1 and the error still occurred so it's not a 10.2 issue.
On 7/19/20 4:35 PM, Sandro Mani wrote:
So now the toolchain update is pushed, I'll keep an eye on failures during the upcoming mass rebuild.
I see the following build failures:
Related to -fstack-protector/-lssp: * mingw-openssl: undefined reference to ***_chk * mingw-boost: undefined reference to ***_chk * mingw-c-ares: configure: LDFLAGS error: LDFLAGS may only be used to specify linker flags, not libraries. Use LIBS for: -lssp => I'll look into those
error: invalid use of '__builtin_va_arg_pack ()': * mingw-speex * mingw-celt051 => Needs investigation
Invalid configuration `aarch64-redhat-linux-gnu': machine `aarch64-redhat' not recognized: * mingw-cppunit * mingw-liboil => Needs investigation
multiple definition of `xxx': * mingw-gdbm * mingw-gtkglext => Most likely due to missing extern declarations
Other: * mingw-gstreamer-plugins-base: error: 'GST_TUNER_CHANNEL_OUTPUT' undeclared => Suppose this will need to be retired anyway as the other gst-0.x packages have been retired * mingw-mediawriter: cannot find -llzma.dll.a => should be trivial, just a wrong import lib name being use * mingw-wine-gecko: internal compiler error: in linemap_compare_locations, at libcpp/line-map.c:1359 => needs an upstream bug report with preprocessed source
On 8/4/20 3:17 AM, Sandro Mani wrote:
- mingw-wine-gecko: internal compiler error: in linemap_compare_locations, at
libcpp/line-map.c:1359 => needs an upstream bug report with preprocessed source
It's been filed.