Repository navigation
opencv: use the registry's zlib, libpng, libjpeg-turbo, libwebp; OpenEXR and IPP off - #1575
Conversation
…nstead of bundled copies opencv compiled its 3rdparty/ copies of these into libopencv_imgcodecs because none of them was a build dep, so find_package failed and opencv fell back to the bundled sources. The bundled libpng (1.6.57) and libjpeg-turbo (3.1.2) are older than our packages and invisible to pkgscan. - Build + runtime deps: libpng, libjpeg-turbo, libwebp; zlib as a build dep. - WITH_OPENEXR=OFF: no OpenEXR package; the bundled 2.3.0 is from 2018. - WITH_IPP=OFF: stops the configure-time download of Intel's prebuilt IPPICV binary on x86_64. - build.sh fails closed if a bundled copy was built, or if libopencv_imgcodecs lacks DT_NEEDED on libz, libpng16, libjpeg, libwebp or libopenjp2. - New standalone test: PNG/JPEG/WebP round trip through imgcodecs. libtiff stays bundled (no package); protobuf is a follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 56 minutes for your next included review. View limit details
|
There was a problem hiding this comment.
Scope matches the title. Both files change only the opencv recipe, and no other recipe imports packages/opencv/build.ncl, so the new runtime deps reach no dependent.
Clobber none. The diff keeps the openjpeg unbundling from #301 and its OSV-2023-444 rationale, and it keeps the smoketest from #1364.
Correctness The recipe is sound on read. The registry packages ship the headers and the shared libraries that opencv looks for, and readelf comes from binutils. The new image_codecs test follows the c-ares pattern. I found three nits only: change narration in the build.sh comment block, a WebP comment that names the wrong mode, and build deps that repeat the runtime deps.
Not checked I ran no build, and the harness denied shell commands other than git log, so gitleaks and trivy did not run. I did not open the opencv 4.14.0 source. These claims are from memory of upstream and are not verified: the 3rdparty archive names (liblibtiff.a, libzlib.a, liblibjpeg-turbo.a, libIlmImf.a), the 3rdparty/lib location, the libz DT_NEEDED on libopencv_imgcodecs under --as-needed, and the lossless default of WebP imwrite. The first build-bot run decides the first three, because the checks fail closed.
| # already the Linux default and do NOT stop the fallback: opencv builds the | ||
| # bundled copy whenever find_package fails (cmake/OpenCVFindLibsGrfmt.cmake), | ||
| # which is what happened while these libraries were not build deps. The | ||
| # checks after the build are what make this fail closed. |
There was a problem hiding this comment.
nit · Three sentences in this block tell the history of the change, not the state of the code. They are "which is what happened while these libraries were not build deps" (line 24), "arm64 never had it" (line 43) and "a follow-up" (line 46). The first is also doubtful for zlib: zlib was a runtime dep before this PR, and runtime deps are in the build environment. Keep the mechanism (the fallback when find_package fails) and move the history to the commit message. I found this in the opencv recipe only.
| } | ||
| double diff = cv::norm(img, back, cv::NORM_INF); | ||
| // PNG is lossless; JPEG and lossy WebP only have to be close. | ||
| if ((std::string(ext) == "png" && diff != 0) || diff > 64) { |
There was a problem hiding this comment.
nit · The comment says "lossy WebP", but cv::imwrite with no parameters writes lossless WebP. The opencv documentation for IMWRITE_WEBP_QUALITY says the default is lossless. The test can require diff == 0 for WebP as it does for PNG, which is a stronger check of the registry's libwebp. Only JPEG needs the tolerance. I did not open the 4.14.0 source to confirm the default.
| openjpeg, | ||
| libpng, | ||
| libjpeg-turbo, | ||
| libwebp, |
There was a problem hiding this comment.
nit · All five libraries are in runtime_deps too (lines 47-53). The repo guide says runtime deps are injected into the build environment, so an identical build_deps entry is not necessary. openjpeg was already listed twice before this PR, and this diff extends the pattern to four more. Keep one list, and put the comment about the bundled-copy fallback on the runtime_deps entries.
Problem
opencv compiles its own
3rdparty/copies of the image libraries and links them statically intolibopencv_imgcodecs. It does that wheneverfind_packagefails (cmake/OpenCVFindLibsGrfmt.cmakeat 4.14.0), and it failed for all of them here because none was a build dep.BUILD_PNGand the rest were alreadyOFFon Linux; they do not stop the fallback.The copies are invisible to pkgscan, and two are older than the registry's packages:
The recipe already did this for openjpeg (OSV-2023-444).
Change
subsetOf, as every other recipe that depends on these three does.WITH_OPENEXR=OFF: no OpenEXR package, and the bundled 2.3.0 carries a long OSS-Fuzz CVE tail. EXR decoding was already opt-in at runtime (OPENCV_IO_ENABLE_OPENEXR), so default behaviour does not change.WITH_IPP=OFF: on x86_64 opencv downloads Intel's prebuilt IPPICV archive at configure time (3rdparty/ippicv/ippicv.cmake, md5-pinned only) and links it statically intolibopencv_core. That is a binary we did not build, under Intel's licence rather than the package's Apache-2.0, fetched outside the recipe's sha256-pinned sources. I turned it off rather than deferring it because it costs one flag. The x86 imgproc kernels IPP accelerated fall back to opencv's own SIMD code, which is slower for some operations. arm64 never had IPP.build.sh(in the style of llama.cpp's):make: no3rdparty/lib/{libzlib,liblibpng,liblibjpeg-turbo,liblibwebp,liblibopenjp2,libIlmImf}.a. The check also requires the bundledliblibtiff.ato be there, so a moved directory cannot make it pass vacuously.readelf -d libopencv_imgcodecs.so.*must listlibz,libpng16,libjpeg,libwebpandlibopenjp2as NEEDED.image_codecs: compiles a small C++ program against the installed headers. It writes a PNG, a JPEG and a WebP, reads each one back, and checks the result: PNG must be exact, JPEG and WebP within tolerance. The package ships nocv2, so the test uses a C++ program, following the pattern of jsoncpp's and c-ares's tests.Recipe evaluated locally with the patched stdlib (
pkgs-nickel-eval) for amd64 and arm64. Not built anywhere yet; the build-bot run on this PR is the first build.Not in this PR (follow-ups)
.pb.ccfiles are for 3.19, and ours is 36.2 (PROTOBUF_UPDATE_FILES=ON, abseil linkage), so it needs its own PR.--with-system-libtiff. The build.sh check expects the bundled copy, so switching to a package has to update the check.hal/kleidicv/kleidicv.cmake, gitlab.arm.com) and ADE for G-API (modules/gapi/cmake/DownloadADE.cmake) on both arches. Both are source archives pinned by md5 only. They should be mirrored and sha256-pinned like the or-tools Eigen source (pkgs#1146).🤖 Generated with Claude Code