Gentoo Archives: gentoo-commits

From: Mikle Kolyada <zlogene@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-dns/bind-tools/, net-dns/bind-tools/files/
Date: Thu, 22 Aug 2019 11:10:23
Message-Id: 1566472202.25be2b1ffdcbf50bf28d89f8987f853f9bdca79c.zlogene@gentoo
1 commit: 25be2b1ffdcbf50bf28d89f8987f853f9bdca79c
2 Author: Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
3 AuthorDate: Thu Aug 22 11:09:27 2019 +0000
4 Commit: Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
5 CommitDate: Thu Aug 22 11:10:02 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=25be2b1f
7
8 net-dns/bind-tools: detect sparc pause instruction properly
9
10 Closes: https://bugs.gentoo.org/691708
11 Package-Manager: Portage-2.3.69, Repoman-2.3.16
12 Signed-off-by: Mikle Kolyada <zlogene <AT> gentoo.org>
13
14 net-dns/bind-tools/bind-tools-9.14.4.ebuild | 2 +
15 .../bind-tools/files/sparc-pause-instruction.patch | 135 +++++++++++++++++++++
16 2 files changed, 137 insertions(+)
17
18 diff --git a/net-dns/bind-tools/bind-tools-9.14.4.ebuild b/net-dns/bind-tools/bind-tools-9.14.4.ebuild
19 index 489ecbb114f..7090d635dc0 100644
20 --- a/net-dns/bind-tools/bind-tools-9.14.4.ebuild
21 +++ b/net-dns/bind-tools/bind-tools-9.14.4.ebuild
22 @@ -42,6 +42,8 @@ S="${WORKDIR}/${MY_P}"
23 # bug 479092, requires networking
24 RESTRICT="test"
25
26 +PATCHES=( "${FILESDIR}"/sparc-pause-instruction.patch )
27 +
28 src_prepare() {
29 default
30
31
32 diff --git a/net-dns/bind-tools/files/sparc-pause-instruction.patch b/net-dns/bind-tools/files/sparc-pause-instruction.patch
33 new file mode 100644
34 index 00000000000..35ddb24da0b
35 --- /dev/null
36 +++ b/net-dns/bind-tools/files/sparc-pause-instruction.patch
37 @@ -0,0 +1,135 @@
38 +From a5ad6b16c5c0bfd333758d707a6397be79a92914 Mon Sep 17 00:00:00 2001
39 +From: Sergei Trofimovich <slyfox@g.o>
40 +Date: Thu, 8 Aug 2019 08:33:10 +0100
41 +Subject: [PATCH] configure.ac: autodetect 'pause' instruction presence on
42 + sparc
43 +
44 +The change fixes the following build failure on sparc T3 and older CPUs:
45 +
46 +```
47 +sparc-unknown-linux-gnu-gcc ... -O2 -mcpu=niagara2 ... -c rwlock.c
48 +{standard input}: Assembler messages:
49 +{standard input}:398: Error: Architecture mismatch on "pause ".
50 +{standard input}:398: (Requires v9e|v9v|v9m|m8; requested architecture is v9b.)
51 +make[1]: *** [Makefile:280: rwlock.o] Error 1
52 +```
53 +
54 +`pause` insutruction exists only on `-mcpu=niagara4` (`T4`) and upper.
55 +
56 +The change adds `pause` configure-time autodetection and uses it if available.
57 +config.h.in got new `HAVE_SPARC_PAUSE` knob. Fallback is a fall-through no-op.
58 +
59 +Build-tested on:
60 +
61 +- sparc-unknown-linux-gnu-gcc (no `pause`, build succeeds)
62 +- sparc-unknown-linux-gnu-gcc -mcpu=niagara4 (`pause`, build succeeds)
63 +
64 +Reported-by: Rolf Eike Beer
65 +Bug: https://bugs.gentoo.org/691708
66 +Signed-off-by: Sergei Trofimovich <slyfox@g.o>
67 +---
68 + config.h.in | 3 +++
69 + configure | 33 +++++++++++++++++++++++++++++++++
70 + configure.ac | 14 ++++++++++++++
71 + lib/isc/rwlock.c | 2 +-
72 + 4 files changed, 51 insertions(+), 1 deletion(-)
73 +
74 +diff --git a/config.h.in b/config.h.in
75 +index 91508e5d91..eeba105ec6 100644
76 +--- a/config.h.in
77 ++++ b/config.h.in
78 +@@ -357,6 +357,9 @@
79 + /* Define to 1 if you have the `setresuid' function. */
80 + #undef HAVE_SETRESUID
81 +
82 ++/* define if the SPARC pause instruction is available */
83 ++#undef HAVE_SPARC_PAUSE
84 ++
85 + /* define if struct stat has st_mtim.tv_nsec field */
86 + #undef HAVE_STAT_NSEC
87 +
88 +diff --git a/configure b/configure
89 +index d336f6aa24..757dacb06e 100755
90 +--- a/configure
91 ++++ b/configure
92 +@@ -13872,6 +13872,39 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; #(
93 + ;;
94 + esac
95 +
96 ++#
97 ++# Check for pause support on SPARC processors
98 ++#
99 ++case $host in #(
100 ++ sparc*) :
101 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pause instruction support" >&5
102 ++$as_echo_n "checking for pause instruction support... " >&6; }
103 ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
104 ++/* end confdefs.h. */
105 ++
106 ++int
107 ++main ()
108 ++{
109 ++__asm__ __volatile__ ("pause")
110 ++ ;
111 ++ return 0;
112 ++}
113 ++_ACEOF
114 ++if ac_fn_c_try_compile "$LINENO"; then :
115 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
116 ++$as_echo "yes" >&6; }
117 ++
118 ++$as_echo "#define HAVE_SPARC_PAUSE 1" >>confdefs.h
119 ++
120 ++else
121 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
122 ++$as_echo "no" >&6; }
123 ++fi
124 ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; #(
125 ++ *) :
126 ++ ;;
127 ++esac
128 ++
129 + for ac_func in sysctlbyname
130 + do :
131 + ac_fn_c_check_func "$LINENO" "sysctlbyname" "ac_cv_func_sysctlbyname"
132 +diff --git a/configure.ac b/configure.ac
133 +index 90aafae8d0..b04c651966 100644
134 +--- a/configure.ac
135 ++++ b/configure.ac
136 +@@ -415,6 +415,20 @@ AS_CASE([$host],
137 + [define if the ARM yield instruction is available])],
138 + [AC_MSG_RESULT([no])])])
139 +
140 ++#
141 ++# Check for pause support on SPARC processors
142 ++#
143 ++AS_CASE([$host],
144 ++ [sparc*],
145 ++ [AC_MSG_CHECKING([for pause instruction support])
146 ++ AC_COMPILE_IFELSE(
147 ++ [AC_LANG_PROGRAM([[]],
148 ++ [[__asm__ __volatile__ ("pause")]])],
149 ++ [AC_MSG_RESULT([yes])
150 ++ AC_DEFINE([HAVE_SPARC_PAUSE], [1],
151 ++ [define if the SPARC pause instruction is available])],
152 ++ [AC_MSG_RESULT([no])])])
153 ++
154 + AC_CHECK_FUNCS([sysctlbyname])
155 +
156 + #
157 +diff --git a/lib/isc/rwlock.c b/lib/isc/rwlock.c
158 +index a6ea35feed..e313a912e0 100644
159 +--- a/lib/isc/rwlock.c
160 ++++ b/lib/isc/rwlock.c
161 +@@ -152,7 +152,7 @@ isc_rwlock_destroy(isc_rwlock_t *rwl) {
162 + # define isc_rwlock_pause() __asm__ __volatile__ ("yield")
163 + #elif defined(sun) && (defined(__sparc) || defined(__sparc__))
164 + # define isc_rwlock_pause() smt_pause()
165 +-#elif defined(__sparc) || defined(__sparc__)
166 ++#elif (defined(__sparc) || defined(__sparc__)) && HAVE_SPARC_PAUSE
167 + # define isc_rwlock_pause() __asm__ __volatile__ ("pause")
168 + #elif defined(__ppc__) || defined(_ARCH_PPC) || \
169 + defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
170 +--
171 +2.21.0
172 +