From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp002.apm-internet.net (smtp002.apm-internet.net [85.119.248.221]) by sourceware.org (Postfix) with ESMTPS id D29113858D34 for ; Mon, 30 Aug 2021 19:29:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D29113858D34 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 95125 invoked from network); 30 Aug 2021 19:29:37 -0000 X-APM-Out-ID: 16303517779512 X-APM-Authkey: 257869/1(257869/1) 4 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp002.apm-internet.net with SMTP; 30 Aug 2021 19:29:37 -0000 From: Iain Sandoe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [PATCH] libiberty, configure, Darwin: Avoid detecting deprecated sbrk. Message-Id: Date: Mon, 30 Aug 2021 20:29:36 +0100 Cc: Ian Lance Taylor To: GCC Patches X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2021 19:29:49 -0000 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=E2=80=99s 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 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=3D"sys_errlist sys_nerr sys_siglist" =20 checkfuncs=3D"__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" =20 +# Darwin has sbrk, but it is deprecated and that produces build-time = warnings +# so do not check for it. +case "${host}" in + *-*-darwin*) ;; + *) checkfuncs=3D"$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" =3D "y"; then @@ -695,7 +702,11 @@ if test -z "${setobjs}"; then =20 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 */