[vlc-commits] [Git][videolan/vlc][master] contrib: opencv: Backport a patch to avoid building with -Werror

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Nov 17 09:18:57 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
b4213d48 by Martin Storsjö at 2026-11-17T07:39:58+00:00
contrib: opencv: Backport a patch to avoid building with -Werror

Previously, opencv built with a bunch of warnings treated as errors.

This caused the build to fail with the latest nightly Clang
since https://github.com/llvm/llvm-project/pull/180955, which
caused the bundled old openexr half.cpp to produce warnings
treated as errors like this:

    contrib/build-i686/opencv4/3rdparty/openexr/Half/half.cpp:73:7: error: unsequenced accesses to volatile qualified 'f' [-Werror,-Wunsequenced]
       73 |         f *= f;                         // this will overflow before
          |           ~~ ^
    1 error generated.

There is little point in reporting this issue further upstream;
openexr itself has changed this code already in 2021 so this code
no longer uses volatile, so those warnings/errors wouldn't appear
any longer.

OpenCV 5.x has dropped the bundled openexr code as well.

Just apply this OpenCV patch (from upstream OpenCV commit
30ff9c6775f3449dcf015eb9c7da26be3e51191d, from OpenCV 3.4.18 and
4.4.6) to stop treating these warnings as errors.

- - - - -


2 changed files:

- + contrib/src/opencv4/0001-cmake-don-t-force-Werror.patch
- contrib/src/opencv4/rules.mak


Changes:

=====================================
contrib/src/opencv4/0001-cmake-don-t-force-Werror.patch
=====================================
@@ -0,0 +1,36 @@
+From 30ff9c6775f3449dcf015eb9c7da26be3e51191d Mon Sep 17 00:00:00 2001
+From: Alexander Alekhin <alexander.a.alekhin at gmail.com>
+Date: Wed, 26 Jan 2022 04:34:51 +0000
+Subject: [PATCH] cmake: don't force -Werror=...
+
+- improve compatibility with further compiler versions
+- warnings are not errors by default
+---
+ cmake/OpenCVCompilerOptions.cmake | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake
+index 90f1896c30..bbfd889690 100644
+--- a/cmake/OpenCVCompilerOptions.cmake
++++ b/cmake/OpenCVCompilerOptions.cmake
+@@ -119,12 +119,12 @@ if(CV_GCC OR CV_CLANG)
+     # we want.
+     add_extra_compiler_option(-Wall)
+   endif()
+-  add_extra_compiler_option(-Werror=return-type)
+-  add_extra_compiler_option(-Werror=non-virtual-dtor)
+-  add_extra_compiler_option(-Werror=address)
+-  add_extra_compiler_option(-Werror=sequence-point)
++  add_extra_compiler_option(-Wreturn-type)
++  add_extra_compiler_option(-Wnon-virtual-dtor)
++  add_extra_compiler_option(-Waddress)
++  add_extra_compiler_option(-Wsequence-point)
+   add_extra_compiler_option(-Wformat)
+-  add_extra_compiler_option(-Werror=format-security -Wformat)
++  add_extra_compiler_option(-Wformat-security -Wformat)
+   add_extra_compiler_option(-Wmissing-declarations)
+   add_extra_compiler_option(-Wmissing-prototypes)
+   add_extra_compiler_option(-Wstrict-prototypes)
+-- 
+2.53.0
+


=====================================
contrib/src/opencv4/rules.mak
=====================================
@@ -22,6 +22,7 @@ $(TARBALLS)/opencv-$(OPENCV4_VERSION).tar.gz:
 
 opencv4: opencv-$(OPENCV4_VERSION).tar.gz .sum-opencv4
 	$(UNPACK)
+	$(APPLY) $(SRC)/opencv4/0001-cmake-don-t-force-Werror.patch
 	# fix build with newer CMake
 	sed -i.orig 's,cmake_minimum_required(VERSION 2.8.12.2),cmake_minimum_required(VERSION 3.5),' $(UNPACK_DIR)/cmake/OpenCVGenPkgconfig.cmake
 	# enable pkg-config on all configurations



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b4213d48aadcf82ee1ff115f4470069000ecbf45

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/b4213d48aadcf82ee1ff115f4470069000ecbf45
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list