summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikle Kolyada <zlogene@gentoo.org>2019-08-22 14:09:27 +0300
committerMikle Kolyada <zlogene@gentoo.org>2019-08-22 14:10:02 +0300
commit25be2b1ffdcbf50bf28d89f8987f853f9bdca79c (patch)
tree8e59b17bf154c10407dfdfd19d7a7b1987a491f1
parentsci-mathematics/rstudio: fix slashes (diff)
downloadgentoo-25be2b1ffdcbf50bf28d89f8987f853f9bdca79c.tar.gz
gentoo-25be2b1ffdcbf50bf28d89f8987f853f9bdca79c.tar.bz2
gentoo-25be2b1ffdcbf50bf28d89f8987f853f9bdca79c.zip
net-dns/bind-tools: detect sparc pause instruction properly
Closes: https://bugs.gentoo.org/691708 Package-Manager: Portage-2.3.69, Repoman-2.3.16 Signed-off-by: Mikle Kolyada <zlogene@gentoo.org>
-rw-r--r--net-dns/bind-tools/bind-tools-9.14.4.ebuild2
-rw-r--r--net-dns/bind-tools/files/sparc-pause-instruction.patch135
2 files changed, 137 insertions, 0 deletions
diff --git a/net-dns/bind-tools/bind-tools-9.14.4.ebuild b/net-dns/bind-tools/bind-tools-9.14.4.ebuild
index 489ecbb114fe..7090d635dc05 100644
--- a/net-dns/bind-tools/bind-tools-9.14.4.ebuild
+++ b/net-dns/bind-tools/bind-tools-9.14.4.ebuild
@@ -42,6 +42,8 @@ S="${WORKDIR}/${MY_P}"
# bug 479092, requires networking
RESTRICT="test"
+PATCHES=( "${FILESDIR}"/sparc-pause-instruction.patch )
+
src_prepare() {
default
diff --git a/net-dns/bind-tools/files/sparc-pause-instruction.patch b/net-dns/bind-tools/files/sparc-pause-instruction.patch
new file mode 100644
index 000000000000..35ddb24da0b0
--- /dev/null
+++ b/net-dns/bind-tools/files/sparc-pause-instruction.patch
@@ -0,0 +1,135 @@
+From a5ad6b16c5c0bfd333758d707a6397be79a92914 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Thu, 8 Aug 2019 08:33:10 +0100
+Subject: [PATCH] configure.ac: autodetect 'pause' instruction presence on
+ sparc
+
+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>
+---
+ config.h.in | 3 +++
+ configure | 33 +++++++++++++++++++++++++++++++++
+ configure.ac | 14 ++++++++++++++
+ lib/isc/rwlock.c | 2 +-
+ 4 files changed, 51 insertions(+), 1 deletion(-)
+
+diff --git a/config.h.in b/config.h.in
+index 91508e5d91..eeba105ec6 100644
+--- a/config.h.in
++++ b/config.h.in
+@@ -357,6 +357,9 @@
+ /* Define to 1 if you have the `setresuid' function. */
+ #undef HAVE_SETRESUID
+
++/* 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
+
+diff --git a/configure b/configure
+index d336f6aa24..757dacb06e 100755
+--- a/configure
++++ b/configure
+@@ -13872,6 +13872,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"
+diff --git a/configure.ac b/configure.ac
+index 90aafae8d0..b04c651966 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -415,6 +415,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])
+
+ #
+diff --git a/lib/isc/rwlock.c b/lib/isc/rwlock.c
+index a6ea35feed..e313a912e0 100644
+--- a/lib/isc/rwlock.c
++++ b/lib/isc/rwlock.c
+@@ -152,7 +152,7 @@ isc_rwlock_destroy(isc_rwlock_t *rwl) {
+ # 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)
+--
+2.21.0
+