Skip to content

Native Zig Tooling

buntatoes edited this page Nov 29, 2026 · 2 revisions

Native Zig Tooling

All original Pisco utilities live in zig/src/, are built from the root build.zig, and are licensed under Apache-2.0. They eliminate Python from both the runtime environment and the build/code-generation pipeline while targeting glibc 2.31 (-Dglibc-compat=true) for Steam Linux Runtime compatibility.


Binary Overview

Binary Source Replaces Purpose
pisco (proton symlink) zig/src/pisco/ proton + filelock.py Steam Play launcher, prefix manager, Bitters/GStreamer wiring, GPU defaults, quirk engine, and Wayland toggle
default_pfx zig/src/default_pfx.zig default_pfx.py Default prefix bootstrap (vodkaboot), builtin & Bitters PE symlink setup, and build-machine registry sanitization
steampipe_fixups zig/src/steampipe_fixups.zig + common/steampipe.zig steampipe_fixups.py SteamPipe deployment manifest capture (process) and permission/empty-dir restoration (restore)
font_merge zig/src/font_merge.zig fonts/scripts/merge.py Pure-Zig TrueType (SFNT) subsetter, multi-font merger, composite glyph remapper, and name renamer
symstore zig/src/symstore.zig + common/pe.zig symstore/symstore.c Microsoft SymSrv PE symbol store indexer with zero external C header dependencies
steam.exe zig/src/steam_helper/main.zig steam_helper/steam.c Cross-compiled Win32/Win64/ARM64 PE stub (x86_64, i386, aarch64)
make_blank_ptna zig/src/make_blank_ptna.zig media/make_blank_ptna.c RFC 7845 .ptna Opus audio stream generator (links libopus)
make_openxr zig/src/generators/make_openxr.zig + xml.zig vodkaopenxr/make_openxr Khronos OpenXR xr.xml parser and C header/thunk generator
gen_lsteamclient zig/src/generators/gen_lsteamclient.zig + clang_ffi.zig lsteamclient/gen_wrapper.py Dynamic libclang Steamworks C++/ABI wrapper generator (u32, u64, w32, w64)
gen_vrclient zig/src/generators/gen_vrclient.zig + clang_ffi.zig vrclient_x64/gen_wrapper.py Dynamic libclang OpenVR C++/ABI wrapper and flatapi.c assembly thunk generator

pisco Launcher (zig/src/pisco/)

The native pisco ELF executable is invoked by Steam via toolmanifest_*.vdf ("/pisco %verb%") and supports every Steam Play verb:

Verb Behavior
run Configures game/Steam drives, initializes or migrates the prefix, and launches the target executable
waitforexitandrun Waits for vodkaserver -w to exit cleanly before launching
runinprefix Executes an arbitrary command inside the game's prefix without modifying tracked prefix files
destroyprefix Removes tracked files from the compatibility prefix
getcompatpath Converts a Linux host path to a Windows path via vodkapath -w
getnativepath Converts a Windows path to a Linux host path via vodkapath

