summaryrefslogtreecommitdiff
path: root/content/posts/2018-08-01-dxvk-gentoo.md
blob: d0aec936e49867387d5289e9b0d00ca711f4923a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
layout: post
title: Building DXVK's DLLs on Gentoo
tags:
  - wine
  - dxvk
  - gentoo

TocOpen: true
ShowToc: true
---

By far the easiest way to do it is on a Debian chroot, but that ain't as fun as
building your own toolchain and do it on Gentoo.

<hr>

# Dependencies

According to the official documentation:

- wine 3.10 or newer
- Meson build system (at least version 0.43)
- MinGW64 compiler and headers (requires threading support)
- glslang front end and validator

All but MinGW you can install directly from portage:

```
emerge virtual/wine dev-util/meson dev-util/glslang
```

## MinGW64

MinGW with POSIX threads is required, problem is, by default `crossdev` will
compile GCC with Win32 threads instead of POSIX. Start by creating your
toolchain with `crossdev`, tuple for x86 is `i686-w64-mingw32` and
`x86_64-w64-mingw32` for x64:

```
crossdev -t i686-w64-mingw32
crossdev -t x86_64-w64-mingw32
```

Fix GCC by enabling POSIX threads:

```
mkdir /etc/portage/{env,package.env}
echo 'EXTRA_ECONF="--enable-threads=posix"' > /etc/portage/env/mingw32_posix_threads
echo -e 'cross-i686-w64-mingw32/gcc mingw32_posix_threads\ncross-x86_64-w64-mingw32/gcc mingw32_posix_threads' > /etc/portage/package.env/mingw32_posix_threads
```

Then add the `libraries` `USE` to `mingw64-runtime`:

```
cross-i686-w64-mingw32/mingw64-runtime libraries
cross-x86_64-w64-mingw32/mingw64-runtime libraries
```

Rebuild `mingw64-runtime` and `gcc`. Order matters, `mingw64-runtime` with
`libraries` provides `pthreads.h` and other stuff that's required to compile GCC
with the POSIX thread model.

```
emerge -1 cross-i686-w64-mingw32/mingw64-runtime cross-x86_64-w64-mingw32/mingw64-runtime
emerge -1 cross-i686-w64-mingw32/gcc cross-x86_64-w64-mingw32/gcc
```

Depending on the runtime version, libraries may end up in the wrong place (see
bug #653246), if that's the case sysmlink those and then rebuild GCC:

```sh
ln -s /usr/x86_64-w64-mingw32/usr/lib64/{libmangle.a,libpthread.a,libpthread.dll.a,libwinpthread.a,libwinpthread.dll.a,libwinpthread.la} \
    /usr/x86_64-w64-mingw32/usr/lib/
```

Final result should be:

```
i686-w64-mingw32-gcc -v

... Thread model: posix ...

x86_64-w64-mingw32-gcc -v

... Thread model: posix ...
```

# Crosscompiling DLLs

```
git clone https://github.com/doitsujin/dxvk.git
cd dxvk

### 32-bit build. For 64-bit builds, replace

### build-win32.txt with build-win64.txt

### build.w32 with build.w64

meson --cross-file build-win32.txt --prefix /some/install/prefix build.w32
cd build.w32/
meson configure -Dbuildtype=release
ninja
ninja install
```

```
ls /some/install/prefix/bin
d3d11.dll dxgi.dll setup_dxvk.sh
```

These are the toolchains I used.

```
cross-i686-w64-mingw32/binutils-2.30-r3
cross-i686-w64-mingw32/gcc-7.3.0-r3
cross-i686-w64-mingw32/mingw64-runtime-5.0.4
cross-x86_64-w64-mingw32/binutils-2.30-r3
cross-x86_64-w64-mingw32/gcc-7.3.0-r3

### symlinks from ...lib64/ -> ...lib/ required! see bug #653246

cross-x86_64-w64-mingw32/mingw64-runtime-5.0.4
```