From f0b04b6c762d8fd75ef3501ae0b6d138c0825b18 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Feb 07 2023 11:11:23 +0000 Subject: Fix C99 compatibility issues in configure scripts Related to: --- diff --git a/sdcc-configure-c99.patch b/sdcc-configure-c99.patch new file mode 100644 index 0000000..bef254b --- /dev/null +++ b/sdcc-configure-c99.patch @@ -0,0 +1,136 @@ +Fix implicit function declarations and implicit ints, for +compatibility with future compilers. + +Submitted upstream: + +Part of the issues are in a bundled copy of GNU binutils; these have +already been fixed in binutils/GCC upstream. + +diff --git a/support/cpp/aclocal.m4 b/support/cpp/aclocal.m4 +index b30c780296875596..be352e4820823eeb 100644 +--- a/support/cpp/aclocal.m4 ++++ b/support/cpp/aclocal.m4 +@@ -351,17 +351,18 @@ changequote({{{,}}})dnl + #include + #include + #include ++#include + + #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON) + # define MAP_ANONYMOUS MAP_ANON + #endif + ++#ifdef HAVE_UNISTD_H ++# include ++#endif ++ + /* This mess was copied from the GNU getpagesize.h. */ + #ifndef HAVE_GETPAGESIZE +-# ifdef HAVE_UNISTD_H +-# include +-# endif +- + /* Assume that all systems that can run configure have sys/param.h. */ + # ifndef HAVE_SYS_PARAM_H + # define HAVE_SYS_PARAM_H 1 +@@ -661,22 +662,22 @@ int main() + + fd = open("conftestdata$$", O_RDONLY); + if (fd < 0) +- exit(1); ++ return 1; + + if (fstat (fd, &st)) +- exit(2); ++ return 2; + + x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (x == (char *) -1) +- exit(3); ++ return 3; + + if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ') +- exit(4); ++ return 4; + + if (munmap(x, st.st_size) < 0) +- exit(5); ++ return 5; + +- exit(0); ++ return 0; + }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no, + ac_cv_func_mmap_file=no)]) + if test $ac_cv_func_mmap_file = yes; then +diff --git a/support/sdbinutils/libiberty/aclocal.m4 b/support/sdbinutils/libiberty/aclocal.m4 +index bf8a907100f9d210..1c1a399bdd0b769d 100644 +--- a/support/sdbinutils/libiberty/aclocal.m4 ++++ b/support/sdbinutils/libiberty/aclocal.m4 +@@ -15,6 +15,7 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, + /* Test by Jim Wilson and Kaveh Ghazi. + Check whether strncmp reads past the end of its string parameters. */ + #include ++#include + + #ifdef HAVE_FCNTL_H + #include +@@ -41,7 +42,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, + + #define MAP_LEN 0x10000 + +-main () ++int ++main (void) + { + #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) + char *p; +@@ -49,7 +51,7 @@ main () + + dev_zero = open ("/dev/zero", O_RDONLY); + if (dev_zero < 0) +- exit (1); ++ return 1; + + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, dev_zero, 0); +@@ -57,7 +59,7 @@ main () + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, -1, 0); + if (p == (char *)-1) +- exit (2); ++ return 2; + else + { + char *string = "__si_type_info"; +@@ -69,7 +71,7 @@ main () + strncmp (r, q, 14); + } + #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */ +- exit (0); ++ return 0; + } + ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no, + ac_cv_func_strncmp_works=yes) +@@ -147,7 +149,8 @@ if test $ac_cv_os_cray = yes; then + fi + + AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, +-[AC_TRY_RUN([find_stack_direction () ++[AC_TRY_RUN([int ++find_stack_direction (void) + { + static char *addr = 0; + auto char dummy; +@@ -159,9 +162,10 @@ AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, + else + return (&dummy > addr) ? 1 : -1; + } +-main () ++int ++main (void) + { +- exit (find_stack_direction() < 0); ++ return find_stack_direction() < 0; + }], + ac_cv_c_stack_direction=1, + ac_cv_c_stack_direction=-1, diff --git a/sdcc.spec b/sdcc.spec index 445d07f..0c30815 100644 --- a/sdcc.spec +++ b/sdcc.spec @@ -1,6 +1,6 @@ Name: sdcc Version: 4.1.0 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Small Device C Compiler License: GPLv2+ URL: http://sdcc.sourceforge.net/ @@ -8,6 +8,7 @@ Source0: http://downloads.sourceforge.net/sdcc/sdcc-src-%{version}.tar.bz Source1: README.fedora Source2: sdcc-%{version}-lyx-preferences Patch1: sdcc-%{version}-python3.patch +Patch2: sdcc-configure-c99.patch BuildRequires: make BuildRequires: bison, gcc-c++, automake, libtool @@ -47,6 +48,7 @@ if you want to modify the C library or as reference of how it works. %setup -q -n sdcc find -name '*.{c,h,cc}' -a -perm -a=x -exec chmod -a=x '{}' \; %patch1 -p1 +%patch2 -p1 # Disable brp-strip-static-archive for now because it errors trying to # strip foreign binaries. echo '%{__os_install_post}' @@ -60,7 +62,9 @@ echo '%{__os_install_post}' OPTS='PDFOPT="/bin/cp"' # The following is to get configure.ac files to work with autoconf 2.71 -cd support/sdbinutils +cd support/cpp +autoconf +cd ../sdbinutils sed -i -e /2.64/s/2.64/2.71/ config/override.m4 autoconf cd libiberty @@ -127,6 +131,9 @@ popd %changelog +* Tue Feb 07 2023 Florian Weimer - 4.1.0-7 +- Fix C99 compatibility issues in configure scripts + * Sun Feb 05 2023 Roy Rankin - 4.1.0-6 - path to build with autoconf 2.71