1 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2 # Local configure fragment for sysdeps/s390.
4 AC_CACHE_CHECK(for __builtin_tbegin, libc_cv_gcc_builtin_tbegin, [dnl
5 cat > conftest.c <<\EOF
7 void testtransaction ()
9 if (__builtin_tbegin (0) == _HTM_TBEGIN_STARTED)
16 dnl test, if the tbegin instruction is used by __builtin_tbegin
17 if AC_TRY_COMMAND([${CC-cc} -mhtm -O2 -S conftest.c -o - | grep -w tbegin > /dev/null]) ;
19 libc_cv_gcc_builtin_tbegin=yes
21 libc_cv_gcc_builtin_tbegin=no
25 if test "$libc_cv_gcc_builtin_tbegin" = no ; then
26 critic_missing="$critic_missing The used GCC has no support for __builtin_tbegin, which is needed for lock-elision on target S390."
30 AC_CACHE_CHECK(for S390 vector instruction support, libc_cv_asm_s390_vx, [dnl
31 cat > conftest.c <<\EOF
34 __asm__ (".machine \"z13\" \n\t"
35 ".machinemode \"zarch_nohighgprs\" \n\t"
36 "vistrbs %%v16,%%v17 \n\t"
37 "locghie %%r1,0" : :);
41 dnl test, if assembler supports S390 vector instructions
42 if AC_TRY_COMMAND([${CC-cc} --shared conftest.c -o conftest.o &> /dev/null]) ;
44 libc_cv_asm_s390_vx=yes
46 libc_cv_asm_s390_vx=no
50 if test "$libc_cv_asm_s390_vx" = yes ;
52 AC_DEFINE(HAVE_S390_VX_ASM_SUPPORT)
54 AC_MSG_WARN([Use binutils with vector-support in order to use optimized implementations.])
57 AC_CACHE_CHECK(for S390 vector support in gcc, libc_cv_gcc_s390_vx, [dnl
58 cat > conftest.c <<\EOF
59 void testvecclobber ()
61 __asm__ ("" : : : "v16");
65 dnl test, if gcc supports S390 vector registers as clobber in inline assembly
66 if AC_TRY_COMMAND([${CC-cc} --shared conftest.c -o conftest.o &> /dev/null]) ;
68 libc_cv_gcc_s390_vx=yes
70 libc_cv_gcc_s390_vx=no
74 if test "$libc_cv_gcc_s390_vx" = yes ;
76 AC_DEFINE(HAVE_S390_VX_GCC_SUPPORT)
79 AC_CACHE_CHECK(for S390 arch13 zarch instruction support,
80 libc_cv_asm_s390_arch13, [dnl
81 cat > conftest.c <<\EOF
82 void testinsn (char *buf)
84 __asm__ (".machine \"arch13\" \n\t"
85 ".machinemode \"zarch_nohighgprs\" \n\t"
87 "mvcrl 0(%0),32(%0) \n\t"
88 "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
89 : : "a" (buf) : "memory", "r0");
92 dnl test, if assembler supports S390 arch13 instructions
93 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
94 -o conftest.o &> /dev/null]) ;
96 libc_cv_asm_s390_arch13=yes
98 libc_cv_asm_s390_arch13=no
101 if test "$libc_cv_asm_s390_arch13" = yes ;
103 AC_DEFINE(HAVE_S390_ARCH13_ASM_SUPPORT)
107 AC_CACHE_CHECK(for S390 z10 zarch instruction support as default,
108 libc_cv_asm_s390_min_z10_zarch, [dnl
109 cat > conftest.c <<\EOF
110 void testinsn (void *a, void *b, int n)
112 __asm__ ("exrl %2,1f \n\t"
114 "1: mvc 0(1,%0),0(%1) \n\t"
116 : : "a" (a), "a" (b), "d" (n)
121 dnl test, if assembler supports S390 z10 zarch instructions as default
122 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
123 -o conftest.o &> /dev/null]) ;
125 libc_cv_asm_s390_min_z10_zarch=yes
127 libc_cv_asm_s390_min_z10_zarch=no
131 if test "$libc_cv_asm_s390_min_z10_zarch" = yes ;
133 AC_DEFINE(HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT)
136 AC_CACHE_CHECK(for S390 z196 zarch instruction support as default,
137 libc_cv_asm_s390_min_z196_zarch, [dnl
138 cat > conftest.c <<\EOF
139 float testinsn (double e)
142 __asm__ ("ledbra %0,5,%1,4" : "=f" (d) : "f" (e) );
147 dnl test, if assembler supports S390 z196 zarch instructions as default
148 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
149 -o conftest.o &> /dev/null]) ;
151 libc_cv_asm_s390_min_z196_zarch=yes
153 libc_cv_asm_s390_min_z196_zarch=no
157 if test "$libc_cv_asm_s390_min_z196_zarch" = yes ;
159 AC_DEFINE(HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT)
162 AC_CACHE_CHECK(for S390 z13 zarch instruction support as default,
163 libc_cv_asm_s390_min_z13_zarch, [dnl
164 cat > conftest.c <<\EOF
168 __asm__ ("vl %%v16,0(%%r15)\n\t"
170 : "=d" (i) : : "memory", "v16");
175 dnl test, if assembler supports S390 z13 zarch instructions as default
176 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
177 -o conftest.o &> /dev/null]) ;
179 libc_cv_asm_s390_min_z13_zarch=yes
181 libc_cv_asm_s390_min_z13_zarch=no
185 if test "$libc_cv_asm_s390_min_z13_zarch" = yes ;
187 AC_DEFINE(HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT)
190 AC_CACHE_CHECK(for S390 arch13 zarch instruction support as default,
191 libc_cv_asm_s390_min_arch13_zarch, [dnl
192 cat > conftest.c <<\EOF
193 void testinsn (char *buf)
195 __asm__ ("lghi %%r0,16 \n\t"
196 "mvcrl 0(%0),32(%0) \n\t"
197 "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
198 : : "a" (buf) : "memory", "r0");
201 dnl test, if assembler supports S390 arch13 zarch instructions as default
202 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
203 -o conftest.o &> /dev/null]) ;
205 libc_cv_asm_s390_min_arch13_zarch=yes
207 libc_cv_asm_s390_min_arch13_zarch=no
210 if test "$libc_cv_asm_s390_min_arch13_zarch" = yes ;
212 AC_DEFINE(HAVE_S390_MIN_ARCH13_ZARCH_ASM_SUPPORT)
215 dnl test if GCC is new enough. See gcc "Bug 98269 - gcc 6.5.0
216 dnl __builtin_add_overflow() with small uint32_t values incorrectly detects
218 dnl (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269)
219 AC_CACHE_CHECK([if $CC is sufficient to build libc on s390x],
220 libc_cv_compiler_ok_on_s390x, [
221 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
222 #if !defined __GNUC__ || __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 1)
223 #error insufficient compiler for building on s390x
226 [libc_cv_compiler_ok_on_s390x=yes],
227 [libc_cv_compiler_ok_on_s390x=no])])
228 if test "$libc_cv_compiler_ok_on_s390x" != yes; then
229 critic_missing="$critic_missing On s390x, GCC >= 7.1.0 is required."
232 test -n "$critic_missing" && AC_MSG_ERROR([
233 *** $critic_missing])