S390: Use compile-only instead of also link-tests in configure.
[glibc.git] / sysdeps / s390 / configure.ac
blob89c3e5b2115d12d8d5d104ae9a121be40c47d242
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
6 #include <htmintrin.h>
7 void testtransaction ()
9   if (__builtin_tbegin (0) == _HTM_TBEGIN_STARTED)
10     {
11       __builtin_tend ();
12     }
14 EOF
15 dnl
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]) ;
18 then
19   libc_cv_gcc_builtin_tbegin=yes
20 else
21   libc_cv_gcc_builtin_tbegin=no
23 rm -f conftest* ])
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, [
31 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
32 void testvecinsn ()
34     __asm__ (".machine \"z13\" \n\t"
35              ".machinemode \"zarch_nohighgprs\" \n\t"
36              "vistrbs %%v16,%%v17 \n\t"
37              "locghie %%r1,0" : :);
39 ]])],
40                   [libc_cv_asm_s390_vx=yes],
41                   [libc_cv_asm_s390_vx=no])])
42 if test "$libc_cv_asm_s390_vx" = yes ;
43 then
44   AC_DEFINE(HAVE_S390_VX_ASM_SUPPORT)
45 else
46   AC_MSG_WARN([Use binutils with vector-support in order to use optimized implementations.])
50 dnl test, if gcc supports S390 vector registers as clobber in inline assembly
51 AC_CACHE_CHECK([for S390 vector support in gcc], libc_cv_gcc_s390_vx, [
52 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
53 void testvecclobber ()
55   __asm__ ("" : : : "v16");
57 ]])],
58                   [libc_cv_gcc_s390_vx=yes],
59                   [libc_cv_gcc_s390_vx=no])])
60 if test "$libc_cv_gcc_s390_vx" = yes ;
61 then
62   AC_DEFINE(HAVE_S390_VX_GCC_SUPPORT)
66 AC_CACHE_CHECK([for S390 arch13 zarch instruction support],
67                libc_cv_asm_s390_arch13, [
68 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
69 void testinsn (char *buf)
71     __asm__ (".machine \"arch13\" \n\t"
72              ".machinemode \"zarch_nohighgprs\" \n\t"
73              "lghi %%r0,16 \n\t"
74              "mvcrl 0(%0),32(%0) \n\t"
75              "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
76              : : "a" (buf) : "memory", "r0");
78 ]])],
79                   [libc_cv_asm_s390_arch13=yes],
80                   [libc_cv_asm_s390_arch13=no])])
81 if test "$libc_cv_asm_s390_arch13" = yes ;
82 then
83   AC_DEFINE(HAVE_S390_ARCH13_ASM_SUPPORT)
87 AC_CACHE_CHECK([for S390 z10 zarch instruction support as default],
88                libc_cv_asm_s390_min_z10_zarch, [
89 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
90 void testinsn (void *a, void *b, int n)
92     __asm__ ("exrl %2,1f \n\t"
93              "j 2f \n\t"
94              "1: mvc 0(1,%0),0(%1) \n\t"
95              "2:"
96              : : "a" (a), "a" (b), "d" (n)
97              : "memory", "cc");
99 ]])],
100                   [libc_cv_asm_s390_min_z10_zarch=yes],
101                   [libc_cv_asm_s390_min_z10_zarch=no])])
102 if test "$libc_cv_asm_s390_min_z10_zarch" = yes ;
103 then
104   AC_DEFINE(HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT)
108 AC_CACHE_CHECK([for S390 z196 zarch instruction support as default],
109                libc_cv_asm_s390_min_z196_zarch, [
110 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
111 float testinsn (double e)
113     float d;
114     __asm__ ("ledbra %0,5,%1,4" : "=f" (d) : "f" (e) );
115     return d;
117 ]])],
118                   [libc_cv_asm_s390_min_z196_zarch=yes],
119                   [libc_cv_asm_s390_min_z196_zarch=no])])
120 if test "$libc_cv_asm_s390_min_z196_zarch" = yes ;
121 then
122   AC_DEFINE(HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT)
126 AC_CACHE_CHECK([for S390 z13 zarch instruction support as default],
127                libc_cv_asm_s390_min_z13_zarch, [
128 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
129 int testinsn (void)
131     int i;
132     __asm__ ("vl %%v16,0(%%r15)\n\t"
133              "vlgvf %0,%%v16,0"
134              : "=d" (i) : : "memory", "v16");
135     return i;
137 ]])],
138                   [libc_cv_asm_s390_min_z13_zarch=yes],
139                   [libc_cv_asm_s390_min_z13_zarch=no])])
140 if test "$libc_cv_asm_s390_min_z13_zarch" = yes ;
141 then
142   AC_DEFINE(HAVE_S390_MIN_Z13_ZARCH_ASM_SUPPORT)
146 AC_CACHE_CHECK([for S390 arch13 zarch instruction support as default],
147                libc_cv_asm_s390_min_arch13_zarch, [
148 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
149 void testinsn (char *buf)
151     __asm__ ("lghi %%r0,16 \n\t"
152              "mvcrl 0(%0),32(%0) \n\t"
153              "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
154              : : "a" (buf) : "memory", "r0");
156 ]])],
157                   [libc_cv_asm_s390_min_arch13_zarch=yes],
158                   [libc_cv_asm_s390_min_arch13_zarch=no])])
159 if test "$libc_cv_asm_s390_min_arch13_zarch" = yes ;
160 then
161   AC_DEFINE(HAVE_S390_MIN_ARCH13_ZARCH_ASM_SUPPORT)
165 dnl test if GCC is new enough. See gcc "Bug 98269 - gcc 6.5.0
166 dnl __builtin_add_overflow() with small uint32_t values incorrectly detects
167 dnl overflow
168 dnl (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269)
169 AC_CACHE_CHECK([if $CC is sufficient to build libc on s390x],
170 libc_cv_compiler_ok_on_s390x, [
171 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[]], [[
172 #if !defined __GNUC__ || __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 1)
173 #error insufficient compiler for building on s390x
174 #endif
175 ]])],
176         [libc_cv_compiler_ok_on_s390x=yes],
177         [libc_cv_compiler_ok_on_s390x=no])])
178 if test "$libc_cv_compiler_ok_on_s390x" != yes; then
179    critic_missing="$critic_missing On s390x, GCC >= 7.1.0 is required."
182 test -n "$critic_missing" && AC_MSG_ERROR([
183 *** $critic_missing])