Skip to content

Windows LTO build fails

Host environment

  • Operating system: Windows 11 Version 10.0.22621
  • OS/kernel version: MSYS_NT-10.0-22621 hostname 3.4.9.x86_64 2023-09-15 12:15 UTC x86_64 Msys
  • Architecture: amd64 ucrt64
  • QEMU version: current master as of writing b55e4b9c
  • configure command line:
    ./configure --enable-lto

Description of problem

LTO likes to delete win32_close_exception_handler which causes an error when linking

[2736/5786] Linking target qemu-system-avr.exe
FAILED: qemu-system-avr.exe
"cc" "-m64" "-mcx16" @qemu-system-avr.exe.rsp
`win32_close_exception_handler' referenced in section `.xdata' of C:\msys64\tmp\cceRwR4N.ltrans59.ltrans.o: defined in discarded section `.text' of libqemuutil.a.p/util_oslib-win32.c.obj (symbol from plugin)
collect2.exe: error: ld returned 1 exit status

Steps to reproduce

  1. ./configure --enable-lto
  2. make

Additional information

Looks like the offending commit is d89f30b4 "win32: wrap socket close() with an exception handler". Undoing the commit or marking the exception handler as __attribute__ ((noinline, used)) both appear to fix the issue.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information