Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Ubuntu and Windows VMs with QEMU on Apple Silicon

Running Linux and Windows on M1 with QEMU

30.11.2020: Updated with the new patchseries and instructions for Windows

02.12.2020: Added tweaks

08.12.2020: Updated with patchseries v4

31.01.2020: Updated with patchseries v6

07.03.2021: Updated instructions to apply patch cleanly

01.06.2021: Updated instructions for Xcode 12.4 and above

Building QEMU

  • Clone QEMU and checkout version 5.2.0
git clone https://github.com/qemu/qemu
cd qemu
git checkout v5.2.0
curl https://patchwork.kernel.org/series/418581/mbox/ | git am --exclude=MAINTAINERS
  • If you use Xcode 12.4 or above, you will need another patch to fix the QEMU build. Download xcode-12-4.patch from below and apply it using
git apply xcode-12-4.patch
  • Install the ARM version of the brew package manager. The (recommended) installation via Rosetta will cause problems when building QEMU. Even if brew screams at you at every launch that this is not a supported configuration I had no major problems so far. You can follow this guide (see the "Multiple Homebrews" section).
  • Install required packages for building:
brew install libffi gettext pkg-config autoconf automake pixman
  • Run the following commands to build qemu:
mkdir build
cd build
../configure --target-list=aarch64-softmmu --disable-gnutls
make -j8
sudo make install
  • For some reason, the qemu binary is modified during make install. You need to resign it with the correct entitlements, otherwise you will get an Unknown Error:
sudo codesign --entitlements /path/to/qemu/accel/hvf/entitlements.plist --force -s - `which qemu-system-aarch64`

Create Ubuntu VM

qemu-img create -f qcow2 disk.qcow2 10G
  • Create an empty file for persisting UEFI variables:
dd if=/dev/zero conv=sync bs=1m count=64 of=ovmf_vars.fd
  • Run qemu with the following command-line arguments:
qemu-system-aarch64 \
    -accel hvf \
    -m 2048 \
    -cpu cortex-a57 -M virt,highmem=off  \
    -drive file=/usr/local/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
    -drive file=ovmf_vars.fd,if=pflash,format=raw \
    -serial telnet::4444,server,nowait \
    -drive if=none,file=disk.qcow2,format=qcow2,id=hd0 \
    -device virtio-blk-device,drive=hd0,serial="dummyserial" \
    -device virtio-net-device,netdev=net0 \
    -netdev user,id=net0 \
    -vga none -device ramfb \
    -cdrom /path/to/ubuntu.iso \
    -device usb-ehci -device usb-kbd -device usb-mouse -usb \
    -monitor stdio
  • You should be able to install Ubuntu as normal
  • If you want a desktop environment, you can install it using sudo apt-get install ubuntu-desktop

Create Windows VM

  • Download Windows for ARM from here
  • Create an empty file for persisting UEFI variables:
dd if=/dev/zero conv=sync bs=1m count=64 of=ovmf_vars.fd
  • For Windows, we need to replace the VirtIO block device with something that is supported natively by the OS. Otherwise, the command-line is almost unchanged
  • You may want to pass multiple cores to the VM using -smp X:
qemu-system-aarch64 \
    -accel hvf \
    -m 2048 -smp 2 \
    -cpu cortex-a72 -M virt,highmem=off  \
    -drive file=/usr/local/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
    -drive file=ovmf_vars.fd,if=pflash,format=raw \
    -serial telnet::4444,server,nowait \
    -drive if=none,file=Windows10_InsiderPreview_Client_ARM64_en-us_20231.VHDX,format=vhdx,id=hd0,cache=writethrough \
    -device nvme,drive=hd0,serial="dummyserial" \
    -nic user,model=virtio \
    -vga none -device ramfb \
    -device usb-ehci -device usb-kbd -device usb-mouse -usb \
    -monitor stdio

Limitations

Networking on Windows

