Bug 369509 - ARMv8.1-a LSE instructions are not supported.
[valgrind.git] / configure.ac
blob78c21f58bf0dbe13548232e1383d7b14d220ae11
2 ##------------------------------------------------------------##
3
4 # The multiple-architecture stuff in this file is pretty
5 # cryptic.  Read docs/internals/multiple-architectures.txt
6 # for at least a partial explanation of what is going on.
8 ##------------------------------------------------------------##
10 # Process this file with autoconf to produce a configure script.
11 AC_INIT([Valgrind],[3.16.0.GIT],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
16 AM_MAINTAINER_MODE
18 #----------------------------------------------------------------------------
19 # Do NOT modify these flags here. Except in feature tests in which case
20 # the original values must be properly restored.
21 #----------------------------------------------------------------------------
22 CFLAGS="$CFLAGS"
23 CXXFLAGS="$CXXFLAGS"
25 #----------------------------------------------------------------------------
26 # Checks for various programs.
27 #----------------------------------------------------------------------------
29 AC_PROG_LN_S
30 AC_PROG_CC
31 AM_PROG_CC_C_O
32 AC_PROG_CPP
33 AC_PROG_CXX
34 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
35 # autoconf 2.59).  If we ever have any Objective-C code in the Valgrind code
36 # base (eg. most likely as Darwin-specific tests) we'll need one of the
37 # following:
38 # - put AC_PROG_OBJC in a Darwin-specific part of this file
39 # - Use AC_PROG_OBJC here and up the minimum autoconf version
40 # - Use the following, which is apparently equivalent:
41 #     m4_ifdef([AC_PROG_OBJC],
42 #        [AC_PROG_OBJC],
43 #        [AC_CHECK_TOOL([OBJC], [gcc])
44 #         AC_SUBST([OBJC])
45 #         AC_SUBST([OBJCFLAGS])
46 #        ])
47 AC_PROG_RANLIB
48 # Set LTO_RANLIB variable to an lto enabled ranlib
49 if test "x$LTO_RANLIB" = "x"; then
50   AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
52 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
54 # provide a very basic definition for AC_PROG_SED if it's not provided by
55 # autoconf (as e.g. in autoconf 2.59).
56 m4_ifndef([AC_PROG_SED],
57           [AC_DEFUN([AC_PROG_SED],
58                     [AC_ARG_VAR([SED])
59                      AC_CHECK_PROGS([SED],[gsed sed])])])
60 AC_PROG_SED
62 # If no AR variable was specified, look up the name of the archiver. Otherwise
63 # do not touch the AR variable.
64 if test "x$AR" = "x"; then
65   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
67 AC_ARG_VAR([AR],[Archiver command])
69 # same for LTO_AR variable for lto enabled archiver
70 if test "x$LTO_AR" = "x"; then
71   AC_PATH_PROGS([LTO_AR], [gcc-ar])
73 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
76 # Check for the compiler support
77 if test "${GCC}" != "yes" ; then
78    AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
81 # figure out where perl lives
82 AC_PATH_PROG(PERL, perl)
84 # figure out where gdb lives
85 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
86 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
88 # some older automake's don't have it so try something on our own
89 ifdef([AM_PROG_AS],[AM_PROG_AS],
91 AS="${CC}"
92 AC_SUBST(AS)
94 ASFLAGS=""
95 AC_SUBST(ASFLAGS)
99 # Check if 'diff' supports -u (universal diffs) and use it if possible.
101 AC_MSG_CHECKING([for diff -u])
102 AC_SUBST(DIFF)
104 # Comparing two identical files results in 0.
105 tmpfile="tmp-xxx-yyy-zzz"
106 touch $tmpfile;
107 if diff -u $tmpfile $tmpfile ; then
108     AC_MSG_RESULT([yes])
109     DIFF="diff -u"
110 else
111     AC_MSG_RESULT([no])
112     DIFF="diff"
114 rm $tmpfile
116 # Make sure we can compile in C99 mode.
117 AC_PROG_CC_C99
118 if test "$ac_cv_prog_cc_c99" == "no"; then
119     AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
122 # We don't want gcc < 3.0
123 AC_MSG_CHECKING([for a supported version of gcc])
125 # Obtain the compiler version.
127 # A few examples of how the ${CC} --version output looks like:
129 # ######## gcc variants ########
130 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
131 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
132 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
133 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
134 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
135 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
136 # OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
138 # ######## clang variants ########
139 # Clang: clang version 2.9 (tags/RELEASE_29/final)
140 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
141 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
143 # ######## Apple LLVM variants ########
144 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
145 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
148 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
149 then
150     is_clang="applellvm"
151     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
152 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
153 then
154     is_clang="clang"
155     # Don't use -dumpversion with clang: it will always produce "4.2.1".
156     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
157 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
158 then
159     is_clang="icc"
160     gcc_version=`${CC} -dumpversion 2>/dev/null`
161 else
162     is_clang="notclang"
163     gcc_version=`${CC} -dumpversion 2>/dev/null`
164     if test "x$gcc_version" = x; then
165         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
166     fi
169 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
170 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
172 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
173 # statements have to be quoted.
174 case "${is_clang}-${gcc_version}" in
175      applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
176         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
177         ;;
178      icc-1[[3-9]].*)
179         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
180         ;;
181      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
182         AC_MSG_RESULT([ok (${gcc_version})])
183         ;;
184      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
185         AC_MSG_RESULT([ok (clang-${gcc_version})])
186         ;;
187      *)
188         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
189         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
190         ;;
191 esac
193 #----------------------------------------------------------------------------
194 # Arch/OS/platform tests.
195 #----------------------------------------------------------------------------
196 # We create a number of arch/OS/platform-related variables.  We prefix them
197 # all with "VGCONF_" which indicates that they are defined at
198 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
199 # variables used when compiling C files.
201 AC_CANONICAL_HOST
203 AC_MSG_CHECKING([for a supported CPU])
205 # ARCH_MAX reflects the most that this CPU can do: for example if it
206 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
207 # Ditto for amd64.  It is used for more configuration below, but is not used
208 # outside this file.
210 # Power PC returns powerpc for Big Endian.  This was not changed when Little
211 # Endian support was added to the 64-bit architecture.  The 64-bit Little
212 # Endian systems explicitly state le in the host_cpu.  For clarity in the
213 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
214 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
215 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
216 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
217 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
218 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
219 # Little Endian.
221 case "${host_cpu}" in
222      i?86) 
223         AC_MSG_RESULT([ok (${host_cpu})])
224         ARCH_MAX="x86"
225         ;;
227      x86_64) 
228         AC_MSG_RESULT([ok (${host_cpu})])
229         ARCH_MAX="amd64"
230         ;;
232      powerpc64)
233      # this only referrs to 64-bit Big Endian
234         AC_MSG_RESULT([ok (${host_cpu})])
235         ARCH_MAX="ppc64be"
236         ;;
238      powerpc64le)
239      # this only referrs to 64-bit Little Endian
240         AC_MSG_RESULT([ok (${host_cpu})])
241         ARCH_MAX="ppc64le"
242         ;;
244      powerpc)
245         # On Linux this means only a 32-bit capable CPU.
246         AC_MSG_RESULT([ok (${host_cpu})])
247         ARCH_MAX="ppc32"
248         ;;
250      s390x)
251         AC_MSG_RESULT([ok (${host_cpu})])
252         ARCH_MAX="s390x"
253         ;;
255      armv7*)
256         AC_MSG_RESULT([ok (${host_cpu})])
257         ARCH_MAX="arm"
258         ;;
260      aarch64*)
261        AC_MSG_RESULT([ok (${host_cpu})])
262        ARCH_MAX="arm64"
263        ;;
265      mips)
266         AC_MSG_RESULT([ok (${host_cpu})])
267         ARCH_MAX="mips32"
268         ;;
270      mipsel)
271         AC_MSG_RESULT([ok (${host_cpu})])
272         ARCH_MAX="mips32"
273         ;;
275      mipsisa32r2)
276         AC_MSG_RESULT([ok (${host_cpu})])
277         ARCH_MAX="mips32"
278         ;;
280      mips64*)
281         AC_MSG_RESULT([ok (${host_cpu})])
282         ARCH_MAX="mips64"
283         ;;
285      mipsisa64*)
286         AC_MSG_RESULT([ok (${host_cpu})])
287         ARCH_MAX="mips64"
288         ;;
290      *) 
291         AC_MSG_RESULT([no (${host_cpu})])
292         AC_MSG_ERROR([Unsupported host architecture. Sorry])
293         ;;
294 esac
296 #----------------------------------------------------------------------------
298 # Sometimes it's convenient to subvert the bi-arch build system and
299 # just have a single build even though the underlying platform is
300 # capable of both.  Hence handle --enable-only64bit and
301 # --enable-only32bit.  Complain if both are issued :-)
302 # [Actually, if either of these options are used, I think both get built,
303 # but only one gets installed.  So if you use an in-place build, both can be
304 # used. --njn]
306 # Check if a 64-bit only build has been requested
307 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
308    [AC_ARG_ENABLE(only64bit, 
309       [  --enable-only64bit      do a 64-bit only build],
310       [vg_cv_only64bit=$enableval],
311       [vg_cv_only64bit=no])])
313 # Check if a 32-bit only build has been requested
314 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
315    [AC_ARG_ENABLE(only32bit, 
316       [  --enable-only32bit      do a 32-bit only build],
317       [vg_cv_only32bit=$enableval],
318       [vg_cv_only32bit=no])])
320 # Stay sane
321 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
322    AC_MSG_ERROR(
323       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
326 #----------------------------------------------------------------------------
328 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
329 # compilation of many C files via -VGO_$(VGCONF_OS) and
330 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
331 AC_MSG_CHECKING([for a supported OS])
332 AC_SUBST(VGCONF_OS)
334 DEFAULT_SUPP=""
336 case "${host_os}" in
337      *linux*)
338         AC_MSG_RESULT([ok (${host_os})])
339         VGCONF_OS="linux"
341         # Ok, this is linux. Check the kernel version
342         AC_MSG_CHECKING([for the kernel version])
344         kernel=`uname -r`
346         case "${kernel}" in
347              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
348                     AC_MSG_RESULT([unsupported (${kernel})])
349                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
350                     ;;
352              *)
353                     AC_MSG_RESULT([2.6 or later (${kernel})])
354                     ;;
355         esac
357         ;;
359      *darwin*)
360         AC_MSG_RESULT([ok (${host_os})])
361         VGCONF_OS="darwin"
362         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
363         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
364         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
365         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
366         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
367         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
368         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
369         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
370         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
372         AC_MSG_CHECKING([for the kernel version])
373         kernel=`uname -r`
375         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
376         # has only one relevant version, the OS version. The `uname` check
377         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
378         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
379         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
380         # and we don't know of an macros similar to __GLIBC__ to get that info.
381         #
382         # XXX: `uname -r` won't do the right thing for cross-compiles, but
383         # that's not a problem yet.
384         #
385         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
386         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
387         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
388         # time support for 10.5 (the 9.* pattern just below), I'll leave it
389         # in for now, just in case anybody wants to give it a try.  But I'm
390         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
391         case "${kernel}" in
392              9.*)
393                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
394                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
395                   DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
396                   DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
397                   ;;
398              10.*)
399                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
400                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
401                   DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
402                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
403                   ;;
404              11.*)
405                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
406                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
407                   DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
408                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
409                   ;;
410              12.*)
411                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
412                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
413                   DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
414                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
415                   ;;
416              13.*)
417                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
418                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
419                   DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
420                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
421                   ;;
422              14.*)
423                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
424                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
425                   DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
426                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
427                   ;;
428              15.*)
429                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
430                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
431                   DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
432                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
433                   ;;
434              16.*)
435                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
436                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
437                   DEFAULT_SUPP="darwin16.supp ${DEFAULT_SUPP}"
438                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
439                   ;;
440              17.*)
441                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
442                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
443                   DEFAULT_SUPP="darwin17.supp ${DEFAULT_SUPP}"
444                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
445                   ;;
446              *) 
447                   AC_MSG_RESULT([unsupported (${kernel})])
448                   AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x and 17.x (Mac OS X 10.6/7/8/9/10/11 and macOS 10.12/13)])
449                   ;;
450         esac
451         ;;
453      solaris2.11*)
454         AC_MSG_RESULT([ok (${host_os})])
455         VGCONF_OS="solaris"
457         uname_v=$( uname -v )
458         case "$uname_v" in
459              11.4.*)
460                  DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
461                  ;;
462              *)
463                  DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
464                  ;;
465         esac
466         ;;
468      solaris2.12*)
469         AC_MSG_RESULT([ok (${host_os})])
470         VGCONF_OS="solaris"
471         DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
472         ;;
474      *) 
475         AC_MSG_RESULT([no (${host_os})])
476         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
477         ;;
478 esac
480 #----------------------------------------------------------------------------
482 # If we are building on a 64 bit platform test to see if the system
483 # supports building 32 bit programs and disable 32 bit support if it
484 # does not support building 32 bit programs
486 case "$ARCH_MAX-$VGCONF_OS" in
487      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
488         AC_MSG_CHECKING([for 32 bit build support])
489         safe_CFLAGS=$CFLAGS
490         CFLAGS="-m32"
491         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
492           return 0;
493         ]])], [
494         AC_MSG_RESULT([yes])
495         ], [
496         vg_cv_only64bit="yes"
497         AC_MSG_RESULT([no])
498         ])
499         CFLAGS=$safe_CFLAGS;;
500     mips64-linux)
501         AC_MSG_CHECKING([for 32 bit build support])
502         safe_CFLAGS=$CFLAGS
503         CFLAGS="$CFLAGS -mips32 -mabi=32"
504         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
505           #include <sys/prctl.h>
506         ]], [[]])], [
507         AC_MSG_RESULT([yes])
508         ], [
509         vg_cv_only64bit="yes"
510         AC_MSG_RESULT([no])
511         ])
512         CFLAGS=$safe_CFLAGS;;
513 esac
515 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
516    AC_MSG_ERROR(
517       [--enable-only32bit was specified but system does not support 32 bit builds])
520 #----------------------------------------------------------------------------
522 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
523 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
524 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
525 # above) will be "amd64" since that reflects the most that this cpu can do,
526 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
527 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
528 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
529 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
530 AC_SUBST(VGCONF_ARCH_PRI)
532 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
533 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
534 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
535 # It is empty if there is no secondary target.
536 AC_SUBST(VGCONF_ARCH_SEC)
538 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
539 # The entire system, including regression and performance tests, will be
540 # built for this target.  The "_CAPS" indicates that the name is in capital
541 # letters, and it also uses '_' rather than '-' as a separator, because it's
542 # used to create various Makefile variables, which are all in caps by
543 # convention and cannot contain '-' characters.  This is in contrast to
544 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
545 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
547 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
548 # Valgrind and tools will also be built for this target, but not the
549 # regression or performance tests.
551 # By default, the primary arch is the same as the "max" arch, as commented
552 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
553 # the big case statement just below here, in the case where we're building
554 # on a 64 bit machine but have been requested only to do a 32 bit build.
555 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
557 AC_MSG_CHECKING([for a supported CPU/OS combination])
559 # NB.  The load address for a given platform may be specified in more 
560 # than one place, in some cases, depending on whether we're doing a biarch,
561 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
562 # Be careful to give consistent values in all subcases.  Also, all four
563 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
564 # even if it is to "0xUNSET".
566 case "$ARCH_MAX-$VGCONF_OS" in
567      x86-linux)
568         VGCONF_ARCH_PRI="x86"
569         VGCONF_ARCH_SEC=""
570         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
571         VGCONF_PLATFORM_SEC_CAPS=""
572         valt_load_address_pri_norml="0x58000000"
573         valt_load_address_pri_inner="0x38000000"
574         valt_load_address_sec_norml="0xUNSET"
575         valt_load_address_sec_inner="0xUNSET"
576         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
577         ;;
578      amd64-linux)
579         valt_load_address_sec_norml="0xUNSET"
580         valt_load_address_sec_inner="0xUNSET"
581         if test x$vg_cv_only64bit = xyes; then
582            VGCONF_ARCH_PRI="amd64"
583            VGCONF_ARCH_SEC=""
584            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
585            VGCONF_PLATFORM_SEC_CAPS=""
586            valt_load_address_pri_norml="0x58000000"
587            valt_load_address_pri_inner="0x38000000"
588         elif test x$vg_cv_only32bit = xyes; then
589            VGCONF_ARCH_PRI="x86"
590            VGCONF_ARCH_SEC=""
591            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
592            VGCONF_PLATFORM_SEC_CAPS=""
593            valt_load_address_pri_norml="0x58000000"
594            valt_load_address_pri_inner="0x38000000"
595         else
596            VGCONF_ARCH_PRI="amd64"
597            VGCONF_ARCH_SEC="x86"
598            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
599            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
600            valt_load_address_pri_norml="0x58000000"
601            valt_load_address_pri_inner="0x38000000"
602            valt_load_address_sec_norml="0x58000000"
603            valt_load_address_sec_inner="0x38000000"
604         fi
605         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
606         ;;
607      ppc32-linux)
608         VGCONF_ARCH_PRI="ppc32"
609         VGCONF_ARCH_SEC=""
610         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
611         VGCONF_PLATFORM_SEC_CAPS=""
612         valt_load_address_pri_norml="0x58000000"
613         valt_load_address_pri_inner="0x38000000"
614         valt_load_address_sec_norml="0xUNSET"
615         valt_load_address_sec_inner="0xUNSET"
616         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
617         ;;
618      ppc64be-linux)
619         valt_load_address_sec_norml="0xUNSET"
620         valt_load_address_sec_inner="0xUNSET"
621         if test x$vg_cv_only64bit = xyes; then
622            VGCONF_ARCH_PRI="ppc64be"
623            VGCONF_ARCH_SEC=""
624            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
625            VGCONF_PLATFORM_SEC_CAPS=""
626            valt_load_address_pri_norml="0x58000000"
627            valt_load_address_pri_inner="0x38000000"
628         elif test x$vg_cv_only32bit = xyes; then
629            VGCONF_ARCH_PRI="ppc32"
630            VGCONF_ARCH_SEC=""
631            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
632            VGCONF_PLATFORM_SEC_CAPS=""
633            valt_load_address_pri_norml="0x58000000"
634            valt_load_address_pri_inner="0x38000000"
635         else
636            VGCONF_ARCH_PRI="ppc64be"
637            VGCONF_ARCH_SEC="ppc32"
638            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
639            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
640            valt_load_address_pri_norml="0x58000000"
641            valt_load_address_pri_inner="0x38000000"
642            valt_load_address_sec_norml="0x58000000"
643            valt_load_address_sec_inner="0x38000000"
644         fi
645         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
646         ;;
647      ppc64le-linux)
648         # Little Endian is only supported on PPC64
649         valt_load_address_sec_norml="0xUNSET"
650         valt_load_address_sec_inner="0xUNSET"
651         VGCONF_ARCH_PRI="ppc64le"
652         VGCONF_ARCH_SEC=""
653         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
654         VGCONF_PLATFORM_SEC_CAPS=""
655         valt_load_address_pri_norml="0x58000000"
656         valt_load_address_pri_inner="0x38000000"
657         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
658        ;;
659      # Darwin gets identified as 32-bit even when it supports 64-bit.
660      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
661      # all Macs support both 32-bit and 64-bit, so we just build both.  If
662      # someone has a really old 32-bit only machine they can (hopefully?)
663      # build with --enable-only32bit.  See bug 243362.
664      x86-darwin|amd64-darwin)
665         ARCH_MAX="amd64"
666         valt_load_address_sec_norml="0xUNSET"
667         valt_load_address_sec_inner="0xUNSET"
668         if test x$vg_cv_only64bit = xyes; then
669            VGCONF_ARCH_PRI="amd64"
670            VGCONF_ARCH_SEC=""
671            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
672            VGCONF_PLATFORM_SEC_CAPS=""
673            valt_load_address_pri_norml="0x158000000"
674            valt_load_address_pri_inner="0x138000000"
675         elif test x$vg_cv_only32bit = xyes; then
676            VGCONF_ARCH_PRI="x86"
677            VGCONF_ARCH_SEC=""
678            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
679            VGCONF_PLATFORM_SEC_CAPS=""
680            VGCONF_ARCH_PRI_CAPS="x86"
681            valt_load_address_pri_norml="0x58000000"
682            valt_load_address_pri_inner="0x38000000"
683         else
684            VGCONF_ARCH_PRI="amd64"
685            VGCONF_ARCH_SEC="x86"
686            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
687            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
688            valt_load_address_pri_norml="0x158000000"
689            valt_load_address_pri_inner="0x138000000"
690            valt_load_address_sec_norml="0x58000000"
691            valt_load_address_sec_inner="0x38000000"
692         fi
693         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
694         ;;
695      arm-linux) 
696         VGCONF_ARCH_PRI="arm"
697         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
698         VGCONF_PLATFORM_SEC_CAPS=""
699         valt_load_address_pri_norml="0x58000000"
700         valt_load_address_pri_inner="0x38000000"
701         valt_load_address_sec_norml="0xUNSET"
702         valt_load_address_sec_inner="0xUNSET"
703         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
704         ;;
705      arm64-linux)
706         valt_load_address_sec_norml="0xUNSET"
707         valt_load_address_sec_inner="0xUNSET"
708         if test x$vg_cv_only64bit = xyes; then
709            VGCONF_ARCH_PRI="arm64"
710            VGCONF_ARCH_SEC=""
711            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
712            VGCONF_PLATFORM_SEC_CAPS=""
713            valt_load_address_pri_norml="0x58000000"
714            valt_load_address_pri_inner="0x38000000"
715         elif test x$vg_cv_only32bit = xyes; then
716            VGCONF_ARCH_PRI="arm"
717            VGCONF_ARCH_SEC=""
718            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
719            VGCONF_PLATFORM_SEC_CAPS=""
720            valt_load_address_pri_norml="0x58000000"
721            valt_load_address_pri_inner="0x38000000"
722         else
723            VGCONF_ARCH_PRI="arm64"
724            VGCONF_ARCH_SEC="arm"
725            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
726            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
727            valt_load_address_pri_norml="0x58000000"
728            valt_load_address_pri_inner="0x38000000"
729            valt_load_address_sec_norml="0x58000000"
730            valt_load_address_sec_inner="0x38000000"
731         fi
732         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
733         ;;
734      s390x-linux)
735         VGCONF_ARCH_PRI="s390x"
736         VGCONF_ARCH_SEC=""
737         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
738         VGCONF_PLATFORM_SEC_CAPS=""
739         # To improve branch prediction hit rate we want to have
740         # the generated code close to valgrind (host) code
741         valt_load_address_pri_norml="0x800000000"
742         valt_load_address_pri_inner="0x810000000"
743         valt_load_address_sec_norml="0xUNSET"
744         valt_load_address_sec_inner="0xUNSET"
745         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
746         ;;
747      mips32-linux) 
748         VGCONF_ARCH_PRI="mips32"
749         VGCONF_ARCH_SEC=""
750         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
751         VGCONF_PLATFORM_SEC_CAPS=""
752         valt_load_address_pri_norml="0x58000000"
753         valt_load_address_pri_inner="0x38000000"
754         valt_load_address_sec_norml="0xUNSET"
755         valt_load_address_sec_inner="0xUNSET"
756         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
757         ;;
758      mips64-linux)
759         valt_load_address_sec_norml="0xUNSET"
760         valt_load_address_sec_inner="0xUNSET"
761         if test x$vg_cv_only64bit = xyes; then
762             VGCONF_ARCH_PRI="mips64"
763             VGCONF_PLATFORM_SEC_CAPS=""
764             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
765             VGCONF_PLATFORM_SEC_CAPS=""
766             valt_load_address_pri_norml="0x58000000"
767             valt_load_address_pri_inner="0x38000000"
768         elif test x$vg_cv_only32bit = xyes; then
769             VGCONF_ARCH_PRI="mips32"
770             VGCONF_ARCH_SEC=""
771             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
772             VGCONF_PLATFORM_SEC_CAPS=""
773             valt_load_address_pri_norml="0x58000000"
774             valt_load_address_pri_inner="0x38000000"
775         else
776             VGCONF_ARCH_PRI="mips64"
777             VGCONF_ARCH_SEC="mips32"
778             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
779             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
780             valt_load_address_pri_norml="0x58000000"
781             valt_load_address_pri_inner="0x38000000"
782             valt_load_address_sec_norml="0x58000000"
783             valt_load_address_sec_inner="0x38000000"
784         fi
785         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
786         ;;
787      x86-solaris)
788         VGCONF_ARCH_PRI="x86"
789         VGCONF_ARCH_SEC=""
790         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
791         VGCONF_PLATFORM_SEC_CAPS=""
792         valt_load_address_pri_norml="0x58000000"
793         valt_load_address_pri_inner="0x38000000"
794         valt_load_address_sec_norml="0xUNSET"
795         valt_load_address_sec_inner="0xUNSET"
796         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
797         ;;
798      amd64-solaris)
799         valt_load_address_sec_norml="0xUNSET"
800         valt_load_address_sec_inner="0xUNSET"
801         if test x$vg_cv_only64bit = xyes; then
802            VGCONF_ARCH_PRI="amd64"
803            VGCONF_ARCH_SEC=""
804            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
805            VGCONF_PLATFORM_SEC_CAPS=""
806            valt_load_address_pri_norml="0x58000000"
807            valt_load_address_pri_inner="0x38000000"
808         elif test x$vg_cv_only32bit = xyes; then
809            VGCONF_ARCH_PRI="x86"
810            VGCONF_ARCH_SEC=""
811            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
812            VGCONF_PLATFORM_SEC_CAPS=""
813            valt_load_address_pri_norml="0x58000000"
814            valt_load_address_pri_inner="0x38000000"
815         else
816            VGCONF_ARCH_PRI="amd64"
817            VGCONF_ARCH_SEC="x86"
818            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
819            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
820            valt_load_address_pri_norml="0x58000000"
821            valt_load_address_pri_inner="0x38000000"
822            valt_load_address_sec_norml="0x58000000"
823            valt_load_address_sec_inner="0x38000000"
824         fi
825         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
826         ;;
827     *)
828         VGCONF_ARCH_PRI="unknown"
829         VGCONF_ARCH_SEC="unknown"
830         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
831         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
832         valt_load_address_pri_norml="0xUNSET"
833         valt_load_address_pri_inner="0xUNSET"
834         valt_load_address_sec_norml="0xUNSET"
835         valt_load_address_sec_inner="0xUNSET"
836         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
837         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
838         ;;
839 esac
841 #----------------------------------------------------------------------------
843 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
844 # defined.
845 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
846                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
847                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
848                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
849                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
850                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
851                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
852 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
853                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
854                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
855                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
856 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
857                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
858                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
859 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
860                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
861                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
862 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
863                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
864                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
865 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
866                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
867 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
868                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
869 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
870                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
871                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
872 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
873                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
875 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
876 # become defined.
877 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
878                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
879                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
880 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
881                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
882 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
883                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
884                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
885 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
886                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
887 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
888                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
889 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
890                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
891                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
892 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
893                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
894 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
895                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
896                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
897 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
898                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
899                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
900 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
901                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
902 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,   
903                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
904                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
905 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
906                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
907 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
908                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
909                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
910 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
911                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
914 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
915 # Relies on the assumption that the primary and secondary targets are 
916 # for the same OS, so therefore only necessary to test the primary.
917 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
918                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
919                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
920                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
921                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
922                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
923                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
924                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
925                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
926                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
927                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
928 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
929                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
930                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
931 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
932                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
933                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
936 # Sometimes, in the Makefile.am files, it's useful to know whether or not
937 # there is a secondary target.
938 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
939                test x$VGCONF_PLATFORM_SEC_CAPS != x)
941 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
942 dnl fallback definition
943 dnl The macro is courtesy of Dave Hart:
944 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
945 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
946 if test -z "$$1_TRUE"; then :
947   m4_n([$2])[]dnl
948 m4_ifval([$3],
949 [else
950   $3
951 ])dnl
952 fi[]dnl
953 ])])
955 #----------------------------------------------------------------------------
956 # Inner Valgrind?
957 #----------------------------------------------------------------------------
959 # Check if this should be built as an inner Valgrind, to be run within
960 # another Valgrind.  Choose the load address accordingly.
961 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
962 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
963 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
964    [AC_ARG_ENABLE(inner, 
965       [  --enable-inner          enables self-hosting],
966       [vg_cv_inner=$enableval],
967       [vg_cv_inner=no])])
968 if test "$vg_cv_inner" = yes; then
969     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
970     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
971     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
972 else
973     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
974     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
977 #----------------------------------------------------------------------------
978 # Undefined behaviour sanitiser
979 #----------------------------------------------------------------------------
980 # Check whether we should build with the undefined beahviour sanitiser.
982 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
983    [AC_ARG_ENABLE(ubsan, 
984       [  --enable-ubsan          enables the undefined behaviour sanitiser],
985       [vg_cv_ubsan=$enableval],
986       [vg_cv_ubsan=no])])
988 #----------------------------------------------------------------------------
989 # Extra fine-tuning of installation directories
990 #----------------------------------------------------------------------------
991 AC_ARG_WITH(tmpdir,
992    [  --with-tmpdir=PATH      Specify path for temporary files],
993    tmpdir="$withval",
994    tmpdir="/tmp")
995 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
996 AC_SUBST(VG_TMPDIR, [$tmpdir])
998 #----------------------------------------------------------------------------
999 # Detect xcode path
1000 #----------------------------------------------------------------------------
1001 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1002 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1003 AC_MSG_CHECKING([for xcode sdk include path])
1004 AC_ARG_WITH(xcodedir,
1005    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1006    [xcodedir="$withval"],
1007    [
1008       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1009          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1010          if test -z "$xcrundir"; then
1011             xcodedir="/usr/include"
1012          else
1013             xcodedir="$xcrundir/usr/include"
1014          fi
1015       else
1016          xcodedir="/usr/include"
1017       fi
1018    ])
1019 AC_MSG_RESULT([$xcodedir])
1020 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1021 AC_SUBST(XCODE_DIR, [$xcodedir])])
1023 #----------------------------------------------------------------------------
1024 # Libc and suppressions
1025 #----------------------------------------------------------------------------
1026 # This variable will collect the suppression files to be used.
1027 AC_SUBST(DEFAULT_SUPP)
1029 AC_CHECK_HEADER([features.h])
1031 if test x$ac_cv_header_features_h = xyes; then
1032   rm -f conftest.$ac_ext
1033   cat <<_ACEOF >conftest.$ac_ext
1034 #include <features.h>
1035 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1036 glibc version is: __GLIBC__ __GLIBC_MINOR__
1037 #endif
1038 _ACEOF
1039   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1042 # not really a version check
1043 AC_EGREP_CPP([DARWIN_LIBC], [
1044 #include <sys/cdefs.h>
1045 #if defined(__DARWIN_VERS_1050)
1046   DARWIN_LIBC
1047 #endif
1049 GLIBC_VERSION="darwin")
1051 # not really a version check
1052 AC_EGREP_CPP([BIONIC_LIBC], [
1053 #if defined(__ANDROID__)
1054   BIONIC_LIBC
1055 #endif
1057 GLIBC_VERSION="bionic")
1059 # there is only one version of libc on Solaris
1060 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1061      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1062     GLIBC_VERSION="solaris"
1065 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1066 # in this case.
1067 if test x$GLIBC_VERSION = x; then
1068     if $CC -dumpmachine | grep -q musl; then
1069         GLIBC_VERSION=musl
1070     fi
1073 AC_MSG_CHECKING([the glibc version])
1075 case "${GLIBC_VERSION}" in
1076      2.2)
1077         AC_MSG_RESULT(${GLIBC_VERSION} family)
1078         DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1079         DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1080         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1081         ;;
1082      2.[[3-6]])
1083         AC_MSG_RESULT(${GLIBC_VERSION} family)
1084         DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1085         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1086         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1087         ;;
1088      2.[[7-9]])
1089         AC_MSG_RESULT(${GLIBC_VERSION} family)
1090         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1091         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1092         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1093         ;;
1094      2.10|2.11)
1095         AC_MSG_RESULT(${GLIBC_VERSION} family)
1096         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1097                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1098         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1099         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1100         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1101         ;;
1102      2.*)
1103         AC_MSG_RESULT(${GLIBC_VERSION} family)
1104         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1105                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1106         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1107                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1108         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1109         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1110         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1111         ;;
1112      darwin)
1113         AC_MSG_RESULT(Darwin)
1114         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1115         # DEFAULT_SUPP set by kernel version check above.
1116         ;;
1117      bionic)
1118         AC_MSG_RESULT(Bionic)
1119         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1120         DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1121         ;;
1122      solaris)
1123         AC_MSG_RESULT(Solaris)
1124         # DEFAULT_SUPP set in host_os switch-case above.
1125         # No other suppression file is used.
1126         ;;
1127      musl)
1128         AC_MSG_RESULT(Musl)
1129         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1130         # no DEFAULT_SUPP file yet for musl libc.
1131         ;;
1132      2.0|2.1|*)
1133         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1134         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1135         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1136         ;;
1137 esac
1139 AC_SUBST(GLIBC_VERSION)
1142 if test "$VGCONF_OS" != "solaris"; then
1143     # Add default suppressions for the X client libraries.  Make no
1144     # attempt to detect whether such libraries are installed on the
1145     # build machine (or even if any X facilities are present); just
1146     # add the suppressions antidisirregardless.
1147     DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1148     DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1150     # Add glibc and X11 suppressions for exp-sgcheck
1151     DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
1155 #----------------------------------------------------------------------------
1156 # Platform variants?
1157 #----------------------------------------------------------------------------
1159 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1160 # But there are times where we need a bit more control.  The motivating
1161 # and currently only case is Android: this is almost identical to
1162 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1163 # platform variant tags, which get passed in the compile as
1164 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1166 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1167 # it is "android" instead.
1169 # Consequently (eg), plain arm-linux would build with
1171 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1173 # whilst an Android build would have
1175 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1177 # Same for x86. The setup of the platform variant is pushed relatively far
1178 # down this file in order that we can inspect any of the variables set above.
1180 # In the normal case ..
1181 VGCONF_PLATVARIANT="vanilla"
1183 # Android ?
1184 if test "$GLIBC_VERSION" = "bionic";
1185 then
1186    VGCONF_PLATVARIANT="android"
1189 AC_SUBST(VGCONF_PLATVARIANT)
1192 # FIXME: do we also want to define automake variables
1193 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1194 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1195 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1196 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1197 # that's what we'd need to do to use this, since what we'd want to write
1198 # is something like
1200 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1202 # Hmm.  Can't think of a nice clean solution to this.
1204 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1205                test x$VGCONF_PLATVARIANT = xvanilla)
1206 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1207                test x$VGCONF_PLATVARIANT = xandroid)
1210 #----------------------------------------------------------------------------
1211 # Checking for various library functions and other definitions
1212 #----------------------------------------------------------------------------
1214 # Check for AT_FDCWD
1216 AC_MSG_CHECKING([for AT_FDCWD])
1217 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1218 #define _GNU_SOURCE
1219 #include <fcntl.h>
1220 #include <unistd.h>
1221 ]], [[
1222   int a = AT_FDCWD;
1223 ]])], [
1224 ac_have_at_fdcwd=yes
1225 AC_MSG_RESULT([yes])
1226 ], [
1227 ac_have_at_fdcwd=no
1228 AC_MSG_RESULT([no])
1231 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1233 # Check for stpncpy function definition in string.h
1234 # This explicitly checks with _GNU_SOURCE defined since that is also
1235 # used in the test case (some systems might define it without anyway
1236 # since stpncpy is part of The Open Group Base Specifications Issue 7
1237 # IEEE Std 1003.1-2008.
1238 AC_MSG_CHECKING([for stpncpy])
1239 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1240 #define _GNU_SOURCE
1241 #include <string.h>
1242 ]], [[
1243   char *d;
1244   char *s;
1245   size_t n = 0;
1246   char *r = stpncpy(d, s, n);
1247 ]])], [
1248 ac_have_gnu_stpncpy=yes
1249 AC_MSG_RESULT([yes])
1250 ], [
1251 ac_have_gnu_stpncpy=no
1252 AC_MSG_RESULT([no])
1255 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1257 # Check for PTRACE_GETREGS
1259 AC_MSG_CHECKING([for PTRACE_GETREGS])
1260 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1261 #include <stdlib.h>
1262 #include <stddef.h>
1263 #include <sys/ptrace.h>
1264 #include <sys/user.h>
1265 ]], [[
1266   void *p;
1267   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1268 ]])], [
1269 AC_MSG_RESULT([yes])
1270 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1271           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1272 ], [
1273 AC_MSG_RESULT([no])
1277 # Check for CLOCK_MONOTONIC
1279 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1281 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1282 #include <time.h>
1283 ]], [[
1284   struct timespec t;
1285   clock_gettime(CLOCK_MONOTONIC, &t);
1286   return 0;
1287 ]])], [
1288 AC_MSG_RESULT([yes])
1289 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1290           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1291 ], [
1292 AC_MSG_RESULT([no])
1296 # Check for ELF32/64_CHDR
1298 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1301 # Check for PTHREAD_RWLOCK_T
1303 AC_MSG_CHECKING([for pthread_rwlock_t])
1305 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1306 #define _GNU_SOURCE
1307 #include <pthread.h>
1308 ]], [[
1309   pthread_rwlock_t rwl;
1310 ]])], [
1311 AC_MSG_RESULT([yes])
1312 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1313           [Define to 1 if you have the `pthread_rwlock_t' type.])
1314 ], [
1315 AC_MSG_RESULT([no])
1319 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1321 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1323 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1324 #define _GNU_SOURCE
1325 #include <pthread.h>
1326 ]], [[
1327   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1328 ]])], [
1329 AC_MSG_RESULT([yes])
1330 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1331           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1332 ], [
1333 AC_MSG_RESULT([no])
1337 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1339 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1341 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1342 #define _GNU_SOURCE
1343 #include <pthread.h>
1344 ]], [[
1345   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1346 ]])], [
1347 AC_MSG_RESULT([yes])
1348 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1349           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1350 ], [
1351 AC_MSG_RESULT([no])
1355 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1357 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1360 #define _GNU_SOURCE
1361 #include <pthread.h>
1362 ]], [[
1363   return (PTHREAD_MUTEX_RECURSIVE_NP);
1364 ]])], [
1365 AC_MSG_RESULT([yes])
1366 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1367           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1368 ], [
1369 AC_MSG_RESULT([no])
1373 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1375 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1377 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1378 #define _GNU_SOURCE
1379 #include <pthread.h>
1380 ]], [[
1381   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1382   return 0;
1383 ]])], [
1384 AC_MSG_RESULT([yes])
1385 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1386           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1387 ], [
1388 AC_MSG_RESULT([no])
1392 # Check whether pthread_mutex_t has a member called __m_kind.
1394 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1395                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1396                            1,                                   
1397                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1398                 ],
1399                 [],
1400                 [#include <pthread.h>])
1403 # Check whether pthread_mutex_t has a member called __data.__kind.
1405 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1406                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1407                           1,
1408                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1409                 ],
1410                 [],
1411                 [#include <pthread.h>])
1413 # Convenience function.  Set flags based on the existing HWCAP entries.
1414 # The AT_HWCAP entries are generated by glibc, and are based on
1415 # functions supported by the hardware/system/libc.
1416 # Subsequent support for whether the capability will actually be utilized
1417 # will also be checked against the compiler capabilities.
1418 # called as
1419 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1420 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1421   AUXV_CHECK_FOR=$1
1422   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1423   if LD_SHOW_AUXV=1 `which true` | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1424   then
1425     AC_MSG_RESULT([yes])
1426     AC_SUBST([$2],[yes])
1427   else
1428     AC_MSG_RESULT([no])
1429     AC_SUBST([$2],[])
1430   fi
1433 # gather hardware capabilities. (hardware/kernel/libc)
1434 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1435 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1436 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1437 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1438 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1439 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1440 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1441 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1443 # ISA Levels
1444 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1445 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1446 # compiler support for isa 2.07 level instructions
1447 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1448 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1449 ]], [[
1450   __asm__ __volatile__("mtvsrd 1,2 ");
1451 ]])], [
1452 ac_asm_have_isa_2_07=yes
1453 AC_MSG_RESULT([yes])
1454 ], [
1455 ac_asm_have_isa_2_07=no
1456 AC_MSG_RESULT([no])
1458 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1459                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1461 # altivec (vsx) support.
1462 # does this compiler support -maltivec and does it have the include file
1463 # <altivec.h> ?
1464 AC_MSG_CHECKING([for Altivec support in the compiler ])
1465 safe_CFLAGS=$CFLAGS
1466 CFLAGS="-maltivec -Werror"
1467 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1468 #include <altivec.h>
1469 ]], [[
1470   vector unsigned int v;
1471 ]])], [
1472 ac_have_altivec=yes
1473 AC_MSG_RESULT([yes])
1474 ], [
1475 ac_have_altivec=no
1476 AC_MSG_RESULT([no])
1478 CFLAGS=$safe_CFLAGS
1479 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1480                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1482 # Check that both: the compiler supports -mvsx and that the assembler
1483 # understands VSX instructions.  If either of those doesn't work,
1484 # conclude that we can't do VSX.
1485 AC_MSG_CHECKING([for VSX compiler flag support])
1486 safe_CFLAGS=$CFLAGS
1487 CFLAGS="-mvsx -Werror"
1488 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1489 ]], [[
1490 ]])], [
1491 ac_compiler_supports_vsx_flag=yes
1492 AC_MSG_RESULT([yes])
1493 ], [
1494 ac_compiler_supports_vsx_flag=no
1495 AC_MSG_RESULT([no])
1497 CFLAGS=$safe_CFLAGS
1499 AC_MSG_CHECKING([for VSX support in the assembler ])
1500 safe_CFLAGS=$CFLAGS
1501 CFLAGS="-mvsx -Werror"
1502 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1503 #include <altivec.h>
1504 ]], [[
1505   vector unsigned int v;
1506   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1507 ]])], [
1508 ac_compiler_supports_vsx=yes
1509 AC_MSG_RESULT([yes])
1510 ], [
1511 ac_compiler_supports_vsx=no
1512 AC_MSG_RESULT([no])
1514 CFLAGS=$safe_CFLAGS
1515 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1516                              -a x$ac_compiler_supports_vsx = xyes \
1517                              -a x$HWCAP_HAS_VSX = xyes ])
1519 # DFP (Decimal Float)
1520 AC_MSG_CHECKING([that assembler knows DFP])
1521 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1522 ]], [[
1523   #ifdef __s390__
1524   __asm__ __volatile__("adtr 1, 2, 3")
1525   #else
1526   __asm__ __volatile__("dadd 1, 2, 3");
1527   __asm__ __volatile__("dcffix 1, 2");
1528   #endif
1529 ]])], [
1530 ac_asm_have_dfp=yes
1531 AC_MSG_RESULT([yes])
1532 ], [
1533 ac_asm_have_dfp=no
1534 AC_MSG_RESULT([no])
1536 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1537 safe_CFLAGS=$CFLAGS
1538 CFLAGS="-mhard-dfp -Werror"
1539 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1540 ]], [[
1541   #ifdef __s390__
1542   __asm__ __volatile__("adtr 1, 2, 3")
1543   #else
1544   __asm__ __volatile__("dadd 1, 2, 3");
1545   __asm__ __volatile__("dcffix 1, 2");
1546   #endif
1547 ]])], [
1548 ac_compiler_have_dfp=yes
1549 AC_MSG_RESULT([yes])
1550 ], [
1551 ac_compiler_have_dfp=no
1552 AC_MSG_RESULT([no])
1554 CFLAGS=$safe_CFLAGS
1555 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1556                           -a x$ac_compiler_have_dfp = xyes \
1557                           -a x$HWCAP_HAS_DFP = xyes )
1559 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1560 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1561 ]], [[
1562   _Decimal64 x = 0.0DD;
1563 ]])], [
1564 ac_compiler_have_dfp_type=yes
1565 AC_MSG_RESULT([yes])
1566 ], [
1567 ac_compiler_have_dfp_type=no
1568 AC_MSG_RESULT([no])
1570 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1571                                   -a x$HWCAP_HAS_DFP = xyes )
1574 # HTM (Hardware Transactional Memory)
1575 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1576 safe_CFLAGS=$CFLAGS
1577 CFLAGS="-mhtm -Werror"
1578 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1579 ]], [[
1580   return 0;
1581 ]])], [
1582 AC_MSG_RESULT([yes])
1583 ac_compiler_supports_htm=yes
1584 ], [
1585 AC_MSG_RESULT([no])
1586 ac_compiler_supports_htm=no
1588 CFLAGS=$safe_CFLAGS
1590 AC_MSG_CHECKING([if compiler can find the htm builtins])
1591 safe_CFLAGS=$CFLAGS
1592 CFLAGS="-mhtm -Werror"
1593  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1594  ]], [[
1595    if (__builtin_tbegin (0))
1596       __builtin_tend (0);
1597  ]])], [
1598  AC_MSG_RESULT([yes])
1599 ac_compiler_sees_htm_builtins=yes
1600  ], [
1601  AC_MSG_RESULT([no])
1602 ac_compiler_sees_htm_builtins=no
1603  ])
1604 CFLAGS=$safe_CFLAGS
1606 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1607                                -a x$ac_compiler_sees_htm_builtins = xyes \
1608                                -a x$HWCAP_HAS_HTM = xyes )
1610 # isa 3.0 checking
1611 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1613 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1614 ]], [[
1615   __asm__ __volatile__("cnttzw 1,2 ");
1616 ]])], [
1617 ac_asm_have_isa_3_00=yes
1618 AC_MSG_RESULT([yes])
1619 ], [
1620 ac_asm_have_isa_3_00=no
1621 AC_MSG_RESULT([no])
1624 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1625                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1627 # Check for pthread_create@GLIBC2.0
1628 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1630 safe_CFLAGS=$CFLAGS
1631 CFLAGS="-lpthread -Werror"
1632 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1633 extern int pthread_create_glibc_2_0(void*, const void*,
1634                                     void *(*)(void*), void*);
1635 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1636 ]], [[
1637 #ifdef __powerpc__
1639  * Apparently on PowerPC linking this program succeeds and generates an
1640  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1641  */
1642 #error This test does not work properly on PowerPC.
1643 #else
1644   pthread_create_glibc_2_0(0, 0, 0, 0);
1645 #endif
1646   return 0;
1647 ]])], [
1648 ac_have_pthread_create_glibc_2_0=yes
1649 AC_MSG_RESULT([yes])
1650 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1651           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1652 ], [
1653 ac_have_pthread_create_glibc_2_0=no
1654 AC_MSG_RESULT([no])
1656 CFLAGS=$safe_CFLAGS
1658 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1659                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1662 # Check for dlinfo RTLD_DI_TLS_MODID
1663 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1665 safe_LIBS="$LIBS"
1666 LIBS="-ldl"
1667 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1668 #ifndef _GNU_SOURCE
1669 #define _GNU_SOURCE
1670 #endif
1671 #include <link.h>
1672 #include <dlfcn.h>
1673 ]], [[
1674   size_t sizes[10000];
1675   size_t modid_offset;
1676   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1677   return 0;
1678 ]])], [
1679 ac_have_dlinfo_rtld_di_tls_modid=yes
1680 AC_MSG_RESULT([yes])
1681 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1682           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1683 ], [
1684 ac_have_dlinfo_rtld_di_tls_modid=no
1685 AC_MSG_RESULT([no])
1687 LIBS=$safe_LIBS
1689 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1690                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1693 # Check for eventfd_t, eventfd() and eventfd_read()
1694 AC_MSG_CHECKING([for eventfd()])
1696 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1697 #include <sys/eventfd.h>
1698 ]], [[
1699   eventfd_t ev;
1700   int fd;
1702   fd = eventfd(5, 0);
1703   eventfd_read(fd, &ev);
1704   return 0;
1705 ]])], [
1706 AC_MSG_RESULT([yes])
1707 AC_DEFINE([HAVE_EVENTFD], 1,
1708           [Define to 1 if you have the `eventfd' function.])
1709 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1710           [Define to 1 if you have the `eventfd_read' function.])
1711 ], [
1712 AC_MSG_RESULT([no])
1715 # Check whether compiler can process #include <thread> without errors
1716 # clang 3.3 cannot process <thread> from e.g.
1717 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1719 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1720 AC_LANG(C++)
1721 safe_CXXFLAGS=$CXXFLAGS
1722 CXXFLAGS=-std=c++0x
1724 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1725 #include <thread> 
1726 ])],
1728 ac_cxx_can_include_thread_header=yes
1729 AC_MSG_RESULT([yes])
1730 ], [
1731 ac_cxx_can_include_thread_header=no
1732 AC_MSG_RESULT([no])
1734 CXXFLAGS=$safe_CXXFLAGS
1735 AC_LANG(C)
1737 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1740 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1741 # of the user_regs_struct from sys/user.h. They are structurally the same
1742 # but we get either one or the other.
1744 AC_CHECK_TYPE([struct user_regs_struct],
1745               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1746               [[#include <sys/ptrace.h>]
1747                [#include <sys/time.h>]
1748                [#include <sys/user.h>]])
1749 if test "$sys_user_has_user_regs" = "yes"; then
1750   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1751             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1754 AC_MSG_CHECKING([for __NR_membarrier])
1755 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1756 #include <linux/unistd.h>
1757 ]], [[
1758 return __NR_membarrier
1759 ]])], [
1760 ac_have_nr_membarrier=yes
1761 AC_MSG_RESULT([yes])
1762 ], [
1763 ac_have_nr_membarrier=no
1764 AC_MSG_RESULT([no])
1767 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
1769 #----------------------------------------------------------------------------
1770 # Checking for supported compiler flags.
1771 #----------------------------------------------------------------------------
1773 case "${host_cpu}" in
1774     mips*)
1775         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1776         if test -z "$ARCH"; then
1777           # does this compiler support -march=mips32 (mips32 default) ?
1778           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
1780           safe_CFLAGS=$CFLAGS
1781           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
1783           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1784             return 0;
1785           ]])], [
1786           FLAG_M32="-mips32 -mabi=32"
1787           AC_MSG_RESULT([yes])
1788           ], [
1789           FLAG_M32=""
1790           AC_MSG_RESULT([no])
1791           ])
1792           CFLAGS=$safe_CFLAGS
1794           AC_SUBST(FLAG_M32)
1797           # does this compiler support -march=mips64r2 (mips64r2 default) ?
1798           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
1800           safe_CFLAGS=$CFLAGS
1801           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
1803           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1804             return 0;
1805           ]])], [
1806           FLAG_M64="-march=mips64r2 -mabi=64"
1807           AC_MSG_RESULT([yes])
1808           ], [
1809           FLAG_M64=""
1810           AC_MSG_RESULT([no])
1811           ])
1812           CFLAGS=$safe_CFLAGS
1814           AC_SUBST(FLAG_M64)
1815         fi
1816         ;;
1817     *)
1818         # does this compiler support -m32 ?
1819         AC_MSG_CHECKING([if gcc accepts -m32])
1821         safe_CFLAGS=$CFLAGS
1822         CFLAGS="-m32 -Werror"
1824         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1825           return 0;
1826         ]])], [
1827         FLAG_M32="-m32"
1828         AC_MSG_RESULT([yes])
1829         ], [
1830         FLAG_M32=""
1831         AC_MSG_RESULT([no])
1832         ])
1833         CFLAGS=$safe_CFLAGS
1835         AC_SUBST(FLAG_M32)
1838         # does this compiler support -m64 ?
1839         AC_MSG_CHECKING([if gcc accepts -m64])
1841         safe_CFLAGS=$CFLAGS
1842         CFLAGS="-m64 -Werror"
1844         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1845           return 0;
1846         ]])], [
1847         FLAG_M64="-m64"
1848         AC_MSG_RESULT([yes])
1849         ], [
1850         FLAG_M64=""
1851         AC_MSG_RESULT([no])
1852         ])
1853         CFLAGS=$safe_CFLAGS
1855         AC_SUBST(FLAG_M64)
1856         ;;
1857 esac
1860 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1861 if test -z "$ARCH"; then
1862   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1863   AC_MSG_CHECKING([if gcc accepts -march=octeon])
1865   safe_CFLAGS=$CFLAGS
1866   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
1868   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1869     return 0;
1870   ]])], [
1871   FLAG_OCTEON="-march=octeon"
1872   AC_MSG_RESULT([yes])
1873   ], [
1874   FLAG_OCTEON=""
1875   AC_MSG_RESULT([no])
1876   ])
1877   CFLAGS=$safe_CFLAGS
1879   AC_SUBST(FLAG_OCTEON)
1882   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1883   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1885   safe_CFLAGS=$CFLAGS
1886   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
1888   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1889     return 0;
1890   ]])], [
1891   FLAG_OCTEON2="-march=octeon2"
1892   AC_MSG_RESULT([yes])
1893   ], [
1894   FLAG_OCTEON2=""
1895   AC_MSG_RESULT([no])
1896   ])
1897   CFLAGS=$safe_CFLAGS
1899   AC_SUBST(FLAG_OCTEON2)
1903 # does this compiler support -mmsa (MIPS MSA ASE) ?
1904 AC_MSG_CHECKING([if gcc accepts -mmsa])
1906 safe_CFLAGS=$CFLAGS
1907 CFLAGS="$CFLAGS -mmsa -Werror"
1909 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1910     return 0;
1911 ]])], [
1912 FLAG_MSA="-mmsa"
1913 AC_MSG_RESULT([yes])
1914 ], [
1915 FLAG_MSA=""
1916 AC_MSG_RESULT([no])
1918 CFLAGS=$safe_CFLAGS
1920 AC_SUBST(FLAG_MSA)
1922 # Are we compiling for the MIPS64 n32 ABI?
1923 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
1924 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1925 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
1926 #error NO
1927 #endif
1928 ]])], [
1929 VGCONF_ABI=N32
1930 FLAG_M64="-march=mips64r2 -mabi=n32"
1931 AC_MSG_RESULT([yes])
1932 ], [
1933 AC_MSG_RESULT([no])
1936 # Are we compiling for the MIPS64 n64 ABI?
1937 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
1938 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1939 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
1940 #error NO
1941 #endif
1942 ]])], [
1943 VGCONF_ABI=64
1944 AC_MSG_RESULT([yes])
1945 ], [
1946 AC_MSG_RESULT([no])
1949 AM_CONDITIONAL([VGCONF_HAVE_ABI],
1950                [test x$VGCONF_ABI != x])
1951 AC_SUBST(VGCONF_ABI)
1954 # does this compiler support -mmmx ?
1955 AC_MSG_CHECKING([if gcc accepts -mmmx])
1957 safe_CFLAGS=$CFLAGS
1958 CFLAGS="-mmmx -Werror"
1960 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1961   return 0;
1962 ]])], [
1963 FLAG_MMMX="-mmmx"
1964 AC_MSG_RESULT([yes])
1965 ], [
1966 FLAG_MMMX=""
1967 AC_MSG_RESULT([no])
1969 CFLAGS=$safe_CFLAGS
1971 AC_SUBST(FLAG_MMMX)
1974 # does this compiler support -msse ?
1975 AC_MSG_CHECKING([if gcc accepts -msse])
1977 safe_CFLAGS=$CFLAGS
1978 CFLAGS="-msse -Werror"
1980 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1981   return 0;
1982 ]])], [
1983 FLAG_MSSE="-msse"
1984 AC_MSG_RESULT([yes])
1985 ], [
1986 FLAG_MSSE=""
1987 AC_MSG_RESULT([no])
1989 CFLAGS=$safe_CFLAGS
1991 AC_SUBST(FLAG_MSSE)
1994 # does this compiler support -mpreferred-stack-boundary=2 when
1995 # generating code for a 32-bit target?  Note that we only care about
1996 # this when generating code for (32-bit) x86, so if the compiler
1997 # doesn't recognise -m32 it's no big deal.  We'll just get code for
1998 # the Memcheck and other helper functions, that is a bit slower than
1999 # it could be, on x86; and no difference at all on any other platform.
2000 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2002 safe_CFLAGS=$CFLAGS
2003 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2005 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2006   return 0;
2007 ]])], [
2008 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2009 AC_MSG_RESULT([yes])
2010 ], [
2011 PREFERRED_STACK_BOUNDARY_2=""
2012 AC_MSG_RESULT([no])
2014 CFLAGS=$safe_CFLAGS
2016 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2019 # does this compiler support -mlong-double-128 ?
2020 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2021 safe_CFLAGS=$CFLAGS
2022 CFLAGS="-mlong-double-128 -Werror"
2023 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2024   return 0;
2025 ]])], [
2026 ac_compiler_supports_mlong_double_128=yes
2027 AC_MSG_RESULT([yes])
2028 ], [
2029 ac_compiler_supports_mlong_double_128=no
2030 AC_MSG_RESULT([no])
2032 CFLAGS=$safe_CFLAGS
2033 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2034 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2035 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2037 # does this toolchain support lto ?
2038 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2039 # are not defined
2040 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2041 # a lot slower, and so not appropriate for Valgrind developments.
2042 # --enable-lto=yes should be used by distro packagers.
2043 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2044    [AC_ARG_ENABLE(lto,
2045       [  --enable-lto          enables building with link time optimisation],
2046       [vg_cv_lto=$enableval],
2047       [vg_cv_lto=no])])
2049 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2050 AC_MSG_CHECKING([if toolchain accepts lto])
2051 safe_CFLAGS=$CFLAGS
2052 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2053 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2054 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2055 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2058   extern void somefun(void);
2059   somefun();
2060   return 0;
2061 ]])], [
2062 LTO_CFLAGS=$TEST_LTO_CFLAGS
2063 AC_MSG_RESULT([yes])
2064 ], [
2065 LTO_CFLAGS=""
2066 AC_MSG_RESULT([no])
2068 CFLAGS=$safe_CFLAGS
2071 AC_SUBST(LTO_CFLAGS)
2073 # if we could not compile with lto args, or lto was disabled,
2074 # then set LTO_AR/LTO_RANLIB to the non lto values
2075 # define in config.h ENABLE_LTO (not needed by the code currently, but
2076 # this guarantees we recompile everything if we re-configure and rebuild
2077 # in a build dir previously build with another value of --enable-lto
2078 if test "x${LTO_CFLAGS}" = "x"; then
2079    LTO_AR=${AR}
2080    LTO_RANLIB=${RANLIB}
2081    vg_cv_lto=no
2082 else
2083    vg_cv_lto=yes
2084    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2087 # Convenience function to check whether GCC supports a particular
2088 # warning option. Takes two arguments,
2089 # first the warning flag name to check (without -W), then the
2090 # substitution name to set with -Wno-warning-flag if the flag exists,
2091 # or the empty string if the compiler doesn't accept the flag. Note
2092 # that checking is done against the warning flag itself, but the
2093 # substitution is then done to cancel the warning flag.
2094 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2095   AC_MSG_CHECKING([if gcc accepts -W$1])
2096   safe_CFLAGS=$CFLAGS
2097   CFLAGS="-W$1 -Werror"
2098   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2099   AC_SUBST([$2], [-Wno-$1])
2100   AC_MSG_RESULT([yes])], [
2101   AC_SUBST([$2], [])
2102   AC_MSG_RESULT([no])])
2103   CFLAGS=$safe_CFLAGS
2106 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2107 # -W$1  (instead of -Wno-$1).
2108 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2109   AC_MSG_CHECKING([if gcc accepts -W$1])
2110   safe_CFLAGS=$CFLAGS
2111   CFLAGS="-W$1 -Werror"
2112   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2113   AC_SUBST([$2], [-W$1])
2114   AC_MSG_RESULT([yes])], [
2115   AC_SUBST([$2], [])
2116   AC_MSG_RESULT([no])])
2117   CFLAGS=$safe_CFLAGS
2120 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2121 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2122 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2123 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2124 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2125 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2126 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2127 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2128 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2130 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2131 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2132 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2133 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2134 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2135 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2136 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2137 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2138 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2139 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2140 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2142 # Does this compiler support -Wformat-security ?
2143 # Special handling is needed, because certain GCC versions require -Wformat
2144 # being present if -Wformat-security is given. Otherwise a warning is issued.
2145 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2146 # And with that the warning will be turned into an error with the result
2147 # that -Wformat-security is believed to be unsupported when in fact it is.
2148 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2149 safe_CFLAGS=$CFLAGS
2150 CFLAGS="-Wformat -Wformat-security -Werror"
2151 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2152 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2153 AC_MSG_RESULT([yes])], [
2154 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2155 AC_MSG_RESULT([no])])
2156 CFLAGS=$safe_CFLAGS
2158 # does this compiler support -Wextra or the older -W ?
2160 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2162 safe_CFLAGS=$CFLAGS
2163 CFLAGS="-Wextra -Werror"
2165 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2166   return 0;
2167 ]])], [
2168 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2169 AC_MSG_RESULT([-Wextra])
2170 ], [
2171   CFLAGS="-W -Werror"
2172   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2173     return 0;
2174   ]])], [
2175   AC_SUBST([FLAG_W_EXTRA], [-W])
2176   AC_MSG_RESULT([-W])
2177   ], [
2178   AC_SUBST([FLAG_W_EXTRA], [])
2179   AC_MSG_RESULT([not supported])
2180   ])
2182 CFLAGS=$safe_CFLAGS
2184 # On ARM we do not want to pass -Wcast-align as that produces loads
2185 # of warnings. GCC is just being conservative. See here:
2186 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2187 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2188   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2189 else
2190   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2193 # does this compiler support -faligned-new ?
2194 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2196 safe_CXXFLAGS=$CXXFLAGS
2197 CXXFLAGS="-faligned-new -Werror"
2199 AC_LANG(C++)
2200 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2201   return 0;
2202 ]])], [
2203 FLAG_FALIGNED_NEW="-faligned-new"
2204 AC_MSG_RESULT([yes])
2205 ], [
2206 FLAG_FALIGNED_NEW=""
2207 AC_MSG_RESULT([no])
2209 CXXFLAGS=$safe_CXXFLAGS
2210 AC_LANG(C)
2212 AC_SUBST(FLAG_FALIGNED_NEW)
2214 # does this compiler support -fno-stack-protector ?
2215 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2217 safe_CFLAGS=$CFLAGS
2218 CFLAGS="-fno-stack-protector -Werror"
2220 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2221   return 0;
2222 ]])], [
2223 no_stack_protector=yes
2224 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2225 AC_MSG_RESULT([yes])
2226 ], [
2227 no_stack_protector=no
2228 FLAG_FNO_STACK_PROTECTOR=""
2229 AC_MSG_RESULT([no])
2231 CFLAGS=$safe_CFLAGS
2233 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2235 # does this compiler support -finline-functions ?
2236 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2238 safe_CFLAGS=$CFLAGS
2239 CFLAGS="-finline-functions -Werror"
2241 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2242   return 0;
2243 ]])], [
2244 inline_functions=yes
2245 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2246 AC_MSG_RESULT([yes])
2247 ], [
2248 inline_functions=no
2249 FLAG_FINLINE_FUNCTIONS=""
2250 AC_MSG_RESULT([no])
2252 CFLAGS=$safe_CFLAGS
2254 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2256 # Does GCC support disabling Identical Code Folding?
2257 # We want to disabled Identical Code Folding for the
2258 # tools preload shared objects to get better backraces.
2259 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2260 # "The optimization reduces code size and may disturb
2261 #  unwind stacks by replacing a function by equivalent
2262 #  one with a different name."
2263 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2265 safe_CFLAGS=$CFLAGS
2266 CFLAGS="-fno-ipa-icf -Werror"
2268 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2269   return 0;
2270 ]])], [
2271 no_ipa_icf=yes
2272 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2273 AC_MSG_RESULT([yes])
2274 ], [
2275 no_ipa_icf=no
2276 FLAG_FNO_IPA_ICF=""
2277 AC_MSG_RESULT([no])
2279 CFLAGS=$safe_CFLAGS
2281 AC_SUBST(FLAG_FNO_IPA_ICF)
2284 # Does this compiler support -fsanitize=undefined. This is true for
2285 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2286 # also checks for alignment violations on memory accesses which the valgrind
2287 # code base is sprinkled (if not littered) with. As those alignment issues
2288 # don't pose a problem we want to suppress warnings about them.
2289 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2290 # GCCs do not support that.
2292 # Only checked for if --enable-ubsan was given.
2293 if test "x${vg_cv_ubsan}" = "xyes"; then
2294 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2295 safe_CFLAGS=$CFLAGS
2296 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2298   return 0;
2299 ]])], [
2300 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2301 LIB_UBSAN="-static-libubsan"
2302 AC_MSG_RESULT([yes])
2303 ], [
2304 CFLAGS="-fsanitize=undefined -Werror"
2305 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2306   return 0;
2307 ]])], [
2308 FLAG_FSANITIZE="-fsanitize=undefined"
2309 LIB_UBSAN="-static-libubsan"
2310 AC_MSG_RESULT([yes])
2311 ], [
2312 FLAG_FSANITIZE=""
2313 LIB_UBSAN=""
2314 AC_MSG_RESULT([no])
2317 CFLAGS=$safe_CFLAGS
2318 AC_SUBST(FLAG_FSANITIZE)
2319 AC_SUBST(LIB_UBSAN)
2321 # does this compiler support --param inline-unit-growth=... ?
2323 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2325 safe_CFLAGS=$CFLAGS
2326 CFLAGS="--param inline-unit-growth=900 -Werror"
2328 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2329   return 0;
2330 ]])], [
2331 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2332          ["--param inline-unit-growth=900"])
2333 AC_MSG_RESULT([yes])
2334 ], [
2335 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2336 AC_MSG_RESULT([no])
2338 CFLAGS=$safe_CFLAGS
2341 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2343 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2345 safe_CFLAGS=$CFLAGS
2346 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2348 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2349   return 0;
2350 ]])], [
2351 ac_have_dwarf4=yes
2352 AC_MSG_RESULT([yes])
2353 ], [
2354 ac_have_dwarf4=no
2355 AC_MSG_RESULT([no])
2357 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2358 CFLAGS=$safe_CFLAGS
2361 # does this compiler support -g -gz=zlib ?
2363 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2365 safe_CFLAGS=$CFLAGS
2366 CFLAGS="-g -gz=zlib"
2368 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2369   return 0;
2370 ]])], [
2371 ac_have_gz_zlib=yes
2372 AC_MSG_RESULT([yes])
2373 ], [
2374 ac_have_gz_zlib=no
2375 AC_MSG_RESULT([no])
2377 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2378 CFLAGS=$safe_CFLAGS
2381 # does this compiler support -g -gz=zlib-gnu ?
2383 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2385 safe_CFLAGS=$CFLAGS
2386 CFLAGS="-g -gz=zlib-gnu"
2388 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2389   return 0;
2390 ]])], [
2391 ac_have_gz_zlib_gnu=yes
2392 AC_MSG_RESULT([yes])
2393 ], [
2394 ac_have_gz_zlib_gnu=no
2395 AC_MSG_RESULT([no])
2397 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2398 CFLAGS=$safe_CFLAGS
2401 # does this compiler support nested functions ?
2403 AC_MSG_CHECKING([if gcc accepts nested functions])
2405 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2406   int foo() { return 1; }
2407   return foo();
2408 ]])], [
2409 ac_have_nested_functions=yes
2410 AC_MSG_RESULT([yes])
2411 ], [
2412 ac_have_nested_functions=no
2413 AC_MSG_RESULT([no])
2415 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2418 # does this compiler support the 'p' constraint in ASM statements ?
2420 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2422 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2423    char *p;
2424    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2425 ]])], [
2426 ac_have_asm_constraint_p=yes
2427 AC_MSG_RESULT([yes])
2428 ], [
2429 ac_have_asm_constraint_p=no
2430 AC_MSG_RESULT([no])
2432 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2435 # Does this compiler and linker support -pie?
2436 # Some compilers actually do not support -pie and report its usage
2437 # as an error. We need to check if it is safe to use it first.
2439 AC_MSG_CHECKING([if gcc accepts -pie])
2441 safe_CFLAGS=$CFLAGS
2442 CFLAGS="-pie"
2444 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2445   return 0;
2446 ]])], [
2447 AC_SUBST([FLAG_PIE], ["-pie"])
2448 AC_MSG_RESULT([yes])
2449 ], [
2450 AC_SUBST([FLAG_PIE], [""])
2451 AC_MSG_RESULT([no])
2453 CFLAGS=$safe_CFLAGS
2456 # Does this compiler support -no-pie?
2457 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2458 # default. However this gets in the way with some tests, we use -no-pie
2459 # for these.
2461 AC_MSG_CHECKING([if gcc accepts -no-pie])
2463 safe_CFLAGS=$CFLAGS
2464 CFLAGS="-no-pie"
2466 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2467   return 0;
2468 ]])], [
2469 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2470 AC_MSG_RESULT([yes])
2471 ], [
2472 AC_SUBST([FLAG_NO_PIE], [""])
2473 AC_MSG_RESULT([no])
2475 CFLAGS=$safe_CFLAGS
2478 # We want to use use the -Ttext-segment option to the linker.
2479 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2480 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2481 # semantics are NOT what we want (GNU gold -Ttext is fine).
2483 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2484 # will reside. -Ttext aligns just the .text section start (but not any
2485 # other section).
2487 # So test for -Ttext-segment which is supported by all bfd ld versions
2488 # and use that if it exists. If it doesn't exist it must be an older
2489 # version of gold and we can fall back to using -Ttext which has the
2490 # right semantics.
2492 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2494 safe_CFLAGS=$CFLAGS
2495 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2497 AC_LINK_IFELSE(
2498 [AC_LANG_SOURCE([int _start () { return 0; }])],
2500   linker_using_t_text="no"
2501   AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2502   AC_MSG_RESULT([yes])
2503 ], [
2504   linker_using_t_text="yes"
2505   AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2506   AC_MSG_RESULT([no])
2508 CFLAGS=$safe_CFLAGS
2510 # If the linker only supports -Ttext (not -Ttext-segment) then we will
2511 # have to strip any build-id ELF NOTEs from the statically linked tools.
2512 # Otherwise the build-id NOTE might end up at the default load address.
2513 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2514 # gold versions also support -Ttext-segment. So just assume that unless
2515 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2516 if test "x${linker_using_t_text}" = "xyes"; then
2517 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2518 # does the linker support -Wl,--build-id=none ?  Note, it's
2519 # important that we test indirectly via whichever C compiler
2520 # is selected, rather than testing /usr/bin/ld or whatever
2521 # directly.
2522 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2523 safe_CFLAGS=$CFLAGS
2524 CFLAGS="-Wl,--build-id=none -Werror"
2526 AC_LINK_IFELSE(
2527 [AC_LANG_PROGRAM([ ], [return 0;])],
2529   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2530   AC_MSG_RESULT([yes])
2531 ], [
2532   AC_SUBST([FLAG_NO_BUILD_ID], [""])
2533   AC_MSG_RESULT([no])
2535 else
2536 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2537 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2539 CFLAGS=$safe_CFLAGS
2541 # does the ppc assembler support "mtocrf" et al?
2542 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2544 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2545 __asm__ __volatile__("mtocrf 4,0");
2546 __asm__ __volatile__("mfocrf 0,4");
2547 ]])], [
2548 ac_have_as_ppc_mftocrf=yes
2549 AC_MSG_RESULT([yes])
2550 ], [
2551 ac_have_as_ppc_mftocrf=no
2552 AC_MSG_RESULT([no])
2554 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2555   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2559 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2560 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2563   do { typedef struct {
2564       double hi;
2565       double lo;
2566      } dbl_pair_t;
2567      dbl_pair_t dbl_pair[3];
2568      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2569    } while (0)
2570 ]])], [
2571 ac_have_as_ppc_fpPO=yes
2572 AC_MSG_RESULT([yes])
2573 ], [
2574 ac_have_as_ppc_fpPO=no
2575 AC_MSG_RESULT([no])
2577 if test x$ac_have_as_ppc_fpPO = xyes ; then
2578   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2582 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2583 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2586 void* p;
2587 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2588 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2589 ]])], [
2590 ac_have_as_amd64_fxsave64=yes
2591 AC_MSG_RESULT([yes])
2592 ], [
2593 ac_have_as_amd64_fxsave64=no
2594 AC_MSG_RESULT([no])
2596 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2597   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2600 # does the x86/amd64 assembler understand SSE3 instructions?
2601 # Note, this doesn't generate a C-level symbol.  It generates a
2602 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2603 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2605 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2606   do { long long int x; 
2607      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
2608   while (0)
2609 ]])], [
2610 ac_have_as_sse3=yes
2611 AC_MSG_RESULT([yes])
2612 ], [
2613 ac_have_as_sse3=no
2614 AC_MSG_RESULT([no])
2617 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2620 # Ditto for SSSE3 instructions (note extra S)
2621 # Note, this doesn't generate a C-level symbol.  It generates a
2622 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2623 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2625 save_CFLAGS="$CFLAGS"
2626 CFLAGS="$CFLAGS -msse -Werror"
2627 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2628   do { long long int x; 
2629    __asm__ __volatile__(
2630       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2631   while (0)
2632 ]])], [
2633 ac_have_as_ssse3=yes
2634 AC_MSG_RESULT([yes])
2635 ], [
2636 ac_have_as_ssse3=no
2637 AC_MSG_RESULT([no])
2639 CFLAGS="$save_CFLAGS"
2641 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2644 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2645 # Note, this doesn't generate a C-level symbol.  It generates a
2646 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2647 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2648 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2649   do {
2650    __asm__ __volatile__(
2651       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2652   while (0)
2653 ]])], [
2654 ac_have_as_pclmulqdq=yes
2655 AC_MSG_RESULT([yes])
2656 ], [
2657 ac_have_as_pclmulqdq=no
2658 AC_MSG_RESULT([no])
2661 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2664 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2665 # Note, this doesn't generate a C-level symbol.  It generates a
2666 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2667 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2668 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2669   do {
2670       /*
2671        * Carry-less multiplication of xmm1 with xmm2 and store the result in
2672        * xmm3. The immediate is used to determine which quadwords of xmm1 and
2673        * xmm2 should be used.
2674        */
2675    __asm__ __volatile__(
2676       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2677   } while (0)
2678 ]])], [
2679 ac_have_as_vpclmulqdq=yes
2680 AC_MSG_RESULT([yes])
2681 ], [
2682 ac_have_as_vpclmulqdq=no
2683 AC_MSG_RESULT([no])
2686 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2689 # does the x86/amd64 assembler understand FMA4 instructions?
2690 # Note, this doesn't generate a C-level symbol.  It generates a
2691 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
2692 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
2693 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2694   do {
2695    __asm__ __volatile__(
2696       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
2697   } while (0)
2698 ]])], [
2699 ac_have_as_vfmaddpd=yes
2700 AC_MSG_RESULT([yes])
2701 ], [
2702 ac_have_as_vfmaddpd=no
2703 AC_MSG_RESULT([no])
2706 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
2709 # does the x86/amd64 assembler understand the LZCNT instruction?
2710 # Note, this doesn't generate a C-level symbol.  It generates a
2711 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2712 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2714 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2715   do {           
2716       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2717   } while (0)
2718 ]])], [
2719   ac_have_as_lzcnt=yes
2720   AC_MSG_RESULT([yes])
2721 ], [
2722   ac_have_as_lzcnt=no
2723   AC_MSG_RESULT([no])
2726 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2729 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2730 # Note, this doesn't generate a C-level symbol.  It generates a
2731 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2732 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2734 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2735   do {           
2736       __asm__ __volatile__("1:  loopnel 1b\n");
2737   } while (0)
2738 ]])], [
2739   ac_have_as_loopnel=yes
2740   AC_MSG_RESULT([yes])
2741 ], [
2742   ac_have_as_loopnel=no
2743   AC_MSG_RESULT([no])
2746 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2749 # does the x86/amd64 assembler understand ADDR32 ?
2750 # Note, this doesn't generate a C-level symbol.  It generates a
2751 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2752 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2754 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2755   do {           
2756       asm volatile ("addr32 rep movsb");
2757   } while (0)
2758 ]])], [
2759   ac_have_as_addr32=yes
2760   AC_MSG_RESULT([yes])
2761 ], [
2762   ac_have_as_addr32=no
2763   AC_MSG_RESULT([no])
2766 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2769 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2770 # Note, this doesn't generate a C-level symbol.  It generates a
2771 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2772 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2774 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2775   do { long long int x; 
2776    __asm__ __volatile__(
2777       "crc32q %%r15,%%r15" : : : "r15" );
2778    __asm__ __volatile__(
2779       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
2780    __asm__ __volatile__(
2781       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2782   while (0)
2783 ]])], [
2784 ac_have_as_sse42=yes
2785 AC_MSG_RESULT([yes])
2786 ], [
2787 ac_have_as_sse42=no
2788 AC_MSG_RESULT([no])
2791 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2794 # does the x86/amd64 assembler understand AVX instructions?
2795 # Note, this doesn't generate a C-level symbol.  It generates a
2796 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2797 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2799 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2800   do { long long int x; 
2801    __asm__ __volatile__(
2802       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2803    __asm__ __volatile__(
2804       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2805   while (0)
2806 ]])], [
2807 ac_have_as_avx=yes
2808 AC_MSG_RESULT([yes])
2809 ], [
2810 ac_have_as_avx=no
2811 AC_MSG_RESULT([no])
2814 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2817 # does the x86/amd64 assembler understand AVX2 instructions?
2818 # Note, this doesn't generate a C-level symbol.  It generates a
2819 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2820 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2822 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2823   do { long long int x; 
2824    __asm__ __volatile__(
2825       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2826    __asm__ __volatile__(
2827       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2828   while (0)
2829 ]])], [
2830 ac_have_as_avx2=yes
2831 AC_MSG_RESULT([yes])
2832 ], [
2833 ac_have_as_avx2=no
2834 AC_MSG_RESULT([no])
2837 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2840 # does the x86/amd64 assembler understand TSX instructions and
2841 # the XACQUIRE/XRELEASE prefixes?
2842 # Note, this doesn't generate a C-level symbol.  It generates a
2843 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2844 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2846 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2847   do {
2848    __asm__ __volatile__(
2849       "       xbegin Lfoo  \n\t"
2850       "Lfoo:  xend         \n\t"
2851       "       xacquire lock incq 0(%rsp)     \n\t"
2852       "       xrelease lock incq 0(%rsp)     \n"
2853    );
2854   } while (0)
2855 ]])], [
2856 ac_have_as_tsx=yes
2857 AC_MSG_RESULT([yes])
2858 ], [
2859 ac_have_as_tsx=no
2860 AC_MSG_RESULT([no])
2863 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2866 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2867 # Note, this doesn't generate a C-level symbol.  It generates a
2868 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2869 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2871 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2872   do { unsigned int h, l;
2873    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2874    __asm__ __volatile__(
2875       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2876    __asm__ __volatile__(
2877       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2878   while (0)
2879 ]])], [
2880 ac_have_as_bmi=yes
2881 AC_MSG_RESULT([yes])
2882 ], [
2883 ac_have_as_bmi=no
2884 AC_MSG_RESULT([no])
2887 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2890 # does the x86/amd64 assembler understand FMA instructions?
2891 # Note, this doesn't generate a C-level symbol.  It generates a
2892 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2893 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2895 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2896   do { unsigned int h, l;
2897    __asm__ __volatile__(
2898       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2899    __asm__ __volatile__(
2900       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2901    __asm__ __volatile__(
2902       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2903   while (0)
2904 ]])], [
2905 ac_have_as_fma=yes
2906 AC_MSG_RESULT([yes])
2907 ], [
2908 ac_have_as_fma=no
2909 AC_MSG_RESULT([no])
2912 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2915 # does the amd64 assembler understand MPX instructions?
2916 # Note, this doesn't generate a C-level symbol.  It generates a
2917 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2918 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2920 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2921   do {
2922     asm ("bndmov %bnd0,(%rsp)");
2923     asm ("bndldx 3(%rbx,%rdx), %bnd2");
2924     asm ("bnd call foo\n"
2925           bnd jmp  end\n"
2926           foo: bnd ret\n"
2927           end: nop");
2928   } while (0)
2929 ]])], [
2930 ac_have_as_mpx=yes
2931 AC_MSG_RESULT([yes])
2932 ], [
2933 ac_have_as_mpx=no
2934 AC_MSG_RESULT([no])
2937 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2940 # does the amd64 assembler understand ADX instructions?
2941 # Note, this doesn't generate a C-level symbol.  It generates a
2942 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
2943 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
2945 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2946   do {
2947     asm ("adcxq %r14,%r8");
2948   } while (0)
2949 ]])], [
2950 ac_have_as_adx=yes
2951 AC_MSG_RESULT([yes])
2952 ], [
2953 ac_have_as_adx=no
2954 AC_MSG_RESULT([no])
2957 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
2960 # does the amd64 assembler understand the RDRAND instruction?
2961 # Note, this doesn't generate a C-level symbol.  It generates a
2962 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
2963 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
2965 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2966   do {
2967     asm ("rdrand %r14");
2968     asm ("rdrand %r14d");
2969     asm ("rdrand %r14w");
2970   } while (0)
2971 ]])], [
2972 ac_have_as_rdrand=yes
2973 AC_MSG_RESULT([yes])
2974 ], [
2975 ac_have_as_rdrand=no
2976 AC_MSG_RESULT([no])
2979 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
2982 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
2983 # VCVTPS2PH) ?
2984 # Note, this doesn't generate a C-level symbol.  It generates a
2985 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
2986 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
2988 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2989   do {
2990     asm ("vcvtph2ps %xmm5, %ymm10");
2991     // If we put the dollar sign and zero together, the shell processing
2992     // this configure.ac script substitutes the command name in.  Sigh.
2993     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
2994   } while (0)
2995 ]])], [
2996 ac_have_as_f16c=yes
2997 AC_MSG_RESULT([yes])
2998 ], [
2999 ac_have_as_f16c=no
3000 AC_MSG_RESULT([no])
3003 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3006 # does the x86/amd64 assembler understand MOVBE?
3007 # Note, this doesn't generate a C-level symbol.  It generates a
3008 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3009 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3011 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3012   do { long long int x; 
3013    __asm__ __volatile__(
3014       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3015   while (0)
3016 ]])], [
3017 ac_have_as_movbe=yes
3018 AC_MSG_RESULT([yes])
3019 ], [
3020 ac_have_as_movbe=no
3021 AC_MSG_RESULT([no])
3024 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3027 # Does the C compiler support the "ifunc" attribute
3028 # Note, this doesn't generate a C-level symbol.  It generates a
3029 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3030 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3032 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3033 static void mytest(void) {}
3035 static void (*resolve_test(void))(void)
3037     return (void (*)(void))&mytest;
3040 void test(void) __attribute__((ifunc("resolve_test")));
3042 int main()
3044     test();
3045     return 0;
3047 ]])], [
3048 ac_have_ifunc_attr=yes
3049 AC_MSG_RESULT([yes])
3050 ], [
3051 ac_have_ifunc_attr=no
3052 AC_MSG_RESULT([no])
3055 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3057 # Does the C compiler support the armv8 crc feature flag
3058 # Note, this doesn't generate a C-level symbol.  It generates a
3059 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3060 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3062 save_CFLAGS="$CFLAGS"
3063 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3064 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3065 int main()
3067     return 0;
3069 ]])], [
3070 ac_have_armv8_crc_feature=yes
3071 AC_MSG_RESULT([yes])
3072 ], [
3073 ac_have_armv8_crc_feature=no
3074 AC_MSG_RESULT([no])
3076 CFLAGS="$save_CFLAGS"
3078 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3081 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3082 # Note, this doesn't generate a C-level symbol.  It generates a
3083 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3084 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3086 save_CFLAGS="$CFLAGS"
3087 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3088 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3089 int main()
3091     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3092     return 0;
3094 ]])], [
3095 ac_have_armv81_feature=yes
3096 AC_MSG_RESULT([yes])
3097 ], [
3098 ac_have_armv81_feature=no
3099 AC_MSG_RESULT([no])
3101 CFLAGS="$save_CFLAGS"
3103 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3106 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3107 # when building the tool executables.  I think we should get rid of it.
3109 # Check for TLS support in the compiler and linker
3110 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3111                                 [[return foo;]])],
3112                                [vg_cv_linktime_tls=yes],
3113                                [vg_cv_linktime_tls=no])
3114 # Native compilation: check whether running a program using TLS succeeds.
3115 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3116 # succeeds but running programs using TLS fails.
3117 # Cross-compiling: check whether linking a program using TLS succeeds.
3118 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3119                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3120                 [vg_cv_tls=$enableval],
3121                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3122                                                 [[return foo;]])],
3123                                [vg_cv_tls=yes],
3124                                [vg_cv_tls=no],
3125                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3127 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3128 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3132 #----------------------------------------------------------------------------
3133 # Solaris-specific checks.
3134 #----------------------------------------------------------------------------
3136 if test "$VGCONF_OS" = "solaris" ; then
3137 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3139 # Solaris-specific check determining if the Sun Studio Assembler is used to
3140 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3141 # cmovl.l instruction, if yes then it's Sun Assembler.
3143 # C-level symbol: none
3144 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3146 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3147 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3148 ]], [[
3149   __asm__ __volatile__("cmovl.l %edx, %eax");
3150 ]])], [
3151 solaris_have_sun_studio_as=yes
3152 AC_MSG_RESULT([yes])
3153 ], [
3154 solaris_have_sun_studio_as=no
3155 AC_MSG_RESULT([no])
3157 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3159 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3160 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3161 # See solaris/vgpreload-solaris.mapfile for details.
3162 # gcc on older Solaris instructs linker to include these symbols,
3163 # gcc on illumos and newer Solaris does not.
3165 # C-level symbol: none
3166 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3168 save_CFLAGS="$CFLAGS"
3169 CFLAGS="$CFLAGS -std=gnu99"
3170 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3171 temp_dir=$( /usr/bin/mktemp -d )
3172 cat <<_ACEOF >${temp_dir}/mylib.c
3173 #include <stdio.h>
3174 int myfunc(void) { printf("LaPutyka\n"); }
3175 _ACEOF
3176 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3177 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3178 if test "x${xpg_present}" = "x" ; then
3179     solaris_xpg_symbols_present=no
3180     AC_MSG_RESULT([no])
3181 else
3182     solaris_xpg_symbols_present=yes
3183     AC_MSG_RESULT([yes])
3185 rm -rf ${temp_dir}
3186 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3187 CFLAGS="$save_CFLAGS"
3190 # Solaris-specific check determining if gcc enables largefile support by
3191 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3192 # variable with gcc flags which disable it.
3194 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3195 save_CFLAGS="$CFLAGS"
3196 CFLAGS="$CFLAGS -m32"
3197 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3198   return _LARGEFILE_SOURCE;
3199 ]])], [
3200 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3201 AC_MSG_RESULT([yes])
3202 ], [
3203 SOLARIS_UNDEF_LARGESOURCE=""
3204 AC_MSG_RESULT([no])
3206 CFLAGS=$safe_CFLAGS
3207 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3210 # Solaris-specific check determining if /proc/self/cmdline
3211 # or /proc/<pid>/cmdline is supported.
3213 # C-level symbol: SOLARIS_PROC_CMDLINE
3214 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3216 AC_CHECK_FILE([/proc/self/cmdline],
3218 solaris_proc_cmdline=yes
3219 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3220           [Define to 1 if you have /proc/self/cmdline.])
3221 ], [
3222 solaris_proc_cmdline=no
3224 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3227 # Solaris-specific check determining default platform for the Valgrind launcher.
3228 # Used in case the launcher cannot select platform by looking at the client
3229 # image (for example because the executable is a shell script).
3231 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3232 # Automake-level symbol: none
3234 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3235 # Get the ELF class of /bin/sh first.
3236 if ! test -f /bin/sh; then
3237   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3239 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3240 case "$elf_class" in
3241   64)
3242     default_arch="$VGCONF_ARCH_PRI";
3243     ;;
3244   32)
3245     if test "x$VGCONF_ARCH_SEC" != "x"; then
3246       default_arch="$VGCONF_ARCH_SEC"
3247     else
3248       default_arch="$VGCONF_ARCH_PRI";
3249     fi
3250     ;;
3251   *)
3252     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3253     ;;
3254 esac
3255 default_platform="$default_arch-$VGCONF_OS"
3256 AC_MSG_RESULT([$default_platform])
3257 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3258                    [Default platform for Valgrind launcher.])
3261 # Solaris-specific check determining if the old syscalls are available.
3263 # C-level symbol: SOLARIS_OLD_SYSCALLS
3264 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3266 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3267 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3268 #include <sys/syscall.h>
3269 ]], [[
3270   return !SYS_open;
3271 ]])], [
3272 solaris_old_syscalls=yes
3273 AC_MSG_RESULT([yes])
3274 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3275           [Define to 1 if you have the old Solaris syscalls.])
3276 ], [
3277 solaris_old_syscalls=no
3278 AC_MSG_RESULT([no])
3280 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3283 # Solaris-specific check determining if the new accept() syscall is available.
3285 # Old syscall:
3286 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3287 #            int version);
3289 # New syscall (available on illumos):
3290 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3291 #            int version, int flags);
3293 # If the old syscall is present then the following syscall will fail with
3294 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3295 # available then it will fail with EINVAL (because the flags parameter is
3296 # invalid).
3298 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3299 # Automake-level symbol: none
3301 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3302 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3303 #include <sys/syscall.h>
3304 #include <errno.h>
3305 ]], [[
3306   errno = 0;
3307   syscall(SYS_accept, 0, 0, 0, 0, -1);
3308   return !(errno == EINVAL);
3309 ]])], [
3310 AC_MSG_RESULT([yes])
3311 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3312           [Define to 1 if you have the new `accept' syscall.])
3313 ], [
3314 AC_MSG_RESULT([no])
3318 # Solaris-specific check determining if the new illumos pipe() syscall is
3319 # available.
3321 # Old syscall:
3322 # longlong_t pipe();
3324 # New syscall (available on illumos):
3325 # int pipe(intptr_t arg, int flags);
3327 # If the old syscall is present then the following call will succeed, if the
3328 # new syscall is available then it will fail with EFAULT (because address 0
3329 # cannot be accessed).
3331 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3332 # Automake-level symbol: none
3334 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3335 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3336 #include <sys/syscall.h>
3337 #include <errno.h>
3338 ]], [[
3339   errno = 0;
3340   syscall(SYS_pipe, 0, 0);
3341   return !(errno == EFAULT);
3342 ]])], [
3343 AC_MSG_RESULT([yes])
3344 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3345           [Define to 1 if you have the new `pipe' syscall.])
3346 ], [
3347 AC_MSG_RESULT([no])
3351 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3352 # available.
3354 # Old syscall:
3355 # int lwp_kill(id_t lwpid, int sig);
3357 # New syscall (available on Solaris 11):
3358 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3359 #                  int si_code, timespec_t *timeout);
3361 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3362 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3364 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3365 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3366 #include <sys/syscall.h> 
3367 ]], [[
3368   return !SYS_lwp_sigqueue;
3369 ]])], [
3370 solaris_lwp_sigqueue_syscall=yes
3371 AC_MSG_RESULT([yes])
3372 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3373           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3374 ], [
3375 solaris_lwp_sigqueue_syscall=no
3376 AC_MSG_RESULT([no])
3378 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3381 # Solaris-specific check determining if the lwp_sigqueue() syscall
3382 # takes both pid and thread id arguments or just thread id.
3384 # Old syscall (available up to Solaris 11.3):
3385 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3386 #                  int si_code, timespec_t *timeout);
3388 # New syscall (available since Solaris 11.4):
3389 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3390 #                  int si_code, timespec_t *timeout);
3392 # If the old syscall is present then the following syscall will fail with
3393 # EINVAL (because signal is out of range); if the new syscall is available
3394 # then it will fail with ESRCH (because it would not find such thread in the
3395 # current process).
3397 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3398 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3400 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3401 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3402 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3403 #include <sys/syscall.h>
3404 #include <errno.h>
3405 ]], [[
3406   errno = 0;
3407   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3408   return !(errno == ESRCH);
3409 ]])], [
3410 solaris_lwp_sigqueue_syscall_takes_pid=yes
3411 AC_MSG_RESULT([yes])
3412 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3413           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3414 ], [
3415 solaris_lwp_sigqueue_syscall_takes_pid=no
3416 AC_MSG_RESULT([no])
3418 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3419                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3421 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3425 # Solaris-specific check determining if the new lwp_name() syscall is
3426 # available.
3428 # New syscall (available on Solaris 11):
3429 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3431 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3432 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3434 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3435 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3436 #include <sys/syscall.h>
3437 ]], [[
3438   return !SYS_lwp_name;
3439 ]])], [
3440 solaris_lwp_name_syscall=yes
3441 AC_MSG_RESULT([yes])
3442 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3443           [Define to 1 if you have the new `lwp_name' syscall.])
3444 ], [
3445 solaris_lwp_name_syscall=no
3446 AC_MSG_RESULT([no])
3448 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3451 # Solaris-specific check determining if the new getrandom() syscall is
3452 # available.
3454 # New syscall (available on Solaris 11):
3455 # int getrandom(void *buf, size_t buflen, uint_t flags);
3457 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3458 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3460 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3462 #include <sys/syscall.h>
3463 ]], [[
3464   return !SYS_getrandom;
3465 ]])], [
3466 solaris_getrandom_syscall=yes
3467 AC_MSG_RESULT([yes])
3468 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3469           [Define to 1 if you have the new `getrandom' syscall.])
3470 ], [
3471 solaris_getrandom_syscall=no
3472 AC_MSG_RESULT([no])
3474 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3477 # Solaris-specific check determining if the new zone() syscall subcodes
3478 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
3479 # were added in Solaris 11 but are missing on illumos.
3481 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3482 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3484 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3485 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3486 #include <sys/zone.h>
3487 ]], [[
3488   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3489 ]])], [
3490 solaris_zone_defunct=yes
3491 AC_MSG_RESULT([yes])
3492 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3493           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3494 ], [
3495 solaris_zone_defunct=no
3496 AC_MSG_RESULT([no])
3498 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3501 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3502 # for auditon(2) subcode of the auditsys() syscall are available.
3503 # These commands are available in Solaris 11 and illumos but were removed
3504 # in Solaris 11.4.
3506 # C-level symbol: SOLARIS_AUDITON_STAT
3507 # Automake-level symbol: SOLARIS_AUDITON_STAT
3509 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3510 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3511 #include <bsm/audit.h>
3512 ]], [[
3513   return !(A_GETSTAT && A_SETSTAT);
3514 ]])], [
3515 solaris_auditon_stat=yes
3516 AC_MSG_RESULT([yes])
3517 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3518           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3519 ], [
3520 solaris_auditon_stat=no
3521 AC_MSG_RESULT([no])
3523 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3526 # Solaris-specific check determining if the new shmsys() syscall subcodes
3527 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3528 # These subcodes were added in Solaris 11 but are missing on illumos.
3530 # C-level symbol: SOLARIS_SHM_NEW
3531 # Automake-level symbol: SOLARIS_SHM_NEW
3533 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3534 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3535 #include <sys/ipc_impl.h>
3536 #include <sys/shm.h>
3537 #include <sys/shm_impl.h>
3538 ]], [[
3539   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3540 ]])], [
3541 solaris_shm_new=yes
3542 AC_MSG_RESULT([yes])
3543 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3544           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3545 ], [
3546 solaris_shm_new=no
3547 AC_MSG_RESULT([no])
3549 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3552 # Solaris-specific check determining if prxregset_t is available.  Illumos
3553 # currently does not define it on the x86 platform.
3555 # C-level symbol: SOLARIS_PRXREGSET_T
3556 # Automake-level symbol: SOLARIS_PRXREGSET_T
3558 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3559 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3560 #include <sys/procfs_isa.h>
3561 ]], [[
3562   return !sizeof(prxregset_t);
3563 ]])], [
3564 solaris_prxregset_t=yes
3565 AC_MSG_RESULT([yes])
3566 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3567           [Define to 1 if you have the `prxregset_t' type.])
3568 ], [
3569 solaris_prxregset_t=no
3570 AC_MSG_RESULT([no])
3572 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3575 # Solaris-specific check determining if the new frealpathat() syscall is
3576 # available.
3578 # New syscall (available on Solaris 11.1):
3579 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
3581 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3582 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3584 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3586 #include <sys/syscall.h>
3587 ]], [[
3588   return !SYS_frealpathat;
3589 ]])], [
3590 solaris_frealpathat_syscall=yes
3591 AC_MSG_RESULT([yes])
3592 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3593           [Define to 1 if you have the new `frealpathat' syscall.])
3594 ], [
3595 solaris_frealpathat_syscall=no
3596 AC_MSG_RESULT([no])
3598 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3601 # Solaris-specific check determining if the new uuidsys() syscall is
3602 # available.
3604 # New syscall (available on newer Solaris):
3605 # int uuidsys(struct uuid *uuid);
3607 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3608 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3610 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3611 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3612 #include <sys/syscall.h>
3613 ]], [[
3614   return !SYS_uuidsys;
3615 ]])], [
3616 solaris_uuidsys_syscall=yes
3617 AC_MSG_RESULT([yes])
3618 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
3619           [Define to 1 if you have the new `uuidsys' syscall.])
3620 ], [
3621 solaris_uuidsys_syscall=no
3622 AC_MSG_RESULT([no])
3624 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
3627 # Solaris-specific check determining if the new labelsys() syscall subcode
3628 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
3629 # missing on illumos.
3631 # C-level symbol: SOLARIS_TNDB_GET_TNIP
3632 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
3634 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
3635 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3636 #include <sys/tsol/tndb.h>
3637 ]], [[
3638   return !TNDB_GET_TNIP;
3639 ]])], [
3640 solaris_tndb_get_tnip=yes
3641 AC_MSG_RESULT([yes])
3642 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
3643           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
3644 ], [
3645 solaris_tndb_get_tnip=no
3646 AC_MSG_RESULT([no])
3648 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
3651 # Solaris-specific check determining if the new labelsys() syscall opcodes
3652 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
3653 # added in Solaris 11 but are missing on illumos.
3655 # C-level symbol: SOLARIS_TSOL_CLEARANCE
3656 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
3658 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
3659 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3660 #include <sys/tsol/tsyscall.h>
3661 ]], [[
3662   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
3663 ]])], [
3664 solaris_tsol_clearance=yes
3665 AC_MSG_RESULT([yes])
3666 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
3667           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
3668 ], [
3669 solaris_tsol_clearance=no
3670 AC_MSG_RESULT([no])
3672 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
3675 # Solaris-specific check determining if the new pset() syscall subcode
3676 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
3677 # is missing on illumos and Solaris 11.3.
3679 # C-level symbol: SOLARIS_PSET_GET_NAME
3680 # Automake-level symbol: SOLARIS_PSET_GET_NAME
3682 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
3683 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3684 #include <sys/pset.h>
3685 ]], [[
3686   return !(PSET_GET_NAME);
3687 ]])], [
3688 solaris_pset_get_name=yes
3689 AC_MSG_RESULT([yes])
3690 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
3691           [Define to 1 if you have the `PSET_GET_NAME' constants.])
3692 ], [
3693 solaris_pset_get_name=no
3694 AC_MSG_RESULT([no])
3696 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
3699 # Solaris-specific check determining if the utimesys() syscall is
3700 # available (on illumos and older Solaris).
3702 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
3703 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
3705 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
3706 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3707 #include <sys/syscall.h>
3708 ]], [[
3709   return !SYS_utimesys;
3710 ]])], [
3711 solaris_utimesys_syscall=yes
3712 AC_MSG_RESULT([yes])
3713 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
3714           [Define to 1 if you have the `utimesys' syscall.])
3715 ], [
3716 solaris_utimesys_syscall=no
3717 AC_MSG_RESULT([no])
3719 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
3722 # Solaris-specific check determining if the utimensat() syscall is
3723 # available (on newer Solaris).
3725 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3726 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3728 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
3729 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3730 #include <sys/syscall.h>
3731 ]], [[
3732   return !SYS_utimensat;
3733 ]])], [
3734 solaris_utimensat_syscall=yes
3735 AC_MSG_RESULT([yes])
3736 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
3737           [Define to 1 if you have the `utimensat' syscall.])
3738 ], [
3739 solaris_utimensat_syscall=no
3740 AC_MSG_RESULT([no])
3742 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
3745 # Solaris-specific check determining if the spawn() syscall is available
3746 # (on newer Solaris).
3748 # C-level symbol: SOLARIS_SPAWN_SYSCALL
3749 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
3751 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
3752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3753 #include <sys/syscall.h>
3754 ]], [[
3755   return !SYS_spawn;
3756 ]])], [
3757 solaris_spawn_syscall=yes
3758 AC_MSG_RESULT([yes])
3759 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
3760           [Define to 1 if you have the `spawn' syscall.])
3761 ], [
3762 solaris_spawn_syscall=no
3763 AC_MSG_RESULT([no])
3765 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
3768 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
3769 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
3771 # C-level symbol: SOLARIS_MODCTL_MODNVL
3772 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
3774 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
3775 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3776 #include <sys/modctl.h>
3777 ]], [[
3778   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
3779 ]])], [
3780 solaris_modctl_modnvl=yes
3781 AC_MSG_RESULT([yes])
3782 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
3783           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
3784 ], [
3785 solaris_modctl_modnvl=no
3786 AC_MSG_RESULT([no])
3788 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
3791 # Solaris-specific check determining whether nscd (name switch cache daemon)
3792 # attaches its door at /system/volatile/name_service_door (Solaris)
3793 # or at /var/run/name_service_door (illumos).
3795 # Note that /var/run is a symlink to /system/volatile on Solaris
3796 # but not vice versa on illumos.
3798 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3799 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3801 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
3802 if test -e /system/volatile/name_service_door; then
3803     solaris_nscd_door_system_volatile=yes
3804     AC_MSG_RESULT([/system/volatile/name_service_door])
3805     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
3806               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
3807 else
3808     solaris_nscd_door_system_volatile=no
3809     AC_MSG_RESULT([/var/run/name_service_door])
3811 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
3814 # Solaris-specific check determining if the new gethrt() fasttrap is available.
3816 # New fasttrap (available on Solaris 11):
3817 # hrt_t *gethrt(void);
3819 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
3820 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
3822 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
3823 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3824 #include <sys/trap.h>
3825 ]], [[
3826   return !T_GETHRT;
3827 ]])], [
3828 solaris_gethrt_fasttrap=yes
3829 AC_MSG_RESULT([yes])
3830 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
3831           [Define to 1 if you have the new `gethrt' fasttrap.])
3832 ], [
3833 solaris_gethrt_fasttrap=no
3834 AC_MSG_RESULT([no])
3836 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
3839 # Solaris-specific check determining if the new get_zone_offset() fasttrap
3840 # is available.
3842 # New fasttrap (available on Solaris 11):
3843 # zonehrtoffset_t *get_zone_offset(void);
3845 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3846 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3848 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
3849 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3850 #include <sys/trap.h>
3851 ]], [[
3852   return !T_GETZONEOFFSET;
3853 ]])], [
3854 solaris_getzoneoffset_fasttrap=yes
3855 AC_MSG_RESULT([yes])
3856 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
3857           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
3858 ], [
3859 solaris_getzoneoffset_fasttrap=no
3860 AC_MSG_RESULT([no])
3862 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
3865 # Solaris-specific check determining if the execve() syscall
3866 # takes fourth argument (flags) or not.
3868 # Old syscall (available on illumos):
3869 # int execve(const char *fname, const char **argv, const char **envp);
3871 # New syscall (available on Solaris):
3872 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
3874 # If the new syscall is present then it will fail with EINVAL (because flags
3875 # are invalid); if the old syscall is available then it will fail with ENOENT
3876 # (because the file could not be found).
3878 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3879 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3881 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
3882 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3883 #include <sys/syscall.h>
3884 #include <errno.h>
3885 ]], [[
3886   errno = 0;
3887   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
3888   return !(errno == EINVAL);
3889 ]])], [
3890 solaris_execve_syscall_takes_flags=yes
3891 AC_MSG_RESULT([yes])
3892 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
3893           [Define to 1 if you have the new `execve' syscall which accepts flags.])
3894 ], [
3895 solaris_execve_syscall_takes_flags=no
3896 AC_MSG_RESULT([no])
3898 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
3899                test x$solaris_execve_syscall_takes_flags = xyes)
3902 # Solaris-specific check determining version of the repository cache protocol.
3903 # Every Solaris version uses a different one, ranging from 21 to current 25.
3904 # The check is very ugly, though.
3906 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
3907 # Automake-level symbol: none
3909 AC_PATH_PROG(DIS_PATH, dis, false)
3910 if test "x$DIS_PATH" = "xfalse"; then
3911   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
3913 AC_CHECK_LIB(scf, scf_handle_bind, [], [
3914   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
3915   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3918 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
3919 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
3920   libscf=/usr/lib/64/libscf.so.1
3921 else
3922   libscf=/usr/lib/libscf.so.1
3924 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
3925   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
3926   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3928 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
3929 if test -z "$hex"; then
3930   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
3931   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3933 version=$( printf "%d\n" 0x$hex )
3934 AC_MSG_RESULT([$version])
3935 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
3936                    [Version number of the repository door cache protocol.])
3939 # Solaris-specific check determining if "sysstat" segment reservation type
3940 # is available.
3942 # New "sysstat" segment reservation (available on Solaris 11.4):
3943 # - program header type:    PT_SUNW_SYSSTAT
3944 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
3946 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
3947 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
3949 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
3950 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3951 #include <sys/auxv.h>
3952 ]], [[
3953   return !AT_SUN_SYSSTAT_ADDR;
3954 ]])], [
3955 solaris_reserve_sysstat_addr=yes
3956 AC_MSG_RESULT([yes])
3957 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
3958           [Define to 1 if you have the new `sysstat' segment reservation.])
3959 ], [
3960 solaris_reserve_sysstat_addr=no
3961 AC_MSG_RESULT([no])
3963 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
3966 # Solaris-specific check determining if "sysstat_zone" segment reservation type
3967 # is available.
3969 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
3970 # - program header type:    PT_SUNW_SYSSTAT_ZONE
3971 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
3973 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
3974 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
3976 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
3977 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3978 #include <sys/auxv.h>
3979 ]], [[
3980   return !AT_SUN_SYSSTAT_ZONE_ADDR;
3981 ]])], [
3982 solaris_reserve_sysstat_zone_addr=yes
3983 AC_MSG_RESULT([yes])
3984 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
3985           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
3986 ], [
3987 solaris_reserve_sysstat_zone_addr=no
3988 AC_MSG_RESULT([no])
3990 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
3993 # Solaris-specific check determining if the system_stats() syscall is available
3994 # (on newer Solaris).
3996 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
3997 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
3999 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4000 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4001 #include <sys/syscall.h>
4002 ]], [[
4003   return !SYS_system_stats;
4004 ]])], [
4005 solaris_system_stats_syscall=yes
4006 AC_MSG_RESULT([yes])
4007 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4008           [Define to 1 if you have the `system_stats' syscall.])
4009 ], [
4010 solaris_system_stats_syscall=no
4011 AC_MSG_RESULT([no])
4013 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4016 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4017 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4019 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4020 # Automake-level symbol: none
4022 AC_CHECK_TYPE([struct _fpchip_state],
4023               [solaris_fpchip_state_takes_underscore=yes],
4024               [solaris_fpchip_state_takes_underscore=no],
4025               [[#include <sys/regset.h>]])
4026 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4027   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4028             [Define to 1 if fpregset_t defines struct _fpchip_state])
4032 # Solaris-specific check determining if schedctl page shared between kernel
4033 # and userspace program is executable (illumos, older Solaris) or not (newer
4034 # Solaris).
4036 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4037 # Automake-level symbol: none
4039 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4040 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4041 #include <assert.h>
4042 #include <fcntl.h>
4043 #include <procfs.h>
4044 #include <schedctl.h>
4045 #include <stdio.h>
4046 #include <unistd.h>
4047 ]], [[
4048     schedctl_t *scp = schedctl_init();
4049     if (scp == NULL)
4050         return 1;
4052     int fd = open("/proc/self/map", O_RDONLY);
4053     assert(fd >= 0);
4055     prmap_t map;
4056     ssize_t rd;
4057     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4058         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4059             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4060                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4061             return (map.pr_mflags & MA_EXEC);
4062         }
4063     }
4065     return 1;
4066 ]])], [
4067 solaris_schedctl_page_exec=no
4068 AC_MSG_RESULT([no])
4069 ], [
4070 solaris_schedctl_page_exec=yes
4071 AC_MSG_RESULT([yes])
4072 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4073           [Define to 1 if you have the schedctl page executable.])
4077 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4078 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4079 # an initial thread pointer for libc (newer Solaris).
4081 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4082 # Automake-level symbol: none
4084 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4085 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4086 #include <sys/fasttrap_isa.h>
4087 ]], [[
4088     return !FT_SCRATCHSIZE;
4089 ]])], [
4090 solaris_pt_sunwdtrace_thrp=yes
4091 AC_MSG_RESULT([yes])
4092 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4093           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4094 ], [
4095 solaris_pt_sunwdtrace_thrp=no
4096 AC_MSG_RESULT([no])
4099 else
4100 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4101 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4102 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4103 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4104 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4105 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4106 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4107 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4108 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4109 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4110 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4111 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4112 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4113 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4114 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4115 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4116 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4117 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4118 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4119 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4120 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4121 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4122 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4123 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4124 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4125 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4126 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4127 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4128 fi # test "$VGCONF_OS" = "solaris"
4131 #----------------------------------------------------------------------------
4132 # Checks for C header files.
4133 #----------------------------------------------------------------------------
4135 AC_CHECK_HEADERS([       \
4136         asm/unistd.h     \
4137         endian.h         \
4138         mqueue.h         \
4139         sys/endian.h     \
4140         sys/epoll.h      \
4141         sys/eventfd.h    \
4142         sys/klog.h       \
4143         sys/poll.h       \
4144         sys/prctl.h      \
4145         sys/signal.h     \
4146         sys/signalfd.h   \
4147         sys/syscall.h    \
4148         sys/sysnvl.h     \
4149         sys/time.h       \
4150         sys/types.h      \
4151         ])
4153 # Verify whether the <linux/futex.h> header is usable.
4154 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4156 save_CFLAGS="$CFLAGS"
4157 CFLAGS="$CFLAGS -D__user="
4158 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4159 #include <linux/futex.h>
4160 ]], [[
4161   return FUTEX_WAIT;
4162 ]])], [
4163 ac_have_usable_linux_futex_h=yes
4164 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4165           [Define to 1 if you have a usable <linux/futex.h> header file.])
4166 AC_MSG_RESULT([yes])
4167 ], [
4168 ac_have_usable_linux_futex_h=no
4169 AC_MSG_RESULT([no])
4171 CFLAGS="$save_CFLAGS"
4174 #----------------------------------------------------------------------------
4175 # Checks for typedefs, structures, and compiler characteristics.
4176 #----------------------------------------------------------------------------
4177 AC_TYPE_UID_T
4178 AC_TYPE_OFF_T
4179 AC_TYPE_SIZE_T
4180 AC_HEADER_TIME
4183 #----------------------------------------------------------------------------
4184 # Checks for library functions.
4185 #----------------------------------------------------------------------------
4186 AC_FUNC_MEMCMP
4187 AC_FUNC_MMAP
4189 AC_CHECK_LIB([pthread], [pthread_create])
4190 AC_CHECK_LIB([rt], [clock_gettime])
4192 AC_CHECK_FUNCS([     \
4193         clock_gettime\
4194         epoll_create \
4195         epoll_pwait  \
4196         klogctl      \
4197         mallinfo     \
4198         memchr       \
4199         memset       \
4200         mkdir        \
4201         mremap       \
4202         ppoll        \
4203         pthread_barrier_init       \
4204         pthread_condattr_setclock  \
4205         pthread_mutex_timedlock    \
4206         pthread_rwlock_timedrdlock \
4207         pthread_rwlock_timedwrlock \
4208         pthread_spin_lock          \
4209         pthread_yield              \
4210         pthread_setname_np         \
4211         readlinkat   \
4212         semtimedop   \
4213         signalfd     \
4214         sigwaitinfo  \
4215         strchr       \
4216         strdup       \
4217         strpbrk      \
4218         strrchr      \
4219         strstr       \
4220         syscall      \
4221         utimensat    \
4222         process_vm_readv  \
4223         process_vm_writev \
4224         copy_file_range \
4225         preadv \
4226         pwritev \
4227         preadv2 \
4228         pwritev2 \
4229         ])
4231 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4232 # libraries with any shared object and/or executable. This is NOT what we
4233 # want for e.g. vgpreload_core-x86-linux.so
4234 LIBS=""
4236 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4237                [test x$ac_cv_func_pthread_barrier_init = xyes])
4238 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4239                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4240 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4241                [test x$ac_cv_func_pthread_spin_lock = xyes])
4242 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4243                [test x$ac_cv_func_pthread_setname_np = xyes])
4244 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4245                [test x$ac_cv_func_copy_file_range = xyes])
4246 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4247                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4248 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4249                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4251 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4252      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
4253   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4254             [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
4257 #----------------------------------------------------------------------------
4258 # MPI checks
4259 #----------------------------------------------------------------------------
4260 # Do we have a useable MPI setup on the primary and/or secondary targets?
4261 # On Linux, by default, assumes mpicc and -m32/-m64
4262 # Note: this is a kludge in that it assumes the specified mpicc 
4263 # understands -m32/-m64 regardless of what is specified using
4264 # --with-mpicc=.
4265 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4266              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4268 mflag_primary=
4269 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4270      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4271      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4272      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4273      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4274   mflag_primary=$FLAG_M32
4275 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4276        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4277        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4278        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4279        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4280   mflag_primary=$FLAG_M64
4281 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4282   mflag_primary="$FLAG_M32 -arch i386"
4283 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4284   mflag_primary="$FLAG_M64 -arch x86_64"
4287 mflag_secondary=
4288 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4289      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4290      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4291      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX ; then
4292   mflag_secondary=$FLAG_M32
4293 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4294   mflag_secondary="$FLAG_M32 -arch i386"
4298 AC_ARG_WITH(mpicc,
4299    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4300    MPI_CC=$withval
4302 AC_SUBST(MPI_CC)
4304 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4305 ## use these values in the check for a functioning mpicc.
4307 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4308 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4309 AM_COND_IF([VGCONF_OS_IS_LINUX],
4310            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4311             LDFLAGS_MPI="-fpic -shared"])
4312 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4313            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4314             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4315 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4316            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4317             LDFLAGS_MPI="-fpic -shared"])
4319 AC_SUBST([CFLAGS_MPI])
4320 AC_SUBST([LDFLAGS_MPI])
4323 ## See if MPI_CC works for the primary target
4325 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4326 saved_CC=$CC
4327 saved_CFLAGS=$CFLAGS
4328 CC=$MPI_CC
4329 CFLAGS="$CFLAGS_MPI $mflag_primary"
4330 saved_LDFLAGS="$LDFLAGS"
4331 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4332 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4333 #include <mpi.h>
4334 #include <stdio.h>
4335 ]], [[
4336   int ni, na, nd, comb;
4337   int r = MPI_Init(NULL,NULL);
4338   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4339   r |= MPI_Finalize();
4340   return r; 
4341 ]])], [
4342 ac_have_mpi2_pri=yes
4343 AC_MSG_RESULT([yes, $MPI_CC])
4344 ], [
4345 ac_have_mpi2_pri=no
4346 AC_MSG_RESULT([no])
4348 CC=$saved_CC
4349 CFLAGS=$saved_CFLAGS
4350 LDFLAGS="$saved_LDFLAGS"
4351 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4353 ## See if MPI_CC works for the secondary target.  Complication: what if
4354 ## there is no secondary target?  We need this to then fail.
4355 ## Kludge this by making MPI_CC something which will surely fail in
4356 ## such a case.
4358 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4359 saved_CC=$CC
4360 saved_CFLAGS=$CFLAGS
4361 saved_LDFLAGS="$LDFLAGS"
4362 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4363 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4364   CC="$MPI_CC this will surely fail"
4365 else
4366   CC=$MPI_CC
4368 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4369 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4370 #include <mpi.h>
4371 #include <stdio.h>
4372 ]], [[
4373   int ni, na, nd, comb;
4374   int r = MPI_Init(NULL,NULL);
4375   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4376   r |= MPI_Finalize();
4377   return r; 
4378 ]])], [
4379 ac_have_mpi2_sec=yes
4380 AC_MSG_RESULT([yes, $MPI_CC])
4381 ], [
4382 ac_have_mpi2_sec=no
4383 AC_MSG_RESULT([no])
4385 CC=$saved_CC
4386 CFLAGS=$saved_CFLAGS
4387 LDFLAGS="$saved_LDFLAGS"
4388 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4391 #----------------------------------------------------------------------------
4392 # Other library checks
4393 #----------------------------------------------------------------------------
4394 # There now follow some tests for Boost, and OpenMP.  These
4395 # tests are present because Drd has some regression tests that use
4396 # these packages.  All regression test programs all compiled only
4397 # for the primary target.  And so it is important that the configure
4398 # checks that follow, use the correct -m32 or -m64 flag for the
4399 # primary target (called $mflag_primary).  Otherwise, we can end up
4400 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4401 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4402 # only build (meaning, the primary target is x86-linux), the build
4403 # of the regtest programs that use Boost fails, because they are 
4404 # build as 32-bit (IN THIS EXAMPLE).
4406 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4407 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4410 # Check whether the boost library 1.35 or later has been installed.
4411 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4413 AC_MSG_CHECKING([for boost])
4415 AC_LANG(C++)
4416 safe_CXXFLAGS=$CXXFLAGS
4417 CXXFLAGS="$mflag_primary"
4418 safe_LIBS="$LIBS"
4419 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4421 AC_LINK_IFELSE([AC_LANG_SOURCE([
4422 #include <boost/thread.hpp>
4423 static void thread_func(void)
4424 { }
4425 int main(int argc, char** argv)
4427   boost::thread t(thread_func);
4428   return 0;
4430 ])],
4432 ac_have_boost_1_35=yes
4433 AC_SUBST([BOOST_CFLAGS], [])
4434 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4435 AC_MSG_RESULT([yes])
4436 ], [
4437 ac_have_boost_1_35=no
4438 AC_MSG_RESULT([no])
4441 LIBS="$safe_LIBS"
4442 CXXFLAGS=$safe_CXXFLAGS
4443 AC_LANG(C)
4445 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4448 # does this compiler support -fopenmp, does it have the include file
4449 # <omp.h> and does it have libgomp ?
4451 AC_MSG_CHECKING([for OpenMP])
4453 safe_CFLAGS=$CFLAGS
4454 CFLAGS="-fopenmp $mflag_primary -Werror"
4456 AC_LINK_IFELSE([AC_LANG_SOURCE([
4457 #include <omp.h> 
4458 int main(int argc, char** argv)
4460   omp_set_dynamic(0);
4461   return 0;
4463 ])],
4465 ac_have_openmp=yes
4466 AC_MSG_RESULT([yes])
4467 ], [
4468 ac_have_openmp=no
4469 AC_MSG_RESULT([no])
4471 CFLAGS=$safe_CFLAGS
4473 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4476 # Check for __builtin_popcount
4477 AC_MSG_CHECKING([for __builtin_popcount()])
4478 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4479 ]], [[
4480   __builtin_popcount(2);
4481   return 0;
4482 ]])], [
4483 AC_MSG_RESULT([yes])
4484 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4485           [Define to 1 if compiler provides __builtin_popcount().])
4486 ], [
4487 AC_MSG_RESULT([no])
4490 # Check for __builtin_clz
4491 AC_MSG_CHECKING([for __builtin_clz()])
4492 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4493 ]], [[
4494   __builtin_clz(2);
4495   return 0;
4496 ]])], [
4497 AC_MSG_RESULT([yes])
4498 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4499           [Define to 1 if compiler provides __builtin_clz().])
4500 ], [
4501 AC_MSG_RESULT([no])
4504 # Check for __builtin_ctz
4505 AC_MSG_CHECKING([for __builtin_ctz()])
4506 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4507 ]], [[
4508   __builtin_ctz(2);
4509   return 0;
4510 ]])], [
4511 AC_MSG_RESULT([yes])
4512 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4513           [Define to 1 if compiler provides __builtin_ctz().])
4514 ], [
4515 AC_MSG_RESULT([no])
4518 # does this compiler have built-in functions for atomic memory access for the
4519 # primary target ?
4520 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4522 safe_CFLAGS=$CFLAGS
4523 CFLAGS="$mflag_primary"
4525 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4526   int variable = 1;
4527   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4528           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4529 ]])], [
4530   ac_have_builtin_atomic_primary=yes
4531   AC_MSG_RESULT([yes])
4532   AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() and __sync_add_and_fetch() for the primary target])
4533 ], [
4534   ac_have_builtin_atomic_primary=no
4535   AC_MSG_RESULT([no])
4538 CFLAGS=$safe_CFLAGS
4540 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4541                [test x$ac_have_builtin_atomic_primary = xyes])
4544 # does this compiler have built-in functions for atomic memory access for the
4545 # secondary target ?
4547 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4549 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
4551 safe_CFLAGS=$CFLAGS
4552 CFLAGS="$mflag_secondary"
4554 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4555   int variable = 1;
4556   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
4557 ]])], [
4558   ac_have_builtin_atomic_secondary=yes
4559   AC_MSG_RESULT([yes])
4560 ], [
4561   ac_have_builtin_atomic_secondary=no
4562   AC_MSG_RESULT([no])
4565 CFLAGS=$safe_CFLAGS
4569 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
4570                [test x$ac_have_builtin_atomic_secondary = xyes])
4572 # does this compiler have built-in functions for atomic memory access on
4573 # 64-bit integers for all targets ?
4575 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
4577 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4578   #include <stdint.h>
4579 ]], [[
4580   uint64_t variable = 1;
4581   return __sync_add_and_fetch(&variable, 1)
4582 ]])], [
4583   ac_have_builtin_atomic64_primary=yes
4584 ], [
4585   ac_have_builtin_atomic64_primary=no
4588 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4590 safe_CFLAGS=$CFLAGS
4591 CFLAGS="$mflag_secondary"
4593 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4594   #include <stdint.h>
4595 ]], [[
4596   uint64_t variable = 1;
4597   return __sync_add_and_fetch(&variable, 1)
4598 ]])], [
4599   ac_have_builtin_atomic64_secondary=yes
4600 ], [
4601   ac_have_builtin_atomic64_secondary=no
4604 CFLAGS=$safe_CFLAGS
4608 if test x$ac_have_builtin_atomic64_primary = xyes && \
4609    test x$VGCONF_PLATFORM_SEC_CAPS = x \
4610      -o x$ac_have_builtin_atomic64_secondary = xyes; then
4611   AC_MSG_RESULT([yes])
4612   ac_have_builtin_atomic64=yes
4613 else
4614   AC_MSG_RESULT([no])
4615   ac_have_builtin_atomic64=no
4618 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
4619                [test x$ac_have_builtin_atomic64 = xyes])
4622 # does g++ have built-in functions for atomic memory access ?
4623 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
4625 safe_CXXFLAGS=$CXXFLAGS
4626 CXXFLAGS="$mflag_primary"
4628 AC_LANG_PUSH(C++)
4629 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4630   int variable = 1;
4631   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4632           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4633 ]])], [
4634   ac_have_builtin_atomic_cxx=yes
4635   AC_MSG_RESULT([yes])
4636   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
4637 ], [
4638   ac_have_builtin_atomic_cxx=no
4639   AC_MSG_RESULT([no])
4641 AC_LANG_POP(C++)
4643 CXXFLAGS=$safe_CXXFLAGS
4645 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
4648 if test x$ac_have_usable_linux_futex_h = xyes \
4649         -a x$ac_have_builtin_atomic_primary = xyes; then
4650   ac_enable_linux_ticket_lock_primary=yes
4652 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
4653                [test x$ac_enable_linux_ticket_lock_primary = xyes])
4655 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
4656         -a x$ac_have_usable_linux_futex_h = xyes \
4657         -a x$ac_have_builtin_atomic_secondary = xyes; then
4658   ac_enable_linux_ticket_lock_secondary=yes
4660 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
4661                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
4664 # does libstdc++ support annotating shared pointers ?
4665 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
4667 safe_CXXFLAGS=$CXXFLAGS
4668 CXXFLAGS="-std=c++0x"
4670 AC_LANG_PUSH(C++)
4671 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4672   #include <memory>
4673 ]], [[
4674   std::shared_ptr<int> p
4675 ]])], [
4676   ac_have_shared_ptr=yes
4677 ], [
4678   ac_have_shared_ptr=no
4680 if test x$ac_have_shared_ptr = xyes; then
4681   # If compilation of the program below fails because of a syntax error
4682   # triggered by substituting one of the annotation macros then that
4683   # means that libstdc++ supports these macros.
4684   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4685     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
4686     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
4687     #include <memory>
4688   ]], [[
4689     std::shared_ptr<int> p
4690   ]])], [
4691     ac_have_shared_pointer_annotation=no
4692     AC_MSG_RESULT([no])
4693   ], [
4694     ac_have_shared_pointer_annotation=yes
4695     AC_MSG_RESULT([yes])
4696     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
4697               [Define to 1 if libstd++ supports annotating shared pointers])
4698   ])
4699 else
4700   ac_have_shared_pointer_annotation=no
4701   AC_MSG_RESULT([no])
4703 AC_LANG_POP(C++)
4705 CXXFLAGS=$safe_CXXFLAGS
4707 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
4708                [test x$ac_have_shared_pointer_annotation = xyes])
4711 #----------------------------------------------------------------------------
4712 # Ok.  We're done checking.
4713 #----------------------------------------------------------------------------
4715 # Nb: VEX/Makefile is generated from Makefile.vex.in.
4716 AC_CONFIG_FILES([
4717    Makefile 
4718    VEX/Makefile:Makefile.vex.in
4719    valgrind.spec
4720    valgrind.pc
4721    glibc-2.X.supp
4722    docs/Makefile 
4723    tests/Makefile 
4724    tests/vg_regtest 
4725    perf/Makefile 
4726    perf/vg_perf
4727    gdbserver_tests/Makefile
4728    gdbserver_tests/solaris/Makefile
4729    include/Makefile 
4730    auxprogs/Makefile
4731    mpi/Makefile
4732    coregrind/Makefile 
4733    memcheck/Makefile
4734    memcheck/tests/Makefile
4735    memcheck/tests/common/Makefile
4736    memcheck/tests/amd64/Makefile
4737    memcheck/tests/x86/Makefile
4738    memcheck/tests/linux/Makefile
4739    memcheck/tests/darwin/Makefile
4740    memcheck/tests/solaris/Makefile
4741    memcheck/tests/amd64-linux/Makefile
4742    memcheck/tests/arm64-linux/Makefile
4743    memcheck/tests/x86-linux/Makefile
4744    memcheck/tests/amd64-solaris/Makefile
4745    memcheck/tests/x86-solaris/Makefile
4746    memcheck/tests/ppc32/Makefile
4747    memcheck/tests/ppc64/Makefile
4748    memcheck/tests/s390x/Makefile
4749    memcheck/tests/mips32/Makefile
4750    memcheck/tests/mips64/Makefile
4751    memcheck/tests/vbit-test/Makefile
4752    cachegrind/Makefile
4753    cachegrind/tests/Makefile
4754    cachegrind/tests/x86/Makefile
4755    cachegrind/cg_annotate
4756    cachegrind/cg_diff
4757    callgrind/Makefile
4758    callgrind/callgrind_annotate
4759    callgrind/callgrind_control
4760    callgrind/tests/Makefile
4761    helgrind/Makefile
4762    helgrind/tests/Makefile
4763    drd/Makefile
4764    drd/scripts/download-and-build-splash2
4765    drd/tests/Makefile
4766    massif/Makefile
4767    massif/tests/Makefile
4768    massif/ms_print
4769    dhat/Makefile
4770    dhat/tests/Makefile
4771    lackey/Makefile
4772    lackey/tests/Makefile
4773    none/Makefile
4774    none/tests/Makefile
4775    none/tests/scripts/Makefile
4776    none/tests/amd64/Makefile
4777    none/tests/ppc32/Makefile
4778    none/tests/ppc64/Makefile
4779    none/tests/x86/Makefile
4780    none/tests/arm/Makefile
4781    none/tests/arm64/Makefile
4782    none/tests/s390x/Makefile
4783    none/tests/mips32/Makefile
4784    none/tests/mips64/Makefile
4785    none/tests/linux/Makefile
4786    none/tests/darwin/Makefile
4787    none/tests/solaris/Makefile
4788    none/tests/amd64-linux/Makefile
4789    none/tests/x86-linux/Makefile
4790    none/tests/amd64-darwin/Makefile
4791    none/tests/x86-darwin/Makefile
4792    none/tests/amd64-solaris/Makefile
4793    none/tests/x86-solaris/Makefile
4794    exp-sgcheck/Makefile
4795    exp-sgcheck/tests/Makefile
4796    exp-bbv/Makefile
4797    exp-bbv/tests/Makefile
4798    exp-bbv/tests/x86/Makefile
4799    exp-bbv/tests/x86-linux/Makefile
4800    exp-bbv/tests/amd64-linux/Makefile
4801    exp-bbv/tests/ppc32-linux/Makefile
4802    exp-bbv/tests/arm-linux/Makefile
4803    shared/Makefile
4804    solaris/Makefile
4806 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
4807                 [chmod +x coregrind/link_tool_exe_linux])
4808 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
4809                 [chmod +x coregrind/link_tool_exe_darwin])
4810 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
4811                 [chmod +x coregrind/link_tool_exe_solaris])
4812 AC_OUTPUT
4814 cat<<EOF
4816          Maximum build arch: ${ARCH_MAX}
4817          Primary build arch: ${VGCONF_ARCH_PRI}
4818        Secondary build arch: ${VGCONF_ARCH_SEC}
4819                    Build OS: ${VGCONF_OS}
4820      Link Time Optimisation: ${vg_cv_lto}
4821        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
4822      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
4823            Platform variant: ${VGCONF_PLATVARIANT}
4824       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
4825          Default supp files: ${DEFAULT_SUPP}