1GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2# Local configure fragment for sysdeps/powerpc/powerpc64le.
3
4dnl Require at least POWER8 on powerpc64le
5OLD_CFLAGS="$CFLAGS"
6CFLAGS="$CFLAGS $libc_cv_cc_submachine"
7AC_CACHE_CHECK([if the target machine is at least POWER8],
8	       libc_cv_target_power8_ok, [
9AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
10#ifndef _ARCH_PWR8
11#error invalid target architecture
12#endif
13]])],
14	       [libc_cv_target_power8_ok=yes],
15	       [libc_cv_target_power8_ok=no])])
16AS_IF([test "$libc_cv_target_power8_ok" != "yes"],
17      [critic_missing="$critic_missing POWER8 or newer is required on powerpc64le."])
18CFLAGS="$OLD_CFLAGS"
19
20dnl Require support for -mno-gnu-attribute
21OLD_CFLAGS="$CFLAGS"
22CFLAGS="$CFLAGS -mno-gnu-attribute"
23AC_CACHE_CHECK([if the compiler supports -mno-gnu-attribute],
24	       libc_cv_no_gnu_attr_ok, [
25AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
26]])],
27	       [libc_cv_no_gnu_attr_ok=yes],
28	       [libc_cv_no_gnu_attr_ok=no])])
29AS_IF([test "$libc_cv_no_gnu_attr_ok" != "yes"],
30      [critic_missing="$critic_missing A compiler with -mno-gnu-attribute is required on powerpc64le."])
31CFLAGS="$OLD_CFLAGS"
32
33dnl Some old compiler versions give error for the function signbit() for
34dnl 128-bit floating point types.  This is fixed by PR83862 and backported
35dnl to gcc6 and gcc7.  This test is to check if we are using the compiler
36dnl that has this bug (fixed in GCC 8.0, backported to 7.4).
37AC_CACHE_CHECK([if $CC compiles signbit with 128-bit floating point type],
38	       libc_cv_compiler_powerpc64le_ice, [dnl
39save_CFLAGS="$CFLAGS"
40CFLAGS="$CFLAGS -mabi=ieeelongdouble -Wno-psabi"
41AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
42int sbr (long double a) { return __builtin_signbit (a); }
43int sbm (long double *a) { return __builtin_signbit (*a); }
44int sbo (long double *a) { return __builtin_signbit (a[4]); }
45int sbi (long double *a, unsigned long n) { return __builtin_signbit (a[n]); }
46void sbs (int *p, long double a) { *p = __builtin_signbit (a); }
47]])],
48		  [libc_cv_compiler_powerpc64le_ice=yes],
49		  [libc_cv_compiler_powerpc64le_ice=no])
50CFLAGS="$save_CFLAGS"])
51AS_IF([test "$libc_cv_compiler_powerpc64le_ice" != "yes"],
52      [critic_missing="$critic_missing __builtin_signbit is broken.  GCC 7.4 or newer is required to resolve (PR83862)."])
53
54dnl Some old compiler versions give out error messages when combining
55dnl -mabi=% and -mlong-double-128.  i.e GCC 7.5.0 (PR94200)
56AC_CACHE_CHECK([if $CC compiles with -mabi=ieeelongdouble and -mlong-double-128],
57	       libc_cv_compiler_powerpc64le_ldbl128_mabi, [dnl
58save_CFLAGS="$CFLAGS"
59CFLAGS="$CFLAGS -mabi=ieeelongdouble -mlong-double-128"
60AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
61long double x;
62]])],
63		  [libc_cv_compiler_powerpc64le_ldbl128_mabi=yes],
64		  [libc_cv_compiler_powerpc64le_ldbl128_mabi=no])
65CFLAGS="$save_CFLAGS"])
66AS_IF([test "$libc_cv_compiler_powerpc64le_ldbl128_mabi" == "no"],
67      [critic_missing="$critic_missing The compiler must support -mabi=ieeelongdouble and -mlong-double-128 simultaneously."])
68
69dnl objcopy (binutils) 2.26 or newer required to support the --update-section
70dnl feature for fixing up .gnu.attribute section with IEEE ldbl.
71AC_CHECK_PROG_VER(OBJCOPY, $OBJCOPY, --version,
72		  [GNU objcopy.* \([0-9]*\.[0-9.]*\)],
73		  [2.1[0-9][0-9]*|2.2[6-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
74		  AS=: critic_missing="$critic_missing objcopy >= 2.26 is required on powerpc64le")
75
76test -n "$critic_missing" && AC_MSG_ERROR([*** $critic_missing])
77