Repository navigation
Commit 5428ec8
Fix Windows MSVC Debug build of XNNPACK and clang-cl kernel gating
Summary:
Building any Debug preset with XNNPACK enabled under the MSVC toolset fails to
compile backends/xnnpack/third-party/XNNPACK/src/subgraph.c. XNNPACK nests two
variadic macros: XNN_RETURN_IF_ERROR expands to xnn_log_error, which in turn
concatenates a location suffix onto its first parameter. MSVC's default legacy
preprocessor forwards the outer __VA_ARGS__ into the inner macro as a single
un-split argument, so the suffix is glued onto the last format argument rather
than the format string, producing "syntax error: missing ')' before 'string'".
Only the three call sites that pass a format string plus format arguments are
affected. Release builds escape it because XNN_LOG_LEVEL is 0 outside of Debug,
which makes xnn_log_error expand to nothing, and that is why the Release-only
windows-msvc CI job never caught this. Enable /Zc:preprocessor for XNNPACK when
the compiler is genuine MSVC.
The same investigation turned up a second problem. The llm preset disables the
quantized and LLM kernels on Windows whenever the MSVC variable is set, but
CMake also sets MSVC for clang-cl, so those kernels were being dropped from
clang-cl builds while the accompanying warning told the user to switch to
-T ClangCL in order to get them. That contradicts the stated intent of pytorch#15719,
so the check now keys off CMAKE_CXX_COMPILER_ID instead.
Fixes pytorch#22084.
Test Plan:
On Windows with VS 2022 (MSVC 19.43), configured with the default MSVC toolset
and built the xnnpack-subgraph target in Debug. Before the change the build
fails with C2143/C2059 at subgraph.c lines 2663, 2918 and 3500, matching the
issue report exactly; after the change it succeeds and produces
xnnpack-subgraph.lib. Separately compiled all 96 XNNPACK logic-layer sources
with XNN_LOG_LEVEL=5 both with and without /Zc:preprocessor to confirm the flag
introduces no new diagnostics.
Verified that cmake --preset llm-debug still disables the quantized and LLM
kernels and warns under MSVC, and now enables them under -T ClangCL, where
custom_ops, quantized_kernels and quantized_ops_lib all build clean.
Reviewers:
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent c4eb0ea commit 5428ec8
2 files changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
0 commit comments