Skip to content

fix(meson): propagate HAVE_CUDA/HAVE_SYCL to 3 more static libs (ODR class follow-up to #840) - #842

Closed
lusoris wants to merge 1 commit into
masterfrom
fix/meson-3-libs-odr-cuda-sycl-defines
Closed

lusoris wants to merge 1 commit into
masterfrom
fix/meson-3-libs-odr-cuda-sycl-defines

Conversation

@lusoris

@lusoris lusoris commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to PR #840 which fixed the picture_pool_cpp23_lib ODR violation by adding explicit cpp_args propagating -DHAVE_CUDA/-DHAVE_SYCL. The deep audit found 3 MORE static libraries with the same ODR bug class:

  1. gpu_picture_pool_cpp23_lib (no cpp_args at all — same fix as picture_pool)
  2. libvmaf_feature_static_lib (c_args uses vmaf_cflags_common captured BEFORE -DHAVE_CUDA/SYCL append)
  3. cuda_static_lib (c_args uses vmaf_cflags_common captured before line 1841 append)

Root cause: the three vmaf_cflags_common += '-DHAVE_*' lines came AFTER the consuming static_library() declarations had already captured the list. Meson list appends are not retroactive.

Fix: (a) moved the 3 append lines BEFORE all consuming libraries — fixes #2 and #3 automatically; (b) added explicit cpp_args to gpu_picture_pool_cpp23_lib (mirrors #840 pattern).

Test plan

  • meson setup build-cuda -Denable_cuda=true && ninja -C build-cuda clean
  • meson test -C build-cuda --suite=fast PASS (test_pic_preallocation incl.)
  • meson setup build-cpu -Denable_cuda=false && ninja -C build-cpu && meson test -C build-cpu --suite=fast 84/84 PASS
  • No public API change

Deep-dive deliverables (ADR-0108)

  • Research digest: no digest needed: same bug class as PR fix(ci): pic-pool ODR CUDA buf_type, gpumask SKIP guard, ort_backend coverage floor, vifks360 timeout #840
  • Decision matrix: no alternatives: only-one-way fix (option (a) move + explicit (b) for outlier)
  • AGENTS.md invariant note: no rebase-sensitive invariants
  • Reproducer / smoke-test command: meson test -C build-cuda test_pic_preallocation passes after the move
  • changelog.d fragment: no changelog fragment needed: internal build-system fix, no user-visible change
  • docs/rebase-notes.md: no rebase impact: meson.build internal flag-propagation only

state.md touch

  • state.md: will add T-MESON-3-LIBS-ODR-CUDA-SYCL-DEFINES-2026-06-08 row when this merges

…class)

Follow-up to PR #840 (picture_pool_cpp23_lib ODR fix).  Deep audit found
three more static_library targets that consumed vmaf_cflags_common before
the HAVE_CUDA / HAVE_NVTX / HAVE_SYCL lines were appended to it (~line 1856
in the pre-fix file), causing the same struct-layout ODR violation in:

- cuda_static_lib (line ~1178): c_args uses vmaf_cflags_common captured
  early; cuda/common.h includes picture.h and gates VmafCudaState on
  #if HAVE_CUDA.

- libvmaf_feature_static_lib (line ~1700): c_args uses vmaf_cflags_common
  captured early; feature_extractor.cpp includes picture.h and dereferences
  VmafPicturePrivate at line 545.

- gpu_picture_pool_cpp23_lib (line ~1793): carried NO c_args/cpp_args at all;
  gpu_picture_pool.cpp includes picture.h (line 30) and gpu_picture_pool.h
  (line 31), which also pulls in picture.h.

Fix strategy (option a from the audit):
1. Move the vmaf_cflags_common += '-DHAVE_CUDA' / '-DHAVE_NVTX' / '-DHAVE_SYCL'
   block from after the libvmaf_sources list to just before the
   `if is_cuda_enabled` backend block (~line 902).  This fixes cuda_static_lib
   and libvmaf_feature_static_lib with no per-target change — any lib that
   already uses `c_args: vmaf_cflags_common` picks up the defines automatically.
2. Add explicit cpp_args to gpu_picture_pool_cpp23_lib (it never references
   vmaf_cflags_common), mirroring the picture_pool_cpp23_lib fix from PR #840.

Verified: meson setup + ninja -C build-cuda-check (-Denable_cuda=true) builds
cleanly; meson test --suite=fast: 101/109 OK (8 pre-existing CUDA hardware
parity failures unrelated to this change); CPU-only build: 84/84 OK.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lusoris

lusoris commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Superseded — bundled into PR #844 for single-CI-cycle drain.

@lusoris lusoris closed this Jun 8, 2026
@lusoris
lusoris deleted the fix/meson-3-libs-odr-cuda-sycl-defines branch June 8, 2026 00:03
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.

1 participant