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). -- https://rrt.sc3d.org <http://rrt.sc3d.org>
From 4d02051576b35622875e2236d2ca11defac1271d 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 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index ae2b049..1a9b175 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-24 Paul Eggert <egg...@cs.ucla.edu> fts: simplify fts_build -- 2.7.4
From 648fd28bb10cfdab5d1dc5d7b8c14fe90e307212 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 1a9b175..49bc93f 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 dc011ef335303d31535e3b71d5e0f8a966794602 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 and Makefile.am lines. * modules/relocatable-lib-lgpl: Likewise. --- ChangeLog | 9 +++++++++ doc/relocatable-maint.texi | 23 +++++++---------------- modules/relocatable-lib | 7 +++++++ modules/relocatable-lib-lgpl | 3 +++ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49bc93f..b1ceb1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 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 and + Makefile.am 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..00868a5 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 @@ -178,17 +180,6 @@ where the script gets installed. Also, at the end, instead of that you need. @item -In your @file{Makefile.am}, for every program @command{foo} that gets -installed in, say, @file{$(bindir)}, you add: - -@example -foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -if RELOCATABLE_VIA_LD -foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` -endif -@end example - -@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..9a4d069 100644 --- a/modules/relocatable-lib +++ b/modules/relocatable-lib @@ -18,8 +18,15 @@ gl_RELOCATABLE_LIBRARY if test $RELOCATABLE = yes; then AC_LIBOBJ([relocatable]) fi +AC_CONFIG_LIBOBJ_DIR([lib]) Makefile.am: +@item +foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE +foo_LIBADD = $(LIBOBJS) # or $(LTLIBOBJS) if using libtool +if RELOCATABLE_VIA_LD +foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +endif Include: "relocatable.h" diff --git a/modules/relocatable-lib-lgpl b/modules/relocatable-lib-lgpl index 0783864..54dbe69 100644 --- a/modules/relocatable-lib-lgpl +++ b/modules/relocatable-lib-lgpl @@ -17,9 +17,12 @@ gl_RELOCATABLE_LIBRARY if test $RELOCATABLE = yes; then AC_LIBOBJ([relocatable]) fi +AC_CONFIG_LIBOBJ_DIR([lib]) Makefile.am: DEFS += -DNO_XMALLOC +foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE +foo_LIBADD = $(LIBOBJS) # or $(LTLIBOBJS) if using libtool Include: "relocatable.h" -- 2.7.4
From 0635f545a8b292fdafd6f7880ad13c62b1c8ecf6 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 b1ceb1d..5f0b993 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 cc4da6d6a9d6824bd5f3d4fdd21e7c80a24d6042 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. * modules/relocatable-lib: Mention that it can be defined to 0. * modules/relocatable-lib-lgpl: Likewise. --- ChangeLog | 7 +++++++ lib/relocatable.c | 10 ++-------- modules/relocatable-lib | 2 +- modules/relocatable-lib-lgpl | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f0b993..94d0888 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 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. + * modules/relocatable-lib: Mention that it can be defined to 0. + * modules/relocatable-lib-lgpl: Likewise. + +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/lib/relocatable.c b/lib/relocatable.c index 0892e3a..9429557 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. */ diff --git a/modules/relocatable-lib b/modules/relocatable-lib index 9a4d069..fb43261 100644 --- a/modules/relocatable-lib +++ b/modules/relocatable-lib @@ -22,7 +22,7 @@ AC_CONFIG_LIBOBJ_DIR([lib]) Makefile.am: @item -foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE +foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE=0 foo_LIBADD = $(LIBOBJS) # or $(LTLIBOBJS) if using libtool if RELOCATABLE_VIA_LD foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` diff --git a/modules/relocatable-lib-lgpl b/modules/relocatable-lib-lgpl index 54dbe69..80abb30 100644 --- a/modules/relocatable-lib-lgpl +++ b/modules/relocatable-lib-lgpl @@ -21,7 +21,7 @@ AC_CONFIG_LIBOBJ_DIR([lib]) Makefile.am: DEFS += -DNO_XMALLOC -foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE +foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE=0 foo_LIBADD = $(LIBOBJS) # or $(LTLIBOBJS) if using libtool Include: -- 2.7.4