Bug 235293

Summary: GCC MIPS cross-compiler build fails due to BSD sed (needing GNU extensions)
Product: Base System Reporter: sebastian.huber
Component: miscAssignee: Kyle Evans <kevans>
Status: New ---    
Severity: Affects Some People CC: bugs, kevans, rb
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

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"
Comment 5 Kyle Evans freebsd_committer freebsd_triage 2020-06-07 20:26:41 UTC
I hope to have resolved this properly by the end of the year; take.