Fix mingw gold build with plugins enabled

* Makefile.am: Replace -ldl with @DLOPEN_LIBS@.
	* configure.ac: Export DLOPEN_LIBS and add headers check.
	* plugin.cc: Handle non-dlfcn case.
	* Makefile.in: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.in: Regenerate.
This commit is contained in:
Ian Lance Taylor 2013-01-11 14:36:36 +00:00
parent 02be4619f1
commit 0bf402d505
8 changed files with 95 additions and 6 deletions

View File

@ -1,3 +1,14 @@
2013-01-11 Pavel Chupin <pavel.v.chupin@intel.com>
Fix mingw gold build with plugins enabled
* Makefile.am: Replace -ldl with @DLOPEN_LIBS@.
* configure.ac: Export DLOPEN_LIBS and add headers check.
* plugin.cc: Handle non-dlfcn case.
* Makefile.in: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.
2013-01-09 Sriraman Tallam <tmsriram@google.com>
* output.h (sort_attached_input_sections): Change to be public.

View File

@ -1,6 +1,7 @@
## Process this file with automake to generate Makefile.in
#
# Copyright 2012 Free Software Foundation
# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -37,7 +38,7 @@ AM_CPPFLAGS = \
LIBIBERTY = ../libiberty/libiberty.a
if PLUGINS
LIBDL = -ldl
LIBDL = @DLOPEN_LIBS@
endif
if THREADS

View File

@ -16,7 +16,8 @@
@SET_MAKE@
#
# Copyright 2012 Free Software Foundation
# Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
# Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -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

View File

@ -73,6 +73,9 @@
don't. */
#undef HAVE_DECL_VSNPRINTF
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <ext/hash_map> header file. */
#undef HAVE_EXT_HASH_MAP
@ -184,6 +187,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* Define to 1 if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H

30
gold/configure vendored
View File

@ -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`

View File

@ -1,6 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Copyright 2012 Free Software Foundation
dnl Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
dnl Free Software Foundation, Inc.
dnl
dnl This file is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
@ -505,6 +506,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, [DLOPEN_LIBS="-ldl"], [DLOPEN_LIBS=""])
AC_SUBST(DLOPEN_LIBS)
AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times)
AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem])

View File

@ -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 <ccoutant@google.com>.
// This file is part of gold.
@ -29,9 +29,39 @@
#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 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"

View File

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