From bb307a0df4e8510a8bd2cb467e856d2e45ab9ed6 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Thu, 28 Nov 2024 07:09:20 +0000 Subject: [PATCH] Update Building a MinGW WoW64 Wine with a custom vkd3d build --- ...GW-WoW64-Wine-with-a-custom-vkd3d-build.md | 97 ++++++++----------- 1 file changed, 38 insertions(+), 59 deletions(-) diff --git a/Building-a-MinGW-WoW64-Wine-with-a-custom-vkd3d-build.md b/Building-a-MinGW-WoW64-Wine-with-a-custom-vkd3d-build.md index e387e27..636209a 100644 --- a/Building-a-MinGW-WoW64-Wine-with-a-custom-vkd3d-build.md +++ b/Building-a-MinGW-WoW64-Wine-with-a-custom-vkd3d-build.md @@ -1,15 +1,13 @@ As of version 7.4, Wine comes with a bundled version of vkd3d. However, if you want to use a more modern version of vkd3d, apply -certain patches to it, or test fixes of your own, you will need Wine to -work with a custom version of vkd3d. +certain patches to it, or test fixes of your own, you will need Wine to work with a custom version of vkd3d. For this purpose, it is necessary to build both projects and link them correctly. Compiling a Windows on Windows (WoW) version of Wine, so that it -supports both 32-bits and 64-bits Windows applications – which is often -desired – adds a layer of complexity to the build process. +supports both 32-bits and 64-bits Windows applications – which is often desired – adds a layer of complexity to the build process. Furthermore, you may want to use MinGW to cross-compile the Wine executables and DLLs in the Windows PE format. This is because various @@ -22,19 +20,17 @@ This guide aims to help you through that process. ## Install Wine dependencies First, install the dependencies listed in the [Building -Wine](https://gitlab.winehq.org/wine/wine/-/wikis/Building-Wine#satisfying-build-dependencies) article. If you system doesn't have multi-lib support you will probably need to work with containers, virtual machines, of chroot as suggested. +Wine](https://gitlab.winehq.org/wine/wine/-/wikis/Building-Wine#satisfying-build-dependencies) article. If you system doesn't have multi-lib support you will probably need to work with containers, virtual machines, or chroot as suggested. -Remember to install the `:i386` version of the required packages too (if -your system has multi-lib support). +Remember to install the `:i386` version of the required packages too (if your system has multi-lib support). -The **mingw** and **vulkan** packages are of particular importance. +The **mingw** and **vulkan** packages are important. It is also recommended that you install `ccache`, as it may save us a considerable amount of time during the builds. If you have a system-wide installation of vkd3d, it may be good to -uninstall it using `make uninstall`. To ensure that the correct version -of vkd3d is linked in this tutorial. +uninstall it using `make uninstall`. To ensure that the correct version of vkd3d is linked in this tutorial. ## Directory organization @@ -78,8 +74,7 @@ patches to these repositories. If the distribution provides a recent enough version (3.21 or later as of this writing) of WIDL, we can skip this step. On Debian that's -provided by the `mingw-w64-tools` package. We can also skip this step if -we already have 64-bit Wine available and built. +provided by the `mingw-w64-tools` package. We can also skip this step if we already have 64-bit Wine available and built. Vkd3d uses WIDL to compile its IDL files, and if the distribution doesn't provide a package, we'll have to build it from the Wine @@ -98,9 +93,7 @@ $ ../wine-git/configure --enable-win64 CC='ccache gcc' x86_64_CC='ccache x86_64- ``` Note that we use `x86_64_CC` to indicate the compiler used for -cross-compilation, in this case we need the 64-bit mingw32 compiler. We -prepend `ccache` which works as a wrapper for the compiler. The same is -done for the regular C compiler, `gcc`, passed with the `CC` variable. +cross-compilation, in this case we need the 64-bit mingw32 compiler. We prepend `ccache` which works as a wrapper for the compiler. The same is done for the regular C compiler, `gcc`, passed with the `CC` variable. Note that to know about other parameters for the `configure` script we can use: @@ -113,11 +106,10 @@ Also, if something from the configure command fails, it is useful to search in `config.log` for the line that contains the pertinent error, and the lines before and after it. -Once the configure script has finished, we use `make tools/widl/widl` to -only compile WIDL. We can pass `-j` to use threads. +Once the configure script has finished, we use `make tools/widl/widl` to only compile WIDL. ``` sh -$ make -j8 tools/widl/widl +$ make tools/widl/widl ``` ## Build a 64-bit vkd3d installation @@ -131,8 +123,7 @@ Alternatively, you can get them from the official [SPIRV-Headers](https://github.com/KhronosGroup/SPIRV-Headers) repositories. -Another alternative is to copy them from your distribution. Usually the -host headers will be installed in `/usr/include/vulkan/` and +Another alternative is to copy them from your distribution. Usually the host headers will be installed in `/usr/include/vulkan/` and `/usr/include/spirv/`. Assuming you downloaded and extracted the SDK, move it to the common @@ -143,7 +134,7 @@ $ mv $HOME/wine-dirs/vulkan-sdk ``` You must change the first argument of the `mv` command depending on -where you downloaded and extracted the SDK. e.g. +where you downloaded and extracted the SDK, including the version number. e.g. `~/Downloads/vulkansdk-linux-x86_64-1.3.204.1/1.3.204.1`. We have to run `autogen.sh` in `vkd3d-git` to generate vkd3d's @@ -185,17 +176,11 @@ $ ../vkd3d-git/configure \ WIDL. When using the distribution's WIDL, `configure` should generally be able to find WIDL on its own and this variable can be omitted; if not, point it to the location of the distribution's WIDL. -- `SONAME_LIBVULKAN` indicates the name of the Vulkan library to load at - run-time. +- `SONAME_LIBVULKAN` indicates the name of the Vulkan library to load at run-time. - We use `CPPFLAGS` so that the compiler knows to search in the - `vulkan-sdk` folder for the vulkan headers (`-I` flag). Note that you - cannot pass `-I/usr/include/` here to use the host headers; this will - result in incorrect detection of headers like `dlfcn.h`. You will need - to copy or link host headers to a separate directory. + `vulkan-sdk` folder for the vulkan headers (`-I` flag). Note that you cannot pass `-I/usr/include/` here to use the host headers; this will result in incorrect detection of headers like `dlfcn.h`. You will need to copy or link host headers to a separate directory. - We use `LDFLAGS="-static-libgcc"` because MinGW gcc depends on - `libgcc_s_sjlj-1.dll`; this links a static version. Alternatively, you - can add the correct path to `--with-system-dllpath` as described - below. + `libgcc_s_sjlj-1.dll`; this links a static version. Then we run @@ -203,7 +188,7 @@ Then we run $ make ``` -Append `-j$(nproc)` to parallelize. +You can append `-jN` to parallelize using `N` jobs. And if the build succeeds, then we run @@ -213,6 +198,8 @@ $ make install to install 64-bit vkd3d in `$HOME/wine-dirs/vkd3d64-prefix`. +**NOTE:** If the build fails because of missing headers, it might be that your MinGW version is too old. You can try disabling some packages. For instance if `#include ` fails, you can pass `--without-ncurses` to the configure script and compile again. + ## Build 64-bit wine Now with the 64-bit `vkd3d` installation, we can compile a 64-bit Wine @@ -234,24 +221,14 @@ will also need to include the vulkan headers: ``` sh $ cd wine64 $ ../wine-git/configure --enable-win64 \ - CC='ccache gcc' x86_64_CC='ccache x86_64-w64-mingw32-gcc' \ - --with-system-dllpath="$HOME/wine-dirs/vkd3d64-prefix/bin:" \ + CC='ccache gcc' x86_64_CC='x86_64-w64-mingw32-gcc' \ + --with-system-dllpath="$HOME/wine-dirs/vkd3d64-prefix/bin" \ VKD3D_PE_CFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include -I$HOME/wine-dirs/vkd3d64-prefix/include/vkd3d" \ - VKD3D_PE_LIBS="-L$HOME/wine-dirs/vkd3d64-prefix/lib -lvkd3d -lvkd3d-shader" + VKD3D_PE_LIBS="-L$HOME/wine-dirs/vkd3d64-prefix/lib -lvkd3d.dll -lvkd3d-shader.dll" ``` -- We use `--with-system-dllpath` so that wine knows to search our vkd3d - prefix for the vkd3d DLLs. If you did not use `-static-libgcc` to - compile vkd3d, you should also add the libgcc path here. Depending on - distribution it may be `/usr/x86_64-w64-mingw32/bin/` (Arch), - `/usr/x86_64-w64-mingw32/sys-root/mingw/bin/` (Fedora), or - `/usr/lib/gcc/x86_64-w64-mingw32/##-win32/`, where `##` depends on the - gcc version (Debian). - - Notice that multiple paths should be separated with a colon. -- We set `VKD3D_PE_CFLAGS` and `VKD3D_PE_LIBS` to indicate that we will - use a custom version of vkd3d. We use `VKD3D_PE_CFLAGS` to include the - vulkan headers and the vkd3d headers and `VKD3D_PE_LIBS` to load - vkd3d's dynamic libraries. +- We use `--with-system-dllpath` so that wine knows to search our vkd3d prefix for the vkd3d DLLs. +- We set `VKD3D_PE_CFLAGS` and `VKD3D_PE_LIBS` to indicate that we will use a custom version of vkd3d. We also use `VKD3D_PE_CFLAGS` to include the Vulkan headers and the vkd3d headers and `VKD3D_PE_LIBS` to load vkd3d's libraries. - Alternatively, you can install MinGW pkg-config, and pass `PKG_CONFIG_PATH="$HOME/wine-dirs/vkd3d64-prefix/lib/pkgconfig"`. @@ -261,18 +238,16 @@ If you get the following message around the last lines: configure: libvkd3d 64-bit MinGW development files not found; using bundled version. ``` -Wine was **not** correctly linked to your custom version of vkd3d. Check -the `config.log`. +Wine was **not** correctly linked to your custom version of vkd3d. Check the `config.log`. -Clean ntdll to make sure that the new system DLL path is picked up, and -then rebuild wine: +Clean ntdll to make sure that the new system DLL path is picked up, and then rebuild wine: ``` sh $ make dlls/ntdll/clean $ make ``` -Append "-j\$(nproc)" to make commands to parallelize. +Remember that you can append `-jN` to these `make` commands to parallelize using `N` jobs. ## Build a 32-bit vkd3d installation @@ -292,8 +267,7 @@ $ ../vkd3d-git/configure \ LDFLAGS="-static-libgcc" ``` -- We now use `--host=i686-w64-mingw32` to indicate that we will use the - 32-bit MinGW compiler. +- We now use `--host=i686-w64-mingw32` to indicate that we will use the 32-bit MinGW compiler. - We are changing the prefix so that this 32-bit vkd3d is installed in the `vkd3d32-prefix` folder instead of `vkd3d64-prefix`. - We're using 64-bit WIDL like before; this is fine. @@ -317,15 +291,13 @@ $ mkdir wine32 ``` sh $ cd wine32 -$ ../wine-git/configure --with-wine64=../wine64/ \ +$ ../wine-git/configure --with-wine64=../wine64 \ CC='ccache gcc' i386_CC='ccache i686-w64-mingw32-gcc' \ - --with-system-dllpath="$HOME/wine-dirs/vkd3d32-prefix/bin:" \ + --with-system-dllpath="$HOME/wine-dirs/vkd3d32-prefix/bin" \ VKD3D_PE_CFLAGS="-I$HOME/wine-dirs/vulkan-sdk/x86_64/include -I$HOME/wine-dirs/vkd3d32-prefix/include/vkd3d" \ - VKD3D_PE_LIBS="-L$HOME/wine-dirs/vkd3d32-prefix/lib -lvkd3d -lvkd3d-shader" + VKD3D_PE_LIBS="-L$HOME/wine-dirs/vkd3d32-prefix/lib -lvkd3d.dll -lvkd3d-shader.dll" ``` - -- We now point `--with-system-dllpath` and `VKD3D_PE_LIBS` to the - directories inside `vkd3d32-prefix`. +- We now point `--with-system-dllpath`, `VKD3D_PE_CFLAGS` and `VKD3D_PE_LIBS` to the directories inside `vkd3d32-prefix`. As above, clean ntdll to make sure that the new system DLL path is picked up, and then rebuild wine: @@ -335,6 +307,13 @@ $ make dlls/ntdll/clean $ make ``` +You should now be able to execute wine: + +``` +$ $HOME/wine-dirs/wine64/wine --version +wine-9.22-48-g33c16a81253 +``` + # Updating your build If you want to update either wine or vkd3d's source code, we can execute