commit:     183d0c261597f9bb247f19174f224bd307edc71c
Author:     NHOrus <jy6x2b32pie9 <AT> yahoo <DOT> com>
AuthorDate: Thu Jan 30 14:47:08 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Feb 10 08:51:46 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=183d0c26

sys-devel/smatch: update EAPI 7 -> 8, fix build failures with C23

Non-deterministic build, usage of unreachable() with completely
different meaning than C23 intends, incompatible function pointer
types.

Add cgcc wrapper for "build and check project" process documented in
sparse.rst, replace sparse readme with smatch.rst readme

Closes: https://bugs.gentoo.org/944322
Closes: https://bugs.gentoo.org/881087
Closes: https://bugs.gentoo.org/882047
Signed-off-by: NHOrus <jy6x2b32pie9 <AT> yahoo.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-devel/smatch/files/smatch-1.72-C23.patch       | 20 ++++++++
 .../files/smatch-1.72-function-prototype.patch     | 54 ++++++++++++++++++++++
 sys-devel/smatch/files/smatch-1.72-make-deps.patch | 14 ++++++
 .../{smatch-1.72.ebuild => smatch-1.72-r1.ebuild}  | 19 +++++---
 4 files changed, 100 insertions(+), 7 deletions(-)

diff --git a/sys-devel/smatch/files/smatch-1.72-C23.patch 
b/sys-devel/smatch/files/smatch-1.72-C23.patch
new file mode 100644
index 000000000000..40540180f25f
--- /dev/null
+++ b/sys-devel/smatch/files/smatch-1.72-C23.patch
@@ -0,0 +1,20 @@
+unreachable() is defined in C23 as function-like macro, undefine
+This definition conflicts with usage in smatch, as it has a valid
+meaning in processing syntactic tree, not a mark that part of the
+smatch state itself can't be reached.
+Other possible solution would be mass-rename of all usages to prevent
+conflict.
+https://bugs.gentoo.org/944322
+--- a/smatch.h
++++ b/smatch.h
+@@ -717,6 +717,10 @@ void __set_fake_cur_stree_fast(struct stree *stree);
+ void __pop_fake_cur_stree_fast(void);
+ void __merge_stree_into_cur(struct stree *stree);
+ 
++#if __STDC_VERSION__ > 201710L
++#undef unreachable //defined in C23
++#endif
++
+ int unreachable(void);
+ void __set_cur_stree_readonly(void);
+ void __set_cur_stree_writable(void);

diff --git a/sys-devel/smatch/files/smatch-1.72-function-prototype.patch 
b/sys-devel/smatch/files/smatch-1.72-function-prototype.patch
new file mode 100644
index 000000000000..abf7a330ccd9
--- /dev/null
+++ b/sys-devel/smatch/files/smatch-1.72-function-prototype.patch
@@ -0,0 +1,54 @@
+https://bugs.gentoo.org/881087
+Modified to work with 1.72 and 1.73
+From 223d2a8d0391a655e853f5deba1f06c75196bdf2 Mon Sep 17 00:00:00 2001
+From: =?utf8?q?Luk=C3=A1=C5=A1=20Zaoral?= <[email protected]>
+Date: Fri, 19 Jan 2024 17:39:39 +0100
+Subject: [PATCH 1/1] untracked_param: fix compilation errors with GCC 14
+MIME-Version: 1.0
+Content-Type: text/plain; charset=utf8
+Content-Transfer-Encoding: 8bit
+
+select_return_states_hook expects that the passed function does not declare
+the key and value arguments as const.
+
+Signed-off-by: Lukáš Zaoral <[email protected]>
+Signed-off-by: Dan Carpenter <[email protected]>
+---
+ smatch.h                 | 2 +-
+ smatch_untracked_param.c | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/smatch.h b/smatch.h
+index ce09ae73..ecdbe684 100644
+--- a/smatch.h
++++ b/smatch.h
+@@ -1443,6 +1443,6 @@ bool buf_comp2_has_bytes(struct expression *buf_expr, 
struct expression *var);
+ bool buf_has_bytes(struct expression *buf, struct expression *var);
+ 
+ /* smatch_untracked_param.c */
+-void mark_untracked(struct expression *expr, int param, const char *key, 
const char *value);
++void mark_untracked(struct expression *expr, int param, char *key, char 
*value);
+ void add_untracked_param_hook(void (func)(struct expression *call, int 
param));
+ void add_lost_param_hook(void (func)(struct expression *call, int param));
+diff --git a/smatch_untracked_param.c b/smatch_untracked_param.c
+index b7230f06..a84889ca 100644
+--- a/smatch_untracked_param.c
++++ b/smatch_untracked_param.c
+@@ -120,12 +120,12 @@ free:
+ 
+ }
+ 
+-void mark_untracked(struct expression *expr, int param, const char *key, 
const char *value)
++void mark_untracked(struct expression *expr, int param, char *key, char 
*value)
+ {
+       mark_untracked_lost(expr, param, key, UNTRACKED_PARAM);
+ }
+ 
+-void mark_lost(struct expression *expr, int param, const char *key, const 
char *value)
++void mark_lost(struct expression *expr, int param, char *key, char *value)
+ {
+       mark_untracked_lost(expr, param, key, LOST_PARAM);
+ }
+-- 
+2.11.4.GIT
+

