Skip to content

make_game.py: accept versioned LLVM tools for the Linux cross-build - #1273

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
kmorales13:fix/versioned-llvm-tools
Nov 22, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
kmorales13:fix/versioned-llvm-tools

Conversation

@kmorales13

Copy link
Copy Markdown
Contributor

Follow-up of #1229 (merged), for @whattheflop's review finding: on distributions that install LLVM under versioned names (clang-cl-21, lld-link-21, …, as Debian and Ubuntu do), preflight reported all five cross-build tools missing, so the Linux runtime stage was dropped from the default stages or refused.

  • Versioned names: preflight accepts the newest full set with one version suffix when the plain names aren't on PATH. It passes them to a new runtime/build/windows as the toolchain's CMAKE_<var> overrides (docs/testing.md). Mixed versions don't count.
  • Existing build folder: a runtime/build/windows whose cached CMAKE_CXX_COMPILER still exists needs no LLVM tools on PATH, and keeps what it was configured with.
  • Docs: the README and the missing-tools message name both forms.

Tested

CachyOS, AMD Ryzen 7 7700X iGPU (RDNA2, RADV Mesa 26.3.1), clang 23.1.5, CMake 4.5.1, Python 3.14.10. No game files.

  • The 11 make_game test scripts pass. The new tests cover the suffix pick, mixed versions, the cached compiler, and the overrides going only to a new build folder.
  • Real run with only clang-cl-23/lld-link-23/llvm-lib-23/llvm-rc-23/llvm-mt-23, cmake and make on PATH: preflight passed, the configure got all six overrides, and the build produced gta6rt.exe and gta6rt_tls_host.dll.
  • With that cache in place and no LLVM tools on PATH, preflight passed. Without the cache, it named the missing tools.

AI-assisted (Claude-Opus).

Distributions that install LLVM as clang-cl-21, lld-link-21 and so on (Debian,
Ubuntu) were reported as having none of the five tools, so the runtime stage
was dropped or refused. Preflight now accepts the newest full set with one
version suffix and passes it to a new build folder as the toolchain's
CMAKE_<var> overrides (docs/testing.md). A runtime/build/windows whose cached
compiler still exists needs no tools on PATH: it keeps what it was configured
with.
@kapitche

Copy link
Copy Markdown
Contributor

Tested 5e9f17c on Linux (WSL2 Ubuntu), Python 3.12, CPU only (no cross-build here): pass.

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted independent verification of 5e9f17c6b3367b3a823fcb4c7473e836a317081e against its direct parent e7584c5207e44ed51472e6aa05c781f39ea975f6. This resolves the compatibility gap I raised in my #1229 review.

  • On Ubuntu 26.04.1 WSL2 (system Python 3.14.4), the same process PATH with only -21 LLVM names passed runtime preflight at head. The parent exited 1, listed all five tools as missing, and created no work directory. A mixed -21/-20 set failed at head. An incomplete -22 set fell back to the complete -21 set, and a complete -22 set won once present.
  • For a fresh directory the CMake subprocess received -DCMAKE_C_COMPILER=clang-cl-21, -DCMAKE_CXX_COMPILER=clang-cl-21, -DCMAKE_LINKER=lld-link-21, -DCMAKE_AR=llvm-lib-21, -DCMAKE_RC_COMPILER=llvm-rc-21, and -DCMAKE_MT=llvm-mt-21. With an existing cache fixture pointing to executable tools by absolute path, preflight passed with all LLVM tools off PATH. Reconfigure passed zero tool overrides both with no LLVM on PATH and with a complete -22 set on PATH. Removing the cached compiler brought back the missing-tools error.
  • Native Windows, uv-managed CPython 3.12.13: all 11 focused test_make_game_*.py scripts passed on both commits (215 tests at head, 210 at parent). make_game.py --help passed on both Windows and WSL.

The WSL check used an SDK directory fixture, the installed LLVM 21 llvm-lib, llvm-rc, and llvm-mt, and executable stand-ins for the missing tools, including CMake. It exercised real PATH lookup and captured the configure subprocess arguments. The real cross-build was covered by the author's CachyOS run. This review used no game files, loader execution, or GPU.

