bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gettext-tools 0.21.1 failing on NetBSD sparc (32 bit)


From: Bruno Haible
Subject: Re: gettext-tools 0.21.1 failing on NetBSD sparc (32 bit)
Date: Wed, 24 May 2023 10:43:29 +0200

[CCing bug-gnulib]

Hello,

Brandon Applegate wrote in
<https://lists.gnu.org/archive/html/bug-gettext/2023-05/msg00042.html>:

> I am able to build gettext-tools 0.21 on NetBSD sparc just fine.  0.21.1 
> fails.  Here is my NetBSD bug report:
> 
> http://gnats.netbsd.org/57425
> 
> So it seems to fail on ftello bits.  However (and I’m not sure this is 
> related ? cause ?) - I notice in my 0.21 tree - gcc runs as expected, but in 
> 0.21.1 - it runs -mcpu=v9.

Yes, this "-mcpu=v9" is the cause. We add this option to $CC and $CXX,
in order to be able to use instructions like 'cas' and 'membar' in
asyncsafe-spin.c. On NetBSD/sparc under qemu, these instructions are
apparently not supported and produce an "Illegal instruction" exception.
Thus many configure tests fail, and the generated configuration file then
activates workarounds (such as FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE)
that were never meant to be used on NetBSD.

It is debatable whether this qemu configuration makes sense, since
SPARC CPUs since 1993 have been supporting the v9 instruction set. But
since both you and me are apparently using this same qemu configuration,
I can make an extra effort to fix this issue.

The original motivation for adding the -mcpu=v9 option was an old GCC on
Solaris <https://lists.gnu.org/archive/html/bug-gnulib/2020-11/msg00173.html>.
Whereas on NetBSD (I use version 7.1) on sparc, this option is better
omitted. This patch fixes it.


2023-05-24  Bruno Haible  <bruno@clisp.org>

        asyncsafe-spin, simple-atomic: Don't use -mcpu-v9 on NetBSD/sparc.
        Reported by Brandon Applegate in
        <https://lists.gnu.org/archive/html/bug-gettext/2023-05/msg00042.html>.
        * lib/asyncsafe-spin.c: Limit the SPARC workaround to Solaris.
        * lib/simple-atomic.c: Likewise.
        * m4/sparcv8+.m4 (gl_SPARC_V8PLUS): Likewise.

diff --git a/lib/asyncsafe-spin.c b/lib/asyncsafe-spin.c
index 9964473828..c4e7d711a1 100644
--- a/lib/asyncsafe-spin.c
+++ b/lib/asyncsafe-spin.c
@@ -134,11 +134,11 @@ do_unlock (asyncsafe_spinlock_t *lock)
 #   endif
 
 #  elif (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) \
-          && !defined __sparc__ && !defined __ANDROID__) \
+          && !(defined __sun && defined __sparc__) && !defined __ANDROID__) \
          || __clang_major__ >= 3) \
         && !defined __ibmxl__
-/* Use GCC built-ins (available in GCC >= 4.1, except on SPARC, and
-   clang >= 3.0).
+/* Use GCC built-ins (available in GCC >= 4.1, except on Solaris/SPARC and
+   Android, and clang >= 3.0).
    Documentation:
    <https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html>  */
 
diff --git a/lib/simple-atomic.c b/lib/simple-atomic.c
index eab87a3ec2..1f43bd771c 100644
--- a/lib/simple-atomic.c
+++ b/lib/simple-atomic.c
@@ -67,11 +67,11 @@ atomic_compare_and_swap_ptr (uintptr_t volatile *vp,
    require to link with -latomic.  */
 
 # if (((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) \
-       && !defined __sparc__ && !defined __ANDROID__) \
+       && !(defined __sun && defined __sparc__) && !defined __ANDROID__) \
       || __clang_major__ >= 3) \
      && !defined __ibmxl__
-/* Use GCC built-ins (available in GCC >= 4.1, except on SPARC, and
-   clang >= 3.0).
+/* Use GCC built-ins (available in GCC >= 4.1, except on Solaris/SPARC and
+   Android, and clang >= 3.0).
    Documentation:
    <https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html>  */
 
diff --git a/m4/sparcv8+.m4 b/m4/sparcv8+.m4
index 584c39d3ba..efe5bcdf86 100644
--- a/m4/sparcv8+.m4
+++ b/m4/sparcv8+.m4
@@ -1,4 +1,4 @@
-# sparcv8+.m4 serial 1
+# sparcv8+.m4 serial 2
 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,8 +18,8 @@ AC_DEFUN([gl_SPARC_V8PLUS]
 [
   AC_REQUIRE([AC_CANONICAL_HOST])
 
-  case "$host_cpu" in
-    sparc*)
+  case "$host" in
+    sparc*-*-solaris*)
       if test -n "$GCC"; then
         AC_CACHE_CHECK([whether SPARC v8+ instructions are supported],
           [gl_cv_sparc_v8plus],






reply via email to

[Prev in Thread] Current Thread [Next in Thread]