Windows does not support VirtIO network interfaces out of the box. To get it working, you need to install additional drivers. See this gist for a guide (be sure to use version 0.1.190 instead of 0.1.185)

Resolution

The resolution is set to 800x600 by default. To change it, hit Esc at the immediately after starting the VM, while you see the tianocore logo, to get into the OVMF config menu. Choose Device Manager -> OVMF Platform Configuration -> Change Preferred -> Select 1024x768 -> Commit Changes and Exit -> Esc -> Reset.

Tweaks

Port Forwarding

Proper NAT networking is currently not possible with QEMU due to the lack of tap devices in macOS Big Sur. If you just want to be able to connect to a port on the VM (e.g. for SSH or RDP), you can configure QEMU to forward a local port to the VM:

    -nic user,model=virtio,hostfwd=tcp:127.0.0.1:3389-0.0.0.0:3389 \

In this case the port for RDP is forwarded so that I can connect to the VM at localhost:3389. The same for Ubuntu/SSH:

    -netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-0.0.0.0:22 \

Disk Snapshots

Some users experience a random filesystem corruptions when booting Windows which can be avoided with the cache=writethrough for the hard drive. You can also perform disk snapshots to save the state of the hard disk at a certain point in time and restore it later. To do this, shut the VM down and create a new disk with your original image as the backing file:

qemu-img create -b Windows10_InsiderPreview_Client_ARM64_en-us_20231.VHDX -F vhdx -f qcow2 disk.qcow2

Now, adjust the -drive parameter so that QEMU boots from your new image:

    -drive if=none,file=disk.qcow2,format=qcow2,id=hd0,cache=writethrough \

If something goes wrong you can now delete disk.qcow2 and recreate it using the same commmand to back to the original state.

