public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10785] libiberty, configure, Darwin: Avoid detecting deprecated sbrk.
@ 2022-05-29 19:07 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2022-05-29 19:07 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1f459833392b4520d5edfeeadd33150b71061b7a

commit r10-10785-g1f459833392b4520d5edfeeadd33150b71061b7a
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Mon Aug 23 17:27:25 2021 +0100

    libiberty, configure, Darwin: Avoid detecting deprecated sbrk.
    
    Darwin provides an implementation of sbrk, which is detected by
    the configuration process.  However, it is deprecated which leads
    to build warnings.  The malloc-based implementation is more
    suitable.  This patch removes sbrk from the functions searched
    for Darwin.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    libiberty/ChangeLog:
    
            * configure: Regenerate.
            * configure.ac: Do not search for sbrk on Darwin.
            * xmalloc.c: Do not declare sbrk unless it has been found
            by configure.
    
    (cherry picked from commit fbb334a6acc5cc5d8944712daeda8089ef1d7fd2)

Diff:
---
 libiberty/configure    | 17 ++++++++++++++---
 libiberty/configure.ac | 15 +++++++++++++--
 libiberty/xmalloc.c    |  2 ++
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/libiberty/configure b/libiberty/configure
index 3f82c5bb865..7bc8b571531 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5977,9 +5977,16 @@ vars="sys_errlist sys_nerr sys_siglist"
 
 checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
  getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
- realpath setrlimit sbrk spawnve spawnvpe strerror strsignal sysconf sysctl \
+ realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \
  sysmp table times wait3 wait4"
 
+# Darwin has sbrk, but it is deprecated and that produces build-time warnings
+# so do not check for it.
+case "${host}" in
+  *-*-darwin*) ;;
+  *) checkfuncs="$checkfuncs sbrk"
+esac
+
 # These are neither executed nor required, but they help keep
 # autoheader happy without adding a bunch of text to acconfig.h.
 if test "x" = "y"; then
@@ -7192,7 +7199,10 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_REALLOC $ac_have_decl
 _ACEOF
-ac_fn_c_check_decl "$LINENO" "sbrk" "ac_cv_have_decl_sbrk" "$ac_includes_default"
+
+  case "${host}" in
+      *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
+      *) ac_fn_c_check_decl "$LINENO" "sbrk" "ac_cv_have_decl_sbrk" "$ac_includes_default"
 if test "x$ac_cv_have_decl_sbrk" = xyes; then :
   ac_have_decl=1
 else
@@ -7202,7 +7212,8 @@ fi
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_SBRK $ac_have_decl
 _ACEOF
-
+;;
+  esac
   ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default"
 if test "x$ac_cv_have_decl_strtol" = xyes; then :
   ac_have_decl=1
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 4e2599c14a8..9b9ec236c3d 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -394,9 +394,16 @@ vars="sys_errlist sys_nerr sys_siglist"
 
 checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
  getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
- realpath setrlimit sbrk spawnve spawnvpe strerror strsignal sysconf sysctl \
+ realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \
  sysmp table times wait3 wait4"
 
+# Darwin has sbrk, but it is deprecated and that produces build-time warnings
+# so do not check for it.
+case "${host}" in
+  *-*-darwin*) ;;
+  *) checkfuncs="$checkfuncs sbrk"
+esac
+
 # These are neither executed nor required, but they help keep
 # autoheader happy without adding a bunch of text to acconfig.h.
 if test "x" = "y"; then
@@ -688,7 +695,11 @@ if test -z "${setobjs}"; then
 
   AC_CHECK_FUNCS($checkfuncs)
   AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
-  AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc, sbrk])
+  AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc])
+  case "${host}" in
+      *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
+      *) AC_CHECK_DECLS([sbrk]);;
+  esac
   AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull])
   AC_CHECK_DECLS([strverscmp])
   AC_CHECK_DECLS([strnlen])
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
index 96d51b57780..40b6eea62c9 100644
--- a/libiberty/xmalloc.c
+++ b/libiberty/xmalloc.c
@@ -87,7 +87,9 @@ extern "C" {
 void *malloc (size_t);
 void *realloc (void *, size_t);
 void *calloc (size_t, size_t);
+#ifdef HAVE_SBRK
 void *sbrk (ptrdiff_t);
+#endif
 #    ifdef __cplusplus
 }
 #    endif /* __cplusplus */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-29 19:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-29 19:07 [gcc r10-10785] libiberty, configure, Darwin: Avoid detecting deprecated sbrk Iain D Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).