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