Skip to content

Commit

Permalink
[bsd] Test patch
Browse files Browse the repository at this point in the history
  • Loading branch information
ileanadumitrescu95 committed Nov 12, 2024
1 parent 95781ca commit cd3e476
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 25 deletions.
3 changes: 1 addition & 2 deletions build-dev-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ git clone --depth 2 -b "$branch" https://git.savannah.gnu.org/git/"$package".git
git clone --depth 1 https://git.savannah.gnu.org/git/gnulib.git

# Apply patches.
(cd "$package" && patch -p1 < ../patches/0001-libtool-Add-option-to-reorder-the-shared-library-cac.patch \
&& patch -p1 < ../patches/0001-Add-temporary-quick-check.patch)
(cd "$package" && patch -p1 < ../patches/0001-libtool-Add-option-to-reorder-the-shared-library-cac.patch)

export GNULIB_SRCDIR=`pwd`/gnulib
cd "$package"
Expand Down
172 changes: 149 additions & 23 deletions patches/0001-libtool-Add-option-to-reorder-the-shared-library-cac.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 8f6582f3c808dc42283d9154b5c2ada82942a59a Mon Sep 17 00:00:00 2001
From add1a4dac78b2a4aae5426442810b116f65eb8bc Mon Sep 17 00:00:00 2001
From: Ileana Dumitrescu <ileanadumitrescu95@gmail.com>
Date: Mon, 11 Nov 2024 21:24:08 +0200
Subject: [PATCH] libtool: Add option to reorder the shared library cache
Expand All @@ -10,13 +10,33 @@ 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.
---
build-aux/ltmain.in | 84 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
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..bdcbf3a3 100644
index 1801dd56..d92e03c6 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -141,6 +141,7 @@ usage_message="Options:
Expand All @@ -31,33 +51,36 @@ index 1801dd56..bdcbf3a3 100644
opt_dry_run=false
opt_help=false
opt_mode=
+ opt_reorder_cache=
+ opt_reorder_cache=false
opt_preserve_dup_deps=false
opt_quiet=false
opt_testing=true
@@ -491,6 +493,21 @@ libtool_parse_options ()
@@ -491,6 +493,24 @@ libtool_parse_options ()
func_append preserve_args " $_G_opt"
;;

+ --reorder-cache)
+ test $# = 0 && func_missing_arg $_G_opt && break
+ opt_reorder_cache=$1
+ case $1 in
+ # Must begin with /:
+ /*) ;;
+
+ # Catch anything else as an error (relative paths)
+ *) func_error "invalid argument for $_G_opt"
+ exit_cmd=exit
+ break
+ ;;
+ esac
+ 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 +1078,15 @@ func_convert_path_front_back_pathsep ()
@@ -1061,6 +1081,15 @@ func_convert_path_front_back_pathsep ()
# end func_convert_path_front_back_pathsep


Expand All @@ -73,7 +96,7 @@ index 1801dd56..bdcbf3a3 100644
##################################################
# $build to $host FILE NAME CONVERSION FUNCTIONS #
##################################################
@@ -1395,6 +1421,58 @@ func_dll_def_p ()
@@ -1395,6 +1424,65 @@ func_dll_def_p ()
}


Expand All @@ -96,6 +119,13 @@ index 1801dd56..bdcbf3a3 100644
+
+ # 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
Expand Down Expand Up @@ -132,19 +162,115 @@ index 1801dd56..bdcbf3a3 100644
# func_mode_compile arg...
func_mode_compile ()
{
@@ -1967,6 +2045,12 @@ if $opt_help; then
@@ -1967,6 +2055,12 @@ if $opt_help; then
fi


+# If preferred search directories supplied, reorder the shared library cache and exit.
+if test -n "$opt_reorder_cache"; then
+# If option '--reorder-cache', reorder the shared library cache and exit.
+if $opt_reorder_cache; then
+ func_reorder_shared_lib_cache $opt_reorder_cache
+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
--
2.45.2

0 comments on commit cd3e476

Please sign in to comment.