diff --git a/Makefile b/Makefile
index bcbbec71a1..8b75085fa5 100644
--- a/Makefile
+++ b/Makefile
@@ -85,7 +85,7 @@ x := $(shell rm -rf meson-private meson-info meson-logs)
endif
# 1. ensure config-host.mak is up-to-date
-config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
+config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/QEMU_VERSION
@echo config-host.mak is out-of-date, running configure
@if test -f meson-private/coredata.dat; then \
./config.status --skip-meson; \
@@ -204,7 +204,7 @@ clean: recurse-clean
rm -f TAGS cscope.* *.pod *~ */*~
rm -f fsdev/*.pod scsi/*.pod
-VERSION = $(shell cat $(SRC_PATH)/VERSION)
+VERSION = $(shell cat $(SRC_PATH)/QEMU_VERSION)
dist: qemu-$(VERSION).tar.bz2
diff --git a/QEMU_VERSION b/QEMU_VERSION
new file mode 100644
index 0000000000..5214c0b8b9
--- /dev/null
+++ b/QEMU_VERSION
@@ -0,0 +1 @@
+5.2.0
diff --git a/VERSION b/VERSION
deleted file mode 100644
index 5214c0b8b9..0000000000
--- a/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-5.2.0
diff --git a/meson.build b/meson.build
index 2dc66ae930..a8f8a02b3f 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
project('qemu', ['c'], meson_version: '>=0.55.0',
default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11', 'b_colorout=auto'] +
(meson.version().version_compare('>=0.56.0') ? [ 'b_staticpic=false' ] : []),
- version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
+ version: run_command('head', meson.source_root() / 'QEMU_VERSION').stdout().strip())
not_found = dependency('', required: false)
if meson.version().version_compare('>=0.56.0')
@citruz
Copy link
Author

citruz commented Mar 23, 2021

I am trying to install Ubuntu on a MacBook Pro Silicon (M1 CPU) but facing a problem running:

mkdir build
cd build
../configure --target-list=aarch64-softmmu
make -j8
sudo make install

It gives several errors, and finally:
qemu/include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found
#include <gnutls/gnutls.h>
^~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
make: *** [run-ninja] Error 1

I would appreciate your help to realise what is going on.

@ahmadfakhari Try adding --disable-gnutls to the configure command.

@fishphhd
Copy link

fishphhd commented Mar 27, 2021

Thanks for your manual. I tried to start this with libvirt with this manual to start the qemu at boot time. But this takes the wrong accelerator.

Error: Error while defining a domain from ubuntu.xml
Error: internal error: Failed to start QEMU binary /usr/local/bin/qemu-system-aarch64 for probing: qemu-system-aarch64: invalid accelerator kvm
Could not allocate dynamic translator buffer

Any idea?

My question on stackoverflow.com

I used this xml to define with virsh (virsh define ubuntu.xml):

<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
    <name>ubuntu</name>
    <uuid>2005CB24-522A-4485-9B9A-E60A61D9F8CF</uuid>
    <memory unit='GB'>2</memory>
    <cpu mode='custom'>
        <model>Westmere</model>
    </cpu>
    <vcpu>2</vcpu>
    <features>
        <acpi/>
        <apic/>
    </features>
    <os>
        <type arch='aarch64' machine='cortex-a57'>hvf</type>
        <bootmenu enable='yes'/>
    </os>
    <clock offset='localtime'/>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>
    <pm>
        <suspend-to-mem enabled='no'/>
        <suspend-to-disk enabled='no'/>
    </pm>
    <devices>
        <emulator>/usr/local/bin/qemu-system-aarch64</emulator>
        <controller type='usb' model='ehci'/>
        <disk type='file' device='disk'>
            <driver name='qemu' type='qcow2'/>
            <source file='/Users/user/VM/Ubuntu_20.04-LTS/disk.qcow2'/>
            <target dev='vda' bus='virtio'/>
        </disk>
        <!--disk type='file' device='cdrom'>
            <source file='/Users/user/VM/Ubuntu_20.04-LTS/ubuntu-20.04.2-live-server-arm64.iso'/>
            <target dev='sdb' bus='sata'/>
        </disk-->
        <console type='pty'>
            <target type='serial'/>
        </console>
        <input type='tablet' bus='usb'/>
        <input type='keyboard' bus='usb'/>
        <graphics type='vnc' port='5900' listen='127.0.0.1'/>
        <video>
            <model type='virtio' vram='16384'/>
        </video>
    </devices>
    <seclabel type='none'/>
    <qemu:commandline>
        <!--qemu:arg value='-machine'/>
        <qemu:arg value='type=q35,accel=hvf'/>
        <qemu:arg value='-netdev'/>
        <qemu:arg value='user,id=n1,hostfwd=tcp::2222-:22'/>
        <qemu:arg value='-device'/>
        <qemu:arg value='virtio-net-pci,netdev=n1,bus=pcie.0,addr=0x19'/-->
	<qemu:arg value='-accel hvf -m 2048 -cpu cortex-a57 -M virt,highmem=off'/>
	<qemu:arg value='-drive file=/usr/local/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on'/>
	<qemu:arg value='-drive file=ovmf_vars.fd,if=pflash,format=raw'/>
	<qemu:arg value='-serial telnet::4444,server,nowait'/>
	<qemu:arg value='-device virtio-blk-device,drive=hd0,serial="dummyserial"'/>
	<qemu:arg value='-device virtio-net-device,netdev=net0'/>
	<qemu:arg value='-netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-0.0.0.0:22'/>
	<qemu:arg value='-vga none -device ramfb'/>
	<qemu:arg value='-device usb-ehci -device usb-kbd -device usb-mouse -usb'/>
	<qemu:arg value='-nographic -serial mon:stdio'/>
    </qemu:commandline>
</domain>

@citruz
Copy link
Author

citruz commented Mar 30, 2021

M1 support is added in the upcoming release of QEMU (6.0) - RC0 comes out today.

@mikegil are you sure about that? I don't see it in the source tree unfortunately https://github.com/qemu/qemu/tree/v6.0.0-rc1/accel/hvf

The changelog states that TCG (emulation) has been updated to work on Apple Silicon, but nothing about @agraf's patches for Hypervisor.framework on Arm.

@faaaaabi
Copy link

faaaaabi commented Apr 2, 2021

I also did as explained and getting

qemu-system-aarch64: -accel hvf: invalid accelerator hvf

I also did the resigning as explained

@kripsy
Copy link

kripsy commented Apr 10, 2021

I also did as explained and getting

qemu-system-aarch64: -accel hvf: invalid accelerator hvf

I also did the resigning as explained

i have same problem

@zoain-it
Copy link

zoain-it commented Apr 16, 2021

How I use sound

@SebDanielsson
Copy link

SebDanielsson commented Apr 29, 2021

With QEMU 6.0 now released, anyone got an idea which patches are now included and which are still missing? A list would be nice 👍

@Lunaticf
Copy link

Lunaticf commented May 2, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t  mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
                                                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
  ^````

use the instruction...dont know why compile error

@zoain-it
Copy link

zoain-it commented May 3, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
^````

use the instruction...dont know why compile error

https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3727099

@Lunaticf
Copy link

Lunaticf commented May 3, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
^````
use the instruction...dont know why compile error

https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3727099

thank you, install xcode is not working. I just want to install qemu on mac m1, tried so many solutions.

@zoain-it
Copy link

zoain-it commented May 3, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
^````
use the instruction...dont know why compile error

https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3727099

thank you, install xcode is not working. I just want to install qemu on mac m1, tried so many solutions.

Just modify the name of the VERSION file under qemu, and he read the one include when compiling. So https://github.com/knazarov/homebrew-qemu-virgl/blob/master/Patches/qemu-version-v01.diff

@Lunaticf
Copy link

Lunaticf commented May 3, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
^````
use the instruction...dont know why compile error

https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3727099

thank you, install xcode is not working. I just want to install qemu on mac m1, tried so many solutions.

Just modify the name of the VERSION file under qemu, and he read the one include when compiling. So https://github.com/knazarov/homebrew-qemu-virgl/blob/master/Patches/qemu-version-v01.diff

change the �VERSION file to QEMU_VERSION still the same error....

@zoain-it
Copy link

zoain-it commented May 3, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
^````
use the instruction...dont know why compile error

https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3727099

thank you, install xcode is not working. I just want to install qemu on mac m1, tried so many solutions.

Just modify the name of the VERSION file under qemu, and he read the one include when compiling. So https://github.com/knazarov/homebrew-qemu-virgl/blob/master/Patches/qemu-version-v01.diff

change the �VERSION file to QEMU_VERSION still the same error....

Did you apply all the changes in that patch?

@Lunaticf
Copy link

Lunaticf commented May 3, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
^````
use the instruction...dont know why compile error

https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3727099

thank you, install xcode is not working. I just want to install qemu on mac m1, tried so many solutions.

Just modify the name of the VERSION file under qemu, and he read the one include when compiling. So https://github.com/knazarov/homebrew-qemu-virgl/blob/master/Patches/qemu-version-v01.diff

change the �VERSION file to QEMU_VERSION still the same error....

Did you apply all the changes in that patch?

just did this above
curl https://patchwork.kernel.org/series/418581/mbox/ | git am --exclude=MAINTAINERS
make me crazy

@zoain-it
Copy link

zoain-it commented May 3, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
^````
use the instruction...dont know why compile error

https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3727099

thank you, install xcode is not working. I just want to install qemu on mac m1, tried so many solutions.

Just modify the name of the VERSION file under qemu, and he read the one include when compiling. So https://github.com/knazarov/homebrew-qemu-virgl/blob/master/Patches/qemu-version-v01.diff

change the �VERSION file to QEMU_VERSION still the same error....

Did you apply all the changes in that patch?

just did this above
curl https://patchwork.kernel.org/series/418581/mbox/ | git am --exclude=MAINTAINERS
make me crazy

On this basis, just merge https://github.com/knazarov/homebrew-qemu-virgl/blob/master/Patches/qemu-version-v01.diff.

@wintifrosch
Copy link

wintifrosch commented May 12, 2021

building qemu failed. full log on my dropbox

...
admin@Mac-mini-von-Admin qemu % mkdir build
cd build
../configure --target-list=aarch64-softmmu --disable-gnutls
make -j8
sudo make install
...
[830/2393] Compiling C++ object libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
FAILED: libcommon.fa.p/disas_libvixl_vixl_utils.cc.o 
[830/2393] Compiling C++ object libcommon.fa.p/disas_libvixl_vixl_utils.cc.o
FAILED: libcommon.fa.p/disas_libvixl_vixl_utils.cc.o 
c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -I../slirp -I../slirp/src -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.2/include -I/opt/homebrew/Cellar/glib/2.68.2/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.2/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.2/include/gio-unix-2.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/admin/qemu/tcg/aarch64 -iquote . -iquote /Users/admin/qemu -iquote /Users/admin/qemu/accel/tcg -iquote /Users/admin/qemu/include -iquote /Users/admin/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_utils.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_utils.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_utils.cc.o -c ../disas/libvixl/vixl/utils.cc
In file included from ../disas/libvixl/vixl/utils.cc:27:
In file included from /Users/admin/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.0
^
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ninja: build stopped: subcommand failed.
make: *** [run-ninja] Error 1
admin@Mac-mini-von-Admin build % 

@mateuszdrab
Copy link

mateuszdrab commented May 18, 2021

c++ -Ilibcommon.fa.p -I. -I.. -I../capstone/include/capstone -I../dtc/libfdt -Iqapi -Itrace -Iui -Iui/shader -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/jpeg/9d/include -I/opt/homebrew/Cellar/libffi/3.3_3/include -I/opt/homebrew/Cellar/glib/2.68.1/include -I/opt/homebrew/Cellar/glib/2.68.1/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.68.1/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.44/include -I/opt/homebrew/Cellar/glib/2.68.1/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libslirp/4.4.0_1/include/slirp -I/opt/homebrew/Cellar/libusb/1.0.24/include/libusb-1.0 -fcolor-diagnostics -Wall -Winvalid-pch -Wnon-virtual-dtor -std=gnu++11 -O2 -g -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DOS_OBJECT_USE_OBJC=0 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wundef -Wwrite-strings -fno-strict-aliasing -fno-common -fwrapv -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-string-plus-int -Wno-typedef-redefinition -Wno-tautological-type-limit-compare -Wno-psabi -fstack-protector-strong -iquote /Users/lunaticf/qemu/tcg/aarch64 -iquote . -iquote /Users/lunaticf/qemu -iquote /Users/lunaticf/qemu/accel/tcg -iquote /Users/lunaticf/qemu/include -iquote /Users/lunaticf/qemu/disas/libvixl -MD -MQ libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -MF libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o.d -o libcommon.fa.p/disas_libvixl_vixl_a64_decoder-a64.cc.o -c ../disas/libvixl/vixl/a64/decoder-a64.cc
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:37:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:418:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:308:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:310:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/limits:121:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:28:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/utils.h:31:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:309:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:668:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/typeinfo:60:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/exception:83:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:671:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/new:93:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:205:
../version:1:1: error: expected unqualified-id
5.2.50
^
In file included from ../disas/libvixl/vixl/a64/decoder-a64.cc:29:
In file included from /Users/lunaticf/qemu/disas/libvixl/vixl/a64/decoder-a64.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/list:185:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:672:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/utility:206:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__debug:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:95:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/wchar.h:119:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:107:48: error: unknown type name 'mbstate_t'; did you mean '__mbstate_t'?
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_types.h:55:3: note: '__mbstate_t' declared here
} __mbstate_t;
^````
use the instruction...dont know why compile error

https://gist.github.com/akihikodaki/87df4149e7ca87f18dc56807ec5a1bc5#gistcomment-3727099

thank you, install xcode is not working. I just want to install qemu on mac m1, tried so many solutions.

Just modify the name of the VERSION file under qemu, and he read the one include when compiling. So https://github.com/knazarov/homebrew-qemu-virgl/blob/master/Patches/qemu-version-v01.diff

change the �VERSION file to QEMU_VERSION still the same error....

Did you apply all the changes in that patch?

just did this above
curl https://patchwork.kernel.org/series/418581/mbox/ | git am --exclude=MAINTAINERS
make me crazy

On this basis, just merge https://github.com/knazarov/homebrew-qemu-virgl/blob/master/Patches/qemu-version-v01.diff.

I merged this patch along with the two patches from https://arstechnica.com/civis/viewtopic.php?f=19&t=1473419 to compile a qemu capable of running x86 on m1 but I get stuck at the following error:

../target/i386/hvf/vmx.h:162:5: note: did you mean 'hv_vcpu_run'?

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Hypervisor.framework/Headers/hv_vcpu.h:238:1: note: 'hv_vcpu_run' declared here
hv_vcpu_run(hv_vcpu_t vcpu);
^
In file included from ../target/i386/hvf/x86_task.c:17:
../target/i386/hvf/vmx.h:165:34: error: unknown type name 'hv_vcpuid_t'; did you mean 'hv_vcpu_t'?
static inline void macvm_set_cr4(hv_vcpuid_t vcpu, uint64_t cr4)
^~~~~~~~~~~
hv_vcpu_t
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Hypervisor.framework/Headers/hv_vcpu_types.h:37:18: note: 'hv_vcpu_t' declared here
typedef uint64_t hv_vcpu_t;
^
In file included from ../target/i386/hvf/x86_task.c:17:
../target/i386/hvf/vmx.h:173:5: error: implicit declaration of function 'hv_vcpu_invalidate_tlb' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
hv_vcpu_invalidate_tlb(vcpu);
^
../target/i386/hvf/vmx.h:174:5: error: implicit declaration of function 'hv_vcpu_flush' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
hv_vcpu_flush(vcpu);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

That means the SDK version is different?

@ihsakashi
Copy link

ihsakashi commented May 24, 2021

@fishphhd I've got a working Libvirt solution. In your case, you need to add -machine accel=hvf,highmem=off. I opened a repo, https://github.com/ihsakashi/VM . Refer to that.

@nrjdalal
Copy link

nrjdalal commented Jun 6, 2021

Installation method above is using QEMU v5.2.0 and Patch Series v6. Also code is signed manually and needs patching for Xcode.

The method above bring a lot redundancy as of June 2021.

Best practice for QEMU installation as of now is given below.

QEMU Silicon Mac Installation

Changelog -

  • QEMU v5.2.0 -> v6.0.0
  • HVF Patch Series v6 -> v8
  • Removes redundant Xcode patching
  • Removes redundant code signing

The link above also provides one command installer.

@nrjdalal
Copy link

nrjdalal commented Jun 6, 2021

Those of you, still having issues installing QEMU, can look into one click installer at the provided link. Be sure to uninstall any instances of QEMU that are installed using brew.

QEMU Silicon Mac Installation

@ywiyogo
Copy link

ywiyogo commented Jul 18, 2021

I also did as explained and getting

qemu-system-aarch64: -accel hvf: invalid accelerator hvf

I also did the resigning as explained
@faaaaabi & @kripsy

You missed the section:

sudo codesign --entitlements /path/to/qemu/accel/hvf/entitlements.plist --force -s - `which qemu-system-aarch64`

If the command hangs, try to run which qemu-system-aarch64 first, and copy the path manually.

@KvizadSaderah
Copy link

KvizadSaderah commented Aug 10, 2021

sudo codesign --entitlements /path/to/qemu/accel/hvf/entitlements.plist --force -s - `which qemu-system-aarch64`

If the command hangs, try to run which qemu-system-aarch64 first, and copy the path manually.

Hi! Even after

sudo codesign --entitlements /path/to/qemu/accel/hvf/entitlements.plist --force -s - `which qemu-system-aarch64`

it still give error qemu-system-aarch64: -accel hvf: invalid accelerator hvf

@kiranchavala
Copy link

kiranchavala commented Aug 23, 2021

Facing the same issue, any updates

@kassiansun
Copy link

kassiansun commented Oct 12, 2021

qemu 6.1 from homebrew now supports hvf natively, everything works on my m1 machine now :)

@m-bers
Copy link

m-bers commented Oct 17, 2021

@kassiansun I tried the 6.1 homebrew release on my M1 Macbook Air and cannot get networking working with -netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-0.0.0.0:22 \

@kassiansun
Copy link

kassiansun commented Oct 31, 2021

@kassiansun I tried the 6.1 homebrew release on my M1 Macbook Air and cannot get networking working with -netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-0.0.0.0:22 \

Did you see any error message? My guess is you're running another VM/application binding to host port tcp:127.0.0.1:2222.

@m-bers
Copy link

m-bers commented Nov 1, 2021

lsof -i tcp:2222 on the host gives no output, so I assume the port is good to go.
Within the VM, I get some really weird behavior. This is what a ping looks like (I get the same results pinging a host on my local network as well):

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=0 ttl=255 time=5324017251240566 ms
wrong data byte #16 should be 0x10 but was 0x0
#16	0 1 0 1 84 f9 7f 61 0 0 0 0 a5 a6 a 0 0 0 0 0 10 11 12 13 14 15 16 17 18 19 1a 1b 
#48	1c 1d 1e 1f 20 21 22 23 

Whereas if I use a different binary (like the one from https://github.com/canonical/multipass), everything works fine, and I can even use

-nic vmnet-macos,mode=shared,model=virtio-net-pci \

to give the VM it's own NAT IP address that I can ssh to directly without port forwarding.

@brandonros
Copy link

brandonros commented Dec 20, 2021

$ uname -a
Darwin Brandons-MacBook-Air.local 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:29:10 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T8101 arm64

$ qemu-system-aarch64 --version # from brew
QEMU emulator version 6.2.0
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

qemu-system-aarch64 \
    -accel hvf \
    -m 2048 -smp 2 \
    -cpu cortex-a72 -M virt,highmem=off  \
    -drive file=/opt/homebrew/share/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on \
    -drive file=/tmp/ovmf_vars.fd,if=pflash,format=raw \
    -serial telnet::4444,server,nowait \
    -drive file=~/Downloads/Windows11_InsiderPreview_Client_ARM64_en-us_22523.VHDX,if=none,format=vhdx,id=hd0,cache=writethrough \
    -device nvme,drive=hd0,serial="dummyserial" \
    -nic user,model=virtio \
    -vga none -device ramfb \
    -device usb-ehci -device usb-kbd -device usb-mouse -usb \
    -monitor stdio

image

Stuck on this TianoCore loading screen.

@Baekalfen
Copy link

Baekalfen commented Mar 18, 2022

@brandonros I was stuck at the same place. I realized I was trying to load an old x86 .iso. Switching to Fedora in aarch64 worked.

@santiagorodpeya
Copy link

santiagorodpeya commented May 30, 2022

Hi,

I am not able to run the qemu on my MacBook Pro (13-inch, M1, 2020).
When I tried to run qemu command always fails. I created the two previous disk mentioned on the guide.
Screenshot at May 30 11-08-39

Any idea?

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment