upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/linux.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/linux.md')
-rw-r--r--docs/linux.md114
1 files changed, 114 insertions, 0 deletions
diff --git a/docs/linux.md b/docs/linux.md
new file mode 100644
index 000000000..e7ca27455
--- /dev/null
+++ b/docs/linux.md
@@ -0,0 +1,114 @@
1# Linux
2
3What a Linux user (x86-64, a Vulkan GPU) can do today, from one page: the build of the shaders and assets runs
4natively, the Vulkan test tools build natively with GCC or Clang, and the loader (`gta6rt`) is a Windows program that
5runs under Wine or Proton. Nothing is playable on any platform yet (README, *Project status*).
6
7The package names below were checked on Ubuntu 26.04 LTS. Other distributions have the same tools under their own
8names; the build lists anything it can't find before it starts.
9
10## What runs where
11
12| Piece | On Linux | How it is checked |
13|---|---|---|
14| `make_game.py`: check, shaders, assets, pipelines | Native | CI (`stdlib-tests-linux`, `translator-tests`, `semantic-tests`) |
15| `Build.sh`, `Mods.sh` | Native (`/bin/sh`) | `tests/test_shell_launchers.py`, in the standard-library loop of `stdlib-tests-linux` |
16| Shader translator, its tests and the GPU test tools (`vk_harness`, `vk_pipeline_check`, ...) | Native, GCC or Clang | CI (`linux-gpu-tools`: GCC, tests on llvmpipe); Clang builds them too, but no CI job uses it yet |
17| `rpf9dump` (asset export) | Native, .NET 8 or newer | CI builds it on Windows only (the `check` job) |
18| `gta6rt`, its shims and their tests | Windows program, under Wine or Proton | Cross-built with clang-cl and xwin; CI runs the Windows build under Wine on pushes to `main` |
19
20## Build the port
21
22Install the prerequisites (Ubuntu 26.04; the comment says what each is for):
23
24```sh
25sudo apt install git python3 \
26 llvm-21 spirv-tools \
27 dotnet-sdk-10.0 \
28 cmake ninja-build g++ libvulkan-dev \
29 ffmpeg zenity python3-tk
30# git, python3 the clone and make_game.py (Python 3.12 or newer)
31# llvm-21, spirv-tools the shaders stage: llvm-mc with the AMDGPU target, spirv-as and spirv-val
32# dotnet-sdk-10.0 the assets stage builds rpf9dump; Ubuntu 26.04 packages no .NET 8 SDK, and 10 builds the
33# net8.0 project through global.json's roll-forward
34# cmake ... libvulkan-dev the pipelines stage builds vk_pipeline_check
35# ffmpeg optional: XMA2 audio and --wav
36# zenity, python3-tk optional: the --pick folder dialog and the mod manager window
37```
38
39Then, with your own copy of the game already readable on disk:
40
41```sh
42git clone --recursive https://github.com/ubiquitarianism/leonida
43cd leonida
44./Build.sh --find # list the copies found: the home folder, Downloads, Documents, /mnt, /media/<user>, ...
45./Build.sh --check # check your copy, build nothing
46./Build.sh # build into ~/Documents/Leonida
47```
48
49`./Build.sh` is `python3 -I make_game.py` with the newest Python 3.12+ it finds, so every `make_game.py` option in
50the README works with it (`--game`, `--out`, `--work`, `--stages`, ...). Without the cross-build tools below, the
51default stages leave `runtime` out (`check,shaders,assets,pipelines`).
52
53Notes:
54
55- **llvm-mc**: Debian and Ubuntu's `llvm-21` installs it only as `llvm-mc-21` and `/usr/lib/llvm-21/bin/llvm-mc`.
56 With `LLVM_MC` unset the tools use the plain `llvm-mc` when it is on `PATH` and otherwise the newest of those
57 versioned names (`tools/mc_command.py`). Set `LLVM_MC` to choose another one.
58- **File names are case-sensitive.** The build opens the package's files by their exact names
59 (`MicrosoftGame.Config`, `Catalog000.bin`, ...). A copy whose names changed case on the way is reported with the
60 name it found and the one it needs; nothing is renamed for you.
61- **Mods**: `./Mods.sh` opens the mod manager window ([modding.md](modding.md)); `python3 -I tools/leonida_mods.py`
62 is the same manager on the command line.
63
64## The runtime, under Wine or Proton
65
66`gta6rt` is a Windows program. To build it on Linux, add the LLVM cross tools and an MSVC CRT and Windows SDK laid
67out by [xwin](https://github.com/Jake-Shadle/xwin) (running xwin downloads them from Microsoft and means accepting
68Microsoft's licence):
69
70```sh
71sudo apt install clang-21 lld-21 llvm-21 wine
72xwin --accept-license --sdk-version 10.0.26100 splat --use-winsysroot-style --preserve-ms-arch-notation \
73 --output ~/.local/share/xwin-sdk
74./Build.sh --stages runtime
75```
76
77On Ubuntu 24.04, `clang-cl-<N>` is in `clang-tools-<N>` instead ([testing.md](testing.md#known-problems)).
78`make_game.py` finds the five tools under one version suffix (`clang-cl-21`, `lld-link-21`, `llvm-lib-21`,
79`llvm-rc-21`, `llvm-mt-21`) or their plain names. Without the SDK it lists what is missing before any work starts.
80`--runtime-build <folder>` takes a Windows build made elsewhere instead, such as the `runtime-windows` artifact of the
81Runtime workflow. The stage writes `<out>/gta6rt.sh`, which starts `gta6rt.exe` with `wine` or the Wine named by `WINE`
82(for Proton, its `files/bin/wine`); README, *Running the loader on Linux*, has the commands.
83[testing.md](testing.md#the-windows-runtime-on-linux-under-wine-or-proton) has the test runs under Wine and Proton
84and what fails there.
85
86### Why there is no native Linux `gta6rt`
87
88A native (ELF) loader is not a matter of build flags:
89
90- The loader shims only the console's own modules and a few Win32 entry points it has to own (GDK, XMem,
91 `d3d12_xs`, the library loader, the process and file-system shims). Every other import binds to the host's Windows
92 DLLs unchanged (`runtime/src/pe_loader.cpp`; [runtime_imports.md](runtime_imports.md): `XboxBvhBuilder.dll`
93 alone binds 4 imports to shims and 53 to the host). On Linux, those host DLLs are what Wine provides.
94- The mapped code uses the Windows x64 calling convention and the Windows thread and exception model: the loader
95 registers unwind tables with `RtlAddFunctionTable`, keeps a module TLS slot through `gta6rt_tls_host.dll`, and
96 `main.cpp` installs a vectored exception handler. The shims are written against `windows.h`.
97
98A Linux-native host would have to reimplement each of those Win32 APIs, which is the work Wine already does, so the
99supported way is the Windows build under Wine or Proton with the D3D12 layer on native Vulkan. What does build
100natively is everything that doesn't touch Win32: the Vulkan tools and the portable runtime pieces with their tests
101(`ctest` on a Linux build runs them, including the root-signature model and the host CPU check).
102
103## Build and test without the game
104
105```sh
106cmake -S runtime -B runtime/build/linux -G Ninja # CC=clang CXX=clang++ for Clang
107cmake --build runtime/build/linux --parallel
108ctest --test-dir runtime/build/linux --output-on-failure # Vulkan tests run on Mesa's lavapipe without a GPU
109python3 -I scripts/run_semantic_tests.py tests/semantic # translator suite
110python3 -I tests/test_<name>.py # one standard-library test
111```
112
113[testing.md](testing.md) covers the GPU tests (`scripts/run_gpu_tests.py`), running them on llvmpipe, and choosing
114the GPU.