Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pavel Chupin <pavel.v.chupin@gmail.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/configure: Replace hardcoded -ldl with check based on dlfcn.h availability
Date: Tue, 07 May 2013 10:02:00 -0000	[thread overview]
Message-ID: <CANwJu1_HerKDCXB4gWAXMQY5TBe++X1A2bFSPcj+xg+MGnYQtA@mail.gmail.com> (raw)
In-Reply-To: <201305061230.r46CU0P4006086@glazunov.sibelius.xs4all.nl>

[-- Attachment #1: Type: text/plain, Size: 1431 bytes --]

On Mon, May 6, 2013 at 4:30 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Mon, 6 May 2013 15:28:14 +0400
>> From: Pavel Chupin <pavel.v.chupin@gmail.com>
>>
>> On Wed, Apr 17, 2013 at 3:21 PM, Pavel Chupin <pavel.v.chupin@gmail.com> wrote:
>> > Hi,
>> > Attached patch adds check for dlfcn.h header availability before
>> > adding -ldl to some configure commands. Otherwise on some
>> > configuration -ldl is added unconditionally even though it's not
>> > required and gdb is configured without ELF support due to failed link.
>> >
>> > Issue is found on mingw gdb build for Android.
>> >
>> > gdb/ChangeLog entry:
>> > 2013-04-16  Pavel Chupin  <pavel.v.chupin@intel.com>
>> >
>> >         Replace hardcoded -ldl with check based on dlfcn.h availability
>> >         * configure.ac: Add dlfcn.h check and DLOPEN_LIBS def.
>> >         * acinclude.m4: Use DLOPEN_LIBS instead of hardcode.
>> >         * configure: Regenerate.
>> >
>>
>> Ping
>
> The fix isn't quite right.  OpenBSD for example has <dlfcn.h> but no
> libdl; dlopen(3) and friends live in libc.

Hi Mark,
Thanks for your comments. Please see new patch attached.

Updated ChangeLog:

2013-05-07  Pavel Chupin  <pavel.v.chupin@intel.com>

        Replace hardcoded -ldl with check for availability
        * acinclude.m4: Add check for dlopen in libdl.
        * configure.ac: Ditto.
        * configure: Regenerate.

--
Pavel Chupin
Intel Corporation

[-- Attachment #2: 0001-Replace-hardcoded-ldl-with-check-for-availability.patch --]
[-- Type: application/octet-stream, Size: 7151 bytes --]

From e0859b03d7b5cf7aa48730dd02ba0f83c1fc2b6c Mon Sep 17 00:00:00 2001
From: Pavel Chupin <pavel.v.chupin@intel.com>
Date: Tue, 16 Apr 2013 16:05:20 +0400
Subject: [PATCH] Replace hardcoded -ldl with check for availability

Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
---
 gdb/acinclude.m4 |   2 +-
 gdb/configure    | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 gdb/configure.ac |   2 +-
 3 files changed, 182 insertions(+), 6 deletions(-)

diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 25caddd..644c1f7 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -455,7 +455,7 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
   # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
   if test "$plugins" = "yes"; then
-    LIBS="-ldl $LIBS"
+    AC_CHECK_LIB(dl, dlopen)
   fi
   LIBS="-lbfd -liberty $intl $LIBS"
   AC_CACHE_CHECK([$1], [$2],
diff --git a/gdb/configure b/gdb/configure
index c5ad94b..449f23c 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12599,7 +12599,51 @@ esac
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
   # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
   if test "$plugins" = "yes"; then
-    LIBS="-ldl $LIBS"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
   fi
   LIBS="-lbfd -liberty $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
@@ -12641,7 +12685,51 @@ $as_echo "#define HAVE_ELF 1" >>confdefs.h
 
   # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
   if test "$plugins" = "yes"; then
-    LIBS="-ldl $LIBS"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
   fi
 fi
 
@@ -12658,7 +12746,51 @@ fi
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
   # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
   if test "$plugins" = "yes"; then
-    LIBS="-ldl $LIBS"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
   fi
   LIBS="-lbfd -liberty $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" >&5
@@ -12710,7 +12842,51 @@ fi
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
   # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
   if test "$plugins" = "yes"; then
-    LIBS="-ldl $LIBS"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBDL 1
+_ACEOF
+
+  LIBS="-ldl $LIBS"
+
+fi
+
   fi
   LIBS="-lbfd -liberty $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SOM support in BFD" >&5
diff --git a/gdb/configure.ac b/gdb/configure.ac
index bb7fbdd..8d53e25 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2035,7 +2035,7 @@ if test $gdb_cv_var_elf = yes; then
 	    [Define if ELF support should be included.])
   # -ldl is provided by bfd/Makfile.am (LIBDL) <PLUGINS>.
   if test "$plugins" = "yes"; then
-    LIBS="-ldl $LIBS"
+    AC_CHECK_LIB(dl, dlopen)
   fi
 fi
 
-- 
1.7.11.4


  reply	other threads:[~2013-05-07 10:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-17 16:39 Pavel Chupin
2013-05-06 11:28 ` Pavel Chupin
2013-05-06 12:30   ` Mark Kettenis
2013-05-07 10:02     ` Pavel Chupin [this message]
2013-05-14 19:00       ` Tom Tromey
2013-05-14 19:24         ` Mark Kettenis
2013-05-16  6:47           ` Pavel Chupin
2013-05-16 14:04             ` Mark Kettenis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANwJu1_HerKDCXB4gWAXMQY5TBe++X1A2bFSPcj+xg+MGnYQtA@mail.gmail.com \
    --to=pavel.v.chupin@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox