Support multi-config generators in the SYCL CMake build#4370
Open
cyyever wants to merge 4 commits into
Open
Conversation
cyyever
marked this pull request as draft
July 17, 2026 04:23
cyyever
force-pushed
the
agent/buildflags-multiconfig-guard
branch
6 times, most recently
from
July 22, 2026 05:21
4829dc6 to
9a04e49
Compare
cyyever
marked this pull request as ready for review
July 22, 2026 05:28
The per-config host and kernel flags were chosen with
`if(CMAKE_BUILD_TYPE MATCHES ...)`, which is empty under multi-config
generators, so Debug/RelWithDebInfo builds silently got the release
flags. Spell them as $<CONFIG:> genexes instead: host flags go in
SYCL_HOST_PER_CONFIG_FLAGS and the DEBUG_XPU kernel option becomes a
genex too.
These genexes are needed only on the -fsycl-host-compiler-options path,
which is assembled from the base CMAKE_CXX_FLAGS and never sees
CMAKE_CXX_FLAGS_<CONFIG>. Because PyTorch unconditionally forces -O2 into
that base CMAKE_CXX_FLAGS, the GNU Debug flags override it back to -O0
while RelWithDebInfo only needs to add -g (dropping the -O2 that would
just duplicate the inherited one); MSVC keeps /O2 since PyTorch adds -O2
only for non-MSVC.
The regular host TUs, compiled through
target_compile_options(${lib} ${TORCH_XPU_OPS_FLAGS}), already receive
PyTorch's per-config flags from CMake: CMAKE_CXX_FLAGS_DEBUG carries
-fno-omit-frame-pointer/-O0, and MSVC_Z7_OVERRIDE swaps /Zi for /Z7. So
TORCH_XPU_OPS_FLAGS stays config-agnostic and does not re-add any of
them, which also stops it from fighting a user who turns MSVC_Z7_OVERRIDE
off. In the same vein, drop -Wunused-variable from SYCL_HOST_FLAGS: both
compile paths inherit PyTorch's base -Wall, which already implies it.
-fPIC stays (the device link extracts it from SYCL_HOST_FLAGS) and
-std=c++20 stays (the host-compiler path does not get CMAKE_CXX_STANDARD).
Test Plan:
```
lintrunner cmake/BuildFlags.cmake
```
Verified together with the FindSYCL change by building a driver project
under both Ninja (single-config) and Ninja Multi-Config.
Authored with Claude Code assistance.
FindSYCL object paths used the deprecated CMAKE_CFG_INTDIR, which stays "." under Ninja Multi-Config, so every configuration wrote to the same intermediate object and dependency files and collided. Add a per-config subdir and suffix, applied only under multi-config generators so the single-config layout (including the device link object) is unchanged. Same-named sources from different directories are now disambiguated by a short hash of their source directory embedded in the object name, replacing the removed SYCL_COMPUTE_BUILD_PATH mirrored-subdirectory scheme inherited from FindCUDA. Dependency bookkeeping expands to the per-config .depend files and the compile command depends on their union, and the per-config output directory is created before device linking. Test Plan: ``` lintrunner cmake/Modules/FindSYCL.cmake ``` Verified by building a driver project (fsycl-specific flags stubbed out) that links two same-named SYCL sources plus a host source, under both Ninja and Ninja Multi-Config (--config Debug and Release). Authored with Claude Code assistance.
The debug guard set USE_SYCLTLA OFF after SYCLTLA.cmake had already been included, so a debug build still pulled the include in. Fold the debug disable into the existing platform guard so USE_SYCLTLA is decided before the include; the later block then only forces BUILD_SEPARATE_OPS. Both key off CMAKE_BUILD_TYPE, which is a configure-time switch with no single answer across a multi-config config list; pytorch's Visual Studio flow exports CMAKE_BUILD_TYPE and builds --config to match, so that path is covered. Test Plan: ``` lintrunner CMakeLists.txt ``` Authored with Claude Code assistance.
cyyever
force-pushed
the
agent/buildflags-multiconfig-guard
branch
from
July 22, 2026 07:50
9a04e49 to
a41b658
Compare
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.
Multi-config generators (Ninja Multi-Config, Visual Studio) did not build correctly: per-config flags keyed off
CMAKE_BUILD_TYPE, which is empty under multi-config, and FindSYCL object paths used the deprecatedCMAKE_CFG_INTDIR, which stays.under Ninja Multi-Config so every configuration collided on the same outputs.Three commits, in review order:
$<CONFIG:>genexes.TORCH_XPU_OPS_FLAGSstays config-agnostic and defers to PyTorch's per-config flags (CMAKE_CXX_FLAGS_DEBUG,MSVC_Z7_OVERRIDE) instead of duplicating/fighting them.USE_SYCLTLAbefore itsinclude()so debug builds skip it.Authored with Claude Code assistance.