On 26 July 2017 at 16:01, Reuben Thomas <r...@sc3d.org> wrote: > As per various emails back in April, some improvements to relocatable. > > Patch 1 makes the default license in the files GPL, to avoid confusion; > Bruno agreed to this: http://lists.gnu.org/archive/html/bug-gnulib/2017- > 04/msg00013.html > > Patch 2 adds Valgrind suppressions. One open question is how bootstrap can > tell the user about these in the same way as configure.ac and Makefile.am > changes. > > Patch 3 improves the documentation as outlined in http://lists.gnu.org/ > archive/html/bug-gnulib/2017-04/msg00008.html > > The last two patches are more speculative, based on changes I've proposed > but had no feedback to. See http://lists.gnu.org/ > archive/html/bug-gnulib/2017-04/msg00027.html > > Patch 4 changes the default to relocation being enabled; patch 5 changes > the default for ENABLE_COSTLY_RELOCATION to 1. In both cases the idea is > that the cost is negligible on GNU systems, and small on almost all systems > (Cygwin being the only exception I'm aware of). >
I fixed a couple of problems with the patches and attach updated versions. The descriptions above are still correct. -- https://rrt.sc3d.org <http://rrt.sc3d.org>
From 8c579b6f08ebfcdc9614231a30e3e1ce9f6b0c6b Mon Sep 17 00:00:00 2001 From: Reuben Thomas <r...@sc3d.org> Date: Wed, 5 Apr 2017 14:43:19 +0100 Subject: [PATCH 1/5] relocatable: make the license on the sources the GPL * lib/relocatable.h (relocatable): * lib/relocatable.c (relocatable): Change the license from LGPL, which a special case so that the relocatable source files could be used without gnulib-tool. They can still be used under the LGPL, using the --lgpl option to gnulib-tool. --- ChangeLog | 9 +++++++++ lib/relocatable.c | 6 +++--- lib/relocatable.h | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec8a301..2631e69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2017-07-26 Reuben Thomas <r...@sc3d.org> + + relocatable: Make the license on the sources the GPL. + * lib/relocatable.h (relocatable): + * lib/relocatable.c (relocatable): Change the license from LGPL, which + a special case so that the relocatable source files could be used + without gnulib-tool. They can still be used under the LGPL, using the + --lgpl option to gnulib-tool. + 2017-07-26 Paul Eggert <egg...@cs.ucla.edu> doc: bring MODULES.html.sh up to date diff --git a/lib/relocatable.c b/lib/relocatable.c index 0892e3a..9a8f637 100644 --- a/lib/relocatable.c +++ b/lib/relocatable.c @@ -3,8 +3,8 @@ Written by Bruno Haible <br...@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -12,7 +12,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public License + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ diff --git a/lib/relocatable.h b/lib/relocatable.h index 11bd9ae..1b1f79a 100644 --- a/lib/relocatable.h +++ b/lib/relocatable.h @@ -3,8 +3,8 @@ Written by Bruno Haible <br...@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2.1 of the License, or + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -12,7 +12,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public License + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _RELOCATABLE_H -- 2.7.4
From 764d43af46db76289acab606aa8f9da50411ea18 Mon Sep 17 00:00:00 2001 From: Reuben Thomas <r...@sc3d.org> Date: Wed, 26 Jul 2017 12:04:38 +0100 Subject: [PATCH 2/5] relocatable-lib{,-lgpl}: add Valgrind suppressions * build-aux/relocatable.supp: Add. * modules/relocatable-lib: Add relocatable.supp. * modules/relocatable-lib-lgpl: Likewise. --- ChangeLog | 7 +++++++ build-aux/relocatable.supp | 8 ++++++++ modules/relocatable-lib | 1 + modules/relocatable-lib-lgpl | 1 + 4 files changed, 17 insertions(+) create mode 100644 build-aux/relocatable.supp diff --git a/ChangeLog b/ChangeLog index 2631e69..6ef31e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2017-07-26 Reuben Thomas <r...@sc3d.org> + relocatable-lib{,-lgpl}: add Valgrind suppressions + * build-aux/relocatable.supp: Add. + * modules/relocatable-lib: Add relocatable.supp. + * modules/relocatable-lib-lgpl: Likewise. + +2017-07-26 Reuben Thomas <r...@sc3d.org> + relocatable: Make the license on the sources the GPL. * lib/relocatable.h (relocatable): * lib/relocatable.c (relocatable): Change the license from LGPL, which diff --git a/build-aux/relocatable.supp b/build-aux/relocatable.supp new file mode 100644 index 0000000..c3dfeff --- /dev/null +++ b/build-aux/relocatable.supp @@ -0,0 +1,8 @@ +# set_this_relocation_prefix leaks intentionally +{ + relocatable/set_this_relocation_prefix + Memcheck:Leak + fun:malloc + fun:set_this_relocation_prefix + fun:set_relocation_prefix +} diff --git a/modules/relocatable-lib b/modules/relocatable-lib index 58efa91..a37c27a 100644 --- a/modules/relocatable-lib +++ b/modules/relocatable-lib @@ -3,6 +3,7 @@ Help make libraries relocatable, that is, to allow them to function properly when copied to an arbitrary directory. Files: +build-aux/relocatable.supp doc/relocatable.texi lib/relocatable.h lib/relocatable.c diff --git a/modules/relocatable-lib-lgpl b/modules/relocatable-lib-lgpl index 11b1400..0783864 100644 --- a/modules/relocatable-lib-lgpl +++ b/modules/relocatable-lib-lgpl @@ -3,6 +3,7 @@ Help make libraries relocatable, that is, to allow them to function properly when copied to an arbitrary directory. Files: +build-aux/relocatable.supp doc/relocatable.texi lib/relocatable.h lib/relocatable.c -- 2.7.4
From d4ea795563e604a04b1ebc1b9cf8b6d496a65480 Mon Sep 17 00:00:00 2001 From: Reuben Thomas <r...@sc3d.org> Date: Wed, 26 Jul 2017 15:03:28 +0100 Subject: [PATCH 3/5] relocatable-lib{,-lgpl}: improve documentation * doc/relocatable-maint.texi: Document use of relocatable-lib{,-lgpl}; previously not mentioned. * modules/relocatable-lib: Add some extra configure.ac lines. * modules/relocatable-lib-lgpl: Likewise. --- ChangeLog | 8 ++++++++ doc/relocatable-maint.texi | 20 +++++++++++++++----- modules/relocatable-lib | 1 + modules/relocatable-lib-lgpl | 1 + 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ef31e6..7496a89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2017-07-26 Reuben Thomas <r...@sc3d.org> + relocatable-lib{,-lgpl}: improve documentation + * doc/relocatable-maint.texi: Document use of relocatable-lib{,-lgpl}; + previously not mentioned. + * modules/relocatable-lib: Add some extra configure.ac lines. + * modules/relocatable-lib-lgpl: Likewise. + +2017-07-26 Reuben Thomas <r...@sc3d.org> + relocatable-lib{,-lgpl}: add Valgrind suppressions * build-aux/relocatable.supp: Add. * modules/relocatable-lib: Add relocatable.supp. diff --git a/doc/relocatable-maint.texi b/doc/relocatable-maint.texi index 50b446b..8208ce3 100644 --- a/doc/relocatable-maint.texi +++ b/doc/relocatable-maint.texi @@ -44,10 +44,6 @@ On other Unix systems, it installs a wrapper executable. The wrapper sets the environment variable that controls shared library searching (usually @env{LD_LIBRARY_PATH}) and then invokes the real executable. -This approach does not always work. On OpenBSD and OpenServer, -prereleases of Libtool 1.5 put absolute file names of libraries in -executables, which prevents searching any other locations. - @item On Windows, the executable's own directory is searched for libraries, so installing shared libraries into the executable's directory is @@ -58,7 +54,8 @@ You can make your program relocatable by following these steps: @enumerate @item -Import the @code{relocatable-prog} module. +Import the @code{relocatable-prog} module. For libraries, use the +@code{relocatable-lib} or @code{relocatable-lib-lgpl} module. @item In every program, add to @code{main} as the first statement (even @@ -71,6 +68,10 @@ set_program_name (argv[0]); The prototype for this function is in @file{progname.h}. @item +If you want your code to be portable to platforms that do not support +automatic initialization, call @code{set_relocation_prefix}. + +@item Everywhere where you use a constant pathname from installation-time, wrap it in @code{relocate} so it gets translated to the run-time situation. Example: @@ -168,6 +169,7 @@ if ("@@RELOCATABLE@@" eq "yes") @{ @} # Get some relocated directory names. +# (The configmake gnulib module can help with this.) $sysconfdir = relocate("@@sysconfdir@@"); $some_datadir = relocate(@@datadir@@/something"); @end example @@ -188,6 +190,14 @@ foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` endif @end example +Also in @file{Makefile.am}, for each library @code{libfoo}, you add: + +@example +libfoo_la_CPPFLAGS = -DIN_LIBRARY +@end example + +(Adjust the suffix @code{la} as necessary if you are not using libtool.) + @item You may also need to add a couple of variable assignments to your @file{configure.ac}. diff --git a/modules/relocatable-lib b/modules/relocatable-lib index a37c27a..71cbf9c 100644 --- a/modules/relocatable-lib +++ b/modules/relocatable-lib @@ -18,6 +18,7 @@ gl_RELOCATABLE_LIBRARY if test $RELOCATABLE = yes; then AC_LIBOBJ([relocatable]) fi +AC_CONFIG_LIBOBJ_DIR([lib]) Makefile.am: diff --git a/modules/relocatable-lib-lgpl b/modules/relocatable-lib-lgpl index 0783864..46a6163 100644 --- a/modules/relocatable-lib-lgpl +++ b/modules/relocatable-lib-lgpl @@ -17,6 +17,7 @@ gl_RELOCATABLE_LIBRARY if test $RELOCATABLE = yes; then AC_LIBOBJ([relocatable]) fi +AC_CONFIG_LIBOBJ_DIR([lib]) Makefile.am: DEFS += -DNO_XMALLOC -- 2.7.4
From adaa231fd4c582e675efede08135747dd7574191 Mon Sep 17 00:00:00 2001 From: Reuben Thomas <r...@sc3d.org> Date: Wed, 26 Jul 2017 15:12:40 +0100 Subject: [PATCH 4/5] Change default for relocatable modules to --enable-relocatable * m4/relocatable.m4: Change --enable-relocatable to --disable-relocatable. * doc/relocatable.texi: Update the documentation. --- ChangeLog | 7 +++++++ doc/relocatable.texi | 19 +++++++------------ m4/relocatable-lib.m4 | 12 ++++++------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7496a89..35a07c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2017-07-26 Reuben Thomas <r...@sc3d.org> + Change default for relocatable modules to --enable-relocatable + * m4/relocatable.m4: Change --enable-relocatable to + --disable-relocatable. + * doc/relocatable.texi: Update the documentation. + +2017-07-26 Reuben Thomas <r...@sc3d.org> + relocatable-lib{,-lgpl}: improve documentation * doc/relocatable-maint.texi: Document use of relocatable-lib{,-lgpl}; previously not mentioned. diff --git a/doc/relocatable.texi b/doc/relocatable.texi index fca0ea5..2f03b15 100644 --- a/doc/relocatable.texi +++ b/doc/relocatable.texi @@ -20,9 +20,6 @@ and moved programs, and invoke them through the symlink. It is possible to do the same thing with a hard link @emph{only} if the hard link file is in the same directory as the real program. -To configure a program to be relocatable, add -@option{--enable-relocatable} to the @command{configure} command line. - On some OSes the executables remember the location of shared libraries and prefer them over any other search path. Therefore, such an executable will look for its shared libraries first in the original @@ -45,18 +42,16 @@ Here's a sample installation run that takes into account all these recommendations: @example -./configure --enable-relocatable --prefix=/nonexistent +./configure --prefix=/nonexistent make make install DESTDIR=/tmp/inst$$ @end example -Installation with @option{--enable-relocatable} will not work for -setuid or setgid executables, because such executables search only -system library paths for security reasons. Also, installation with -@option{--enable-relocatable} might not work on OpenBSD, when the -package contains shared libraries and libtool versions 1.5.xx are used. +Relocation will not work for setuid or setgid executables, because such +executables search only system library paths for security reasons. The runtime penalty and size penalty are negligible on GNU/Linux (just -one system call more when an executable is launched), and small on -other systems (the wrapper program just sets an environment variable -and executes the real program). +one system call more when an executable is launched), and small on other +systems (the wrapper program just sets an environment variable and +executes the real program); however, if desired you can disable +relocatability by configuring with @option{--disable-relocatable}. diff --git a/m4/relocatable-lib.m4 b/m4/relocatable-lib.m4 index 24572ee..6b311f3 100644 --- a/m4/relocatable-lib.m4 +++ b/m4/relocatable-lib.m4 @@ -34,14 +34,14 @@ AC_DEFUN([gl_RELOCATABLE_NOP], [ AC_MSG_CHECKING([whether to activate relocatable installation]) AC_ARG_ENABLE([relocatable], - [AS_HELP_STRING([--enable-relocatable], - [install a package that can be moved in the file system])], - [if test "$enableval" != no; then - RELOCATABLE=yes - else + [AS_HELP_STRING([--disable-relocatable], + [install a package that cannot be moved in the file system])], + [if test "$enableval" != yes; then RELOCATABLE=no + else + RELOCATABLE=yes fi - ], RELOCATABLE=no) + ], RELOCATABLE=yes) AC_SUBST([RELOCATABLE]) AC_MSG_RESULT([$RELOCATABLE]) ]) -- 2.7.4
From 7d67d76d0d5cb32fb5eb55a55238d169694ffed2 Mon Sep 17 00:00:00 2001 From: Reuben Thomas <r...@sc3d.org> Date: Wed, 26 Jul 2017 15:23:29 +0100 Subject: [PATCH 5/5] relocatable-lib{,-lgpl}: make ENABLE_COSTLY_RELOCATABLE the default * lib/relocatable.c: Define ENABLE_COSTLY_RELOCATABLE to 1 if undefined. * doc/relocatable-maint.texi: Mention that it can be defined to 0. --- ChangeLog | 6 ++++++ doc/relocatable-maint.texi | 4 ++-- lib/relocatable.c | 10 ++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35a07c9..2fa071b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2017-07-26 Reuben Thomas <r...@sc3d.org> + relocatable-lib{,-lgpl}: make ENABLE_COSTLY_RELOCATABLE the default + * lib/relocatable.c: Define ENABLE_COSTLY_RELOCATABLE to 1 if undefined. + * doc/relocatable-maint.texi: Mention that it can be defined to 0. + +2017-07-26 Reuben Thomas <r...@sc3d.org> + Change default for relocatable modules to --enable-relocatable * m4/relocatable.m4: Change --enable-relocatable to --disable-relocatable. diff --git a/doc/relocatable-maint.texi b/doc/relocatable-maint.texi index 8208ce3..9300899 100644 --- a/doc/relocatable-maint.texi +++ b/doc/relocatable-maint.texi @@ -184,7 +184,7 @@ In your @file{Makefile.am}, for every program @command{foo} that gets installed in, say, @file{$(bindir)}, you add: @example -foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" +foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" # optionally, -DENABLE_COSTLY_RELOCATABLE=0 if RELOCATABLE_VIA_LD foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` endif @@ -193,7 +193,7 @@ endif Also in @file{Makefile.am}, for each library @code{libfoo}, you add: @example -libfoo_la_CPPFLAGS = -DIN_LIBRARY +libfoo_la_CPPFLAGS = -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE=0 @end example (Adjust the suffix @code{la} as necessary if you are not using libtool.) diff --git a/lib/relocatable.c b/lib/relocatable.c index 9a8f637..24192b5 100644 --- a/lib/relocatable.c +++ b/lib/relocatable.c @@ -95,15 +95,9 @@ /* Whether to enable the more costly support for relocatable libraries. It allows libraries to be have been installed with a different original - prefix than the program. But it is quite costly, especially on Cygwin - platforms, see below. Therefore we enable it by default only on native - Windows platforms. */ + prefix than the program. */ #ifndef ENABLE_COSTLY_RELOCATABLE -# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ -# define ENABLE_COSTLY_RELOCATABLE 1 -# else -# define ENABLE_COSTLY_RELOCATABLE 0 -# endif +# define ENABLE_COSTLY_RELOCATABLE 1 #endif /* Original installation prefix. */ -- 2.7.4