summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormark.yang <mark.yang@lge.com>2025-04-03 15:13:51 +0900
committerKhem Raj <raj.khem@gmail.com>2025-04-04 19:18:20 -0700
commit0f08684d7f550c5d783f3af2a0adfffad2fbc5b5 (patch)
tree0cb49b3ea29eff27b2f30da50688799e73d84941
parent31519530f3084977294eff54ff42556c05b49fd6 (diff)
downloadmeta-openembedded-0f08684d7f550c5d783f3af2a0adfffad2fbc5b5.tar.gz
sharutils: fix build with gcc-15.0.1
* gcc-15 uses gnu23 standard for c: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212 bool is included as a reserved word, causing an error due to duplicate declaration. Also, when parameters are empty, an error occurs. Therefore, when using functions from the standard library, modify the defines in configure.ac and source code to use standard library functions. * ../../sharutils-4.15.2/lib/system.h:51:36: error: expected ';', identifier or '(' before 'bool' 51 | typedef enum {false = 0, true = 1} bool; | ^~~~ ../../sharutils-4.15.2/lib/system.h:79:7: error: conflicting types for 'fdopen'; have 'FILE *(void)' 79 | FILE *fdopen (); | ^~~~~~ In file included from ../lib/stdio.h:43, from ../../sharutils-4.15.2/libopts/autoopts/options.h:42, from ../../sharutils-4.15.2/src/shar-opts.h:49: recipe-sysroot/usr/include/stdio.h:299:14: note: previous declaration of 'fdopen' with type 'FILE *(int, const char *)' 299 | extern FILE *fdopen (int __fd, const char *__modes) __THROW | ^~~~~~ ../../sharutils-4.15.2/lib/system.h:82:7: error: conflicting types for 'popen'; have 'FILE *(void)' 82 | FILE *popen (); | ^~~~~ recipe-sysroot/usr/include/stdio.h:893:14: note: previous declaration of 'popen' with type 'FILE *(const char *, const char *)' 893 | extern FILE *popen (const char *__command, const char *__modes) | ^~~~~ ../../sharutils-4.15.2/src/shar.c:112:12: error: conflicting types for 'localtime'; have 'struct tm *(void)' 112 | struct tm *localtime (); | ^~~~~~~~~ In file included from ../lib/time.h:39, from ../lib/sys/stat.h:44, from ../../sharutils-4.15.2/lib/system.h:32: recipe-sysroot/usr/include/time.h:136:19: note: previous declaration of 'localtime' with type 'struct tm *(const time_t *)' {aka 'struct tm *(const long int *)'} 136 | extern struct tm *localtime (const time_t *__timer) __THROW; | ^~~~~~~~~ ../../sharutils-4.15.2/src/uudecode.c:85:16: error: conflicting types for 'getpwnam'; have 'struct passwd *(void)' 85 | struct passwd *getpwnam (); | ^~~~~~~~ In file included from ../../sharutils-4.15.2/src/uudecode.c:76: recipe-sysroot/usr/include/pwd.h:116:23: note: previous declaration of 'getpwnam' with type 'struct passwd *(const char *)' 116 | extern struct passwd *getpwnam (const char *__name) __nonnull ((1)); | ^~~~~~~~ | ^~~~~~~~~ Signed-off-by: mark.yang <mark.yang@lge.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-oe/recipes-support/sharutils/sharutils/0001-ISO-C23-Backport-stdbool.m4.patch213
-rw-r--r--meta-oe/recipes-support/sharutils/sharutils/0002-ISO-C23-Port-getcwd.m4-to-ISO-C23.patch49
-rw-r--r--meta-oe/recipes-support/sharutils/sharutils/0003-ISO-C23-Port-the-code-to-ISO-C23.patch143
-rw-r--r--meta-oe/recipes-support/sharutils/sharutils_4.15.2.bb3
4 files changed, 408 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/sharutils/sharutils/0001-ISO-C23-Backport-stdbool.m4.patch b/meta-oe/recipes-support/sharutils/sharutils/0001-ISO-C23-Backport-stdbool.m4.patch
new file mode 100644
index 0000000000..507c0c99cb
--- /dev/null
+++ b/meta-oe/recipes-support/sharutils/sharutils/0001-ISO-C23-Backport-stdbool.m4.patch
@@ -0,0 +1,213 @@
1From c349e9656440fcde2f71950d466fcddaa9a59f72 Mon Sep 17 00:00:00 2001
2From: "mark.yang" <mark.yang@lge.com>
3Date: Fri, 4 Apr 2025 14:19:00 +0900
4Subject: [PATCH 1/3] ISO C23: Backport stdbool.m4
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9From: Petr Písař <ppisar@redhat.com>
10
11The bundled gnulib check for stdbool.h did not account for ISO C23
12which provides its own false and true keywords. As a result stdbool.h
13presence was not correctly detected and libopts/compat/compat.h,
14bundled from AutoGen, failed to compile with GCC 15 which defaults to
15ISO C23:
16
17 In file included from autoopts/project.h:30,
18 from libopts.c:2:
19 ./compat/compat.h:188:19: error: cannot use keyword ‘false’ as enumeration
20constant
21 188 | typedef enum { false = 0, true = 1 } _Bool;
22 | ^~~~~
23 ./compat/compat.h:188:19: note: ‘false’ is a keyword with ‘-std=c23’ onwards
24 ./compat/compat.h:188:41: error: expected ‘;’, identifier or ‘(’ before
25‘_Bool’
26 188 | typedef enum { false = 0, true = 1 } _Bool;
27 | ^~~~~
28
29Signed-off-by: Petr Písař <ppisar@redhat.com>
30
31Upstream-Status: Backport [https://lists.gnu.org/r/bug-gnu-utils/2025-03/msg00002.html]
32Signed-off-by: mark.yang <mark.yang@lge.com>
33---
34 m4/stdbool.m4 | 129 +++++++++++++++++++++++++++++---------------------
35 1 file changed, 74 insertions(+), 55 deletions(-)
36
37diff --git a/m4/stdbool.m4 b/m4/stdbool.m4
38index 7273b82..8e00e4a 100644
39--- a/m4/stdbool.m4
40+++ b/m4/stdbool.m4
41@@ -1,27 +1,40 @@
42 # Check for stdbool.h that conforms to C99.
43
44-dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc.
45+dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
46 dnl This file is free software; the Free Software Foundation
47 dnl gives unlimited permission to copy and/or distribute it,
48 dnl with or without modifications, as long as this notice is preserved.
49
50-#serial 5
51+#serial 10
52
53 # Prepare for substituting <stdbool.h> if it is not supported.
54
55 AC_DEFUN([AM_STDBOOL_H],
56 [
57 AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
58+ AC_REQUIRE([AC_CANONICAL_HOST])
59
60- # Define two additional variables used in the Makefile substitution.
61-
62+ dnl On some platforms, <stdbool.h> does not exist or does not conform to C99.
63+ dnl On Solaris 10 with CC=cc CXX=CC, <stdbool.h> exists but is not usable
64+ dnl in C++ mode (and no <cstdbool> exists). In this case, we use our
65+ dnl replacement, also in C mode (for binary compatibility between C and C++).
66 if test "$ac_cv_header_stdbool_h" = yes; then
67- STDBOOL_H=''
68+ case "$host_os" in
69+ solaris*)
70+ if test -z "$GCC"; then
71+ GL_GENERATE_STDBOOL_H=true
72+ else
73+ GL_GENERATE_STDBOOL_H=false
74+ fi
75+ ;;
76+ *)
77+ GL_GENERATE_STDBOOL_H=false
78+ ;;
79+ esac
80 else
81- STDBOOL_H='stdbool.h'
82+ GL_GENERATE_STDBOOL_H=true
83 fi
84- AC_SUBST([STDBOOL_H])
85- AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"])
86+ AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test "$GL_GENERATE_STDBOOL_H" = "true"])
87
88 if test "$ac_cv_type__Bool" = yes; then
89 HAVE__BOOL=1
90@@ -31,70 +44,76 @@ AC_DEFUN([AM_STDBOOL_H],
91 AC_SUBST([HAVE__BOOL])
92 ])
93
94-# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
95-AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
96-
97-# This version of the macro is needed in autoconf <= 2.68.
98+m4_version_prereq([2.72], [], [
99
100 AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
101- [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
102+ [AC_CHECK_TYPES([_Bool])
103+ AC_CACHE_CHECK([for stdbool.h that conforms to C99 or later],
104 [ac_cv_header_stdbool_h],
105 [AC_COMPILE_IFELSE(
106 [AC_LANG_PROGRAM(
107- [[
108- #include <stdbool.h>
109- #ifndef bool
110- "error: bool is not defined"
111+ [[#include <stdbool.h>
112+
113+ /* "true" and "false" should be usable in #if expressions and
114+ integer constant expressions, and "bool" should be a valid
115+ type name.
116+
117+ Although C99 requires bool, true, and false to be macros,
118+ C23 and C++11 overrule that, so do not test for that.
119+ Although C99 requires __bool_true_false_are_defined and
120+ _Bool, C23 says they are obsolescent, so do not require
121+ them. */
122+
123+ #if !true
124+ #error "'true' is not true"
125 #endif
126- #ifndef false
127- "error: false is not defined"
128+ #if true != 1
129+ #error "'true' is not equal to 1"
130 #endif
131+ char b[true == 1 ? 1 : -1];
132+ char c[true];
133+
134 #if false
135- "error: false is not 0"
136+ #error "'false' is not false"
137 #endif
138- #ifndef true
139- "error: true is not defined"
140- #endif
141- #if true != 1
142- "error: true is not 1"
143- #endif
144- #ifndef __bool_true_false_are_defined
145- "error: __bool_true_false_are_defined is not defined"
146+ #if false != 0
147+ #error "'false' is not equal to 0"
148 #endif
149+ char d[false == 0 ? 1 : -1];
150+
151+ enum { e = false, f = true, g = false * true, h = true * 256 };
152+
153+ char i[(bool) 0.5 == true ? 1 : -1];
154+ char j[(bool) 0.0 == false ? 1 : -1];
155+ char k[sizeof (bool) > 0 ? 1 : -1];
156+
157+ struct sb { bool s: 1; bool t; } s;
158+ char l[sizeof s.t > 0 ? 1 : -1];
159
160- struct s { _Bool s: 1; _Bool t; } s;
161-
162- char a[true == 1 ? 1 : -1];
163- char b[false == 0 ? 1 : -1];
164- char c[__bool_true_false_are_defined == 1 ? 1 : -1];
165- char d[(bool) 0.5 == true ? 1 : -1];
166- /* See body of main program for 'e'. */
167- char f[(_Bool) 0.0 == false ? 1 : -1];
168- char g[true];
169- char h[sizeof (_Bool)];
170- char i[sizeof s.t];
171- enum { j = false, k = true, l = false * true, m = true * 256 };
172 /* The following fails for
173 HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
174- _Bool n[m];
175- char o[sizeof n == m * sizeof n[0] ? 1 : -1];
176- char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
177+ bool m[h];
178+ char n[sizeof m == h * sizeof m[0] ? 1 : -1];
179+ char o[-1 - (bool) 0 < 0 ? 1 : -1];
180 /* Catch a bug in an HP-UX C compiler. See
181- http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
182- http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
183+ https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
184+ https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html
185 */
186- _Bool q = true;
187- _Bool *pq = &q;
188+ bool p = true;
189+ bool *pp = &p;
190 ]],
191 [[
192- bool e = &s;
193- *pq |= q;
194- *pq |= ! q;
195- /* Refer to every declared value, to avoid compiler optimizations. */
196- return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
197- + !m + !n + !o + !p + !q + !pq);
198+ bool ps = &s;
199+ *pp |= p;
200+ *pp |= ! p;
201+
202+ /* Refer to every declared value, so they cannot be
203+ discarded as unused. */
204+ return (!b + !c + !d + !e + !f + !g + !h + !i + !j + !k
205+ + !l + !m + !n + !o + !p + !pp + !ps);
206 ]])],
207 [ac_cv_header_stdbool_h=yes],
208 [ac_cv_header_stdbool_h=no])])
209- AC_CHECK_TYPES([_Bool])
210-])
211+])# AC_CHECK_HEADER_STDBOOL
212+
213+]) # m4_version_prereq 2.72
diff --git a/meta-oe/recipes-support/sharutils/sharutils/0002-ISO-C23-Port-getcwd.m4-to-ISO-C23.patch b/meta-oe/recipes-support/sharutils/sharutils/0002-ISO-C23-Port-getcwd.m4-to-ISO-C23.patch
new file mode 100644
index 0000000000..44991cad1b
--- /dev/null
+++ b/meta-oe/recipes-support/sharutils/sharutils/0002-ISO-C23-Port-getcwd.m4-to-ISO-C23.patch
@@ -0,0 +1,49 @@
1From 01c13c5b455ec8d51240af20f59324b2ed15a337 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
3Date: Fri, 4 Apr 2025 14:20:05 +0900
4Subject: [PATCH 2/3] ISO C23: Port getcwd.m4 to ISO C23
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9From: Petr Písař <ppisar@redhat.com>
10
11Some confgure tests failed because of function arguments missing from
12the prototypes:
13
14 configure:16105: checking whether getcwd (NULL, 0) allocates memory for
15result
16 configure:16162: gcc -o conftest -g -O2 conftest.c >&5
17 conftest.c:186:16: error: conflicting types for 'getcwd'; have 'char
18*(void)'
19 186 | char *getcwd ();
20 | ^~~~~~
21 In file included from conftest.c:181:
22 /usr/include/unistd.h:531:14: note: previous declaration of 'getcwd' with
23type 'char *(char *, size_t)'
24
25This patch fixes it.
26
27Maintainer is encouraged to rebase the m4 files to the latest gnulib.
28
29Signed-off-by: Petr Písař <ppisar@redhat.com>
30
31Upstream-Status: Backport [https://lists.gnu.org/r/bug-gnu-utils/2025-03/msg00003.html]
32Signed-off-by: mark.yang <mark.yang@lge.com>
33---
34 m4/getcwd.m4 | 2 +-
35 1 file changed, 1 insertion(+), 1 deletion(-)
36
37diff --git a/m4/getcwd.m4 b/m4/getcwd.m4
38index b9fbcec..6f24b14 100644
39--- a/m4/getcwd.m4
40+++ b/m4/getcwd.m4
41@@ -21,7 +21,7 @@ AC_DEFUN([gl_FUNC_GETCWD_NULL],
42 # include <direct.h>
43 # endif
44 # ifndef getcwd
45- char *getcwd ();
46+ char *getcwd (char *buf, size_t size);
47 # endif
48 ]], [[
49 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
diff --git a/meta-oe/recipes-support/sharutils/sharutils/0003-ISO-C23-Port-the-code-to-ISO-C23.patch b/meta-oe/recipes-support/sharutils/sharutils/0003-ISO-C23-Port-the-code-to-ISO-C23.patch
new file mode 100644
index 0000000000..57e0ac3ed6
--- /dev/null
+++ b/meta-oe/recipes-support/sharutils/sharutils/0003-ISO-C23-Port-the-code-to-ISO-C23.patch
@@ -0,0 +1,143 @@
1From 4e50196673fc14bd6081e8a78cc940199566ba55 Mon Sep 17 00:00:00 2001
2From: "mark.yang" <mark.yang@lge.com>
3Date: Fri, 4 Apr 2025 14:38:51 +0900
4Subject: [PATCH 3/3] ISO C23: Port the code to ISO C23
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9From: Petr Písař <ppisar@redhat.com>
10
11With GCC 15, which defaults to ISO 23, a build failed, for example like
12this:
13
14 gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I..
15-I../libopts -I. -I.. -I../lib -I
16 ../lib -I../intl -Wno-format-contains-nul -g -O2 -Wno-format-contains-nul
17-c -o shar.o shar.c
18 In file included from local.h:23,
19 from shar-opts.h:354,
20 from shar.c:46:
21 ../lib/system.h:78:7: error: conflicting types for ‘fdopen’; have ‘FILE
22*(void)’
23 78 | FILE *fdopen ();
24 | ^~~~~~
25
26The cause is that ISO C23 changed a meaning of an empty argument list
27from an unspecified list to no arguments.
28
29Also K&R syntax is now deprecated and the compiler warned:
30
31 encode.c: In function ‘write_encoded_bytes’:
32 encode.c:33:1: warning: old-style function definition
33[-Wold-style-definition]
34 33 | write_encoded_bytes (group, file)
35 | ^~~~~~~~~~~~~~~~~~~
36
37This patch fixes both the erros and the warnigs by specifying all the
38arguments in the modern syntax.
39
40Signed-off-by: Petr Písař <ppisar@redhat.com>
41
42Upstream-Status: Backport [https://lists.gnu.org/r/bug-gnu-utils/2025-03/msg00001.html]
43Signed-off-by: mark.yang <mark.yang@lge.com>
44---
45 lib/system.h | 6 +++---
46 src/encode.c | 13 +++----------
47 src/shar.c | 3 +--
48 src/uudecode.c | 2 +-
49 4 files changed, 8 insertions(+), 16 deletions(-)
50
51diff --git a/lib/system.h b/lib/system.h
52index 2b9846b..811e8cf 100644
53--- a/lib/system.h
54+++ b/lib/system.h
55@@ -52,7 +52,7 @@ typedef enum {false = 0, true = 1} bool;
56 #endif
57
58 #if !HAVE_DECL_STRTOIMAX && !defined strtoimax
59-intmax_t strtoimax ();
60+intmax_t strtoimax (const char *nptr, char **endptr, int base);
61 #endif
62
63 #if HAVE_STRING_H
64@@ -75,8 +75,8 @@ intmax_t strtoimax ();
65 # include <unistd.h>
66 #endif
67
68-FILE *fdopen ();
69-FILE *popen ();
70+FILE *fdopen (int fd, const char *mode);
71+FILE *popen (const char *command, const char *type);
72
73 /* Global functions of the shar package. */
74
75diff --git a/src/encode.c b/src/encode.c
76index 09e0c69..b1de8bd 100644
77--- a/src/encode.c
78+++ b/src/encode.c
79@@ -30,9 +30,7 @@
80 `------------------------------------------*/
81
82 static void
83-write_encoded_bytes (group, file)
84- char *group;
85- FILE *file;
86+write_encoded_bytes (char *group, FILE *file)
87 {
88 int c1, c2, c3, c4;
89
90@@ -52,10 +50,7 @@ write_encoded_bytes (group, file)
91 `--------------------------------------------------------------------*/
92
93 static int
94-read_raw_bytes (file, buffer, buffer_size)
95- FILE *file;
96- char *buffer;
97- int buffer_size;
98+read_raw_bytes (FILE *file, char *buffer, int buffer_size)
99 {
100 int character;
101 int counter;
102@@ -75,9 +70,7 @@ read_raw_bytes (file, buffer, buffer_size)
103 `----------------------------------------------------*/
104
105 void
106-copy_file_encoded (input, output)
107- FILE *input;
108- FILE *output;
109+copy_file_encoded (FILE *input, FILE *output)
110 {
111 char buffer[LINE_BUFFER_SIZE];
112 int counter;
113diff --git a/src/shar.c b/src/shar.c
114index 6d7ed1d..b5e84ff 100644
115--- a/src/shar.c
116+++ b/src/shar.c
117@@ -1,4 +1,3 @@
118-
119 static const char cright_years_z[] =
120
121 /* Handle so called `shell archives'.
122@@ -109,7 +108,7 @@ static inline unsigned char to_uchar (char ch) { return ch; }
123 #define IS_GRAPH(_c) (isprint (to_uchar (_c)) && !isspace (to_uchar (_c)))
124 #endif
125
126-struct tm *localtime ();
127+struct tm *localtime (const time_t *timep);
128
129 #if MSDOS
130 /* 1 extra for CR. */
131diff --git a/src/uudecode.c b/src/uudecode.c
132index 0621c99..b8a316e 100644
133--- a/src/uudecode.c
134+++ b/src/uudecode.c
135@@ -82,7 +82,7 @@ static char const cright_years_z[] =
136 #define UU_CHMOD(_n, _fd, _m) chmod ((_n), UU_MODE_BITS(_m))
137 #endif
138
139-struct passwd *getpwnam ();
140+struct passwd *getpwnam (const char *name);
141
142 static uudecode_exit_code_t read_stduu(
143 const char *inname, const char *outname);
diff --git a/meta-oe/recipes-support/sharutils/sharutils_4.15.2.bb b/meta-oe/recipes-support/sharutils/sharutils_4.15.2.bb
index 1bded9f6d1..45bf341063 100644
--- a/meta-oe/recipes-support/sharutils/sharutils_4.15.2.bb
+++ b/meta-oe/recipes-support/sharutils/sharutils_4.15.2.bb
@@ -14,6 +14,9 @@ SRC_URI = "${GNU_MIRROR}/${BPN}/${BP}.tar.gz \
14 file://0002-Do-not-include-lib-md5.c-into-src-shar.c.patch \ 14 file://0002-Do-not-include-lib-md5.c-into-src-shar.c.patch \
15 file://0001-configure.ac-Check-and-define-intmax_t-type.patch \ 15 file://0001-configure.ac-Check-and-define-intmax_t-type.patch \
16 file://0001-libopts.m4-accept-POSIX_SHELL-from-the-environment-d.patch \ 16 file://0001-libopts.m4-accept-POSIX_SHELL-from-the-environment-d.patch \
17 file://0001-ISO-C23-Backport-stdbool.m4.patch \
18 file://0002-ISO-C23-Port-getcwd.m4-to-ISO-C23.patch \
19 file://0003-ISO-C23-Port-the-code-to-ISO-C23.patch \
17 " 20 "
18SRC_URI[sha256sum] = "ee336e68549664e7a19b117adf02edfdeac6307f22e5ba78baca457116914637" 21SRC_URI[sha256sum] = "ee336e68549664e7a19b117adf02edfdeac6307f22e5ba78baca457116914637"
19 22