Skip to content

Build with llvm-mingw, smaller DLL, IDE setup, CI/CD on Linux - #47

Merged
3vcloud merged 14 commits into
masterfrom
build/llvm-mingw-bootstrap
Nov 27, 2026
Merged

3vcloud merged 14 commits into
masterfrom
build/llvm-mingw-bootstrap

Conversation

@3vcloud

@3vcloud 3vcloud commented Nov 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces the Visual Studio/vcpkg build with the GWToolbox approach: bootstrap.sh/bootstrap.bat, scripts/bootstrap.py, scripts/build.py, CMake presets, pinned CMake 4.4.4 and llvm-mingw.
  • Device-release crash fix: the teardown that releases fake textures now runs while the device is still alive (h_DeviceRelease).
  • Smaller DLL: stripped with split gMod.debug, --gc-sections/ICF, no exceptions (-fno-exceptions), std::regex/iostreams/locale removed.
  • CI builds on Linux and Windows. CD builds on Linux, signs with ssign + osslsigncode, publishes gzipped PDB/debug files.
  • IDE setup for CLion, Rider (Flatpak), VS Code and Visual Studio, ported from GWToolbox.

Before merging

The CD workflow publishes on every push to master. CMakeLists.txt still says 1.10.0, which is the existing v1.10.0.0 release, so the publish step would replace that release's assets. Bump the version before merging.

🤖 Generated with Claude Code

3vcloud and others added 14 commits November 27, 2026 16:18
Replace the Visual Studio/vcpkg-preset build with the GWToolbox approach:
bootstrap.sh and bootstrap.bat install the pinned llvm-mingw and vcpkg, then
scripts/build.py builds a CMake preset (relwithdebinfo, debug or release)
into build/<host>/<preset>/, with output in bin/.

- CMakePresets.json: base plus three build presets, on the same toolchain
  file and vcpkg triplet overlay as GWToolbox (i686 llvm-mingw, static CRT).
- C++ modules declared in FILE_SET CXX_MODULES, and import std enabled with
  the CMake 4.4 experimental UUID.
- directxtex comes from vcpkg; DDS/WIC texture loaders come from
  cmake/directxtexloader.cmake. D3DX9 links from llvm-mingw, not dxsdk-d3dx.
- Source fixes for clang: explicit void* casts for MinHook, the MSVC-only
  pragma guarded, the import std and header include paths corrected.
- The CI and release workflows still use MSVC and are not ported here.
h_DeviceRelease called the original Release first and only then, if the
device's refcount reached zero, deleted the TextureClient. The destructor
releases the fake textures gMod still owns, so those releases ran against a
device that D3D9 had already destroyed. Keep a reference across the game's
Release and run the teardown while the device is alive, then drop that
reference.
Pin CMake 4.4.4 in scripts/cmake.version and install it from Kitware with a
SHA-256 check. The import std experimental UUID in CMakeLists.txt belongs to
one CMake version, so the bootstrap, build and CI all use the pinned binary.

- ci.yaml: builds the release preset on Linux (ubuntu-24.04) and on Windows
  (windows-2025), with bootstrap and build.py. Uploads the binaries.
- cd.yaml: builds on Linux, carries d3dx9_43.dll forward from the latest
  release (MinGW does not produce it), signs gMod.dll and TpfConvert.exe with
  Certum SimplySign on Windows, then publishes the release from Linux.
- lint.yaml: formats the renamed TpfConvert/src/TpfConvert.cpp.
- scripts/version.py: reads the file version from CMakeLists.txt for CD.
Port the CD sign job from a Windows runner with SimplySign Desktop to
ubuntu-24.04, the way GWToolbox signs. ssign (pinned to v0.1.8 by SHA-256)
signs gMod.dll and TpfConvert.exe over Certum's cloud API with the existing
CERTUM_USERID and CERTUM_OTP_URI secrets, and osslsigncode verifies them
against CERTUM_CERT_SHA1 with a required timestamp (verify-certum.sh, copied
from GWToolbox). The SimplySign Desktop scripts are removed.

