commit 7d04eca24fb83cf38176490460ee77a7fc40d458 Author: Pavel Chupin Date: Fri Jan 11 14:00:44 2013 +0400 Fix mingw gold build with plugins enabled Signed-off-by: Pavel Chupin 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/configure.ac b/gold/configure.ac index 804a474..9ab7973 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -505,6 +505,13 @@ 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) + +dnl When plugins enabled dynamic loader interface is required. Check headers +dnl which may provide this interface. In case of dlfcn.h add libdl to link. +AC_CHECK_HEADERS(windows.h) +AC_CHECK_HEADERS(dlfcn.h,lt_cv_dlopen_libs="-ldl",lt_cv_dlopen_libs="") +AC_SUBST(lt_cv_dlopen_libs) + 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..ca497f7 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -29,9 +29,39 @@ #include #ifdef ENABLE_PLUGINS +#ifdef HAVE_DLFCN_H #include +#elif defined (HAVE_WINDOWS_H) +#include +#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( + GetProcAddress(static_cast(handle),name)); +} + +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"