Mercurial > hg > octave-kai > gnulib-hg
changeset 11254:28202c1cd52d
Add new module ld-version-script. Fix doc for visibility.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Tue, 03 Mar 2009 12:00:59 +0100 |
parents | c90f22b1783e |
children | 8654d5f5a115 |
files | ChangeLog doc/gnulib.texi doc/ld-version-script.texi doc/visibility.texi m4/ld-version-script.m4 modules/ld-version-script |
diffstat | 6 files changed, 148 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-03-03 Simon Josefsson <simon@josefsson.org> + + * doc/gnulib.texi: Link to sections for ld version script and + visibility. + * doc/visibility.texi: Add @node and @section. + * modules/ld-version-script: New module. + * m4/ld-version-script.m4: New file. + * doc/ld-version-script.texi: New file. + 2009-03-02 David Lutterkort <lutter@redhat.com> * lib/safe-alloc.h (__GNUC_PREREQ): New macro.
--- a/doc/gnulib.texi +++ b/doc/gnulib.texi @@ -5825,6 +5825,8 @@ * func:: * warnings:: * manywarnings:: +* visibility:: +* LD Version Scripts:: @end menu @node alloca @@ -5917,6 +5919,10 @@ @include manywarnings.texi +@include visibility.texi + +@include ld-version-script.texi + @node GNU Free Documentation License @appendix GNU Free Documentation License
new file mode 100644 --- /dev/null +++ b/doc/ld-version-script.texi @@ -0,0 +1,77 @@ +i@node LD Version Scripts +@section LD Version Scripts + +The @code{ld-version-script} module can be used to add shared library +versioning support. Currently, only GNU LD and the Solaris linker +supports this. + +Version scripts provides information that can be used by GNU/Linux +distribution packaging tools. For example, Debian has a tool +@code{dpkg-shlibdeps} that can determine the minimal required version +of each dependency (by looking at the symbol list) and stuff the +information into the Debian specific packaging files. + +For more information and other uses of version scripts, see Ulrich +Drepper's paper @url{http://people.redhat.com/drepper/dsohowto.pdf} + +You use the module by importing it to your library, and then add the +following lines to the @code{Makefile.am} that builds the library: + +@smallexample +if HAVE_LD_VERSION_SCRIPT +libfoo_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libfoo.map +endif +@end smallexample + +The version script file format is documented in the GNU LD manual, but +a small example would be: + +@smallexample +LIBFOO_1.0 @{ + global: + libfoo_init; libfoo_doit; libfoo_done; + + local: + *; +@}; +@end smallexample + +If you target platforms that do not support linker scripts (i.e., all +platforms that doesn't use GNU LD) you may want to consider a more +portable but less powerful alternative: libtool +@code{-export-symbols}. It will hide internal symbols from your +library, but will not add ELF versioning symbols. Your usage would +then be something like: + +@smallexample +if HAVE_LD_VERSION_SCRIPT +libfoo_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libfoo.map +else +libfoo_la_LDFLAGS += -export-symbols $(srcdir)/libfoo.sym +endif +@end smallexample + +See the Libtool manual for the file syntax, but a small example would +be: + +@smallexample +libfoo_init +libfoo_doit +libfoo_done +@end smallexample + +To avoid the need for a @code{*.sym} file if your symbols are easily +expressed using a regular expression, you may use +@code{-export-symbols-regex}: + +@smallexample +if HAVE_LD_VERSION_SCRIPT +libfoo_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libfoo.map +else +libfoo_la_LDFLAGS += -export-symbols-regex '^libfoo_.*' +endif +@end smallexample + +For more discussions about symbol visibility, rather than shared +library versioning, see the @code{visibility} module +(@pxref{visibility}).
--- a/doc/visibility.texi +++ b/doc/visibility.texi @@ -1,3 +1,6 @@ +@node visibility +@section visibility + @c Documentation of gnulib module 'visibility'. @c Copyright (C) 2005-2006, 2009 Free Software Foundation, Inc.
new file mode 100644 --- /dev/null +++ b/m4/ld-version-script.m4 @@ -0,0 +1,39 @@ +# ld-version-script.m4 serial 1 +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_VERSION_SCRIPT +# -------------------- +# Check if LD supports linker scripts, and define automake conditional +# HAVE_LD_VERSION_SCRIPT if so. +AC_DEFUN([gl_LD_VERSION_SCRIPT], +[ + AC_ARG_ENABLE([ld-version-script], + AS_HELP_STRING([--enable-ld-version-script], + [enable linker version script (default is enabled when possible)]), + [have_ld_version_script=$enableval], []) + if test -z "$have_ld_version_script"; then + AC_MSG_CHECKING([if LD -Wl,--version-script works]) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" + cat > conftest.map <<EOF +VERS_1 { + global: sym; +}; + +VERS_2 { + global: sym; +} VERS_1; +EOF + AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), + [have_ld_version_script=yes], [have_ld_version_script=no]) + rm -f conftest.map + LDFLAGS="$save_LDFLAGS" + AC_MSG_RESULT($have_ld_version_script) + fi + AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") +])