package/tinycbor: bump to version 0.6.1

This is nominally a bugfix release which now also includes the patch we
previously backported, so we can remove it.

However, it also introduced some breakage:

 - Builds with older toolchains (like br-arm-full-static, GCC 9) fail
   because the introduction of C23 [[fallthrough]] to the code was not
   properly gated on compiler support.

 - Compiling for x86 without SSE2 support (e.g. with
   bootlin-x86-i686-musl) fails because the check for native half-with
   float arithmetic support on the target was not strict enough.

Import unreleased upstream patches that fix these issues.

Release notes: https://github.com/intel/tinycbor/releases/tag/v0.6.1

Signed-off-by: Florian Larysch <fl@n621.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Florian Larysch
2025-08-19 23:32:59 +02:00
committed by Thomas Petazzoni
parent 90576d681c
commit ca70913684
6 changed files with 116 additions and 47 deletions

View File

@@ -1131,7 +1131,6 @@ package/ti-sgx-um/0001-Makefile-do-not-install-init-script.patch lib_patch.Upstr
package/ti-sgx-um/S80ti-sgx lib_sysv.Variables
package/ti-utils/0001-plt.h-fix-build-with-gcc-10.patch lib_patch.Upstream
package/tinyalsa/0001-include-time.h-before-asound.h.patch lib_patch.Upstream
package/tinycbor/0001-Makefile-add-DISABLE_WERROR.patch lib_patch.Upstream
package/tinycompress/0001-wave-add-time.h-missing-header-inclusion.patch lib_patch.Upstream
package/tinydtls/0001-sha2-sha2.c-fix-build-on-big-endian.patch lib_patch.Upstream
package/tinyxml/0001-In-stamp-always-advance-the-pointer-if-p-0xef.patch lib_patch.Upstream

View File

@@ -0,0 +1,55 @@
From 45e4641059709862b4e46f3608d140337566334b Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Wed, 2 Apr 2025 08:39:04 -0700
Subject: [PATCH] Fix build with GCC < 11: [[fallthrough]] is supported but not
allowed in C
I think GCC says `__has_cpp_attribute(fallthrough)` is true because C++
supports it (it means "has C++ attribute"), but that doesn't apply to
the C language. This causes a compilation error:
```
compilersupport_p.h:57:41: error: expected expression before '[' token
57 | # define CBOR_FALLTHROUGH [[fallthrough]]
| ^
cborparser.c:225:13: note: in expansion of macro 'CBOR_FALLTHROUGH'
225 | CBOR_FALLTHROUGH;
| ^~~~~~~~~~~~~~~~
```
Instead, we should use the C23 `__has_c_attribute` to detect the C
attribute.
Fixes #293.
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
Upstream: https://github.com/intel/tinycbor/commit/45e4641059709862b4e46f3608d140337566334b
Signed-off-by: Florian Larysch <fl@n621.de>
---
src/compilersupport_p.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/compilersupport_p.h b/src/compilersupport_p.h
index c91ea93..9251799 100644
--- a/src/compilersupport_p.h
+++ b/src/compilersupport_p.h
@@ -52,10 +52,14 @@
# define cbor_static_assert(x) ((void)sizeof(char[2*!!(x) - 1]))
#endif
-#if defined(__has_cpp_attribute) // C23 and C++17
+#if defined(__has_cpp_attribute) && defined(__cplusplus) // C++17
# if __has_cpp_attribute(fallthrough)
# define CBOR_FALLTHROUGH [[fallthrough]]
# endif
+#elif defined(__has_c_attribute) && !defined(__cplusplus) // C23
+# if __has_c_attribute(fallthrough)
+# define CBOR_FALLTHROUGH [[fallthrough]]
+# endif
#endif
#ifndef CBOR_FALLTHROUGH
# ifdef __GNUC__
--
2.50.1

View File

