annotate libgfortran/acinclude.m4 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 m4_include(../config/acx.m4)
kono
parents:
diff changeset
2 m4_include(../config/no-executables.m4)
kono
parents:
diff changeset
3 m4_include(../config/math.m4)
kono
parents:
diff changeset
4 m4_include(../config/ax_check_define.m4)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
5 m4_include(../config/enable.m4)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
6 m4_include(../config/cet.m4)
111
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 dnl Check that we have a working GNU Fortran compiler
kono
parents:
diff changeset
9 AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [
kono
parents:
diff changeset
10 AC_MSG_CHECKING([whether the GNU Fortran compiler is working])
kono
parents:
diff changeset
11 AC_LANG_PUSH([Fortran])
kono
parents:
diff changeset
12 AC_COMPILE_IFELSE([[
kono
parents:
diff changeset
13 program foo
kono
parents:
diff changeset
14 real, parameter :: bar = sin (12.34 / 2.5)
kono
parents:
diff changeset
15 end program foo]],
kono
parents:
diff changeset
16 [AC_MSG_RESULT([yes])],
kono
parents:
diff changeset
17 [AC_MSG_RESULT([no])
kono
parents:
diff changeset
18 AC_MSG_ERROR([GNU Fortran is not working; please report a bug in http://gcc.gnu.org/bugzilla, attaching $PWD/config.log])
kono
parents:
diff changeset
19 ])
kono
parents:
diff changeset
20 AC_LANG_POP([Fortran])
kono
parents:
diff changeset
21 ])
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 sinclude(../libtool.m4)
kono
parents:
diff changeset
25 dnl The lines below arrange for aclocal not to bring an installed
kono
parents:
diff changeset
26 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
kono
parents:
diff changeset
27 dnl add a definition of LIBTOOL to Makefile.in.
kono
parents:
diff changeset
28 ifelse(,,,[AC_SUBST(LIBTOOL)
kono
parents:
diff changeset
29 AC_DEFUN([AM_PROG_LIBTOOL])
kono
parents:
diff changeset
30 AC_DEFUN([AC_LIBTOOL_DLOPEN])
kono
parents:
diff changeset
31 AC_DEFUN([AC_PROG_LD])
kono
parents:
diff changeset
32 ])
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 dnl Check whether the target supports hidden visibility.
kono
parents:
diff changeset
35 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
kono
parents:
diff changeset
36 AC_CACHE_CHECK([whether the target supports hidden visibility],
kono
parents:
diff changeset
37 libgfor_cv_have_attribute_visibility, [
kono
parents:
diff changeset
38 save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
39 CFLAGS="$CFLAGS -Werror"
kono
parents:
diff changeset
40 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void __attribute__((visibility("hidden"))) foo(void) { }]], [])],
kono
parents:
diff changeset
41 libgfor_cv_have_attribute_visibility=yes,
kono
parents:
diff changeset
42 libgfor_cv_have_attribute_visibility=no)
kono
parents:
diff changeset
43 CFLAGS="$save_CFLAGS"])
kono
parents:
diff changeset
44 if test $libgfor_cv_have_attribute_visibility = yes; then
kono
parents:
diff changeset
45 AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
kono
parents:
diff changeset
46 [Define to 1 if the target supports __attribute__((visibility(...))).])
kono
parents:
diff changeset
47 fi])
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 dnl Check whether the target supports symbol aliases.
kono
parents:
diff changeset
50 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [
kono
parents:
diff changeset
51 AC_CACHE_CHECK([whether the target supports symbol aliases],
kono
parents:
diff changeset
52 libgfor_cv_have_attribute_alias, [
kono
parents:
diff changeset
53 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
54 void foo(void) { }
kono
parents:
diff changeset
55 extern void bar(void) __attribute__((alias("foo")));]],
kono
parents:
diff changeset
56 [[bar();]])], libgfor_cv_have_attribute_alias=yes, libgfor_cv_have_attribute_alias=no)])
kono
parents:
diff changeset
57 if test $libgfor_cv_have_attribute_alias = yes; then
kono
parents:
diff changeset
58 AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
kono
parents:
diff changeset
59 [Define to 1 if the target supports __attribute__((alias(...))).])
kono
parents:
diff changeset
60 fi])
kono
parents:
diff changeset
61
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
62 dnl Check whether the target supports __atomic_fetch_add.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
63 AC_DEFUN([LIBGFOR_CHECK_ATOMIC_FETCH_ADD], [
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
64 AC_CACHE_CHECK([whether the target supports __atomic_fetch_add],
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
65 libgfor_cv_have_atomic_fetch_add, [
111
kono
parents:
diff changeset
66 AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foovar = 0;]], [[
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
67 if (foovar <= 0) return __atomic_fetch_add (&foovar, 1, __ATOMIC_ACQ_REL);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
68 if (foovar > 10) return __atomic_add_fetch (&foovar, -1, __ATOMIC_ACQ_REL);]])],
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
69 libgfor_cv_have_atomic_fetch_add=yes, libgfor_cv_have_atomic_fetch_add=no)])
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
70 if test $libgfor_cv_have_atomic_fetch_add = yes; then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
71 AC_DEFINE(HAVE_ATOMIC_FETCH_ADD, 1,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
72 [Define to 1 if the target supports __atomic_fetch_add])
111
kono
parents:
diff changeset
73 fi])
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 dnl Check for pragma weak.
kono
parents:
diff changeset
76 AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [
kono
parents:
diff changeset
77 AC_CACHE_CHECK([whether pragma weak works],
kono
parents:
diff changeset
78 libgfor_cv_have_pragma_weak, [
kono
parents:
diff changeset
79 gfor_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
80 CFLAGS="$CFLAGS -Wunknown-pragmas"
kono
parents:
diff changeset
81 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
82 void foo (void);
kono
parents:
diff changeset
83 #pragma weak foo
kono
parents:
diff changeset
84 ]], [[if (foo) foo ();]])],
kono
parents:
diff changeset
85 libgfor_cv_have_pragma_weak=yes, libgfor_cv_have_pragma_weak=no)])
kono
parents:
diff changeset
86 if test $libgfor_cv_have_pragma_weak = yes; then
kono
parents:
diff changeset
87 AC_DEFINE(SUPPORTS_WEAK, 1,
kono
parents:
diff changeset
88 [Define to 1 if the target supports #pragma weak])
kono
parents:
diff changeset
89 fi
kono
parents:
diff changeset
90 case "$host" in
kono
parents:
diff changeset
91 *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
kono
parents:
diff changeset
92 AC_DEFINE(GTHREAD_USE_WEAK, 0,
kono
parents:
diff changeset
93 [Define to 0 if the target shouldn't use #pragma weak])
kono
parents:
diff changeset
94 ;;
kono
parents:
diff changeset
95 esac])
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 dnl Check whether target effectively supports weakref
kono
parents:
diff changeset
98 AC_DEFUN([LIBGFOR_CHECK_WEAKREF], [
kono
parents:
diff changeset
99 AC_CACHE_CHECK([whether the target supports weakref],
kono
parents:
diff changeset
100 libgfor_cv_have_weakref, [
kono
parents:
diff changeset
101 save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
102 CFLAGS="$CFLAGS -Wunknown-pragmas -Werror"
kono
parents:
diff changeset
103 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
104 static int mytoto (int) __attribute__((__weakref__("toto")));
kono
parents:
diff changeset
105 ]], [[return (mytoto != 0);]])],
kono
parents:
diff changeset
106 libgfor_cv_have_weakref=yes, libgfor_cv_have_weakref=no)
kono
parents:
diff changeset
107 CFLAGS="$save_CFLAGS"])
kono
parents:
diff changeset
108 if test $libgfor_cv_have_weakref = yes; then
kono
parents:
diff changeset
109 AC_DEFINE(SUPPORTS_WEAKREF, 1,
kono
parents:
diff changeset
110 [Define to 1 if the target supports weakref])
kono
parents:
diff changeset
111 fi])
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 dnl Check whether target can unlink a file still open.
kono
parents:
diff changeset
114 AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
kono
parents:
diff changeset
115 AC_CACHE_CHECK([whether the target can unlink an open file],
kono
parents:
diff changeset
116 libgfor_cv_have_unlink_open_file, [
kono
parents:
diff changeset
117 AC_RUN_IFELSE([AC_LANG_SOURCE([[
kono
parents:
diff changeset
118 #include <errno.h>
kono
parents:
diff changeset
119 #include <fcntl.h>
kono
parents:
diff changeset
120 #include <unistd.h>
kono
parents:
diff changeset
121 #include <sys/stat.h>
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 int main ()
kono
parents:
diff changeset
124 {
kono
parents:
diff changeset
125 int fd;
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 fd = open ("testfile", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR);
kono
parents:
diff changeset
128 if (fd <= 0)
kono
parents:
diff changeset
129 return 0;
kono
parents:
diff changeset
130 if (unlink ("testfile") == -1)
kono
parents:
diff changeset
131 return 1;
kono
parents:
diff changeset
132 write (fd, "This is a test\n", 15);
kono
parents:
diff changeset
133 close (fd);
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 if (open ("testfile", O_RDONLY) == -1 && errno == ENOENT)
kono
parents:
diff changeset
136 return 0;
kono
parents:
diff changeset
137 else
kono
parents:
diff changeset
138 return 1;
kono
parents:
diff changeset
139 }]])], libgfor_cv_have_unlink_open_file=yes, libgfor_cv_have_unlink_open_file=no, [
kono
parents:
diff changeset
140 case "${target}" in
kono
parents:
diff changeset
141 *mingw*) libgfor_cv_have_unlink_open_file=no ;;
kono
parents:
diff changeset
142 *) libgfor_cv_have_unlink_open_file=yes;;
kono
parents:
diff changeset
143 esac])])
kono
parents:
diff changeset
144 if test x"$libgfor_cv_have_unlink_open_file" = xyes; then
kono
parents:
diff changeset
145 AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.])
kono
parents:
diff changeset
146 fi])
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 dnl Check whether CRLF is the line terminator
kono
parents:
diff changeset
149 AC_DEFUN([LIBGFOR_CHECK_CRLF], [
kono
parents:
diff changeset
150 AC_CACHE_CHECK([whether the target has CRLF as line terminator],
kono
parents:
diff changeset
151 libgfor_cv_have_crlf, [
kono
parents:
diff changeset
152 AC_RUN_IFELSE([AC_LANG_SOURCE([[
kono
parents:
diff changeset
153 /* This test program should exit with status 0 if system uses a CRLF as
kono
parents:
diff changeset
154 line terminator, and status 1 otherwise.
kono
parents:
diff changeset
155 Since it is used to check for mingw systems, and should return 0 in any
kono
parents:
diff changeset
156 other case, in case of a failure we will not use CRLF. */
kono
parents:
diff changeset
157 #include <sys/stat.h>
kono
parents:
diff changeset
158 #include <stdlib.h>
kono
parents:
diff changeset
159 #include <fcntl.h>
kono
parents:
diff changeset
160 #include <stdio.h>
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 int main ()
kono
parents:
diff changeset
163 {
kono
parents:
diff changeset
164 #ifndef O_BINARY
kono
parents:
diff changeset
165 exit(1);
kono
parents:
diff changeset
166 #else
kono
parents:
diff changeset
167 int fd, bytes;
kono
parents:
diff changeset
168 char buff[5];
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
kono
parents:
diff changeset
171 if (fd < 0)
kono
parents:
diff changeset
172 exit(1);
kono
parents:
diff changeset
173 if (write (fd, "\n", 1) < 0)
kono
parents:
diff changeset
174 perror ("write");
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 close (fd);
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0)
kono
parents:
diff changeset
179 exit(1);
kono
parents:
diff changeset
180 bytes = read (fd, buff, 5);
kono
parents:
diff changeset
181 if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n')
kono
parents:
diff changeset
182 exit(0);
kono
parents:
diff changeset
183 else
kono
parents:
diff changeset
184 exit(1);
kono
parents:
diff changeset
185 #endif
kono
parents:
diff changeset
186 }]])], libgfor_cv_have_crlf=yes, libgfor_cv_have_crlf=no, [
kono
parents:
diff changeset
187 case "${target}" in
kono
parents:
diff changeset
188 *mingw*) libgfor_cv_have_crlf=yes ;;
kono
parents:
diff changeset
189 *) libgfor_cv_have_crlf=no;;
kono
parents:
diff changeset
190 esac])])
kono
parents:
diff changeset
191 if test x"$libgfor_cv_have_crlf" = xyes; then
kono
parents:
diff changeset
192 AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.])
kono
parents:
diff changeset
193 fi])
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 dnl Check whether the st_ino and st_dev stat fields taken together uniquely
kono
parents:
diff changeset
196 dnl identify the file within the system. This is should be true for POSIX
kono
parents:
diff changeset
197 dnl systems; it is known to be false on mingw32.
kono
parents:
diff changeset
198 AC_DEFUN([LIBGFOR_CHECK_WORKING_STAT], [
kono
parents:
diff changeset
199 AC_CACHE_CHECK([whether the target stat is reliable],
kono
parents:
diff changeset
200 libgfor_cv_have_working_stat, [
kono
parents:
diff changeset
201 AC_RUN_IFELSE([AC_LANG_SOURCE([[
kono
parents:
diff changeset
202 #include <stdio.h>
kono
parents:
diff changeset
203 #include <sys/types.h>
kono
parents:
diff changeset
204 #include <sys/stat.h>
kono
parents:
diff changeset
205 #include <unistd.h>
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 int main ()
kono
parents:
diff changeset
208 {
kono
parents:
diff changeset
209 FILE *f, *g;
kono
parents:
diff changeset
210 struct stat st1, st2;
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 f = fopen ("foo", "w");
kono
parents:
diff changeset
213 g = fopen ("bar", "w");
kono
parents:
diff changeset
214 if (stat ("foo", &st1) != 0 || stat ("bar", &st2))
kono
parents:
diff changeset
215 return 1;
kono
parents:
diff changeset
216 if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
kono
parents:
diff changeset
217 return 1;
kono
parents:
diff changeset
218 fclose(f);
kono
parents:
diff changeset
219 fclose(g);
kono
parents:
diff changeset
220 return 0;
kono
parents:
diff changeset
221 }]])], libgfor_cv_have_working_stat=yes, libgfor_cv_have_working_stat=no, [
kono
parents:
diff changeset
222 case "${target}" in
kono
parents:
diff changeset
223 *mingw*) libgfor_cv_have_working_stat=no ;;
kono
parents:
diff changeset
224 *) libgfor_cv_have_working_stat=yes;;
kono
parents:
diff changeset
225 esac])])
kono
parents:
diff changeset
226 if test x"$libgfor_cv_have_working_stat" = xyes; then
kono
parents:
diff changeset
227 AC_DEFINE(HAVE_WORKING_STAT, 1, [Define if target has a reliable stat.])
kono
parents:
diff changeset
228 fi])
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 dnl Checks for fpsetmask function.
kono
parents:
diff changeset
231 AC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [
kono
parents:
diff changeset
232 AC_CACHE_CHECK([whether fpsetmask is present], libgfor_cv_have_fpsetmask, [
kono
parents:
diff changeset
233 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
234 #if HAVE_FLOATINGPOINT_H
kono
parents:
diff changeset
235 # include <floatingpoint.h>
kono
parents:
diff changeset
236 #endif /* HAVE_FLOATINGPOINT_H */
kono
parents:
diff changeset
237 #if HAVE_IEEEFP_H
kono
parents:
diff changeset
238 # include <ieeefp.h>
kono
parents:
diff changeset
239 #endif /* HAVE_IEEEFP_H */]],[[fpsetmask(0);]])],
kono
parents:
diff changeset
240 eval "libgfor_cv_have_fpsetmask=yes", eval "libgfor_cv_have_fpsetmask=no")
kono
parents:
diff changeset
241 ])
kono
parents:
diff changeset
242 if test x"$libgfor_cv_have_fpsetmask" = xyes; then
kono
parents:
diff changeset
243 have_fpsetmask=yes
kono
parents:
diff changeset
244 AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.])
kono
parents:
diff changeset
245 fi
kono
parents:
diff changeset
246 ])
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 dnl Check whether we have a mingw that provides a __mingw_snprintf function
kono
parents:
diff changeset
249 AC_DEFUN([LIBGFOR_CHECK_MINGW_SNPRINTF], [
kono
parents:
diff changeset
250 AC_CACHE_CHECK([whether __mingw_snprintf is present], libgfor_cv_have_mingw_snprintf, [
kono
parents:
diff changeset
251 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
252 #include <stdio.h>
kono
parents:
diff changeset
253 extern int __mingw_snprintf (char *, size_t, const char *, ...);
kono
parents:
diff changeset
254 ]],[[
kono
parents:
diff changeset
255 __mingw_snprintf (NULL, 0, "%d\n", 1);
kono
parents:
diff changeset
256 ]])],
kono
parents:
diff changeset
257 eval "libgfor_cv_have_mingw_snprintf=yes", eval "libgfor_cv_have_mingw_snprintf=no")
kono
parents:
diff changeset
258 ])
kono
parents:
diff changeset
259 if test x"$libgfor_cv_have_mingw_snprintf" = xyes; then
kono
parents:
diff changeset
260 AC_DEFINE(HAVE_MINGW_SNPRINTF, 1, [Define if you have __mingw_snprintf.])
kono
parents:
diff changeset
261 fi
kono
parents:
diff changeset
262 ])
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 dnl Check whether we have a __float128 type
kono
parents:
diff changeset
265 AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
kono
parents:
diff changeset
266 LIBQUADSPEC=
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 if test "x$enable_libquadmath_support" != xno; then
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 AC_CACHE_CHECK([whether we have a usable __float128 type],
kono
parents:
diff changeset
271 libgfor_cv_have_float128, [
kono
parents:
diff changeset
272 GCC_TRY_COMPILE_OR_LINK([
kono
parents:
diff changeset
273 typedef _Complex float __attribute__((mode(TC))) __complex128;
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 __float128 foo (__float128 x)
kono
parents:
diff changeset
276 {
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 __complex128 z1, z2;
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 z1 = x;
kono
parents:
diff changeset
281 z2 = x / 7.Q;
kono
parents:
diff changeset
282 z2 /= z1;
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 return (__float128) z2;
kono
parents:
diff changeset
285 }
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 __float128 bar (__float128 x)
kono
parents:
diff changeset
288 {
kono
parents:
diff changeset
289 return x * __builtin_huge_valq ();
kono
parents:
diff changeset
290 }
kono
parents:
diff changeset
291 ],[
kono
parents:
diff changeset
292 foo (1.2Q);
kono
parents:
diff changeset
293 bar (1.2Q);
kono
parents:
diff changeset
294 ],[
kono
parents:
diff changeset
295 libgfor_cv_have_float128=yes
kono
parents:
diff changeset
296 ],[
kono
parents:
diff changeset
297 libgfor_cv_have_float128=no
kono
parents:
diff changeset
298 ])])
kono
parents:
diff changeset
299
kono
parents:
diff changeset
300 if test "x$libgfor_cv_have_float128" = xyes; then
kono
parents:
diff changeset
301 AC_DEFINE(HAVE_FLOAT128, 1, [Define if have a usable __float128 type.])
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported
kono
parents:
diff changeset
304 dnl
kono
parents:
diff changeset
305 dnl Turn warnings into error to avoid testsuite breakage. So enable
kono
parents:
diff changeset
306 dnl AC_LANG_WERROR, but there's currently (autoconf 2.64) no way to turn
kono
parents:
diff changeset
307 dnl it off again. As a workaround, save and restore werror flag like
kono
parents:
diff changeset
308 dnl AC_PATH_XTRA.
kono
parents:
diff changeset
309 dnl Cf. http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01889.html
kono
parents:
diff changeset
310 ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
kono
parents:
diff changeset
311 AC_CACHE_CHECK([whether --as-needed/-z ignore works],
kono
parents:
diff changeset
312 [libgfor_cv_have_as_needed],
kono
parents:
diff changeset
313 [
kono
parents:
diff changeset
314 # Test for native Solaris options first.
kono
parents:
diff changeset
315 # No whitespace after -z to pass it through -Wl.
kono
parents:
diff changeset
316 libgfor_cv_as_needed_option="-zignore"
kono
parents:
diff changeset
317 libgfor_cv_no_as_needed_option="-zrecord"
kono
parents:
diff changeset
318 save_LDFLAGS="$LDFLAGS"
kono
parents:
diff changeset
319 LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option"
kono
parents:
diff changeset
320 libgfor_cv_have_as_needed=no
kono
parents:
diff changeset
321 AC_LANG_WERROR
kono
parents:
diff changeset
322 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
kono
parents:
diff changeset
323 [libgfor_cv_have_as_needed=yes],
kono
parents:
diff changeset
324 [libgfor_cv_have_as_needed=no])
kono
parents:
diff changeset
325 LDFLAGS="$save_LDFLAGS"
kono
parents:
diff changeset
326 if test "x$libgfor_cv_have_as_needed" = xno; then
kono
parents:
diff changeset
327 libgfor_cv_as_needed_option="--as-needed"
kono
parents:
diff changeset
328 libgfor_cv_no_as_needed_option="--no-as-needed"
kono
parents:
diff changeset
329 save_LDFLAGS="$LDFLAGS"
kono
parents:
diff changeset
330 LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option"
kono
parents:
diff changeset
331 libgfor_cv_have_as_needed=no
kono
parents:
diff changeset
332 AC_LANG_WERROR
kono
parents:
diff changeset
333 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
kono
parents:
diff changeset
334 [libgfor_cv_have_as_needed=yes],
kono
parents:
diff changeset
335 [libgfor_cv_have_as_needed=no])
kono
parents:
diff changeset
336 LDFLAGS="$save_LDFLAGS"
kono
parents:
diff changeset
337 fi
kono
parents:
diff changeset
338 ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag
kono
parents:
diff changeset
339 ])
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 dnl For static libgfortran linkage, depend on libquadmath only if needed.
kono
parents:
diff changeset
342 if test "x$libgfor_cv_have_as_needed" = xyes; then
kono
parents:
diff changeset
343 LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
kono
parents:
diff changeset
344 else
kono
parents:
diff changeset
345 LIBQUADSPEC="-lquadmath"
kono
parents:
diff changeset
346 fi
kono
parents:
diff changeset
347 if test -f ../libquadmath/libquadmath.la; then
kono
parents:
diff changeset
348 LIBQUADLIB=../libquadmath/libquadmath.la
kono
parents:
diff changeset
349 LIBQUADLIB_DEP=../libquadmath/libquadmath.la
kono
parents:
diff changeset
350 LIBQUADINCLUDE='-I$(srcdir)/../libquadmath'
kono
parents:
diff changeset
351 else
kono
parents:
diff changeset
352 LIBQUADLIB="-lquadmath"
kono
parents:
diff changeset
353 LIBQUADLIB_DEP=
kono
parents:
diff changeset
354 LIBQUADINCLUDE=
kono
parents:
diff changeset
355 fi
kono
parents:
diff changeset
356 fi
kono
parents:
diff changeset
357 else
kono
parents:
diff changeset
358 # for --disable-quadmath
kono
parents:
diff changeset
359 LIBQUADLIB=
kono
parents:
diff changeset
360 LIBQUADLIB_DEP=
kono
parents:
diff changeset
361 LIBQUADINCLUDE=
kono
parents:
diff changeset
362 fi
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 dnl For the spec file
kono
parents:
diff changeset
365 AC_SUBST(LIBQUADSPEC)
kono
parents:
diff changeset
366 AC_SUBST(LIBQUADLIB)
kono
parents:
diff changeset
367 AC_SUBST(LIBQUADLIB_DEP)
kono
parents:
diff changeset
368 AC_SUBST(LIBQUADINCLUDE)
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 dnl We need a conditional for the Makefile
kono
parents:
diff changeset
371 AM_CONDITIONAL(LIBGFOR_BUILD_QUAD, [test "x$libgfor_cv_have_float128" = xyes])
kono
parents:
diff changeset
372 ])
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 dnl Check whether we have strerror_r
kono
parents:
diff changeset
376 AC_DEFUN([LIBGFOR_CHECK_STRERROR_R], [
kono
parents:
diff changeset
377 dnl Check for three-argument POSIX version of strerror_r
kono
parents:
diff changeset
378 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
379 CFLAGS="-Wimplicit-function-declaration -Werror"
kono
parents:
diff changeset
380 AC_TRY_COMPILE([#define _GNU_SOURCE 1
kono
parents:
diff changeset
381 #include <string.h>
kono
parents:
diff changeset
382 #include <locale.h>],
kono
parents:
diff changeset
383 [char s[128]; strerror_r(5, s, 128);],
kono
parents:
diff changeset
384 AC_DEFINE(HAVE_STRERROR_R, 1,
kono
parents:
diff changeset
385 [Define if strerror_r is available in <string.h>.]),)
kono
parents:
diff changeset
386 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 dnl Check for two-argument version of strerror_r (e.g. for VxWorks)
kono
parents:
diff changeset
389 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
390 CFLAGS="-Wimplicit-function-declaration -Werror"
kono
parents:
diff changeset
391 AC_TRY_COMPILE([#define _GNU_SOURCE 1
kono
parents:
diff changeset
392 #include <string.h>
kono
parents:
diff changeset
393 #include <locale.h>],
kono
parents:
diff changeset
394 [char s[128]; strerror_r(5, s);],
kono
parents:
diff changeset
395 AC_DEFINE(HAVE_STRERROR_R_2ARGS, 1,
kono
parents:
diff changeset
396 [Define if strerror_r takes two arguments and is available in <string.h>.]),)
kono
parents:
diff changeset
397 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
398 ])
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 dnl Check for AVX
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 AC_DEFUN([LIBGFOR_CHECK_AVX], [
kono
parents:
diff changeset
403 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
404 CFLAGS="-O2 -mavx"
kono
parents:
diff changeset
405 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
406 void _mm256_zeroall (void)
kono
parents:
diff changeset
407 {
kono
parents:
diff changeset
408 __builtin_ia32_vzeroall ();
kono
parents:
diff changeset
409 }]], [[]])],
kono
parents:
diff changeset
410 AC_DEFINE(HAVE_AVX, 1,
kono
parents:
diff changeset
411 [Define if AVX instructions can be compiled.]),
kono
parents:
diff changeset
412 [])
kono
parents:
diff changeset
413 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
414 ])
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 dnl Check for AVX2
kono
parents:
diff changeset
417
kono
parents:
diff changeset
418 AC_DEFUN([LIBGFOR_CHECK_AVX2], [
kono
parents:
diff changeset
419 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
420 CFLAGS="-O2 -mavx2"
kono
parents:
diff changeset
421 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
422 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
kono
parents:
diff changeset
423 __v4di
kono
parents:
diff changeset
424 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
kono
parents:
diff changeset
425 {
kono
parents:
diff changeset
426 return __builtin_ia32_andnotsi256 (__X, __Y);
kono
parents:
diff changeset
427 }]], [[]])],
kono
parents:
diff changeset
428 AC_DEFINE(HAVE_AVX2, 1,
kono
parents:
diff changeset
429 [Define if AVX2 instructions can be compiled.]),
kono
parents:
diff changeset
430 [])
kono
parents:
diff changeset
431 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
432 ])
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 dnl Check for AVX512f
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436 AC_DEFUN([LIBGFOR_CHECK_AVX512F], [
kono
parents:
diff changeset
437 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
438 CFLAGS="-O2 -mavx512f"
kono
parents:
diff changeset
439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
440 typedef double __m512d __attribute__ ((__vector_size__ (64)));
kono
parents:
diff changeset
441 __m512d _mm512_add (__m512d a)
kono
parents:
diff changeset
442 {
kono
parents:
diff changeset
443 __m512d b = __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
kono
parents:
diff changeset
444 /* For -m64/-mx32 also verify that code will work even if
kono
parents:
diff changeset
445 the target uses call saved zmm16+ and needs to emit
kono
parents:
diff changeset
446 unwind info for them (e.g. on mingw). See PR79127. */
kono
parents:
diff changeset
447 #ifdef __x86_64__
kono
parents:
diff changeset
448 asm volatile ("" : : : "zmm16", "zmm17", "zmm18", "zmm19");
kono
parents:
diff changeset
449 #endif
kono
parents:
diff changeset
450 return b;
kono
parents:
diff changeset
451 }]], [[]])],
kono
parents:
diff changeset
452 AC_DEFINE(HAVE_AVX512F, 1,
kono
parents:
diff changeset
453 [Define if AVX512f instructions can be compiled.]),
kono
parents:
diff changeset
454 [])
kono
parents:
diff changeset
455 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
456 ])
kono
parents:
diff changeset
457
kono
parents:
diff changeset
458 dnl Check for FMA3
kono
parents:
diff changeset
459 dnl
kono
parents:
diff changeset
460 AC_DEFUN([LIBGFOR_CHECK_FMA3], [
kono
parents:
diff changeset
461 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
462 CFLAGS="-O2 -mfma -mno-fma4"
kono
parents:
diff changeset
463 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
464 typedef float __m128 __attribute__ ((__vector_size__ (16)));
kono
parents:
diff changeset
465 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
kono
parents:
diff changeset
466 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
kono
parents:
diff changeset
467 {
kono
parents:
diff changeset
468 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
kono
parents:
diff changeset
469 (__v4sf)__B,
kono
parents:
diff changeset
470 (__v4sf)__C);
kono
parents:
diff changeset
471 }]], [[]])],
kono
parents:
diff changeset
472 AC_DEFINE(HAVE_FMA3, 1,
kono
parents:
diff changeset
473 [Define if FMA3 instructions can be compiled.]),
kono
parents:
diff changeset
474 [])
kono
parents:
diff changeset
475 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
476 ])
kono
parents:
diff changeset
477
kono
parents:
diff changeset
478 dnl Check for FMA4
kono
parents:
diff changeset
479 dnl
kono
parents:
diff changeset
480 AC_DEFUN([LIBGFOR_CHECK_FMA4], [
kono
parents:
diff changeset
481 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
482 CFLAGS="-O2 -mfma4 -mno-fma"
kono
parents:
diff changeset
483 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
484 typedef float __m128 __attribute__ ((__vector_size__ (16)));
kono
parents:
diff changeset
485 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
kono
parents:
diff changeset
486 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
kono
parents:
diff changeset
487 {
kono
parents:
diff changeset
488 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
kono
parents:
diff changeset
489 (__v4sf)__B,
kono
parents:
diff changeset
490 (__v4sf)__C);
kono
parents:
diff changeset
491 }]], [[]])],
kono
parents:
diff changeset
492 AC_DEFINE(HAVE_FMA4, 1,
kono
parents:
diff changeset
493 [Define if FMA4 instructions can be compiled.]),
kono
parents:
diff changeset
494 [])
kono
parents:
diff changeset
495 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
496 ])
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 dnl Check for -mprefer-avx128
kono
parents:
diff changeset
499 dnl This also defines an automake conditional.
kono
parents:
diff changeset
500 AC_DEFUN([LIBGFOR_CHECK_AVX128], [
kono
parents:
diff changeset
501 ac_save_CFLAGS="$CFLAGS"
kono
parents:
diff changeset
502 CFLAGS="-O2 -mavx -mprefer-avx128"
kono
parents:
diff changeset
503 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
kono
parents:
diff changeset
504 void foo()
kono
parents:
diff changeset
505 {
kono
parents:
diff changeset
506 }]], [[]])],
kono
parents:
diff changeset
507 AC_DEFINE(HAVE_AVX128, 1,
kono
parents:
diff changeset
508 [Define if -mprefer-avx128 is supported.])
kono
parents:
diff changeset
509 AM_CONDITIONAL([HAVE_AVX128],true),
kono
parents:
diff changeset
510 [AM_CONDITIONAL([HAVE_AVX128],false)])
kono
parents:
diff changeset
511 CFLAGS="$ac_save_CFLAGS"
kono
parents:
diff changeset
512 ])