Repository navigation
fix(cmake): append ImageMagick delegate closure for stock-tier consumers (+ reship) - #457
Merged
Merged
Conversation
…ers + reship After the relocatable-export fix (#453) the wasm demo consumer got PAST the abs-path error but failed to LINK with undefined BZ2_*/lzma_*/xmlReadMemory/xmlFreeDoc symbols: libMagickCore needs the bz2/lzma/xml2 codec delegates, and they were absent from the consumer's link line. Cause: cvcConfig.cmake.in appends the ImageMagick static delegate closure to MagickCore only when _cvc_im_synth is set — i.e. only when the pkg-config or last-resort tier synthesised the target. But on a wasm consumer the STOCK FindImageMagick tier wins (it finds the static -7.Q16HDRI libs in the prefix via find_library) and creates a delegate-LESS MagickCore without setting the flag, so the append was skipped and the delegates never made the link line. Fix: gate the delegate append on the MagickCore target existing, not on _cvc_im_synth. The append is self-guarding (find_library per delegate, missing ones skipped) and a harmless dedup for a shared ImageMagick, so it is safe to run for any MagickCore that reaches it. Verified locally against the reshipped wasm prefix: MagickCore's interface now carries libbz2/liblzma/libxml2 (+ jpeg/png/webp/tiff/sharpyuv/Lerc/z). Reship to embed the corrected consumer config: - libcvc 5 -> 6 (ships fixed cvcConfig.cmake.in) - cvcgl 6 -> 7 (rebuild + re-pin against libcvc +cvc.6; exact-pin means the old +cvc.6 cvcgl still pins the +cvc.5 libcvc with the broken consumer config) After merge: publish-cvcgl-wasm (dry_run=false) -> re-run cvcdbg demo3 nightly.
transfix
added a commit
that referenced
this pull request
Oct 25, 2026
… work (#801) * wasm: build the gallery and pycvc-gl with ImageMagick ON, and make it work The wasm gallery (libcvc-examples-web) and pycvc-gl-cp312's wasm columns configured with CVC_ENABLE_IMAGEMAGICK=OFF because every executable that linked the static cvc died in wasm-ld on MagickCore's undefined BZ2_*, lzma_* and xml* symbols. Three bugs were behind ImageMagick not being usable on wasm. 1. The codec closure was skipped on the stock FindImageMagick tier. src/cvc/CMakeLists.txt hung bz2/lzma/libxml2/tiff/webp/Lerc/... off MagickCore only on its own raw-libs fallback path. CMake >= 3.26's FindImageMagick makes delegate-less ImageMagick::* targets itself whenever pkg-config can see MagickCore.pc, and a cvcpkg build env exports CMAKE_PREFIX_PATH, which FindPkgConfig turns into a pkg-config search path even under emcmake. Such a build took the stock tier and never added the closure. The closure is now added for any static MagickCore (wasm, or a libMagickCore*.a), whichever tier found it, plus zlib. #457 fixed the consumer side (cvcConfig.cmake.in) the same way. 2. The wasm HDRI define was wrong. With no pkg-config answer the configure kept its Q16 / HDRI=0 defaults, but the cvcpkg wasm library is libMagickCore-7.Q16HDRI, and ImageMagick's headers take MAGICKCORE_HDRI_ENABLE from the compile line alone. cvc and every consumer (through cvc's public define) compiled against an integer Quantum while the library uses float. The published libcvc 3.7.0+cvc.1 wasm-mt SDK was built that way. The quantum depth and HDRI now come from the library name when pkg-config gives nothing. 3. The wasm coder registry was empty at run time. MagickCore creates the registry lazily, on the first GetMagickInfo, and RegisterMagickInfo drops every entry until then. magick_io.cpp's wasm-only init called RegisterStaticModules() and the Register*Image() entry points straight after InitializeMagick, so every coder was dropped while each static module was still marked registered, and the lazy path never retried. Every Magick read and write failed ("no encoder", NoDecodeDelegate). That is what stb_io.cpp's comment blamed on duplicated objects in libMagickCore.a. The init now calls GetMagickInfo("*") first, which creates the registry and registers the static coders into it. Recipes and CI: - libcvc-examples-web and pycvc-gl-cp312 (build-wasm.sh and .ps1) build with ImageMagick ON and list imagemagick and its codec bundles (tiff, libjpeg-turbo, libpng, libwebp, lerc, xz, bzip2, libxml2) as wasm build deps. - The configure records CVC_IMAGEMAGICK_ENABLED in the cache. build-wasm-demo.sh and the pycvc-gl wasm scripts fail when ImageMagick was asked for and not found, instead of shipping without it. - ci.yml's ari-wasm job links ari with ImageMagick ON. It passes CMAKE_PREFIX_PATH, so it takes the stock tier that broke, and ari's cvc::image::load pulls MagickCore in. It also checks the configure reports (Q16, HDRI=1). - publish-cvcgl-wasm.yml fails if the wasm-mt SDK's cvcTargets.cmake does not carry MAGICKCORE_HDRI_ENABLE=1. - cvc_revision: libcvc 1 -> 3 and cvcgl 1 -> 3 in lockstep (the wasm-mt SDK changes, native is already at +cvc.2), pycvc-gl-cp312 1 -> 3 (linux is at +cvc.2), libcvc-examples-web 1 -> 2. Native builds are unchanged: the closure gate is static-only, the HDRI inference is skipped on WIN32 and wherever pkg-config answers, and the registry change is __EMSCRIPTEN__-only. Verified locally on Windows with emsdk 5.0.7 against catalog wasm deps (imagemagick 7.1.2+cvc.23, vtk 9.5.0+cvc.3), single-threaded, configured like build-wasm-demo.sh with CMAKE_PREFIX_PATH exported: - master: terrain_lab.js fails in wasm-ld with undefined BZ2_*/lzma_*/xml* from libMagickCore-7.Q16HDRI.a (blob.o, miff.o, profile.o), the same failure as publish-cvcgl-wasm run 35070058005. - this change: terrain_lab, bunny_shadow, volren_bunny, volslice_bunny and ari link, terrain_lab renders in a browser, and ari passes ci.yml's node snapshot check. The exported cvcTargets.cmake names only ImageMagick::Magick++/::MagickCore and carries MAGICKCORE_HDRI_ENABLE=1. - no-pkg-config configure: "(Q16, HDRI=1)" (master: HDRI=0), closure linked. - a program linked against the static cvc round-trips a 7x5 RGBA image through TIFF (Magick + libtiff, which stb cannot do) under node, byte-identical. The registry holds 255 formats after init (0 before). * ci(wasm): run ImageMagick at run time under node, not just link it Nothing in CI exercised ImageMagick at run time in a wasm build. The ari-wasm job only proves the codec libraries resolve at link time. The empty coder registry that the previous commit fixes in magick_io.cpp failed every Magick read and write while everything still linked and every native test passed. image_magick_roundtrip_test is a plain main() like physics_replay_test, since googletest has no wasm build. It is built by CVC_BUILD_IMAGE_MAGICK_ROUNDTRIP. It checks that every extension magick_image_io advertises has a coder that both decodes and encodes, then round-trips an RGBA image through TIFF (byte-identical) and WEBP (size). Neither format can go through the stb handler, so both directions run through Magick, libtiff and libwebp. It exits 77 in a build without ImageMagick. Natively, image_test covers the same round trips. ci.yml's ari-wasm job now configures with the option, builds the target next to ari, and runs it under the emsdk's node. Its path filter also covers src/cvc/image, inc/cvc/image and the test. Verified locally (emsdk 5.0.7, catalog wasm deps, the same stock-tier configure as the job): the test passes. With init_magick_once's GetMagickInfo("*") call removed, it fails with 11 failures (all nine coders unregistered, both round trips with "no encoder") and exits 1.
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.
Follow-up to #453 (relocatable export). With the export fixed, a downstream wasm consumer build got past the abs-path error but failed to link:
Cause:
cvcConfig.cmake.inappends the ImageMagick static codec-delegate closure (bz2/lzma/xml2/…) toMagickCoreonly when_cvc_im_synthis set — i.e. only when the pkg-config or last-resort tier synthesised the target. On a wasm consumer the stockFindImageMagicktier wins (it finds the static-7.Q16HDRIlibs in the prefix) and creates a delegate-lessMagickCorewithout the flag, so the append was skipped.Fix: gate the append on
TARGET ImageMagick::MagickCoreexisting, not on_cvc_im_synth. The append is self-guarding (find_library per delegate; missing skipped) and a harmless dedup for a shared ImageMagick. Verified locally against the reshipped wasm prefix —MagickCore's interface now carrieslibbz2/liblzma/libxml2(the exact 3 undefined-symbol delegates) + jpeg/png/webp/tiff/sharpyuv/Lerc/z.Reship (embeds the corrected consumer config):
After merge →
publish-cvcgl-wasm→ downstream wasm nightly.