Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / cf / solaris-test1.m4
1 dnl This test is for the Solaris x86 kernel module
2 dnl build. They prevent newer Solaris compilers (12.3
3 dnl and up) from using XMM registers (SIMD instructions)
4 dnl and floating point registers, which are invalid in
5 dnl Solaris kernel code.
6 dnl Without this, Solaris may panic in libafs with:
7 dnl BAD TRAP: type=7 (#nm Device not available)
8 dnl
9 dnl
10 AC_DEFUN([SOLARIS_CC_TAKES_XVECTOR_NONE], [
11 AC_CACHE_CHECK([if $CC accepts -xvector=%none],
12 [ac_cv_solaris_cc_takes_xvector_none],
13 [save_CFLAGS="$CFLAGS"
14 CFLAGS="$CFLAGS -xvector=%none"
15 AC_COMPILE_IFELSE(
16 [AC_LANG_PROGRAM([[]], [[int x;]])],
17 [ac_cv_solaris_cc_takes_xvector_none=yes],
18 [ac_cv_solaris_cc_takes_xvector_none=no])
19 CFLAGS="$save_CFLAGS"
20 ])
21
22 dnl -xvector=%none first appeared in Studio 11, but has only been
23 dnl documented as required for Solaris x86 kernel code since Studio
24 dnl 12.3. Studio 12.3 is when the compiler started making more
25 dnl aggressive optimizations by using SSE/SIMD instructions with XMM
26 dnl (floating point/ SIMD) registers. Although -xvector=%none is
27 dnl required to prevent these optimizations, it is not sufficient.
28 dnl Experiments have shown that -xregs=no%float is also needed to
29 dnl 1) eliminate a few optimizations not squelched by -xvector=%none,
30 dnl and 2) prevent actual use of floating point types in the kernel
31 dnl module. -xregs=no%float has been present since before Studio 8, so
32 dnl it is safe to assume its presence when -xvector=%none is present.
33 dnl
34
35 AS_IF([test "$ac_cv_solaris_cc_takes_xvector_none" = "yes"],
36 [SOLARIS_CC_KOPTS="-xvector=%none -xregs=no%float "])
37 ])
38