]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
configure.ac: autodetect 'pause' instruction presence on sparc
authorSergei Trofimovich <slyfox@gentoo.org>
Thu, 8 Aug 2019 07:33:10 +0000 (08:33 +0100)
committerOndřej Surý <ondrej@sury.org>
Thu, 8 Aug 2019 12:03:29 +0000 (14:03 +0200)
The change fixes the following build failure on sparc T3 and older CPUs:

```
sparc-unknown-linux-gnu-gcc ... -O2 -mcpu=niagara2 ... -c rwlock.c
{standard input}: Assembler messages:
{standard input}:398: Error: Architecture mismatch on "pause ".
{standard input}:398: (Requires v9e|v9v|v9m|m8; requested architecture is v9b.)
make[1]: *** [Makefile:280: rwlock.o] Error 1
```

`pause` insutruction exists only on `-mcpu=niagara4` (`T4`) and upper.

The change adds `pause` configure-time autodetection and uses it if available.
config.h.in got new `HAVE_SPARC_PAUSE` knob. Fallback is a fall-through no-op.

Build-tested on:

- sparc-unknown-linux-gnu-gcc (no `pause`, build succeeds)
- sparc-unknown-linux-gnu-gcc -mcpu=niagara4 (`pause`, build succeeds)

Reported-by: Rolf Eike Beer
Bug: https://bugs.gentoo.org/691708
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit a5ad6b16c5c0bfd333758d707a6397be79a92914)

config.h.in
configure
configure.ac
lib/isc/rwlock.c

index 00a1d747b48d779fc331efda2e9e10a398456c7f..46f90da292377cfdca39ebe4568ae2c8a39f8d38 100644 (file)
 /* Define to 1 if you have the `sigwait' function. */
 #undef HAVE_SIGWAIT
 
+/* define if the SPARC pause instruction is available */
+#undef HAVE_SPARC_PAUSE
+
 /* define if struct stat has st_mtim.tv_nsec field */
 #undef HAVE_STAT_NSEC
 
index 19a32ebe4f7d8e4e390bbda0524422dd61fc2743..13b788325c488bc2aa35842f828929637a009853 100755 (executable)
--- a/configure
+++ b/configure
@@ -13627,6 +13627,39 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; #(
      ;;
 esac
 
+#
+# Check for pause support on SPARC processors
+#
+case $host in #(
+  sparc*) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pause instruction support" >&5
+$as_echo_n "checking for pause instruction support... " >&6; }
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+__asm__ __volatile__ ("pause")
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_SPARC_PAUSE 1" >>confdefs.h
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; #(
+  *) :
+     ;;
+esac
+
 for ac_func in sysctlbyname
 do :
   ac_fn_c_check_func "$LINENO" "sysctlbyname" "ac_cv_func_sysctlbyname"
index 1ac6e5f7420ebb6bdfbbba00a097f8a546188ffe..94a6a05339092329c20917e2853362d2efdea524 100644 (file)
@@ -443,6 +443,20 @@ AS_CASE([$host],
                        [define if the ARM yield instruction is available])],
             [AC_MSG_RESULT([no])])])
 
+#
+# Check for pause support on SPARC processors
+#
+AS_CASE([$host],
+       [sparc*],
+       [AC_MSG_CHECKING([for pause instruction support])
+        AC_COMPILE_IFELSE(
+            [AC_LANG_PROGRAM([[]],
+                            [[__asm__ __volatile__ ("pause")]])],
+            [AC_MSG_RESULT([yes])
+             AC_DEFINE([HAVE_SPARC_PAUSE], [1],
+                       [define if the SPARC pause instruction is available])],
+            [AC_MSG_RESULT([no])])])
+
 AC_CHECK_FUNCS([sysctlbyname])
 
 #
index 3780b98c9971363dcefecfc11ba7d22201e84783..7ff6877b193bd46333c99ff829988ffea9393642 100644 (file)
@@ -58,7 +58,7 @@
 # define isc_rwlock_pause() __asm__ __volatile__ ("yield")
 #elif defined(sun) && (defined(__sparc) || defined(__sparc__))
 # define isc_rwlock_pause() smt_pause()
-#elif defined(__sparc) || defined(__sparc__)
+#elif (defined(__sparc) || defined(__sparc__)) && HAVE_SPARC_PAUSE
 # define isc_rwlock_pause() __asm__ __volatile__ ("pause")
 #elif defined(__ppc__) || defined(_ARCH_PPC)  ||                       \
        defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)