@@ -1,44 +0,0 @@
From 5f26eaf8d7be760fafe11ef4a6e0f907e7e8c3f0 Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Mon, 10 Jan 2022 23:17:45 +0100
Subject: [PATCH] Makefile: add DISABLE_WERROR
Allow the user to disable -Werror to avoid the following build failure
with gcc 4.8 raised since version 0.6.0 and
https://github.com/intel/tinycbor/commit/e2a4ed135c4d9101c4df83f2dd033cd249b6ef07:
/home/buildroot/autobuild/instance-1/output-1/host/bin/arm-none-linux-gnueabi-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I./src -std=gnu99 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -D_FORTIFY_SOURCE=1 -Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=int-conversion -fPIC -c -o src/cborerrorstrings.pic.o src/cborerrorstrings.c
cc1: error: -Werror=incompatible-pointer-types: no option -Wincompatible-pointer-types
cc1: error: -Werror=int-conversion: no option -Wint-conversion
Fixes:
- http://autobuild.buildroot.org/results/a9f/a9fe64c42bb96f9e7b4af3050464f6570c1c00fa
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Retrieved from:
https://github.com/intel/tinycbor/commit/5f26eaf8d7be760fafe11ef4a6e0f907e7e8c3f0]
---
Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 6492ea16..3cde2b3d 100644
--- a/Makefile
+++ b/Makefile
@@ -236,10 +236,15 @@ tag: distcheck
.SECONDARY:
cflags := $(CPPFLAGS) -I$(SRCDIR)src
-cflags += -std=gnu99 $(CFLAGS) \
+cflags += -std=gnu99 $(CFLAGS)
+
+ifneq ($(DISABLE_WERROR),1)
+cflags += \
-Werror=incompatible-pointer-types \
-Werror=implicit-function-declaration \
-Werror=int-conversion
+endif
+
%.o: %.c
@test -d $(@D) || $(MKDIR) $(@D)
$(CC) $(cflags) $($(basename $(notdir $@))_CCFLAGS) -c -o $@ $<

View File

@@ -0,0 +1,59 @@
From 48a22bddfcc67b3a433ded695f906cc314a0bd5f Mon Sep 17 00:00:00 2001
From: Florian Larysch <fl@n621.de>
Date: Sun, 17 Aug 2025 00:20:57 +0200
Subject: [PATCH] fix build on i386 without SSE2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit 3cba6b1 ("Use _Float16 for half conversions if available") added
support for using half-width float support in the compiler to perform
encoding operations, using the FLT16_MANT_DIG macro to check for
support on the given target.
However, on x86 GCC only supports this when SSE2 is enabled[1]. Unlike
clang and the other architectures where support for this is conditional,
GCC *does* define those macros even without SSE2 support, causing a
build failure:
In file included from cborencoder_float.c:29:
cborinternal_p.h: In function encode_half:
cborinternal_p.h:56:5: error: invalid conversion to type _Float16 without option -msse2
56 | _Float16 f = (_Float16)x;
| ^~~~~~~~
cborinternal_p.h: In function decode_half:
cborinternal_p.h:65:5: error: invalid conversion from type _Float16 without option -msse2
65 | return (float)f;
|
Work around this by additionally checking for this specific condition.
[1] https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html
Upstream: https://github.com/intel/tinycbor/commit/48a22bddfcc67b3a433ded695f906cc314a0bd5f
Signed-off-by: Florian Larysch <fl@n621.de>
---
src/cborinternal_p.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/cborinternal_p.h b/src/cborinternal_p.h
index 19273ac..ee9c117 100644
--- a/src/cborinternal_p.h
+++ b/src/cborinternal_p.h
@@ -48,8 +48,12 @@
/* Check for FLT16_MANT_DIG using integer comparison. Clang headers incorrectly
* define this macro unconditionally when __STDC_WANT_IEC_60559_TYPES_EXT__
* is defined (regardless of actual support for _Float16).
+ *
+ * GCC defines these macros but doesn't support arithmetic including
+ * conversions on x86 without SSE2.
*/
-# if FLT16_MANT_DIG > 0 || __FLT16_MANT_DIG__ > 0
+# if (FLT16_MANT_DIG > 0 || __FLT16_MANT_DIG__ > 0) && \
+ !(defined(__i386__) && !defined(__SSE2__))
static inline unsigned short encode_half(float x)
{
unsigned short h;
--
2.50.1

View File

@@ -1,3 +1,3 @@
# Locally computed:
sha256 512e2c9fce74f60ef9ed3af59161e905f9e19f30a52e433fc55f39f4c70d27e4 tinycbor-0.6.0.tar.gz
sha256 0f9944496d1143935e9c996bc6233ca0dd5451299def33ef400a409942f8f34b tinycbor-0.6.1.tar.gz
sha256 3c6ba0b5bfa7830505301ffb336a17b0748e0d61c4d34216e9dc98f10e40395e LICENSE

View File

@@ -4,7 +4,7 @@
#
################################################################################
TINYCBOR_VERSION = 0.6.0
TINYCBOR_VERSION = 0.6.1
TINYCBOR_SITE = $(call github,intel,tinycbor,v$(TINYCBOR_VERSION))
TINYCBOR_LICENSE = MIT
TINYCBOR_LICENSE_FILES = LICENSE