package/pkg-autotools.mk: also handle libtool 2.6.x

Fixes:
https://autobuild.buildroot.org/results/e6159cee14f84569c85a61f77824b2b58d68a4bc/

Libtool 2.6.x is starting to be used by upstreams when generating
release tarballs (e.g. cryptsetup-2.8.8). As LIBTOOL_PATCH_HOOK does
not know about it, ltmain.sh is left unpatched, so libtool relinks
libraries at install time and adds -L/usr/lib, which is rejected by
the toolchain wrapper:

i686-buildroot-linux-gnu-gcc: ERROR: unsafe header/library path used in cross-compilation: '-L/usr/lib'

The v2.4.4 patch no longer applies cleanly, so add a v2.6 variant,
rebased on libtool 2.6.2, and use it for 2.6.x versions.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Assisted-by: Claude:claude-opus-5
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
(cherry picked from commit 5dbba2616f)
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
This commit is contained in:
Yegor Yefremov
2026-09-24 15:41:09 +02:00
committed by Raphaël Mélotte
parent 23e6fb3ef2
commit 265e33686b
3 changed files with 99 additions and 0 deletions

View File

@@ -986,6 +986,7 @@ support/libtool/buildroot-libtool-v1.5.patch lib_patch.ApplyOrder lib_patch.Sob
support/libtool/buildroot-libtool-v2.2.patch lib_patch.ApplyOrder lib_patch.Sob lib_patch.Upstream
support/libtool/buildroot-libtool-v2.4.4.patch lib_patch.ApplyOrder lib_patch.Upstream
support/libtool/buildroot-libtool-v2.4.patch lib_patch.ApplyOrder lib_patch.Sob lib_patch.Upstream
support/libtool/buildroot-libtool-v2.6.patch lib_patch.ApplyOrder lib_patch.Upstream
support/misc/relocate-sdk.sh Shellcheck
support/scripts/apply-patches.sh Shellcheck
support/scripts/check-bin-arch Shellcheck

View File

@@ -76,6 +76,8 @@ define LIBTOOL_PATCH_HOOK
fi \
elif test $${ltmain_version} = "2.5"; then\
patch -i support/libtool/buildroot-libtool-v2.4.4.patch $${i}; \
elif test $${ltmain_version} = "2.6"; then\
patch -i support/libtool/buildroot-libtool-v2.6.patch $${i}; \
fi \
done
endef

View File

@@ -0,0 +1,96 @@
Libtool fixes for cross-compilation, many past contributors/authors.
Update based on libtool-2.6.2.
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -3008,9 +3008,8 @@
# was found and let the user know that the "--tag" command
# line option must be used.
if test -z "$tagname"; then
- func_echo "unable to infer tagged configuration with compiler."
- func_echo "Possible use of unsupported compiler."
- func_fatal_error "specify a tag with '--tag'. For more information, try '$progname --help'."
+ func_echo "defaulting to \`CC'"
+ func_echo "if this is not correct, specify a tag with \`--tag'"
# else
# func_verbose "using $tagname tagged configuration"
fi
@@ -4746,8 +4745,12 @@
# At present, this check doesn't affect windows .dll's that
# are installed into $libdir/../bin (currently, that works fine)
# but it's something to keep an eye on.
- test "$inst_prefix_dir" = "$destdir" && \
- func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
+
+ #
+ # This breaks install into our staging area. -PB
+ #
+ #test "$inst_prefix_dir" = "$destdir" && \
+ # func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
if test -n "$inst_prefix_dir"; then
# Stick the inst_prefix_dir data into the link command.
@@ -7063,7 +7066,8 @@
;;
-all-static | -static | -static-libtool-libs | --static | -Bstatic)
case $arg in
- -all-static)
+ # Make -static behave like -all-static -GZ
+ -all-static | -static)
if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
func_warning "complete static linking is impossible in this configuration"
fi
@@ -7072,12 +7076,6 @@
fi
prefer_static_libs=yes
;;
- -static)
- if test -z "$pic_flag" && test -n "$link_static_flag"; then
- dlopen_self=$dlopen_self_static
- fi
- prefer_static_libs=built
- ;;
-static-libtool-libs | --static | -Bstatic)
if test -z "$pic_flag" && test -n "$link_static_flag"; then
dlopen_self=$dlopen_self_static
@@ -7393,7 +7391,8 @@
prevarg=$arg
case $arg in
- -all-static)
+ # Make -static behave like -all-static -GZ
+ -all-static | -static)
if test -n "$link_static_flag"; then
# See comment for -static flag below, for more details.
func_append compile_command " $link_static_flag"
@@ -7695,7 +7694,7 @@
continue
;;
- -static | -static-libtool-libs)
+ -static-libtool-libs)
# The effects of -static are defined in a previous loop.
# We used to do the same as -all-static on platforms that
# didn't have a PIC flag, but the assumption that the effects
@@ -8755,7 +8754,7 @@
*)
if test no = "$installed"; then
func_append notinst_deplibs " $lib"
- need_relink=yes
+ need_relink=no
fi
;;
esac
@@ -11296,6 +11295,10 @@
# Replace all uninstalled libtool libraries with the installed ones
newdependency_libs=
for deplib in $dependency_libs; do
+ # Replacing uninstalled with installed can easily break crosscompilation,
+ # since the installed path is generally the wrong architecture. -CL
+ newdependency_libs="$newdependency_libs $deplib"
+ continue
case $deplib in
*.la)
func_basename "$deplib"