diff mbox series

[meta-multimedia,4/6] libcamera: Fix build with clang 23

Message ID 20260908020752.2748681-4-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe,1/6] assimp: Do not treat warnings as errors | expand

Commit Message

Khem Raj Sept. 8, 2026, 2:07 a.m. UTC
clang 23 enables -Wunused-template as part of -Wall (via -Wmost ->
-Wunused), where previously neither -Wall nor -Wextra turned it on.
libcamera builds with -Werror, so this now breaks the build:

  In file included from include/libcamera/ipa/core_ipa_serializer.h:18:
  include/libcamera/internal/ipa_data_serializer.h:57:3: error: unused
      function template 'readPOD' [-Werror,-Wunused-template]
     57 | T readPOD(std::vector<uint8_t> &vec, size_t pos)
        |   ^~~~~~~

The POD helpers sit in an anonymous namespace, so they have internal
linkage and clang diagnoses them per translation unit. appendPOD() and
the iterator overload of readPOD() are referenced by the
IPADataSerializer specialisations in the header itself, so they count as
used everywhere. The std::vector overload of readPOD() is not: nothing
in libcamera calls it, its only callers are the IPA proxies and proxy
workers generated at build time from the mojom templates. So it is
genuinely unused in every translation unit that is not generated proxy
code, which is what [[maybe_unused]] exists for.

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...er-Mark-vector-readPOD-overload-as-m.patch | 65 +++++++++++++++++++
 .../libcamera/libcamera_0.7.2.bb              |  1 +
 2 files changed, 66 insertions(+)
 create mode 100644 meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-ipa_data_serializer-Mark-vector-readPOD-overload-as-m.patch
diff mbox series

Patch

diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-ipa_data_serializer-Mark-vector-readPOD-overload-as-m.patch b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-ipa_data_serializer-Mark-vector-readPOD-overload-as-m.patch
new file mode 100644
index 0000000000..4cb8c47050
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/libcamera/libcamera/0001-ipa_data_serializer-Mark-vector-readPOD-overload-as-m.patch
@@ -0,0 +1,65 @@ 
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Sun, 6 Sep 2026 22:40:00 -0700
+Subject: [PATCH] ipa_data_serializer: Mark vector readPOD() overload as
+ maybe_unused
+
+clang 23 enables -Wunused-template as part of -Wall (via -Wmost ->
+-Wunused; it was not enabled by -Wall or -Wextra before). Combined with
+libcamera's -Werror this breaks the build:
+
+  In file included from include/libcamera/ipa/core_ipa_serializer.h:18:
+  include/libcamera/internal/ipa_data_serializer.h:57:3: error: unused
+      function template 'readPOD' [-Werror,-Wunused-template]
+     57 | T readPOD(std::vector<uint8_t> &vec, size_t pos)
+        |   ^~~~~~~
+
+The POD helpers live in an anonymous namespace, so they have internal
+linkage and clang diagnoses them per translation unit. appendPOD() and
+the iterator overload of readPOD() are referenced by the IPADataSerializer
+specialisations in this header, so they are seen as used everywhere.
+
+The std::vector overload of readPOD() is different: nothing in libcamera
+itself calls it. Its only callers are the IPA proxies and proxy workers
+generated at build time from the mojom templates, for example
+
+  [[maybe_unused]] const size_t ipaControlsBufSize =
+          readPOD<uint32_t>(_ipcOutputBuf.data(), 4);
+
+in src/libcamera/proxy/soft_ipa_proxy.cpp. It is therefore genuinely
+unused in every translation unit that includes this header without being
+generated proxy code, which is exactly what [[maybe_unused]] is for.
+
+Note the overload cannot simply be dropped: doing so breaks the generated
+proxies with "no matching function for call to 'readPOD'".
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ include/libcamera/internal/ipa_data_serializer.h | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/include/libcamera/internal/ipa_data_serializer.h b/include/libcamera/internal/ipa_data_serializer.h
+index 0dda76d..528527d 100644
+--- a/include/libcamera/internal/ipa_data_serializer.h
++++ b/include/libcamera/internal/ipa_data_serializer.h
+@@ -52,9 +52,15 @@ T readPOD(std::vector<uint8_t>::const_iterator it, size_t pos,
+ 	return ret;
+ }
+
++/*
++ * This overload is only used by the generated IPA proxies and proxy workers,
++ * and thus is unused in translation units that include this header without
++ * being generated proxy code. Mark it as such to avoid -Wunused-template
++ * warnings, which clang enables as part of -Wall since version 23.
++ */
+ template<typename T,
+ 	 std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr>
+-T readPOD(std::vector<uint8_t> &vec, size_t pos)
++[[maybe_unused]] T readPOD(std::vector<uint8_t> &vec, size_t pos)
+ {
+ 	return readPOD<T>(vec.cbegin(), pos, vec.end());
+ }
+--
+2.51.0
+
diff --git a/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.7.2.bb b/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.7.2.bb
index 3199ad8a4f..955cf041ba 100644
--- a/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.7.2.bb
+++ b/meta-multimedia/recipes-multimedia/libcamera/libcamera_0.7.2.bb
@@ -11,6 +11,7 @@  LIC_FILES_CHKSUM = "\

 SRC_URI = " \
         git://git.libcamera.org/libcamera/libcamera.git;protocol=https;branch=master;tag=v${PV} \
+        file://0001-ipa_data_serializer-Mark-vector-readPOD-overload-as-m.patch \
 "

 SRCREV = "191e202178f02430b5942397c70d215cdd2056fa"