performance: 0.883 virtual: 0.876 graphic: 0.873 permissions: 0.858 register: 0.847 debug: 0.846 user-level: 0.840 peripherals: 0.837 architecture: 0.827 risc-v: 0.825 TCG: 0.820 arm: 0.818 KVM: 0.814 device: 0.812 VMM: 0.810 vnc: 0.810 semantic: 0.803 assembly: 0.802 files: 0.799 boot: 0.798 network: 0.795 ppc: 0.793 hypervisor: 0.777 PID: 0.775 mistranslation: 0.769 i386: 0.758 kernel: 0.756 socket: 0.743 x86: 0.736 Windows TCG plugin build fails with mingw cross-compile images Description of problem: It looks like the mingw variants of the compiler are sensitive to the order of linking: ``` bash-5.2$ x86_64-w64-mingw32-gcc -m64 -mcx16 plugins/qemu_plugin_api.lib -o tests/plugin/libinsn.dll tests/plugin/libinsn.dll.p/insn.c.obj tests/plugin/libinsn.dll.p/.._.._contrib_plugins_win32_linker.c.obj plugins/qemu_plugin_api.lib -Wl,--allow-shlib-undefined -shared -Wl,--start-group -Wl,--out-implib=tests/plugin/libinsn.dll.a -fstack-protector-strong -Wl,--no-seh -Wl,--nxcompat -Wl,--dynamicbase -Wl,--high-entropy-va -Wl,--warn-common /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libglib-2.0.dll.a /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libintl.dll.a /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libgmodule-2.0.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -Wl,--end-group bash-5.2$ x86_64-w64-mingw32-gcc -m64 -mcx16 plugins/qemu_plugin_api.lib -o tests/plugin/libinsn.dll tests/plugin/libinsn.dll.p/insn.c.obj tests/plugin/libinsn.dll.p/.._.._contrib_plugins_win32_linker.c.obj -Wl,--allow-shlib-undefined -shared -Wl,--start-group -Wl,--out-implib=tests/plugin/libinsn.dll.a -fstack-protector-strong -Wl,--no-seh -Wl,--nxcompat -Wl,--dynamicbase -Wl,--high-entropy-va -Wl,--warn-common /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libglib-2.0.dll.a /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libintl.dll.a /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libgmodule-2.0.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -Wl,--end-group /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: tests/plugin/libinsn.dll.p/insn.c.obj: in function `vcpu_tb_trans': /tmp/qemu-test/build/../src/tests/plugin/insn.c:90: undefined reference to `__imp_qemu_plugin_tb_n_insns' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:100: undefined reference to `__imp_qemu_plugin_insn_vaddr' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:97: undefined reference to `__imp_qemu_plugin_register_vcpu_insn_exec_inline' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:94: undefined reference to `__imp_qemu_plugin_tb_get_insn' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:101: undefined reference to `__imp_qemu_plugin_register_vcpu_insn_exec_cb' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:107: undefined reference to `__imp_qemu_plugin_insn_size' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:121: undefined reference to `__imp_qemu_plugin_insn_disas' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:130: undefined reference to `__imp_qemu_plugin_register_vcpu_insn_exec_cb' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: tests/plugin/libinsn.dll.p/insn.c.obj: in function `plugin_exit': /tmp/qemu-test/build/../src/tests/plugin/insn.c:168: undefined reference to `__imp_qemu_plugin_outs' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:168: undefined reference to `__imp_qemu_plugin_outs' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:168: undefined reference to `__imp_qemu_plugin_outs' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: tests/plugin/libinsn.dll.p/insn.c.obj: in function `vcpu_insn_matched_exec_before': /tmp/qemu-test/build/../src/tests/plugin/insn.c:83: undefined reference to `__imp_qemu_plugin_outs' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: tests/plugin/libinsn.dll.p/insn.c.obj: in function `qemu_plugin_install': /tmp/qemu-test/build/../src/tests/plugin/insn.c:199: undefined reference to `__imp_qemu_plugin_bool_parse' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:215: undefined reference to `__imp_qemu_plugin_register_vcpu_tb_trans_cb' /usr/lib/gcc/x86_64-w64-mingw32/12.2.1/../../../../x86_64-w64-mingw32/bin/ld: /tmp/qemu-test/build/../src/tests/plugin/insn.c:216: undefined reference to `__imp_qemu_plugin_register_atexit_cb' collect2: error: ld returned 1 exit status If you move the qemu_plugin_api.lib to after the other .obj files, it works: bash-5.2$ x86_64-w64-mingw32-gcc -m64 -mcx16 plugins/qemu_plugin_api.lib -o tests/plugin/libinsn.dll tests/plugin/libinsn.dll.p/insn.c.obj tests/plugin/libinsn.dll.p/.._.._contrib_plugins_win32_linker.c.obj plugins/qemu_plugin_api.lib -Wl,--allow-shlib-undefined -shared -Wl,--start-group -Wl,--out-implib=tests/plugin/libinsn.dll.a -fstack-protector-strong -Wl,--no-seh -Wl,--nxcompat -Wl,--dynamicbase -Wl,--high-entropy-va -Wl,--warn-common /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libglib-2.0.dll.a /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libintl.dll.a /usr/x86_64-w64-mingw32/sys-root/mingw/lib/libgmodule-2.0.dll.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -Wl,--end-group bash-5.2$ echo $? 0 ``` Steps to reproduce: ``` make docker-test-build@fedora-win64-cross J=30 V=1 EXTRA_CONFIGURE_OPTS="--enable-fdt=internal --enable-plugins" NETWORK=1 ```