public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Maciej W. Rozycki <macro@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] C-SKY: Use an autoconf template to produce `preconfigure'
Date: Fri, 13 May 2022 16:10:18 +0000 (GMT)	[thread overview]
Message-ID: <20220513161018.5B94C3857C4A@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7c20479d082eb85ac1179df0411ef3e4a0634298

commit 7c20479d082eb85ac1179df0411ef3e4a0634298
Author: Maciej W. Rozycki <macro@embecosm.com>
Date:   Fri May 13 17:07:23 2022 +0100

    C-SKY: Use an autoconf template to produce `preconfigure'
    
    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'.

Diff:
---
 sysdeps/csky/preconfigure    | 27 ++++++++++++++--------
 sysdeps/csky/preconfigure.ac | 55 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 10 deletions(-)

diff --git a/sysdeps/csky/preconfigure b/sysdeps/csky/preconfigure
index 5f22416f95..8a6136dd8d 100644
--- a/sysdeps/csky/preconfigure
+++ b/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
diff --git a/sysdeps/csky/preconfigure.ac b/sysdeps/csky/preconfigure.ac
new file mode 100644
index 0000000000..332c0f1cab
--- /dev/null
+++ b/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-13 16:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220513161018.5B94C3857C4A@sourceware.org \
    --to=macro@sourceware.org \
    --cc=glibc-cvs@sourceware.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).