Signing stays gated on the Certum secrets, so forks and unconfigured repos
still publish unsigned binaries.
Match GWToolbox's post-build step: the DLL keeps DWARF until the link, then
llvm-objcopy writes it to gMod.debug and strips the DLL. The CodeView PDB is
unchanged.

Add --gc-sections and --icf=all outside Debug, as GWToolbox does. The
sections were already split per function and data item, but the link never
dropped the unused ones.

Release gMod.dll: 1,904,640 -> 1,356,800 bytes with gc-sections, before the
code changes in the next commit.
…ghter code

- ModfileLoader: the hash and texmod.def line regexes become exact hand-written
  parsers. They match the regexes' results on 300,000 generated inputs.
- utils::SplitLines and utils::ReadWholeFile replace istringstream, stringstream
  and ifstream, reading through the C runtime.
- TpfReader reads the whole file with _wfopen instead of std::ifstream.
- TextureFunction names the .dds file with snprintf instead of std::format.
- TextureClient no longer calls std::locale::global(std::locale("")). Nothing
  else in the DLL reads the global locale now. Needs a runtime check with
  non-ASCII modlist entries.

Release gMod.dll: 1,356,800 -> 1,021,952 bytes.
…exceptions

Remove every throw, try and catch from the DLL:
- utf8_to_wstring returns std::optional; an invalid modlist line is skipped
  with a warning instead of throwing out of LoadStartupModlists.
- TpfReader reports an unreadable file through IsOpen(), and GetTpfContents
  warns and returns no entries.
- std::filesystem calls use the error_code overloads. A path or file that
  cannot be read is treated as missing, which the callers already handled.
- ImageSave warns through the error code instead of a catch block.
- The exported functions return directly. Their catch-all blocks are gone,
  so a failure that used to become RETURN_FATAL_ERROR now aborts, except
  for the paths above.

Compile gMod with -fno-exceptions. Release gMod.dll: 1,021,952 -> 995,328
bytes. The unwind tables shrink too, but the libc++ and vcpkg code is still
built with exceptions, so the unwinder remains linked.
Match GWToolbox's release: gzip the PDB and the split debug file in the build
job, then attach gMod.pdb.gz and gMod.debug.gz to the release alongside the
DLL. The signing job passes the release directory through unchanged.
Port GWToolbox's IDE bootstrap to gMod:

- bootstrap/: CLion/Rider module file for Linux and Windows, and VS Code
  settings and extensions. The bootstrap copies them into .idea/ and .vscode/
  and backs up what it replaces.
- scripts/ide_setup.py: CMake profiles, Flatpak sandbox setup for CLion and
  Rider (host tools reached through .toolchain/host-tools/bin/host-tool, with
  the pinned CMake first), VS Code extensions, and stale lock cleanup. Lock
  cleanup is skipped while the IDE is running.
- scripts/vs_solution.py: writes gMod.slnx and the Visual Studio projects.
- scripts/build.py: --target, --clean and --rebuild for the Visual Studio
  build commands.
- scripts/bootstrap.py and bootstrap.sh/.bat: run the IDE steps, and refuse to
  run while CLion or Rider is open.

The GWToolbox-only parts are left out: the Linux launcher, the remote-debug
stub and the Docker build.
The Windows job failed for two reasons. pip's ninja lands in the Python
Scripts folder, which is not on the runner's PATH, so CMake could not find it.
And vcpkg's pkgconf download points at an msys2 package that the mirrors no
longer serve, so the directxmath build failed. Install ninja and pkgconf with
choco, and have vcpkg use the system binaries.
The Windows job still failed after the pkgconf fix. vcpkg picked a Visual
Studio generator for directxmath, which this mingw build does not use, so the
triplet now sets VCPKG_CMAKE_GENERATOR Ninja. And choco's ninja shim was not
on PATH for the bootstrap step, because the runner does not refresh PATH after
choco updates it. The install step now adds chocolatey\bin to GITHUB_PATH.
CI builds on Linux only. The Windows build is not run in CI.
@3vcloud
3vcloud merged commit 285c115 into master Nov 27, 2026
2 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.

1 participant