diff mbox series

[12/12] docs: add information on how to setup build environments

Message ID 20241031040426.772604-13-pierrick.bouvier@linaro.org (mailing list archive)
State New
Headers show
Series Enable building plugins on Windows with Clang | expand

Commit Message

Pierrick Bouvier Oct. 31, 2024, 4:04 a.m. UTC
MacOS and Linux are straightforward, but Windows needs a bit more
details.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 docs/about/build-platforms.rst |   4 +-
 docs/devel/build-system.rst    | 100 +++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+), 1 deletion(-)

Comments

Daniel P. Berrangé Oct. 31, 2024, 9:24 a.m. UTC | #1
On Wed, Oct 30, 2024 at 09:04:26PM -0700, Pierrick Bouvier wrote:
> MacOS and Linux are straightforward, but Windows needs a bit more
> details.
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>  docs/about/build-platforms.rst |   4 +-
>  docs/devel/build-system.rst    | 100 +++++++++++++++++++++++++++++++++
>  2 files changed, 103 insertions(+), 1 deletion(-)

> +Windows
> +-------
> +
> +You first need to install `MSYS2 <https://www.msys2.org/>`_.
> +MSYS2 offers `different environments <https://www.msys2.org/docs/environments/>`_.
> +x86_64 environments are based on GCC, while aarch64 is based on Clang.
> +
> +We recommend to use UCRT64 for windows-x86_64 and CLANGARM64 for windows-aarch64
> +(only available on windows-aarch64 hosts).

I don't believe we should be recommending ucrt64 for windows. We have two
testing jobs, one cross compiled from Mingw Fedora, and one native under
Msys2, both of which are validating mingw64. We have no ucrt64 testing.
IIUC, Stefan's QEMU installer binaries are also mingw32/mingw64 based,
not ucrt64.

With regards,
Daniel
Pierrick Bouvier Oct. 31, 2024, 7:38 p.m. UTC | #2
On 10/31/24 02:24, Daniel P. Berrangé wrote:
> On Wed, Oct 30, 2024 at 09:04:26PM -0700, Pierrick Bouvier wrote:
>> MacOS and Linux are straightforward, but Windows needs a bit more
>> details.
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>> ---
>>   docs/about/build-platforms.rst |   4 +-
>>   docs/devel/build-system.rst    | 100 +++++++++++++++++++++++++++++++++
>>   2 files changed, 103 insertions(+), 1 deletion(-)
> 
>> +Windows
>> +-------
>> +
>> +You first need to install `MSYS2 <https://www.msys2.org/>`_.
>> +MSYS2 offers `different environments <https://www.msys2.org/docs/environments/>`_.
>> +x86_64 environments are based on GCC, while aarch64 is based on Clang.
>> +
>> +We recommend to use UCRT64 for windows-x86_64 and CLANGARM64 for windows-aarch64
>> +(only available on windows-aarch64 hosts).
> 
> I don't believe we should be recommending ucrt64 for windows. We have two
> testing jobs, one cross compiled from Mingw Fedora, and one native under
> Msys2, both of which are validating mingw64. We have no ucrt64 testing.
> IIUC, Stefan's QEMU installer binaries are also mingw32/mingw64 based,
> not ucrt64.
> 

I have no strong opinion, and was just following default recommendation 
of MSYS2 project to switch to UCRT64.
All msys2 environment use mingw64, but mingw64 can target different 
windows runtime. From what I understand, any difference or bug would be 
a bug for mingw64 project, not for us.

UCRT is now the default target used by mingw64 [1].
More information on this difference here [2].
Migrating to UCRT64 seems to be the best way in the future.

All that said, I'll update this recommendation to MINGW64 for V2 of this 
series,

[1] https://www.mingw-w64.org/changelog/#v1200-2024-05-29
[2] 
https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-doc/howto-build/ucrt-vs-msvcrt.txt

> With regards,
> Daniel
Peter Maydell Nov. 4, 2024, 3:58 p.m. UTC | #3
On Thu, 31 Oct 2024 at 04:07, Pierrick Bouvier
<pierrick.bouvier@linaro.org> wrote:
>
> MacOS and Linux are straightforward, but Windows needs a bit more
> details.
>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>

