[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch development updated: libtool: Add option to reorder the shared li
From: |
Ileana Dumitrescu |
Subject: |
branch development updated: libtool: Add option to reorder the shared library cache |
Date: |
Tue, 12 Nov 2024 13:34:01 -0500 |
This is an automated email from the git hooks/post-receive script.
ildumi pushed a commit to branch development
in repository libtool.
The following commit(s) were added to refs/heads/development by this push:
new 0a1e8942 libtool: Add option to reorder the shared library cache
0a1e8942 is described below
commit 0a1e894220521e5955371eea5408fd6f7a5149c1
Author: Ileana Dumitrescu <ileanadumitrescu95@gmail.com>
AuthorDate: Mon Nov 11 21:24:08 2024 +0200
libtool: Add option to reorder the shared library cache
Add option to reorder the shared library cache in OpenBSD so that user
preferred directories for shared libraries can be used when linking
before directories previously listed in the shared library cache.
This allows for users in OpenBSD to easily switch between versions of
libraries with the same name during testing.
* NEWS: Update for new (OpenBSD) option.
* build-aux/ltmain.in: Add option --reorder-cache=DIRS.
* doc/libtool.texi: Update documentation for new option.
* test/bug_71489.at: Alter test for OpenBSD to utilize new option.
---
NEWS | 3 ++
build-aux/ltmain.in | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++
doc/libtool.texi | 57 ++++++++++++++++++++++++++++++--
tests/bug_71489.at | 10 ++++++
4 files changed, 161 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 28e4ecbc..4694cab7 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ NEWS - list of user-visible changes between releases of GNU
Libtool
- New libtool command line flags, --test and --check, to skip executing
finish_cmds that would alter the shared library cache during testing.
+ - New libtool command line flag, --reorder-cache=DIRS, to reorder the
+ shared library cache, only on OpenBSD.
+
** Bug fixes:
- Fix incorrect use of workarounds designed for Darwin versions that
diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 1801dd56..b571c442 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -141,6 +141,7 @@ usage_message="Options:
--mode=MODE use operation mode MODE
--no-warnings equivalent to '-Wnone'
--preserve-dup-deps don't remove duplicate dependency libraries
+ --reorder-cache=DIRS reorder shared library cache for preferred DIRS
--test, --check don't update shared library cache during testing
--quiet, --silent don't print informational messages
--tag=TAG use configuration variables from tag TAG
@@ -376,6 +377,7 @@ libtool_options_prep ()
opt_dry_run=false
opt_help=false
opt_mode=
+ opt_reorder_cache=false
opt_preserve_dup_deps=false
opt_quiet=false
opt_testing=true
@@ -491,6 +493,24 @@ libtool_parse_options ()
func_append preserve_args " $_G_opt"
;;
+ --reorder-cache)
+ opt_reorder_cache=true
+ shared_lib_dirs=$1
+ if test -n "$shared_lib_dirs"; then
+ case $1 in
+ # Must begin with /:
+ /*) ;;
+
+ # Catch anything else as an error (relative paths)
+ *) func_warning "invalid argument '$1' for $_G_opt"
+ func_warning "absolute paths are required for
$_G_opt"
+ exit_cmd=exit
+ break
+ ;;
+ esac
+ fi
+ ;;
+
--silent|--quiet)
opt_quiet=:
opt_verbose=false
@@ -1061,6 +1081,15 @@ func_convert_path_front_back_pathsep ()
# end func_convert_path_front_back_pathsep
+# func_convert_delimited_path PATH ORIG_DELIMITER NEW_DELIMITER
+# Replaces a delimiter for a given path.
+func_convert_delimited_path ()
+{
+ converted_path=`$ECHO "$1" | $SED "s#$2#$3#g"`
+}
+# end func_convert_delimited_path
+
+
##################################################
# $build to $host FILE NAME CONVERSION FUNCTIONS #
##################################################
@@ -1395,6 +1424,65 @@ func_dll_def_p ()
}
+# func_reorder_shared_lib_cache DIRS
+# Reorder the shared library cache by unconfiguring previous shared library
cache
+# and configuring preferred search directories before previous search
directories.
+# Previous shared library cache: /usr/lib /usr/local/lib
+# Preferred search directories: /tmp/testing
+# Reordered shared library cache: /tmp/testing /usr/lib /usr/local/lib
+func_reorder_shared_lib_cache ()
+{
+ $debug_cmd
+
+ case $host_os in
+ openbsd*)
+ get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP
"search directories" | $SED "s#.*search directories:\ ##g"`
+ func_convert_delimited_path "$get_search_directories" ':' '\ '
+ save_search_directories=$converted_path
+ func_convert_delimited_path "$1" ':' '\ '
+
+ # Ensure directories exist
+ for dir in $converted_path; do
+ # Ensure each directory is an absolute path
+ case $dir in
+ /*) ;;
+ *) func_warning "Directory '$dir' is not an absolute path"
+ exit $EXIT_FAILURE ;;
+ esac
+ # Ensure no trailing slashes
+ func_stripname '' '/' "$dir"
+ dir=$func_stripname_result
+ if test -d "$dir"; then
+ if test -n "$preferred_search_directories"; then
+ preferred_search_directories="$preferred_search_directories
$dir"
+ else
+ preferred_search_directories=$dir
+ fi
+ else
+ func_warning "Directory '$dir' does not exist"
+ exit $EXIT_FAILURE
+ fi
+ done
+
+ PATH="$PATH:/sbin" ldconfig -U $save_search_directories
+ PATH="$PATH:/sbin" ldconfig -m $preferred_search_directories
$save_search_directories
+ get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP
"search directories" | $SED "s#.*search directories:\ ##g"`
+ func_convert_delimited_path "$get_search_directories" ':' '\ '
+ reordered_search_directories=$converted_path
+
+ $ECHO "Original: $save_search_directories"
+ $ECHO "Reordered: $reordered_search_directories"
+ exit $EXIT_SUCCESS
+ ;;
+ *)
+ func_warning "--reorder-cache is not supported for
host_os=$host_os."
+ exit $EXIT_FAILURE
+ ;;
+ esac
+}
+# end func_reorder_shared_lib_cache
+
+
# func_mode_compile arg...
func_mode_compile ()
{
@@ -1967,6 +2055,12 @@ if $opt_help; then
fi
+# If option '--reorder-cache', reorder the shared library cache and exit.
+if $opt_reorder_cache; then
+ func_reorder_shared_lib_cache $shared_lib_dirs
+fi
+
+
# func_mode_execute arg...
func_mode_execute ()
{
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 484077ff..9dfd5738 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -1275,8 +1275,59 @@ that libtool knows it can safely.
@item --test
@itemx --check
Do not execute finish_cmds (disabled by default). This option is for
-specifying that the testsuite is executing so that ldconfig will not alter
-the shared library cache, which is an issue observed on OpenBSD 7.5.
+specifying that testing of local changes to shared libraries is being
+performed so that ldconfig will not alter the shared library cache, which
+is an issue observed on OpenBSD 7.5. This option should be combined with
+the usage of @option{--mode=install} and @option{--mode=finish} to have
+any effect. Prior to utilizing this option, the shared library cache must
+not contain links to the listed install directory for shared libraries
+undergoing testing; otherwise, it will have no useful effect. The shared
+library cache can be reordered to prefer directories for testing shared
+libraries over the directories already listed in the shared library cache
+with @option{--reorder-cache=@var{shared_lib_dirs}}.
+
+@item --reorder-cache=@var{shared_lib_dirs}
+Reorder the shared library cache by providing the preferred directories
+(@var{shared_lib_dirs}) to link shared libraries from. The previous
+shared library cache is unconfigured, and the preferred directories are
+configured with the previous directories appended to the end (if not in
+the preferred directory list)@footnote{Additionally, all directories
+that no longer exist will be removed from the shared library cache.}.
+This option is currently only available on OpenBSD where @code{make
+install} has been required before @code{make check} for the shared
+library cache to be updated.
+
+This option is essentially a wrapper for executing @command{ldconfig},
+and it should be used as an independent option before and after testing
+changes to shared libraries. Below are some usage examples:
+
+@example
+$ @kbd{libtool --reorder-cache=/tmp/testing}
+Original: /usr/lib /usr/X11R6/lib /usr/local/lib
+Reordered: /tmp/testing /usr/lib /usr/X11R6/lib /usr/local/lib
+$ @kbd{libtool --reorder-cache=/usr/lib:/usr/X11R6/lib:/usr/local/lib}
+Original: /tmp/testing /usr/lib /usr/X11R6/lib /usr/local/lib
+Reordered: /usr/lib /usr/X11R6/lib /usr/local/lib /tmp/testing
+@end example
+
+@example
+$ @kbd{libtool --reorder-cache=/tmp/testing}
+Original: /usr/lib /usr/X11R6/lib /usr/local/lib
+Reordered: /tmp/testing /usr/lib /usr/X11R6/lib /usr/local/lib
+$ @kbd{rm -rf /tmp/testing}
+$ @kbd{libtool --reorder-cache=/usr/lib:/usr/X11R6/lib:/usr/local/lib}
+Original: /tmp/testing /usr/lib /usr/X11R6/lib /usr/local/lib
+Reordered: /usr/lib /usr/X11R6/lib /usr/local/lib
+@end example
+
+@example
+$ @kbd{libtool --reorder-cache=/tmp/testing:/usr/local/lib:/home/user/dir}
+Original: /usr/lib /usr/X11R6/lib /usr/local/lib
+Reordered: /tmp/testing /usr/local/lib /home/user/dir /usr/lib /usr/X11R6/lib
+$ @kbd{libtool --reorder-cache=/usr/lib /usr/X11R6/lib /usr/local/lib}
+Original: /tmp/testing /usr/local/lib /home/user/dir /usr/lib /usr/X11R6/lib
+Reordered: /usr/lib /usr/X11R6/lib /usr/local/lib /tmp/testing /home/user/dir
+@end example
@item --quiet
@itemx --silent
@@ -6862,7 +6913,7 @@ shell does not support the shell option
@code{nocaseglob}, making
@defvar finish_cmds
Commands to tell the dynamic linker how to find shared libraries in a
specific directory. These commands can be disabled during testing local
-changes with @option{--test} or @option{--check}.
+changes to shared libraries with @option{--test} or @option{--check}.
@end defvar
@defvar finish_eval
diff --git a/tests/bug_71489.at b/tests/bug_71489.at
index ef4f51f7..08196966 100644
--- a/tests/bug_71489.at
+++ b/tests/bug_71489.at
@@ -382,6 +382,16 @@ echo "Building local copy of the project"
cd build_local
LT_AT_CONFIGURE([--prefix=$prefix], [$ltb2/configure])
LT_AT_MAKE([])
+
+ case $host_os in
+ openbsd*)
+ build_local_dir=$(pwd)
+ AT_CHECK(
+ [
+ $LIBTOOL
--reorder-cache="$build_local_dir/liba/.libs:$build_local_dir/libb/.libs"
+ ], 0, ignore, ignore);;
+ *) ;;
+ esac
)
# Although we have installed ltb2, we still expect that we are using the local
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch development updated: libtool: Add option to reorder the shared library cache,
Ileana Dumitrescu <=