RISC-V: Use `as_fn_error' to report errors in `preconfigure'

Message ID alpine.DEB.2.20.2205121752330.11552@tpp.orcam.me.uk
State Superseded
Headers
Series RISC-V: Use `as_fn_error' to report errors in `preconfigure' |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Maciej W. Rozycki May 12, 2022, 5:19 p.m. UTC
  Unlike some other `preconfigure' fragments the RISC-V one uses `echo' 
and `exit' directly for error handling.  Owing to the lack of any kind 
of error annotation it makes it difficult to spot the message in the 
flood in a parallel build and neither it is logged in `config.log'.

Switch to using `as_fn_error' then as the fragment is sourced from the 
main `configure' script and therefore the function can be used like in 
other `preconfigure' fragments, so the message printed is such as:

configure: error: glibc requires the A extension

rather than plain:

glibc requires the A extension

and one can filter on the "error" part.
---
 sysdeps/riscv/preconfigure |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

glibc-riscv-preconfigure-as-fn-error.diff
  

Comments

Andreas Schwab May 12, 2022, 5:32 p.m. UTC | #1
On Mai 12 2022, Maciej W. Rozycki wrote:

> Switch to using `as_fn_error' then as the fragment is sourced from the 
> main `configure' script and therefore the function can be used like in 
> other `preconfigure' fragments, so the message printed is such as:

I don't think we should use autoconf internals.
  
Maciej W. Rozycki May 12, 2022, 6:39 p.m. UTC | #2
On Thu, 12 May 2022, Andreas Schwab wrote:

> > Switch to using `as_fn_error' then as the fragment is sourced from the 
> > main `configure' script and therefore the function can be used like in 
> > other `preconfigure' fragments, so the message printed is such as:
> 
> I don't think we should use autoconf internals.

 In principle I agree, I just didn't realise we have some `preconfigure' 
fragments handwritten and some autoconf-generated.  That probably confused 
people too who added various handwritten equivalents where they would have 
best relied on autoconf instead.

 So let's fix the C-SKY and RISC-V ones, which already both mess up with 
confdefs.h the wrong way, update them along with the m68k one for proper 
error reporting, and fix the MIPS one which already incorrectly relies on 
`as_fn_error'.  Other fragments are either generated or do not appear to 
mess up with autoconf internals.

 Sending v2 right away, for the total of 4 patches now.  Thanks for your 
review!

  Maciej
  

Patch

Index: glibc/sysdeps/riscv/preconfigure
===================================================================
--- glibc.orig/sysdeps/riscv/preconfigure
+++ glibc/sysdeps/riscv/preconfigure
@@ -9,8 +9,7 @@  riscv*)
     64 | 32)
 	;;
     *)
-	echo "Unable to determine XLEN" >&2
-	exit 1
+	as_fn_error 1 "Unable to determine XLEN" "$LINENO" 5
 	;;
     esac
 
@@ -20,15 +19,13 @@  riscv*)
 	with_fp_cond=1
 	;;
     32)
-	echo "glibc does not yet support systems with the F but not D extensions" >&2
-	exit 1
+	as_fn_error 1 "glibc does not yet support systems with the F but not D extensions" "$LINENO" 5
 	;;
     "")
 	with_fp_cond=0
 	;;
     *)
-	echo "Unable to determine FLEN" >&2
-	exit 1
+	as_fn_error 1 "Unable to determine FLEN" "$LINENO" 5
 	;;
     esac
 
@@ -37,15 +34,13 @@  riscv*)
 	abi_flen=0
 	;;
     single)
-	echo "glibc does not yet support the single floating-point ABI" >&2
-	exit 1
+	as_fn_error 1 "glibc does not yet support the single floating-point ABI" "$LINENO" 5
 	;;
     double)
 	abi_flen=64
 	;;
     *)
-	echo "Unable to determine floating-point ABI" >&2
-	exit 1
+	as_fn_error 1 "Unable to determine floating-point ABI" "$LINENO" 5
 	;;
     esac
 
@@ -53,8 +48,7 @@  riscv*)
     __riscv_atomic)
         ;;
     *)
-        echo "glibc requires the A extension" >&2
-	exit 1
+	as_fn_error 1 "glibc requires the A extension" "$LINENO" 5
 	;;
     esac