Bug 235293 - GCC MIPS cross-compiler build fails due to BSD sed
Summary: GCC MIPS cross-compiler build fails due to BSD sed
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-29 10:48 UTC by sebastian.huber
Modified: 2019-01-30 06:47 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sebastian.huber 2019-01-29 10:48:58 UTC
See also:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66032

The problem is this sed invocation:

https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/config/t-hardfp#l76

For example, BSD sed produces (FreeBSD 12):

echo "__adddsf3" | sed 's/\(.*\)\(sf\|df\)/\1 \2/'
__adddsf3

GNU sed produces:

echo "__adddsf3" | sed 's/\(.*\)\(sf\|df\)/\1 \2/'
__addd sf3
Comment 1 Bob Bishop 2019-01-29 11:22:22 UTC
BSD sed behaves as documented. Per re_format(7): "Obsolete (``basic'') regular expressions differ in several	respects.  `|' is an ordinary character and there	is no equivalent for its functionality."

Rewrite the RE as follows to achieve the desired outcome:

echo "__adddsf3" | sed 's/\(.*\)\([sd]f\)/\1 \2/'
__addd sf3
Comment 2 sebastian.huber 2019-01-29 11:44:25 UTC
In the referenced GCC file, the sed expression is constructed in several steps, one input is

hardfp_float_modes := sf df

which is transformed via

hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /\\|/g')

which is used in

hardfp_defines_for = \
   $(shell echo $1 | \
     sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/')

So, it is difficult to use another regex.
Comment 3 Bob Bishop 2019-01-29 17:01:29 UTC
(In reply to sebastian.huber from comment #2)
OK, so if it's too hard to use GNU sed for the build, wrap BSD sed (for the build) in a script that fixes the RE in the troublesome case(s) and is otherwise pass-thru.
Comment 4 sebastian.huber 2019-01-30 06:47:27 UTC
Fixing BSD sed to cope with these regular expressions is not an option? If it is not an option, then please close this bug as "Works As Intended"