diff mbox

Non portable sed invocation in libgcc configury

Message ID 20140323104629.GA18530@mail.duskware.de
State New
Headers show

Commit Message

Martin Husemann March 23, 2014, 10:46 a.m. UTC
libgcc/config/t-hardfp uses sed to convert libgcc function names
(like __addsf3) into a tuple of -D defines.

The regular expression used for that contains |, which is not a basic
regular expression and not understood by posix sed.

Gnu sed seems to enable it by default, I suppose - or this should have been
noticed earlier. Many other sed implementations need -E or -r (for gnu sed
compatibility), which the attached patch adds.

It might be better to split the alternatives into several expressions
and duplicate the right hand sides, or mix with some sh code, but this is
already pretty messy.

Martin

Comments

Andreas Schwab March 23, 2014, 10:59 a.m. UTC | #1
Martin Husemann <martin@NetBSD.org> writes:

> --- t-hardfp.orig	2014-02-07 08:46:34.000000000 +0100
> +++ t-hardfp	2014-03-23 11:36:12.000000000 +0100
> @@ -64,7 +64,7 @@
>  #   TYPE: the last floating-point mode (e.g. sf)
>  hardfp_defines_for = \
>    $(shell echo $1 | \
> -    sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/')
> +    sed -r 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/')

-r changes the regexp syntax to extended, so this will no longer match.

Andreas.
Martin Husemann March 23, 2014, 12:21 p.m. UTC | #2
On Sun, Mar 23, 2014 at 11:59:39AM +0100, Andreas Schwab wrote:
> -r changes the regexp syntax to extended, so this will no longer match.

Right, it needs a few more \ removed - however, it doesn't work anyway,
as our sed does not accept empty alternatives:

(si|2|3|) fails with: RE error: empty (sub)expression

Since the script is outside posix, what is the prefered solution here?

Martin
diff mbox

Patch

--- t-hardfp.orig	2014-02-07 08:46:34.000000000 +0100
+++ t-hardfp	2014-03-23 11:36:12.000000000 +0100
@@ -64,7 +64,7 @@ 
 #   TYPE: the last floating-point mode (e.g. sf)
 hardfp_defines_for = \
   $(shell echo $1 | \
-    sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/')
+    sed -r 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/')
 
 hardfp-o = $(patsubst %,%$(objext),$(hardfp_func_list))
 $(hardfp-o): %$(objext): $(srcdir)/config/hardfp.c