Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pavel Chupin <pavel.v.chupin@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdb/configure: Replace hardcoded -ldl with check based on dlfcn.h availability
Date: Wed, 17 Apr 2013 16:39:00 -0000	[thread overview]
Message-ID: <CANwJu1-LGhEaeA3Mmi37UkLZOAqEFpzFpKaKzL3MVA2WORdR7Q@mail.gmail.com> (raw)

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

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.


--
Pavel Chupin
Intel Corporation

[-- Attachment #2: 0001-Replace-hardcoded-ldl-with-check-based-on-dlfcn.h-av.patch --]
[-- Type: application/octet-stream, Size: 3517 bytes --]

From dc692c2a2185b0e882d945cd8dd80ff928efb1c5 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 based on dlfcn.h
 availability

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

diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 25caddd..b2a08de 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"
+    LIBS="$DLOPEN_LIBS $LIBS"
   fi
   LIBS="-lbfd -liberty $intl $LIBS"
   AC_CACHE_CHECK([$1], [$2],
diff --git a/gdb/configure b/gdb/configure
index f9d9a17..becb3c4 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12585,6 +12585,20 @@ $as_echo "#define USE_WIN32API 1" >>confdefs.h
 esac
 
 
+for ac_header in dlfcn.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
+if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+ DLOPEN_LIBS="-ldl"
+else
+  DLOPEN_LIBS=""
+fi
+
+done
+
 # Add ELF support to GDB, but only if BFD includes ELF support.
 
   OLD_CFLAGS=$CFLAGS
@@ -12598,7 +12612,7 @@ 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"
+    LIBS="$DLOPEN_LIBS $LIBS"
   fi
   LIBS="-lbfd -liberty $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
@@ -12640,7 +12654,7 @@ $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"
+    LIBS="$DLOPEN_LIBS $LIBS"
   fi
 fi
 
@@ -12657,7 +12671,7 @@ 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"
+    LIBS="$DLOPEN_LIBS $LIBS"
   fi
   LIBS="-lbfd -liberty $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" >&5
@@ -12709,7 +12723,7 @@ 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"
+    LIBS="$DLOPEN_LIBS $LIBS"
   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 ce6fa7a..a864e3c 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2025,6 +2025,7 @@ case ${host} in
 esac	    
 AC_SUBST(WIN32LIBS)
 
+AC_CHECK_HEADERS(dlfcn.h,DLOPEN_LIBS="-ldl",DLOPEN_LIBS="")
 # Add ELF support to GDB, but only if BFD includes ELF support.
 GDB_AC_CHECK_BFD([for ELF support in BFD], gdb_cv_var_elf,
                  [bfd_get_elf_phdr_upper_bound (NULL)], elf-bfd.h)
@@ -2034,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"
+    LIBS="$DLOPEN_LIBS $LIBS"
   fi
 fi
 
-- 
1.7.11.4


             reply	other threads:[~2013-04-17 11:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-17 16:39 Pavel Chupin [this message]
2013-05-06 11:28 ` Pavel Chupin
2013-05-06 12:30   ` Mark Kettenis
2013-05-07 10:02     ` Pavel Chupin
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-LGhEaeA3Mmi37UkLZOAqEFpzFpKaKzL3MVA2WORdR7Q@mail.gmail.com \
    --to=pavel.v.chupin@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /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