Skip to content

Fix Halide/HalideHelpers CMake package dependency inversion#9234

Open
alexreinking wants to merge 2 commits into
mainfrom
alexreinking/cmake-package
Open

Fix Halide/HalideHelpers CMake package dependency inversion#9234
alexreinking wants to merge 2 commits into
mainfrom
alexreinking/cmake-package

Conversation

@alexreinking

@alexreinking alexreinking commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Halide's installed CMake package previously depended on HalideHelpers, backwards from the intended cross-compiling story where a target-side build should load only the lightweight, arch-independent helpers and lazily pull
in the compiled compiler binaries only when actually needed. This PR swaps the roles:

  • Halide is now the always-available helpers package. find_package(Halide) never touches a compiled binary while cross-compiling unless the new JIT or Python component is explicitly requested.
  • HalideCompiler is the new name for the platform-specific compiled package that Halide (or add_halide_generator, etc.) can lazily load.

The static/shared preference recorded by Halide's static/shared components is a plain, directory-scoped variable, so independent find_package(Halide ...) calls in unrelated directories of the same project don't stomp on each other. HalideCompilerConfig.cmake detects a genuine conflict -- an explicit component that contradicts an already-recorded preference, or an ancestor directory that already loaded the other flavor -- and fails cleanly instead of silently keeping whichever flavor loaded first.

Also fixes two pre-existing, unrelated packaging bugs: a casing mismatch in the FlatBuffers pkgdep heuristic, and a missing CMAKE_MODULE_PATH entry for the bundled Halide_LLVM/V8 Find modules.

Adds test/integration coverage to testing-ecosystem.yml: shared + static + serialization builds, a real aarch64 cross-compile, a forced-JIT-without-compiler negative case, and independent per-directory static/shared selection including a conflict-detection negative case.

Fixes #7344
Fixes #7037

Test plan

  • test/integration suite passes locally (shared + static builds, JIT/AOT matrix, multi-directory static/shared independence and conflict-detection tests)
  • testing-ecosystem.yml CI workflow updated to build and exercise this surface (shared build, static+serialization build, cross-compile to aarch64, forced-JIT-without-compiler negative case)
  • tools/check_cmake_style.py and mdformat pass on all changed files

alexreinking and others added 2 commits July 22, 2026 15:59
Halide previously depended on HalideHelpers, backwards from the intended
cross-compiling story where a target-side build should load only the
lightweight, arch-independent helpers and lazily pull in the compiler
binaries only when actually needed. Swap the roles: Halide is now the
always-available helpers package (find_package(Halide) never touches a
compiled binary while cross-compiling unless the new JIT or Python
component is explicitly requested), and HalideCompiler is the new name
for the platform-specific compiled package it can lazily load.

The static/shared preference recorded by Halide's static/shared
components is a plain, directory-scoped variable, so independent
find_package(Halide ...) calls in unrelated directories of the same
project don't stomp on each other. HalideCompilerConfig.cmake detects
a genuine conflict -- an explicit component that contradicts an
already-recorded preference, or an ancestor directory that already loaded
the other flavor -- and fails cleanly instead of silently keeping whichever
flavor loaded first. An explicit static/shared request is also forwarded
as a real component into HalideConfig.cmake's own find_dependency(HalideCompiler)
call, since find_dependency() otherwise skips its underlying find_package()
call for arguments identical to an earlier call in the same directory
(or a descendant), and the preference variable alone isn't part of
those arguments -- without forwarding, that CMake-level optimization
would silently defeat the conflict detection above.

Also fixes two pre-existing, unrelated packaging bugs: a casing
mismatch in the FlatBuffers pkgdep heuristic, and a missing
CMAKE_MODULE_PATH entry for the bundled Halide_LLVM/V8 Find modules.

Adds test/integration coverage to testing-ecosystem.yml: shared +
static + serialization builds, a real aarch64 cross-compile, a
forced-JIT-without-compiler negative case, and independent
per-directory static/shared selection including a conflict-detection
negative case.

Fixes #7344
Fixes #7037

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@alexreinking alexreinking added the release_notes For changes that may warrant a note in README for official releases. label Jul 22, 2026
@alexreinking
alexreinking requested a review from shoaibkamil July 22, 2026 21:37
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@766b7f6). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9234   +/-   ##
=======================================
  Coverage        ?   70.25%           
=======================================
  Files           ?      255           
  Lines           ?    78929           
  Branches        ?    18879           
=======================================
  Hits            ?    55451           
  Misses          ?    17879           
  Partials        ?     5599           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexreinking
alexreinking requested a review from abadams July 23, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_notes For changes that may warrant a note in README for official releases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CMake package should lazy-load binaries Cross-compiling Halide pipelines in CMake builds should be much easier

1 participant