Add x86_64 (64-bit) build support#39
Open
moonexpr wants to merge 8 commits into
Open
Conversation
Generalize the build from x86-only to a multi-arch (x86 + x86_64) configure, following the modern AlliedModders pattern, so the extension can be built for 64-bit srcds (e.g. 64-bit Team Fortress 2). Build system: - configure.py: --target -> --targets (comma-separated arch list). - AMBuildScript: dict-form platformSpec + SDK.shouldBuild(); per-arch all_targets loop; drop hardcoded -m32 / /MACHINE:X86; add -fPIC and COMPILER_MSVC64 for x86_64; bump to C++17; modernize gcc version gates (cxx.family + vendor-prefixed versions) so -Wno-unused-result etc. apply. - Add the tf2 SDK (WinLinux64); sdk2013 stays x86-only as it ships no lib/public/linux64 tier libs. - PackageScript: route x86_64 binaries to extensions/x64/ (SM 1.12 convention). - Extension/AMBuilder: build one binary per (sdk, arch); pick the arch-appropriate libsteam_api.so (linux64 / win64 steam_api64.lib). Detours (the only x86-specific code): - Drop the bundled 32-bit CDetour + asm trampolines and build against SourceMod's safetyhook-based public/CDetour, compiling safetyhook from the copy SourceMod bundles. safetyhook provides x86_64 inline hooks. - Re-provide the DETOUR_CREATE_STATIC_FIXED macro SM dropped (the underlying CreateDetour(void*) overload still exists). SDK currency: - ISteamGameServer::ForceHeartbeat() was removed from the public Steamworks SDK (heartbeats are now automatic); make the sm_ForceHeartbeat native a no-op so existing plugins keep loading. Builds clean for linux x86_64 against hl2sdk-tf2 + SourceMod 1.12.
The Steam API library path was hardcoded to the 32-bit "./bin/libsteam_api.so" layout, which is not guaranteed to exist on a 64-bit srcds. Discover the actually-loaded library via dl_iterate_phdr so the Steam interface creators resolve regardless of architecture / install layout, falling back to the old path and keeping the gamedata LibSteamAPI override. Adopts the runtime-discovery approach from bottiger1's prior 64-bit PR (KyleSanderson#38).
swtest.sp exercises the built extension by calling Steam natives that require the game-server interfaces to have resolved, so a build can be confirmed functional (not just loadable) on a live server. README documents the run.
The gcc arm already builds at -std=c++17 and the bundled safetyhook sub-build sets /std:c++17 for itself, but the global MSVC arm omitted it, so the extension translation units (which pull in the safetyhook-based CDetour headers, requiring C++17) would compile under MSVC's default C++14 and fail. Parity fix, MSVC-only.
Builds the extension on a [ubuntu-latest, windows-latest] matrix for both arches against hl2sdk-tf2 + SourceMod/Metamod 1.12, with the Steamworks SDK from the rlabrecque mirror; verifies the win64 import lib before linking.
A single vsdevcmd only puts one arch's cl.exe on PATH, so AMBuild could not build the x86_64 target (found x86 cl, errored on the arch mismatch). Set AMBUILD_VCVARS_X86 / AMBUILD_VCVARS_X86_64 to the vcvars32/vcvars64 scripts so AMBuild runs the matching one per target, building both arches in one job.
On modern AMBuild cxx.vendor does not equal 'msvc', so the entire MSVC flags
block (incl. /std:c++17) was skipped on Windows — MSVC then compiled the
safetyhook-based detour headers at its default C++14 and failed on std::optional.
Switch the vendor checks to cxx.like('msvc')/cxx.family (as the gcc arm and
webcon already do) so the MSVC flags actually apply.
- remove stale CI (.travis.yml and c-cpp.yml; superseded by ci.yml) - configure.py: default --sdks to "present" instead of "all" - rewrite README with a link to the SteamWorks.inc plugin API + build steps - ci: include the commit short SHA in the upload-artifact name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Team Fortress 2's dedicated server (and other Source games) now ship a 64-bit
srcds, and SourceMod 1.12 has matching 64-bit support — but SteamWorks onlybuilds for
x86, so it can't be loaded on a 64-bit server. This generalizes thebuild to multi-arch (
x86+x86_64), following the modern AlliedModderspattern (as used by e.g. sourcetvmanager), so a 64-bit
SteamWorks.ext.socanbe produced.
x86still builds exactly as before — no functional or API changefor existing users.
What changed
Build system
configure.py:--target→--targets(comma-separated arch list).AMBuildScript: dict-formplatformSpec+SDK.shouldBuild(); per-archall_targetsloop; drop hardcoded-m32//MACHINE:X86; add-fPICandCOMPILER_MSVC64forx86_64; bump to C++17; modernize the gcc version gates(
cxx.family+ vendor-prefixed versions) so-Wno-unused-resultet al.actually apply on a current gcc.
tf2SDK (WinLinux64).sdk2013staysx86-only because it ships nolib/public/linux64tier libs; 64-bit builds against a 64-bit-capable SDK(e.g.
-s tf2).buildbot/PackageScript: routex86_64binaries toaddons/sourcemod/extensions/x64/(SourceMod 1.12 convention).Extension/AMBuilder: build one binary per (sdk, arch); pick thearch-appropriate Steam API (
redistributable_bin/linux64/libsteam_api.so,win64/steam_api64.lib).Detours (the only genuinely x86-specific code)
CDetour+ hand-rolledasm/asm.ctrampolines cannot workon x86_64. Build against SourceMod's safetyhook-based
public/CDetour/detours.cppinstead, compiling safetyhook from the copy SourceMod bundles
(
public/safetyhook). safetyhook provides x86/x86_64 inline hooks.DETOUR_CREATE_STATIC_FIXEDconvenience macro SourceModdropped (the underlying
CreateDetour(void*)overload still exists).Steamworks SDK currency
ISteamGameServer::ForceHeartbeat()was removed from the public SteamworksSDK (master-server heartbeats are automatic now). The
ForceHeartbeatnativeis made a no-op so existing plugins keep loading.
Building
against the hl2sdk
tf2branch and SourceMod / Metamod1.12-dev.Validation
Built
x86+x86_64with gcc 13.3 against hl2sdk-tf2+ SourceMod 1.12. The64-bit
SteamWorks.ext.soloads on a live 64-bit TF2srcds(SourceMod1.12.0.7239):
The binary exports
GetSMExtAPI+CreateInterfaceand linkslibsteam_api.so.Exercised end-to-end with a test plugin calling SteamWorks natives — the Steam
game-server interfaces resolve and return correct live data on the 64-bit server:
(
connected/vac/IP match the server's real, Steam-registered state — provingthe interface resolution actually works, not just that the extension loads.)
A GitHub Actions workflow (also added here) builds the linux + windows ✕
x86 + x86_64 matrix green; AMBuild selects the per-arch MSVC toolchain via
AMBUILD_VCVARS_{X86,X86_64}. The Windows artifacts containSteamWorks.ext.dllfor bothextensions/(x86) andextensions/x64/(x86_64).Relationship to #38
This converges with @bottiger1's earlier 64-bit PR (#38), which had the right
shape — multi-arch
AMBuildScript, dropping the bundled 32-bitCDetour/asm,the
ForceHeartbeatchange, theDETOUR_CREATE_STATIC_FIXEDmacro, and runtimediscovery of
libsteam_api.so— but was left rough ("probably broke buildbot …do what you will with this") and never merged.
This PR is a clean, complete take on the same goal: it builds safetyhook from the
copy SourceMod bundles (so the detour layer actually links), produces both
x86and
x86_64, packages 64-bit binaries underextensions/x64/, and is validatedloading on a live 64-bit server. It adopts #38's
dl_iterate_phdr-basedlibsteam_api.sodiscovery (credited in the commit) so the Steam interfacecreators resolve regardless of install layout. Credit to @bottiger1 for the
original 64-bit work.
Packaging cleanup
Folded in alongside the x64 work is a small, self-contained packaging cleanup
(no interdependency with the build change):
.travis.ymland.github/workflows/c-cpp.yml, bothsuperseded by the
ci.ymladded here.configure.py --sdkstopresentrather thanall.(
Pawn/includes/SteamWorks.inc).upload-artifactname.Limitations / not yet verified
.dlls build in CI (x86 + x86_64, linkingsteam_api64.lib)but were not run on a live Windows server. Windows x64 gamedata byte-patterns,
if any are needed at runtime, are a separate concern.
libsteam_api.soruntime discovery was verified on a server wherebin/libsteam_api.sois also the loaded path; it was not tested on a layoutwhere the library lives elsewhere (which is the case the change is for).
1.12-dev; validated on SM 1.12.0.7239.