CMake keeps a toolchain-chosen compiler in CMakeFiles/<version>/
CMakeCXXCompiler.cmake, not in CMakeCache.txt, so every runtime/build/windows
configured with the plain names went unrecognised: with only a versioned set
left on PATH, preflight passed and the build failed after the long stages.
Preflight now reads the configured tools from those files and requires each
to resolve, else it says to restore them or delete the folder.

The plain names win only when their clang-cl is 19 or newer, so an old default
no longer hides a complete newer versioned set. A mixed set names the missing
versioned tool. The overrides go to every configure until the folder records
its tools, which also covers a folder whose first configure failed.
@kmorales13

Copy link
Copy Markdown
Contributor Author

Thanks @kapitche and @whattheflop for verifying. An independent review of 5e9f17c found one more gap, fixed in the new commit:

  • Folders configured with the plain names went unrecognised. CMake keeps a toolchain-chosen compiler in CMakeFiles/<version>/CMakeCXXCompiler.cmake, not in CMakeCache.txt, so the cache check missed them. With only a versioned set left on PATH, preflight passed and the build failed after the long stages. Preflight now reads the tools from CMake's compiler files and requires each to resolve. Otherwise it says to restore them or delete runtime/build/windows.
  • Old plain names: they win only when their clang-cl is 19 or newer, so an LLVM 18 default no longer hides a complete -21 set.
  • Mixed sets: the message now names the missing versioned tool (e.g. llvm-mt-21).
  • Tool overrides: they go to every configure until the folder records its tools, which also covers a folder whose first configure failed.

Tested on CachyOS with clang 23:

  • Unit tests: the 11 make_game test scripts pass. New tests use CMake's real compiler-file format.
  • Real runs:
    • The plain-configured folder is read correctly.
    • With only -23 names on PATH, that folder is now reported instead of passing.
    • A fresh folder with only -23 names builds gta6rt.exe and gta6rt_tls_host.dll.
    • A second run on that folder passes from its recorded tools.

AI-assisted (Claude-Opus).

CMake keeps the archiver and resource compiler given on the command line as
bare names (CMAKE_AR=llvm-lib-23), so a build folder configured from a
versioned set still needed those names on PATH: once a static library had to
be archived again, the runtime stage failed. The overrides are now the
resolved paths, so every entry in the cache is absolute.
@kmorales13

Copy link
Copy Markdown
Contributor Author

A full review with real builds found one more gap, fixed in the latest commit. CMake keeps -DCMAKE_AR=llvm-lib-23 and -DCMAKE_RC_COMPILER=llvm-rc-23 as bare names in the cache, so a folder configured from a versioned set still needed them on PATH. A rebuild that had to re-archive a static library failed in the runtime stage. The overrides are now resolved full paths.

Tested by configuring with only the -23 names on PATH, deleting the folder's .lib files, and rebuilding with only cmake on PATH. All five tools are absolute in the cache, preflight passes, and gta6rt.exe and gta6rt_tls_host.dll rebuild. The 11 make_game test scripts pass.

AI-assisted (Claude-Opus).

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted follow-up at a65a039cfdaf9311b215d836710b93d3f13d3cdf to my earlier review. On Ubuntu WSL2, a complete LLVM 21 set in a directory with spaces won over plain LLVM 18. The recording CMake stand-in received six absolute, quote-free overrides, each as one argument. With CMake compiler/cache fixtures recording those paths and LLVM removed from PATH, preflight passed and reconfigure sent zero overrides. All 11 focused scripts passed on Windows with Python 3.12.13.

One remaining path case in cross_configure(): with the same executable set exposed through the valid relative PATH entry LLVM 21 tools, preflight passed and the subprocess received -DCMAKE_AR=LLVM 21 tools/llvm-lib-21 and five similarly relative overrides. Could the code make each shutil.which() result absolute before passing it to CMake, while preserving the tool basename? The WSL test recorded argv using stand-ins, so the relative-path observation is at the configure boundary.

@ItsNotRexed
ItsNotRexed merged commit 779aa4a into ItsNotRexed:main Nov 22, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants