Skip to contentSkip to conversation

avro-c++: Fix build for 32-bit targets

PATCH New Alper Ak 1 participant 1 message Jul 24, 2025

lore
Share & tools
lore

Alper Ak

author
#0 lore raw

PATCH v2 1/1 avro-c++: Fix build for 32-bit targets

Building avro-c++ for 32-bit targets currently fails due to the following warnings being treated as errors:

- useless-cast in Symbol.cc
- conversion in FileStream.cc

These are promoted to errors because of -Werror in the project's build flags.

Fix:

lib32-avro-c++/1.12/sources/avro-c++-1.12/lang/c++/impl/parsing/Symbol.cc:91:27:
error: useless cast to type 'int' [-Werror=useless-cast]
91 | adj.push_back(static_cast(it - rs.begin()));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

lib32-avro-c++/1.12/sources/avro-c++-1.12/lang/c++/impl/FileStream.cc:208:41:
error: conversion from 'int64_t' {aka 'long long int'} to 'size_t' {aka 'unsigned int'} may change value [-Werror=conversion] 208 | in_->seek(position - byteCount_ - available_);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

lib32-avro-c++/1.12/sources/avro-c++-1.12/lang/c++/impl/FileStream.cc:209:22:
error: conversion from 'int64_t' {aka 'long long int'} to 'size_t' {aka 'unsigned int'} may change value [-Werror=conversion]
209 | byteCount_ = position;
| ^~~~~~~~
cc1plus: all warnings being treated as errors

---
 meta-oe/recipes-support/avro/avro-c++_1.12.bb | 12 ++++++++++++
 1 file changed, 12 insertions(+)
meta-oe/recipes-support/avro/avro-c++_1.12.bb +12 -0
index 726a861bc9..61aef88e13 100644
@@ -26,4 +26,16 @@ do_configure:prepend() {
         cp -r ${UNPACKDIR}/_deps/fmt-src ${B}/_deps/
 }
 
+# Workaround for 32-bit build failures due to -Werror:
+# 'useless-cast' in Symbol.cc and 'conversion' in FileStream.cc
+#
+# A patch has been submitted upstream: https://github.com/apache/avro/pull/3433
+# Once this or an equivalent fix is merged and the recipe upgraded, this can be removed.
+#
+# These errors don't occur when using Clang accordingly to upstream configuration and
+# the workaround flags aren't recognized by Clang either.
+# To avoid unnecessary warnings and keep the build clean across toolchains, the flags are conditionally added
+# using the toolchain-gcc override. This makes it unnecessary to override anything for Clang.
+CXXFLAGS:append:toolchain-gcc = " -Wno-error=useless-cast -Wno-error=conversion"
+
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.43.0