commit:     da0c85ebf7953b3fd6ff5c242b22115b3227a7f8
Author:     Z. Liu <zhixu.liu <AT> gmail <DOT> com>
AuthorDate: Tue Feb 25 04:24:10 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Apr 10 10:38:04 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=da0c85eb

app-accessibility/flite: fix build w/ clang

Closes: https://bugs.gentoo.org/938721
Signed-off-by: Z. Liu <zhixu.liu <AT> gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/40747
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../flite/files/flite-2.2-remove-const-cast.patch  |  83 ++++++++++++
 app-accessibility/flite/flite-2.2-r3.ebuild        | 139 +++++++++++++++++++++
 2 files changed, 222 insertions(+)

diff --git a/app-accessibility/flite/files/flite-2.2-remove-const-cast.patch 
b/app-accessibility/flite/files/flite-2.2-remove-const-cast.patch
new file mode 100644
index 000000000000..c49aef91220e
--- /dev/null
+++ b/app-accessibility/flite/files/flite-2.2-remove-const-cast.patch
@@ -0,0 +1,83 @@
+https://github.com/festvox/flite/pull/112
+
+From 4fcb01e726b867440fc918e820a8d27bd09f3bd4 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
+
+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 */
+             {
+-- 
+2.45.2
+

diff --git a/app-accessibility/flite/flite-2.2-r3.ebuild 
b/app-accessibility/flite/flite-2.2-r3.ebuild
new file mode 100644
index 000000000000..bf364726796e
--- /dev/null
+++ b/app-accessibility/flite/flite-2.2-r3.ebuild
@@ -0,0 +1,139 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools multilib-minimal toolchain-funcs
+
+DESCRIPTION="Flite text to speech engine"
+HOMEPAGE="http://www.festvox.org/flite/ https://github.com/festvox/flite";
+SRC_URI="https://github.com/festvox/flite/archive/v${PV}.tar.gz -> ${P}.tar.gz
+       voices? (
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_ben_rm.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_guj_ad.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_guj_dp.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_guj_kt.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_hin_ab.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_kan_plv.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_mar_aup.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_mar_slp.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_pan_amp.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_tam_sdr.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_tel_kpn.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_tel_sk.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_indic_tel_ss.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_aew.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_ahw.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_aup.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_awb.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_axb.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_bdl.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_clb.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_eey.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_fem.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_gka.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_jmk.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_ksp.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_ljm.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_lnh.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_rms.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_rxr.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_slp.flitevox
+               
http://www.festvox.org/${PN}/packed/${P}/voices/cmu_us_slt.flitevox
+       )"
+
+LICENSE="BSD freetts public-domain regexp-UofT BSD-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc 
~x86"
+IUSE="alsa oss pulseaudio test voices"
+REQUIRED_USE="test? ( alsa )"
+RESTRICT="!test? ( test )"
+
+DEPEND="
+       pulseaudio? ( media-libs/libpulse[${MULTILIB_USEDEP}] )
+       !pulseaudio? ( alsa? ( 
>=media-libs/alsa-lib-1.0.27.2[${MULTILIB_USEDEP}] ) )
+"
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-1.4-audio-interface.patch
+       "${FILESDIR}"/${PN}-2.2-backport-pr30.patch
+       "${FILESDIR}"/${PN}-2.2-make-4.4.patch
+       "${FILESDIR}"/${PN}-2.2-backport-pr66.patch
+       "${FILESDIR}"/${PN}-2.2-remote-const-cast.patch
+)
+
+get_audio() {
+       if use pulseaudio; then
+               echo pulseaudio
+       elif use alsa; then
+               echo alsa
+       elif use oss; then
+               echo oss
+       else
+               echo none
+       fi
+}
+
+pkg_pretend() {
+       [[ ${MERGE_TYPE} != binary ]] && use test && tc-check-openmp
+}
+
+pkg_setup() {
+       [[ ${MERGE_TYPE} != binary ]] && use test && tc-check-openmp
+}
+
+src_unpack() {
+       for file in ${A}; do
+               case "${file}" in
+                       *.flitevox)
+                               cp -av "${DISTDIR}/${file}" "${WORKDIR}/" || 
die "Unable to copy ${file}"
+                               ;;
+                       *)
+                               unpack "${file}"
+                               ;;
+               esac
+       done
+}
+
+src_prepare() {
+       default
+       sed -i main/Makefile \
+               -e '/-rpath/s|$(LIBDIR)|$(INSTALLLIBDIR)|g' \
+               || die
+       mv configure.{in,ac} || die
+       eautoreconf
+
+       # custom makefiles
+       multilib_copy_sources
+}
+
+multilib_src_configure() {
+       local myconf=(
+               --enable-shared
+               --with-audio=$(get_audio)
+       )
+       econf "${myconf[@]}"
+}
+
+multilib_src_compile() {
+       emake -j1 CC="$(tc-getCC)" CFLAGS="${CFLAGS}"
+}
+
+multilib_src_install_all() {
+       dodoc ACKNOWLEDGEMENTS README.md
+
+       rm -rf "${D}"/usr/lib*/*.a
+
+       if use voices; then
+               insinto /usr/share/flite
+               doins "${WORKDIR}"/*.flitevox
+       fi
+}
+
+pkg_postinst() {
+       if [[ "$(get_audio)" = "none" ]]; then
+               ewarn "flite is built without audio support. Enable the"
+               ewarn "alsa, oss, or pulseaudio USE flags for audio support."
+       fi
+}

Reply via email to