commit:     62fd83e4fe0ed20c7228a06acc880dc5a8d39224
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 23 00:24:10 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Nov 23 00:29:08 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=62fd83e4

dev-tcltk/tclreadline: fix configure w/ clang 16

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../tclreadline-2.3.8-configure-clang16.patch      | 67 ++++++++++++++++++++++
 ...2.3.8-r1.ebuild => tclreadline-2.3.8-r2.ebuild} | 23 ++++++--
 2 files changed, 84 insertions(+), 6 deletions(-)

diff --git 
a/dev-tcltk/tclreadline/files/tclreadline-2.3.8-configure-clang16.patch 
b/dev-tcltk/tclreadline/files/tclreadline-2.3.8-configure-clang16.patch
new file mode 100644
index 000000000000..1454cf54f698
--- /dev/null
+++ b/dev-tcltk/tclreadline/files/tclreadline-2.3.8-configure-clang16.patch
@@ -0,0 +1,67 @@
+https://github.com/flightaware/tclreadline/pull/46
+
+From 8c75e01b814ac852167611f5edae9659a1f709d2 Mon Sep 17 00:00:00 2001
+From: Sam James <s...@gentoo.org>
+Date: Wed, 23 Nov 2022 00:19:55 +0000
+Subject: [PATCH 1/2] Fix configure.ac compatibility with Clang 16
+
+Clang 16 makes -Wimplicit-function-declaration and -Wimplicit-int errors by 
default.
+
+Unfortunately, this can lead to misconfiguration or miscompilation of software 
as configure
+tests may then return the wrong result.
+
+We also fix -Wstrict-prototypes while here as it's easy to do and it prepares
+us for C23.
+
+For more information, see LWN.net [0] or LLVM's Discourse [1], the Gentoo wiki 
[2],
+or the (new) c-std-porting mailing list [3].
+
+[0] https://lwn.net/Articles/913505/
+[1] 
https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213
+[2] https://wiki.gentoo.org/wiki/Modern_C_porting
+[3] hosted at lists.linux.dev.
+
+Signed-off-by: Sam James <s...@gentoo.org>
+--- a/configure.ac
++++ b/configure.ac
+@@ -245,7 +245,8 @@ AC_TRY_LINK(,[
+ AC_MSG_CHECKING([for the readline version number])
+ AC_TRY_RUN([
+ #include <stdio.h>
+-int main () {
++#include <unistd.h>
++int main (void) {
+     FILE *fp = fopen("conftestversion", "w");
+     extern char *rl_library_version;
+     fprintf(fp, "%s", rl_library_version);
+
+From b64772750c7543fe66165fd7862b355d289412b6 Mon Sep 17 00:00:00 2001
+From: Sam James <s...@gentoo.org>
+Date: Wed, 23 Nov 2022 00:21:34 +0000
+Subject: [PATCH 2/2] Fix -Wint-conversion in readline configure test
+
+Fixes the following warning with Clang 16:
+```
+configure:12873: clang-16 -o conftest -g -O2   conftest.c -lreadline  >&5
+conftest.c:33:11: error: incompatible pointer to integer conversion passing 
'FILE *' (aka 'struct _IO_FILE *') to parameter of type 'int' [-Wint-conversion]
+    close(fp);
+          ^~
+/usr/include/unistd.h:358:23: note: passing argument to parameter '__fd' here
+extern int close (int __fd);
+```
+
+fopen should be paired with fclose.
+
+Signed-off-by: Sam James <s...@gentoo.org>
+--- a/configure.ac
++++ b/configure.ac
+@@ -250,7 +250,7 @@ int main (void) {
+     FILE *fp = fopen("conftestversion", "w");
+     extern char *rl_library_version;
+     fprintf(fp, "%s", rl_library_version);
+-    close(fp);
++    fclose(fp);
+     return 0;
+ }],
+     READLINE_VERSION=`cat conftestversion`
+

diff --git a/dev-tcltk/tclreadline/tclreadline-2.3.8-r1.ebuild 
b/dev-tcltk/tclreadline/tclreadline-2.3.8-r2.ebuild
similarity index 74%
rename from dev-tcltk/tclreadline/tclreadline-2.3.8-r1.ebuild
rename to dev-tcltk/tclreadline/tclreadline-2.3.8-r2.ebuild
index ff8d8154a93b..f19d330e2688 100644
--- a/dev-tcltk/tclreadline/tclreadline-2.3.8-r1.ebuild
+++ b/dev-tcltk/tclreadline/tclreadline-2.3.8-r2.ebuild
@@ -1,7 +1,9 @@
-# Copyright 2020-2021 Gentoo Authors
+# Copyright 2020-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
+
+inherit autotools
 
 DESCRIPTION="Readline extension to TCL"
 HOMEPAGE="https://github.com/flightaware/tclreadline";
@@ -13,14 +15,23 @@ SLOT="0"
 KEYWORDS="~alpha amd64 ppc ~sparc x86 ~amd64-linux ~x86-linux"
 IUSE="tk"
 
-DEPEND="dev-lang/tcl:0=
-       sys-libs/readline:0=
-       tk? ( dev-lang/tk:0= )"
+DEPEND="
+       dev-lang/tcl:=
+       sys-libs/readline:=
+       tk? ( dev-lang/tk:= )
+"
 RDEPEND="${DEPEND}"
-BDEPEND=""
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-2.3.8-configure-clang16.patch
+)
 
 src_prepare() {
        default
+
+       # Needed for Clang 16 patch, can drop once in a release
+       eautoreconf
+
        sed -i \
                -e 
"s|^\(TCLRL_LIBDIR\)=.*|\1=\"${EPREFIX}/usr/$(get_libdir)\"|" \
                configure || die

Reply via email to