public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] config, aarch64: Use a more compatible sed invocation.
@ 2023-10-24 15:53 Iain Sandoe
  2023-10-25  9:09 ` Richard Earnshaw
  0 siblings, 1 reply; 2+ messages in thread
From: Iain Sandoe @ 2023-10-24 15:53 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard.Earnshaw

Although this came up initially when working on the Darwin Arm64
port, it also breaks cross-compilers on platforms with non-GNU sed.

Tested on x86_64-darwin X aarch64-linux-gnu, aarch64-darwin,
aarch64-linux-gnu and x86_64-linux-gnu.  OK for master?
thanks,
Iain

--- 8< ---

Currently, the sed command used to parse --with-{cpu,tune,arch} are
using GNU-specific extension to the -e (recognising extended regex).

This is failing on Darwin, which defaults to Posix behaviour for -e.
However '-E' is accepted to indicate an extended RE.  Strictly, this
is also not really sufficient, since we should only require a Posix
sed (but it seems supported for BSD-derivatives).

gcc/ChangeLog:

	* config.gcc: Use -E to to sed to indicate that we are using
	extended REs.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 gcc/config.gcc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 606d3a8513e..a7216907261 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4199,8 +4199,8 @@ case "${target}" in
 		fi
 		for which in cpu arch tune; do
 			eval "val=\$with_$which"
-			base_val=`echo $val | sed -e 's/\+.*//'`
-			ext_val=`echo $val | sed -e 's/[a-z0-9.-]\+//'`
+			base_val=`echo $val | sed -E 's/\+.*//'`
+			ext_val=`echo $val | sed -E 's/[a-z0-9.-]+//'`
 
 			if [ $which = arch ]; then
 			  def=aarch64-arches.def
@@ -4232,9 +4232,9 @@ case "${target}" in
 
 			  while [ x"$ext_val" != x ]
 			  do
-				ext_val=`echo $ext_val | sed -e 's/\+//'`
-				ext=`echo $ext_val | sed -e 's/\+.*//'`
-				base_ext=`echo $ext | sed -e 's/^no//'`
+				ext_val=`echo $ext_val | sed -E 's/\+//'`
+				ext=`echo $ext_val | sed -E 's/\+.*//'`
+				base_ext=`echo $ext | sed -E 's/^no//'`
 				opt_line=`echo -e "$options_parsed" | \
 					grep "^\"$base_ext\""`
 
@@ -4245,7 +4245,7 @@ case "${target}" in
 				  echo "Unknown extension used in --with-$which=$val" 1>&2
 				  exit 1
 				fi
-				ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'`
+				ext_val=`echo $ext_val | sed -E 's/[a-z0-9]+//'`
 			  done
 
 			  true
-- 
2.39.2 (Apple Git-143)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] config, aarch64: Use a more compatible sed invocation.
  2023-10-24 15:53 [PATCH] config, aarch64: Use a more compatible sed invocation Iain Sandoe
@ 2023-10-25  9:09 ` Richard Earnshaw
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Earnshaw @ 2023-10-25  9:09 UTC (permalink / raw)
  To: iain, gcc-patches



On 24/10/2023 16:53, Iain Sandoe wrote:
> Although this came up initially when working on the Darwin Arm64
> port, it also breaks cross-compilers on platforms with non-GNU sed.
> 
> Tested on x86_64-darwin X aarch64-linux-gnu, aarch64-darwin,
> aarch64-linux-gnu and x86_64-linux-gnu.  OK for master?
> thanks,
> Iain
> 
> --- 8< ---
> 
> Currently, the sed command used to parse --with-{cpu,tune,arch} are
> using GNU-specific extension to the -e (recognising extended regex).
> 
> This is failing on Darwin, which defaults to Posix behaviour for -e.
> However '-E' is accepted to indicate an extended RE.  Strictly, this
> is also not really sufficient, since we should only require a Posix
> sed (but it seems supported for BSD-derivatives).
> 

The man pages I have for linux, freebsd and macos all show something 
pretty similar:

   -e script
               add the script to the commands to be executed

Wording varies slightly, but I think the meaning is clearly the same. 
So this really has nothing to do with extended regexps.

That means, I think, that we really want '-E -e <script>' if we need to 
handle extended regexps here.

If that works for Darwin, then please commit with that change.

R.

> gcc/ChangeLog:
> 
> 	* config.gcc: Use -E to to sed to indicate that we are using
> 	extended REs.
> 
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> ---
>   gcc/config.gcc | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 606d3a8513e..a7216907261 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -4199,8 +4199,8 @@ case "${target}" in
>   		fi
>   		for which in cpu arch tune; do
>   			eval "val=\$with_$which"
> -			base_val=`echo $val | sed -e 's/\+.*//'`
> -			ext_val=`echo $val | sed -e 's/[a-z0-9.-]\+//'`
> +			base_val=`echo $val | sed -E 's/\+.*//'`
> +			ext_val=`echo $val | sed -E 's/[a-z0-9.-]+//'`
>   
>   			if [ $which = arch ]; then
>   			  def=aarch64-arches.def
> @@ -4232,9 +4232,9 @@ case "${target}" in
>   
>   			  while [ x"$ext_val" != x ]
>   			  do
> -				ext_val=`echo $ext_val | sed -e 's/\+//'`
> -				ext=`echo $ext_val | sed -e 's/\+.*//'`
> -				base_ext=`echo $ext | sed -e 's/^no//'`
> +				ext_val=`echo $ext_val | sed -E 's/\+//'`
> +				ext=`echo $ext_val | sed -E 's/\+.*//'`
> +				base_ext=`echo $ext | sed -E 's/^no//'`
>   				opt_line=`echo -e "$options_parsed" | \
>   					grep "^\"$base_ext\""`
>   
> @@ -4245,7 +4245,7 @@ case "${target}" in
>   				  echo "Unknown extension used in --with-$which=$val" 1>&2
>   				  exit 1
>   				fi
> -				ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'`
> +				ext_val=`echo $ext_val | sed -E 's/[a-z0-9]+//'`
>   			  done
>   
>   			  true

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-25  9:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-24 15:53 [PATCH] config, aarch64: Use a more compatible sed invocation Iain Sandoe
2023-10-25  9:09 ` Richard Earnshaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).