From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 143723829BD4; Sun, 29 May 2022 19:07:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 143723829BD4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10785] libiberty, configure, Darwin: Avoid detecting deprecated sbrk. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: d1618884bc3d0013df18a1e550357e6156e9a5ed X-Git-Newrev: 1f459833392b4520d5edfeeadd33150b71061b7a Message-Id: <20220529190742.143723829BD4@sourceware.org> Date: Sun, 29 May 2022 19:07:42 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 May 2022 19:07:42 -0000 https://gcc.gnu.org/g:1f459833392b4520d5edfeeadd33150b71061b7a commit r10-10785-g1f459833392b4520d5edfeeadd33150b71061b7a Author: Iain Sandoe 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 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 */