public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH mingw/gold] Fix mingw gold build with plugins enabled for non-dlfcn case
@ 2012-12-28 18:41 Pavel Chupin
  2013-01-05 19:18 ` Ian Lance Taylor
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Chupin @ 2012-12-28 18:41 UTC (permalink / raw)
  To: binutils

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

Hi,
Attached patch fixes mingw build configured (for example) as:

../configure --prefix=`pwd`/../INSTALL --target=i686-linux-android
--host=i586-pc-mingw32msvc --build=i386-linux-gnu --enable-plugins
--enable-gold
make

Error message:

../../gold/plugin.cc:32:19: fatal error: dlfcn.h: No such file or directory

I'm fixing it like it's done in bfd configure: check for headers and
library, add/not-add -ldl on link.
Also adding windows.h case into plugin.cc to handle case when
mingw-dlfcn is not installed on the system.

ChangeLog:

2012-12-25  Pavel Chupin  <pavel.v.chupin@intel.com>

       Fix mingw gold build with plugins enabled
       * gold/Makefile.am: Replace -ldl with @lt_cv_dlopen_libs@.
       * gold/aclocal.m4: Include libtool modules.
       * gold/configure.ac: Export lt_cv_dlopen_libs and add headers check.
       * gold/plugin.cc: Handle non-dlfcn case.
       * gold/Makefile.in: Regenerate.
       * gold/config.in: Regenerate.
       * gold/configure: Regenerate.
       * gold/testsuite/Makefile.in: Regenerate.

Ok for trunk?

--
Pavel Chupin
Intel Corporation

[-- Attachment #2: gold-mingw-plugins.patch --]
[-- Type: application/octet-stream, Size: 2757 bytes --]

commit a1acf449032c28dd029183afd5ed6241212c727f
Author: Pavel Chupin <pavel.v.chupin@intel.com>
Date:   Tue Dec 25 14:51:24 2012 +0400

    Fix mingw gold build with plugins enabled
    
    Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>

diff --git a/gold/Makefile.am b/gold/Makefile.am
index df8dcb5..0c13c10 100644
--- a/gold/Makefile.am
+++ b/gold/Makefile.am
@@ -37,7 +37,7 @@ AM_CPPFLAGS = \
 LIBIBERTY = ../libiberty/libiberty.a
 
 if PLUGINS
-LIBDL = -ldl
+LIBDL = @lt_cv_dlopen_libs@
 endif
 
 if THREADS
diff --git a/gold/aclocal.m4 b/gold/aclocal.m4
index 8321894..9f95f1e 100644
--- a/gold/aclocal.m4
+++ b/gold/aclocal.m4
@@ -989,4 +989,9 @@ m4_include([../config/override.m4])
 m4_include([../config/po.m4])
 m4_include([../config/progtest.m4])
 m4_include([../config/zlib.m4])
+m4_include([../libtool.m4])
+m4_include([../ltoptions.m4])
+m4_include([../ltsugar.m4])
+m4_include([../ltversion.m4])
+m4_include([../lt~obsolete.m4])
 m4_include([../bfd/warning.m4])
diff --git a/gold/configure.ac b/gold/configure.ac
index 9d23835..ae4cc5a 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -290,6 +290,10 @@ AC_PROG_LN_S
 
 AC_GNU_SOURCE
 
+# required when plugins enabled
+LT_INIT([dlopen])
+AC_SUBST(lt_cv_dlopen_libs)
+
 ZW_GNU_GETTEXT_SISTER_DIR
 AM_PO_SUBDIRS
 
@@ -517,6 +521,9 @@ AC_LANG_PUSH(C++)
 AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map)
 AC_CHECK_HEADERS(ext/hash_map ext/hash_set)
 AC_CHECK_HEADERS(byteswap.h)
+
+AC_CHECK_HEADERS(windows.h dlfcn.h)
+
 AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times)
 AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])
 
diff --git a/gold/plugin.cc b/gold/plugin.cc
index c39e11e..93a8ba8 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -29,9 +29,45 @@
 #include <vector>
 
 #ifdef ENABLE_PLUGINS
+#ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
+#elif defined (HAVE_WINDOWS_H)
+#include <windows.h>
+#else
+#error Unknown how to handle dynamic-load-libraries.
 #endif
 
+#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
+
+#define RTLD_NOW 0      /* Dummy value.  */
+static void *
+dlopen (const char *file, int mode ATTRIBUTE_UNUSED)
+{
+  return LoadLibrary (file);
+}
+
+static void *
+dlsym (void *handle, const char *name)
+{
+  return reinterpret_cast<void *>(GetProcAddress (static_cast<HMODULE>(handle), name));
+}
+
+static int ATTRIBUTE_UNUSED
+dlclose (void *handle)
+{
+  FreeLibrary (static_cast<HMODULE>(handle));
+  return 0;
+}
+
+static const char *
+dlerror (void)
+{
+  return "Unable to load DLL.";
+}
+
+#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)  */
+#endif /* ENABLE_PLUGINS */
+
 #include "parameters.h"
 #include "errors.h"
 #include "fileread.h"

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

end of thread, other threads:[~2013-01-14 14:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-28 18:41 [PATCH mingw/gold] Fix mingw gold build with plugins enabled for non-dlfcn case Pavel Chupin
2013-01-05 19:18 ` Ian Lance Taylor
2013-01-09 14:35   ` Pavel Chupin
2013-01-09 15:50     ` Ian Lance Taylor
2013-01-10  8:25       ` Pavel Chupin
2013-01-10 18:04         ` Ian Lance Taylor
2013-01-11 12:31           ` Pavel Chupin
2013-01-11 14:36             ` Ian Lance Taylor
2013-01-14 14:12               ` Pavel Chupin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).