https://bugs.gentoo.org/show_bug.cgi?id=347931 Fix mingw gold build with plugins enabled https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=0bf402d505d293fd9ceaa6bf7ca7bd4d910fd545 diff --git a/gold/Makefile.in b/gold/Makefile.in index 216532a..f12832b 100644 --- a/gold/Makefile.in +++ b/gold/Makefile.in @@ -272,6 +273,7 @@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLOPEN_LIBS = @DLOPEN_LIBS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ @@ -398,7 +400,7 @@ AM_CPPFLAGS = \ -DTOOLLIBDIR="\"$(tooldir)/lib\"" @INCINTL@ LIBIBERTY = ../libiberty/libiberty.a -@PLUGINS_TRUE@LIBDL = -ldl +@PLUGINS_TRUE@LIBDL = @DLOPEN_LIBS@ @THREADS_TRUE@THREADSLIB = -lpthread AM_YFLAGS = -d diff --git a/gold/config.in b/gold/config.in index 42252bf..d46fd75 100644 --- a/gold/config.in +++ b/gold/config.in @@ -73,6 +73,9 @@ don't. */ #undef HAVE_DECL_VSNPRINTF +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + /* Define to 1 if you have the header file. */ #undef HAVE_EXT_HASH_MAP @@ -184,6 +187,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the header file. */ +#undef HAVE_WINDOWS_H + /* Define to 1 if you have the header file. */ #undef HAVE_ZLIB_H diff --git a/gold/configure b/gold/configure index 9e1ee27..7e58cdf 100755 --- a/gold/configure +++ b/gold/configure @@ -596,6 +596,7 @@ MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE HAVE_PUBNAMES_FALSE HAVE_PUBNAMES_TRUE +DLOPEN_LIBS CXXCPP HAVE_ZLIB_FALSE HAVE_ZLIB_TRUE @@ -7139,6 +7140,35 @@ fi done + +for ac_header in windows.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "windows.h" "ac_cv_header_windows_h" "$ac_includes_default" +if test "x$ac_cv_header_windows_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_WINDOWS_H 1 +_ACEOF + +fi + +done + +for ac_header in dlfcn.h +do : + ac_fn_cxx_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 + + + for ac_func in mallinfo posix_fallocate fallocate readv sysconf times do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/gold/plugin.cc b/gold/plugin.cc index c39e11e..9176e06 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -1,6 +1,6 @@ // plugin.cc -- plugin manager for gold -*- C++ -*- -// Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. // Written by Cary Coutant . // This file is part of gold. @@ -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" diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 6e22934..b2eb352 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -1878,6 +1878,7 @@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLOPEN_LIBS = @DLOPEN_LIBS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@