id = 1904 title = "Windows LTO build fails" state = "closed" created_at = "2023-09-23T07:33:54.701Z" closed_at = "2023-10-06T13:29:58.398Z" labels = ["hostos: Windows"] url = "https://gitlab.com/qemu-project/qemu/-/issues/1904" host-os = "Windows 11 Version 10.0.22621" host-arch = "amd64 ucrt64" qemu-version = "current master as of writing b55e4b9c0525560577384adfc6d30eb0daa8d7be" guest-os = "n/a" guest-arch = "n/a" description = """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 ```""" reproduce = """1. `./configure --enable-lto` 2. `make`""" additional = """Looks like the offending commit is d89f30b4df13dfe389a4d6cf8a30b2f87c4c166e "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."""