Add centralized flag system for TheRock#3831
Open
stellaraccident wants to merge 2 commits intomainfrom
Open
Conversation
Introduces a central flag registry (FLAGS.cmake) with automated variable
and preprocessor define propagation to subprojects. Flags are declared
with therock_declare_flag() and controlled via THEROCK_FLAG_{NAME} cache
variables.
Key capabilities:
- GLOBAL_CMAKE_VARS/GLOBAL_CPP_DEFINES propagated to all subprojects
- CMAKE_VARS/CPP_DEFINES scoped to specific subprojects via SUB_PROJECTS
- BRANCH_FLAGS.cmake support for integration branch default overrides
- Flag states recorded in therock_manifest.json via flag_settings.json
- End-of-configure report of all flag states
Migrates THEROCK_KPACK_SPLIT_ARTIFACTS to THEROCK_FLAG_KPACK_SPLIT_ARTIFACTS
as the first flag. Removes THEROCK_KPACK_DIR cache variable (hardcoded to
rocm-systems/shared/kpack path). The manual -DROCM_KPACK_ENABLED=ON
forwarding to hip-clr is now handled by the flag system's CMAKE_VARS.
Changes:
- New: cmake/therock_flag_utils.cmake (declare, finalize, report, override)
- New: FLAGS.cmake (central flag declarations)
- New: docs/development/flags.md (documentation)
- Modified: cmake/therock_subproject.cmake (2-line flag injection hook)
- Modified: CMakeLists.txt (include FLAGS.cmake, remove old KPACK defs)
- Modified: core/CMakeLists.txt (remove manual ROCM_KPACK_ENABLED forwarding)
- Modified: base/CMakeLists.txt (rename flag, pass settings to aux-overlay)
- Modified: cmake/therock_artifacts.cmake (rename flag, hardcode kpack path)
- Modified: build_tools/generate_therock_manifest.py (--flag-settings arg)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
stellaraccident
commented
Mar 7, 2026
cmake/therock_flag_utils.cmake
Outdated
| endif() | ||
|
|
||
| # Create cache variable. | ||
| set(THEROCK_FLAG_${ARG_NAME} "${ARG_DEFAULT_VALUE}" CACHE BOOL "${ARG_DESCRIPTION}") |
Collaborator
Author
There was a problem hiding this comment.
Stash the default value in a property and don't manipulate the CACHE vars here. Then in the override function, just update the property. Do all global/cache manipulation in finalize in order to avoid set-ordering fiascos.
therock_declare_flag() now only stores metadata in global properties (including the default value). therock_override_flag_default() only updates the stored default property. All cache variable creation and global state manipulation happens in therock_finalize_flags(), avoiding set-ordering issues between declare and override calls. Co-Authored-By: Claude <[email protected]>
Collaborator
Author
|
Reviewers: I've already done a detailed review and applied one round of feedback. More welcome, but this LGTM. |
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
FLAGS.cmake) with automated CMake variable and C preprocessor define propagation to subprojectstherock_declare_flag()and controlled viaTHEROCK_FLAG_{NAME}cache variablesBRANCH_FLAGS.cmakefor integration branches to override flag defaultstherock_manifest.jsonTHEROCK_KPACK_SPLIT_ARTIFACTS→THEROCK_FLAG_KPACK_SPLIT_ARTIFACTSas the first flagTHEROCK_KPACK_DIRcache variable (hardcoded to rocm-systems path)docs/development/flags.mdTest plan
cmake -B build -S . -GNinja -DTHEROCK_AMDGPU_FAMILIES=gfx1201— flag defaults OFF, no kpack targetscmake ... -DTHEROCK_FLAG_KPACK_SPLIT_ARTIFACTS=ON— rocm-kpack included,ROCM_KPACK_ENABLED=ONinjected into hip-clr_init.cmakeflag_settings.jsongenerated in build dir with correct flag statesBRANCH_FLAGS.cmakewiththerock_override_flag_default(KPACK_SPLIT_ARTIFACTS ON)overrides default and logs message🤖 Generated with Claude Code