* [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts
@ 2022-05-12 22:28 Maciej W. Rozycki
2022-05-12 22:28 ` [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure' Maciej W. Rozycki
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Maciej W. Rozycki @ 2022-05-12 22:28 UTC (permalink / raw)
To: libc-alpha
Cc: Mao Han, Andreas Schwab, Joseph Myers, Palmer Dabbelt,
Darius Rad, Andrew Waterman, DJ Delorie
Hi,
I have discovered that we have two kinds of `preconfigure' scripts,
handwritten ones and autoconf-generated ones. While it seems perfectly
fine to have these scripts handwritten, some of them wire into autoconf
internals or use an ad-hoc way to report errors. The scripts for the
C-SKY, m68k, MIPS and RISC-V targets fall into this category.
This small patch series addresses this problem by converting these
scripts to autoconf templates with suitable adjustments, then processed
with autoconf to re-create functionally equivalent almost identical
scripts.
The RISC-V script has been verified to still correctly build the library.
All have been visually inspected to ensure functional equivalence; changes
are so minimal for this to be straightforward. There's some noise though
from a formatting fix to replace octets of spaces with tabs in the new
templates.
OK to apply?
Maciej
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure'
2022-05-12 22:28 [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Maciej W. Rozycki
@ 2022-05-12 22:28 ` Maciej W. Rozycki
2022-05-13 8:12 ` Andreas Schwab
2022-05-12 22:28 ` [PATCH v2 2/4] m68k: " Maciej W. Rozycki
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Maciej W. Rozycki @ 2022-05-12 22:28 UTC (permalink / raw)
To: libc-alpha
Cc: Mao Han, Andreas Schwab, Joseph Myers, Palmer Dabbelt,
Darius Rad, Andrew Waterman, DJ Delorie
Avoid fiddling with autoconf internals and use AC_DEFINE_UNQUOTED to
define macros in the configuration headers rather than handcoding an
equivalent shell sequence with the use of the `as_echo' undocumented
variable.
Switch to using AC_MSG_ERROR rather than `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'.
---
New change in v2.
---
sysdeps/csky/preconfigure | 27 +++++++++++++--------
sysdeps/csky/preconfigure.ac | 55 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 10 deletions(-)
glibc-csky-preconfigure-as-fn-error.diff
Index: glibc/sysdeps/csky/preconfigure
===================================================================
--- glibc.orig/sysdeps/csky/preconfigure
+++ glibc/sysdeps/csky/preconfigure
@@ -1,3 +1,6 @@
+# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
+# Local preconfigure fragment for sysdeps/csky
+
case "$machine" in
csky*)
abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
@@ -11,16 +14,14 @@ csky*)
case "$abi" in
1)
- echo "glibc does not support abiv1 yet" >&2
- exit 1
- ;;
+ as_fn_error 1 "glibc does not support abiv1 yet" "$LINENO" 5
+ ;;
2)
- machine=abiv2
- ;;
+ machine=abiv2
+ ;;
*)
- echo "Unknown abi" >&2
- exit 1
- ;;
+ as_fn_error 1 "Unknown abi" "$LINENO" 5
+ ;;
esac
# __CSKY_HARD_FLOAT_ABI__ was added on gcc 11 to specify whether
@@ -48,7 +49,13 @@ csky*)
base_machine=csky
machine=csky/$machine
- $as_echo "#define CSKYABI $abi" >>confdefs.h
- $as_echo "#define CSKY_HARD_FLOAT $with_fp_cond" >>confdefs.h
+ cat >>confdefs.h <<_ACEOF
+#define CSKYABI $abi
+_ACEOF
+
+ cat >>confdefs.h <<_ACEOF
+#define CSKY_HARD_FLOAT $with_fp_cond
+_ACEOF
+
;;
esac
Index: glibc/sysdeps/csky/preconfigure.ac
===================================================================
--- /dev/null
+++ glibc/sysdeps/csky/preconfigure.ac
@@ -0,0 +1,55 @@
+GLIBC_PROVIDES[]dnl See aclocal.m4 in the top level source directory.
+# Local preconfigure fragment for sysdeps/csky
+
+case "$machine" in
+csky*)
+ abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+ sed -n 's/^#define __CSKYABI__ \(.*\)/\1/p'`
+ hard_float=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+ sed -n 's/^#define __CSKY_HARD_FLOAT__ \(.*\)/\1/p'`
+ hard_float_sf=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+ sed -n 's/^#define __CSKY_HARD_FLOAT_FPU_SF__ \(.*\)/\1/p'`
+ hard_float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null |
+ sed -n 's/^#define __CSKY_HARD_FLOAT_ABI__ \(.*\)/\1/p'`
+
+ case "$abi" in
+ 1)
+ AC_MSG_ERROR([glibc does not support abiv1 yet], [1])
+ ;;
+ 2)
+ machine=abiv2
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown abi], [1])
+ ;;
+ esac
+
+ # __CSKY_HARD_FLOAT_ABI__ was added on gcc 11 to specify whether
+ # -mfloat-abi=hard is set. On older gcc, the float ABI is defined solely
+ # with __CSKY_HARD_FLOAT__. If __CSKY_HARD_FLOAT__ is set, it can be
+ # either a hard-float ABI (gcc older than 11, or gcc11 -mfloat-abi=hard
+ # (__CSKY_HARD_FLOAT_ABI__ is set) or -mfloat-abi=softfp
+ # (__CSKY_HARD_FLOAT_ABI__ is not set). To be compatible with older gcc,
+ # use __CSKY_HARD_FLOAT_FPU_SF__ identify if -mfloat-abi is supported,
+ # because it is added to gcc at the same time as -mfloat-abi.
+ if test -n "$hard_float"; then
+ if test -z "$hard_float_sf"; then
+ with_fp_cond=1
+ else
+ if test -n "$hard_float_abi"; then
+ with_fp_cond=1
+ else
+ with_fp_cond=0
+ fi
+ fi
+ else
+ with_fp_cond=0
+ fi
+
+ base_machine=csky
+ machine=csky/$machine
+
+ AC_DEFINE_UNQUOTED([CSKYABI], [$abi])
+ AC_DEFINE_UNQUOTED([CSKY_HARD_FLOAT], [$with_fp_cond])
+ ;;
+esac
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/4] m68k: Use an autoconf template to produce `preconfigure'
2022-05-12 22:28 [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Maciej W. Rozycki
2022-05-12 22:28 ` [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure' Maciej W. Rozycki
@ 2022-05-12 22:28 ` Maciej W. Rozycki
2022-05-13 8:12 ` Andreas Schwab
2022-05-12 22:29 ` [PATCH v2 3/4] MIPS: " Maciej W. Rozycki
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Maciej W. Rozycki @ 2022-05-12 22:28 UTC (permalink / raw)
To: libc-alpha
Cc: Mao Han, Andreas Schwab, Joseph Myers, Palmer Dabbelt,
Darius Rad, Andrew Waterman, DJ Delorie
Switch to using AC_MSG_ERROR rather than `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'.
---
New change in v2.
---
sysdeps/m68k/preconfigure | 6 ++++--
sysdeps/m68k/preconfigure.ac | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
glibc-m68k-preconfigure-as-fn-error.diff
Index: glibc/sysdeps/m68k/preconfigure
===================================================================
--- glibc.orig/sysdeps/m68k/preconfigure
+++ glibc/sysdeps/m68k/preconfigure
@@ -1,3 +1,6 @@
+# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
+# Local preconfigure fragment for sysdeps/m68k
+
# This fragment canonicalizes the machine names for m68k variants.
case "$machine" in
@@ -10,8 +13,7 @@ m68k) variant=`(echo "#ifdef __mcoldfir
$CC $CFLAGS $CPPFLAGS -E - |
grep '^[a-z]'`
if test -z "$variant"; then
- echo >&2 "Cannot determine m68k processor variant"
- exit 1
+ as_fn_error 1 "Cannot determine m68k processor variant" "$LINENO" 5
fi
base_machine=m68k machine=m68k/$variant
if test "$variant" = "coldfire"; then
Index: glibc/sysdeps/m68k/preconfigure.ac
===================================================================
--- /dev/null
+++ glibc/sysdeps/m68k/preconfigure.ac
@@ -0,0 +1,23 @@
+GLIBC_PROVIDES[]dnl See aclocal.m4 in the top level source directory.
+# Local preconfigure fragment for sysdeps/m68k
+
+# This fragment canonicalizes the machine names for m68k variants.
+
+case "$machine" in
+m680?0) base_machine=m68k machine=m68k/m680x0/$machine ;;
+m68k) variant=`(echo "#ifdef __mcoldfire__"
+ echo "coldfire"
+ echo "#else"
+ echo "m680x0/m68020"
+ echo "#endif") |
+ $CC $CFLAGS $CPPFLAGS -E - |
+ grep '^[[a-z]]'`
+ if test -z "$variant"; then
+ AC_MSG_ERROR([Cannot determine m68k processor variant], [1])
+ fi
+ base_machine=m68k machine=m68k/$variant
+ if test "$variant" = "coldfire"; then
+ with_fp_cond="defined __mcffpu__"
+ fi
+ ;;
+esac
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/4] MIPS: Use an autoconf template to produce `preconfigure'
2022-05-12 22:28 [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Maciej W. Rozycki
2022-05-12 22:28 ` [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure' Maciej W. Rozycki
2022-05-12 22:28 ` [PATCH v2 2/4] m68k: " Maciej W. Rozycki
@ 2022-05-12 22:29 ` Maciej W. Rozycki
2022-05-13 8:15 ` Andreas Schwab
2022-05-12 22:29 ` [PATCH v2 4/4] RISC-V: " Maciej W. Rozycki
2022-05-12 22:33 ` [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Palmer Dabbelt
4 siblings, 1 reply; 11+ messages in thread
From: Maciej W. Rozycki @ 2022-05-12 22:29 UTC (permalink / raw)
To: libc-alpha
Cc: Mao Han, Andreas Schwab, Joseph Myers, Palmer Dabbelt,
Darius Rad, Andrew Waterman, DJ Delorie
Avoid fiddling with autoconf internals and use AC_DEFINE_UNQUOTED to
define macros in the configuration headers rather than handcoding an
equivalent shell sequence with the use of the `as_echo' undocumented
variable.
Similarly use AC_MSG_ERROR for error handling rather than the internal
undocumented `as_fn_error' variable. Switch to using 1 as the exit code
as it makes no sense to refer $? in the contexts involved, it's not a
command failure handled there.
---
New change in v2.
---
sysdeps/mips/preconfigure | 7 +++++--
sysdeps/mips/preconfigure.ac | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
glibc-mips-preconfigure-as-fn-error.diff
Index: glibc/sysdeps/mips/preconfigure
===================================================================
--- glibc.orig/sysdeps/mips/preconfigure
+++ glibc/sysdeps/mips/preconfigure
@@ -1,3 +1,6 @@
+# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
+# Local preconfigure fragment for sysdeps/mips
+
case "$machine" in
mips*)
abiflag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define _MIPS_SIM \(.*\)/\1/p'`
@@ -15,7 +18,7 @@ mips*)
elif test "$abiflag" = "_ABI64" ; then
machine=mips/mips64/n64
else
- as_fn_error $? "Unable to determine ABI." "$LINENO" 5
+ as_fn_error 1 "Unable to determine ABI." "$LINENO" 5
fi
# $config_machine is not really needed here but the slash after
# $machine is needed by the case statement in
@@ -23,7 +26,7 @@ mips*)
machine=$machine/$config_machine
if test "$abiflag" != "_ABIO32" -a "$mips16flag" = "1"; then
- as_fn_error $? "MIPS16 is only supported with the o32 ABI." "$LINENO" 5
+ as_fn_error 1 "MIPS16 is only supported with the o32 ABI." "$LINENO" 5
fi
with_fp_cond="defined __mips_hard_float"
Index: glibc/sysdeps/mips/preconfigure.ac
===================================================================
--- /dev/null
+++ glibc/sysdeps/mips/preconfigure.ac
@@ -0,0 +1,34 @@
+GLIBC_PROVIDES[]dnl See aclocal.m4 in the top level source directory.
+# Local preconfigure fragment for sysdeps/mips
+
+case "$machine" in
+mips*)
+ abiflag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define _MIPS_SIM \(.*\)/\1/p'`
+ mips16flag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __mips16 \(.*\)/\1/p'`
+
+ base_machine=mips
+ if test "$abiflag" = "_ABIO32" ; then
+ if test "$mips16flag" = "1" ; then
+ machine=mips/mips32/mips16
+ else
+ machine=mips/mips32
+ fi
+ elif test "$abiflag" = "_ABIN32" ; then
+ machine=mips/mips64/n32
+ elif test "$abiflag" = "_ABI64" ; then
+ machine=mips/mips64/n64
+ else
+ AC_MSG_ERROR([Unable to determine ABI.], [1])
+ fi
+ # $config_machine is not really needed here but the slash after
+ # $machine is needed by the case statement in
+ # sysdeps/unix/sysv/linux/mips/configure.ac.
+ machine=$machine/$config_machine
+
+ if test "$abiflag" != "_ABIO32" -a "$mips16flag" = "1"; then
+ AC_MSG_ERROR([MIPS16 is only supported with the o32 ABI.], [1])
+ fi
+
+ with_fp_cond="defined __mips_hard_float"
+ ;;
+esac
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 4/4] RISC-V: Use an autoconf template to produce `preconfigure'
2022-05-12 22:28 [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Maciej W. Rozycki
` (2 preceding siblings ...)
2022-05-12 22:29 ` [PATCH v2 3/4] MIPS: " Maciej W. Rozycki
@ 2022-05-12 22:29 ` Maciej W. Rozycki
2022-05-12 22:34 ` Palmer Dabbelt
2022-05-12 22:33 ` [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Palmer Dabbelt
4 siblings, 1 reply; 11+ messages in thread
From: Maciej W. Rozycki @ 2022-05-12 22:29 UTC (permalink / raw)
To: libc-alpha
Cc: Mao Han, Andreas Schwab, Joseph Myers, Palmer Dabbelt,
Darius Rad, Andrew Waterman, DJ Delorie
Avoid fiddling with autoconf internals and use AC_DEFINE_UNQUOTED to
define macros in the configuration headers rather than handcoding an
equivalent shell sequence with the use of the `as_echo' undocumented
variable.
Switch to using AC_MSG_ERROR rather than `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'.
---
Changes from v1:
- Convert the script to an autoconf template and use AC_MSG_ERROR.
- Also handle configuration macro definitions, using AC_DEFINE_UNQUOTED.
---
sysdeps/riscv/preconfigure | 33 +++++++++++----------
sysdeps/riscv/preconfigure.ac | 64 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 15 deletions(-)
glibc-riscv-preconfigure-as-fn-error.diff
Index: glibc/sysdeps/riscv/preconfigure
===================================================================
--- glibc.orig/sysdeps/riscv/preconfigure
+++ glibc/sysdeps/riscv/preconfigure
@@ -1,3 +1,6 @@
+# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
+# Local preconfigure fragment for sysdeps/riscv
+
case "$machine" in
riscv*)
xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'`
@@ -9,8 +12,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 +22,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,31 +37,34 @@ 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
case "$atomic" in
__riscv_atomic)
- ;;
+ ;;
*)
- echo "glibc requires the A extension" >&2
- exit 1
+ as_fn_error 1 "glibc requires the A extension" "$LINENO" 5
;;
esac
base_machine=riscv
machine=riscv/rv$xlen/$float_machine
- $as_echo "#define RISCV_ABI_XLEN $xlen" >>confdefs.h
- $as_echo "#define RISCV_ABI_FLEN $abi_flen" >>confdefs.h
+ cat >>confdefs.h <<_ACEOF
+#define RISCV_ABI_XLEN $xlen
+_ACEOF
+
+ cat >>confdefs.h <<_ACEOF
+#define RISCV_ABI_FLEN $abi_flen
+_ACEOF
+
;;
esac
Index: glibc/sysdeps/riscv/preconfigure.ac
===================================================================
--- /dev/null
+++ glibc/sysdeps/riscv/preconfigure.ac
@@ -0,0 +1,64 @@
+GLIBC_PROVIDES[]dnl See aclocal.m4 in the top level source directory.
+# Local preconfigure fragment for sysdeps/riscv
+
+case "$machine" in
+riscv*)
+ xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'`
+ flen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_flen \(.*\)/\1/p'`
+ float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_float_abi_\([^ ]*\) .*/\1/p'`
+ atomic=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep '#define __riscv_atomic' | cut -d' ' -f2`
+
+ case "$xlen" in
+ 64 | 32)
+ ;;
+ *)
+ AC_MSG_ERROR([Unable to determine XLEN], [1])
+ ;;
+ esac
+
+ case "$flen" in
+ 64)
+ float_machine=rvd
+ with_fp_cond=1
+ ;;
+ 32)
+ AC_MSG_ERROR([glibc does not yet support systems with the F but not D extensions], 1)
+ ;;
+ "")
+ with_fp_cond=0
+ ;;
+ *)
+ AC_MSG_ERROR([Unable to determine FLEN], [1])
+ ;;
+ esac
+
+ case "$float_abi" in
+ soft)
+ abi_flen=0
+ ;;
+ single)
+ AC_MSG_ERROR([glibc does not yet support the single floating-point ABI], [1])
+ ;;
+ double)
+ abi_flen=64
+ ;;
+ *)
+ AC_MSG_ERROR([Unable to determine floating-point ABI], [1])
+ ;;
+ esac
+
+ case "$atomic" in
+ __riscv_atomic)
+ ;;
+ *)
+ AC_MSG_ERROR([glibc requires the A extension], [1])
+ ;;
+ esac
+
+ base_machine=riscv
+ machine=riscv/rv$xlen/$float_machine
+
+ AC_DEFINE_UNQUOTED([RISCV_ABI_XLEN], [$xlen])
+ AC_DEFINE_UNQUOTED([RISCV_ABI_FLEN], [$abi_flen])
+ ;;
+esac
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts
2022-05-12 22:28 [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Maciej W. Rozycki
` (3 preceding siblings ...)
2022-05-12 22:29 ` [PATCH v2 4/4] RISC-V: " Maciej W. Rozycki
@ 2022-05-12 22:33 ` Palmer Dabbelt
4 siblings, 0 replies; 11+ messages in thread
From: Palmer Dabbelt @ 2022-05-12 22:33 UTC (permalink / raw)
To: macro
Cc: libc-alpha, han_mao, schwab, joseph, Darius Rad, Andrew Waterman, dj
On Thu, 12 May 2022 15:28:27 PDT (-0700), macro@embecosm.com wrote:
> Hi,
>
> I have discovered that we have two kinds of `preconfigure' scripts,
> handwritten ones and autoconf-generated ones. While it seems perfectly
> fine to have these scripts handwritten, some of them wire into autoconf
> internals or use an ad-hoc way to report errors. The scripts for the
> C-SKY, m68k, MIPS and RISC-V targets fall into this category.
>
> This small patch series addresses this problem by converting these
> scripts to autoconf templates with suitable adjustments, then processed
> with autoconf to re-create functionally equivalent almost identical
> scripts.
>
> The RISC-V script has been verified to still correctly build the library.
> All have been visually inspected to ensure functional equivalence; changes
> are so minimal for this to be straightforward. There's some noise though
> from a formatting fix to replace octets of spaces with tabs in the new
> templates.
>
> OK to apply?
OK from me for the RISC-V bits (I'd had a draft up for the v1 waiting
for me to build it, as that one hadn't said anything), but given that I
probably broke them in the first place (and likely because I don't
understand autoconf) that might not be the best ack ;)
Thanks!
>
> Maciej
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 4/4] RISC-V: Use an autoconf template to produce `preconfigure'
2022-05-12 22:29 ` [PATCH v2 4/4] RISC-V: " Maciej W. Rozycki
@ 2022-05-12 22:34 ` Palmer Dabbelt
0 siblings, 0 replies; 11+ messages in thread
From: Palmer Dabbelt @ 2022-05-12 22:34 UTC (permalink / raw)
To: macro
Cc: libc-alpha, han_mao, schwab, joseph, Darius Rad, Andrew Waterman, dj
On Thu, 12 May 2022 15:29:11 PDT (-0700), macro@embecosm.com wrote:
> Avoid fiddling with autoconf internals and use AC_DEFINE_UNQUOTED to
> define macros in the configuration headers rather than handcoding an
> equivalent shell sequence with the use of the `as_echo' undocumented
> variable.
>
> Switch to using AC_MSG_ERROR rather than `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'.
> ---
> Changes from v1:
>
> - Convert the script to an autoconf template and use AC_MSG_ERROR.
>
> - Also handle configuration macro definitions, using AC_DEFINE_UNQUOTED.
> ---
> sysdeps/riscv/preconfigure | 33 +++++++++++----------
> sysdeps/riscv/preconfigure.ac | 64 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 82 insertions(+), 15 deletions(-)
>
> glibc-riscv-preconfigure-as-fn-error.diff
> Index: glibc/sysdeps/riscv/preconfigure
> ===================================================================
> --- glibc.orig/sysdeps/riscv/preconfigure
> +++ glibc/sysdeps/riscv/preconfigure
> @@ -1,3 +1,6 @@
> +# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
> +# Local preconfigure fragment for sysdeps/riscv
> +
> case "$machine" in
> riscv*)
> xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'`
> @@ -9,8 +12,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 +22,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,31 +37,34 @@ 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
>
> case "$atomic" in
> __riscv_atomic)
> - ;;
> + ;;
> *)
> - echo "glibc requires the A extension" >&2
> - exit 1
> + as_fn_error 1 "glibc requires the A extension" "$LINENO" 5
> ;;
> esac
>
> base_machine=riscv
> machine=riscv/rv$xlen/$float_machine
>
> - $as_echo "#define RISCV_ABI_XLEN $xlen" >>confdefs.h
> - $as_echo "#define RISCV_ABI_FLEN $abi_flen" >>confdefs.h
> + cat >>confdefs.h <<_ACEOF
> +#define RISCV_ABI_XLEN $xlen
> +_ACEOF
> +
> + cat >>confdefs.h <<_ACEOF
> +#define RISCV_ABI_FLEN $abi_flen
> +_ACEOF
> +
> ;;
> esac
> Index: glibc/sysdeps/riscv/preconfigure.ac
> ===================================================================
> --- /dev/null
> +++ glibc/sysdeps/riscv/preconfigure.ac
> @@ -0,0 +1,64 @@
> +GLIBC_PROVIDES[]dnl See aclocal.m4 in the top level source directory.
> +# Local preconfigure fragment for sysdeps/riscv
> +
> +case "$machine" in
> +riscv*)
> + xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'`
> + flen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_flen \(.*\)/\1/p'`
> + float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_float_abi_\([^ ]*\) .*/\1/p'`
> + atomic=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep '#define __riscv_atomic' | cut -d' ' -f2`
> +
> + case "$xlen" in
> + 64 | 32)
> + ;;
> + *)
> + AC_MSG_ERROR([Unable to determine XLEN], [1])
> + ;;
> + esac
> +
> + case "$flen" in
> + 64)
> + float_machine=rvd
> + with_fp_cond=1
> + ;;
> + 32)
> + AC_MSG_ERROR([glibc does not yet support systems with the F but not D extensions], 1)
> + ;;
> + "")
> + with_fp_cond=0
> + ;;
> + *)
> + AC_MSG_ERROR([Unable to determine FLEN], [1])
> + ;;
> + esac
> +
> + case "$float_abi" in
> + soft)
> + abi_flen=0
> + ;;
> + single)
> + AC_MSG_ERROR([glibc does not yet support the single floating-point ABI], [1])
> + ;;
> + double)
> + abi_flen=64
> + ;;
> + *)
> + AC_MSG_ERROR([Unable to determine floating-point ABI], [1])
> + ;;
> + esac
> +
> + case "$atomic" in
> + __riscv_atomic)
> + ;;
> + *)
> + AC_MSG_ERROR([glibc requires the A extension], [1])
> + ;;
> + esac
> +
> + base_machine=riscv
> + machine=riscv/rv$xlen/$float_machine
> +
> + AC_DEFINE_UNQUOTED([RISCV_ABI_XLEN], [$xlen])
> + AC_DEFINE_UNQUOTED([RISCV_ABI_FLEN], [$abi_flen])
> + ;;
> +esac
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure'
2022-05-12 22:28 ` [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure' Maciej W. Rozycki
@ 2022-05-13 8:12 ` Andreas Schwab
0 siblings, 0 replies; 11+ messages in thread
From: Andreas Schwab @ 2022-05-13 8:12 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: libc-alpha, Mao Han, Joseph Myers, Palmer Dabbelt, Darius Rad,
Andrew Waterman, DJ Delorie
On Mai 12 2022, Maciej W. Rozycki wrote:
> Avoid fiddling with autoconf internals and use AC_DEFINE_UNQUOTED to
> define macros in the configuration headers rather than handcoding an
> equivalent shell sequence with the use of the `as_echo' undocumented
> variable.
>
> Switch to using AC_MSG_ERROR rather than `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'.
Ok.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/4] m68k: Use an autoconf template to produce `preconfigure'
2022-05-12 22:28 ` [PATCH v2 2/4] m68k: " Maciej W. Rozycki
@ 2022-05-13 8:12 ` Andreas Schwab
0 siblings, 0 replies; 11+ messages in thread
From: Andreas Schwab @ 2022-05-13 8:12 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: libc-alpha, Mao Han, Joseph Myers, Palmer Dabbelt, Darius Rad,
Andrew Waterman, DJ Delorie
On Mai 12 2022, Maciej W. Rozycki wrote:
> Switch to using AC_MSG_ERROR rather than `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'.
Ok.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/4] MIPS: Use an autoconf template to produce `preconfigure'
2022-05-12 22:29 ` [PATCH v2 3/4] MIPS: " Maciej W. Rozycki
@ 2022-05-13 8:15 ` Andreas Schwab
2022-05-13 16:10 ` Maciej W. Rozycki
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2022-05-13 8:15 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: libc-alpha, Mao Han, Joseph Myers, Palmer Dabbelt, Darius Rad,
Andrew Waterman, DJ Delorie
On Mai 12 2022, Maciej W. Rozycki wrote:
> Avoid fiddling with autoconf internals and use AC_DEFINE_UNQUOTED to
> define macros in the configuration headers rather than handcoding an
> equivalent shell sequence with the use of the `as_echo' undocumented
> variable.
>
> Similarly use AC_MSG_ERROR for error handling rather than the internal
> undocumented `as_fn_error' variable. Switch to using 1 as the exit code
> as it makes no sense to refer $? in the contexts involved, it's not a
> command failure handled there.
Ok.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/4] MIPS: Use an autoconf template to produce `preconfigure'
2022-05-13 8:15 ` Andreas Schwab
@ 2022-05-13 16:10 ` Maciej W. Rozycki
0 siblings, 0 replies; 11+ messages in thread
From: Maciej W. Rozycki @ 2022-05-13 16:10 UTC (permalink / raw)
To: Andreas Schwab
Cc: libc-alpha, Mao Han, Joseph Myers, Palmer Dabbelt, Darius Rad,
Andrew Waterman, DJ Delorie
On Fri, 13 May 2022, Andreas Schwab wrote:
> > Similarly use AC_MSG_ERROR for error handling rather than the internal
> > undocumented `as_fn_error' variable. Switch to using 1 as the exit code
> > as it makes no sense to refer $? in the contexts involved, it's not a
> > command failure handled there.
>
> Ok.
Series committed, thank you both for the review.
Maciej
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-05-13 16:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 22:28 [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Maciej W. Rozycki
2022-05-12 22:28 ` [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure' Maciej W. Rozycki
2022-05-13 8:12 ` Andreas Schwab
2022-05-12 22:28 ` [PATCH v2 2/4] m68k: " Maciej W. Rozycki
2022-05-13 8:12 ` Andreas Schwab
2022-05-12 22:29 ` [PATCH v2 3/4] MIPS: " Maciej W. Rozycki
2022-05-13 8:15 ` Andreas Schwab
2022-05-13 16:10 ` Maciej W. Rozycki
2022-05-12 22:29 ` [PATCH v2 4/4] RISC-V: " Maciej W. Rozycki
2022-05-12 22:34 ` Palmer Dabbelt
2022-05-12 22:33 ` [PATCH v2 0/4] Avoid relying on autoconf internals in `preconfigure' scripts Palmer Dabbelt
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).