8000 opencv: link system openjpeg 2.5.4 instead of the bundled copy by bryan-minimal · Pull Request #301 · gominimal/pkgs · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/opencv/build.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let make = import "../make/build.ncl" in
let gcc = import "../gcc/build.ncl" in
let glibc = import "../glibc/build.ncl" in
let zlib = import "../zlib/build.ncl" in
let openjpeg = import "../openjpeg/build.ncl" in

# TODO: This doesn't install the opencv_contrib, which has a LOT of the useful stuff. Implement that.
# See:
Expand All @@ -18,7 +19,7 @@ let version = "4.13.0" in
build_deps = [
{ file = "build.sh" } | Local,
{
# https://github.com/opencv/opencv/archive/refs/tags/4.12.0.tar.gz
# https://github.com/opencv/opencv/archive/refs/tags/4.13.0.tar.gz
url = "gs://minimal-staging-archives/opencv-%{version}.tar.gz",
sha256 = "1d40ca017ea51c533cf9fd5cbde5b5fe7ae248291ddf2af99d4c17cf8e13017d",
extract = true,
Expand All @@ -27,11 +28,16 @@ let version = "4.13.0" in
toolchain,
cmake,
make,
# System openjpeg for JPEG2000 (find_package(OpenJPEG) at configure
# time); replaces opencv's bundled 3rdparty/openjpeg. See build.sh.
openjpeg,
],
runtime_deps = [
glibc,
subsetOf gcc ["libgcc", "libstdcpp"],
zlib,
# opencv's imgcodecs dynamically links libopenjp2.so at runtime.
openjpeg,
],

cmd = "./build.sh",
Expand Down
11 changes: 10 additions & 1 deletion packages/opencv/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ export CFLAGS="$MARCH -O2 -pipe -gno-record-gcc-switches -ffile-prefix-map=$(pwd
export LDFLAGS="-Wl,--build-id=none"
export CXXFLAGS="${CFLAGS}"

# Configure
# Configure.
#
# WITH_OPENJPEG=ON + BUILD_OPENJPEG=OFF links the system openjpeg (our
# 2.5.4 package) instead of compiling the bundled 3rdparty/openjpeg copy.
# The bundled copy is what OSS-Fuzz flagged as OSV-2023-444 (heap-overflow
# in opj_jp2_apply_pclr); the system lib carries the upstream fix
# (OpenJPEG PR #1441, shipped in 2.5.1+), so this removes the vulnerable
# code rather than asserting the vendored copy is patched.
cmake \
-DCMAKE_INSTALL_PREFIX=/usr \
-DOPENCV_GENERATE_PKGCONFIG=ON \
-DOPENCV_LIB_INSTALL_PATH=/usr/lib \
-DWITH_OPENJPEG=ON \
-DBUILD_OPENJPEG=OFF \
../opencv-$MINIMAL_ARG_VERSION

# Build
Expand Down
0