Bug 235293 - GCC MIPS cross-compiler build fails due to BSD sed (needing GNU extensions)
Summary: GCC MIPS cross-compiler build fails due to BSD sed (needing GNU extensions)
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Kyle Evans
Depends on:
Reported: 2019-01-29 10:48 UTC by sebastian.huber
Modified: 2020-06-07 20:27 UTC (History)
3 users (show)

See Also:


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:


The problem is this sed invocation:


For example, BSD sed produces (FreeBSD 12):

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

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