From acffc72f16c13a81f622f9353a5da40a35ebb5ee Mon Sep 17 00:00:00 2001 From: Thomas Backlund Date: Sat, 5 Feb 2011 19:36:23 +0000 Subject: merge under/overlinking scripts from rpm-manbo-setup --- Makefile.am | 21 ++++++---- NEWS | 1 + ...-no-undefined-for-shared-lib-modules-in-libtool | 47 ++++++++++++++++++++++ fix-dlsearch-path-in-libtool-for-multilib | 23 +++++++++++ fix-libtool-from-moving-options-after-libs | 15 +++++++ fix-libtool-ltmain-from-overlinking | 14 +++++++ force-as-needed-for-shared-lib-in-libtool | 14 +++++++ 7 files changed, 127 insertions(+), 8 deletions(-) create mode 100755 drop-ld-no-undefined-for-shared-lib-modules-in-libtool create mode 100644 fix-dlsearch-path-in-libtool-for-multilib create mode 100755 fix-libtool-from-moving-options-after-libs create mode 100644 fix-libtool-ltmain-from-overlinking create mode 100755 force-as-needed-for-shared-lib-in-libtool diff --git a/Makefile.am b/Makefile.am index 5c1c0db..ff71923 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,15 +22,20 @@ pkg_gconfig = \ pkg_scripts = \ brp-compress \ - brp-strip \ - brp-strip-comment-note \ + brp-strip \ + brp-strip-comment-note \ brp-strip-static-archive \ - filter.sh \ - find-lang.pl \ - find-debuginfo.sh \ - gem_helper.rb \ - git-repository--after-tarball \ - git-repository--apply-patch \ + drop-ld-no-undefined-for-shared-lib-modules-in-libtool \ + filter.sh \ + find-lang.pl \ + find-debuginfo.sh \ + fix-dlsearch-path-in-libtool-for-multilib \ + fix-libtool-from-moving-options-after-libs \ + fix-libtool-ltmain-from-overlinking \ + force-as-needed-for-shared-lib-in-libtool \ + gem_helper.rb \ + git-repository--after-tarball \ + git-repository--apply-patch \ http.req \ magic.prov \ magic.req \ diff --git a/NEWS b/NEWS index 77206b6..c84a799 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ Version 1.116 - 5 February 2011, by Thomas Backlund - merge rpmrc from rpm-manbo-setup - merge manbo.macros from rpm-manbo-setup - merge manbo-build.macros from rpm-manbo-setup +- merge under/overlinking scripts from rpm-manbo-setup Version 1.115 - 9 January 2011, by Oliver Blin - initial Mageia import diff --git a/drop-ld-no-undefined-for-shared-lib-modules-in-libtool b/drop-ld-no-undefined-for-shared-lib-modules-in-libtool new file mode 100755 index 0000000..e2d8e67 --- /dev/null +++ b/drop-ld-no-undefined-for-shared-lib-modules-in-libtool @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# applies patch: +# --- ltmain.sh.pix 2008-05-23 13:51:52.000000000 +0200 +# +++ ltmain.sh 2008-05-23 13:52:16.000000000 +0200 +# @@ -1948,6 +1948,11 @@ +# fi +# done # argument parsing loop +# +# + if test "$module" = yes ; then +# + # [Manbo-labs] dropping ld option "--no-undefined" which is wrong for plugins +# + linker_flags=`echo "X $linker_flags" | $Xsed -e 's/ --no-undefined//'` +# + compiler_flags=`echo "X $compiler_flags" | $Xsed -e 's/ -Wl,--no-undefined//'` +# + fi +# + +# if test -n "$prev"; then +# $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 +# $echo "$help" 1>&2 + +# a similar patch has been applied in ltmain.sh in libtool package +# but this works even if autoreconf is not called + +foreach my $ltmain ('ltmain.sh', glob("*/ltmain.sh")) { + open(my $F, '<', $ltmain) or next; + + print "Modifying $ltmain underlinking for plugins (cf http://wiki.mandriva.com/en/Underlinking)\n"; + + open(my $G, '>', "$ltmain.new") or exit; + while (<$F>) { + print $G $_; + + if ($_ eq " done # argument parsing loop\n") { + $modified = 1; + print $G <<'EOF'; + + if test "$module" = yes ; then + linker_flags=`echo "X $linker_flags" | $Xsed -e 's/ --no-undefined//'` + compiler_flags=`echo "X $compiler_flags" | $Xsed -e 's/ -Wl,--no-undefined//'` + fi +EOF + } + } + + rename $ltmain, "$ltmain.drop" + and rename "$ltmain.new", $ltmain or print STDERR "modifying $ltmain failed: $!\n"; +} + diff --git a/fix-dlsearch-path-in-libtool-for-multilib b/fix-dlsearch-path-in-libtool-for-multilib new file mode 100644 index 0000000..6872ee5 --- /dev/null +++ b/fix-dlsearch-path-in-libtool-for-multilib @@ -0,0 +1,23 @@ +#!/bin/sh + +# If configure was generated with libtool that did not have support for +# run-time library search path (sys_lib_dlsearch_path_spec) autodetection, +# we replace the hardcoded search path with "/usr/%{_lib} /%{_lib}". + +# Our libtool has autodetection in form of lib64.patch, though it does not +# handle cases (e.g. Debian) where /usr/lib is valid for multilib archs. + +# Without the correct search path defined, binaries would wrongly get rpath even +# when the libraries are located in a standard directory. + +CONFIGURE_TOP="${1:-.}" +LIB="${2:-lib}" +if [ -e $CONFIGURE_TOP/configure ] && grep -q 'sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"' $CONFIGURE_TOP/configure; then + echo "Forcing run-time library search path definition in configure to prevent libtool from adding rpath for standard directories (configure was generated with libtool without support for autodetection)" + + sed -i \ + -e "s,^[ \t]*# Append ld.so.conf contents to the search path, sys_lib_dlsearch_path_spec=\"/usr/${LIB} /${LIB}\"\n\0," \ + -e 's,sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra",sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra",' \ + $CONFIGURE_TOP/configure +fi + diff --git a/fix-libtool-from-moving-options-after-libs b/fix-libtool-from-moving-options-after-libs new file mode 100755 index 0000000..e8db899 --- /dev/null +++ b/fix-libtool-from-moving-options-after-libs @@ -0,0 +1,15 @@ +#!/bin/sh + +CONFIGURE_TOP="${1:-.}" +if [ -e $CONFIGURE_TOP/configure ] && grep -q -F '$deplibs $compiler_flags' $CONFIGURE_TOP/configure; then + echo "Fixing libtool inside configure to pass -Wl,xxx options before libraries" + + # a similar patch has been applied in libtool in libtool package (#47273) + # but this works even if autoreconf is not called + + sed -i \ + -e 's,$deplibs $compiler_flags,$compiler_flags $deplibs,' \ + -e 's,$deplibs $postdep_objects $compiler_flags,$compiler_flags $deplibs $postdep_objects,' \ + $CONFIGURE_TOP/configure +fi + diff --git a/fix-libtool-ltmain-from-overlinking b/fix-libtool-ltmain-from-overlinking new file mode 100644 index 0000000..b6b97e3 --- /dev/null +++ b/fix-libtool-ltmain-from-overlinking @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ -e ltmain.sh ]; then + echo "Fixing libtool's ltmain.sh to prevent overlinking (cf http://wiki.mandriva.com/en/Overlinking)" + + # a similar patch has been applied in ltmain.sh in libtool package + # but this works even if autoreconf is not called + + mv ltmain.sh ltmain.sh.orig + echo link_all_deplibs=no > ltmain.sh + cat ltmain.sh.orig >> ltmain.sh + + sed -i -s 's/link) libs="$deplibs %DEPLIBS% $dependency_libs"/link) libs="$deplibs %DEPLIBS%"/' ltmain.sh +fi diff --git a/force-as-needed-for-shared-lib-in-libtool b/force-as-needed-for-shared-lib-in-libtool new file mode 100755 index 0000000..2694273 --- /dev/null +++ b/force-as-needed-for-shared-lib-in-libtool @@ -0,0 +1,14 @@ +#!/bin/sh + +# replaces +# tmp_sharedflag='-shared' ;; +# with +# tmp_sharedflag='-shared -Wl,--as-needed' ;; +# +# since passing -Wl,--as-needed is not enough because libtool moves it +# after *.o and libs + +if [ -e configure ]; then + echo "Forcing -Wl,--as-needed in configure/libtool to workaround libtool bug (cf http://lists.gnu.org/archive/html/libtool-patches/2004-06/msg00002.html)" + sed -i "s/^\([ \t]*tmp_sharedflag\)='-shared'/\1='-shared -Wl,--as-needed'/" configure +fi -- cgit v1.2.1