We have documentation on the wiki currently about how to
build on various platforms:

https://wiki.qemu.org/Hosts/Linux
https://wiki.qemu.org/Hosts/Mac
https://wiki.qemu.org/Hosts/W32

I agree that we ought to move this into the main documentation.
Some of the information in those wiki pages is probably
out of date, but some of it looks like useful extra detail
that we could incorporate here.

> ---
>  docs/about/build-platforms.rst |   4 +-
>  docs/devel/build-system.rst    | 100 +++++++++++++++++++++++++++++++++

I don't think this is the best place to put this information.
"How do I build from source?" is a question that most beginning
developers and some end users will have. The information in
build-system.rst is mostly about the internals of our
build system and how to modify it, which is a more niche topic.

I would be inclined to put this in a new file, maybe even
in docs/about/ rather than docs/devel.

thanks
-- PMM
Michael S. Tsirkin Nov. 4, 2024, 4:08 p.m. UTC | #4
On Mon, Nov 04, 2024 at 03:58:19PM +0000, Peter Maydell wrote:
> On Thu, 31 Oct 2024 at 04:07, Pierrick Bouvier
> <pierrick.bouvier@linaro.org> wrote:
> >
> > MacOS and Linux are straightforward, but Windows needs a bit more
> > details.
> >
> > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> 
> We have documentation on the wiki currently about how to
> build on various platforms:
> 
> https://wiki.qemu.org/Hosts/Linux
> https://wiki.qemu.org/Hosts/Mac
> https://wiki.qemu.org/Hosts/W32
> 
> I agree that we ought to move this into the main documentation.
> Some of the information in those wiki pages is probably
> out of date, but some of it looks like useful extra detail
> that we could incorporate here.

Also, as that wiki notes:

32 bit Linux target on a 64 bit Linux host would be useful for build bots



> > ---
> >  docs/about/build-platforms.rst |   4 +-
> >  docs/devel/build-system.rst    | 100 +++++++++++++++++++++++++++++++++
> 
> I don't think this is the best place to put this information.
> "How do I build from source?" is a question that most beginning
> developers and some end users will have. The information in
> build-system.rst is mostly about the internals of our
> build system and how to modify it, which is a more niche topic.
> 
> I would be inclined to put this in a new file, maybe even
> in docs/about/ rather than docs/devel.
> 
> thanks
> -- PMM
Pierrick Bouvier Nov. 4, 2024, 10:05 p.m. UTC | #5
On 11/4/24 07:58, Peter Maydell wrote:
> On Thu, 31 Oct 2024 at 04:07, Pierrick Bouvier
> <pierrick.bouvier@linaro.org> wrote:
>>
>> MacOS and Linux are straightforward, but Windows needs a bit more
>> details.
>>
>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> 
> We have documentation on the wiki currently about how to
> build on various platforms:
> 
> https://wiki.qemu.org/Hosts/Linux
> https://wiki.qemu.org/Hosts/Mac
> https://wiki.qemu.org/Hosts/W32
> 
> I agree that we ought to move this into the main documentation.
> Some of the information in those wiki pages is probably
> out of date, but some of it looks like useful extra detail
> that we could incorporate here.
> 

I noticed that. Is the QEMU wiki considered as "deprecated" (no new 
information there), or more seen as a complement to current manual?

My goal adding this to the documentation was to have a simple (and 
single) "how-to" per platform, instead of trying to cover all the 
possible details and configuration.

Would that be acceptable to add links to the wiki instead of adding all 
information in our documentation?

>> ---
>>   docs/about/build-platforms.rst |   4 +-
>>   docs/devel/build-system.rst    | 100 +++++++++++++++++++++++++++++++++
> 
> I don't think this is the best place to put this information.
> "How do I build from source?" is a question that most beginning
> developers and some end users will have. The information in
> build-system.rst is mostly about the internals of our
> build system and how to modify it, which is a more niche topic.
> 
> I would be inclined to put this in a new file, maybe even
> in docs/about/ rather than docs/devel.
> 

I was not sure, and adding a new file for new developers seems to be the 
best solution. I'll do it.

> thanks
> -- PMM

