>From d93a003e6189c0c8f9f91ef6e48b3a65063979da Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Thu, 13 Feb 2014 20:22:42 +0100 Subject: [PATCH] libtool: speed up ltwrapper_script detection in execute mode Execute mode is slow and might even DOS the computer in extreme cases when a parameter is a big binary file without newlines. Work around this with different truncation if a suitable dd utility is found. Fixes bug#13472 and bug#16662. Reported by Pavel Raiskup and Nick Bowler. * m4/libtool.m4 (_LT_CMD_TRUNCATE): New macro, for finding out how to truncate binary pipes (fallback to the old sed truncation if no suitable dd is found). (_LT_SETUP): Require _LT_CMD_TRUNCATE. * build_aux/ltmain.in (func_ltwrapper_script_p): Truncate the pipe according to _LT_CMD_TRUNCATE. * THANKS: Update. Signed-off-by: Peter Rosin --- THANKS | 2 ++ build-aux/ltmain.in | 4 +++- m4/libtool.m4 | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/THANKS b/THANKS index e895aee..85c5150 100644 --- a/THANKS +++ b/THANKS @@ -150,6 +150,7 @@ Mike Gorchak address@hidden Mike Frysinger address@hidden Mike Miller address@hidden + Nick Bowler address@hidden Nix address@hidden Olaf Lenz address@hidden Olly Betts address@hidden @@ -161,6 +162,7 @@ Paul Eggert address@hidden Paul Laight address@hidden Paul Seidler address@hidden + Pavel Raiskup address@hidden Paweł Daniluk address@hidden Peter Eisentraut address@hidden Peter Fritzsche address@hidden diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index f8e0f5f..b013688 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -610,7 +610,9 @@ func_lalib_unsafe_p () # determined imposters. func_ltwrapper_script_p () { - func_lalib_p "$1" + test -f "$1" && + $lt_truncate_bin < "$1" 2>/dev/null \ + | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_ltwrapper_executable_p file diff --git a/m4/libtool.m4 b/m4/libtool.m4 index ce58f31..b9ac7f8 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -169,6 +169,7 @@ m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl +m4_require([_LT_CMD_TRUNCATE])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options that allow our @@ -3216,6 +3217,27 @@ _LT_TAGDECL([], [reload_cmds], [2])dnl ])# _LT_CMD_RELOAD +# _LT_CMD_TRUNCATE +# ---------------- +# find command to truncate a binary pipe +m4_defun([_LT_CMD_TRUNCATE], +[AC_PATH_PROG([DD], [dd]) +test -z "$DD" && DD=dd + +AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], +[lt_cv_truncate_bin="$SED -e 4q" +printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +if "$DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out && lt_cv_truncate_bin="$DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out]) + +_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], + [Command to truncate a binary pipe]) +])# _LT_CMD_TRUNCATE + + # _LT_CHECK_MAGIC_METHOD # ---------------------- # how to check for library dependencies -- 1.7.9