From 36bbaa57fdb174f5630ee908fd184655e3b229cf Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:32:11 -0500 Subject: [PATCH] Launcher: read WRONGGPU_HIP_RUNTIME only in test builds The HIP runtime check took the developer-only WRONGGPU_HIP_RUNTIME setting in release builds too, so a leftover value on a PC could change which HIP library an install recorded. Only a WRONGGPU_TESTING build reads it now; a release build searches System32, PATH, the ROCm folders and HIP_PATH as before. Test: wg-core points the variable at a stand-in file (nothing is loaded): a testing build tries it first, a release build never names it. Fixes #25 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/installer/README.md | 2 +- clean/installer/src/wg_core/checks.cpp | 9 ++++++--- clean/installer/tests/wg_core_tests.cpp | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/clean/installer/README.md b/clean/installer/README.md index afb7ddc1..b0871357 100644 --- a/clean/installer/README.md +++ b/clean/installer/README.md @@ -178,7 +178,7 @@ With the defaults nothing of this section changes the installer. architecture from HIP's device properties and creates a context on a supported one: `gfx1201` (RX 9070 family); `gfx1200` (RX 9060 family) is reported as not supported yet (one line, `kSupportedArch`, when the owner decides). Search order: System32 (installed by the AMD Software: Adrenalin Edition driver), the PATH folders, the newest - `C:\Program Files\AMD\ROCm\\bin`, `HIP_PATH`; `WRONGGPU_HIP_RUNTIME` overrides it (development). The child + `C:\Program Files\AMD\ROCm\\bin`, `HIP_PATH`; `WRONGGPU_HIP_RUNTIME` overrides it in a `WRONGGPU_TESTING` build only (development; since 0.6.1). The child runs without `LLVM_PATH`. On failure the player is pointed to AMD's driver page (https://www.amd.com/en/support/download/drivers.html), the HIP SDK only as a second option. No SDK is needed. - **Model file (bring your own).** Candidates in this order: a file the player picks (`Model file...` / `/MODEL=`), diff --git a/clean/installer/src/wg_core/checks.cpp b/clean/installer/src/wg_core/checks.cpp index 23c0c7b1..bc51a1d4 100644 --- a/clean/installer/src/wg_core/checks.cpp +++ b/clean/installer/src/wg_core/checks.cpp @@ -61,7 +61,8 @@ GpuInfo DetectGpu() { // The AMD HIP runtime (amdhip64_7.dll) the clean runtime loads (spec 30 answer 7): from the system search path first // (System32, where the AMD Software: Adrenalin Edition driver installs it; then the PATH folders), then the newest -// C:\Program Files\AMD\ROCm\\bin (HIP SDK), then HIP_PATH. WRONGGPU_HIP_RUNTIME overrides (development). +// C:\Program Files\AMD\ROCm\\bin (HIP SDK), then HIP_PATH. WRONGGPU_HIP_RUNTIME overrides (development; read +// only by a WRONGGPU_TESTING build). const wchar_t* const kHipDll = L"amdhip64_7.dll"; const wchar_t* const kDriverPage = L"https://www.amd.com/en/support/download/drivers.html"; const char* const kSupportedArch[] = {"gfx1201", "gfx1200"}; // RDNA 4: the RX 9070 family and the RX 9060 family @@ -103,9 +104,11 @@ std::vector HipCandidates() { } return c; } -#endif - wstring env = EnvVar(L"WRONGGPU_HIP_RUNTIME"); + // 0.6.1: the development override only in a WRONGGPU_TESTING build; a release build never reads it (a developer's + // mock HIP library set at install time was recorded in hip-runtime.txt) + const wstring env = EnvVar(L"WRONGGPU_HIP_RUNTIME"); if (!env.empty()) c.push_back(env); +#endif wchar_t sys[MAX_PATH]; if (GetSystemDirectoryW(sys, MAX_PATH)) c.push_back(Join(sys, kHipDll)); wstring path = EnvVar(L"PATH"); diff --git a/clean/installer/tests/wg_core_tests.cpp b/clean/installer/tests/wg_core_tests.cpp index 0ed749ac..293edd1b 100644 --- a/clean/installer/tests/wg_core_tests.cpp +++ b/clean/installer/tests/wg_core_tests.cpp @@ -58,6 +58,29 @@ int main() { // VersionLess (the launcher's start, Update due, the update check, ROCm folders): a pre-release before its release require(VersionLess(L"0.6.1-rc1", L"0.6.1") && !VersionLess(L"0.6.1", L"0.6.1-rc1"), "VersionLess: 0.6.1-rc1 < 0.6.1"); require(VersionLess(L"0.6.0", L"0.6.1-rc1") && !VersionLess(L"0.6.1-rc1", L"0.6.0"), "VersionLess: 0.6.0 < 0.6.1-rc1"); + // 0.6.1: WRONGGPU_HIP_RUNTIME (the development override of the HIP runtime search) is read only by a WRONGGPU_TESTING + // build. The candidate list only names files that exist (nothing is loaded): a few bytes of text stand in for the + // library in the test's own temp folder; the test's variables are put back afterwards. + { + const wstring savedHip = EnvVar(L"WRONGGPU_HIP_RUNTIME"), savedMocks = EnvVar(L"WRONGGPU_TEST_HIP_CANDIDATES"); + const wstring hipDir = TempFolder(), fake = Join(hipDir, L"amdhip64_7.dll"); + if (FILE* f = _wfopen(fake.c_str(), L"wb")) { std::fputs("not a HIP runtime (wg-core-tests)", f); std::fclose(f); } + require(IsFile(fake), "HIP search: the stand-in file is there"); + SetEnvironmentVariableW(L"WRONGGPU_TEST_HIP_CANDIDATES", nullptr); + SetEnvironmentVariableW(L"WRONGGPU_HIP_RUNTIME", fake.c_str()); + const std::vector cands = HipCandidates(); + bool named = false; + for (auto& c : cands) named = named || IEq(c, fake); + SetEnvironmentVariableW(L"WRONGGPU_HIP_RUNTIME", savedHip.empty() ? nullptr : savedHip.c_str()); + SetEnvironmentVariableW(L"WRONGGPU_TEST_HIP_CANDIDATES", savedMocks.empty() ? nullptr : savedMocks.c_str()); + RemoveTree(hipDir); +#ifdef WRONGGPU_TESTING + require(!cands.empty() && IEq(cands[0], fake), "HIP search: a testing build tries WRONGGPU_HIP_RUNTIME first"); +#else + require(!named, "HIP search: a release build never reads WRONGGPU_HIP_RUNTIME"); +#endif + (void)named; + } require(VersionLess(L"0.6.1-rc2", L"0.6.1-rc10") && VersionLess(L"0.6.1-beta2", L"0.6.1-rc1") && !VersionLess(L"0.6.1-rc1", L"0.6.1-rc1"), "VersionLess: two pre-releases by their words, then their numbers"); require(!VersionLess(L"v0.6.1", L"0.6.1") && !VersionLess(L"0.6.1", L"v0.6.1") && VersionLess(L"v0.6.0", L"0.6.1"), "VersionLess: a leading v doesn't count");