commit:     ef0f2d0c1e074d48a6272a646dd0cb7f0605d160
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 01:13:59 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 01:13:59 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ef0f2d0c

sys-apps/texinfo: backport LTO & crash fixes

>From 7.0.1 branch.

Closes: https://bugs.gentoo.org/863713
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/texinfo-7.0.1-info-groff-crash.patch     | 44 ++++++++++++++
 .../files/texinfo-7.0.1-lto-type-mismatch.patch    | 31 ++++++++++
 sys-apps/texinfo/texinfo-7.0.1-r1.ebuild           | 67 ++++++++++++++++++++++
 3 files changed, 142 insertions(+)

diff --git a/sys-apps/texinfo/files/texinfo-7.0.1-info-groff-crash.patch 
b/sys-apps/texinfo/files/texinfo-7.0.1-info-groff-crash.patch
new file mode 100644
index 000000000000..d215ae719ccb
--- /dev/null
+++ b/sys-apps/texinfo/files/texinfo-7.0.1-info-groff-crash.patch
@@ -0,0 +1,44 @@
+https://git.savannah.gnu.org/cgit/texinfo.git/commit/?h=release/7.0&id=86185e7cedafd011376d0efb6f7e028231dbf641
+
+From 86185e7cedafd011376d0efb6f7e028231dbf641 Mon Sep 17 00:00:00 2001
+From: Gavin Smith <[email protected]>
+Date: Mon, 12 Dec 2022 18:40:01 +0000
+Subject: =?UTF-8?q?*=20info/util.c=20(text=5Fbuffer=5Ficonv):=20Correctly?=
+ =?UTF-8?q?=20update=20arguments=20for=20iconv=20in=20loop.=20=20Crash=20f?=
+ =?UTF-8?q?or=20"info=20groff"=20reported=20by=20Jakub=20Wilk=20via=20Hilm?=
+ =?UTF-8?q?ar=20Preu=C3=9Fe=20<[email protected]>.?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+--- a/info/util.c
++++ b/info/util.c
+@@ -350,11 +350,11 @@ text_buffer_iconv (struct text_buffer *buf, iconv_t 
iconv_state,
+   size_t iconv_ret;
+   size_t extra_alloc = 1;
+ 
+-  outptr = text_buffer_base (buf) + text_buffer_off (buf);
+-  out_bytes_left = text_buffer_space_left (buf);
+-
+   while (1)
+     {
++      outptr = text_buffer_base (buf) + text_buffer_off (buf);
++      out_bytes_left = text_buffer_space_left (buf);
++
+       iconv_ret = iconv (iconv_state, inbuf, inbytesleft,
+                          &outptr, &out_bytes_left);
+       if (iconv_ret != (size_t) -1)
+@@ -362,10 +362,7 @@ text_buffer_iconv (struct text_buffer *buf, iconv_t 
iconv_state,
+ 
+       /* If we ran out of space, allocate more and try again. */
+       if (errno == E2BIG)
+-        {
+-          text_buffer_alloc (buf, (extra_alloc *= 4));
+-          out_bytes_left = text_buffer_space_left (buf);
+-        }
++        text_buffer_alloc (buf, (extra_alloc *= 4));
+       else
+         break; /* let calling code deal with it */
+     }
+-- 
+cgit v1.1

diff --git a/sys-apps/texinfo/files/texinfo-7.0.1-lto-type-mismatch.patch 
b/sys-apps/texinfo/files/texinfo-7.0.1-lto-type-mismatch.patch
new file mode 100644
index 000000000000..a8906195480e
--- /dev/null
+++ b/sys-apps/texinfo/files/texinfo-7.0.1-lto-type-mismatch.patch
@@ -0,0 +1,31 @@
+https://git.savannah.gnu.org/cgit/texinfo.git/patch/?id=952b333db85f88fb51c7e051b15063d95cf7dfc8
+https://lists.gnu.org/archive/html/bug-texinfo/2022-12/msg00034.html
+https://bugs.gentoo.org/863713
+
+From 952b333db85f88fb51c7e051b15063d95cf7dfc8 Mon Sep 17 00:00:00 2001
+From: Gavin Smith <[email protected]>
+Date: Sat, 10 Dec 2022 01:10:38 +0000
+Subject: =?UTF-8?q?*=20install-info/install-info.c=20(error):=20Declare=20?=
+ =?UTF-8?q?as=20static=20to=20avoid=20clash=20with=20error=20function=20fr?=
+ =?UTF-8?q?om=20glibc,=20called=20from=20gnulib.=20Report=20from=20Sam=20J?=
+ =?UTF-8?q?ames=20<[email protected]>=20and=20suggested=20solution=20from=20A?=
+ =?UTF-8?q?rsen=20Arsenovi=C4=87=20<[email protected]>.?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+--- a/install-info/install-info.c
++++ b/install-info/install-info.c
+@@ -214,7 +214,9 @@ vdiag (const char *fmt, const char *diagtype, va_list ap)
+   putc ('\n', stderr);
+ }
+ 
+-void
++/* declare as static to avoid clash with glibc error function, called from
++   gnulib. */
++static void
+ error (const char *fmt, ...)
+ {
+   va_list ap;
+-- 
+cgit v1.1

diff --git a/sys-apps/texinfo/texinfo-7.0.1-r1.ebuild 
b/sys-apps/texinfo/texinfo-7.0.1-r1.ebuild
new file mode 100644
index 000000000000..ac7dbea1ee77
--- /dev/null
+++ b/sys-apps/texinfo/texinfo-7.0.1-r1.ebuild
@@ -0,0 +1,67 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Note: if your package uses the texi2dvi utility, it must depend on the
+# virtual/texi2dvi package to pull in all the right deps.  The tool is not
+# usable out-of-the-box because it requires the large tex packages.
+
+EAPI=8
+
+inherit flag-o-matic toolchain-funcs
+
+DESCRIPTION="The GNU info program and utilities"
+HOMEPAGE="https://www.gnu.org/software/texinfo/";
+
+if [[ $(ver_cut 3) -ge 90 ]] ; then
+       SRC_URI="https://alpha.gnu.org/gnu/${PN}/${P}.tar.xz";
+else
+       SRC_URI="mirror://gnu/${PN}/${P}.tar.xz"
+       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc 
~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos 
~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+fi
+
+LICENSE="GPL-3+"
+SLOT="0"
+IUSE="nls +standalone static"
+
+RDEPEND="
+       !=app-text/tetex-2*
+       >=sys-libs/ncurses-5.2-r2:=
+       virtual/perl-Data-Dumper
+       virtual/perl-Encode
+       standalone? ( >=dev-lang/perl-5.8.1 )
+       !standalone?  ( >=dev-lang/perl-5.8.1:= )
+       nls? ( virtual/libintl )
+"
+DEPEND="${RDEPEND}"
+BDEPEND="nls? ( >=sys-devel/gettext-0.19.6 )"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-lto-type-mismatch.patch
+       "${FILESDIR}"/${P}-info-groff-crash.patch
+)
+
+src_prepare() {
+       default
+
+       if use prefix ; then
+               sed -i -e '1c\#!/usr/bin/env sh' util/texi2dvi util/texi2pdf || 
die
+               touch doc/{texi2dvi,texi2pdf,pdftexi2dvi}.1
+       fi
+}
+
+src_configure() {
+       # Respect compiler and CPPFLAGS/CFLAGS/LDFLAGS for Perl extensions
+       # bug #622576
+       local -x PERL_EXT_CC="$(tc-getCC)" PERL_EXT_CPPFLAGS="${CPPFLAGS}"
+       local -x PERL_EXT_CFLAGS="${CFLAGS}" PERL_EXT_LDFLAGS="${LDFLAGS}"
+
+       use static && append-ldflags -static
+
+       local myeconfargs=(
+               --cache-file="${S}"/config.cache
+               $(use_enable nls)
+               $(use_enable !standalone perl-xs)
+       )
+
+       econf "${myeconfargs[@]}"
+}

Reply via email to