[PATCH 01/12] ltmain.in: Handle trailing slashes on install commands correctly
A command like: libtool --mode=install /usr/bin/install -c gck-roots-store-standalone.la '/image/usr/lib/gnome-keyring/standalone/' where the path ends with a trailing slash currently fails. This occurs in software like gnome-keyring or pulseaudio and is because the comparision code doesn't see the paths as equal. Strip both paths to ensure this works reliably. Signed-off-by: Richard Purdie --- build-aux/ltmain.in | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index 96b37003..3d5dcd0a 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -2378,8 +2378,14 @@ func_mode_install () func_append dir "$objdir" if test -n "$relink_command"; then + # Strip any trailing slash from the destination. + func_stripname '' '/' "$libdir" + destlibdir=$func_stripname_result + func_stripname '' '/' "$destdir" + s_destdir=$func_stripname_result + # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` + inst_prefix_dir=`$ECHO "X$s_destdir" | $Xsed -e "s%$destlibdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that -- 2.25.1
[PATCH 04/12] ltmain.sh: Fix sysroot paths being encoded into RPATHs
There is a bug where RPATHs could end up containing sysroot values when cross compiling which is obviously incorrect. Strip out sysroot components from libdir when building RPATH values to avoid this. Signed-off-by: Richard Purdie --- build-aux/ltmain.in | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index 2c994612..96238350 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -7654,9 +7654,11 @@ EOF test relink = "$opt_mode" || rpath=$compile_rpath$rpath for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then + func_replace_sysroot "$libdir" + libdir=$func_replace_sysroot_result + func_stripname '=' '' "$libdir" + libdir=$func_stripname_result if test -n "$hardcode_libdir_separator"; then - func_replace_sysroot "$libdir" - libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else @@ -8386,6 +8388,10 @@ EOF hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then + func_replace_sysroot "$libdir" + libdir=$func_replace_sysroot_result + func_stripname '=' '' "$libdir" + libdir=$func_stripname_result if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir @@ -8437,6 +8443,10 @@ EOF hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then + func_replace_sysroot "$libdir" + libdir=$func_replace_sysroot_result + func_stripname '=' '' "$libdir" + libdir=$func_stripname_result if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir -- 2.25.1
[PATCH 09/12] Makefile.am: make sure autoheader run before autoconf
From: Mingli Yu autoheader will update ../libtool-2.4.6/libltdl/config-h.in which autoconf needs, so there comes a race sometimes as below: | configure.ac:45: error: required file 'config-h.in' not found | touch '../libtool-2.4.6/libltdl/config-h.in' So make sure autoheader run before autoconf to avoid this race. Signed-off-by: Mingli Yu Signed-off-by: Richard Purdie --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 6b546092..84795d87 100644 --- a/Makefile.am +++ b/Makefile.am @@ -370,7 +370,7 @@ lt_configure_deps = $(lt_aclocal_m4) $(lt_aclocal_m4_deps) $(lt_aclocal_m4): $(lt_aclocal_m4_deps) $(AM_V_GEN)cd '$(srcdir)/$(ltdl_dir)' && $(ACLOCAL) -I ../m4 -$(lt_configure): $(lt_configure_deps) +$(lt_configure): $(lt_configure_deps) $(lt_config_h_in) $(AM_V_GEN)cd '$(srcdir)/$(ltdl_dir)' && $(AUTOCONF) $(lt_config_h_in): $(lt_configure_deps) -- 2.25.1
[PATCH 06/12] libtool.m4: Handle "/" as a sysroot correctly
Update libtool.m4 to resolve a problem with lt_sysroot not being properly updated if the option '--with[-libtool]-sysroot' is not provided when running the 'configure' script for a package so that "/" as a sysroot is handled correctly by libtool. Signed-off-by: Richard Purdie --- m4/libtool.m4 | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/m4/libtool.m4 b/m4/libtool.m4 index de2f1ebf..180dd9d1 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1256,16 +1256,20 @@ dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case $with_libtool_sysroot in #( - yes) + no) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` + # Treat "/" the same a an unset sysroot. + if test "$lt_sysroot" = /; then + lt_sysroot= + fi fi ;; #( + yes|''|/) + ;; #( /*) lt_sysroot=`echo "$with_libtool_sysroot" | sed -e "$sed_quote_subst"` ;; #( - no|'') - ;; #( *) AC_MSG_RESULT([$with_libtool_sysroot]) AC_MSG_ERROR([The sysroot must be an absolute path.]) -- 2.25.1
[PATCH 05/12] ltmain.in: Don't encode RATHS which match default linker paths
We don't want to add RPATHS which match default linker search paths, they're a waste of space. This patch filters libtools list of paths to encoode and removes the ones we don't need. Libtool may be passed link paths of the form "/usr/lib/../lib" so normalize the paths before comparision. Signed-off-by: Richard Purdie --- build-aux/ltmain.in | 34 -- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index 96238350..6fb58ed2 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -7672,8 +7672,16 @@ EOF esac fi else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append dep_rpath " $flag" +# We only want to hardcode in an rpath if it isn't in the +# default dlsearch path. +func_normal_abspath "$libdir" +libdir_norm=$func_normal_abspath_result + case " $sys_lib_dlsearch_path " in + *" $libdir_norm "*) ;; + *) eval flag=\"$hardcode_libdir_flag_spec\" + func_append dep_rpath " $flag" + ;; + esac fi elif test -n "$runpath_var"; then case "$perm_rpath " in @@ -8406,8 +8414,16 @@ EOF esac fi else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" +# We only want to hardcode in an rpath if it isn't in the +# default dlsearch path. +func_normal_abspath "$libdir" +libdir_norm=$func_normal_abspath_result + case " $sys_lib_dlsearch_path " in + *" $libdir_norm "*) ;; + *) eval flag=\"$hardcode_libdir_flag_spec\" + rpath+=" $flag" + ;; + esac fi elif test -n "$runpath_var"; then case "$perm_rpath " in @@ -8461,8 +8477,14 @@ EOF esac fi else - eval flag=\"$hardcode_libdir_flag_spec\" - func_append rpath " $flag" +# We only want to hardcode in an rpath if it isn't in the +# default dlsearch path. + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) eval flag=\"$hardcode_libdir_flag_spec\" + func_append rpath " $flag" + ;; + esac fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in -- 2.25.1
[PATCH 03/12] ltmain.in: Add missing sysroot to library path
From: Khem Raj When using a sysroot we should append it to libdir, which is helpful in cross builds as the system is staged in the sysroot. For normal builds, i.e. when lt_sysroot is not set, it will still behave the same and add -L/usr/lib to the relink command. Signed-off-by: Richard Purdie --- build-aux/ltmain.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index 3d5dcd0a..2c994612 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -6475,7 +6475,7 @@ func_mode_link () fi else # We cannot seem to hardcode it, guess we'll fake it. - add_dir=-L$libdir + add_dir="-L$lt_sysroot$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in -- 2.25.1
[PATCH 10/12] Makefile.am: make sure autoheader run before automake
From: Mingli Yu When use automake to generate Makefile.in from Makefile.am, there comes below race: | configure.ac:45: error: required file 'config-h.in' not found It is because the file config-h.in in updating process by autoheader, so make automake run after autoheader to avoid the above race. Signed-off-by: Mingli Yu Signed-off-by: Richard Purdie --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 84795d87..8c9949ed 100644 --- a/Makefile.am +++ b/Makefile.am @@ -333,7 +333,7 @@ EXTRA_DIST += $(lt_aclocal_m4) \ $(lt_obsolete_m4) \ $(stamp_mk) -$(lt_Makefile_in): $(lt_Makefile_am) $(lt_aclocal_m4) +$(lt_Makefile_in): $(lt_Makefile_am) $(lt_aclocal_m4) $(lt_config_h_in) $(AM_V_GEN)cd '$(srcdir)/$(ltdl_dir)' && $(AUTOMAKE) Makefile # Don't let unused scripts leak into the libltdl Makefile -- 2.25.1
[PATCH 11/12] ltmain.in: Handle prefix-map compiler options correctly
If lto is enabled, we need the prefix-map variables to be passed to the linker. Add these to the list of options libtool passes through. Signed-off-by: Richard Purdie --- build-aux/ltmain.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index 606f17be..7dc2e897 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -5392,10 +5392,11 @@ func_mode_link () # -stdlib=*select c++ std lib with clang # -fsanitize=* Clang/GCC memory and address sanitizer # -fuse-ld=* Linker select flags for GCC + # -f*-prefix-map* needed for lto linking -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ - -specs=*|-fsanitize=*|-fuse-ld=*) + -specs=*|-fsanitize=*|-fuse-ld=*|-f*-prefix-map*) func_quote_arg pretty "$arg" arg=$func_quote_arg_result func_append compile_command " $arg" -- 2.25.1
[PATCH 07/12] libtool: Fix support for NIOS2 processor
From: Marek Vasut The name of the system contains the string "nios2". This string is caught by the some of the greedy checks for OS/2 in libtool, in particular the *os2* branches of switch statements match for the nios2 string, which results in incorrect behavior of libtool. This patch adds an explicit check for *nios2* before the *os2* checks to prevent the OS/2 check incorrectly trapping the nios2 as well. Signed-off-by: Marek Vasut Signed-off-by: Richard Purdie --- build-aux/ltmain.in | 20 1 file changed, 20 insertions(+) diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index 6fb58ed2..606f17be 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -519,6 +519,12 @@ libtool_validate_options () test : = "$debug_cmd" || func_append preserve_args " --debug" case $host in + # For NIOS2, we want to make sure that it's not caught by the + # more general OS/2 check below. Otherwise, NIOS2 is the same + # as the default option. + *nios2*) +opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps +;; # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) @@ -6246,6 +6252,15 @@ func_mode_link () if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in + *nios2*) + # For NIOS2, we want to make sure that it's not caught by the + # more general OS/2 check below. Otherwise, NIOS2 is the same + # as the default option. + if test no = "$installed"; then + func_append notinst_deplibs " $lib" + need_relink=yes + fi + ;; *cygwin* | *mingw* | *cegcc* | *os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" @@ -6316,6 +6331,11 @@ func_mode_link () elif test -n "$soname_spec"; then # bleh windows case $host in + *nios2*) + # For NIOS2, we want to make sure that it's not caught by the + # more general OS/2 check below. Otherwise, NIOS2 is the same + # as the default option. + ;; *cygwin* | mingw* | *cegcc* | *os2*) func_arith $current - $age major=$func_arith_result -- 2.25.1
[PATCH 08/12] libtool: Check for static libs for internal compiler libraries
From: Khem Raj Libtool checks only for libraries linked as -l* when trying to find internal compiler libraries. Clang, however uses the absolute path to link its internal libraries e.g. compiler_rt. This patch handles clang's statically linked libraries when finding internal compiler libraries. Signed-off-by: Khem Raj Signed-off-by: Richard Purdie --- m4/libtool.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/libtool.m4 b/m4/libtool.m4 index 180dd9d1..022c1292 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -7560,7 +7560,7 @@ if AC_TRY_EVAL(ac_compile); then for p in `eval "$output_verbose_link_cmd"`; do case $prev$p in --L* | -R* | -l*) +-L* | -R* | -l* | */libclang_rt.*.a) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test x-L = "$p" || -- 2.25.1
[PATCH 12/12] libtool.m4: For reproducibility stop encoding hostname in libtool script
For reproducibilty, stop encoding the hostname into the libtool script, this isn't really adding much to debugging and most distros are carrying such a patch now as reproducibility is important. Signed-off-by: Richard Purdie --- m4/libtool.m4 | 1 - 1 file changed, 1 deletion(-) diff --git a/m4/libtool.m4 b/m4/libtool.m4 index 022c1292..1a8a2998 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -728,7 +728,6 @@ _LT_CONFIG_SAVE_COMMANDS([ cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. -- 2.25.1
[PATCH 02/12] libtool.m4: Rename the --with-sysroot option to avoid conflict with gcc/binutils
From: Khem Raj This patch renames the --with-sysroot option to --with-libtool-sysroot to avoid namespace conflict with binutils, gcc and other toolchain components since these componets also add that option to configure and this becomes confusing and conflicting otherwise. Signed-off-by: Richard Purdie --- m4/libtool.m4| 12 ++-- tests/sysroot.at | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/m4/libtool.m4 b/m4/libtool.m4 index f2d1f398..de2f1ebf 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1246,28 +1246,28 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) # AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) -AC_ARG_WITH([sysroot], -[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], +AC_ARG_WITH([libtool-sysroot], +[AS_HELP_STRING([--with-libtool-sysroot@<:@=DIR@:>@], [Search for dependent libraries within DIR (or the compiler's sysroot if not specified).])], -[], [with_sysroot=no]) +[], [with_libtool_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= -case $with_sysroot in #( +case $with_libtool_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + lt_sysroot=`echo "$with_libtool_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) - AC_MSG_RESULT([$with_sysroot]) + AC_MSG_RESULT([$with_libtool_sysroot]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac diff --git a/tests/sysroot.at b/tests/sysroot.at index 05faa13d..7a1f9567 100644 --- a/tests/sysroot.at +++ b/tests/sysroot.at @@ -64,7 +64,7 @@ while read file; do done]) LDFLAGS="$LDFLAGS --sysroot=$sysroot -no-undefined" -configure_options="$configure_options --with-sysroot=$sysroot --prefix=$prefix" +configure_options="$configure_options --with-libtool-sysroot=$sysroot --prefix=$prefix" #??? if test PATH = "$shlibpath_var"; then @@ -114,7 +114,7 @@ AM_INIT_AUTOMAKE([foreign]) AC_PROG_CC AC_CONFIG_SRCDIR([lib2.c]) LT_INIT -sysroot=$with_sysroot +sysroot=$with_libtool_sysroot AC_SUBST([sysroot]) AC_OUTPUT(Makefile) ]]) @@ -155,7 +155,7 @@ AM_INIT_AUTOMAKE([foreign]) AC_PROG_CC AC_CONFIG_SRCDIR([prog.c]) LT_INIT -sysroot=$with_sysroot +sysroot=$with_libtool_sysroot AC_SUBST([sysroot]) AC_OUTPUT(Makefile) ]]) -- 2.25.1
[PATCH 00/12] Yocto Project libtool patch queue
Hi, I saw comments about a possible pending release and decided to take the opportunity to send out the bulk of Yocto Project's patch queue for libtool. We use it in a cross compiling environment and make extensive use of the sysroot support in the toolchain so most of our issues are in that area but there are also some reproducubility and reduction of unnecessary rpaths tweaks here. We've been using these patches for many years in some cases so it would be create to reduce our patchset and share the fixes with others. Some have been on the libtool mailing lists before but I thought it simpler to send the set out for review together as a set. Cheers, Richard Khem Raj (3): libtool.m4: Rename the --with-sysroot option to avoid conflict with gcc/binutils ltmain.in: Add missing sysroot to library path libtool: Check for static libs for internal compiler libraries Marek Vasut (1): libtool: Fix support for NIOS2 processor Mingli Yu (2): Makefile.am: make sure autoheader run before autoconf Makefile.am: make sure autoheader run before automake Richard Purdie (6): ltmain.in: Handle trailing slashes on install commands correctly ltmain.sh: Fix sysroot paths being encoded into RPATHs ltmain.in: Don't encode RATHS which match default linker paths libtool.m4: Handle "/" as a sysroot correctly ltmain.in: Handle prefix-map compiler options correctly libtool.m4: For reproducibility stop encoding hostname in libtool script Makefile.am | 4 +-- build-aux/ltmain.in | 81 +++-- m4/libtool.m4 | 25 -- tests/sysroot.at| 6 ++-- 4 files changed, 89 insertions(+), 27 deletions(-) -- 2.25.1