From 459f787360977400f6382f4f89a7b5ea8f43ea55 Mon Sep 17 00:00:00 2001 From: DatCaptainHorse Date: Mon, 5 Oct 2026 16:25:33 +0300 Subject: [PATCH] feat: proton-cachyos returns --- build/Containerfile | 2 - build/Containerfile.proton | 131 +++++++++-- build/Containerfile.proton.containerignore | 15 ++ build/Makefile | 90 +++---- build/README.md | 79 +++---- build/kernel/scx.fragment | 46 ++++ ...rder-i386-steps-only-when-they-exist.patch | 26 --- ...fetch-unzip-from-snapshot.debian.org.patch | 22 -- ...ch-pe-arch-its-own-vkd3d-under-wow64.patch | 43 ---- build/scripts/kernel-build.sh | 33 ++- build/scripts/proton-build.sh | 220 +++++++----------- build/scripts/proton-fetch.sh | 57 +++++ 12 files changed, 422 insertions(+), 342 deletions(-) create mode 100644 build/Containerfile.proton.containerignore create mode 100644 build/kernel/scx.fragment delete mode 100644 build/patches/proton-ge/0001-kaldi-order-i386-steps-only-when-they-exist.patch delete mode 100644 build/patches/proton-ge/0002-protonfixes-fetch-unzip-from-snapshot.debian.org.patch delete mode 100644 build/patches/proton-ge/0003-wine-give-each-pe-arch-its-own-vkd3d-under-wow64.patch create mode 100755 build/scripts/proton-fetch.sh diff --git a/build/Containerfile b/build/Containerfile index 722a4a80..8031fd3a 100644 --- a/build/Containerfile +++ b/build/Containerfile @@ -637,8 +637,6 @@ RUN echo "NESTRI_STAGE=runtime_prod" >> /etc/os-release # ─────────────────────────────────────────────────────────── FROM runtime AS runtime_debug -COPY --from=compat_check /compat-verified /usr/share/nestri/compat-verified - # `-Sy` and not `-Syu`: a full upgrade here can pull a package back in as # somebody's dependency, and the one that matters is systemd. The check below # catches it either way, but a debug image that fails to build is worse than diff --git a/build/Containerfile.proton b/build/Containerfile.proton index fb633159..a8721017 100644 --- a/build/Containerfile.proton +++ b/build/Containerfile.proton @@ -1,25 +1,122 @@ # ═══════════════════════════════════════════════════════════ -# proton-ge, built wow64-only, as a copyable image -# -# This file does not build Proton. It packages a Proton tree that was already -# built, and it cannot build it: proton-ge's build runs its own steps in the -# Steam Runtime SDK image through a container engine, so it runs on the host, -# and running it inside this build would mean nested containers. -# `scripts/proton-build.sh` does the build, and this file wraps the result. +# proton-cachyos, built wow64-only # # Separate from the guest Containerfile because it is a separate cadence: -# hours to build, and only when PROTON_TAG moves. The guest image pulls the -# result from a registry instead of rebuilding it, which is why none of this -# is reached by `make build`. +# hours to build, and only when PROTON_TAG moves. A box is given the result +# at run time instead of carrying it, which is why this file is not part of +# the guest image build and is not reached by `make build`. # -# It is FROM scratch, so the image *is* the Proton tree. There is nothing in -# it to run, only something to COPY --from. +# The final stage is FROM scratch, so the image *is* the Proton tree — nothing +# to run, only something to COPY --from. # # Build and publish with `make proton-image` / `make proton-push`. **Its -# context is the built tree** (`output/proton/obj/dist`), and not this -# directory or the repository root: the tree is the whole input, and it is -# the only thing the build needs to send. +# context is this directory**, not the repository root the guest build uses: +# all it needs is the two scripts beside it, and a context of the whole tree +# would hand it a multi-gigabyte `output/` for no reason. +# +# `PROTON_TAG` is the one thing to change, and the Makefile derives the +# published image's version from it. They are the same number in two +# spellings, and an image whose name does not say which Proton is inside it +# is worse than no image. +# ═══════════════════════════════════════════════════════════ +FROM docker.io/archlinux:base-devel AS builder + +# proton-cachyos-native's makedepends, minus every lib32-* (that is the whole +# point of --enable-wow64), with two substitutions Arch requires: ocl-icd +# provides opencl-icd-loader, and mesa-libgl is folded into libglvnd. +# +# glib2-devel is the one that is easy to miss — it carries glib-mkenums, which +# libsoup's meson looks up through glib-2.0's pkg-config variables and fails on +# obscurely. unzip and zip are for the xalia dist step. afdko is not packaged at +# all, and the fonts submodule needs it, so it comes from PyPI. +RUN pacman -Syu --noconfirm --needed \ + alsa-lib clang cmake curl ffmpeg fontforge giflib git glib2-devel \ + glslang gnutls gtk3 libgphoto2 libglvnd libpulse libva libxcomposite \ + libxinerama libxxf86vm lld mesa meson ninja nasm \ + opencl-headers ocl-icd pcsclite perl perl-json python python-pip \ + python-pefile python-setuptools-scm rsync rust samba unixodbc \ + unzip zip v4l-utils vulkan-headers vulkan-icd-loader wayland \ + wayland-protocols wget xorg-util-macros \ + mingw-w64-gcc mingw-w64-binutils mingw-w64-crt mingw-w64-headers \ + mingw-w64-winpthreads \ + && pip install --break-system-packages --no-cache-dir afdko \ + && pacman -Scc --noconfirm + +# widl generates vkd3d's public headers. Without it autoconf sets HAVE_WIDL to +# false, the headers are silently not generated, and the build dies an hour +# later on a missing vkd3d_d3dx9shader.h. Arch ships widl only inside `wine`, +# which requires multilib; the AUR's mingw-w64-tools builds it standalone, so do +# the same. +# +# The digest is not a formality. What is extracted here has its `configure` and +# its makefiles run as root in this builder, and what they produce is copied +# into the image a box runs -- so whoever can change these bytes can change what +# runs on every host. SourceForge hands the request to whichever mirror it +# likes, over a connection this builder does not pin, and the project publishes +# no signature. The digest is the only thing that makes the mirror not matter. +# +# Taken 2026-09-14 from two different mirrors of v14.0.0, which agreed. A +# mismatch here is not a thing to paper over by taking the new digest: it means +# the bytes behind this exact version string changed, and that wants looking at +# before it wants fixing. +ARG MINGW_W64_VER=14.0.0 +ARG MINGW_W64_SHA256=6eaf921d9eb987d3820b364ea9775bc19b965ec81490b6fdd716526c28e1995c +RUN curl -fL --retry 3 -o /tmp/mingw-w64.tar.bz2 \ + "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v${MINGW_W64_VER}.tar.bz2/download" \ + && echo "${MINGW_W64_SHA256} /tmp/mingw-w64.tar.bz2" | sha256sum -c - \ + && tar xf /tmp/mingw-w64.tar.bz2 -C /tmp \ + && for arch in i686-w64-mingw32 x86_64-w64-mingw32; do \ + mkdir -p "/tmp/widl-${arch}" && cd "/tmp/widl-${arch}" \ + && "/tmp/mingw-w64-v${MINGW_W64_VER}/mingw-w64-tools/widl/configure" \ + --prefix=/usr --target="${arch}" --program-prefix="${arch}-" \ + && make -j"$(nproc)" && make install; \ + done \ + && rm -rf /tmp/mingw-w64* /tmp/widl-* + +WORKDIR /build + +ARG PROTON_GIT=https://github.com/CachyOS/proton-cachyos.git +ARG PROTON_TAG=cachyos-11.0-20261005-native +ARG GECKO_VER=2.47.4 +ARG MONO_VER=11.3.0 +ARG XALIA_VER=0.5.0 +ARG JOBS= + +# Fetch and build are separate layers on purpose: the submodule checkout runs +# well past ten minutes, and a build that fails on a flag or a missing tool must +# not pay for it again. +COPY scripts/proton-fetch.sh /build/proton-fetch.sh +RUN PROTON_GIT="${PROTON_GIT}" PROTON_TAG="${PROTON_TAG}" \ + GECKO_VER="${GECKO_VER}" MONO_VER="${MONO_VER}" XALIA_VER="${XALIA_VER}" \ + bash /build/proton-fetch.sh + +# What proton-cachyos-native lists as run-time dependencies, installed here too. +# Its own packaging builds with them present, and a newer tag can turn a plugin +# that used to be skipped when its library is absent into a required one -- +# gst-plugins-bad's uvch264 needs libgudev as of cachyos-11.0-20261005, and +# configure stops an hour in on "gudev-1.0 not found". The set is the +# PKGBUILD's `depends`, minus what is installed above, the lib32 and virtual +# entries, and `atk`, which Arch no longer ships. +# +# Its own layer, after the fetch, so that a dependency a tag bump turns up +# costs a package install and not the submodule checkout again. +RUN pacman -Syu --noconfirm --needed \ + attr cabextract desktop-file-utils fontconfig flac freetype2 gettext \ + libgudev libnsl libpcap libunwind libvpx libwebp libx11 libxcursor \ + libxext libxkbcommon libxml2 libxi libxrandr mpg123 pipewire python-six \ + speex speexdsp cairo dbus-glib freeglut gdk-pixbuf2 glu lcms2 libcaca \ + libcanberra dbus libdrm libice libibus libnm libusb libvdpau libvorbis \ + libxft libxmu libxrender libxtst nspr openal pango sdl2-compat librsvg \ + libsm libtheora xz \ + && pacman -Scc --noconfirm + +COPY scripts/proton-build.sh /build/proton-build.sh +RUN GECKO_VER="${GECKO_VER}" MONO_VER="${MONO_VER}" JOBS="${JOBS}" \ + bash /build/proton-build.sh + + +# ═══════════════════════════════════════════════════════════ +# The publishable artifact: the Proton tree and nothing else # ═══════════════════════════════════════════════════════════ FROM scratch -ARG BUILD_NAME=proton-ge -COPY . /usr/share/steam/compatibilitytools.d/${BUILD_NAME}/ +COPY --from=builder /artifacts/proton/ / diff --git a/build/Containerfile.proton.containerignore b/build/Containerfile.proton.containerignore new file mode 100644 index 00000000..f7b2c9b1 --- /dev/null +++ b/build/Containerfile.proton.containerignore @@ -0,0 +1,15 @@ +# This build's context is `build/`, not the repository root, because all it +# needs is the two scripts beside the Containerfile. +# +# `output/` is the reason this file exists. It holds packed rootfs images — +# multiple gigabytes each — and a build context is copied before the first +# instruction runs, so without this line every Proton build starts by moving +# the last one it produced. +output + +# Nothing else here is an input to this build. +etc +README.md +Makefile +Containerfile +Containerfile.containerignore diff --git a/build/Makefile b/build/Makefile index bc01159e..e17b777c 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,5 +1,5 @@ SHELL := /bin/bash -.PHONY: build build-debug image image-debug kernel kernel-clean proton-image proton-push proton-clean clean help +.PHONY: build build-debug image image-debug kernel kernel-clean kernel-objclean proton-image proton-push clean help CONTAINER_RT := $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null) ifeq ($(CONTAINER_RT),) @@ -29,32 +29,27 @@ CONTEXT := .. IMAGE_NAME := ghcr.io/nestrilabs/nestri/base # Proton is the one artifact worth publishing on its own: it takes hours to -# build and changes only when its tag moves, so the guest build pulls it by -# name instead of rebuilding it. +# build and changes only when its tag moves. It is not part of the guest +# rootfs; it is a separate payload that reaches a box at run time, so this +# is built and published on its own cadence. # # `PROTON_TAG` is the single place to change it. The published version is # derived from the tag rather than written twice, because the two are the same # number in two spellings and an image whose name does not say which Proton is # inside it is worse than no image at all. Changing the tag by hand and # forgetting the version is exactly the mistake this removes. -PROTON_GIT ?= https://github.com/gloriouseggroll/proton-ge-custom.git -PROTON_TAG ?= GE-Proton11-7 -PROTON_VERSION := 11.0-20260703 +PROTON_TAG ?= cachyos-11.0-20261005-native +PROTON_VERSION := $(PROTON_TAG:cachyos-%-native=%) PROTON_IMAGE ?= ghcr.io/nestrilabs/proton-cachyos-native-wow64 PROTON_REF := $(PROTON_IMAGE):$(PROTON_VERSION) -# The directory name under compatibilitytools.d, and the name Steam shows. -PROTON_NAME := proton-ge OUTPUT_DIR := output -# Source, build tree, ccache and cargo downloads. Tens of gigabytes, and it -# lives under output/ because that directory is already ignored by git and -# kept out of the guest build's context. -PROTON_WORK := $(OUTPUT_DIR)/proton ROOTFS_SIZE ?= 2G FORCE_REBUILD ?= # The guest kernel: CachyOS's fork, for its scheduler patches, with our own # minimal config on top (kernel/nestri.fragment). The tree is a clone rather -# than vendored, and lives under output/ for the same reason Proton's does. +# than vendored, and lives under output/, which git ignores and the guest +# build never sees. # KERNEL_SRC may point at an existing tree elsewhere. KERNEL_GIT ?= https://github.com/CachyOS/linux.git KERNEL_REF ?= cachyos-7.2.6-1 @@ -76,6 +71,12 @@ INFINITY_REV ?= e6c85d841f25e21393a7ea47fdef286318915d8c INFINITY_SERIES := patches/cachyos/tuned-eevdf/$(KERNEL_REF:cachyos-%=%) INFINITY_WORK := $(OUTPUT_DIR)/infinity-sched +# Experimental: KERNEL_SCX=1 adds what a sched_ext scheduler needs +# (kernel/scx.fragment), so a guest can load one. Its own tree and its own +# name for the same reason as above, and it does not combine with +# KERNEL_INFINITY: they are two answers to the same question. +KERNEL_SCX ?= + # The guest half of NVIDIA forwarding: the driver, built into the kernel, and # its Vulkan layer, built into the rootfs. A branch, so each build takes them # as they are now; set NVGPU_REF to a tag or commit to pin it. The commit built @@ -85,9 +86,15 @@ NVGPU_GIT ?= https://github.com/nestrilabs/virtio-nvgpu.git NVGPU_REF ?= dev NVGPU_WORK := $(OUTPUT_DIR)/virtio-nvgpu +ifneq ($(and $(KERNEL_INFINITY),$(KERNEL_SCX)),) +$(error KERNEL_INFINITY and KERNEL_SCX are alternatives; set one) +endif ifneq ($(KERNEL_INFINITY),) KERNEL_SRC ?= $(OUTPUT_DIR)/kernel-infinity KERNEL_OUTPUT := $(OUTPUT_DIR)/vmlinux-infinity +else ifneq ($(KERNEL_SCX),) +KERNEL_SRC ?= $(OUTPUT_DIR)/kernel-scx +KERNEL_OUTPUT := $(OUTPUT_DIR)/vmlinux-scx else KERNEL_SRC ?= $(OUTPUT_DIR)/kernel KERNEL_OUTPUT := $(OUTPUT_DIR)/vmlinux @@ -95,34 +102,25 @@ endif build: DOCKER_BUILDKIT=1 $(CONTAINER_RT) build $(if $(FORCE_REBUILD),--no-cache,) \ - --build-arg PROTON_IMAGE=$(PROTON_REF) \ --build-arg NVGPU_GIT=$(NVGPU_GIT) --build-arg NVGPU_REF=$(NVGPU_REF) \ -f Containerfile -t $(IMAGE_NAME):latest --target runtime_prod $(CONTEXT) build-debug: DOCKER_BUILDKIT=1 $(CONTAINER_RT) build $(if $(FORCE_REBUILD),--no-cache,) \ - --build-arg PROTON_IMAGE=$(PROTON_REF) \ --build-arg NVGPU_GIT=$(NVGPU_GIT) --build-arg NVGPU_REF=$(NVGPU_REF) \ -f Containerfile -t $(IMAGE_NAME):debug --target runtime_debug $(CONTEXT) -# Hours, and only when PROTON_TAG moves. Two steps: the build runs on the host, -# because proton-ge's build drives the container engine itself, and the -# finished tree is then the whole context of a FROM scratch image. See the head -# of Containerfile.proton for why the build cannot run inside it. -# -# A second run of the same tag resumes where the last one stopped. A new tag, -# or FORCE_REBUILD, starts the tree over but keeps ccache. +# Hours, and only when PROTON_TAG moves. Its context is this directory rather +# than the repository root: the two scripts beside the Containerfile are the +# whole input, and the root would hand it everything else for nothing. proton-image: - PROTON_GIT=$(PROTON_GIT) PROTON_TAG=$(PROTON_TAG) PROTON_WORK=$(PROTON_WORK) \ - BUILD_NAME=$(PROTON_NAME) CONTAINER_ENGINE=$(notdir $(CONTAINER_RT)) \ - FORCE_REBUILD=$(FORCE_REBUILD) \ - bash scripts/proton-build.sh - $(CONTAINER_RT) build --build-arg BUILD_NAME=$(PROTON_NAME) \ - -f Containerfile.proton -t $(PROTON_REF) $(PROTON_WORK)/obj/dist + DOCKER_BUILDKIT=1 $(CONTAINER_RT) build $(if $(FORCE_REBUILD),--no-cache,) \ + --build-arg PROTON_TAG=$(PROTON_TAG) \ + -f Containerfile.proton -t $(PROTON_REF) . @echo "Built $(PROTON_REF)" -# Publishing is what makes `make build` cheap for everyone else, since that -# build pulls this by name. Push before expecting anyone to use a new tag. +# Publishing is what lets a box be given this Proton by name. Push before +# expecting anyone to use a new tag. proton-push: proton-image $(CONTAINER_RT) push $(PROTON_REF) @@ -144,25 +142,30 @@ image-debug: build-debug kernel: KERNEL_GIT=$(KERNEL_GIT) KERNEL_REF=$(KERNEL_REF) KERNEL_SRC=$(KERNEL_SRC) \ KERNEL_MARCH=$(KERNEL_MARCH) KERNEL_OUTPUT=$(KERNEL_OUTPUT) \ - KERNEL_INFINITY=$(KERNEL_INFINITY) INFINITY_GIT=$(INFINITY_GIT) \ + KERNEL_INFINITY=$(KERNEL_INFINITY) KERNEL_SCX=$(KERNEL_SCX) INFINITY_GIT=$(INFINITY_GIT) \ INFINITY_REV=$(INFINITY_REV) INFINITY_SERIES=$(INFINITY_SERIES) \ INFINITY_WORK=$(INFINITY_WORK) \ NVGPU_GIT=$(NVGPU_GIT) NVGPU_REF=$(NVGPU_REF) NVGPU_WORK=$(NVGPU_WORK) \ bash scripts/kernel-build.sh -# Leaves $(PROTON_WORK) and the kernel alone: one is hours of build and ccache, -# the other a clone and a warm object tree, and a rootfs is neither. -# proton-clean and kernel-clean are the ones that drop them. +# Leaves the kernel alone: it is a clone and a warm object tree, and a rootfs +# is neither. kernel-clean is the one that drops it. clean: - find $(OUTPUT_DIR) -mindepth 1 -maxdepth 1 ! -name proton ! -name 'kernel*' \ + find $(OUTPUT_DIR) -mindepth 1 -maxdepth 1 ! -name 'kernel*' \ ! -name 'vmlinux*' ! -name infinity-sched ! -name virtio-nvgpu -exec rm -rf {} + 2>/dev/null || true -kernel-clean: - rm -rf $(OUTPUT_DIR)/kernel $(OUTPUT_DIR)/kernel-infinity $(INFINITY_WORK) $(NVGPU_WORK) \ - $(OUTPUT_DIR)/vmlinux $(OUTPUT_DIR)/vmlinux-infinity $(OUTPUT_DIR)/vmlinux*.nvgpu-rev +# Drops the objects and keeps the clone, the config and the driver checkout. +# For a tree whose compiler changed underneath it: kbuild's dependency files +# name the old compiler's headers by path, and once a compiler upgrade removes +# them make stops on "No rule to make target" for a file it cannot rebuild. +# Acts on the tree the same flags select for `kernel`, so +# `make KERNEL_SCX=1 kernel-objclean` cleans that one. +kernel-objclean: + $(MAKE) -C $(KERNEL_SRC) LLVM=1 clean -proton-clean: - rm -rf $(PROTON_WORK) +kernel-clean: + rm -rf $(OUTPUT_DIR)/kernel $(OUTPUT_DIR)/kernel-infinity $(OUTPUT_DIR)/kernel-scx $(INFINITY_WORK) $(NVGPU_WORK) \ + $(OUTPUT_DIR)/vmlinux $(OUTPUT_DIR)/vmlinux-infinity $(OUTPUT_DIR)/vmlinux-scx $(OUTPUT_DIR)/vmlinux*.nvgpu-rev help: @echo "Usage:" @@ -172,11 +175,12 @@ help: @echo " make image-debug Build + pack runtime_debug into output/rootfs-debug.ext4" @echo " make kernel Build the guest kernel into output/vmlinux" @echo " make KERNEL_INFINITY=1 kernel Experimental Infinity scheduler build → output/vmlinux-infinity" - @echo " make kernel-clean Remove both kernel trees and images" + @echo " make KERNEL_SCX=1 kernel Experimental build that can load a sched_ext scheduler → output/vmlinux-scx" + @echo " make kernel-objclean Drop a kernel tree's objects, keep the clone and config (after a compiler upgrade)" + @echo " make kernel-clean Remove every kernel tree and image" @echo " make clean Remove the rootfs images from output/" @echo " make proton-image Build Proton from source (hours)" - @echo " make proton-clean Remove the Proton source, build tree and ccache" @echo " make proton-push Build it and publish it" @echo " make FORCE_REBUILD=1 ... Rebuild from scratch, no layer cache" - @echo " make PROTON_TAG=... ... Use a different proton-ge tag" + @echo " make PROTON_TAG=... ... Use a different proton-cachyos tag" @echo " make ROOTFS_SIZE=8G image Override the packed image size (default 5G)" diff --git a/build/README.md b/build/README.md index 796e7a06..31a70e5a 100644 --- a/build/README.md +++ b/build/README.md @@ -63,8 +63,8 @@ something this repo names, links to, or depends on. **Proton is not in the image.** It used to be, at a cost of about 1.4 GB, and it is attached to a box at run time now: a read-only EROFS image of a Proton tree, mounted at `/nestri/compat`, chosen per session by whatever starts the -box. That is what makes trying another Proton (GE's releases, a newer build of -ours) a matter of attaching a different image rather than rebuilding this one. +box. That is what makes trying another Proton (a newer build of ours, or someone +else's) a matter of attaching a different image rather than rebuilding this one. What stays here is everything Proton needs around itself: the interpreter for its entry point and every library its programs and Wine's core link. The @@ -79,8 +79,8 @@ stage, because the leaf stages copy that marker out of it. The image holds no Proton path, so a box started without one fails saying where it looked instead of quietly using something stale. -What the published Proton is: **proton-ge built wow64-only**, as a published -image rather than rebuilt here, because it takes hours and moves only when its +What the published Proton is: **proton-cachyos built with `--enable-wow64`**, as +a published image rather than rebuilt here, because it takes hours and moves only when its own tag does. wow64 runs 32-bit Windows code inside a 64-bit unix process, so a box needs no lib32 glibc, no second Mesa for i686, and no second capture layer for 32-bit titles to be captured. Upstream Wine defaults to it from Proton 11, @@ -215,57 +215,48 @@ a package list says that; the check below is what said it. ## Proton has its own cadence, and its own Containerfile -`make build` **pulls** Proton by tag to check it against; it does not build it -and does not ship it. Building it takes hours and it changes only when its tag -moves, so it is one image published once. `make proton-image` is -that build, and it lives here so the published tag stays reproducible from -this tree rather than from somebody's laptop. +`make build` neither builds Proton nor ships it. Building it takes hours and it +changes only when its tag moves, so it is one image published once and attached +to boxes at run time. `Containerfile.proton` is that build, and it lives here so +the published tag stays reproducible from this tree rather than from somebody's +laptop. ```sh -make proton-image # the current tag -make PROTON_TAG=GE-Proton11-8 proton-image -make proton-clean # drop the source, build tree and ccache +make proton-image # the current tag +make PROTON_TAG=cachyos-11.1-20261115-native proton-image +make proton-push # build it and publish it ``` **`PROTON_TAG` is the only thing to change.** The published version is derived from it in the `Makefile` rather than written a second time, because the two are the same number in two spellings — and an image whose name does not say -which Proton is inside it is worse than no image. The `Containerfile`'s own -`PROTON_IMAGE` default is a fallback for a bare container build; going through -`make` is what keeps them in step. +which Proton is inside it is worse than no image. -**The build runs on the host, not in a `podman build`.** proton-ge's build is -container-driven itself: `make` runs outside, and every step runs in the Steam -Runtime SDK image through the container engine, so the host needs only git, -make and podman. Wrapping that in a container build would mean nested -containers. So there are two steps: +A tag bump also means checking `GECKO_VER`, `MONO_VER` and `XALIA_VER` in +`Containerfile.proton`: they are the runtimes the tag's own `Makefile.in` names, +fetched in the slow layer so that a failure later does not repeat the fetch. -1. `scripts/proton-build.sh` clones the tag with its submodules, applies - proton-ge's patch set, and runs its build with one change: the arch list - drops the 32-bit unix side, which is what makes it wow64-only. Everything - happens under `output/proton/`, which is tens of gigabytes. -2. `Containerfile.proton` is `FROM scratch` with the built tree as its whole - context, so the image is the tree and nothing else. +The result is `FROM scratch` over the tree, so the image's root *is* the tree, +under `usr/share/steam/compatibilitytools.d/proton-cachyos`, and there is +nothing in it to run. -Things worth knowing before changing it: +Its **context is `build/`**, not the repository root the guest build uses. All +it needs is the two scripts beside it, and `Containerfile.proton.containerignore` +keeps `output/` out of that context — a build context is copied before the +first instruction runs, so without it every Proton build would begin by moving +the last rootfs image, or kernel tree, it produced. -- **A rerun of the same tag resumes.** The clone, the patching and the - configure step each run once per tag, and proton-ge's own make picks up - where it stopped. A new tag or `FORCE_REBUILD=1` starts the tree over; - ccache and the cargo downloads survive both. `make clean` leaves all of it - alone, and `make proton-clean` removes it. -- **The patch script does not fail on a patch that does not apply.** It - carries on and exits 0, so `proton-build.sh` greps its output - (`output/proton/patch.log`) and stops. Otherwise the result is an image - that looks fine and is missing a fix. -- **`patches/proton-ge/` is ours, applied after proton-ge's own set.** It holds - what wow64-only needs that proton-ge's makefile does not handle, and fixes - for things a tag pinned that have since moved. Each patch says why it exists - at its top, and each one fails the build outright once it stops applying, - which on a tag bump is usually upstream having fixed it. -- **The patch script is not idempotent**, so a tree is patched exactly once. - An interrupted run resets every submodule to the commits the tag pins before - patching again. +Two things in the recipe are worth knowing before changing it: + +- **Fetch and build are separate layers on purpose.** The submodule checkout + runs well past ten minutes, and a build that fails on a flag or a missing + tool must not pay for that again. Keep anything that can fail *fast* in + `proton-build.sh`. +- **`widl` is built by hand from the mingw-w64 release.** Without it autoconf + quietly sets `HAVE_WIDL` to false, vkd3d's public headers are never + generated, and the build dies an hour later on a missing header. Arch ships + `widl` only inside `wine`, which wants multilib — which is the thing + `--enable-wow64` exists to avoid. ## There is no init system in here, and that is the design diff --git a/build/kernel/scx.fragment b/build/kernel/scx.fragment new file mode 100644 index 00000000..8ae061be --- /dev/null +++ b/build/kernel/scx.fragment @@ -0,0 +1,46 @@ +# Merged after nestri.fragment when KERNEL_SCX=1: what a sched_ext scheduler +# needs from the kernel it is loaded into. Off by default, because a guest that +# does not load one pays for the tracing and debug-info support below and gets +# nothing back. +# +# A scheduler is a BPF program attached through struct_ops, and the loader +# checks the kernel's own symbols, BTF and config before it will attach. +# Each group below is one of those checks; the failure when it is missing is +# the loader's, not the kernel's, and says little. + +# The class itself, and the BPF it is loaded through. struct_ops resolves a +# member's stub function by address, so it needs kallsyms. +CONFIG_SCHED_CLASS_EXT=y +CONFIG_BPF_SYSCALL=y +CONFIG_BPF_JIT=y +CONFIG_KALLSYMS=y + +# Type information for the kernel's own structures. The stock fragment turns +# debug info off, and BTF is built from it, so that is undone here. A scheduler reads task +# fields by BTF, and resolves per-CPU variables such as the preempt count by +# name, which kallsyms only lists with KALLSYMS_ALL. +# CONFIG_DEBUG_INFO_NONE is not set +CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y +CONFIG_DEBUG_INFO_BTF=y +CONFIG_KALLSYMS_ALL=y + +# The loader reads the running kernel's config from /proc/config.gz to decide +# which features to use. +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y + +# Tracing the loader checks for and attaches to: debugfs to find it, and +# function and syscall tracepoints for the futex hooks some schedulers use to +# boost a lock holder. +CONFIG_DEBUG_FS=y +CONFIG_FTRACE=y +CONFIG_FUNCTION_TRACER=y +CONFIG_DYNAMIC_FTRACE=y +CONFIG_FPROBE=y +CONFIG_FTRACE_SYSCALLS=y +CONFIG_KPROBES=y +CONFIG_KPROBE_EVENTS=y + +# Utilisation hints a scheduler can read from a task. +CONFIG_UCLAMP_TASK=y +CONFIG_UCLAMP_TASK_GROUP=y diff --git a/build/patches/proton-ge/0001-kaldi-order-i386-steps-only-when-they-exist.patch b/build/patches/proton-ge/0001-kaldi-order-i386-steps-only-when-they-exist.patch deleted file mode 100644 index 2a3fbb2b..00000000 --- a/build/patches/proton-ge/0001-kaldi-order-i386-steps-only-when-they-exist.patch +++ /dev/null @@ -1,26 +0,0 @@ -kaldi's i386 and x86_64 builds share one source directory, and its cmake -writes generated files into it, so proton-ge serializes the two with plain -ordering rules. Those rules name the i386 steps unconditionally. - -A wow64-only build has no i386-unix in ARCHS, so the i386 steps are never -defined, and make stops with "no rule to make target .kaldi-i386-configure". -Only order against them when they exist. - -diff --git a/Makefile.in b/Makefile.in -index f8d959c..9b92fec 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -573,9 +573,13 @@ $(eval $(call rules-cmake,kaldi,aarch64,unix)) - # the same source directory. - # - # The below assures that only a single configure/build step can run at a time. -+# The i386 steps exist only when i386-unix is in ARCHS; a wow64-only build has -+# none, and ordering against them would ask for a target with no rule. -+ifneq ($(findstring i386-unix,$(ARCHS)),) - $(OBJ)/.kaldi-x86_64-configure: $(OBJ)/.kaldi-i386-configure - $(OBJ)/.kaldi-i386-build: $(OBJ)/.kaldi-x86_64-configure - $(OBJ)/.kaldi-i386-build: $(OBJ)/.kaldi-x86_64-build -+endif - - ## - ## vosk diff --git a/build/patches/proton-ge/0002-protonfixes-fetch-unzip-from-snapshot.debian.org.patch b/build/patches/proton-ge/0002-protonfixes-fetch-unzip-from-snapshot.debian.org.patch deleted file mode 100644 index 2d9cabe9..00000000 --- a/build/patches/proton-ge/0002-protonfixes-fetch-unzip-from-snapshot.debian.org.patch +++ /dev/null @@ -1,22 +0,0 @@ -protonfixes pins unzip to Debian revision 6.0-29 and fetches it from the -live pool. The pool keeps only current revisions, so once 6.0-31 landed the -download started failing with a 404 and the build with it. - -snapshot.debian.org keeps every revision Debian has published, at a stable -path per timestamp. This is the first snapshot that carries 6.0-29, and the -orig tarball has been in the pool since 2009, so both files resolve there -and are the same bytes the pin always meant. - -diff --git a/protonfixes/Makefile b/protonfixes/Makefile -index 4dcd851..8fab279 100644 ---- a/protonfixes/Makefile -+++ b/protonfixes/Makefile -@@ -146,7 +146,7 @@ DEFINES = -DACORN_FTYPE_NFS -DWILD_STOP_AT_DIR -DLARGE_FILE_SUPPORT \ - -DNO_WORKING_ISPRINT - UNZIP_VERSION := 6.0 - UNZIP_DEBIAN_REVISION := 29 --UNZIP_BASE_URL := https://deb.debian.org/debian/pool/main/u/unzip -+UNZIP_BASE_URL := https://snapshot.debian.org/archive/debian/20250311T215724Z/pool/main/u/unzip - UNZIP_ORIG_TARBALL := unzip_$(UNZIP_VERSION).orig.tar.gz - UNZIP_DEBIAN_TARBALL := unzip_$(UNZIP_VERSION)-$(UNZIP_DEBIAN_REVISION).debian.tar.xz - UNZIP_DOWNLOAD_DIR := $(OBJDIR)/downloads/unzip diff --git a/build/patches/proton-ge/0003-wine-give-each-pe-arch-its-own-vkd3d-under-wow64.patch b/build/patches/proton-ge/0003-wine-give-each-pe-arch-its-own-vkd3d-under-wow64.patch deleted file mode 100644 index 846890b3..00000000 --- a/build/patches/proton-ge/0003-wine-give-each-pe-arch-its-own-vkd3d-under-wow64.patch +++ /dev/null @@ -1,43 +0,0 @@ -The x86_64 wine build gets VKD3D_PE_LIBS with a -L to the x86_64 vkd3d -DLLs. That is right while a separate i386 wine build exists and gets its -own value. - -A wow64-only build has no i386 wine build: the x86_64 one builds the i386 -PE side as well, and wine takes one VKD3D_PE_LIBS for every PE arch. The -i386 wined3d.dll then links against the x86_64 libvkd3d-1.dll and fails -with "file format not recognized". ld does not skip a mismatched DLL -named with -l:, so listing both directories does not work either. - -Under wow64, keep the library names in VKD3D_PE_LIBS and pass each arch -its own directory through i386_LDFLAGS and x86_64_LDFLAGS, which wine's -configure already takes per arch. The i386 vkd3d was only ever built -as a dependency of the i386 wine build, so the x86_64 one now waits for it. - -diff --git a/Makefile.in b/Makefile.in -index f8d959c..2ac0b34 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -635,9 +639,23 @@ WINE_aarch64_AUTOCONF_ARGS = \ - WINE_i386_AUTOCONF_ARGS += \ - VKD3D_PE_CFLAGS="-I$(VULKAN_HEADERS_i386_DST)/include -I$(VKD3D_i386_DST)/include/vkd3d" \ - VKD3D_PE_LIBS="-L$(VKD3D_i386_LIBDIR)/vkd3d/i386-windows -l:libvkd3d-1.dll -l:libvkd3d-shader-1.dll -l:libvkd3d-utils-1.dll" -+ifneq ($(findstring i386-unix,$(ARCHS)),) - WINE_x86_64_AUTOCONF_ARGS += \ - VKD3D_PE_CFLAGS="-I$(VULKAN_HEADERS_x86_64_DST)/include -I$(VKD3D_x86_64_DST)/include/vkd3d" \ - VKD3D_PE_LIBS="-L$(VKD3D_x86_64_LIBDIR)/vkd3d/x86_64-windows -l:libvkd3d-1.dll -l:libvkd3d-shader-1.dll -l:libvkd3d-utils-1.dll" -+else -+# Without i386-unix there is no i386 wine build, and the x86_64 one builds the -+# i386 PE side too (wow64). It links both, but VKD3D_PE_LIBS is one value for -+# every PE arch, so a -L in it would hand the i386 link the x86_64 DLLs. Name -+# the libraries there and give each arch its own directory through its own -+# LDFLAGS instead. -+WINE_x86_64_AUTOCONF_ARGS += \ -+ VKD3D_PE_CFLAGS="-I$(VULKAN_HEADERS_x86_64_DST)/include -I$(VKD3D_x86_64_DST)/include/vkd3d" \ -+ VKD3D_PE_LIBS="-l:libvkd3d-1.dll -l:libvkd3d-shader-1.dll -l:libvkd3d-utils-1.dll" -+WINE_i386-windows_LIBFLAGS = -L$(VKD3D_i386_LIBDIR)/vkd3d/i386-windows -+WINE_x86_64-windows_LIBFLAGS = -L$(VKD3D_x86_64_LIBDIR)/vkd3d/x86_64-windows -+$(OBJ)/.wine-x86_64-build: $(OBJ)/.vkd3d-i386-post-build -+endif - - WINE_DEPENDS = ffmpeg openfst kaldi vosk libxml2 libxkbcommon libpcap - WINE_i386_DEPENDS = vkd3d diff --git a/build/scripts/kernel-build.sh b/build/scripts/kernel-build.sh index 0c037958..9a387408 100644 --- a/build/scripts/kernel-build.sh +++ b/build/scripts/kernel-build.sh @@ -134,11 +134,11 @@ nvgpu_src="${NVGPU_WORK}/driver" # node fails with "DRM core is not initialized". Loaded as a module, the order # never came up. nvgpu_dst="drivers/gpu/drm/nvgpu" -mkdir -p "${nvgpu_dst}/gen" -for dst in "${nvgpu_dst}"/*.[ch] "${nvgpu_dst}"/gen/*.h; do +mkdir -p "${nvgpu_dst}/gen" "${nvgpu_dst}/rmctrl" +for dst in "${nvgpu_dst}"/*.[ch] "${nvgpu_dst}"/gen/*.h "${nvgpu_dst}"/rmctrl/*.h; do [[ -e "${dst}" && ! -e "${nvgpu_src}/${dst#"${nvgpu_dst}"/}" ]] && rm -f "${dst}" done -for src in "${nvgpu_src}"/*.[ch] "${nvgpu_src}"/gen/*.h "${nvgpu_src}/Kconfig"; do +for src in "${nvgpu_src}"/*.[ch] "${nvgpu_src}"/gen/*.h "${nvgpu_src}"/rmctrl/*.h "${nvgpu_src}/Kconfig"; do dst="${nvgpu_dst}/${src#"${nvgpu_src}"/}" cmp -s "${src}" "${dst}" || cp "${src}" "${dst}" done @@ -193,10 +193,14 @@ if [[ ! -f .config ]]; then cp "${SEED}" .config fi -echo "kernel: merging kernel/nestri.fragment" +fragments=("${FRAGMENT}") +if [[ -n "${KERNEL_SCX:-}" ]]; then + fragments+=("${KERNEL_DIR}/scx.fragment") +fi +echo "kernel: merging ${fragments[*]/#${KERNEL_DIR}\//kernel/}" # -m merges without running a config target, so olddefconfig resolves # dependencies once, in one place. -./scripts/kconfig/merge_config.sh -m .config "${FRAGMENT}" >/dev/null +./scripts/kconfig/merge_config.sh -m .config "${fragments[@]}" >/dev/null make "${make_args[@]}" olddefconfig >/dev/null # ── Verify the fragment actually took ─────────────────── @@ -205,16 +209,29 @@ make "${make_args[@]}" olddefconfig >/dev/null # enough for a setting whose failure mode is silent audio, so check the result # rather than the intent. Both halves count: an option that must be on, and one # that must be off. +# +# One entry per symbol, the last fragment's: a later fragment may turn off what +# an earlier one turned on, and checking both would fail whichever way the +# build went. +declare -A wanted=() +order=() +while read -r line; do + sym="$(sed -E 's/^(# )?(CONFIG_[A-Z0-9_]+)[ =].*/\2/' <<<"${line}")" + [[ -v "wanted[${sym}]" ]] || order+=("${sym}") + wanted["${sym}"]="${line}" +done < <(grep -hE '^(CONFIG_[A-Z0-9_]+=|# CONFIG_[A-Z0-9_]+ is not set)' "${fragments[@]}" \ + | sed -E 's/^(CONFIG_[A-Z0-9_]+=[^[:space:]#]+)[[:space:]]*#.*/\1/') + missing=() total=0 -while read -r want; do +for sym in "${order[@]}"; do + want="${wanted[${sym}]}" total=$((total + 1)) case "${want}" in CONFIG_*) grep -qx "${want}" .config || missing+=("${want%%=*}") ;; "# "*) grep -qx "${want}" .config || missing+=("${want:2} (must be off)") ;; esac -done < <(grep -E '^(CONFIG_[A-Z0-9_]+=|# CONFIG_[A-Z0-9_]+ is not set)' "${FRAGMENT}" \ - | sed -E 's/^(CONFIG_[A-Z0-9_]+=[^[:space:]#]+)[[:space:]]*#.*/\1/') +done if (( ${#missing[@]} )); then echo "kernel: these fragment entries did not survive olddefconfig:" >&2 diff --git a/build/scripts/proton-build.sh b/build/scripts/proton-build.sh index d24e3b47..2e576157 100755 --- a/build/scripts/proton-build.sh +++ b/build/scripts/proton-build.sh @@ -1,150 +1,96 @@ #!/usr/bin/env bash -# Builds proton-ge wow64-only and leaves the finished tree in "${PROTON_WORK}/obj/dist". -# Runs on the host, not in a container. +# Builds proton-cachyos from the tree proton-fetch.sh laid down. Container-only. # -# It has to run on the host because proton-ge's build is itself container-driven: -# `make` runs outside, and every step runs in the Steam Runtime SDK image, where -# the toolchains live, through the engine it is configured with. There is no -# mode without a container, and a container engine inside `podman build` is -# nested containers, which is a lot of fragile setup for no gain. So the only -# thing this script needs from the host is git, make and the engine. The -# Makefile packages the result afterwards. +# The one thing that matters here is --enable-wow64: it builds wine so that +# 32-bit Windows code runs inside a 64-bit unix process, thunking down to the +# 64-bit host libraries. Without it, Proton needs a complete 32-bit host stack — +# lib32 glibc, a second Mesa built for i686, and a second nescapture layer, +# because a 32-bit game would load the 32-bit Vulkan loader and our 64-bit +# capture layer would be invisible to it. With it, none of that exists. # -# The one thing we change is the arch list: it becomes wow64-only, and that -# change is the reason this is our own build and not a download. wow64 runs -# 32-bit Windows code inside a 64-bit unix process. Without it Proton needs a -# complete 32-bit host stack: lib32 glibc, a second Mesa built for i686, and a -# second nescapture layer, because a 32-bit game would load the 32-bit Vulkan -# loader and our 64-bit capture layer would be invisible to it. The released -# builds carry an i386 unix side, which is exactly why they need lib32-*. -# -# Everything else is proton-ge's own recipe: the same SDK image, the same flags -# and the same patch set. The one addition is patches/proton-ge/: fixes for the -# places its makefile assumes a 32-bit unix side that wow64 does not have, and -# for things a tag pinned that have since moved out from under it. +# The cost is that the distro package cannot be used: proton-cachyos-native is +# packaged without the flag, which is exactly why it depends on lib32-*. set -euo pipefail -: "${PROTON_GIT:?}" -: "${PROTON_TAG:?}" -: "${PROTON_WORK:?}" -: "${BUILD_NAME:?}" +: "${GECKO_VER:?}" +: "${MONO_VER:?}" -ENGINE="${CONTAINER_ENGINE:-podman}" JOBS="${JOBS:-$(nproc)}" +BUILD_NAME="proton-cachyos" +SRC_DIR="/build/proton-cachyos" +BUILD_DIR="/build/build" +OUT_DIR="/artifacts/proton/usr/share/steam/compatibilitytools.d/${BUILD_NAME}" -mkdir -p "${PROTON_WORK}" -PROTON_WORK="$(cd "${PROTON_WORK}" && pwd)" -SRC="${PROTON_WORK}/src" -OBJ="${PROTON_WORK}/obj" -STAMP_TAG="${PROTON_WORK}/.tag" -STAMP_PATCHED="${PROTON_WORK}/.patched" -PATCH_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../patches/proton-ge" && pwd)" +[[ -d "${SRC_DIR}" ]] || { echo "no source tree — proton-fetch.sh did not run"; exit 1; } -# Two builds in one tree do not fail cleanly. They race on the same objects and -# leave half-written files that a later build trusts. A failed make also keeps -# running its in-flight jobs for a while after it reports the error, so the -# first build is often still running when the second one starts. -exec 9>"${PROTON_WORK}/.lock" -flock -n 9 || { echo "proton: another build is using ${PROTON_WORK}" >&2; exit 1; } - -# ccache and cargo's downloads are kept outside src/ and obj/, so a new tag or -# FORCE_REBUILD throws away the build and keeps the parts that are correct to -# reuse. proton-ge's makefile mounts both into the container from these -# variables. -export CCACHE_DIR="${PROTON_WORK}/ccache" -export CARGO_HOME="${PROTON_WORK}/cargo" -mkdir -p "${CCACHE_DIR}" "${CARGO_HOME}" - -if [[ -n "${FORCE_REBUILD:-}" || "$(cat "${STAMP_TAG}" 2>/dev/null)" != "${PROTON_TAG}" ]]; then - echo "proton: fresh tree for ${PROTON_TAG}" - rm -rf "${SRC}" "${OBJ}" "${STAMP_TAG}" "${STAMP_PATCHED}" -fi - -# ── Fetch ─────────────────────────────────────────────── -if [[ ! -e "${STAMP_TAG}" ]]; then - rm -rf "${SRC}" - git clone --branch "${PROTON_TAG}" --depth=1 "${PROTON_GIT}" "${SRC}" - # No --depth here: submodules are pinned to commits that are often not a - # branch tip. --filter=tree:0 keeps the download down instead. - git -C "${SRC}" submodule update --init --filter=tree:0 --recursive - echo "${PROTON_TAG}" > "${STAMP_TAG}" -fi - -# The SDK image is pinned by proton-ge's own makefile, per tag. Asking it keeps -# the patch step below and the build on the same image. -SDK_IMAGE="$(make --silent --no-print-directory -f "${SRC}/Makefile.in" \ - SRCDIR="${SRC}" get-steamrt-image)" - -# ── Patch ─────────────────────────────────────────────── -# The patch script edits the tree in place and is not idempotent: it resets -# some submodules first and not others. So a tree is patched once, and one that -# was interrupted halfway is reset to the commits the tag pins before trying -# again. -# -# It is run in the SDK image rather than on the host, so it does not depend on -# the host's python, patch or wget. -# -# The script carries on past a patch that does not apply and exits 0 anyway. -# The upstream instructions are to grep its output for failures, so that is -# what happens here. The alternative is an image that looks fine and is missing -# a fix. -# -# A build tree does not survive its source being re-patched. Changing -# Makefile.in re-syncs every component's source copy, but a component's -# configure step depends on that sync order-only, so it does not rerun, and its -# old build directory is left pointing at generated autotools files the sync -# just removed. So patching starts obj/ over too. ccache keeps that cheap. -if [[ ! -e "${STAMP_PATCHED}" ]]; then - rm -rf "${OBJ}" - git -C "${SRC}" reset -q --hard - git -C "${SRC}" submodule foreach -q --recursive 'git reset -q --hard && git clean -qfdx' - "${ENGINE}" run --rm -v "${SRC}:${SRC}" -w "${SRC}" "${SDK_IMAGE}" \ - ./patches/protonprep-valve-staging.sh 2>&1 | tee "${PROTON_WORK}/patch.log" - if grep -Ei 'hunk .* failed|saving rejects|can.t find file|malformed patch|skipping patch|^error' \ - "${PROTON_WORK}/patch.log"; then - echo "proton: patches did not apply cleanly, see ${PROTON_WORK}/patch.log" >&2 - exit 1 - fi - # Ours go on top. They are paths from the root of the tree, submodules - # included. `git apply` fails outright on a patch that no longer applies, - # which is what a tag bump should do: each one says why it exists, so the - # question is only whether upstream fixed it. - for p in "${PATCH_DIR}"/*.patch; do - [[ -e "$p" ]] || continue - echo "proton: applying $(basename "$p")" - git -C "${SRC}" apply "$p" +# ── Toolchain wrappers ────────────────────────────────── +# Proton's build calls the compiler by GNU triplet. Arch's gcc does not install +# under those names, so stand in for them. The i686 set is generated too: with +# wow64 nothing should reach for it, and if something does, failing on a missing +# 32-bit header beats silently building a 32-bit unix library we then have to +# ship libraries for. +WRAP=/build/wrappers +rm -rf "$WRAP" && mkdir -p "$WRAP" +_wrappers() { + local arch="$1" gccflag="$2" ldflag="$3" asflag="$4" stripfmt="$5" + local l t + for l in ar ranlib nm; do + ln -sf "/usr/bin/gcc-${l}" "${WRAP}/${arch}-pc-linux-gnu-${l}" done - touch "${STAMP_PATCHED}" -fi - -# ── Configure ─────────────────────────────────────────── -# configure.sh refuses an in-tree build, and it test-runs the SDK image to work -# out how the engine maps file ownership, so it is also where a broken engine -# setup shows up first. -mkdir -p "${OBJ}" -if [[ ! -e "${OBJ}/Makefile" ]]; then - (cd "${OBJ}" && "${SRC}/configure.sh" \ - --build-name="${BUILD_NAME}" \ - --container-engine="${ENGINE}") -fi + for t in gcc g++; do + printf '#!/usr/bin/bash\n/usr/bin/%s %s "$@"\n' "$t" "$gccflag" \ + > "${WRAP}/${arch}-pc-linux-gnu-${t}" + chmod 755 "${WRAP}/${arch}-pc-linux-gnu-${t}" + done + printf '#!/usr/bin/bash\n/usr/bin/ld %s "$@"\n' "$ldflag" > "${WRAP}/${arch}-pc-linux-gnu-ld" + printf '#!/usr/bin/bash\n/usr/bin/as %s "$@"\n' "$asflag" > "${WRAP}/${arch}-pc-linux-gnu-as" + printf '#!/usr/bin/bash\n/usr/bin/strip -F %s "$@"\n' "$stripfmt" > "${WRAP}/${arch}-pc-linux-gnu-strip" + chmod 755 "${WRAP}/${arch}-pc-linux-gnu-"{ld,as,strip} +} +_wrappers x86_64 "-m64" "-melf_x86_64" "--64" "elf64-x86-64" +_wrappers i686 "-m32" "-melf_i386" "--32" "elf32-i386" +export PATH="${WRAP}:${PATH}" # ── Build ─────────────────────────────────────────────── -# ARCHS drops i386-unix, which leaves wine configured for x86_64 unix with an -# i386 PE side. That is wow64. Every component rule is gated on ARCHS, so the -# 32-bit unix builds of everything else go with it. ENABLE_WOW64 makes the -# proton script ask wine for a wow64 prefix. proton-ge ships it as a switch -# but never turns it on. -# -# A command-line variable reaches the container build too: the outer make -# hands its overrides to the inner one. -# -# SOURCE_DATE_EPOCH is the tag's commit time rather than now, so two builds of -# one tag stamp the same dates into their output. -make -C "${OBJ}" \ - J="${JOBS}" \ - ARCHS="i386-windows x86_64-windows x86_64-unix" \ - ENABLE_WOW64=1 \ - SOURCE_DATE_EPOCH="$(git -C "${SRC}" log -1 --format=%ct)" \ - dist +# -march=nocona matches the distro packaging: Proton has to run on whatever CPU +# the guest is given, and the VMM does not promise a feature level. +export CFLAGS="-O3 -march=nocona -mtune=core-avx2" +export CXXFLAGS="${CFLAGS}" +export RUSTFLAGS="-C opt-level=3 -C target-cpu=nocona" +export LDFLAGS="-Wl,-O1,--sort-common,--as-needed" +export RUSTUP_TOOLCHAIN=stable -echo "proton: built ${OBJ}/dist" +mkdir -p "${BUILD_DIR}" +cd "${BUILD_DIR}" + +ROOTLESS_CONTAINER="" \ +"${SRC_DIR}/configure.sh" \ + --container-engine="none" \ + --proton-sdk-image="" \ + --build-name="${BUILD_NAME}" \ + --without-extras=all \ + --without-vklayers=all \ + --without-steamrt-depends \ + --without-tts \ + --without-nvidia-libs \ + --enable-wow64 + +# The top-level make is serial by design; SUBJOBS is what it hands to each +# component's build. +SUBJOBS="${JOBS}" make -j1 dist + +# ── Install ───────────────────────────────────────────── +mkdir -p "${OUT_DIR}" +cp -a "${BUILD_DIR}/dist/." "${OUT_DIR}/" + +# Debug symbols in the bundled PE runtimes are dead weight in a guest image. +cd "${OUT_DIR}/files" +find "share/wine/gecko/wine-gecko-${GECKO_VER}-x86" -name '*.dll' -o -name '*.exe' 2>/dev/null \ + | xargs -r i686-w64-mingw32-strip --strip-debug 2>/dev/null || true +find "share/wine/gecko/wine-gecko-${GECKO_VER}-x86_64" -name '*.dll' -o -name '*.exe' 2>/dev/null \ + | xargs -r x86_64-w64-mingw32-strip --strip-debug 2>/dev/null || true +find "share/wine/mono/wine-mono-${MONO_VER}" -name '*.dll' -o -name '*.exe' 2>/dev/null \ + | xargs -r i686-w64-mingw32-strip --strip-debug 2>/dev/null || true + +rm -rf "${BUILD_DIR}" +echo "proton: installed to ${OUT_DIR}" diff --git a/build/scripts/proton-fetch.sh b/build/scripts/proton-fetch.sh new file mode 100755 index 00000000..3b0cfad4 --- /dev/null +++ b/build/scripts/proton-fetch.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# Fetches proton-cachyos' source and its bundled runtimes. Container-only. +# +# Deliberately its own script, and its own layer: the submodule checkout runs +# well past ten minutes, and it must not be redone every time a build flag or a +# missing dependency changes. Keep everything that can fail *fast* in +# proton-build.sh instead. +set -euo pipefail + +: "${PROTON_GIT:?}" +: "${PROTON_TAG:?}" +: "${GECKO_VER:?}" +: "${MONO_VER:?}" +: "${XALIA_VER:?}" + +SRC_DIR="/build/proton-cachyos" + +git clone --branch "${PROTON_TAG}" --depth=1 "${PROTON_GIT}" "${SRC_DIR}" +cd "${SRC_DIR}" +# Relative submodule paths resolve against origin, so it has to be the real URL +# even though we cloned by tag. +git remote set-url origin "${PROTON_GIT}" +# No --depth here: submodules are pinned to commits that are often not a branch +# tip. --filter=tree:0 keeps the download down instead. +git submodule update --init --filter=tree:0 --recursive + +# Still needed with wow64: these are PE-side, and a 32-bit Windows program wants +# the 32-bit gecko and mono regardless of how wine is built. +mkdir -p contrib +for url in \ + "https://dl.winehq.org/wine/wine-gecko/${GECKO_VER}/wine-gecko-${GECKO_VER}-x86.tar.xz" \ + "https://dl.winehq.org/wine/wine-gecko/${GECKO_VER}/wine-gecko-${GECKO_VER}-x86_64.tar.xz" \ + "https://github.com/madewokherd/wine-mono/releases/download/wine-mono-${MONO_VER}/wine-mono-${MONO_VER}-x86.tar.xz" \ + "https://github.com/madewokherd/xalia/releases/download/xalia-${XALIA_VER}/xalia-${XALIA_VER}-net48-mono.zip" \ +; do + curl -fL --retry 3 -o "contrib/$(basename "$url")" "$url" +done + +# Proton's cargo rule runs `cargo build --locked --offline`, so every crate has +# to be in CARGO_HOME before the build starts — including the git dependencies, +# which is what the "you are in the offline mode" failure is really saying. The +# error names a URL that is perfectly reachable; the build simply refuses to go +# out and get it. +# +# gst-plugins-rs is the only cargo component in the tree. Both targets are +# fetched: wow64 should mean nothing builds the i386 unix side, but a fetch is +# metadata only and costs almost nothing next to being wrong about that. +# +# CARGO_HOME is left at its default so it lands in this layer and the build +# layer inherits it. +export CARGO_NET_GIT_FETCH_WITH_CLI=true +export RUSTUP_TOOLCHAIN=stable +cd "${SRC_DIR}/gst-plugins-rs" +cargo fetch --locked --target x86_64-unknown-linux-gnu +cargo fetch --locked --target i686-unknown-linux-gnu + +echo "proton: source at ${SRC_DIR}"