Skip to content

Fix missing propagation of defines during build time#4245

Open
atobiszei wants to merge 4 commits into
mainfrom
atobisze_build_fixes
Open

Fix missing propagation of defines during build time#4245
atobiszei wants to merge 4 commits into
mainfrom
atobisze_build_fixes

Conversation

@atobiszei
Copy link
Copy Markdown
Collaborator

@atobiszei atobiszei commented May 27, 2026

PYTHON_DISABLE and MEDIAPIPE_DISABLE preprocessor macros were not reliably propagated to all translation units that needed them. The previous approach used copts (-DPYTHON_DISABLE=1) or local_defines on individual targets in BUILD files. Both mechanisms are non-transitive in Bazel — they only apply to the target they're defined on, not to its dependents, so if header used them, and other bazel target included this header but by itself did not rely on those ifdefs it was missing them.

JIRA:CVS-187417

atobiszei added 3 commits May 25, 2026 17:40
…E_DISABLE

Replace per-target copts/local_defines with transitive defines propagated via
ovms_cc_library macro. All dependents automatically get correct preprocessor
state without per-target configuration.

- Add COMMON_DEFINES (select-based) to ovms_cc_library defines field
- Remove COPTS_PYTHON, COPTS_MEDIAPIPE from src/BUILD
- Clean up LOCAL_DEFINES_TESTS to only contain SPDLOG
- Move rerank_api_handler and embeddings_handler_tests into mediapipe select
- Remove additional_local_defines from src/llm/BUILD, src/mediapipe_internal/BUILD,
  src/graph_export/BUILD
Copilot AI review requested due to automatic review settings May 27, 2026 08:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes preprocessor macro propagation in the Bazel build. PYTHON_DISABLE and MEDIAPIPE_DISABLE were previously injected via per-target additional_copts (COPTS_PYTHON, COPTS_MEDIAPIPE), which are non-transitive — dependents that included headers using those #if guards (e.g. servable.hpp, modelmanager.hpp, logging.hpp, http_graph_executor_impl.hpp) could see different macro values than the library that exported them. The fix moves the macros into the Bazel defines attribute on ovms_cc_library, making them transitive to all dependents.

Changes:

  • Add COMMON_DEFINES (built from new LOCAL_DEFINES_PYTHON / LOCAL_DEFINES_MEDIAPIPE selects) and have ovms_cc_library default defines = COMMON_DEFINES; add additional_local_defines plumbing.
  • Remove COPTS_PYTHON / COPTS_MEDIAPIPE and all additional_copts = COPTS_PYTHON + COPTS_MEDIAPIPE usages from src/BUILD, src/llm/BUILD, src/mediapipe_internal/BUILD, and src/graph_export/BUILD.
  • In src/BUILD, introduce LOCAL_DEFINES_TESTS and apply it consistently to all native cc_library/cc_test test helpers; also move rerank_api_handler and embeddings_handler_tests into the not_disable_mediapipe branch of ovms_test srcs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
common_settings.bzl Replaces non-transitive COPTS_PYTHON/COPTS_MEDIAPIPE with LOCAL_DEFINES_PYTHON/LOCAL_DEFINES_MEDIAPIPE, exposes them via COMMON_DEFINES, and updates ovms_cc_library to propagate them through defines.
src/BUILD Drops COPTS_PYTHON/COPTS_MEDIAPIPE usages, defines LOCAL_DEFINES_TESTS, and applies it to all test libraries; reorganizes mediapipe-only test deps in ovms_test.
src/llm/BUILD Removes COPTS_PYTHON import and all additional_copts = COPTS_PYTHON lines now that the macro is transitive.
src/mediapipe_internal/BUILD Removes COPTS_PYTHON/COPTS_MEDIAPIPE import and per-target additions.
src/graph_export/BUILD Removes COPTS_MEDIAPIPE import and additional copts.

Comment thread common_settings.bzl Outdated
@atobiszei atobiszei force-pushed the atobisze_build_fixes branch from 73e5214 to 633489b Compare May 29, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants