>From 718f64eeeda938634fbdf14f99b33409376b7960 Mon Sep 17 00:00:00 2001 From: Peter Rosin Date: Tue, 11 Feb 2014 18:39:39 +0100 Subject: [PATCH] libtool: speed up lalib 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 by truncation if the dd utility is found and working. 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 pipes to 4k (fallback to no truncation if that is not possible). (_LT_SETUP): Require _LT_CMD_TRUNCATE. * build_aux/ltmain.in (func_lalib_p): Truncate the pipe before passing it on to sed. * THANKS: Update. Signed-off-by: Peter Rosin --- THANKS | 2 ++ build-aux/ltmain.in | 2 +- m4/libtool.m4 | 22 ++++++++++++++++++++++ 3 files changed, 25 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 3b4e6ec..bff642e 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -577,7 +577,7 @@ _LTECHO_EOF' func_lalib_p () { test -f "$1" && - $SED -e 4q "$1" 2>/dev/null \ + $lt_truncate_4k < "$1" 2>/dev/null | $SED -e 4q 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } diff --git a/m4/libtool.m4 b/m4/libtool.m4 index ce58f31..d5967d2 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 pipe to 4k +m4_defun([_LT_CMD_TRUNCATE], +[AC_PATH_PROG([DD], [dd]) +test -z "$DD" && DD=dd + +AC_CACHE_CHECK([how to truncate pipes to 4k], [lt_cv_truncate_4k], +[lt_cv_truncate_4k=cat +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_4k="$DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out]) + +_LT_DECL([lt_truncate_4k], [lt_cv_truncate_4k], [1], + [Command to truncate a pipe to 4k]) +])# _LT_CMD_TRUNCATE + + # _LT_CHECK_MAGIC_METHOD # ---------------------- # how to check for library dependencies -- 1.7.9