1GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2# Local configure fragment for sysdeps/s390.
3
4dnl It is always possible to access static and hidden symbols in an
5dnl position independent way.
6AC_DEFINE(PI_STATIC_AND_HIDDEN)
7
8AC_CACHE_CHECK(for __builtin_tbegin, libc_cv_gcc_builtin_tbegin, [dnl
9cat > conftest.c <<\EOF
10#include <htmintrin.h>
11void testtransaction ()
12{
13  if (__builtin_tbegin (0) == _HTM_TBEGIN_STARTED)
14    {
15      __builtin_tend ();
16    }
17}
18EOF
19dnl
20dnl test, if the tbegin instruction is used by __builtin_tbegin
21if AC_TRY_COMMAND([${CC-cc} -mhtm -O2 -S conftest.c -o - | grep -w tbegin > /dev/null]) ;
22then
23  libc_cv_gcc_builtin_tbegin=yes
24else
25  libc_cv_gcc_builtin_tbegin=no
26fi
27rm -f conftest* ])
28
29if test "$libc_cv_gcc_builtin_tbegin" = no ; then
30   critic_missing="$critic_missing The used GCC has no support for __builtin_tbegin, which is needed for lock-elision on target S390."
31fi
32
33
34AC_CACHE_CHECK(for S390 vector instruction support, libc_cv_asm_s390_vx, [dnl
35cat > conftest.c <<\EOF
36void testvecinsn ()
37{
38    __asm__ (".machine \"z13\" \n\t"
39	     ".machinemode \"zarch_nohighgprs\" \n\t"
40	     "vistrbs %%v16,%%v17 \n\t"
41	     "locghie %%r1,0" : :);
42}
43EOF
44dnl
45dnl test, if assembler supports S390 vector instructions
46if AC_TRY_COMMAND([${CC-cc} --shared conftest.c -o conftest.o &> /dev/null]) ;
47then
48  libc_cv_asm_s390_vx=yes
49else
50  libc_cv_asm_s390_vx=no
51fi
52rm -f conftest* ])
53
54if test "$libc_cv_asm_s390_vx" = yes ;
55then
56  AC_DEFINE(HAVE_S390_VX_ASM_SUPPORT)
57else
58  AC_MSG_WARN([Use binutils with vector-support in order to use optimized implementations.])
59fi
60
61AC_CACHE_CHECK(for S390 vector support in gcc, libc_cv_gcc_s390_vx, [dnl
62cat > conftest.c <<\EOF
63void testvecclobber ()
64{
65  __asm__ ("" : : : "v16");
66}
67EOF
68dnl
69dnl test, if gcc supports S390 vector registers as clobber in inline assembly
70if AC_TRY_COMMAND([${CC-cc} --shared conftest.c -o conftest.o &> /dev/null]) ;
71then
72  libc_cv_gcc_s390_vx=yes
73else
74  libc_cv_gcc_s390_vx=no
75fi
76rm -f conftest* ])
77
78if test "$libc_cv_gcc_s390_vx" = yes ;
79then
80  AC_DEFINE(HAVE_S390_VX_GCC_SUPPORT)
81fi
82
83AC_CACHE_CHECK(for S390 arch13 zarch instruction support,
84	       libc_cv_asm_s390_arch13, [dnl
85cat > conftest.c <<\EOF
86void testinsn (char *buf)
87{
88    __asm__ (".machine \"arch13\" \n\t"
89	     ".machinemode \"zarch_nohighgprs\" \n\t"
90	     "lghi %%r0,16 \n\t"
91	     "mvcrl 0(%0),32(%0) \n\t"
92	     "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
93	     : : "a" (buf) : "memory", "r0");
94}
95EOF
96dnl test, if assembler supports S390 arch13 instructions
97if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
98			-o conftest.o &> /dev/null]) ;
99then
100  libc_cv_asm_s390_arch13=yes
101else
102  libc_cv_asm_s390_arch13=no
103fi
104rm -f conftest* ])
105if test "$libc_cv_asm_s390_arch13" = yes ;
106then
107  AC_DEFINE(HAVE_S390_ARCH13_ASM_SUPPORT)
108fi
109
110
111AC_CACHE_CHECK(for S390 z10 zarch instruction support as default,
112	       libc_cv_asm_s390_min_z10_zarch, [dnl
113cat > conftest.c <<\EOF
114void testinsn (void *a, void *b, int n)
115{
116    __asm__ ("exrl %2,1f \n\t"
117	     "j 2f \n\t"
118	     "1: mvc 0(1,%0),0(%1) \n\t"
119	     "2:"
120	     : : "a" (a), "a" (b), "d" (n)
121	     : "memory", "cc");
122}
123EOF
124dnl
125dnl test, if assembler supports S390 z10 zarch instructions as default
126if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
127			-o conftest.o &> /dev/null]) ;
128then
129  libc_cv_asm_s390_min_z10_zarch=yes
130else
131  libc_cv_asm_s390_min_z10_zarch=no
132fi
133rm -f conftest* ])
134
135if test "$libc_cv_asm_s390_min_z10_zarch" = yes ;
136then
137  AC_DEFINE(HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT)
138fi
139
140AC_CACHE_CHECK(for S390 z196 zarch instruction support as default,
141	       libc_cv_asm_s390_min_z196_zarch, [dnl
142cat > conftest.c <<\EOF
143float testinsn (double e)
144{
145    float d;
146    __asm__ ("ledbra %0,5,%1,4" : "=f" (d) : "f" (e) );
147    return d;
148}
149EOF
150dnl
151dnl test, if assembler supports S390 z196 zarch instructions as default
152if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
153			-o conftest.o &> /dev/null]) ;
154then
155  libc_cv_asm_s390_min_z196_zarch=yes
156else
157  libc_cv_asm_s390_min_z196_zarch=no
158fi
159rm -f conftest* ])
160
161if test "$libc_cv_asm_s390_min_z196_zarch" = yes ;
162then
163  AC_DEFINE(HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT)
164fi
165
166AC_CACHE_CHECK(for S390 z13 zarch instruction support as default,
167	       libc_cv_asm_s390_min_z13_zarch, [dnl
168cat > conftest.c <<\EOF
169int testinsn (void)
170{
171    int i;
172    __asm__ ("vl %%v16,0(%%r15)\n\t"
173	     "vlgvf %0,%%v16,0"
174	     : "=d" (i) : : "memory", "v16");
175    return i;
176}
177EOF
178dnl
179dnl test, if assembler supports S390 z13 zarch instructions as default
180if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
181			-o conftest.o &> /dev/null]) ;
182then
183  libc_cv_asm_s390_min_z13_zarch=yes
184else
185  libc_cv_asm_s390_min_z13_zarch=no
186fi
187rm -f conftest* ])
188
189if test "$libc_cv_asm_s390_min_z13_zarch" = yes ;
190then
191  AC_DEFINE(HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT)
192fi
193
194AC_CACHE_CHECK(for S390 arch13 zarch instruction support as default,
195	       libc_cv_asm_s390_min_arch13_zarch, [dnl
196cat > conftest.c <<\EOF
197void testinsn (char *buf)
198{
199    __asm__ ("lghi %%r0,16 \n\t"
200	     "mvcrl 0(%0),32(%0) \n\t"
201	     "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
202	     : : "a" (buf) : "memory", "r0");
203}
204EOF
205dnl test, if assembler supports S390 arch13 zarch instructions as default
206if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
207			-o conftest.o &> /dev/null]) ;
208then
209  libc_cv_asm_s390_min_arch13_zarch=yes
210else
211  libc_cv_asm_s390_min_arch13_zarch=no
212fi
213rm -f conftest* ])
214if test "$libc_cv_asm_s390_min_arch13_zarch" = yes ;
215then
216  AC_DEFINE(HAVE_S390_MIN_ARCH13_ZARCH_ASM_SUPPORT)
217fi
218
219dnl test if GCC is new enough. See gcc "Bug 98269 - gcc 6.5.0
220dnl __builtin_add_overflow() with small uint32_t values incorrectly detects
221dnl overflow
222dnl (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269)
223AC_CACHE_CHECK([if $CC is sufficient to build libc on s390x],
224libc_cv_compiler_ok_on_s390x, [
225AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
226#if !defined __GNUC__ || __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 1)
227#error insufficient compiler for building on s390x
228#endif
229]])],
230	[libc_cv_compiler_ok_on_s390x=yes],
231	[libc_cv_compiler_ok_on_s390x=no])])
232if test "$libc_cv_compiler_ok_on_s390x" != yes; then
233   critic_missing="$critic_missing On s390x, GCC >= 7.1.0 is required."
234fi
235
236test -n "$critic_missing" && AC_MSG_ERROR([
237*** $critic_missing])
238