OiO.lk Blog C++ fallocate not defined in QEMU 7.2.14 trying to compile on windows using mingw
C++

fallocate not defined in QEMU 7.2.14 trying to compile on windows using mingw


Trying to compile QEMU 7.2.14 so I can use HAXM virtualizer to accelerate it (not using hyperv) and I’m getting an error saying that the fallocate function is not found in file qemu/softmmu/physmem.c line 3600, I have already tried looking for a fix but I can’t find one & this function seems to be linux specific so I have no idea why it’s used even though qemu is specified to be windows buildable
Using mingw64 (latest version) with

./configure --enable-gtk --enable-sdl --target-list=x86_64-softmmu --disable-werror --disable-stack-protector
make -j

Error info

[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

I tried to find alternative functions to fallocate and it seem like this function is for file creation but there is no libs/alternative’s that would not require manual implementation on windows using ntos as far as I could find, I was expecting qemu to compile without any errors



You need to sign in to view this answers

Exit mobile version