Thanks
Pierrick Bouvier Nov. 4, 2024, 10:09 p.m. UTC | #6
On 11/4/24 08:08, Michael S. Tsirkin wrote:
> On Mon, Nov 04, 2024 at 03:58:19PM +0000, Peter Maydell wrote:
>> On Thu, 31 Oct 2024 at 04:07, Pierrick Bouvier
>> <pierrick.bouvier@linaro.org> wrote:
>>>
>>> MacOS and Linux are straightforward, but Windows needs a bit more
>>> details.
>>>
>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>
>> We have documentation on the wiki currently about how to
>> build on various platforms:
>>
>> https://wiki.qemu.org/Hosts/Linux
>> https://wiki.qemu.org/Hosts/Mac
>> https://wiki.qemu.org/Hosts/W32
>>
>> I agree that we ought to move this into the main documentation.
>> Some of the information in those wiki pages is probably
>> out of date, but some of it looks like useful extra detail
>> that we could incorporate here.
> 
> Also, as that wiki notes:
> 
> 32 bit Linux target on a 64 bit Linux host would be useful for build bots
> 

IMHO, and regarding my previous message, I don't think adding details 
about cross compilation would help new comers.
Cross compilation is specific, and most of the people who do it know how 
to do it. Especially when setting up a build bot.
In more, we already have a docker container for this use case 
(debian-i686-cross), without needing to play with host machine.

> 
> 
>>> ---
>>>   docs/about/build-platforms.rst |   4 +-
>>>   docs/devel/build-system.rst    | 100 +++++++++++++++++++++++++++++++++
>>
>> I don't think this is the best place to put this information.
>> "How do I build from source?" is a question that most beginning
>> developers and some end users will have. The information in
>> build-system.rst is mostly about the internals of our
>> build system and how to modify it, which is a more niche topic.
>>
>> I would be inclined to put this in a new file, maybe even
>> in docs/about/ rather than docs/devel.
>>
>> thanks
>> -- PMM
>
Peter Maydell Nov. 5, 2024, 10:15 a.m. UTC | #7
On Mon, 4 Nov 2024 at 22:05, Pierrick Bouvier
<pierrick.bouvier@linaro.org> wrote:
>
> On 11/4/24 07:58, Peter Maydell wrote:
> > On Thu, 31 Oct 2024 at 04:07, Pierrick Bouvier
> > <pierrick.bouvier@linaro.org> wrote:
> >>
> >> MacOS and Linux are straightforward, but Windows needs a bit more
> >> details.
> >>
> >> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> >
> > We have documentation on the wiki currently about how to
> > build on various platforms:
> >
> > https://wiki.qemu.org/Hosts/Linux
> > https://wiki.qemu.org/Hosts/Mac
> > https://wiki.qemu.org/Hosts/W32
> >
> > I agree that we ought to move this into the main documentation.
> > Some of the information in those wiki pages is probably
> > out of date, but some of it looks like useful extra detail
> > that we could incorporate here.
> >
>
> I noticed that. Is the QEMU wiki considered as "deprecated" (no new
> information there), or more seen as a complement to current manual?

It's in the usual state of all wikis -- it has a lot of information,
some of which is out of date and some of which is still useful,
and none of which is particularly well organized. Some of it
we should definitely move into our main documentation.

> My goal adding this to the documentation was to have a simple (and
> single) "how-to" per platform, instead of trying to cover all the
> possible details and configuration.
>
> Would that be acceptable to add links to the wiki instead of adding all
> information in our documentation?

I think if we want to document the build process in our
"real" documentation (which we should) then we should
remove the wiki pages (or replace their content with
pointers to the docs). Otherwise we just have two
places with the same information. If we decide that
some of the information on the wiki pages is too stale
or too niche to include that's fine.

thanks
-- PMM
diff mbox series

Patch

diff --git a/docs/about/build-platforms.rst b/docs/about/build-platforms.rst
index 8fd7da140a3..fd1a8cabe36 100644
--- a/docs/about/build-platforms.rst
+++ b/docs/about/build-platforms.rst
@@ -29,6 +29,9 @@  The `Repology`_ site is a useful resource to identify
 currently shipped versions of software in various operating systems,
 though it does not cover all distros listed below.
 
