[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ld-output-def
From: |
Simon Josefsson |
Subject: |
Re: ld-output-def |
Date: |
Wed, 01 Apr 2009 07:33:23 +0200 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.90 (gnu/linux) |
Here is an updated patch. Thoughts?
/Simon
>From cb86aabc84146a5205d5ea88b3f067d893810a1d Mon Sep 17 00:00:00 2001
From: Simon Josefsson <address@hidden>
Date: Wed, 1 Apr 2009 07:31:49 +0200
Subject: [PATCH] Add new module lib-msvc-compat.
---
MODULES.html.sh | 1 +
doc/gnulib.texi | 3 ++
doc/ld-output-def.texi | 64 +++++++++++++++++++++++++++++++++++++++++++++++
m4/ld-output-def.m4 | 30 ++++++++++++++++++++++
modules/lib-msvc-compat | 14 ++++++++++
5 files changed, 112 insertions(+), 0 deletions(-)
create mode 100644 doc/ld-output-def.texi
create mode 100644 m4/ld-output-def.m4
create mode 100644 modules/lib-msvc-compat
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 4175895..9f6e7db 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -3132,6 +3132,7 @@ func_all_modules ()
func_module include_next
func_module ldd
func_module lib-ignore
+ func_module lib-msvc-compat
func_module lib-symbol-versions
func_module link-warning
func_module no-c++
diff --git a/doc/gnulib.texi b/doc/gnulib.texi
index 6e13cdf..02927aa 100644
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -5823,6 +5823,7 @@ This list of functions is sorted according to the header
that declares them.
* Searching for Libraries::
* Exported Symbols of Shared Libraries::
* LD Version Scripts::
+* Visual Studio Compatibility::
* Supporting Relocation::
* func::
* warnings::
@@ -5915,6 +5916,8 @@ generated automatically.
@include ld-version-script.texi
address@hidden ld-output-def.texi
+
@include relocatable-maint.texi
@include func.texi
diff --git a/doc/ld-output-def.texi b/doc/ld-output-def.texi
new file mode 100644
index 0000000..3ad1feb
--- /dev/null
+++ b/doc/ld-output-def.texi
@@ -0,0 +1,64 @@
address@hidden Visual Studio Compatibility
address@hidden Visual Studio Compatibility
address@hidden DEF files
address@hidden LD DEF files
+
+The @code{lib-msvc-compat} module detects whether the linker supports
address@hidden when building a library. That parameter is used
+to generate a DEF file for a shared library (DLL). DEF files are
+useful for developers that use Visual Studio to develop programs that
+links to your library. See the GNU LD manual for more information.
+
+There are other ways to create a DEF file, but we believe they are all
+sub-optimal to using @code{--output-def} during the build process.
+The variants we have considered include:
+
address@hidden @bullet
address@hidden Use DUMPBIN /EXPORTS.
+The tool does not generate DEF files directly, so its output needs to
+be post processed manually. The tool is documented to potentially not
+work with non-MS development tools
+(@url{http://support.microsoft.com/kb/131313/en-us}), which is the
+case when MinGW is used to build the library.
+
address@hidden Use IMPDEF.
+There is a tool called IMPDEF
+(@url{http://sei.pku.edu.cn/~caodg/course/c/reference/win32/tools/dlltool.html})
+that can generate DEF files. However, it is not part of a standard
+Visual Studio installation. Further, it is documented as being an
+unreliable process.
+
address@hidden Use DLLTOOL.
+The dlltool is part of the MinGW suite, and thus not part of a
+standard Visual Studio installation. The documentation for the IMPDEF
+tool claims that DLLTOOL is the wrong tool for this job. Finally,
+DLLTOOL does not generate DEF files directly, so it requires
+post-processing of the output.
+
address@hidden itemize
+
+If you are using libtool to build your shared library, here is how to
+use this module. Import @code{lib-msvc-compat} to your project, and
+then add the following lines to the @code{Makefile.am} that builds the
+library:
+
address@hidden
+if HAVE_LD_OUTPUT_DEF
+libfoo_la_LDFLAGS += -Wl,--output-def,libfoo-$(SOVERSION).def
+defexecdir = $(bindir)
+defexec_DATA = libfoo-$(SOVERSION).def
+DISTCLEANFILES += $(defexec_DATA)
+endif
address@hidden smallexample
+
+The @code{SOVERSION} variable needs to be defined. It should be the
+shared library version number used in the DLL filename. For Windows
+targets you compute this value from the values you pass to Libtool's
address@hidden Assuming you have variables @code{LT_CURRENT}
+and @code{LT_AGE} defined for the @code{CURRENT} and @code{AGE}
+libtool version integers, you compute @code{SOVERSION} as follows:
+
address@hidden
+SOVERSION=`expr address@hidden@} - address@hidden@}`
+AC_SUBST(SOVERSION)
address@hidden smallexample
diff --git a/m4/ld-output-def.m4 b/m4/ld-output-def.m4
new file mode 100644
index 0000000..3228d15
--- /dev/null
+++ b/m4/ld-output-def.m4
@@ -0,0 +1,30 @@
+# ld-output-def.m4 serial 2
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+
+# gl_LD_OUTPUT_DEF()
+# -------------
+# Check if linker supports -Wl,--output-def and define automake
+# conditional HAVE_LD_OUTPUT_DEF if it is.
+AC_DEFUN([gl_LD_OUTPUT_DEF],
+[
+ AC_MSG_CHECKING([if gcc/ld supports -Wl,--output-def])
+ if test "$enable_shared" = no; then
+ gl_output_def=no
+ AC_MSG_RESULT([not need, since shared libraries are disabled])
+ else
+ gl_ldflags_save=$LDFLAGS
+ LDFLAGS="-Wl,--output-def,conftest.def"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
+ [gl_output_def=yes],
+ [gl_output_def=no])
+ rm -f conftest.def
+ AC_MSG_RESULT($gl_output_def)
+ LDFLAGS="$gl_ldflags_save"
+ fi
+ AM_CONDITIONAL(HAVE_LD_OUTPUT_DEF, test "$gl_output_def" = "yes")
+])
diff --git a/modules/lib-msvc-compat b/modules/lib-msvc-compat
new file mode 100644
index 0000000..344b501
--- /dev/null
+++ b/modules/lib-msvc-compat
@@ -0,0 +1,14 @@
+Description:
+Macros to test whether LD support --output-def.
+
+Files:
+m4/ld-output-def.m4
+
+configure.ac:
+gl_LD_OUTPUT_DEF
+
+License:
+unlimited
+
+Maintainer:
+Simon Josefsson
--
1.5.6.5
- Re: ld-output-def, (continued)
- Re: ld-output-def, Simon Josefsson, 2009/04/01
- Re: ld-output-def, Eric Blake, 2009/04/01
- Re: ld-output-def, Simon Josefsson, 2009/04/01
- Re: ld-output-def, Eric Blake, 2009/04/01
- Re: ld-output-def, Simon Josefsson, 2009/04/01
- Re: ld-output-def, Eric Blake, 2009/04/01
- Re: ld-output-def, Simon Josefsson, 2009/04/01
- Re: ld-output-def, Simon Josefsson, 2009/04/01
- Re: ld-output-def, Simon Josefsson, 2009/04/01
- Re: ld-output-def,
Simon Josefsson <=