build(hipdnn): probe the Windows resource compiler and fall back to rc.exe - #12198
Open
adickin-amd wants to merge 1 commit into
Open
adickin-amd wants to merge 1 commit into
adickin-amd wants to merge 1 commit into
Conversation
…c.exe Finding llvm-rc is not proof that resources compile. With a clang toolchain CMake compiles .rc files in two stages: preprocess with the C/C++ compiler, then hand the result to llvm-rc, which (LLVM >= 16) preprocesses it again. When the preprocessor emits line markers whose Windows path separators are unescaped, that second pass fails on the invalid escapes and floods stderr; cmake -E cmake_llvm_rc never drains the pipe, so llvm-rc blocks on a full pipe and the resource compile deadlocks with no output and no error. Probe the configured pipeline at configure time by compiling a probe resource under a timeout, and when it does not work fall back to rc.exe from the Windows Kits, which compiles .rc directly and has no preprocessing pass to break. When neither works, fail configuration naming the paths needed to fix it instead of silently dropping version metadata. The probe expands CMAKE_RC_COMPILE_OBJECT rather than hard-coding a command, so it tests whatever pipeline the build configured, and the verdict is cached against the pipeline it was made for so regeneration does not re-probe.
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
CMiservaAMD
approved these changes
Sep 16, 2026
tvy-amd
reviewed
Sep 16, 2026
| # 1. Compile a probe resource with the configured pipeline, under a timeout. | ||
| # 2. If that does not work, fall back to rc.exe from the Windows Kits, which compiles .rc directly | ||
| # and has no preprocessing pass to break. | ||
| # 3. If neither works, fail configuration with the paths needed to fix it. |
Contributor
There was a problem hiding this comment.
This does change the behaviour. It used to not fail if it cannot find the RC.
I think it's fine to do, but be careful as it may break other's machine if they don't have an llvm-rc or msvc rc.
tvy-amd
approved these changes
Sep 16, 2026
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
Windows resource compilation is probed at configure time instead of assumed. CMake's two-stage
llvm-rc rule deadlocks when the resource preprocessor emits line markers with unescaped path
separators, which stalls the build with no output and no error. hipDNN now compiles a probe resource
under a timeout, falls back to the Windows Kits
rc.exewhen the configured pipeline does not work,and fails configuration with actionable paths when neither works.
JIRA ID : ALMIOPEN-2632
Risk Assessment
Risk level 3. Windows-only configure-time logic, guarded by
if(NOT WIN32), so Linux builds areuntouched. It changes a failure mode on Windows: a host with no working resource compiler now fails
configuration instead of silently producing a DLL without VERSIONINFO metadata. The fallback also
switches the resource rule from two-stage llvm-rc to single-stage
rc.exe, which drops resourcedepfile tracking (
rc.exeemits none);.rcsources here include only stable SDK headers and thegenerated
backend.rcis re-created byconfigure_file, so the practical exposure is nil.ASIC Coverage
No ASIC impact. The change is host-side CMake configure logic that selects a Windows resource
compiler; it does not touch kernels, dispatch, defaults, or any support surface, and it compiles no
device code. Passing PR CI is sufficient; no specific-ASIC run or multi-arch sweep is required.
Testing Summary
deadlock (AMD clang 24.0.0git, nightly 10.2.0a20260916), covering all three resolution paths:
configured pipeline works, fallback to Windows Kits
rc.exe, and no usable resource compiler..cmake/CMakeLists.txt), which therepository has no unit-test harness for, and the PR bot's unit-test rule applies to source
extensions only.
Testing Checklist
cmake --preset hipdnn -B build -DROCM_PATH=<wheel> -DCMAKE_PROGRAM_PATH=<clang> -DGPU_TARGETS=gfx1151- Status: Passed (configure exit 0, warning names the cause,rc.exeadopted)cmake --build build --target hipdnn_backend --parallel 16- Status: Passed (hipdnn_backend.dllFileVersion0.3.0.3ca9ff7ff7)rc.exe)-DHIPDNN_WINDOWS_SDK_ROOT="C:/Program Files (x86)/Windows Kits/10"- Status: Passed-DHIPDNN_WINDOWS_SDK_ROOT="D:/no/such/windows/kit"- Status: Passed (configure exit 1, message names both remedies)-- hipDNN: resource compiler: ...llvm-rc.exe, two-stage rule retained)pre-commit run cmake-lint --files projects/hipdnn/cmake/ResourceCompiler.cmake projects/hipdnn/CMakeLists.txt projects/hipdnn/backend/src/CMakeLists.txt- Status: PassedTechnical Changes
projects/hipdnn/cmake/ResourceCompiler.cmake: compiles a probe.rc(which#includes<winver.h>, the header that drags in the problematic line markers) by expandingCMAKE_RC_COMPILE_OBJECT, so whatever pipeline the build configured is what gets tested. The proberuns under
execute_process(... TIMEOUT)rather thantry_compile, because the failure mode is adeadlock and
try_compilehas no timeout.line markers whose Windows path separators are unescaped, quoting the offending marker.
rc.exefrom the Windows Kits (%WindowsSdkDir%,%ProgramFiles(x86)%, then thedefault install locations; newest
10.*version,x64beforex86, only versions whoseInclude/<version>/um/winver.hexists). Adopting it also installs the single-stage rule, the SDKinclude directories
rc.execannot discover on its own, and clearsCMAKE_DEPFILE_FLAGS_RC.HIPDNN_WINDOWS_SDK_ROOT(cache PATH) to point the search at a specific Kit, andHIPDNN_RC_PROBE_TIMEOUT(cache STRING, default 60) to tune the deadlock timeout.FATAL_ERRORwhen no pipeline works, naming both remedies:-DHIPDNN_WINDOWS_SDK_ROOT=...with the required layout, or explicit-DCMAKE_RC_COMPILERplus-DCMAKE_RC_FLAGSinclude directories (forward slashes required — a backslash path makes CMakereject the generated
CMakeRCCompiler.cmakewithInvalid character escape).of re-probing.
projects/hipdnn/backend/src/CMakeLists.txt: drop the "no resource compiler, warn and skip"branch. Configuration now guarantees a working compiler, so the guard was dead code.