public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@embecosm.com>
To: libc-alpha@sourceware.org
Cc: Mao Han <han_mao@linux.alibaba.com>,
	 Andreas Schwab <schwab@linux-m68k.org>,
	 Joseph Myers <joseph@codesourcery.com>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Darius Rad <darius@bluespec.com>,
	 Andrew Waterman <andrew@sifive.com>, DJ Delorie <dj@redhat.com>
Subject: [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure'
Date: Thu, 12 May 2022 23:28:45 +0100 (BST)	[thread overview]
Message-ID: <alpine.DEB.2.20.2205122246320.10833@tpp.orcam.me.uk> (raw)
In-Reply-To: <alpine.DEB.2.20.2205122234010.10833@tpp.orcam.me.uk>

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

  reply	other threads:[~2022-05-12 22:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-05-13  8:12   ` [PATCH v2 1/4] C-SKY: Use an autoconf template to produce `preconfigure' 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.2205122246320.10833@tpp.orcam.me.uk \
    --to=macro@embecosm.com \
    --cc=andrew@sifive.com \
    --cc=darius@bluespec.com \
    --cc=dj@redhat.com \
    --cc=han_mao@linux.alibaba.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=palmer@dabbelt.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).