Launcher Modules

  • main.zig: Core session lifecycle, CURRENT_PREFIX_VERSION (11.0-100) tracking, PISCO_* -> PROTON_* env normalization, PROTON_ENABLE_WAYLAND handling with X11 fallback, VODKADLLPATH and VODKADLLOVERRIDES assembly for Bitters / vkd3d-proton / vodkagfx, GST_PLUGIN_SYSTEM_PATH_1_0 host plugin path discovery (PISCO_NO_HOST_GST_PLUGINS opt-out), PROTON_LOG initialization, Bitters/vkd3d-proton shader cache wiring (STEAM_COMPAT_SHADER_PATH), optional external NVAPI detection (only enabling overrides if DLLs exist on disk), and ARM64 (FEX) setup.
  • gpu_vendors.zig: Scans /sys/bus/pci/devices for display controllers, selects the primary discrete/verified GPU, classifies AMD (verified), NVIDIA RTX 2000+ (experimental), Intel Arc / Xe Gen12+ (experimental), and legacy GPUs (unsupported_legacy), and applies safe user-overridable Wayland/Vulkan environment defaults.
  • settings.zig: Standalone parser supporting both user_settings.json and legacy user_settings.py dictionary syntax (including # comments, single/double quotes, trailing commas, and ignoring _-prefixed comment keys).
  • reg.zig: Atomic Vodka .reg hive key/value reader and replacer (getReplaceRegValue) using .new/.old rename swaps for prefix migrations (e.g., MachineGuid preservation).
  • nvidia.zig: Dynamically dlopens libGLX_nvidia.so.0 and inspects RTLD_DI_LINKMAP to locate the host NVIDIA driver's nvngx.dll directory and export NVIDIA_VODKA_DLL_DIR.
  • common/filelock.zig: Re-entrant POSIX flock(LOCK_EX | LOCK_NB) advisory file lock matching filelock.py (50 ms poll interval; never unlinks the lockfile on release to avoid races).

Per-Game Quirk Tables (zig/src/pisco/quirks.zig)

quirks.zig encodes structured, compile-time per-AppID and per-GameID compatibility workarounds tracked from upstream Proton 11:

Table Effect Examples
nomfdxgiman_appids Sets VODKA_DO_NOT_CREATE_DXGI_DEVICE_MANAGER=1 FUSER, DEVIATOR
noopwr_appids Sets VODKA_DISABLE_VULKAN_OPWR=1 Sea of Thieves, Halo MCC/Infinite, Forza Horizon 4/5, Age of Empires DE/II/III/IV, Warframe, Wuthering Waves
noforcelgadd_appids Disables VODKA_LARGE_ADDRESS_AWARE Act of War: Direct Action, Sword and Fairy 4, Metal Fatigue
heapdelayfree_appids Sets VODKA_HEAP_DELAY_FREE=1 Call of Duty: Black Ops II (MP/Zombies), WITCH ON THE HOLY NIGHT
heapzeromemory_appids Sets VODKA_HEAP_ZERO_MEMORY=1 Call of Juarez: Bound in Blood, Helldivers 2, Sonic Colors: Ultimate
heaptopdown_appids Sets VODKA_HEAP_TOP_DOWN=1 Crazy Taxi, MySims Kingdom
nofsync_appids Disables VODKA_FSYNC and VODKA_ESYNC Call of Duty 2, Disaster Report 4, Flatout 3, Disgaea 4 Complete+
disablenvapi_appids / disablenvapi_non_nvidia_appids Disables optional external NVAPI globally or on non-NVIDIA GPUs Divinity: Original Sin 2, Guardians of the Galaxy, The Witcher 3 Remastered, Alan Wake, The Finals
hidenvgpu_appids / forcenvapi_appids / hidevggpu_appids / hideintelgpu_appids / hideapu_appids GPU vendor/APU visibility workarounds The Crew Motorfest, Tony Hawk's Pro Skater 1+2, Serious Sam 4, Jusant, Deathloop
fnad3d11_appids Sets FNA3D_FORCE_DRIVER=D3D11 Duck Game, Eterium, Zombie Estate 2
noxalia_compat_appids Sets PROTON_USE_XALIA=0 Deadly Premonition, Final Fantasy VII / VIII Remastered, Wuthering Waves
nohardwarescheduling_compat_appids Sets VODKA_DISABLE_HARDWARE_SCHEDULING=1 No Man's Sky, Portal with RTX
default_cpu_limits Caps exposed core count (1–30 or "P" for P-cores via VODKA_CPU_TOPOLOGY) Far Cry 2/4, The Witcher 2, Dawn of War II, Prototype 1/2, DIRT 5
openssl_ia32cap_gameids Sets OPENSSL_ia32cap=~0x20000000 57 titles affected by OpenSSL SHA-NI crashes
ddraw_native_gameids Sets ddraw=n,b DLL override Arcanum, Resident Evil (1996/1998), Dino Crisis, Breath of Fire IV
limit_res_16_gameids / limit_res_32_gameids Caps enumerated display modes (PROTON_LIMIT_RESOLUTIONS) SpellForce, NieR: Automata, Sekiro, Dark Souls III
spoof_steaminput_gameids Sets PROTON_SPOOF_STEAMINPUT_VIDPID=1 Far Cry New Dawn, Binding of Isaac: Rebirth, Split/Second
wow64_gameids / limit_addr_space_appids / cod_steam_exe_gameids WoW64 mode, address-space capping, and CoD steam.exe handling CoD: Black Ops 3, CoD: Black Ops Cold War, Undecember
default_builtin_dll_copy Comma-separated builtin DLL copy list (PROTON_DLL_COPY default) d3dcompiler_*.dll, xaudio*.dll, xinput*.dll, CRT/STL DLLs, ntdll.dll, vulkan-1.dll

Build, Prefix & Packaging Tools

default_pfx (zig/src/default_pfx.zig)

Invoked during make (default_pfx <pfx_dir> <dist_dir> <arm64_flag>):

  1. Runs vodkaboot (or vodka vodkaboot) and vodkaserver -w into the staging prefix with VODKADEBUG=-all and VODKADLLPATH prepending vodka/bitters.
  2. Walks the prefix using common/pe.zig (isVodkaBuiltinDll and dllBitness), replacing builtin PE DLL copies with relative symlinks into lib/vodka/{i386,x86_64,aarch64}-windows/ (skipping amd_ags_x64.dll, comctl32.dll, and comctl32_v6.dll).
  3. Symlinks Bitters multi-arch PE DLLs (dxgi.dll, d3d11.dll, d3d10core.dll, d3d9.dll, d3d8.dll) into drive_c/windows/system32 and drive_c/windows/syswow64.
  4. Cleans dosdevices/*: drive links.
  5. Sanitizes user.reg and system.reg by stripping build-machine drive-qualified font entries (Fonts, External Fonts) and any Z:\<dist_dir> build-machine installer source paths (such as vodka-mono MSI InstallSource).

steampipe_fixups (zig/src/steampipe_fixups.zig)

Preserves metadata that SteamPipe strips during depot uploads:

  • steampipe_fixups process <dir> [manifest] — Walks <dir>, records sorted empty_dirs and read-only no_write_paths (files lacking S_IWUSR), assigns a random id, and writes steampipe_fixups.json.
  • steampipe_fixups restore <dir> [manifest] — Recreates empty directories and strips write permission bits (S_IWUSR | S_IWGRP | S_IWOTH) on listed files. Also invoked automatically by pisco at startup when steampipe_fixups.json is present.

font_merge (zig/src/font_merge.zig)

Pure-Zig SFNT TrueType font processor replacing fonts/scripts/merge.py (zero fontTools dependency):

  • Parses head, hhea, maxp, hmtx, loca, glyf, cmap, OS/2, and post tables directly.
  • Subsets codepoint ranges from range definition files (fonts/ranges/{micross,nirmala,arial,lucon}), merges multiple Noto fallback fonts, remaps composite glyph component indices, and rewrites the name table to produce micross.ttf, nirmala.ttf, alt/arial.ttf, and lucon.ttf.

symstore (zig/src/symstore.zig)

Native Windows symbol store indexer implementing the Microsoft SymSrv <filename>/<TimeDateStamp><SizeOfImage>/<filename> layout:

  • Uses common/pe.zig (parsePeSrvInfo) to extract TimeDateStamp, SizeOfImage, and the COM descriptor directory (.NET managed detection) directly from PE32 / PE32+ headers — zero external C headers and no MAX_PATH limits.
  • Supports -v, --skip-managed, --lower-case, and --upper-case.

steam.exe (zig/src/steam_helper/main.zig)

Pure-Zig Windows PE stub cross-compiled directly by build.zig to x86_64-windows, i386-windows, and aarch64-windows (linking standard Win32 import libraries kernel32, user32, advapi32, shlwapi, shell32, msi, ole32):

  • Handles Steam client registry/DRM IPC, steam:// URL forwarding, PROTON_WAIT_ATTACH debugger pauses, EA Desktop workarounds, and child game process launching without MinGW or external C headers.

make_blank_ptna (zig/src/make_blank_ptna.zig)

Links libopus to emit RFC 7845 Section 5.1 OpusHead + framed .ptna Proton Audio streams (--audible emits a 400 Hz tone; default emits 10 ms of 48 kHz mono silence).


Build-Time Code Generators (zig/src/generators/)

make_openxr (make_openxr.zig + xml.zig)

  • Pure-Zig Khronos OpenXR xr.xml (1.1.63) parser and code generator with zero external dependencies.
  • Emits vodkaopenxr.h, vodkaopenxr.json, openxr_thunks.h, openxr_thunks.c, loader_thunks.h, and loader_thunks.c, respecting platform filters (macos, metal, wayland, xlib) and manual Unix/loader thunk lists.

gen_lsteamclient (gen_lsteamclient.zig + clang_ffi.zig)

  • Loads libclang dynamically at runtime via dlopen (clang_ffi.zig) to avoid compile-time LLVM version pinning.
  • Parses user-supplied Steamworks SDK headers (--sdk-dir, not bundled in the repository) across versions 099u–165 and all four ABIs (u32, u64, w32, w64), emitting cpp<Class>_<Version>.cpp, win<Class>.c, steamclient_generated.{h,c}, steamclient_structs_generated.h, unix_private_generated.h, and unixlib_generated.{h,cpp}.

gen_vrclient (gen_vrclient.zig + clang_ffi.zig)

  • Uses the same dynamic libclang FFI across OpenVR SDK v0.9.0–v2.15.6 and all four ABIs (u32, u64, w32, w64).
  • Emits cpp<Class>_<Version>.cpp, win<Class>.c (vtable + FnTable flat C constructors/destructors), flatapi.c (x86/x86_64 assembly call thunks), vrclient_generated.{h,c}, vrclient_structs_generated.h, unix_private_generated.h, and unixlib_generated.{h,cpp}.

Running Unit Tests

All major Zig modules include built-in test blocks covering common (filelock, pe, steampipe), pisco (main, gpu_vendors, settings, reg, shlexSplit, GStreamer host plugin path discovery, Bitters VODKADLLPATH/overrides, optional NVAPI guard), default_pfx, symstore, font_merge, make_openxr, gen_lsteamclient, gen_vrclient, and steam_helper:

zig build test --summary all