Hosts/Mac: Difference between revisions

From QEMU
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= QEMU on OS X (macOS) hosts =
= Notes =
Some system emulations on Linux use KVM, a special emulation mode which claims to reach nearly native speed.
KVM is mainly used for x86 (32 and 64 bit) emulation on x86 hosts running Linux. Should you want to run Qemu with KVM support on a G5, depending on your distribution, you might have to compile your own kernel with KVM support.
 
If your host's (your computer) architecture matches the guest's (QEMU) architecture and is running Mac OS 10.10 or higher, then you could speed up execution to near native speed using this option: -accel hvf


While QEMU's main host platform is [[Hosts/Linux|Linux]], it is also supported on operating systems for Apple's Mac computers (known as OS X or macOS). The official support policy covers the last two released versions of OSX; QEMU might work on older versions, but it is not guaranteed and it might not even compile on older versions.
== Installing QEMU using a package manager ==


Please note that fewer developers work on QEMU for Mac hosts, so it might be less stable (but I don't think it is). If you can replicate a bug on a Linux hosted QEMU before reporting it, this is helpful as it means a wider set of people might look into it.
[https://github.com/mistydemeo/tigerbrew Tigerbrew:]
  brew install qemu
 
[https://brew.sh HomeBrew:]
  brew install qemu
 
[https://www.macports.org MacPorts:]
  sudo port install qemu
 
[https://www.finkproject.org Fink:]
  fink install qemu


Some system emulations on Linux use KVM, a special emulation mode which claims to reach nearly native speed.
KVM is mainly used for x86 (32 and 64 bit) emulation on x86 hosts running Linux. Should you want to run Qemu with KVM support on a G5, depending on your distribution, you might have to compile your own kernel with KVM support.
There exists a port of QEMU to Hypervisor.framework (a kernel module from Apple which is similar in spirit to KVM), but unfortunately it is not included in upstream QEMU.


== Building QEMU for OS X ==
== Building QEMU for macOS ==


The system requirements are:
The system requirements are:
* One of the last two most recent versions of OS X (currently that's 10.15 or 10.16)
* One of the two most recent versions of macOS (currently Ventura or Sonoma)
* The clang compiler shipped with the version of Xcode for that OS X. GCC might also work, but we recommend clang
* The clang compiler shipped with the version of Xcode for that OS X. GCC might also work, but we recommend clang


Line 20: Line 31:
* [http://ftp.gnome.org/pub/GNOME/sources/glib/ glib]
* [http://ftp.gnome.org/pub/GNOME/sources/glib/ glib]
* [http://www.freedesktop.org/wiki/Software/pkg-config/ pkg-config]
* [http://www.freedesktop.org/wiki/Software/pkg-config/ pkg-config]
* [http://www.gnu.org/software/autoconf/autoconf.html autoconf]
* [http://www.gnu.org/software/automake/ automake]
* [http://www.pixman.org/ pixman]
* [http://www.pixman.org/ pixman]
* [https://ninja-build.org/ ninja]
* [https://ninja-build.org/ ninja]
* [https://mesonbuild.com/ meson]
As Qemu can now also run in SDL or GTK windows besides a Cocoa window, optionally you can install the SDL2 and./or gtk+3 devel packages.


make (when installed through brew, make is installed as gmake, so use gmake)
make (when installed through brew, make is installed as gmake, so use gmake)
You may find it easiest to get these from a third-party packager
such as [http://brew.sh/ Homebrew], [https://www.macports.org Macports], or [http://finkproject.org Fink].


After downloading the QEMU source code, double-click it to expand it.
After downloading the QEMU source code, double-click it to expand it.
Line 47: Line 55:
You can use './configure --help' to see a full list of options.  
You can use './configure --help' to see a full list of options.  


Here are all the currently available machines:
We recommend building QEMU with the default compiler provided by Apple, for your version of Mac OS X (which will be 'clang'). The configure script will automatically pick this.
<ul>
<li>aarch64-softmmu</li>
<li>alpha-softmmu</li>
<li>arm-softmmu</li>
<li>cris-softmmu</li>
<li>i386-softmmu</li>
<li>lm32-softmmu</li>
<li>m68k-softmmu</li>
<li>microblaze-softmmu</li>
<li>microblazeel-softmmu</li>
<li>mips-softmmu</li>
<li>mips64-softmmu</li>
<li>mips64el-softmmu</li>
<li>mipsel-softmmu</li>
<li>moxie-softmmu</li>
<li>or32-softmmu</li>
<li>ppc-softmmu</li>
<li>ppc64-softmmu</li>
<li>ppcemb-softmmu</li>
<li>s390x-softmmu</li>
<li>sh4-softmmu</li>
<li>sh4eb-softmmu</li>
<li>sparc-softmmu</li>
<li>sparc64-softmmu</li>
<li>tricore-softmmu</li>
<li>unicore32-softmmu</li>
<li>x86_64-softmmu</li>
<li>xtensa-softmmu</li>
<li>xtensaeb-softmmu</li>
</ul>
 
 
We recommend building QEMU with the -default compiler provided by Apple, for your version of Mac OS X (which will be 'clang'). The configure script will automatically pick this.


== Errors on old compilers ==
== Errors on old compilers ==
Line 111: Line 86:
  --extra-cxxflags="-I/usr/local/opt/llvm/include" \
  --extra-cxxflags="-I/usr/local/opt/llvm/include" \
  --extra-ldflags="-L/usr/local/opt/llvm/lib -L/usr/local/opt/libffi/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib" \
  --extra-ldflags="-L/usr/local/opt/llvm/lib -L/usr/local/opt/libffi/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib" \
  --target-list="ppc-softmmu"
  --target-list="<list of machines here>"


== Contacts ==
== Contacts ==
If there are any issues with this web page, please let [mailto:programmingkidx@gmail.com me] know.
If there are any issues with this web page, please let [mailto:programmingkidx@gmail.com me] know.

Latest revision as of 18:08, 9 October 2023

Notes

Some system emulations on Linux use KVM, a special emulation mode which claims to reach nearly native speed. KVM is mainly used for x86 (32 and 64 bit) emulation on x86 hosts running Linux. Should you want to run Qemu with KVM support on a G5, depending on your distribution, you might have to compile your own kernel with KVM support.

If your host's (your computer) architecture matches the guest's (QEMU) architecture and is running Mac OS 10.10 or higher, then you could speed up execution to near native speed using this option: -accel hvf

Installing QEMU using a package manager

Tigerbrew:

 brew install qemu

HomeBrew:

 brew install qemu

MacPorts:

 sudo port install qemu

Fink:

 fink install qemu


Building QEMU for macOS

The system requirements are:

  • One of the two most recent versions of macOS (currently Ventura or Sonoma)
  • The clang compiler shipped with the version of Xcode for that OS X. GCC might also work, but we recommend clang

Additional build requirements are:

As Qemu can now also run in SDL or GTK windows besides a Cocoa window, optionally you can install the SDL2 and./or gtk+3 devel packages.

make (when installed through brew, make is installed as gmake, so use gmake)

After downloading the QEMU source code, double-click it to expand it.

Then configure and make QEMU. The target-list option is used to build only the machine or machines you want. If you don't specify it, all machines would be built. Probably not what you want.

./configure --target-list=<list of machines here>
make

This way doesn't require you to wait for the configure command to complete:

./configure --target-list=<list of machines here> && make

If your system has the 'say' command, you can use it to tell you when QEMU is done

 ./configure --target-list=i386-softmmu,ppc-softmmu && make ; say "I'm all done compiling QEMU"

You can use './configure --help' to see a full list of options.

We recommend building QEMU with the default compiler provided by Apple, for your version of Mac OS X (which will be 'clang'). The configure script will automatically pick this.

Errors on old compilers

Note: If after the configure step you see a message like this:

ERROR: Your compiler does not support the __thread specifier for
       Thread-Local Storage (TLS). Please upgrade to a version that does.

you may have to install your own version of gcc. You can build it from source (expect that to take several hours) or obtain third party binaries of gcc available from Homebrew or MacPorts.

You can have several versions of GCC on your system. To specify a certain version, use the --cc and --cxx options.

./configure --cxx=<path of your c++ compiler> --cc=<path of your c compiler> <other options>

Build with LLVM/Clang 7

If you need to compile with newer versions of clang (to get f.i. AVX/AVX2 support), you can install llvm through e.g., brew.

brew install llvm

Note that building for machines with CPUs supporting such extensions will exclude running your binary on earlier machines.

Compile with:

export PATH="/usr/local/opt/llvm/bin:$PATH"
./configure --cc=clang-7 --cxx=clang++-7 --host-cc=clang-7 \
--extra-cflags=-mavx2 \
--extra-cxxflags="-I/usr/local/opt/llvm/include" \
--extra-ldflags="-L/usr/local/opt/llvm/lib -L/usr/local/opt/libffi/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib" \
--target-list="<list of machines here>"

Contacts

If there are any issues with this web page, please let me know.