Any exe we build with crossdev-20180508 (mingw) crashes immediately when run. This report https://bugs.gentoo.org/show_bug.cgi?id=644930 is very similar but the resolution does not help (crossdev was ugraded meanwhile). Details: - fresh Gentoo installation (also tried on other Gentoo boxes) - crossdev version: 20180508 - toolchain we tried: crossdev --gcc 7.3.0-r1 --binutils 2.29.1-r1 --ov-output /usr/local/portage-overlays/ --genv 'USE="-fortran -vtv -sanitize -pie -hardened"' i686-w64-mingw32 - other toolchains we tried: i686-pc-mingw32, setting/not setting -pie and -hardened, with/without --gcc and --binutils etc - used C program test.c: int main(int c, char** av){ return 0; } - compilation command: i686-w64-mingw32-gcc test.c - a.exe started under Windows 7 (several boxes): crash immediately - same program compiled for linux, with/without printf(): works ok - compiling with -static or -static-libgcc: no change Reproducible: Always
Can you provide a few more details? 1. 'emerge --info' for a host system 2. 'i686-w64-mingw32-gcc -v' output 3. attach binary resulting from 'i686-w64-mingw32-gcc test.c' compilation 4. crash details from windows box. maybe eventlog contains something like a backtrace with addresses.
Created attachment 538568 [details] the generated/crashing binary
Created attachment 538570 [details] output of emerge --info
Created attachment 538572 [details] output of i686-w64-mingw32-gcc -v
Created attachment 538574 [details] eventviewer entry after crash
Created attachment 538576 [details] output of the crash dialog itself
Thanks for asking. Attachements created.
In your binary I see unusual code in CRT startup code like: 00401000 <___mingw_invalidParameterHandler>: 401000: ff 25 3a 15 40 00 jmp *0x40153a while mine (working) has: 00401000 <___mingw_invalidParameterHandler>: 401000: c3 ret I think it's caused by retpoline flags. Your CFLAGS are: CFLAGS="-march=core2 -g0 -O3 -pipe -fomit-frame-pointer -mindirect-branch=thunk -mfunction-return=thunk -mindirect-branch-register -fno-diagnostics-show-caret" Can you try to rebuild cross-i686-w64-mingw32/mingw64-runtime with safer CFLAGS (ideally drop flags one by one to find the culprit) and check it it workarounds failure for you?
(In reply to Sergei Trofimovich from comment #8) > In your binary I see unusual code in CRT startup code like: > > 00401000 <___mingw_invalidParameterHandler>: > 401000: ff 25 3a 15 40 00 jmp *0x40153a > > while mine (working) has: > > 00401000 <___mingw_invalidParameterHandler>: > 401000: c3 ret > > I think it's caused by retpoline flags. Your CFLAGS are: > > CFLAGS="-march=core2 -g0 -O3 -pipe -fomit-frame-pointer > -mindirect-branch=thunk -mfunction-return=thunk -mindirect-branch-register > -fno-diagnostics-show-caret" > > Can you try to rebuild > cross-i686-w64-mingw32/mingw64-runtime > with safer CFLAGS (ideally drop flags one by one to find the culprit) and > check it it workarounds failure for you? Thanks for the terrific support. Leaving out all three -minderiect-* CFLAGS fixed the issue. I'll now try to recompile mingw64-runtime with some combinations of the above flags to narrow down the causes a bit further.
Can the CFLAGS be specified for crossdev only, so elsewhere than in /etc/portage/make.conf, to keep that separate from the hosts CFLAGS? And here the results of more tests, for completeness: # # works # CFLAGS="-march=core2 -g0 -O3 -pipe -fomit-frame-pointer -fno-diagnostics-show-caret" # # variant1 -- crash # #CFLAGS="-march=core2 -g0 -O3 -pipe -fomit-frame-pointer -mindirect-branch=thunk -mfunction-return=thunk -fno-diagnostics-show-caret" # # variant2 -- crash # #CFLAGS="-march=core2 -g0 -O3 -pipe -fomit-frame-pointer -mindirect-branch=thunk -mindirect-branch-register -fno-diagnostics-show-caret" # # variant3 -- crash # #CFLAGS="-march=core2 -g0 -O3 -pipe -fomit-frame-pointer -mfunction-return=thunk -mindirect-branch-register -fno-diagnostics-show-caret"
(In reply to fkater from comment #10) > Can the CFLAGS be specified for crossdev only, so elsewhere than in > /etc/portage/make.conf, to keep that separate from the hosts CFLAGS? I suggest using https://wiki.gentoo.org/wiki/etc/portage/package.env It should look like /etc/portage/env/safer-cflags.conf: CFLAGS="-march=core2 -g0 -O3 -pipe -fomit-frame-pointer -fno-diagnostics-show-caret" /etc/portage/package.env: cross-i686-w64-mingw32/mingw64-runtime safer-cflags.conf
Invalid generated code it more likely a dev-util/mingw64-runtime bug or sys-devel/gcc bug (if trampolines can be statically resolved). Reassigning to toolchain@.