diff mbox series

[meta-python,2/2] python3-inflate64: Fix build with clang fortified glibc headers

Message ID 20240703052049.2661826-2-raj.khem@gmail.com
State New
Headers show
Series [meta-multimedia,1/2] flite: Fix buld with clang fortify enabled distros | expand

Commit Message

Khem Raj July 3, 2024, 5:20 a.m. UTC
This issue is seen with upcoming glibc 2.40

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...0001-Do-not-override-const-qualifier.patch | 83 +++++++++++++++++++
 .../python/python3-inflate64_1.0.0.bb         |  1 +
 2 files changed, 84 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-inflate64/0001-Do-not-override-const-qualifier.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-inflate64/0001-Do-not-override-const-qualifier.patch b/meta-python/recipes-devtools/python/python3-inflate64/0001-Do-not-override-const-qualifier.patch
new file mode 100644
index 0000000000..5391a11da0
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-inflate64/0001-Do-not-override-const-qualifier.patch
@@ -0,0 +1,83 @@ 
+From 7e3a795cbeea94b3324aa926f2b11904cb169acc Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 2 Jul 2024 22:02:38 -0700
+Subject: [PATCH] Do not override 'const' qualifier
+
+This has worked so far but with fortified system headers from
+Glibc 2.40+ and clang compiler it ends up in compile errors
+
+| In file included from /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/string.h:548:
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:77:66: error: pass_object_size attribute only applies to constant pointer arguments
+|    77 | __NTH (strcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
+|       |                                                                  ^
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:86:66: error: pass_object_size attribute only applies to constant pointer arguments
+|    86 | __NTH (stpcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
+|       |                                                                  ^
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:96:67: error: pass_object_size attribute only applies to constant pointer arguments
+|    96 | __NTH (strncpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
+|       |                                                                   ^
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:107:56: error: pass_object_size attribute only applies to constant pointer arguments
+|   107 | __NTH (stpncpy (__fortify_clang_overload_arg (char *, ,__dest),
+|       |                                                        ^
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:136:66: error: pass_object_size attribute only applies to constant pointer arguments
+|   136 | __NTH (strcat (__fortify_clang_overload_arg (char *, __restrict, __dest),
+|       |                                                                  ^
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:145:67: error: pass_object_size attribute only applies to constant pointer arguments
+|   145 | __NTH (strncat (__fortify_clang_overload_arg (char *, __restrict, __dest),
+|       |                                                                   ^
+| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/python3-inflate64/1.0.0/recipe-sysroot/usr/include/bits/string_fortified.h:161:67: error: pass_object_size attribute only applies to constant pointer arguments
+|   161 | __NTH (strlcpy (__fortify_clang_overload_arg (char *, __restrict, __dest),
+
+Therefore adjust needed places to use const qualifier
+
+Upstream-Status: Submitted [https://codeberg.org/miurahr/inflate64/pulls/13]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/lib/deflate.h          | 2 +-
+ src/lib/deflate_tree.c     | 4 ++--
+ src/lib/inflate64_config.h | 3 ---
+ 3 files changed, 3 insertions(+), 6 deletions(-)
+
+diff --git a/src/lib/deflate.h b/src/lib/deflate.h
+index 72a324f..c780be9 100644
+--- a/src/lib/deflate.h
++++ b/src/lib/deflate.h
+@@ -288,6 +288,6 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, char FAR *buf,
+   extern const unsigned char ZLIB_INTERNAL _dist_code[];
+ #endif
+ #endif
+-extern uch ZLIB_INTERNAL length_code[];
++extern const uch ZLIB_INTERNAL length_code[];
+ 
+ #endif /* DEFLATE_H */
+diff --git a/src/lib/deflate_tree.c b/src/lib/deflate_tree.c
+index 5a66139..cdee934 100644
+--- a/src/lib/deflate_tree.c
++++ b/src/lib/deflate_tree.c
+@@ -78,10 +78,10 @@ local const uch bl_order[BL_CODES]
+ 
+ #define DIST_CODE_LEN  768 /* see definition of array dist_code below */
+ 
+-local int base_length[LENGTH_CODES];
++local const int base_length[LENGTH_CODES];
+ /* First normalized length for each code (0 = MIN_MATCH) */
+ 
+-uch length_code[BASE_MATCH-MIN_MATCH+1];
++const uch length_code[BASE_MATCH-MIN_MATCH+1];
+ /* length code for each normalized match length (0 == MIN_MATCH) */
+ 
+ #if defined(GEN_TREES_H) || !defined(STDC)
+diff --git a/src/lib/inflate64_config.h b/src/lib/inflate64_config.h
+index 16cfd12..ade7300 100644
+--- a/src/lib/inflate64_config.h
++++ b/src/lib/inflate64_config.h
+@@ -53,9 +53,6 @@
+ #  define FAR
+ #endif
+ 
+-#ifndef const
+-#  define const
+-#endif
+ #define z_const const
+ 
+ typedef unsigned char  uch;
diff --git a/meta-python/recipes-devtools/python/python3-inflate64_1.0.0.bb b/meta-python/recipes-devtools/python/python3-inflate64_1.0.0.bb
index 2ccc98e36b..9fbd5157af 100644
--- a/meta-python/recipes-devtools/python/python3-inflate64_1.0.0.bb
+++ b/meta-python/recipes-devtools/python/python3-inflate64_1.0.0.bb
@@ -6,6 +6,7 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c"
 
 inherit setuptools3 pypi
 
+SRC_URI += "file://0001-Do-not-override-const-qualifier.patch"
 SRC_URI[sha256sum] = "3278827b803cf006a1df251f3e13374c7d26db779e5a33329cc11789b804bc2d"
 
 PYPI_PACKAGE = "inflate64"