Skip to content

Add centralized flag system for TheRock#3831

Open
stellaraccident wants to merge 2 commits intomainfrom
users/stellaraccident/flag-system
Open

Add centralized flag system for TheRock#3831
stellaraccident wants to merge 2 commits intomainfrom
users/stellaraccident/flag-system

Conversation

@stellaraccident
Copy link
Collaborator

@stellaraccident stellaraccident commented Mar 7, 2026

Summary

  • Introduces a central flag registry (FLAGS.cmake) with automated CMake variable and C preprocessor define propagation to subprojects
  • Each flag is declared with therock_declare_flag() and controlled via THEROCK_FLAG_{NAME} cache variables
  • Supports BRANCH_FLAGS.cmake for integration branches to override flag defaults
  • Flag states are recorded in therock_manifest.json
  • Migrates THEROCK_KPACK_SPLIT_ARTIFACTSTHEROCK_FLAG_KPACK_SPLIT_ARTIFACTS as the first flag
  • Removes THEROCK_KPACK_DIR cache variable (hardcoded to rocm-systems path)
  • Documentation in docs/development/flags.md

Test plan

  • cmake -B build -S . -GNinja -DTHEROCK_AMDGPU_FAMILIES=gfx1201 — flag defaults OFF, no kpack targets
  • cmake ... -DTHEROCK_FLAG_KPACK_SPLIT_ARTIFACTS=ON — rocm-kpack included, ROCM_KPACK_ENABLED=ON injected into hip-clr _init.cmake
  • flag_settings.json generated in build dir with correct flag states
  • BRANCH_FLAGS.cmake with therock_override_flag_default(KPACK_SPLIT_ARTIFACTS ON) overrides default and logs message
  • CI configure passes with flag OFF (default)

🤖 Generated with Claude Code

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]>
endif()

# Create cache variable.
set(THEROCK_FLAG_${ARG_NAME} "${ARG_DEFAULT_VALUE}" CACHE BOOL "${ARG_DESCRIPTION}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@stellaraccident stellaraccident requested review from ScottTodd, amd-shiraz and marbre and removed request for ScottTodd and marbre March 7, 2026 01:17
@stellaraccident stellaraccident marked this pull request as ready for review March 7, 2026 01:18
@stellaraccident
Copy link
Collaborator Author

Reviewers: I've already done a detailed review and applied one round of feedback. More welcome, but this LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: TODO

Development

Successfully merging this pull request may close these issues.

1 participant