public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libiberty, configure, Darwin: Avoid detecting deprecated  sbrk.
@ 2021-08-30 19:29 Iain Sandoe
  2021-09-01 17:45 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Iain Sandoe @ 2021-08-30 19:29 UTC (permalink / raw)
  To: GCC Patches; +Cc: Ian Lance Taylor

Hi,

Darwin provides an implementation of sbrk, which is detected by the
libiberty configuration process.

However, (like most of the BSD-derivatives) sbrk/brk are deprecated on
Darwin which leads to build-time warnings.  It seems that the configure
process does not see the deprecation warnings as reason for excluding
the fn.

Darwin should use the malloc-based implementation.

This patch works around the issue by removing sbrk from the functions
searched (for Darwin only, although it’s likely that other BSD-ish ports
might wish to do the same).

Open to more elegant solutions, of course,
tested on powerpc,i686,x86_64-darwin, x86_64, powerpc64- linux,

OK for master?
thanks Iain

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.
---
 libiberty/configure    | 43 ++++++++++++++++++++----------------------
 libiberty/configure.ac | 15 +++++++++++++--
 libiberty/xmalloc.c    |  2 ++
 3 files changed, 35 insertions(+), 25 deletions(-)

diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index a85ff25501a..4b78c1830c7 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -395,9 +395,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
@@ -695,7 +702,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 85826c1e10f..b9e23c38643 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] 2+ messages in thread

* Re: [PATCH] libiberty, configure, Darwin: Avoid detecting deprecated sbrk.
  2021-08-30 19:29 [PATCH] libiberty, configure, Darwin: Avoid detecting deprecated sbrk Iain Sandoe
@ 2021-09-01 17:45 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-09-01 17:45 UTC (permalink / raw)
  To: Iain Sandoe, GCC Patches; +Cc: Ian Lance Taylor



On 8/30/2021 1:29 PM, Iain Sandoe wrote:
> Hi,
>
> Darwin provides an implementation of sbrk, which is detected by the
> libiberty configuration process.
>
> However, (like most of the BSD-derivatives) sbrk/brk are deprecated on
> Darwin which leads to build-time warnings.  It seems that the configure
> process does not see the deprecation warnings as reason for excluding
> the fn.
>
> Darwin should use the malloc-based implementation.
>
> This patch works around the issue by removing sbrk from the functions
> searched (for Darwin only, although it’s likely that other BSD-ish ports
> might wish to do the same).
>
> Open to more elegant solutions, of course,
> tested on powerpc,i686,x86_64-darwin, x86_64, powerpc64- linux,
>
> OK for master?
> thanks Iain
>
> 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.
OK
jeff


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-01 17:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 19:29 [PATCH] libiberty, configure, Darwin: Avoid detecting deprecated sbrk Iain Sandoe
2021-09-01 17:45 ` Jeff Law

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).