diff --git a/sys-devel/smatch/files/smatch-1.72-make-deps.patch 
b/sys-devel/smatch/files/smatch-1.72-make-deps.patch
new file mode 100644
index 000000000000..9d2bf1e6bebc
--- /dev/null
+++ b/sys-devel/smatch/files/smatch-1.72-make-deps.patch
@@ -0,0 +1,14 @@
+Missing build dependency was found with MAKEOPTS=--shuffle=3383668468
+and solved by expanding targets' dependencies in makefile.
+https://bugs.gentoo.org/882047
+--- a/Makefile
++++ b/Makefile
+@@ -400,7 +400,7 @@ cflags   += $($(*)-cflags) $(CPPFLAGS) $(CFLAGS)
+ selfcheck: $(OBJS:.o=.sc)
+ 
+ SPARSE_VERSION:=$(shell git describe --dirty 2>/dev/null || echo '$(VERSION)')
+-lib.o: version.h
++lib.o options.o compile-i386.o: version.h
+ version.h: FORCE
+       @echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > version.h.tmp
+       @if cmp -s version.h version.h.tmp; then \

diff --git a/sys-devel/smatch/smatch-1.72.ebuild 
b/sys-devel/smatch/smatch-1.72-r1.ebuild
similarity index 76%
rename from sys-devel/smatch/smatch-1.72.ebuild
rename to sys-devel/smatch/smatch-1.72-r1.ebuild
index 2e2fc45d2564..1b69db0bdad0 100644
--- a/sys-devel/smatch/smatch-1.72.ebuild
+++ b/sys-devel/smatch/smatch-1.72-r1.ebuild
@@ -1,7 +1,7 @@
-# Copyright 1999-2022 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=8
 
 inherit toolchain-funcs
 if [[ ${PV} == 9999 ]] ; then
@@ -9,7 +9,7 @@ if [[ ${PV} == 9999 ]] ; then
                https://repo.or.cz/r/${PN}.git";
        inherit git-r3
 else
-       SRC_URI="http://repo.or.cz/w/smatch.git/snapshot/${PV}.tar.gz -> 
${P}.tar.gz
+       SRC_URI="https://repo.or.cz/w/smatch.git/snapshot/${PV}.tar.gz -> 
${P}.tar.gz
                mirror://gentoo/${P}.tar.gz"
        # Update on bumps
        S="${WORKDIR}"/${P}-7f4b936
@@ -18,7 +18,7 @@ else
 fi
 
 DESCRIPTION="Static analysis tool for C"
-HOMEPAGE="http://smatch.sourceforge.net/";
+HOMEPAGE="https://smatch.sourceforge.net/";
 
 # bug #853733
 LICENSE="GPL-2+ MIT OSL-1.1"
@@ -28,11 +28,16 @@ RDEPEND="dev-db/sqlite"
 DEPEND="${RDEPEND}"
 BDEPEND="virtual/pkgconfig"
 
+PATCHES=(
+       "${FILESDIR}/${P}-C23.patch"
+       "${FILESDIR}/${P}-function-prototype.patch"
+       "${FILESDIR}/${P}-make-deps.patch"
+       )
+
 src_prepare() {
        default
 
        sed -i \
-               -e '/^CFLAGS =/{s:=:+=:;s:-O2 -finline-functions:${CPPFLAGS}:}' 
\
                -e 's:pkg-config:$(PKG_CONFIG):' \
                Makefile || die
 }
@@ -62,8 +67,8 @@ src_test() {
 
 src_install() {
        # default install target installs a lot of sparse cruft
-       dobin smatch
+       dobin smatch cgcc
        insinto /usr/share/smatch/smatch_data
        doins smatch_data/*
-       dodoc FAQ README
+       dodoc FAQ Documentation/smatch.rst
 }

Reply via email to