Skip to content

Commit 75dbfba

Browse files
pbo-linarostsquad
authored andcommitted
docs/devel: add information on how to setup build environments
MacOS and Linux are straightforward, but Windows needs a bit more details. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Message-Id: <20241209183104.365796-5-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20250116160306.1709518-35-alex.bennee@linaro.org>
1 parent ca494c9 commit 75dbfba

File tree

4 files changed

+124
-2
lines changed

4 files changed

+124
-2
lines changed

MAINTAINERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ R: Markus Armbruster <armbru@redhat.com>
7272
R: Philippe Mathieu-Daudé <philmd@linaro.org>
7373
W: https://www.qemu.org/docs/master/devel/index.html
7474
S: Odd Fixes
75-
F: docs/devel/style.rst
75+
F: docs/devel/build-environment.rst
7676
F: docs/devel/code-of-conduct.rst
7777
F: docs/devel/conflict-resolution.rst
78+
F: docs/devel/style.rst
7879
F: docs/devel/submitting-a-patch.rst
7980
F: docs/devel/submitting-a-pull-request.rst
8081

docs/about/build-platforms.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ The `Repology`_ site is a useful resource to identify
2929
currently shipped versions of software in various operating systems,
3030
though it does not cover all distros listed below.
3131

32+
You can find how to install build dependencies for different systems on the
33+
:ref:`setup-build-env` page.
34+
3235
Supported host architectures
3336
----------------------------
3437

@@ -130,7 +133,6 @@ Optional build dependencies
130133
cross compilation using ``docker`` or ``podman``, or to use pre-built
131134
binaries distributed with QEMU.
132135

133-
134136
Windows
135137
-------
136138

docs/devel/build-environment.rst

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
2+
.. _setup-build-env:
3+
4+
Setup build environment
5+
=======================
6+
7+
QEMU uses a lot of dependencies on the host system. glib2 is used everywhere in
8+
the code base, and most of the other dependencies are optional.
9+
10+
We present here simple instructions to enable native builds on most popular
11+
systems.
12+
13+
You can find additional instructions on `QEMU wiki <https://wiki.qemu.org/>`_:
14+
15+
- `Linux <https://wiki.qemu.org/Hosts/Linux>`_
16+
- `MacOS <https://wiki.qemu.org/Hosts/Mac>`_
17+
- `Windows <https://wiki.qemu.org/Hosts/W32>`_
18+
- `BSD <https://wiki.qemu.org/Hosts/BSD>`_
19+
20+
Note: Installing dependencies using your package manager build dependencies may
21+
miss out on deps that have been newly introduced in qemu.git. In more, it misses
22+
deps the distribution has decided to exclude.
23+
24+
Linux
25+
-----
26+
27+
Fedora
28+
++++++
29+
30+
::
31+
32+
sudo dnf update && sudo dnf builddep qemu
33+
34+
Debian/Ubuntu
35+
+++++++++++++
36+
37+
You first need to enable `Sources List <https://wiki.debian.org/SourcesList>`_.
38+
Then, use apt to install dependencies:
39+
40+
::
41+
42+
sudo apt update && sudo apt build-dep qemu
43+
44+
MacOS
45+
-----
46+
47+
You first need to install `Homebrew <https://brew.sh/>`_. Then, use it to
48+
install dependencies:
49+
50+
::
51+
52+
brew update && brew install $(brew deps --include-build qemu)
53+
54+
Windows
55+
-------
56+
57+
You first need to install `MSYS2 <https://www.msys2.org/>`_.
58+
MSYS2 offers `different environments <https://www.msys2.org/docs/environments/>`_.
59+
x86_64 environments are based on GCC, while aarch64 is based on Clang.
60+
61+
We recommend to use MINGW64 for windows-x86_64 and CLANGARM64 for windows-aarch64
62+
(only available on windows-aarch64 hosts).
63+
64+
Then, you can open a windows shell, and enter msys2 env using:
65+
66+
::
67+
68+
c:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64
69+
# Replace -ucrt64 by -clangarm64 or -ucrt64 for other environments.
70+
71+
MSYS2 package manager does not offer a built-in way to install build
72+
dependencies. You can start with this list of packages using pacman:
73+
74+
Note: Dependencies need to be installed again if you use a different MSYS2
75+
environment.
76+
77+
::
78+
79+
# update MSYS2 itself, you need to reopen your shell at the end.
80+
pacman -Syu
81+
pacman -S \
82+
base-devel binutils bison diffutils flex git grep make sed \
83+
${MINGW_PACKAGE_PREFIX}-toolchain \
84+
${MINGW_PACKAGE_PREFIX}-glib2 \
85+
${MINGW_PACKAGE_PREFIX}-gtk3 \
86+
${MINGW_PACKAGE_PREFIX}-libnfs \
87+
${MINGW_PACKAGE_PREFIX}-libssh \
88+
${MINGW_PACKAGE_PREFIX}-ninja \
89+
${MINGW_PACKAGE_PREFIX}-pixman \
90+
${MINGW_PACKAGE_PREFIX}-pkgconf \
91+
${MINGW_PACKAGE_PREFIX}-python \
92+
${MINGW_PACKAGE_PREFIX}-SDL2 \
93+
${MINGW_PACKAGE_PREFIX}-zstd
94+
95+
If you want to install all dependencies, it's possible to use recipe used to
96+
build QEMU in MSYS2 itself.
97+
98+
::
99+
100+
pacman -S wget
101+
wget https://raw.githubusercontent.com/msys2/MINGW-packages/refs/heads/master/mingw-w64-qemu/PKGBUILD
102+
# Some packages may be missing for your environment, installation will still
103+
# be done though.
104+
makepkg -s PKGBUILD || true
105+
106+
Build on windows-aarch64
107+
++++++++++++++++++++++++
108+
109+
When trying to cross compile meson for x86_64 using UCRT64 or MINGW64 env,
110+
configure will run into an error because the cpu detected is not correct.
111+
112+
Meson detects x86_64 processes emulated, so you need to manually set the cpu,
113+
and force a cross compilation (with empty prefix).
114+
115+
::
116+
117+
./configure --cpu=x86_64 --cross-prefix=
118+

docs/devel/index-build.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ some of the basics if you are adding new files and targets to the build.
88
:maxdepth: 3
99

1010
build-system
11+
build-environment
1112
kconfig
1213
docs
1314
qapi-code-gen

0 commit comments

Comments
 (0)