Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/configure: Replace hardcoded -ldl with check based on dlfcn.h availability
@ 2013-04-17 16:39 Pavel Chupin
  2013-05-06 11:28 ` Pavel Chupin
  0 siblings, 1 reply; 8+ messages in thread
From: Pavel Chupin @ 2013-04-17 16:39 UTC (permalink / raw)
  To: gdb-patches

[-- 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-05-16 14:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-17 16:39 [PATCH] gdb/configure: Replace hardcoded -ldl with check based on dlfcn.h availability Pavel Chupin
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox