crt: Fix LTO -Ofast compilation
When mingw-w64 is compiled with LTO support (-flto and -ffat-lto-objects in
CFLAGS and LDFLAGS) then compiling any application with -Ofast fails.
Calling "gcc -flto -Ofast" throws fatal error:
`___main' referenced in section `.text.startup' of /tmp/ccXtREge.ltrans0.ltrans.o: defined in discarded section `.text' of lib32_libmingw32_a-gccmain.o (symbol from plugin)
collect2: error: ld returned 1 exit status
With -O2 or other level there is no error at all.
It looks like that function __main from file mingw-w64-crt/crt/gccmain.c is
somehow automatically discarded by gcc / ld LTO compiler when using -Ofast.
Fix this problem by manually adding __attribute__((used)).
Signed-off-by: Martin Storsjö <martin@martin.st>
1 file changed