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 |
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
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
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=
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(-)