summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2024-01-14 18:07:45 +0000
committerSam James <sam@gentoo.org>2024-01-14 18:10:49 +0000
commit6c423a0961c235b9a898d21954705a3b8f943d1f (patch)
tree590ed39d15f4607581225f5df85e7e40eeff3769
parentpatches: darwin20-conf: add upstream references (diff)
downloadelt-patches-6c423a0961c235b9a898d21954705a3b8f943d1f.tar.gz
elt-patches-6c423a0961c235b9a898d21954705a3b8f943d1f.tar.bz2
elt-patches-6c423a0961c235b9a898d21954705a3b8f943d1f.zip
patches: sed-quote: add new patch
See https://harald.hoyer.xyz/2015/03/05/libtool-getting-rid-of-180000-sed-forks/ Interestingly, at the time, we added the patch to sys-devel/libtool in 5f4225eb727dcd8cc0eebd60620d4b2b160712aa, but we never pulled it into elt-patches. Note that we could try to pull in two more fixes: * 'libtool: optimizing options-parser hooks' (https://git.savannah.gnu.org/cgit/libtool.git/commit/?id=16dbc070d32e6d4601cb5878dfdf69f2e29c84e1) * 'funclib: refactor quoting methods a bit' (https://git.savannah.gnu.org/cgit/libtool.git/commit/?id=9187e9a231e0a06cc29c336857e95f07f855b2c9) Unconvinced it's worth it for those though: they're a lot bigger and they affect the API of the functions so more care is needed with any risk of fuzz, etc. Bug: https://bugs.gnu.org/20006 Bug: https://bugs.gentoo.org/542252 Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--eltpatch.in2
-rw-r--r--patches/sed-quote/2.4.6128
2 files changed, 129 insertions, 1 deletions
diff --git a/eltpatch.in b/eltpatch.in
index dfa994f..b1a623c 100644
--- a/eltpatch.in
+++ b/eltpatch.in
@@ -129,7 +129,7 @@ elibtoolize() {
local force="false"
local elt_patches="
install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed target-nm ppc64le
- specs fsanitize fuse-ld static-flags werror cxx-pthread color-record
+ specs fsanitize fuse-ld static-flags werror cxx-pthread color-record sed-quote
"
for x in "$@" ; do
diff --git a/patches/sed-quote/2.4.6 b/patches/sed-quote/2.4.6
new file mode 100644
index 0000000..073e40e
--- /dev/null
+++ b/patches/sed-quote/2.4.6
@@ -0,0 +1,128 @@
+https://harald.hoyer.xyz/2015/03/05/libtool-getting-rid-of-180000-sed-forks/
+https://bugs.gnu.org/20006
+https://bugs.gentoo.org/542252
+
+From 32f0df9835ac15ac17e04be57c368172c3ad1d19 Mon Sep 17 00:00:00 2001
+From: Pavel Raiskup <praiskup@redhat.com>
+Date: Sun, 4 Oct 2015 21:55:03 +0200
+Subject: [PATCH] libtool: mitigate the $sed_quote_subst slowdown
+
+When it is reasonably possible, use shell implementation for
+quoting.
+
+References:
+http://lists.gnu.org/archive/html/libtool/2015-03/msg00005.html
+http://lists.gnu.org/archive/html/libtool/2015-02/msg00000.html
+https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20006
+
+* ltmain.in (func_emit_wrapper): Use func_quote instead
+of '$SED $sed_quote_subst'.
+(func_mode_link): Likewise.
+--- ltmain.sh
++++ ltmain.sh
+@@ -1026,6 +1026,57 @@ func_relative_path ()
+ }
+
+
++# func_quote ARG
++# --------------
++# Aesthetically quote one ARG, store the result into $func_quote_result. Note
++# that we keep attention to performance here (so far O(N) complexity as long as
++# func_append is O(1)).
++func_quote ()
++{
++ $debug_cmd
++
++ func_quote_result=$1
++
++ case $func_quote_result in
++ *[\\\`\"\$]*)
++ case $func_quote_result in
++ *[\[\*\?]*)
++ func_quote_result=`$ECHO "$func_quote_result" | $SED "$sed_quote_subst"`
++ return 0
++ ;;
++ esac
++
++ func_quote_old_IFS=$IFS
++ for _G_char in '\' '`' '"' '$'
++ do
++ # STATE($1) PREV($2) SEPARATOR($3)
++ set start "" ""
++ func_quote_result=dummy"$_G_char$func_quote_result$_G_char"dummy
++ IFS=$_G_char
++ for _G_part in $func_quote_result
++ do
++ case $1 in
++ quote)
++ func_append func_quote_result "$3$2"
++ set quote "$_G_part" "\\$_G_char"
++ ;;
++ start)
++ set first "" ""
++ func_quote_result=
++ ;;
++ first)
++ set quote "$_G_part" ""
++ ;;
++ esac
++ done
++ IFS=$func_quote_old_IFS
++ done
++ ;;
++ *) ;;
++ esac
++}
++
++
+ # func_quote_for_eval ARG...
+ # --------------------------
+ # Aesthetically quote ARGs to be evaled later.
+@@ -1042,12 +1093,8 @@ func_quote_for_eval ()
+ func_quote_for_eval_unquoted_result=
+ func_quote_for_eval_result=
+ while test 0 -lt $#; do
+- case $1 in
+- *[\\\`\"\$]*)
+- _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
+- *)
+- _G_unquoted_arg=$1 ;;
+- esac
++ func_quote "$1"
++ _G_unquoted_arg=$func_quote_result
+ if test -n "$func_quote_for_eval_unquoted_result"; then
+ func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
+ else
+@@ -3346,7 +3346,8 @@ else
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ file=\"\$0\""
+
+- qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
++ func_quote "$ECHO"
++ qECHO=$func_quote_result
+ $ECHO "\
+
+ # A function that is used when there is no print builtin or printf.
+@@ -8596,8 +8597,8 @@ EOF
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+- relink_command="(cd `pwd`; $relink_command)"
+- relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
++ func_quote "(cd `pwd`; $relink_command)"
++ relink_command=$func_quote_result
+ fi
+
+ # Only actually do things if not in dry run mode.
+@@ -8843,7 +8844,8 @@ EOF
+ done
+ # Quote the link command for shipping.
+ relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+- relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
++ func_quote "$relink_command"
++ relink_command=$func_quote_result
+ if test yes = "$hardcode_automatic"; then
+ relink_command=
+ fi
+--
+2.6.2