Windows HIP: setup and the package put the whole dependency closure of amdhip64_7.dll and amd_comgr.dll beside strata.exe, and the engine says why the bundled runtime did not load (#461)

amdhip64_7.dll imports rocm_kpack.dll, which imports the MSVC runtime. Only the two runtime DLLs were copied beside the exe, so a
full-path load of the bundled one failed with error 126, Windows fell back to System32's copy, and big prompts died with
hipErrorInvalidDeviceFunction (RX 7800 XT, gfx1101). The closure is now read from the PE import tables of the files in the zip
(tools/hip/dll_closure.py, no pefile), by setup.hip_runtime_beside_exe and tools/hip/package_windows.py. On the 0.1.40.2 HIP zip it is
amdhip64_7, amd_comgr, rocm_kpack, msvcp140, vcruntime140, vcruntime140_1. The engine, when the loaded runtime is not the one beside it,
also tries LoadLibraryEx on the bundled one and prints GetLastError. Diagnostic only. Not tested on a Windows AMD card.
This commit is contained in:
Niko1221 committed 2026-10-07 17:34:36 +02:00
1 parent 4dc544eda7
commit 4b3ff7a1b4
5 files changed
+327 -18

No files matched your search

+15 -1
View File
@@ -3972,11 +3972,25 @@ int main(int argc, char** argv) {
const size_t cut = beside.find_last_of("\\/");
beside = (cut == std::string::npos ? std::string() : beside.substr(0, cut + 1)) + "amdhip64_7.dll";
if (GetFileAttributesA(beside.c_str()) != INVALID_FILE_ATTRIBUTES &&
_stricmp(beside.c_str(), path) != 0)
_stricmp(beside.c_str(), path) != 0) {
std::fprintf(stderr, "strata generate: WARNING: the HIP runtime in use is not the bundled one beside "
"the engine (%s): if prompts fail with hipErrorInvalidDeviceFunction, tell the "
"maintainers with this log (#1261)\n",
beside.c_str());
// #461: why the bundled one lost. Its imports (rocm_kpack.dll and the C++ runtime) must be beside the
// exe too; LoadLibraryEx on it with the search limited to its own folder says what is missing (126 =
// a dependency). A diagnostic only: the copy it loads is released at once and nothing is forced.
SetLastError(0);
HMODULE probe = LoadLibraryExA(beside.c_str(), nullptr,
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
const DWORD le = probe != nullptr ? 0 : GetLastError();
if (probe != nullptr) FreeLibrary(probe);
std::fprintf(stderr, "strata generate: the bundled runtime beside the engine %s (GetLastError %lu)%s\n",
probe != nullptr ? "loads on its own" : "does NOT load", (unsigned long) le,
le == 126 ? ": a DLL it imports is missing from the engine's folder (rocm_kpack.dll, "
"msvcp140.dll, vcruntime140.dll, vcruntime140_1.dll); run START-HERE.bat "
"again (0.1.40.3 and later copy them)" : "");
}
}
}
}