flite: Fix buld with clang fortify enabled distros
PATCH 1/2 flite: Fix buld with clang fortify enabled distros
This issue shows up with upcoming glibc-2.40+ where clang fortify support has been enhanced significantly.
Set CLEANBROKEN since it does not recover from a dirty tree
Signed-off-by Khem Raj <[email protected]>
--- ...001-Remove-defining-const-as-nothing.patch | 79 +++++++++++++++++++ .../recipes-multimedia/flite/flite_2.2.bb | 3 + 2 files changed, 82 insertions(+) create mode 100644 meta-multimedia/recipes-multimedia/flite/flite/0001-Remove-defining-const-as-nothing.patch
meta-multimedia/recipes-multimedia/flite/flite/0001-Remove-defining-const-as-nothing.patch new file +79 -0
@@ -0,0 +1,79 @@ +From c71d844f5639ea447b9f795a4db5b5d43f0de814 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Tue, 2 Jul 2024 21:41:24 -0700 +Subject: [PATCH] Remove defining 'const' as nothing + +This is a hack to override constness of struct members +however, with modern compiler like clang with fortified +glibc ( 2.40+ ) headers this runs into compiler errors + +| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/flite/2.2/recipe-sysroot/usr/include/bits/stdlib.h:38:54: error: pass_object_size attribute only applies to constant pointer arguments +| 38 | __fortify_clang_overload_arg (char *, __restrict, __resolved))) +| | ^ +| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/flite/2.2/recipe-sysroot/usr/include/bits/stdlib.h:73:43: error: pass_object_size attribute only applies to constant pointer arguments +| 73 | __fortify_clang_overload_arg (char *, ,__buf), +| | ^ +| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/flite/2.2/recipe-sysroot/usr/include/bits/stdlib.h:91:55: error: pass_object_size attribute only applies to constant pointer arguments +| 91 | __NTH (wctomb (__fortify_clang_overload_arg (char *, ,__s), wchar_t __wchar)) +| | ^ +| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/flite/2.2/recipe-sysroot/usr/include/bits/stdlib.h:129:71: error: pass_object_size attribute only applies to constant pointer arguments +| 129 | __NTH (mbstowcs (__fortify_clang_overload_arg (wchar_t *, __restrict, __dst), +| | ^ +| /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/flite/2.2/recipe-sysroot/usr/include/bits/stdlib.h:159:68: error: pass_object_size attribute only applies to constant pointer arguments +| 159 | __NTH (wcstombs (__fortify_clang_overload_arg (char *, __restrict, __dst), +| | ^ +| 5 errors generated. +| + +Therefore take this out, instead cast away the 'const' qualifier where needed ( equilly dangerous ) +however limited to just this file instead of apply to all headers including system headers + +Upstream-Status: Submitted [https://github.com/festvox/flite/pull/112] +Signed-off-by: Khem Raj <[email protected]> +--- + tools/find_sts_main.c | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/tools/find_sts_main.c b/tools/find_sts_main.c +index 3c94449..a5bf8ef 100644 +--- a/tools/find_sts_main.c ++++ b/tools/find_sts_main.c +@@ -41,9 +41,6 @@ + #include <math.h> + #include <string.h> + +-/* To allow some normally const fields to manipulated during building */ +-#define const +- + #include "cst_args.h" + #include "cst_wave.h" + #include "cst_track.h" +@@ -132,16 +129,16 @@ cst_sts *find_sts(cst_wave *sig, cst_track *lpc) + lpc->frames[i],lpc->num_channels, + resd, + size); +- sts[i].size = size; ++ *(int *)(&sts[i].size) = size; + sts[i].frame = cst_alloc(unsigned short,lpc->num_channels-1); + for (j=1; j < lpc->num_channels; j++) +- sts[i].frame[j-1] = (unsigned short) ++ *(unsigned short *)(&sts[i].frame[j-1]) = (unsigned short) + (((lpc->frames[i][j]-lpc_min)/lpc_range)*65535); + if (cst_streq(residual_codec,"ulaw")) + { + sts[i].residual = cst_alloc(unsigned char,size); + for (j=0; j < size; j++) +- sts[i].residual[j] = cst_short_to_ulaw((short)resd[j]); ++ *(unsigned char *)(&sts[i].residual[j]) = cst_short_to_ulaw((short)resd[j]); + } + else if (cst_streq(residual_codec,"g721")) + { +@@ -189,7 +186,7 @@ cst_sts *find_sts(cst_wave *sig, cst_track *lpc) + { + sts[i].residual = cst_alloc(unsigned char,size); + for (j=0; j < size; j++) +- sts[i].residual[j] = cst_short_to_ulaw((short)resd[j]); ++ *(unsigned char *)(&sts[i].residual[j]) = cst_short_to_ulaw((short)resd[j]); + } + else /* Unvoiced frame */ + {
meta-multimedia/recipes-multimedia/flite/flite_2.2.bb +3 -0
@@ -9,6 +9,7 @@ inherit autotools-brokensep DEPENDS += "alsa-lib chrpath-replacement-native" SRC_URI = "git://github.com/festvox/flite.git;protocol=https;branch=master" +SRC_URI += "file://0001-Remove-defining-const-as-nothing.patch" SRCREV = "e9e2e37c329dbe98bfeb27a1828ef9a71fa84f88"
@@ -25,3 +26,5 @@ do_install:append() { } # | make[1]: *** No rule to make target 'flite_voice_list.c', needed by 'all'. Stop. PARALLEL_MAKE = "" + +CLEANBROKEN = "1"
PATCH 2/2 python3-inflate64: Fix build with clang fortified glibc headers
This issue is seen with upcoming glibc 2.40
Signed-off-by Khem Raj <[email protected]>
--- ...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
meta-python/recipes-devtools/python/python3-inflate64/0001-Do-not-override-const-qualifier.patch new file +83 -0
@@ -0,0 +1,83 @@ +From 7e3a795cbeea94b3324aa926f2b11904cb169acc Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +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 <[email protected]> +--- + 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;
meta-python/recipes-devtools/python/python3-inflate64_1.0.0.bb +1 -0
@@ -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"