尝试编译 QEMU 7.2.14,以便我可以使用 HAXM 虚拟器来加速它(不使用 hyperv),但我收到一条错误,指出在文件
fallocate
第 3600 行中找不到 qemu/softmmu/physmem.c
函数,我已经尝试寻找修复程序,但我找不到一个,并且这个函数似乎是 Linux 特定的,所以我不知道为什么使用它,即使 qemu 被指定为可在 Windows 上构建
使用 mingw64(最新版本)与
./configure --enable-gtk --enable-sdl --target-list=x86_64-softmmu --disable-werror --disable-stack-protector
make -j
错误信息
[1038/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/softmmu_physmem.c.obj
FAILED: libqemu-x86_64-softmmu.fa.p/softmmu_physmem.c.obj
"cc" "-m64" "-mcx16" "-Ilibqemu-x86_64-softmmu.fa.p" "-I." "-I.." "-Itarget/i386" "-I../target/i386" "-Iqapi" "-Itrace" "-Iui" "-Iui/shader" "-IE:/msys64/mingw64/include/pixman-1" "-IE:/msys64/mingw64/include/capstone" "-IE:/msys64/mingw64/include/glib-2.0" "-IE:/msys64/mingw64/lib/glib-2.0/include" "-fdiagnostics-color=auto" "-Wall" "-Winvalid-pch" "-std=gnu11" "-O2" "-g" "-iquote" "." "-iquote" "E:/source/repos/qemu" "-iquote" "E:/source/repos/qemu/include" "-iquote" "E:/source/repos/qemu/tcg/i386" "-U_FORTIFY_SOURCE" "-D_FORTIFY_SOURCE=2" "-fno-pie" "-no-pie" "-D_GNU_SOURCE" "-D_FILE_OFFSET_BITS=64" "-D_LARGEFILE_SOURCE" "-Wstrict-prototypes" "-Wredundant-decls" "-Wundef" "-Wwrite-strings" "-Wmissing-prototypes" "-fno-strict-aliasing" "-fno-common" "-fwrapv" "-Wold-style-declaration" "-Wold-style-definition" "-Wtype-limits" "-Wformat-security" "-Wformat-y2k" "-Winit-self" "-Wignored-qualifiers" "-Wempty-body" "-Wnested-externs" "-Wendif-labels" "-Wexpansion-to-defined" "-Wimplicit-fallthrough=2" "-Wno-missing-include-dirs" "-Wno-shift-negative-value" "-Wno-psabi" "-DNEED_CPU_H" "-DCONFIG_TARGET=\"x86_64-softmmu-config-target.h\"" "-DCONFIG_DEVICES=\"x86_64-softmmu-config-devices.h\"" -MD -MQ libqemu-x86_64-softmmu.fa.p/softmmu_physmem.c.obj -MF "libqemu-x86_64-softmmu.fa.p/softmmu_physmem.c.obj.d" -o libqemu-x86_64-softmmu.fa.p/softmmu_physmem.c.obj "-c" ../softmmu/physmem.c
../softmmu/physmem.c: In function 'ram_block_discard_range':
../softmmu/physmem.c:3600:19: error: implicit declaration of function 'fallocate'; did you mean '_alloca'? [-Wimplicit-function-declaration]
3600 | ret = fallocate(rb->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, start, length);
| ^~~~~~~~~
| _alloca
../softmmu/physmem.c:3600:19: warning: nested extern declaration of 'fallocate' [-Wnested-externs]
[1039/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/softmmu_icount.c.obj
[1040/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/page-vary.c.obj
[1041/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/softmmu_dirtylimit.c.obj
[1042/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/softmmu_qtest.c.obj
[1043/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/dump_dump.c.obj
[1044/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/cpu.c.obj
[1045/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/disas.c.obj
[1046/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/gdbstub_gdbstub.c.obj
[1047/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/migration_target.c.obj
[1048/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/migration_dirtyrate.c.obj
[1049/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/tcg_region.c.obj
[1050/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/softmmu_memory.c.obj
[1051/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/monitor_misc.c.obj
[1052/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/tcg_optimize.c.obj
[1053/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/migration_ram.c.obj
[1054/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/tcg_tcg.c.obj
[1055/1346] Compiling C object libqemu-x86_64-softmmu.fa.p/target_i386_tcg_translate.c.obj
ninja: build stopped: subcommand failed.
make[1]: *** [Makefile:165: run-ninja] Error 1
make[1]: Leaving directory '/e/source/repos/qemu/build'
make: *** [GNUmakefile:11: all] Error 2
我试图找到
fallocate
的替代函数,似乎这个函数是用于文件创建的,但据我所知,没有不需要使用 ntos 在 Windows 上手动实现的库/替代函数,我希望 qemu 能够编译没有任何错误
解决此问题的方法只是禁用使用宏的函数部分,并且由于不强制擦除页面,因此不会导致任何问题,但是将 qemu 与 haxm 一起使用甚至不再与 qemu 一起使用,因此如果您来到这里试图解决这个问题,我只是建议使用 linux 进行 qemu,因为 KVM 无论如何都更快