+You can find how to install build dependencies for different systems on the
+:ref:`setup-build-env` page.
+
 Supported host architectures
 ----------------------------
 
@@ -118,7 +121,6 @@  Optional build dependencies
   cross compilation using ``docker`` or ``podman``, or to use pre-built
   binaries distributed with QEMU.
 
-
 Windows
 -------
 
diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst
index d42045a2325..fa5601fed82 100644
--- a/docs/devel/build-system.rst
+++ b/docs/devel/build-system.rst
@@ -595,3 +595,103 @@  Built by Makefile:
   meson.build.  The rules are produced from Meson's JSON description of
   tests (obtained with "meson introspect --tests") through the script
   scripts/mtest2make.py.
+
+.. _setup-build-env:
+
+Setup build environment
+=======================
+
+Linux
+-----
+
+Fedora
+++++++
+
+::
+
+    sudo dnf update && sudo dnf builddep qemu
+
+Debian/Ubuntu
++++++++++++++
+
+You first need to enable `Sources List <https://wiki.debian.org/SourcesList>`_.
+Then, use apt to install dependencies:
+
+::
+
+    sudo apt update && sudo apt build-dep qemu
+
+MacOS
+-----
+
+You first need to install `Homebrew <https://brew.sh/>`_. Then, use it to
+install dependencies:
+
+::
+
+    brew update && brew install $(brew deps --include-build qemu)
+
+Windows
+-------
+
+You first need to install `MSYS2 <https://www.msys2.org/>`_.
+MSYS2 offers `different environments <https://www.msys2.org/docs/environments/>`_.
+x86_64 environments are based on GCC, while aarch64 is based on Clang.
+
+We recommend to use UCRT64 for windows-x86_64 and CLANGARM64 for windows-aarch64
+(only available on windows-aarch64 hosts).
+
+Then, you can open a windows shell, and enter msys2 env using:
+
+::
+
+    c:/msys64/msys2_shell.cmd -defterm -here -no-start -ucrt64
+    # Replace -ucrt64 by -clangarm64 or -mingw64 for other environments.
+
+MSYS2 package manager does not offer a built-in way to install build
+dependencies. You can start with this list of packages using pacman:
+
+Note: Dependencies need to be installed again if you use a different MSYS2
+environment.
+
+::
+
+    # update MSYS2 itself, you need to reopen your shell at the end.
+    pacman -Syu
+    pacman -S \
+        base-devel binutils bison diffutils flex git grep make sed \
+        ${MINGW_PACKAGE_PREFIX}-toolchain \
+        ${MINGW_PACKAGE_PREFIX}-glib2 \
+        ${MINGW_PACKAGE_PREFIX}-gtk3 \
+        ${MINGW_PACKAGE_PREFIX}-libnfs \
+        ${MINGW_PACKAGE_PREFIX}-libssh \
+        ${MINGW_PACKAGE_PREFIX}-ninja \
+        ${MINGW_PACKAGE_PREFIX}-pixman \
+        ${MINGW_PACKAGE_PREFIX}-pkgconf \
+        ${MINGW_PACKAGE_PREFIX}-python \
+        ${MINGW_PACKAGE_PREFIX}-SDL2 \
+        ${MINGW_PACKAGE_PREFIX}-zstd
+
+If you want to install all dependencies, it's possible to use recipe used to
+build QEMU in MSYS2 itself.
+
+::
+
+    pacman -S wget
+    wget https://raw.githubusercontent.com/msys2/MINGW-packages/refs/heads/master/mingw-w64-qemu/PKGBUILD
+    # Some packages may be missing for your environment, installation will still
+    # be done though.
+    makepkg -s PKGBUILD || true
+
+Build on windows-aarch64
+++++++++++++++++++++++++
+
+When trying to cross compile meson for x86_64 using UCRT64 or MINGW64 env,
+configure will run into an error because the cpu detected is not correct.
+
+Meson detects x86_64 processes emulated, so you need to manually set the cpu,
+and force a cross compilation (with empty prefix).
+
+::
+
+    ./configure --cpu=x86_64 --cross-prefix=