diff mbox series

libbacktrace: Move define of HAVE_ZLIB into check for -lz

Message ID CABOHX+eb04n65-Vs=7PFwOFvAEbNVe92AeZ1WoEa=dLrJEFQNg@mail.gmail.com
State New
Headers show
Series libbacktrace: Move define of HAVE_ZLIB into check for -lz | expand

Commit Message

Iain Buclaw July 29, 2018, 2:50 p.m. UTC
This is really to suppress the default action-if-found for
AC_CHECK_LIBS.  Zlib is not a dependency of libbacktrace, and so it
shouldn't be added to LIBS.  When looking at the check, saw that could
remove the test for ac_cv_lib_z_compress also.

Regards
Iain
---

Comments

Li, Pan2 via Gcc-patches July 31, 2018, 2:33 p.m. UTC | #1
On Sun, Jul 29, 2018 at 7:50 AM, Iain Buclaw <ibuclaw@gdcproject.org> wrote:
>
> This is really to suppress the default action-if-found for
> AC_CHECK_LIBS.  Zlib is not a dependency of libbacktrace, and so it
> shouldn't be added to LIBS.  When looking at the check, saw that could
> remove the test for ac_cv_lib_z_compress also.

Thanks, but this doesn't seem like quite the right approach, as seen
by the fact that HAVE_ZLIB_H was dropped from config.h.in.  I think
you need to keep the AC_DEFINE out of the AC_CHECK_LIB.  I would guess
that it would work to just change the default case of AC_CHECK_LIB to
[;] or something similarly innocuous.

Ian
Iain Buclaw July 31, 2018, 3:10 p.m. UTC | #2
On 31 July 2018 at 16:33, Ian Lance Taylor <iant@google.com> wrote:
> On Sun, Jul 29, 2018 at 7:50 AM, Iain Buclaw <ibuclaw@gdcproject.org> wrote:
>>
>> This is really to suppress the default action-if-found for
>> AC_CHECK_LIBS.  Zlib is not a dependency of libbacktrace, and so it
>> shouldn't be added to LIBS.  When looking at the check, saw that could
>> remove the test for ac_cv_lib_z_compress also.
>
> Thanks, but this doesn't seem like quite the right approach, as seen
> by the fact that HAVE_ZLIB_H was dropped from config.h.in.  I think
> you need to keep the AC_DEFINE out of the AC_CHECK_LIB.  I would guess
> that it would work to just change the default case of AC_CHECK_LIB to
> [;] or something similarly innocuous.
>
> Ian

May I ask you to look at the patch again?  There's two similarly named
variables here, HAVE_LIBZ and HAVE_ZLIB.

Only the unused HAVE_LIBZ has been dropped from config.h.in.  The one
that matters has been left alone, or at least I'm pretty sure of.

Iain.
Li, Pan2 via Gcc-patches July 31, 2018, 8:27 p.m. UTC | #3
On Tue, Jul 31, 2018 at 8:10 AM, Iain Buclaw <ibuclaw@gdcproject.org> wrote:
> On 31 July 2018 at 16:33, Ian Lance Taylor <iant@google.com> wrote:
>> On Sun, Jul 29, 2018 at 7:50 AM, Iain Buclaw <ibuclaw@gdcproject.org> wrote:
>>>
>>> This is really to suppress the default action-if-found for
>>> AC_CHECK_LIBS.  Zlib is not a dependency of libbacktrace, and so it
>>> shouldn't be added to LIBS.  When looking at the check, saw that could
>>> remove the test for ac_cv_lib_z_compress also.
>>
>> Thanks, but this doesn't seem like quite the right approach, as seen
>> by the fact that HAVE_ZLIB_H was dropped from config.h.in.  I think
>> you need to keep the AC_DEFINE out of the AC_CHECK_LIB.  I would guess
>> that it would work to just change the default case of AC_CHECK_LIB to
>> [;] or something similarly innocuous.
>>
>> Ian
>
> May I ask you to look at the patch again?  There's two similarly named
> variables here, HAVE_LIBZ and HAVE_ZLIB.
>
> Only the unused HAVE_LIBZ has been dropped from config.h.in.  The one
> that matters has been left alone, or at least I'm pretty sure of.

Ah, got it.  Sorry about that.  The patch is OK with a ChangeLog entry.  Thanks.

Ian
diff mbox series

Patch

2018-07-29 Iain Buclaw  <ibuclaw@gdcproject.org>

	* configure.ac: Move define of HAVE_ZLIB into check for -lz.
	* Makefile.in: Regenerate.
	* config.h.in: Likewise.
	* configure: Likewise.

diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index f7f849bdeaf..8b5dc3e5b41 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -16,7 +16,7 @@ 
 @SET_MAKE@
 
 # Makefile.am -- Backtrace Makefile.
-# Copyright (C) 2012-2017 Free Software Foundation, Inc.
+# Copyright (C) 2012-2018 Free Software Foundation, Inc.
 
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
diff --git a/libbacktrace/config.h.in b/libbacktrace/config.h.in
index c19b6e430cb..6205fc55fa5 100644
--- a/libbacktrace/config.h.in
+++ b/libbacktrace/config.h.in
@@ -34,9 +34,6 @@ 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the `z' library (-lz). */
-#undef HAVE_LIBZ
-
 /* Define to 1 if you have the <link.h> header file. */
 #undef HAVE_LINK_H
 
diff --git a/libbacktrace/configure b/libbacktrace/configure
index 87cadda6c8c..d5a9d79e15c 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -12973,19 +12973,11 @@  fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5
 $as_echo "$ac_cv_lib_z_compress" >&6; }
 if test "x$ac_cv_lib_z_compress" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBZ 1
-_ACEOF
-
-  LIBS="-lz $LIBS"
-
-fi
-
-if test $ac_cv_lib_z_compress = "yes"; then
 
 $as_echo "#define HAVE_ZLIB 1" >>confdefs.h
 
 fi
+
  if test "$ac_cv_lib_z_compress" = yes; then
   HAVE_ZLIB_TRUE=
   HAVE_ZLIB_FALSE='#'
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 6f7b5eabca6..fd367451602 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -426,10 +426,8 @@  AC_SUBST(PTHREAD_CFLAGS)
 
 AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
 
-AC_CHECK_LIB([z], [compress], [])
-if test $ac_cv_lib_z_compress = "yes"; then
-  AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])
-fi
+AC_CHECK_LIB([z], [compress],
+    [AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
 AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
 
 dnl Test whether the linker supports the --compress_debug_sections option.