1 From 3adadb568fbf15d952bd25a005b6a9afb7e59dc7 Mon Sep 17 00:00:00 2001
2 From: Pavel Raiskup <praiskup@redhat.com>
3 Date: Sun, 4 Oct 2015 21:55:03 +0200
4 Subject: libtool: mitigate the $sed_quote_subst slowdown
6 When it is reasonably possible, use shell implementation for
10 http://lists.gnu.org/archive/html/libtool/2015-03/msg00005.html
11 http://lists.gnu.org/archive/html/libtool/2015-02/msg00000.html
12 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20006
14 * gl/build-aux/funclib.sh (func_quote): New function that can be
15 used as substitution for '$SED $sed_quote_subst' call.
16 * build-aux/ltmain.in (func_emit_wrapper): Use func_quote instead
17 of '$SED $sed_quote_subst'.
18 (func_mode_link): Likewise.
20 * bootstrap: Sync with funclib.sh.
22 (cherry picked from commit 32f0df9835ac15ac17e04be57c368172c3ad1d19)
23 (skipping NEWS change)
24 Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
28 @@ -230,7 +230,7 @@ vc_ignore=
30 # Source required external libraries:
31 # Set a version string for this script.
32 -scriptversion=2015-01-20.17; # UTC
33 +scriptversion=2015-10-04.22; # UTC
35 # General shell script boiler plate, and helper functions.
36 # Written by Gary V. Vaughan, 2004
37 @@ -1257,6 +1257,57 @@ func_relative_path ()
43 +# Aesthetically quote one ARG, store the result into $func_quote_result. Note
44 +# that we keep attention to performance here (so far O(N) complexity as long as
45 +# func_append is O(1)).
50 + func_quote_result=$1
52 + case $func_quote_result in
54 + case $func_quote_result in
56 + func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"`
61 + func_quote_old_IFS=$IFS
62 + for _G_char in '\' '`' '"' '$'
64 + # STATE($1) PREV($2) SEPARATOR($3)
66 + func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy
68 + for _G_part in $func_quote_result
72 + func_append func_quote_result "$3$2"
73 + set quote "$_G_part" "\\$_G_char"
80 + set quote "$_G_part" ""
84 + IFS=$func_quote_old_IFS
92 # func_quote_for_eval ARG...
93 # --------------------------
94 # Aesthetically quote ARGs to be evaled later.
95 @@ -1273,12 +1324,8 @@ func_quote_for_eval ()
96 func_quote_for_eval_unquoted_result=
97 func_quote_for_eval_result=
98 while test 0 -lt $#; do
101 - _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
103 - _G_unquoted_arg=$1 ;;
106 + _G_unquoted_arg=$func_quote_result
107 if test -n "$func_quote_for_eval_unquoted_result"; then
108 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
110 --- a/build-aux/ltmain.in
111 +++ b/build-aux/ltmain.in
112 @@ -3356,7 +3356,8 @@ else
113 if test \"\$libtool_execute_magic\" != \"$magic\"; then
116 - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
118 + qECHO=$func_quote_result
121 # A function that is used when there is no print builtin or printf.
122 @@ -8618,8 +8619,8 @@ EOF
123 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
126 - relink_command="(cd `pwd`; $relink_command)"
127 - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
128 + func_quote "(cd `pwd`; $relink_command)"
129 + relink_command=$func_quote_result
132 # Only actually do things if not in dry run mode.
133 @@ -8865,7 +8866,8 @@ EOF
135 # Quote the link command for shipping.
136 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
137 - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
138 + func_quote "$relink_command"
139 + relink_command=$func_quote_result
140 if test yes = "$hardcode_automatic"; then
143 --- a/build-aux/funclib.sh
144 +++ b/build-aux/funclib.sh
146 # Set a version string for this script.
147 -scriptversion=2015-01-20.17; # UTC
148 +scriptversion=2015-10-04.22; # UTC
150 # General shell script boiler plate, and helper functions.
151 # Written by Gary V. Vaughan, 2004
152 @@ -1026,6 +1026,57 @@ func_relative_path ()
158 +# Aesthetically quote one ARG, store the result into $func_quote_result. Note
159 +# that we keep attention to performance here (so far O(N) complexity as long as
160 +# func_append is O(1)).
165 + func_quote_result=$1
167 + case $func_quote_result in
169 + case $func_quote_result in
171 + func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"`
176 + func_quote_old_IFS=$IFS
177 + for _G_char in '\' '`' '"' '$'
179 + # STATE($1) PREV($2) SEPARATOR($3)
181 + func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy
183 + for _G_part in $func_quote_result
187 + func_append func_quote_result "$3$2"
188 + set quote "$_G_part" "\\$_G_char"
195 + set quote "$_G_part" ""
199 + IFS=$func_quote_old_IFS
207 # func_quote_for_eval ARG...
208 # --------------------------
209 # Aesthetically quote ARGs to be evaled later.
210 @@ -1042,12 +1093,8 @@ func_quote_for_eval ()
211 func_quote_for_eval_unquoted_result=
212 func_quote_for_eval_result=
213 while test 0 -lt $#; do
216 - _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
218 - _G_unquoted_arg=$1 ;;
221 + _G_unquoted_arg=$func_quote_result
222 if test -n "$func_quote_for_eval_unquoted_result"; then
223 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"