drd/tests: Extract start_thread which can come from libpthread or libc
[valgrind.git] / configure.ac
blob3f51bc5c627806268f2365370d515cb2894705df
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.18.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]].*|icc-202[[0-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|amd64) 
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         ;;
289      nanomips)
290         AC_MSG_RESULT([ok (${host_cpu})])
291         ARCH_MAX="nanomips"
292         ;;
294      *) 
295         AC_MSG_RESULT([no (${host_cpu})])
296         AC_MSG_ERROR([Unsupported host architecture. Sorry])
297         ;;
298 esac
300 #----------------------------------------------------------------------------
302 # Sometimes it's convenient to subvert the bi-arch build system and
303 # just have a single build even though the underlying platform is
304 # capable of both.  Hence handle --enable-only64bit and
305 # --enable-only32bit.  Complain if both are issued :-)
306 # [Actually, if either of these options are used, I think both get built,
307 # but only one gets installed.  So if you use an in-place build, both can be
308 # used. --njn]
310 # Check if a 64-bit only build has been requested
311 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
312    [AC_ARG_ENABLE(only64bit, 
313       [  --enable-only64bit      do a 64-bit only build],
314       [vg_cv_only64bit=$enableval],
315       [vg_cv_only64bit=no])])
317 # Check if a 32-bit only build has been requested
318 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
319    [AC_ARG_ENABLE(only32bit, 
320       [  --enable-only32bit      do a 32-bit only build],
321       [vg_cv_only32bit=$enableval],
322       [vg_cv_only32bit=no])])
324 # Stay sane
325 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
326    AC_MSG_ERROR(
327       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
330 #----------------------------------------------------------------------------
332 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
333 # compilation of many C files via -VGO_$(VGCONF_OS) and
334 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
335 AC_MSG_CHECKING([for a supported OS])
336 AC_SUBST(VGCONF_OS)
338 DEFAULT_SUPP=""
340 case "${host_os}" in
341      *linux*)
342         AC_MSG_RESULT([ok (${host_os})])
343         VGCONF_OS="linux"
345         # Ok, this is linux. Check the kernel version
346         AC_MSG_CHECKING([for the kernel version])
348         kernel=`uname -r`
350         case "${kernel}" in
351              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
352                     AC_MSG_RESULT([unsupported (${kernel})])
353                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
354                     ;;
356              *)
357                     AC_MSG_RESULT([2.6 or later (${kernel})])
358                     ;;
359         esac
361         ;;
363      *freebsd*)
364         AC_MSG_RESULT([ok (${host_os})])
365         VGCONF_OS="freebsd"
366         AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
367         AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
368         AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
369         AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
370         AC_DEFINE([FREEBSD_13], 1300, [FREEBSD_VERS value for FreeBSD 13.x])
371         AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
373         AC_MSG_CHECKING([for the kernel version])
374         kernel=`uname -r`
376         case "${kernel}" in
377         10.*)
378            AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
379            AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
380            ;;
381         11.*)
382            AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
383            AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
384            ;;
385         12.*)
386            case "${kernel}" in
387            12.[[0-1]]-*)
388               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
389               AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
390               ;;
391            *)
392               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
393               AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
394               ;;
395            esac
396            ;;
397         13.*)
398            AC_MSG_RESULT([FreeBSD 13.x (${kernel})])
399            AC_DEFINE([FREEBSD_VERS], FREEBSD_13, [FreeBSD version])
400            ;;
401         14.*)
402            AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
403            AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
404            ;;
405         *)
406            AC_MSG_RESULT([unsupported (${kernel})])
407            AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x])
408            ;;
409         esac
411         DEFAULT_SUPP="freebsd.supp freebsd-helgrind.supp freebsd-drd.supp ${DEFAULT_SUPP}"
412         ;;
414      *darwin*)
415         AC_MSG_RESULT([ok (${host_os})])
416         VGCONF_OS="darwin"
417         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
418         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
419         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
420         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
421         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
422         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
423         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
424         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
425         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
427         AC_MSG_CHECKING([for the kernel version])
428         kernel=`uname -r`
430         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
431         # has only one relevant version, the OS version. The `uname` check
432         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
433         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
434         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
435         # and we don't know of an macros similar to __GLIBC__ to get that info.
436         #
437         # XXX: `uname -r` won't do the right thing for cross-compiles, but
438         # that's not a problem yet.
439         #
440         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
441         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
442         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
443         # time support for 10.5 (the 9.* pattern just below), I'll leave it
444         # in for now, just in case anybody wants to give it a try.  But I'm
445         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
446         case "${kernel}" in
447              9.*)
448                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
449                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
450                   DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
451                   DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
452                   ;;
453              10.*)
454                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
455                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
456                   DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
457                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
458                   ;;
459              11.*)
460                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
461                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
462                   DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
463                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
464                   ;;
465              12.*)
466                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
467                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
468                   DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
469                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
470                   ;;
471              13.*)
472                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
473                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
474                   DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
475                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
476                   ;;
477              14.*)
478                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
479                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
480                   DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
481                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
482                   ;;
483              15.*)
484                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
485                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
486                   DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
487                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
488                   ;;
489              16.*)
490                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
491                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
492                   DEFAULT_SUPP="darwin16.supp ${DEFAULT_SUPP}"
493                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
494                   ;;
495              17.*)
496                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
497                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
498                   DEFAULT_SUPP="darwin17.supp ${DEFAULT_SUPP}"
499                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
500                   ;;
501              *) 
502                   AC_MSG_RESULT([unsupported (${kernel})])
503                   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)])
504                   ;;
505         esac
506         ;;
508      solaris2.11*)
509         AC_MSG_RESULT([ok (${host_os})])
510         VGCONF_OS="solaris"
512         uname_v=$( uname -v )
513         case "$uname_v" in
514              11.4.*)
515                  DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
516                  ;;
517              *)
518                  DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
519                  ;;
520         esac
521         ;;
523      solaris2.12*)
524         AC_MSG_RESULT([ok (${host_os})])
525         VGCONF_OS="solaris"
526         DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
527         ;;
529      *) 
530         AC_MSG_RESULT([no (${host_os})])
531         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
532         ;;
533 esac
535 #----------------------------------------------------------------------------
537 # If we are building on a 64 bit platform test to see if the system
538 # supports building 32 bit programs and disable 32 bit support if it
539 # does not support building 32 bit programs
541 case "$ARCH_MAX-$VGCONF_OS" in
542      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
543         AC_MSG_CHECKING([for 32 bit build support])
544         safe_CFLAGS=$CFLAGS
545         CFLAGS="-m32"
546         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
547           return 0;
548         ]])], [
549         AC_MSG_RESULT([yes])
550         ], [
551         vg_cv_only64bit="yes"
552         AC_MSG_RESULT([no])
553         ])
554         CFLAGS=$safe_CFLAGS;;
555     mips64-linux)
556         AC_MSG_CHECKING([for 32 bit build support])
557         safe_CFLAGS=$CFLAGS
558         CFLAGS="$CFLAGS -mips32 -mabi=32"
559         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
560           #include <sys/prctl.h>
561         ]], [[]])], [
562         AC_MSG_RESULT([yes])
563         ], [
564         vg_cv_only64bit="yes"
565         AC_MSG_RESULT([no])
566         ])
567         CFLAGS=$safe_CFLAGS;;
568 esac
570 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
571    AC_MSG_ERROR(
572       [--enable-only32bit was specified but system does not support 32 bit builds])
575 #----------------------------------------------------------------------------
577 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
578 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
579 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
580 # above) will be "amd64" since that reflects the most that this cpu can do,
581 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
582 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
583 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
584 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
585 AC_SUBST(VGCONF_ARCH_PRI)
587 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
588 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
589 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
590 # It is empty if there is no secondary target.
591 AC_SUBST(VGCONF_ARCH_SEC)
593 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
594 # The entire system, including regression and performance tests, will be
595 # built for this target.  The "_CAPS" indicates that the name is in capital
596 # letters, and it also uses '_' rather than '-' as a separator, because it's
597 # used to create various Makefile variables, which are all in caps by
598 # convention and cannot contain '-' characters.  This is in contrast to
599 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
600 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
602 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
603 # Valgrind and tools will also be built for this target, but not the
604 # regression or performance tests.
606 # By default, the primary arch is the same as the "max" arch, as commented
607 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
608 # the big case statement just below here, in the case where we're building
609 # on a 64 bit machine but have been requested only to do a 32 bit build.
610 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
612 AC_MSG_CHECKING([for a supported CPU/OS combination])
614 # NB.  The load address for a given platform may be specified in more 
615 # than one place, in some cases, depending on whether we're doing a biarch,
616 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
617 # Be careful to give consistent values in all subcases.  Also, all four
618 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
619 # even if it is to "0xUNSET".
621 case "$ARCH_MAX-$VGCONF_OS" in
622      x86-linux)
623         VGCONF_ARCH_PRI="x86"
624         VGCONF_ARCH_SEC=""
625         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
626         VGCONF_PLATFORM_SEC_CAPS=""
627         valt_load_address_pri_norml="0x58000000"
628         valt_load_address_pri_inner="0x38000000"
629         valt_load_address_sec_norml="0xUNSET"
630         valt_load_address_sec_inner="0xUNSET"
631         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
632         ;;
633      amd64-linux)
634         valt_load_address_sec_norml="0xUNSET"
635         valt_load_address_sec_inner="0xUNSET"
636         if test x$vg_cv_only64bit = xyes; then
637            VGCONF_ARCH_PRI="amd64"
638            VGCONF_ARCH_SEC=""
639            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
640            VGCONF_PLATFORM_SEC_CAPS=""
641            valt_load_address_pri_norml="0x58000000"
642            valt_load_address_pri_inner="0x38000000"
643         elif test x$vg_cv_only32bit = xyes; then
644            VGCONF_ARCH_PRI="x86"
645            VGCONF_ARCH_SEC=""
646            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
647            VGCONF_PLATFORM_SEC_CAPS=""
648            valt_load_address_pri_norml="0x58000000"
649            valt_load_address_pri_inner="0x38000000"
650         else
651            VGCONF_ARCH_PRI="amd64"
652            VGCONF_ARCH_SEC="x86"
653            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
654            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
655            valt_load_address_pri_norml="0x58000000"
656            valt_load_address_pri_inner="0x38000000"
657            valt_load_address_sec_norml="0x58000000"
658            valt_load_address_sec_inner="0x38000000"
659         fi
660         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
661         ;;
662      ppc32-linux)
663         VGCONF_ARCH_PRI="ppc32"
664         VGCONF_ARCH_SEC=""
665         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
666         VGCONF_PLATFORM_SEC_CAPS=""
667         valt_load_address_pri_norml="0x58000000"
668         valt_load_address_pri_inner="0x38000000"
669         valt_load_address_sec_norml="0xUNSET"
670         valt_load_address_sec_inner="0xUNSET"
671         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
672         ;;
673      ppc64be-linux)
674         valt_load_address_sec_norml="0xUNSET"
675         valt_load_address_sec_inner="0xUNSET"
676         if test x$vg_cv_only64bit = xyes; then
677            VGCONF_ARCH_PRI="ppc64be"
678            VGCONF_ARCH_SEC=""
679            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
680            VGCONF_PLATFORM_SEC_CAPS=""
681            valt_load_address_pri_norml="0x58000000"
682            valt_load_address_pri_inner="0x38000000"
683         elif test x$vg_cv_only32bit = xyes; then
684            VGCONF_ARCH_PRI="ppc32"
685            VGCONF_ARCH_SEC=""
686            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
687            VGCONF_PLATFORM_SEC_CAPS=""
688            valt_load_address_pri_norml="0x58000000"
689            valt_load_address_pri_inner="0x38000000"
690         else
691            VGCONF_ARCH_PRI="ppc64be"
692            VGCONF_ARCH_SEC="ppc32"
693            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
694            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
695            valt_load_address_pri_norml="0x58000000"
696            valt_load_address_pri_inner="0x38000000"
697            valt_load_address_sec_norml="0x58000000"
698            valt_load_address_sec_inner="0x38000000"
699         fi
700         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
701         ;;
702      ppc64le-linux)
703         # Little Endian is only supported on PPC64
704         valt_load_address_sec_norml="0xUNSET"
705         valt_load_address_sec_inner="0xUNSET"
706         VGCONF_ARCH_PRI="ppc64le"
707         VGCONF_ARCH_SEC=""
708         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
709         VGCONF_PLATFORM_SEC_CAPS=""
710         valt_load_address_pri_norml="0x58000000"
711         valt_load_address_pri_inner="0x38000000"
712         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
713        ;;
714      x86-freebsd)
715         VGCONF_ARCH_PRI="x86"
716         VGCONF_ARCH_SEC=""
717         VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
718         VGCONF_PLATFORM_SEC_CAPS=""
719         valt_load_address_pri_norml="0x38000000"
720         valt_load_address_pri_inner="0x28000000"
721         valt_load_address_sec_norml="0xUNSET"
722         valt_load_address_sec_inner="0xUNSET"
723         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
724         ;;
725      amd64-freebsd)
726         if test x$vg_cv_only64bit = xyes; then
727            VGCONF_ARCH_PRI="amd64"
728            VGCONF_ARCH_SEC=""
729            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
730            VGCONF_PLATFORM_SEC_CAPS=""
731         elif test x$vg_cv_only32bit = xyes; then
732            VGCONF_ARCH_PRI="x86"
733            VGCONF_ARCH_SEC=""
734            VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
735            VGCONF_PLATFORM_SEC_CAPS=""
736         else
737            VGCONF_ARCH_PRI="amd64"
738            VGCONF_ARCH_SEC="x86"
739            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
740            VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
741         fi
742         # These work with either base clang or ports installed gcc
743         # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
744         if test x$is_clang = xclang ; then
745            FLAG_32ON64="-B/usr/lib32"
746         else
747            GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
748            FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
749         fi
750         valt_load_address_pri_norml="0x38000000"
751         valt_load_address_pri_inner="0x28000000"
752         valt_load_address_sec_norml="0x38000000"
753         valt_load_address_sec_inner="0x28000000"
754         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
755         ;;
756      # Darwin gets identified as 32-bit even when it supports 64-bit.
757      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
758      # all Macs support both 32-bit and 64-bit, so we just build both.  If
759      # someone has a really old 32-bit only machine they can (hopefully?)
760      # build with --enable-only32bit.  See bug 243362.
761      x86-darwin|amd64-darwin)
762         ARCH_MAX="amd64"
763         valt_load_address_sec_norml="0xUNSET"
764         valt_load_address_sec_inner="0xUNSET"
765         if test x$vg_cv_only64bit = xyes; then
766            VGCONF_ARCH_PRI="amd64"
767            VGCONF_ARCH_SEC=""
768            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
769            VGCONF_PLATFORM_SEC_CAPS=""
770            valt_load_address_pri_norml="0x158000000"
771            valt_load_address_pri_inner="0x138000000"
772         elif test x$vg_cv_only32bit = xyes; then
773            VGCONF_ARCH_PRI="x86"
774            VGCONF_ARCH_SEC=""
775            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
776            VGCONF_PLATFORM_SEC_CAPS=""
777            VGCONF_ARCH_PRI_CAPS="x86"
778            valt_load_address_pri_norml="0x58000000"
779            valt_load_address_pri_inner="0x38000000"
780         else
781            VGCONF_ARCH_PRI="amd64"
782            VGCONF_ARCH_SEC="x86"
783            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
784            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
785            valt_load_address_pri_norml="0x158000000"
786            valt_load_address_pri_inner="0x138000000"
787            valt_load_address_sec_norml="0x58000000"
788            valt_load_address_sec_inner="0x38000000"
789         fi
790         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
791         ;;
792      arm-linux) 
793         VGCONF_ARCH_PRI="arm"
794         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
795         VGCONF_PLATFORM_SEC_CAPS=""
796         valt_load_address_pri_norml="0x58000000"
797         valt_load_address_pri_inner="0x38000000"
798         valt_load_address_sec_norml="0xUNSET"
799         valt_load_address_sec_inner="0xUNSET"
800         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
801         ;;
802      arm64-linux)
803         valt_load_address_sec_norml="0xUNSET"
804         valt_load_address_sec_inner="0xUNSET"
805         if test x$vg_cv_only64bit = xyes; then
806            VGCONF_ARCH_PRI="arm64"
807            VGCONF_ARCH_SEC=""
808            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
809            VGCONF_PLATFORM_SEC_CAPS=""
810            valt_load_address_pri_norml="0x58000000"
811            valt_load_address_pri_inner="0x38000000"
812         elif test x$vg_cv_only32bit = xyes; then
813            VGCONF_ARCH_PRI="arm"
814            VGCONF_ARCH_SEC=""
815            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
816            VGCONF_PLATFORM_SEC_CAPS=""
817            valt_load_address_pri_norml="0x58000000"
818            valt_load_address_pri_inner="0x38000000"
819         else
820            VGCONF_ARCH_PRI="arm64"
821            VGCONF_ARCH_SEC="arm"
822            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
823            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
824            valt_load_address_pri_norml="0x58000000"
825            valt_load_address_pri_inner="0x38000000"
826            valt_load_address_sec_norml="0x58000000"
827            valt_load_address_sec_inner="0x38000000"
828         fi
829         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
830         ;;
831      s390x-linux)
832         VGCONF_ARCH_PRI="s390x"
833         VGCONF_ARCH_SEC=""
834         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
835         VGCONF_PLATFORM_SEC_CAPS=""
836         # To improve branch prediction hit rate we want to have
837         # the generated code close to valgrind (host) code
838         valt_load_address_pri_norml="0x800000000"
839         valt_load_address_pri_inner="0x810000000"
840         valt_load_address_sec_norml="0xUNSET"
841         valt_load_address_sec_inner="0xUNSET"
842         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
843         ;;
844      mips32-linux) 
845         VGCONF_ARCH_PRI="mips32"
846         VGCONF_ARCH_SEC=""
847         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
848         VGCONF_PLATFORM_SEC_CAPS=""
849         valt_load_address_pri_norml="0x58000000"
850         valt_load_address_pri_inner="0x38000000"
851         valt_load_address_sec_norml="0xUNSET"
852         valt_load_address_sec_inner="0xUNSET"
853         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
854         ;;
855      mips64-linux)
856         valt_load_address_sec_norml="0xUNSET"
857         valt_load_address_sec_inner="0xUNSET"
858         if test x$vg_cv_only64bit = xyes; then
859             VGCONF_ARCH_PRI="mips64"
860             VGCONF_PLATFORM_SEC_CAPS=""
861             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
862             VGCONF_PLATFORM_SEC_CAPS=""
863             valt_load_address_pri_norml="0x58000000"
864             valt_load_address_pri_inner="0x38000000"
865         elif test x$vg_cv_only32bit = xyes; then
866             VGCONF_ARCH_PRI="mips32"
867             VGCONF_ARCH_SEC=""
868             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
869             VGCONF_PLATFORM_SEC_CAPS=""
870             valt_load_address_pri_norml="0x58000000"
871             valt_load_address_pri_inner="0x38000000"
872         else
873             VGCONF_ARCH_PRI="mips64"
874             VGCONF_ARCH_SEC="mips32"
875             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
876             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
877             valt_load_address_pri_norml="0x58000000"
878             valt_load_address_pri_inner="0x38000000"
879             valt_load_address_sec_norml="0x58000000"
880             valt_load_address_sec_inner="0x38000000"
881         fi
882         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
883         ;;
884      nanomips-linux)
885         VGCONF_ARCH_PRI="nanomips"
886         VGCONF_ARCH_SEC=""
887         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
888         VGCONF_PLATFORM_SEC_CAPS=""
889         valt_load_address_pri_norml="0x58000000"
890         valt_load_address_pri_inner="0x38000000"
891         valt_load_address_sec_norml="0xUNSET"
892         valt_load_address_sec_inner="0xUNSET"
893         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
894         ;;
895      x86-solaris)
896         VGCONF_ARCH_PRI="x86"
897         VGCONF_ARCH_SEC=""
898         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
899         VGCONF_PLATFORM_SEC_CAPS=""
900         valt_load_address_pri_norml="0x58000000"
901         valt_load_address_pri_inner="0x38000000"
902         valt_load_address_sec_norml="0xUNSET"
903         valt_load_address_sec_inner="0xUNSET"
904         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
905         ;;
906      amd64-solaris)
907         valt_load_address_sec_norml="0xUNSET"
908         valt_load_address_sec_inner="0xUNSET"
909         if test x$vg_cv_only64bit = xyes; then
910            VGCONF_ARCH_PRI="amd64"
911            VGCONF_ARCH_SEC=""
912            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
913            VGCONF_PLATFORM_SEC_CAPS=""
914            valt_load_address_pri_norml="0x58000000"
915            valt_load_address_pri_inner="0x38000000"
916         elif test x$vg_cv_only32bit = xyes; then
917            VGCONF_ARCH_PRI="x86"
918            VGCONF_ARCH_SEC=""
919            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
920            VGCONF_PLATFORM_SEC_CAPS=""
921            valt_load_address_pri_norml="0x58000000"
922            valt_load_address_pri_inner="0x38000000"
923         else
924            VGCONF_ARCH_PRI="amd64"
925            VGCONF_ARCH_SEC="x86"
926            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
927            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
928            valt_load_address_pri_norml="0x58000000"
929            valt_load_address_pri_inner="0x38000000"
930            valt_load_address_sec_norml="0x58000000"
931            valt_load_address_sec_inner="0x38000000"
932         fi
933         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
934         ;;
935     *)
936         VGCONF_ARCH_PRI="unknown"
937         VGCONF_ARCH_SEC="unknown"
938         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
939         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
940         valt_load_address_pri_norml="0xUNSET"
941         valt_load_address_pri_inner="0xUNSET"
942         valt_load_address_sec_norml="0xUNSET"
943         valt_load_address_sec_inner="0xUNSET"
944         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
945         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
946         ;;
947 esac
949 #----------------------------------------------------------------------------
951 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
952 # defined.
953 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
954                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
955                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
956                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
957                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
958                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
959                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
960                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
961                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
962 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
963                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
964                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
965                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
966                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
967 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
968                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
969                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
970 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
971                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
972                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
973 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
974                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
975                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
976 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
977                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
978 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
979                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
980 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
981                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
982                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
983 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
984                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
985 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
986                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
988 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
989 # become defined.
990 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
991                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
992                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
993 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
994                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
995 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
996                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
997                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
998 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
999                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1000 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1001                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1002 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1003                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1004                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1005 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1006                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1007 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1008                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1009                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1010 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1011                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1012                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1013 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1014                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1015 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1016                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1017 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1018                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1019                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1020 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1021                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1022 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1023                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1024                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1025 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1026                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1027 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1028                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1029                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1030 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1031                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1034 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1035 # Relies on the assumption that the primary and secondary targets are 
1036 # for the same OS, so therefore only necessary to test the primary.
1037 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1038                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1039                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1040                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1041                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1042                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1043                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1044                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1045                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1046                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1047                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1048                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1049 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1050                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1051                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1052 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1053                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1054                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1055 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1056                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1057                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1058 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1059                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1060                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1061                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1062                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1065 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1066 # there is a secondary target.
1067 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1068                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1070 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1071 dnl fallback definition
1072 dnl The macro is courtesy of Dave Hart:
1073 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1074 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1075 if test -z "$$1_TRUE"; then :
1076   m4_n([$2])[]dnl
1077 m4_ifval([$3],
1078 [else
1079   $3
1080 ])dnl
1081 fi[]dnl
1082 ])])
1084 #----------------------------------------------------------------------------
1085 # Inner Valgrind?
1086 #----------------------------------------------------------------------------
1088 # Check if this should be built as an inner Valgrind, to be run within
1089 # another Valgrind.  Choose the load address accordingly.
1090 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1091 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1092 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1093    [AC_ARG_ENABLE(inner, 
1094       [  --enable-inner          enables self-hosting],
1095       [vg_cv_inner=$enableval],
1096       [vg_cv_inner=no])])
1097 if test "$vg_cv_inner" = yes; then
1098     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1099     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1100     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1101 else
1102     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1103     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1106 #----------------------------------------------------------------------------
1107 # Undefined behaviour sanitiser
1108 #----------------------------------------------------------------------------
1109 # Check whether we should build with the undefined beahviour sanitiser.
1111 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1112    [AC_ARG_ENABLE(ubsan, 
1113       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1114       [vg_cv_ubsan=$enableval],
1115       [vg_cv_ubsan=no])])
1117 #----------------------------------------------------------------------------
1118 # Extra fine-tuning of installation directories
1119 #----------------------------------------------------------------------------
1120 AC_ARG_WITH(tmpdir,
1121    [  --with-tmpdir=PATH      Specify path for temporary files],
1122    tmpdir="$withval",
1123    tmpdir="/tmp")
1124 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1125 AC_SUBST(VG_TMPDIR, [$tmpdir])
1127 #----------------------------------------------------------------------------
1128 # Detect xcode path
1129 #----------------------------------------------------------------------------
1130 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1131 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1132 AC_MSG_CHECKING([for xcode sdk include path])
1133 AC_ARG_WITH(xcodedir,
1134    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1135    [xcodedir="$withval"],
1136    [
1137       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1138          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1139          if test -z "$xcrundir"; then
1140             xcodedir="/usr/include"
1141          else
1142             xcodedir="$xcrundir/usr/include"
1143          fi
1144       else
1145          xcodedir="/usr/include"
1146       fi
1147    ])
1148 AC_MSG_RESULT([$xcodedir])
1149 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1150 AC_SUBST(XCODE_DIR, [$xcodedir])])
1152 #----------------------------------------------------------------------------
1153 # Libc and suppressions
1154 #----------------------------------------------------------------------------
1155 # This variable will collect the suppression files to be used.
1156 AC_SUBST(DEFAULT_SUPP)
1158 AC_CHECK_HEADER([features.h])
1160 if test x$ac_cv_header_features_h = xyes; then
1161   rm -f conftest.$ac_ext
1162   cat <<_ACEOF >conftest.$ac_ext
1163 #include <features.h>
1164 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1165 glibc version is: __GLIBC__ __GLIBC_MINOR__
1166 #endif
1167 _ACEOF
1168   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1171 # not really a version check
1172 AC_EGREP_CPP([DARWIN_LIBC], [
1173 #include <sys/cdefs.h>
1174 #if defined(__DARWIN_VERS_1050)
1175   DARWIN_LIBC
1176 #endif
1178 GLIBC_VERSION="darwin")
1180 AC_EGREP_CPP([FREEBSD_LIBC], [
1181 #include <sys/cdefs.h>
1182 #if defined(__FreeBSD__)
1183   FREEBSD_LIBC
1184 #endif
1186 GLIBC_VERSION="freebsd")
1188 # not really a version check
1189 AC_EGREP_CPP([BIONIC_LIBC], [
1190 #if defined(__ANDROID__)
1191   BIONIC_LIBC
1192 #endif
1194 GLIBC_VERSION="bionic")
1196 # there is only one version of libc on Solaris
1197 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1198      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1199     GLIBC_VERSION="solaris"
1202 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1203 # in this case.
1204 if test x$GLIBC_VERSION = x; then
1205     if $CC -dumpmachine | grep -q musl; then
1206         GLIBC_VERSION=musl
1207     fi
1210 # If this is glibc then figure out the generic (in file) libc.so and
1211 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1212 # was a separate library, afterwards it was merged into libc.so and
1213 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1214 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1215 case ${GLIBC_VERSION} in
1217   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1218   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1219   [
1220     AC_MSG_RESULT([no])
1221     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1222     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1223   ], [
1224     AC_MSG_RESULT([yes])
1225     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1226     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1227   ])
1228   ;;
1230   AC_MSG_CHECKING([not glibc...])
1231   AC_MSG_RESULT([${GLIBC_VERSION}])
1232   ;;
1233 esac
1235 AC_MSG_CHECKING([the glibc version])
1237 case "${GLIBC_VERSION}" in
1238      2.2)
1239         AC_MSG_RESULT(${GLIBC_VERSION} family)
1240         DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1241         DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1242         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1243         ;;
1244      2.[[3-6]])
1245         AC_MSG_RESULT(${GLIBC_VERSION} family)
1246         DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1247         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1248         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1249         ;;
1250      2.[[7-9]])
1251         AC_MSG_RESULT(${GLIBC_VERSION} family)
1252         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1253         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1254         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1255         ;;
1256      2.10|2.11)
1257         AC_MSG_RESULT(${GLIBC_VERSION} family)
1258         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1259                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1260         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1261         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1262         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1263         ;;
1264      2.*)
1265         AC_MSG_RESULT(${GLIBC_VERSION} family)
1266         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1267                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1268         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1269                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1270         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1271         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1272         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1273         ;;
1274      darwin)
1275         AC_MSG_RESULT(Darwin)
1276         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1277         # DEFAULT_SUPP set by kernel version check above.
1278         ;;
1279      freebsd)
1280         AC_MSG_RESULT(FreeBSD)
1281         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1282         # DEFAULT_SUPP set by kernel version check above.
1283         ;;
1284      bionic)
1285         AC_MSG_RESULT(Bionic)
1286         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1287         DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1288         ;;
1289      solaris)
1290         AC_MSG_RESULT(Solaris)
1291         # DEFAULT_SUPP set in host_os switch-case above.
1292         # No other suppression file is used.
1293         ;;
1294      musl)
1295         AC_MSG_RESULT(Musl)
1296         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1297         DEFAULT_SUPP="musl.supp ${DEFAULT_SUPP}"
1298         ;;
1299      2.0|2.1|*)
1300         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1301         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1302         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1303         ;;
1304 esac
1306 AC_SUBST(GLIBC_VERSION)
1307 AC_SUBST(GLIBC_LIBC_PATH)
1308 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1311 if test "$VGCONF_OS" != "solaris"; then
1312     # Add default suppressions for the X client libraries.  Make no
1313     # attempt to detect whether such libraries are installed on the
1314     # build machine (or even if any X facilities are present); just
1315     # add the suppressions antidisirregardless.
1316     DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1317     DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1321 #----------------------------------------------------------------------------
1322 # Platform variants?
1323 #----------------------------------------------------------------------------
1325 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1326 # But there are times where we need a bit more control.  The motivating
1327 # and currently only case is Android: this is almost identical to
1328 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1329 # platform variant tags, which get passed in the compile as
1330 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1332 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1333 # it is "android" instead.
1335 # Consequently (eg), plain arm-linux would build with
1337 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1339 # whilst an Android build would have
1341 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1343 # Same for x86. The setup of the platform variant is pushed relatively far
1344 # down this file in order that we can inspect any of the variables set above.
1346 # In the normal case ..
1347 VGCONF_PLATVARIANT="vanilla"
1349 # Android ?
1350 if test "$GLIBC_VERSION" = "bionic";
1351 then
1352    VGCONF_PLATVARIANT="android"
1355 AC_SUBST(VGCONF_PLATVARIANT)
1358 # FIXME: do we also want to define automake variables
1359 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1360 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1361 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1362 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1363 # that's what we'd need to do to use this, since what we'd want to write
1364 # is something like
1366 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1368 # Hmm.  Can't think of a nice clean solution to this.
1370 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1371                test x$VGCONF_PLATVARIANT = xvanilla)
1372 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1373                test x$VGCONF_PLATVARIANT = xandroid)
1376 #----------------------------------------------------------------------------
1377 # Checking for various library functions and other definitions
1378 #----------------------------------------------------------------------------
1380 # Check for AT_FDCWD
1382 AC_MSG_CHECKING([for AT_FDCWD])
1383 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1384 #define _GNU_SOURCE
1385 #include <fcntl.h>
1386 #include <unistd.h>
1387 ]], [[
1388   int a = AT_FDCWD;
1389 ]])], [
1390 ac_have_at_fdcwd=yes
1391 AC_MSG_RESULT([yes])
1392 ], [
1393 ac_have_at_fdcwd=no
1394 AC_MSG_RESULT([no])
1397 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1399 # Check for stpncpy function definition in string.h
1400 # This explicitly checks with _GNU_SOURCE defined since that is also
1401 # used in the test case (some systems might define it without anyway
1402 # since stpncpy is part of The Open Group Base Specifications Issue 7
1403 # IEEE Std 1003.1-2008.
1404 AC_MSG_CHECKING([for stpncpy])
1405 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1406 #define _GNU_SOURCE
1407 #include <string.h>
1408 ]], [[
1409   char *d;
1410   char *s;
1411   size_t n = 0;
1412   char *r = stpncpy(d, s, n);
1413 ]])], [
1414 ac_have_gnu_stpncpy=yes
1415 AC_MSG_RESULT([yes])
1416 ], [
1417 ac_have_gnu_stpncpy=no
1418 AC_MSG_RESULT([no])
1421 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1423 # Check for PTRACE_GETREGS
1425 AC_MSG_CHECKING([for PTRACE_GETREGS])
1426 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1427 #include <stdlib.h>
1428 #include <stddef.h>
1429 #include <sys/ptrace.h>
1430 #include <sys/user.h>
1431 ]], [[
1432   void *p;
1433   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1434 ]])], [
1435 AC_MSG_RESULT([yes])
1436 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1437           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1438 ], [
1439 AC_MSG_RESULT([no])
1443 # Check for CLOCK_MONOTONIC
1445 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1447 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1448 #include <time.h>
1449 ]], [[
1450   struct timespec t;
1451   clock_gettime(CLOCK_MONOTONIC, &t);
1452   return 0;
1453 ]])], [
1454 AC_MSG_RESULT([yes])
1455 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1456           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1457 ], [
1458 AC_MSG_RESULT([no])
1462 # Check for ELF32/64_CHDR
1464 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1467 # Check for PTHREAD_RWLOCK_T
1469 AC_MSG_CHECKING([for pthread_rwlock_t])
1471 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1472 #define _GNU_SOURCE
1473 #include <pthread.h>
1474 ]], [[
1475   pthread_rwlock_t rwl;
1476 ]])], [
1477 AC_MSG_RESULT([yes])
1478 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1479           [Define to 1 if you have the `pthread_rwlock_t' type.])
1480 ], [
1481 AC_MSG_RESULT([no])
1485 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1487 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1489 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1490 #define _GNU_SOURCE
1491 #include <pthread.h>
1492 ]], [[
1493   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1494 ]])], [
1495 AC_MSG_RESULT([yes])
1496 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1497           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1498 ], [
1499 AC_MSG_RESULT([no])
1503 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1505 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1507 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1508 #define _GNU_SOURCE
1509 #include <pthread.h>
1510 ]], [[
1511   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1512 ]])], [
1513 AC_MSG_RESULT([yes])
1514 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1515           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1516 ], [
1517 AC_MSG_RESULT([no])
1521 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1523 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1525 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1526 #define _GNU_SOURCE
1527 #include <pthread.h>
1528 ]], [[
1529   return (PTHREAD_MUTEX_RECURSIVE_NP);
1530 ]])], [
1531 AC_MSG_RESULT([yes])
1532 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1533           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1534 ], [
1535 AC_MSG_RESULT([no])
1539 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1541 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1543 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1544 #define _GNU_SOURCE
1545 #include <pthread.h>
1546 ]], [[
1547   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1548   return 0;
1549 ]])], [
1550 AC_MSG_RESULT([yes])
1551 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1552           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1553 ], [
1554 AC_MSG_RESULT([no])
1558 # Check whether pthread_mutex_t has a member called __m_kind.
1560 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1561                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1562                            1,                                   
1563                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1564                 ],
1565                 [],
1566                 [#include <pthread.h>])
1569 # Check whether pthread_mutex_t has a member called __data.__kind.
1571 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1572                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1573                           1,
1574                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1575                 ],
1576                 [],
1577                 [#include <pthread.h>])
1579 # Convenience function.  Set flags based on the existing HWCAP entries.
1580 # The AT_HWCAP entries are generated by glibc, and are based on
1581 # functions supported by the hardware/system/libc.
1582 # Subsequent support for whether the capability will actually be utilized
1583 # will also be checked against the compiler capabilities.
1584 # called as
1585 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1586 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1587   AUXV_CHECK_FOR=$1
1588   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1589   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1590   then
1591     AC_MSG_RESULT([yes])
1592     AC_SUBST([$2],[yes])
1593   else
1594     AC_MSG_RESULT([no])
1595     AC_SUBST([$2],[])
1596   fi
1599 # gather hardware capabilities. (hardware/kernel/libc)
1600 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1601 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1602 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1603 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1604 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1605 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1606 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1607 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1608 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1609 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1611 # ISA Levels
1612 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1613 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1614 # compiler support for isa 2.07 level instructions
1615 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1616 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1617 ]], [[
1618   __asm__ __volatile__("mtvsrd 1,2 ");
1619 ]])], [
1620 ac_asm_have_isa_2_07=yes
1621 AC_MSG_RESULT([yes])
1622 ], [
1623 ac_asm_have_isa_2_07=no
1624 AC_MSG_RESULT([no])
1626 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1627                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1629 # altivec (vsx) support.
1630 # does this compiler support -maltivec and does it have the include file
1631 # <altivec.h> ?
1632 AC_MSG_CHECKING([for Altivec support in the compiler ])
1633 safe_CFLAGS=$CFLAGS
1634 CFLAGS="-maltivec -Werror"
1635 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1636 #include <altivec.h>
1637 ]], [[
1638   vector unsigned int v;
1639 ]])], [
1640 ac_have_altivec=yes
1641 AC_MSG_RESULT([yes])
1642 ], [
1643 ac_have_altivec=no
1644 AC_MSG_RESULT([no])
1646 CFLAGS=$safe_CFLAGS
1647 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1648                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1650 # Check that both: the compiler supports -mvsx and that the assembler
1651 # understands VSX instructions.  If either of those doesn't work,
1652 # conclude that we can't do VSX.
1653 AC_MSG_CHECKING([for VSX compiler flag support])
1654 safe_CFLAGS=$CFLAGS
1655 CFLAGS="-mvsx -Werror"
1656 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1657 ]], [[
1658 ]])], [
1659 ac_compiler_supports_vsx_flag=yes
1660 AC_MSG_RESULT([yes])
1661 ], [
1662 ac_compiler_supports_vsx_flag=no
1663 AC_MSG_RESULT([no])
1665 CFLAGS=$safe_CFLAGS
1667 AC_MSG_CHECKING([for VSX support in the assembler ])
1668 safe_CFLAGS=$CFLAGS
1669 CFLAGS="-mvsx -Werror"
1670 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1671 #include <altivec.h>
1672 ]], [[
1673   vector unsigned int v;
1674   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1675 ]])], [
1676 ac_compiler_supports_vsx=yes
1677 AC_MSG_RESULT([yes])
1678 ], [
1679 ac_compiler_supports_vsx=no
1680 AC_MSG_RESULT([no])
1682 CFLAGS=$safe_CFLAGS
1683 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1684                              -a x$ac_compiler_supports_vsx = xyes \
1685                              -a x$HWCAP_HAS_VSX = xyes ])
1687 # DFP (Decimal Float)
1688 # The initial DFP support was added in Power 6.  The dcffix instruction
1689 # support was added in Power 7.
1690 AC_MSG_CHECKING([that assembler knows DFP])
1691 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1692 ]], [[
1693   #ifdef __s390__
1694   __asm__ __volatile__("adtr 1, 2, 3")
1695   #else
1696 __asm__ __volatile__(".machine power7;\n" \
1697   "dadd 1, 2, 3;\n" \
1698   "dcffix 1, 2");
1699   #endif
1700 ]])], [
1701 ac_asm_have_dfp=yes
1702 AC_MSG_RESULT([yes])
1703 ], [
1704 ac_asm_have_dfp=no
1705 AC_MSG_RESULT([no])
1707 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1708 safe_CFLAGS=$CFLAGS
1709 CFLAGS="-mhard-dfp -Werror"
1711 # The dcffix instruction is Power 7
1712 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1713 ]], [[
1714   #ifdef __s390__
1715   __asm__ __volatile__("adtr 1, 2, 3")
1716   #else
1717   __asm__ __volatile__(".machine power7;\n" \
1718   "dadd 1, 2, 3;\n" \
1719   "dcffix 1, 2");
1720   #endif
1721 ]])], [
1722 ac_compiler_have_dfp=yes
1723 AC_MSG_RESULT([yes])
1724 ], [
1725 ac_compiler_have_dfp=no
1726 AC_MSG_RESULT([no])
1728 CFLAGS=$safe_CFLAGS
1729 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1730                           -a x$ac_compiler_have_dfp = xyes \
1731                           -a x$HWCAP_HAS_DFP = xyes )
1733 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1734 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1735 ]], [[
1736   _Decimal64 x = 0.0DD;
1737 ]])], [
1738 ac_compiler_have_dfp_type=yes
1739 AC_MSG_RESULT([yes])
1740 ], [
1741 ac_compiler_have_dfp_type=no
1742 AC_MSG_RESULT([no])
1744 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1745                                   -a x$HWCAP_HAS_DFP = xyes )
1748 # HTM (Hardware Transactional Memory)
1749 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1750 safe_CFLAGS=$CFLAGS
1751 CFLAGS="-mhtm -Werror"
1752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1753 ]], [[
1754   return 0;
1755 ]])], [
1756 AC_MSG_RESULT([yes])
1757 ac_compiler_supports_htm=yes
1758 ], [
1759 AC_MSG_RESULT([no])
1760 ac_compiler_supports_htm=no
1762 CFLAGS=$safe_CFLAGS
1764 AC_MSG_CHECKING([if compiler can find the htm builtins])
1765 safe_CFLAGS=$CFLAGS
1766 CFLAGS="-mhtm -Werror"
1767  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1768  ]], [[
1769    if (__builtin_tbegin (0))
1770       __builtin_tend (0);
1771  ]])], [
1772  AC_MSG_RESULT([yes])
1773 ac_compiler_sees_htm_builtins=yes
1774  ], [
1775  AC_MSG_RESULT([no])
1776 ac_compiler_sees_htm_builtins=no
1777  ])
1778 CFLAGS=$safe_CFLAGS
1780 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1781                                -a x$ac_compiler_sees_htm_builtins = xyes \
1782                                -a x$HWCAP_HAS_HTM = xyes )
1784 # isa 3.0 checking. (actually 3.0 or newer)
1785 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1787 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1788 ]], [[
1789 __asm__ __volatile__ (".machine power9;\n" \
1790         "cnttzw   1,3; \n" );
1791 ]])], [
1792 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1793 # cpabort support
1794 safe_CFLAGS=$CFLAGS
1795 CFLAGS="-DHAS_ISA_3_00"
1796 ac_asm_have_isa_3_00=yes
1797 AC_MSG_RESULT([yes])
1798 ], [
1799 ac_asm_have_isa_3_00=no
1800 AC_MSG_RESULT([no])
1802 CFLAGS=$safe_CFLAGS
1804 # xscvhpdp checking
1805 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1807 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1808 ]], [[
1809 __asm__ __volatile__ (".machine power9;\n" \
1810         "xscvhpdp 1,2;\n" );
1811 ]])], [
1812 ac_asm_have_xscvhpdp=yes
1813 AC_MSG_RESULT([yes])
1814 ], [
1815 ac_asm_have_xscvhpdp=no
1816 AC_MSG_RESULT([no])
1819 # darn instruction checking
1820 AC_MSG_CHECKING([that assembler knows darn instruction ])
1822 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1823 ]], [[
1824   __asm__ __volatile__(".machine power9; darn 1,0 ");
1825 ]])], [
1826 ac_asm_have_darn_inst=yes
1827 AC_MSG_RESULT([yes])
1828 ], [
1829 ac_asm_have_darn_inst=no
1830 AC_MSG_RESULT([no])
1833 # isa 3.01 checking
1834 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1835 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1836 ]], [[
1837 __asm__ __volatile__ (".machine power10;\n" \
1838         "brh 1,2;\n ");
1839 ]])], [
1840 ac_asm_have_isa_3_1=yes
1841 AC_MSG_RESULT([yes])
1842 ], [
1843 ac_asm_have_isa_3_1=no
1844 AC_MSG_RESULT([no])
1848 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1849                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1851 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1852 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1854 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1855                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1857 # Check for pthread_create@GLIBC2.0
1858 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1860 safe_CFLAGS=$CFLAGS
1861 CFLAGS="-lpthread -Werror"
1862 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1863 extern int pthread_create_glibc_2_0(void*, const void*,
1864                                     void *(*)(void*), void*);
1865 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1866 ]], [[
1867 #ifdef __powerpc__
1869  * Apparently on PowerPC linking this program succeeds and generates an
1870  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1871  */
1872 #error This test does not work properly on PowerPC.
1873 #else
1874   pthread_create_glibc_2_0(0, 0, 0, 0);
1875 #endif
1876   return 0;
1877 ]])], [
1878 ac_have_pthread_create_glibc_2_0=yes
1879 AC_MSG_RESULT([yes])
1880 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1881           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1882 ], [
1883 ac_have_pthread_create_glibc_2_0=no
1884 AC_MSG_RESULT([no])
1886 CFLAGS=$safe_CFLAGS
1888 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1889                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1892 # Check for dlinfo RTLD_DI_TLS_MODID
1893 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1895 safe_LIBS="$LIBS"
1896 LIBS="-ldl"
1897 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1898 #ifndef _GNU_SOURCE
1899 #define _GNU_SOURCE
1900 #endif
1901 #include <link.h>
1902 #include <dlfcn.h>
1903 ]], [[
1904   size_t sizes[10000];
1905   size_t modid_offset;
1906   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1907   return 0;
1908 ]])], [
1909 ac_have_dlinfo_rtld_di_tls_modid=yes
1910 AC_MSG_RESULT([yes])
1911 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1912           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1913 ], [
1914 ac_have_dlinfo_rtld_di_tls_modid=no
1915 AC_MSG_RESULT([no])
1917 LIBS=$safe_LIBS
1919 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1920                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1923 # Check for eventfd_t, eventfd() and eventfd_read()
1924 AC_MSG_CHECKING([for eventfd()])
1926 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1927 #include <sys/eventfd.h>
1928 ]], [[
1929   eventfd_t ev;
1930   int fd;
1932   fd = eventfd(5, 0);
1933   eventfd_read(fd, &ev);
1934   return 0;
1935 ]])], [
1936 AC_MSG_RESULT([yes])
1937 AC_DEFINE([HAVE_EVENTFD], 1,
1938           [Define to 1 if you have the `eventfd' function.])
1939 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1940           [Define to 1 if you have the `eventfd_read' function.])
1941 ], [
1942 AC_MSG_RESULT([no])
1945 # Check whether compiler can process #include <thread> without errors
1946 # clang 3.3 cannot process <thread> from e.g.
1947 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1949 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1950 AC_LANG(C++)
1951 safe_CXXFLAGS=$CXXFLAGS
1952 CXXFLAGS=-std=c++0x
1954 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1955 #include <thread> 
1956 ])],
1958 ac_cxx_can_include_thread_header=yes
1959 AC_MSG_RESULT([yes])
1960 ], [
1961 ac_cxx_can_include_thread_header=no
1962 AC_MSG_RESULT([no])
1964 CXXFLAGS=$safe_CXXFLAGS
1965 AC_LANG(C)
1967 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1970 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1971 # of the user_regs_struct from sys/user.h. They are structurally the same
1972 # but we get either one or the other.
1974 AC_CHECK_TYPE([struct user_regs_struct],
1975               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1976               [[#include <sys/ptrace.h>]
1977                [#include <sys/time.h>]
1978                [#include <sys/user.h>]])
1979 if test "$sys_user_has_user_regs" = "yes"; then
1980   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1981             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1984 AC_MSG_CHECKING([for __NR_membarrier])
1985 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1986 #include <linux/unistd.h>
1987 ]], [[
1988 return __NR_membarrier
1989 ]])], [
1990 ac_have_nr_membarrier=yes
1991 AC_MSG_RESULT([yes])
1992 ], [
1993 ac_have_nr_membarrier=no
1994 AC_MSG_RESULT([no])
1997 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
1999 #----------------------------------------------------------------------------
2000 # Checking for supported compiler flags.
2001 #----------------------------------------------------------------------------
2003 case "${host_cpu}" in
2004     mips*)
2005         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2006         if test -z "$ARCH"; then
2007           # does this compiler support -march=mips32 (mips32 default) ?
2008           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2010           safe_CFLAGS=$CFLAGS
2011           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2013           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2014             return 0;
2015           ]])], [
2016           FLAG_M32="-mips32 -mabi=32"
2017           AC_MSG_RESULT([yes])
2018           ], [
2019           FLAG_M32=""
2020           AC_MSG_RESULT([no])
2021           ])
2022           CFLAGS=$safe_CFLAGS
2024           AC_SUBST(FLAG_M32)
2027           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2028           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2030           safe_CFLAGS=$CFLAGS
2031           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2033           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2034             return 0;
2035           ]])], [
2036           FLAG_M64="-march=mips64r2 -mabi=64"
2037           AC_MSG_RESULT([yes])
2038           ], [
2039           FLAG_M64=""
2040           AC_MSG_RESULT([no])
2041           ])
2042           CFLAGS=$safe_CFLAGS
2044           AC_SUBST(FLAG_M64)
2045         fi
2046         ;;
2047     nanomips*)
2048         ;;
2049     *)
2050         # does this compiler support -m32 ?
2051         AC_MSG_CHECKING([if gcc accepts -m32])
2053         safe_CFLAGS=$CFLAGS
2054         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2056         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2057           return 0;
2058         ]])], [
2059         FLAG_M32="${FLAG_32ON64} -m32"
2060         AC_MSG_RESULT([yes])
2061         ], [
2062         FLAG_M32=""
2063         AC_MSG_RESULT([no])
2064         ])
2065         CFLAGS=$safe_CFLAGS
2067         AC_SUBST(FLAG_M32)
2070         # does this compiler support -m64 ?
2071         AC_MSG_CHECKING([if gcc accepts -m64])
2073         safe_CFLAGS=$CFLAGS
2074         CFLAGS="-m64 -Werror"
2076         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2077           return 0;
2078         ]])], [
2079         FLAG_M64="-m64"
2080         AC_MSG_RESULT([yes])
2081         ], [
2082         FLAG_M64=""
2083         AC_MSG_RESULT([no])
2084         ])
2085         CFLAGS=$safe_CFLAGS
2087         AC_SUBST(FLAG_M64)
2088         ;;
2089 esac
2092 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2093 if test -z "$ARCH"; then
2094   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2095   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2097   safe_CFLAGS=$CFLAGS
2098   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2100   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2101     return 0;
2102   ]])], [
2103   FLAG_OCTEON="-march=octeon"
2104   AC_MSG_RESULT([yes])
2105   ], [
2106   FLAG_OCTEON=""
2107   AC_MSG_RESULT([no])
2108   ])
2109   CFLAGS=$safe_CFLAGS
2111   AC_SUBST(FLAG_OCTEON)
2114   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2115   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2117   safe_CFLAGS=$CFLAGS
2118   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2120   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2121     return 0;
2122   ]])], [
2123   FLAG_OCTEON2="-march=octeon2"
2124   AC_MSG_RESULT([yes])
2125   ], [
2126   FLAG_OCTEON2=""
2127   AC_MSG_RESULT([no])
2128   ])
2129   CFLAGS=$safe_CFLAGS
2131   AC_SUBST(FLAG_OCTEON2)
2135 # does this compiler support -mmsa (MIPS MSA ASE) ?
2136 AC_MSG_CHECKING([if gcc accepts -mmsa])
2138 safe_CFLAGS=$CFLAGS
2139 CFLAGS="$CFLAGS -mmsa -Werror"
2141 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2142     return 0;
2143 ]])], [
2144 FLAG_MSA="-mmsa"
2145 AC_MSG_RESULT([yes])
2146 ], [
2147 FLAG_MSA=""
2148 AC_MSG_RESULT([no])
2150 CFLAGS=$safe_CFLAGS
2152 AC_SUBST(FLAG_MSA)
2154 # Are we compiling for the MIPS64 n32 ABI?
2155 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2156 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2157 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2158 #error NO
2159 #endif
2160 ]])], [
2161 VGCONF_ABI=N32
2162 FLAG_M64="-march=mips64r2 -mabi=n32"
2163 AC_MSG_RESULT([yes])
2164 ], [
2165 AC_MSG_RESULT([no])
2168 # Are we compiling for the MIPS64 n64 ABI?
2169 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2170 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2171 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2172 #error NO
2173 #endif
2174 ]])], [
2175 VGCONF_ABI=64
2176 AC_MSG_RESULT([yes])
2177 ], [
2178 AC_MSG_RESULT([no])
2181 # We enter the code block below in the following case:
2182 # Target architecture is set to mips64, the desired abi
2183 # was not specified and the compiler's default abi setting
2184 # is neither n32 nor n64.
2185 # Probe for and set the abi to either n64 or n32, in that order,
2186 # which is required for a mips64 build of valgrind.
2187 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2188   safe_CFLAGS=$CFLAGS
2189   CFLAGS="$CFLAGS -mabi=64 -Werror"
2190   AC_MSG_CHECKING([if gcc is n64 capable])
2191   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2192       return 0;
2193   ]])], [
2194   VGCONF_ABI=64
2195   AC_MSG_RESULT([yes])
2196   ], [
2197   AC_MSG_RESULT([no])
2198   ])
2199   CFLAGS=$safe_CFLAGS
2201   if test "x$VGCONF_ABI" = "x"; then
2202     safe_CFLAGS=$CFLAGS
2203     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2204     AC_MSG_CHECKING([if gcc is n32 capable])
2205     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2206         return 0;
2207     ]])], [
2208     VGCONF_ABI=N32
2209     FLAG_M64="-march=mips64r2 -mabi=n32"
2210     AC_MSG_RESULT([yes])
2211     ], [
2212     AC_MSG_RESULT([no])
2213     ])
2214     CFLAGS=$safe_CFLAGS
2215   fi
2218 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2219                [test x$VGCONF_ABI != x])
2220 AC_SUBST(VGCONF_ABI)
2223 # does this compiler support -mmmx ?
2224 AC_MSG_CHECKING([if gcc accepts -mmmx])
2226 safe_CFLAGS=$CFLAGS
2227 CFLAGS="-mmmx -Werror"
2229 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2230   return 0;
2231 ]])], [
2232 FLAG_MMMX="-mmmx"
2233 AC_MSG_RESULT([yes])
2234 ], [
2235 FLAG_MMMX=""
2236 AC_MSG_RESULT([no])
2238 CFLAGS=$safe_CFLAGS
2240 AC_SUBST(FLAG_MMMX)
2243 # does this compiler support -msse ?
2244 AC_MSG_CHECKING([if gcc accepts -msse])
2246 safe_CFLAGS=$CFLAGS
2247 CFLAGS="-msse -Werror"
2249 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2250   return 0;
2251 ]])], [
2252 FLAG_MSSE="-msse"
2253 AC_MSG_RESULT([yes])
2254 ], [
2255 FLAG_MSSE=""
2256 AC_MSG_RESULT([no])
2258 CFLAGS=$safe_CFLAGS
2260 AC_SUBST(FLAG_MSSE)
2263 # does this compiler support -mpreferred-stack-boundary=2 when
2264 # generating code for a 32-bit target?  Note that we only care about
2265 # this when generating code for (32-bit) x86, so if the compiler
2266 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2267 # the Memcheck and other helper functions, that is a bit slower than
2268 # it could be, on x86; and no difference at all on any other platform.
2269 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2271 safe_CFLAGS=$CFLAGS
2272 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2274 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2275   return 0;
2276 ]])], [
2277 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2278 AC_MSG_RESULT([yes])
2279 ], [
2280 PREFERRED_STACK_BOUNDARY_2=""
2281 AC_MSG_RESULT([no])
2283 CFLAGS=$safe_CFLAGS
2285 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2288 # does this compiler support -mlong-double-128 ?
2289 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2290 safe_CFLAGS=$CFLAGS
2291 CFLAGS="-mlong-double-128 -Werror"
2292 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2293   return 0;
2294 ]])], [
2295 ac_compiler_supports_mlong_double_128=yes
2296 AC_MSG_RESULT([yes])
2297 ], [
2298 ac_compiler_supports_mlong_double_128=no
2299 AC_MSG_RESULT([no])
2301 CFLAGS=$safe_CFLAGS
2302 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2303 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2304 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2306 # does this toolchain support lto ?
2307 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2308 # are not defined
2309 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2310 # a lot slower, and so not appropriate for Valgrind developments.
2311 # --enable-lto=yes should be used by distro packagers.
2312 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2313    [AC_ARG_ENABLE(lto,
2314       [  --enable-lto          enables building with link time optimisation],
2315       [vg_cv_lto=$enableval],
2316       [vg_cv_lto=no])])
2318 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2319 AC_MSG_CHECKING([if toolchain accepts lto])
2320 safe_CFLAGS=$CFLAGS
2321 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2322 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2323 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2324 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2326 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2327   extern void somefun(void);
2328   somefun();
2329   return 0;
2330 ]])], [
2331 LTO_CFLAGS=$TEST_LTO_CFLAGS
2332 AC_MSG_RESULT([yes])
2333 ], [
2334 LTO_CFLAGS=""
2335 AC_MSG_RESULT([no])
2337 CFLAGS=$safe_CFLAGS
2340 AC_SUBST(LTO_CFLAGS)
2342 # if we could not compile with lto args, or lto was disabled,
2343 # then set LTO_AR/LTO_RANLIB to the non lto values
2344 # define in config.h ENABLE_LTO (not needed by the code currently, but
2345 # this guarantees we recompile everything if we re-configure and rebuild
2346 # in a build dir previously build with another value of --enable-lto
2347 if test "x${LTO_CFLAGS}" = "x"; then
2348    LTO_AR=${AR}
2349    LTO_RANLIB=${RANLIB}
2350    vg_cv_lto=no
2351 else
2352    vg_cv_lto=yes
2353    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2356 # Convenience function to check whether GCC supports a particular
2357 # warning option. Takes two arguments,
2358 # first the warning flag name to check (without -W), then the
2359 # substitution name to set with -Wno-warning-flag if the flag exists,
2360 # or the empty string if the compiler doesn't accept the flag. Note
2361 # that checking is done against the warning flag itself, but the
2362 # substitution is then done to cancel the warning flag.
2363 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2364   AC_MSG_CHECKING([if gcc accepts -W$1])
2365   safe_CFLAGS=$CFLAGS
2366   CFLAGS="-W$1 -Werror"
2367   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2368   AC_SUBST([$2], [-Wno-$1])
2369   AC_MSG_RESULT([yes])], [
2370   AC_SUBST([$2], [])
2371   AC_MSG_RESULT([no])])
2372   CFLAGS=$safe_CFLAGS
2375 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2376 # -W$1  (instead of -Wno-$1).
2377 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2378   AC_MSG_CHECKING([if gcc accepts -W$1])
2379   safe_CFLAGS=$CFLAGS
2380   CFLAGS="-W$1 -Werror"
2381   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2382   AC_SUBST([$2], [-W$1])
2383   AC_MSG_RESULT([yes])], [
2384   AC_SUBST([$2], [])
2385   AC_MSG_RESULT([no])])
2386   CFLAGS=$safe_CFLAGS
2389 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2390 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2391 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2392 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2393 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2394 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2395 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2396 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2397 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2398 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2400 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2401 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2402 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2403 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2404 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2405 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2406 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2407 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2408 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2409 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2410 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2412 # Does this compiler support -Wformat-security ?
2413 # Special handling is needed, because certain GCC versions require -Wformat
2414 # being present if -Wformat-security is given. Otherwise a warning is issued.
2415 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2416 # And with that the warning will be turned into an error with the result
2417 # that -Wformat-security is believed to be unsupported when in fact it is.
2418 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2419 safe_CFLAGS=$CFLAGS
2420 CFLAGS="-Wformat -Wformat-security -Werror"
2421 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2422 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2423 AC_MSG_RESULT([yes])], [
2424 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2425 AC_MSG_RESULT([no])])
2426 CFLAGS=$safe_CFLAGS
2428 # does this compiler support -Wextra or the older -W ?
2430 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2432 safe_CFLAGS=$CFLAGS
2433 CFLAGS="-Wextra -Werror"
2435 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2436   return 0;
2437 ]])], [
2438 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2439 AC_MSG_RESULT([-Wextra])
2440 ], [
2441   CFLAGS="-W -Werror"
2442   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2443     return 0;
2444   ]])], [
2445   AC_SUBST([FLAG_W_EXTRA], [-W])
2446   AC_MSG_RESULT([-W])
2447   ], [
2448   AC_SUBST([FLAG_W_EXTRA], [])
2449   AC_MSG_RESULT([not supported])
2450   ])
2452 CFLAGS=$safe_CFLAGS
2454 # On ARM we do not want to pass -Wcast-align as that produces loads
2455 # of warnings. GCC is just being conservative. See here:
2456 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2457 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2458   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2459 else
2460   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2463 # does this compiler support -faligned-new ?
2464 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2466 safe_CXXFLAGS=$CXXFLAGS
2467 CXXFLAGS="-faligned-new -Werror"
2469 AC_LANG(C++)
2470 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2471   return 0;
2472 ]])], [
2473 FLAG_FALIGNED_NEW="-faligned-new"
2474 AC_MSG_RESULT([yes])
2475 ], [
2476 FLAG_FALIGNED_NEW=""
2477 AC_MSG_RESULT([no])
2479 CXXFLAGS=$safe_CXXFLAGS
2480 AC_LANG(C)
2482 AC_SUBST(FLAG_FALIGNED_NEW)
2484 # does this compiler support -fsized-deallocation ?
2485 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2487 safe_CXXFLAGS=$CXXFLAGS
2488 CXXFLAGS="-fsized-deallocation -Werror"
2490 AC_LANG(C++)
2491 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2492   return 0;
2493 ]])], [
2494 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2495 ac_have_sized_deallocation=yes
2496 AC_MSG_RESULT([yes])
2497 ], [
2498 FLAG_FSIZED_DEALLOCATION=""
2499 ac_have_sized_deallocation=no
2500 AC_MSG_RESULT([no])
2502 CXXFLAGS=$safe_CXXFLAGS
2503 AC_LANG(C)
2505 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2506 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2508 # does this compiler support C++17 aligned new/delete?
2509 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2511 safe_CXXFLAGS=$CXXFLAGS
2512 CXXFLAGS="-std=c++17"
2514 AC_LANG(C++)
2515 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2516 #include <cstdlib>
2517 #include <new>
2518 ]], [[
2519   operator delete(nullptr, std::align_val_t(64U));
2520 ]])], [
2521 ac_have_aligned_cxx_alloc=yes
2522 AC_MSG_RESULT([yes])
2523 ], [
2524 ac_have_aligned_cxx_alloc=no
2525 AC_MSG_RESULT([no])
2527 CXXFLAGS=$safe_CXXFLAGS
2528 AC_LANG(C)
2530 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2532 # does this compiler support -fno-stack-protector ?
2533 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2535 safe_CFLAGS=$CFLAGS
2536 CFLAGS="-fno-stack-protector -Werror"
2538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2539   return 0;
2540 ]])], [
2541 no_stack_protector=yes
2542 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2543 AC_MSG_RESULT([yes])
2544 ], [
2545 no_stack_protector=no
2546 FLAG_FNO_STACK_PROTECTOR=""
2547 AC_MSG_RESULT([no])
2549 CFLAGS=$safe_CFLAGS
2551 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2553 # does this compiler support -finline-functions ?
2554 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2556 safe_CFLAGS=$CFLAGS
2557 CFLAGS="-finline-functions -Werror"
2559 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2560   return 0;
2561 ]])], [
2562 inline_functions=yes
2563 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2564 AC_MSG_RESULT([yes])
2565 ], [
2566 inline_functions=no
2567 FLAG_FINLINE_FUNCTIONS=""
2568 AC_MSG_RESULT([no])
2570 CFLAGS=$safe_CFLAGS
2572 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2574 # Does GCC support disabling Identical Code Folding?
2575 # We want to disabled Identical Code Folding for the
2576 # tools preload shared objects to get better backraces.
2577 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2578 # "The optimization reduces code size and may disturb
2579 #  unwind stacks by replacing a function by equivalent
2580 #  one with a different name."
2581 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2583 safe_CFLAGS=$CFLAGS
2584 CFLAGS="-fno-ipa-icf -Werror"
2586 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2587   return 0;
2588 ]])], [
2589 no_ipa_icf=yes
2590 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2591 AC_MSG_RESULT([yes])
2592 ], [
2593 no_ipa_icf=no
2594 FLAG_FNO_IPA_ICF=""
2595 AC_MSG_RESULT([no])
2597 CFLAGS=$safe_CFLAGS
2599 AC_SUBST(FLAG_FNO_IPA_ICF)
2602 # Does this compiler support -fsanitize=undefined. This is true for
2603 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2604 # also checks for alignment violations on memory accesses which the valgrind
2605 # code base is sprinkled (if not littered) with. As those alignment issues
2606 # don't pose a problem we want to suppress warnings about them.
2607 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2608 # GCCs do not support that.
2610 # Only checked for if --enable-ubsan was given.
2611 if test "x${vg_cv_ubsan}" = "xyes"; then
2612 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2613 safe_CFLAGS=$CFLAGS
2614 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2615 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2616   return 0;
2617 ]])], [
2618 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2619 LIB_UBSAN="-static-libubsan"
2620 AC_MSG_RESULT([yes])
2621 ], [
2622 CFLAGS="-fsanitize=undefined -Werror"
2623 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2624   return 0;
2625 ]])], [
2626 FLAG_FSANITIZE="-fsanitize=undefined"
2627 LIB_UBSAN="-static-libubsan"
2628 AC_MSG_RESULT([yes])
2629 ], [
2630 FLAG_FSANITIZE=""
2631 LIB_UBSAN=""
2632 AC_MSG_RESULT([no])
2635 CFLAGS=$safe_CFLAGS
2636 AC_SUBST(FLAG_FSANITIZE)
2637 AC_SUBST(LIB_UBSAN)
2639 # does this compiler support --param inline-unit-growth=... ?
2641 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2643 safe_CFLAGS=$CFLAGS
2644 CFLAGS="--param inline-unit-growth=900 -Werror"
2646 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2647   return 0;
2648 ]])], [
2649 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2650          ["--param inline-unit-growth=900"])
2651 AC_MSG_RESULT([yes])
2652 ], [
2653 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2654 AC_MSG_RESULT([no])
2656 CFLAGS=$safe_CFLAGS
2659 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2661 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2663 safe_CFLAGS=$CFLAGS
2664 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2666 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2667   return 0;
2668 ]])], [
2669 ac_have_dwarf4=yes
2670 AC_MSG_RESULT([yes])
2671 ], [
2672 ac_have_dwarf4=no
2673 AC_MSG_RESULT([no])
2675 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2676 CFLAGS=$safe_CFLAGS
2679 # does this compiler support -g -gz=zlib ?
2681 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2683 safe_CFLAGS=$CFLAGS
2684 CFLAGS="-g -gz=zlib"
2686 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2687   return 0;
2688 ]])], [
2689 ac_have_gz_zlib=yes
2690 AC_MSG_RESULT([yes])
2691 ], [
2692 ac_have_gz_zlib=no
2693 AC_MSG_RESULT([no])
2695 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2696 CFLAGS=$safe_CFLAGS
2699 # does this compiler support -g -gz=zlib-gnu ?
2701 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2703 safe_CFLAGS=$CFLAGS
2704 CFLAGS="-g -gz=zlib-gnu"
2706 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2707   return 0;
2708 ]])], [
2709 ac_have_gz_zlib_gnu=yes
2710 AC_MSG_RESULT([yes])
2711 ], [
2712 ac_have_gz_zlib_gnu=no
2713 AC_MSG_RESULT([no])
2715 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2716 CFLAGS=$safe_CFLAGS
2719 # does this compiler support nested functions ?
2721 AC_MSG_CHECKING([if gcc accepts nested functions])
2723 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2724   int foo() { return 1; }
2725   return foo();
2726 ]])], [
2727 ac_have_nested_functions=yes
2728 AC_MSG_RESULT([yes])
2729 ], [
2730 ac_have_nested_functions=no
2731 AC_MSG_RESULT([no])
2733 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2736 # does this compiler support the 'p' constraint in ASM statements ?
2738 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2740 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2741    char *p;
2742    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2743 ]])], [
2744 ac_have_asm_constraint_p=yes
2745 AC_MSG_RESULT([yes])
2746 ], [
2747 ac_have_asm_constraint_p=no
2748 AC_MSG_RESULT([no])
2750 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2753 # Does this compiler and linker support -pie?
2754 # Some compilers actually do not support -pie and report its usage
2755 # as an error. We need to check if it is safe to use it first.
2757 AC_MSG_CHECKING([if gcc accepts -pie])
2759 safe_CFLAGS=$CFLAGS
2760 CFLAGS="-pie"
2762 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2763   return 0;
2764 ]])], [
2765 AC_SUBST([FLAG_PIE], ["-pie"])
2766 AC_MSG_RESULT([yes])
2767 ], [
2768 AC_SUBST([FLAG_PIE], [""])
2769 AC_MSG_RESULT([no])
2771 CFLAGS=$safe_CFLAGS
2774 # Does this compiler support -no-pie?
2775 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2776 # default. However this gets in the way with some tests, we use -no-pie
2777 # for these.
2779 AC_MSG_CHECKING([if gcc accepts -no-pie])
2781 safe_CFLAGS=$CFLAGS
2782 CFLAGS="-no-pie -Werror"
2784 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2785   return 0;
2786 ]])], [
2787 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2788 AC_MSG_RESULT([yes])
2789 ], [
2790 AC_SUBST([FLAG_NO_PIE], [""])
2791 AC_MSG_RESULT([no])
2793 CFLAGS=$safe_CFLAGS
2796 # We want to use use the -Ttext-segment option to the linker.
2797 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2798 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2799 # semantics are NOT what we want (GNU gold -Ttext is fine).
2801 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2802 # will reside. -Ttext aligns just the .text section start (but not any
2803 # other section).
2805 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
2806 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
2807 # The --image-base option (since version 6.0?) provides the semantics needed.
2808 # -Ttext-segment generates an error, but -Ttext now more closely
2809 # follows the GNU (bfd) ld's -Ttext.
2811 # So test first for --image-base support, and if that fails then
2812 # for -Ttext-segment which is supported by all bfd ld versions
2813 # and use that if it exists. If it doesn't exist it must be an older
2814 # version of gold and we can fall back to using -Ttext which has the
2815 # right semantics.
2817 safe_CFLAGS=$CFLAGS
2818 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
2820 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
2822 AC_LINK_IFELSE(
2823 [AC_LANG_SOURCE([int _start () { return 0; }])],
2825   linker_using_t_text="no"
2826   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
2827   AC_MSG_RESULT([yes])
2828 ], [
2829   AC_MSG_RESULT([no])
2831   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2833   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2835   AC_LINK_IFELSE(
2836   [AC_LANG_SOURCE([int _start () { return 0; }])],
2837   [
2838     linker_using_t_text="no"
2839     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2840     AC_MSG_RESULT([yes])
2841   ], [
2842     linker_using_t_text="yes"
2843     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2844     AC_MSG_RESULT([no])
2845   ])
2848 CFLAGS=$safe_CFLAGS
2850 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
2851 # have to strip any build-id ELF NOTEs from the statically linked tools.
2852 # Otherwise the build-id NOTE might end up at the default load address.
2853 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2854 # gold versions also support -Ttext-segment. So just assume that unless
2855 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2856 if test "x${linker_using_t_text}" = "xyes"; then
2857 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2858 # does the linker support -Wl,--build-id=none ?  Note, it's
2859 # important that we test indirectly via whichever C compiler
2860 # is selected, rather than testing /usr/bin/ld or whatever
2861 # directly.
2862 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2863 safe_CFLAGS=$CFLAGS
2864 CFLAGS="-Wl,--build-id=none -Werror"
2866 AC_LINK_IFELSE(
2867 [AC_LANG_PROGRAM([ ], [return 0;])],
2869   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2870   AC_MSG_RESULT([yes])
2871 ], [
2872   AC_SUBST([FLAG_NO_BUILD_ID], [""])
2873   AC_MSG_RESULT([no])
2875 else
2876 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
2877 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2879 CFLAGS=$safe_CFLAGS
2881 # does the ppc assembler support "mtocrf" et al?
2882 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2884 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2885 __asm__ __volatile__("mtocrf 4,0");
2886 __asm__ __volatile__("mfocrf 0,4");
2887 ]])], [
2888 ac_have_as_ppc_mftocrf=yes
2889 AC_MSG_RESULT([yes])
2890 ], [
2891 ac_have_as_ppc_mftocrf=no
2892 AC_MSG_RESULT([no])
2894 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2895   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2899 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2900 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2902 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2903   do { typedef struct {
2904       double hi;
2905       double lo;
2906      } dbl_pair_t;
2907      dbl_pair_t dbl_pair[3];
2908      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2909    } while (0)
2910 ]])], [
2911 ac_have_as_ppc_fpPO=yes
2912 AC_MSG_RESULT([yes])
2913 ], [
2914 ac_have_as_ppc_fpPO=no
2915 AC_MSG_RESULT([no])
2917 if test x$ac_have_as_ppc_fpPO = xyes ; then
2918   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2922 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2923 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2925 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2926 void* p;
2927 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2928 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2929 ]])], [
2930 ac_have_as_amd64_fxsave64=yes
2931 AC_MSG_RESULT([yes])
2932 ], [
2933 ac_have_as_amd64_fxsave64=no
2934 AC_MSG_RESULT([no])
2936 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2937   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2940 # does the x86/amd64 assembler understand SSE3 instructions?
2941 # Note, this doesn't generate a C-level symbol.  It generates a
2942 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2943 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2945 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2946   do { long long int x; 
2947      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
2948   while (0)
2949 ]])], [
2950 ac_have_as_sse3=yes
2951 AC_MSG_RESULT([yes])
2952 ], [
2953 ac_have_as_sse3=no
2954 AC_MSG_RESULT([no])
2957 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2960 # Ditto for SSSE3 instructions (note extra S)
2961 # Note, this doesn't generate a C-level symbol.  It generates a
2962 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2963 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2965 save_CFLAGS="$CFLAGS"
2966 CFLAGS="$CFLAGS -msse -Werror"
2967 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2968   do { long long int x; 
2969    __asm__ __volatile__(
2970       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2971   while (0)
2972 ]])], [
2973 ac_have_as_ssse3=yes
2974 AC_MSG_RESULT([yes])
2975 ], [
2976 ac_have_as_ssse3=no
2977 AC_MSG_RESULT([no])
2979 CFLAGS="$save_CFLAGS"
2981 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2984 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2985 # Note, this doesn't generate a C-level symbol.  It generates a
2986 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2987 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2988 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2989   do {
2990    __asm__ __volatile__(
2991       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2992   while (0)
2993 ]])], [
2994 ac_have_as_pclmulqdq=yes
2995 AC_MSG_RESULT([yes])
2996 ], [
2997 ac_have_as_pclmulqdq=no
2998 AC_MSG_RESULT([no])
3001 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3004 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3005 # Note, this doesn't generate a C-level symbol.  It generates a
3006 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3007 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3008 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3009   do {
3010       /*
3011        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3012        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3013        * xmm2 should be used.
3014        */
3015    __asm__ __volatile__(
3016       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3017   } while (0)
3018 ]])], [
3019 ac_have_as_vpclmulqdq=yes
3020 AC_MSG_RESULT([yes])
3021 ], [
3022 ac_have_as_vpclmulqdq=no
3023 AC_MSG_RESULT([no])
3026 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3029 # does the x86/amd64 assembler understand FMA4 instructions?
3030 # Note, this doesn't generate a C-level symbol.  It generates a
3031 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3032 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3033 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3034   do {
3035    __asm__ __volatile__(
3036       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3037   } while (0)
3038 ]])], [
3039 ac_have_as_vfmaddpd=yes
3040 AC_MSG_RESULT([yes])
3041 ], [
3042 ac_have_as_vfmaddpd=no
3043 AC_MSG_RESULT([no])
3046 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3049 # does the x86/amd64 assembler understand the LZCNT instruction?
3050 # Note, this doesn't generate a C-level symbol.  It generates a
3051 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3052 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3054 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3055   do {           
3056       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3057   } while (0)
3058 ]])], [
3059   ac_have_as_lzcnt=yes
3060   AC_MSG_RESULT([yes])
3061 ], [
3062   ac_have_as_lzcnt=no
3063   AC_MSG_RESULT([no])
3066 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3069 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3070 # Note, this doesn't generate a C-level symbol.  It generates a
3071 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3072 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3074 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3075   do {           
3076       __asm__ __volatile__("1:  loopnel 1b\n");
3077   } while (0)
3078 ]])], [
3079   ac_have_as_loopnel=yes
3080   AC_MSG_RESULT([yes])
3081 ], [
3082   ac_have_as_loopnel=no
3083   AC_MSG_RESULT([no])
3086 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3089 # does the x86/amd64 assembler understand ADDR32 ?
3090 # Note, this doesn't generate a C-level symbol.  It generates a
3091 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3092 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3094 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3095   do {           
3096       asm volatile ("addr32 rep movsb");
3097   } while (0)
3098 ]])], [
3099   ac_have_as_addr32=yes
3100   AC_MSG_RESULT([yes])
3101 ], [
3102   ac_have_as_addr32=no
3103   AC_MSG_RESULT([no])
3106 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3109 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3110 # Note, this doesn't generate a C-level symbol.  It generates a
3111 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3112 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3114 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3115   do { long long int x; 
3116    __asm__ __volatile__(
3117       "crc32q %%r15,%%r15" : : : "r15" );
3118    __asm__ __volatile__(
3119       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3120    __asm__ __volatile__(
3121       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3122   while (0)
3123 ]])], [
3124 ac_have_as_sse42=yes
3125 AC_MSG_RESULT([yes])
3126 ], [
3127 ac_have_as_sse42=no
3128 AC_MSG_RESULT([no])
3131 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3134 # does the x86/amd64 assembler understand AVX instructions?
3135 # Note, this doesn't generate a C-level symbol.  It generates a
3136 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3137 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3139 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3140   do { long long int x; 
3141    __asm__ __volatile__(
3142       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3143    __asm__ __volatile__(
3144       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3145   while (0)
3146 ]])], [
3147 ac_have_as_avx=yes
3148 AC_MSG_RESULT([yes])
3149 ], [
3150 ac_have_as_avx=no
3151 AC_MSG_RESULT([no])
3154 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3157 # does the x86/amd64 assembler understand AVX2 instructions?
3158 # Note, this doesn't generate a C-level symbol.  It generates a
3159 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3160 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3162 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3163   do { long long int x; 
3164    __asm__ __volatile__(
3165       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3166    __asm__ __volatile__(
3167       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3168   while (0)
3169 ]])], [
3170 ac_have_as_avx2=yes
3171 AC_MSG_RESULT([yes])
3172 ], [
3173 ac_have_as_avx2=no
3174 AC_MSG_RESULT([no])
3177 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3180 # does the x86/amd64 assembler understand TSX instructions and
3181 # the XACQUIRE/XRELEASE prefixes?
3182 # Note, this doesn't generate a C-level symbol.  It generates a
3183 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3184 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3186 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3187   do {
3188    __asm__ __volatile__(
3189       "       xbegin Lfoo  \n\t"
3190       "Lfoo:  xend         \n\t"
3191       "       xacquire lock incq 0(%rsp)     \n\t"
3192       "       xrelease lock incq 0(%rsp)     \n"
3193    );
3194   } while (0)
3195 ]])], [
3196 ac_have_as_tsx=yes
3197 AC_MSG_RESULT([yes])
3198 ], [
3199 ac_have_as_tsx=no
3200 AC_MSG_RESULT([no])
3203 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3206 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3207 # Note, this doesn't generate a C-level symbol.  It generates a
3208 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3209 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3211 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3212   do { unsigned int h, l;
3213    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3214    __asm__ __volatile__(
3215       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3216    __asm__ __volatile__(
3217       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3218   while (0)
3219 ]])], [
3220 ac_have_as_bmi=yes
3221 AC_MSG_RESULT([yes])
3222 ], [
3223 ac_have_as_bmi=no
3224 AC_MSG_RESULT([no])
3227 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3230 # does the x86/amd64 assembler understand FMA instructions?
3231 # Note, this doesn't generate a C-level symbol.  It generates a
3232 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3233 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3235 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3236   do { unsigned int h, l;
3237    __asm__ __volatile__(
3238       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3239    __asm__ __volatile__(
3240       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3241    __asm__ __volatile__(
3242       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3243   while (0)
3244 ]])], [
3245 ac_have_as_fma=yes
3246 AC_MSG_RESULT([yes])
3247 ], [
3248 ac_have_as_fma=no
3249 AC_MSG_RESULT([no])
3252 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3255 # does the amd64 assembler understand MPX instructions?
3256 # Note, this doesn't generate a C-level symbol.  It generates a
3257 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3258 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3260 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3261   do {
3262     asm ("bndmov %bnd0,(%rsp)");
3263     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3264     asm ("bnd call foo\n"
3265           bnd jmp  end\n"
3266           foo: bnd ret\n"
3267           end: nop");
3268   } while (0)
3269 ]])], [
3270 ac_have_as_mpx=yes
3271 AC_MSG_RESULT([yes])
3272 ], [
3273 ac_have_as_mpx=no
3274 AC_MSG_RESULT([no])
3277 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3280 # does the amd64 assembler understand ADX instructions?
3281 # Note, this doesn't generate a C-level symbol.  It generates a
3282 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3283 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3286   do {
3287     asm ("adcxq %r14,%r8");
3288   } while (0)
3289 ]])], [
3290 ac_have_as_adx=yes
3291 AC_MSG_RESULT([yes])
3292 ], [
3293 ac_have_as_adx=no
3294 AC_MSG_RESULT([no])
3297 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3300 # does the amd64 assembler understand the RDRAND instruction?
3301 # Note, this doesn't generate a C-level symbol.  It generates a
3302 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3303 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3305 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3306   do {
3307     asm ("rdrand %r14");
3308     asm ("rdrand %r14d");
3309     asm ("rdrand %r14w");
3310   } while (0)
3311 ]])], [
3312 ac_have_as_rdrand=yes
3313 AC_MSG_RESULT([yes])
3314 ], [
3315 ac_have_as_rdrand=no
3316 AC_MSG_RESULT([no])
3319 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3321 # does the amd64 assembler understand the RDSEED instruction?
3322 # Note, this doesn't generate a C-level symbol.  It generates a
3323 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3324 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3326 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3327   do {
3328     asm ("rdseed %r14");
3329     asm ("rdseed %r14d");
3330     asm ("rdseed %r14w");
3331   } while (0)
3332 ]])], [
3333 ac_have_as_rdseed=yes
3334 AC_MSG_RESULT([yes])
3335 ], [
3336 ac_have_as_rdseed=no
3337 AC_MSG_RESULT([no])
3340 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3342 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3343 # VCVTPS2PH) ?
3344 # Note, this doesn't generate a C-level symbol.  It generates a
3345 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3346 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3348 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3349   do {
3350     asm ("vcvtph2ps %xmm5, %ymm10");
3351     // If we put the dollar sign and zero together, the shell processing
3352     // this configure.ac script substitutes the command name in.  Sigh.
3353     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3354   } while (0)
3355 ]])], [
3356 ac_have_as_f16c=yes
3357 AC_MSG_RESULT([yes])
3358 ], [
3359 ac_have_as_f16c=no
3360 AC_MSG_RESULT([no])
3363 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3366 # does the x86/amd64 assembler understand MOVBE?
3367 # Note, this doesn't generate a C-level symbol.  It generates a
3368 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3369 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3371 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3372   do { long long int x; 
3373    __asm__ __volatile__(
3374       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3375   while (0)
3376 ]])], [
3377 ac_have_as_movbe=yes
3378 AC_MSG_RESULT([yes])
3379 ], [
3380 ac_have_as_movbe=no
3381 AC_MSG_RESULT([no])
3384 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3387 # Does the C compiler support the "ifunc" attribute
3388 # Note, this doesn't generate a C-level symbol.  It generates a
3389 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3390 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3392 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3393 static void mytest(void) {}
3395 static void (*resolve_test(void))(void)
3397     return (void (*)(void))&mytest;
3400 void test(void) __attribute__((ifunc("resolve_test")));
3402 int main()
3404     test();
3405     return 0;
3407 ]])], [
3408 ac_have_ifunc_attr=yes
3409 AC_MSG_RESULT([yes])
3410 ], [
3411 ac_have_ifunc_attr=no
3412 AC_MSG_RESULT([no])
3415 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3417 # Does the C compiler support the armv8 crc feature flag
3418 # Note, this doesn't generate a C-level symbol.  It generates a
3419 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3420 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3422 save_CFLAGS="$CFLAGS"
3423 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3424 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3425 int main()
3427     return 0;
3429 ]])], [
3430 ac_have_armv8_crc_feature=yes
3431 AC_MSG_RESULT([yes])
3432 ], [
3433 ac_have_armv8_crc_feature=no
3434 AC_MSG_RESULT([no])
3436 CFLAGS="$save_CFLAGS"
3438 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3441 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3442 # Note, this doesn't generate a C-level symbol.  It generates a
3443 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3444 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3446 save_CFLAGS="$CFLAGS"
3447 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3448 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3449 int main()
3451     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3452     return 0;
3454 ]])], [
3455 ac_have_armv81_feature=yes
3456 AC_MSG_RESULT([yes])
3457 ], [
3458 ac_have_armv81_feature=no
3459 AC_MSG_RESULT([no])
3461 CFLAGS="$save_CFLAGS"
3463 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3466 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3467 # Note, this doesn't generate a C-level symbol.  It generates a
3468 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3469 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3471 save_CFLAGS="$CFLAGS"
3472 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3473 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3474 int main()
3476     __asm__ __volatile__("faddp h0, v1.2h");
3477     return 0;
3479 ]])], [
3480 ac_have_armv82_feature=yes
3481 AC_MSG_RESULT([yes])
3482 ], [
3483 ac_have_armv82_feature=no
3484 AC_MSG_RESULT([no])
3486 CFLAGS="$save_CFLAGS"
3488 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3491 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3492 # when building the tool executables.  I think we should get rid of it.
3494 # Check for TLS support in the compiler and linker
3495 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3496                                 [[return foo;]])],
3497                                [vg_cv_linktime_tls=yes],
3498                                [vg_cv_linktime_tls=no])
3499 # Native compilation: check whether running a program using TLS succeeds.
3500 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3501 # succeeds but running programs using TLS fails.
3502 # Cross-compiling: check whether linking a program using TLS succeeds.
3503 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3504                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3505                 [vg_cv_tls=$enableval],
3506                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3507                                                 [[return foo;]])],
3508                                [vg_cv_tls=yes],
3509                                [vg_cv_tls=no],
3510                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3512 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3513 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3517 #----------------------------------------------------------------------------
3518 # Solaris-specific checks.
3519 #----------------------------------------------------------------------------
3521 if test "$VGCONF_OS" = "solaris" ; then
3522 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3524 # Solaris-specific check determining if the Sun Studio Assembler is used to
3525 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3526 # cmovl.l instruction, if yes then it's Sun Assembler.
3528 # C-level symbol: none
3529 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3531 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3532 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3533 ]], [[
3534   __asm__ __volatile__("cmovl.l %edx, %eax");
3535 ]])], [
3536 solaris_have_sun_studio_as=yes
3537 AC_MSG_RESULT([yes])
3538 ], [
3539 solaris_have_sun_studio_as=no
3540 AC_MSG_RESULT([no])
3542 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3544 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3545 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3546 # See solaris/vgpreload-solaris.mapfile for details.
3547 # gcc on older Solaris instructs linker to include these symbols,
3548 # gcc on illumos and newer Solaris does not.
3550 # C-level symbol: none
3551 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3553 save_CFLAGS="$CFLAGS"
3554 CFLAGS="$CFLAGS -std=gnu99"
3555 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3556 temp_dir=$( /usr/bin/mktemp -d )
3557 cat <<_ACEOF >${temp_dir}/mylib.c
3558 #include <stdio.h>
3559 int myfunc(void) { printf("LaPutyka\n"); }
3560 _ACEOF
3561 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3562 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3563 if test "x${xpg_present}" = "x" ; then
3564     solaris_xpg_symbols_present=no
3565     AC_MSG_RESULT([no])
3566 else
3567     solaris_xpg_symbols_present=yes
3568     AC_MSG_RESULT([yes])
3570 rm -rf ${temp_dir}
3571 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3572 CFLAGS="$save_CFLAGS"
3575 # Solaris-specific check determining if gcc enables largefile support by
3576 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3577 # variable with gcc flags which disable it.
3579 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3580 save_CFLAGS="$CFLAGS"
3581 CFLAGS="$CFLAGS -m32"
3582 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3583   return _LARGEFILE_SOURCE;
3584 ]])], [
3585 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3586 AC_MSG_RESULT([yes])
3587 ], [
3588 SOLARIS_UNDEF_LARGESOURCE=""
3589 AC_MSG_RESULT([no])
3591 CFLAGS=$safe_CFLAGS
3592 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3595 # Solaris-specific check determining if /proc/self/cmdline
3596 # or /proc/<pid>/cmdline is supported.
3598 # C-level symbol: SOLARIS_PROC_CMDLINE
3599 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3601 AC_CHECK_FILE([/proc/self/cmdline],
3603 solaris_proc_cmdline=yes
3604 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3605           [Define to 1 if you have /proc/self/cmdline.])
3606 ], [
3607 solaris_proc_cmdline=no
3609 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3612 # Solaris-specific check determining default platform for the Valgrind launcher.
3613 # Used in case the launcher cannot select platform by looking at the client
3614 # image (for example because the executable is a shell script).
3616 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3617 # Automake-level symbol: none
3619 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3620 # Get the ELF class of /bin/sh first.
3621 if ! test -f /bin/sh; then
3622   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3624 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3625 case "$elf_class" in
3626   64)
3627     default_arch="$VGCONF_ARCH_PRI";
3628     ;;
3629   32)
3630     if test "x$VGCONF_ARCH_SEC" != "x"; then
3631       default_arch="$VGCONF_ARCH_SEC"
3632     else
3633       default_arch="$VGCONF_ARCH_PRI";
3634     fi
3635     ;;
3636   *)
3637     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3638     ;;
3639 esac
3640 default_platform="$default_arch-$VGCONF_OS"
3641 AC_MSG_RESULT([$default_platform])
3642 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3643                    [Default platform for Valgrind launcher.])
3646 # Solaris-specific check determining if the old syscalls are available.
3648 # C-level symbol: SOLARIS_OLD_SYSCALLS
3649 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3651 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3652 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3653 #include <sys/syscall.h>
3654 ]], [[
3655   return !SYS_open;
3656 ]])], [
3657 solaris_old_syscalls=yes
3658 AC_MSG_RESULT([yes])
3659 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3660           [Define to 1 if you have the old Solaris syscalls.])
3661 ], [
3662 solaris_old_syscalls=no
3663 AC_MSG_RESULT([no])
3665 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3668 # Solaris-specific check determining if the new accept() syscall is available.
3670 # Old syscall:
3671 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3672 #            int version);
3674 # New syscall (available on illumos):
3675 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3676 #            int version, int flags);
3678 # If the old syscall is present then the following syscall will fail with
3679 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3680 # available then it will fail with EINVAL (because the flags parameter is
3681 # invalid).
3683 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3684 # Automake-level symbol: none
3686 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3687 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3688 #include <sys/syscall.h>
3689 #include <errno.h>
3690 ]], [[
3691   errno = 0;
3692   syscall(SYS_accept, 0, 0, 0, 0, -1);
3693   return !(errno == EINVAL);
3694 ]])], [
3695 AC_MSG_RESULT([yes])
3696 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3697           [Define to 1 if you have the new `accept' syscall.])
3698 ], [
3699 AC_MSG_RESULT([no])
3703 # Solaris-specific check determining if the new illumos pipe() syscall is
3704 # available.
3706 # Old syscall:
3707 # longlong_t pipe();
3709 # New syscall (available on illumos):
3710 # int pipe(intptr_t arg, int flags);
3712 # If the old syscall is present then the following call will succeed, if the
3713 # new syscall is available then it will fail with EFAULT (because address 0
3714 # cannot be accessed).
3716 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3717 # Automake-level symbol: none
3719 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3720 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3721 #include <sys/syscall.h>
3722 #include <errno.h>
3723 ]], [[
3724   errno = 0;
3725   syscall(SYS_pipe, 0, 0);
3726   return !(errno == EFAULT);
3727 ]])], [
3728 AC_MSG_RESULT([yes])
3729 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3730           [Define to 1 if you have the new `pipe' syscall.])
3731 ], [
3732 AC_MSG_RESULT([no])
3736 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3737 # available.
3739 # Old syscall:
3740 # int lwp_kill(id_t lwpid, int sig);
3742 # New syscall (available on Solaris 11):
3743 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3744 #                  int si_code, timespec_t *timeout);
3746 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3747 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3749 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3750 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3751 #include <sys/syscall.h> 
3752 ]], [[
3753   return !SYS_lwp_sigqueue;
3754 ]])], [
3755 solaris_lwp_sigqueue_syscall=yes
3756 AC_MSG_RESULT([yes])
3757 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3758           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3759 ], [
3760 solaris_lwp_sigqueue_syscall=no
3761 AC_MSG_RESULT([no])
3763 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3766 # Solaris-specific check determining if the lwp_sigqueue() syscall
3767 # takes both pid and thread id arguments or just thread id.
3769 # Old syscall (available up to Solaris 11.3):
3770 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3771 #                  int si_code, timespec_t *timeout);
3773 # New syscall (available since Solaris 11.4):
3774 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3775 #                  int si_code, timespec_t *timeout);
3777 # If the old syscall is present then the following syscall will fail with
3778 # EINVAL (because signal is out of range); if the new syscall is available
3779 # then it will fail with ESRCH (because it would not find such thread in the
3780 # current process).
3782 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3783 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3785 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3786 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3787 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3788 #include <sys/syscall.h>
3789 #include <errno.h>
3790 ]], [[
3791   errno = 0;
3792   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3793   return !(errno == ESRCH);
3794 ]])], [
3795 solaris_lwp_sigqueue_syscall_takes_pid=yes
3796 AC_MSG_RESULT([yes])
3797 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3798           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3799 ], [
3800 solaris_lwp_sigqueue_syscall_takes_pid=no
3801 AC_MSG_RESULT([no])
3803 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3804                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3806 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3810 # Solaris-specific check determining if the new lwp_name() syscall is
3811 # available.
3813 # New syscall (available on Solaris 11):
3814 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3816 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3817 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3819 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3820 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3821 #include <sys/syscall.h>
3822 ]], [[
3823   return !SYS_lwp_name;
3824 ]])], [
3825 solaris_lwp_name_syscall=yes
3826 AC_MSG_RESULT([yes])
3827 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3828           [Define to 1 if you have the new `lwp_name' syscall.])
3829 ], [
3830 solaris_lwp_name_syscall=no
3831 AC_MSG_RESULT([no])
3833 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3836 # Solaris-specific check determining if the new getrandom() syscall is
3837 # available.
3839 # New syscall (available on Solaris 11):
3840 # int getrandom(void *buf, size_t buflen, uint_t flags);
3842 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3843 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3845 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3846 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3847 #include <sys/syscall.h>
3848 ]], [[
3849   return !SYS_getrandom;
3850 ]])], [
3851 solaris_getrandom_syscall=yes
3852 AC_MSG_RESULT([yes])
3853 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3854           [Define to 1 if you have the new `getrandom' syscall.])
3855 ], [
3856 solaris_getrandom_syscall=no
3857 AC_MSG_RESULT([no])
3859 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3862 # Solaris-specific check determining if the new zone() syscall subcodes
3863 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
3864 # were added in Solaris 11 but are missing on illumos.
3866 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3867 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3869 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3870 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3871 #include <sys/zone.h>
3872 ]], [[
3873   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3874 ]])], [
3875 solaris_zone_defunct=yes
3876 AC_MSG_RESULT([yes])
3877 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3878           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3879 ], [
3880 solaris_zone_defunct=no
3881 AC_MSG_RESULT([no])
3883 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3886 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3887 # for auditon(2) subcode of the auditsys() syscall are available.
3888 # These commands are available in Solaris 11 and illumos but were removed
3889 # in Solaris 11.4.
3891 # C-level symbol: SOLARIS_AUDITON_STAT
3892 # Automake-level symbol: SOLARIS_AUDITON_STAT
3894 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3895 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3896 #include <bsm/audit.h>
3897 ]], [[
3898   return !(A_GETSTAT && A_SETSTAT);
3899 ]])], [
3900 solaris_auditon_stat=yes
3901 AC_MSG_RESULT([yes])
3902 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3903           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3904 ], [
3905 solaris_auditon_stat=no
3906 AC_MSG_RESULT([no])
3908 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3911 # Solaris-specific check determining if the new shmsys() syscall subcodes
3912 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3913 # These subcodes were added in Solaris 11 but are missing on illumos.
3915 # C-level symbol: SOLARIS_SHM_NEW
3916 # Automake-level symbol: SOLARIS_SHM_NEW
3918 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3919 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3920 #include <sys/ipc_impl.h>
3921 #include <sys/shm.h>
3922 #include <sys/shm_impl.h>
3923 ]], [[
3924   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3925 ]])], [
3926 solaris_shm_new=yes
3927 AC_MSG_RESULT([yes])
3928 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3929           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3930 ], [
3931 solaris_shm_new=no
3932 AC_MSG_RESULT([no])
3934 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3937 # Solaris-specific check determining if prxregset_t is available.  Illumos
3938 # currently does not define it on the x86 platform.
3940 # C-level symbol: SOLARIS_PRXREGSET_T
3941 # Automake-level symbol: SOLARIS_PRXREGSET_T
3943 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3944 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3945 #include <sys/procfs_isa.h>
3946 ]], [[
3947   return !sizeof(prxregset_t);
3948 ]])], [
3949 solaris_prxregset_t=yes
3950 AC_MSG_RESULT([yes])
3951 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3952           [Define to 1 if you have the `prxregset_t' type.])
3953 ], [
3954 solaris_prxregset_t=no
3955 AC_MSG_RESULT([no])
3957 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3960 # Solaris-specific check determining if the new frealpathat() syscall is
3961 # available.
3963 # New syscall (available on Solaris 11.1):
3964 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
3966 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3967 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3969 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3970 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3971 #include <sys/syscall.h>
3972 ]], [[
3973   return !SYS_frealpathat;
3974 ]])], [
3975 solaris_frealpathat_syscall=yes
3976 AC_MSG_RESULT([yes])
3977 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3978           [Define to 1 if you have the new `frealpathat' syscall.])
3979 ], [
3980 solaris_frealpathat_syscall=no
3981 AC_MSG_RESULT([no])
3983 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3986 # Solaris-specific check determining if the new uuidsys() syscall is
3987 # available.
3989 # New syscall (available on newer Solaris):
3990 # int uuidsys(struct uuid *uuid);
3992 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3993 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3995 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3996 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3997 #include <sys/syscall.h>
3998 ]], [[
3999   return !SYS_uuidsys;
4000 ]])], [
4001 solaris_uuidsys_syscall=yes
4002 AC_MSG_RESULT([yes])
4003 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4004           [Define to 1 if you have the new `uuidsys' syscall.])
4005 ], [
4006 solaris_uuidsys_syscall=no
4007 AC_MSG_RESULT([no])
4009 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4012 # Solaris-specific check determining if the new labelsys() syscall subcode
4013 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4014 # missing on illumos.
4016 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4017 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4019 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4020 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4021 #include <sys/tsol/tndb.h>
4022 ]], [[
4023   return !TNDB_GET_TNIP;
4024 ]])], [
4025 solaris_tndb_get_tnip=yes
4026 AC_MSG_RESULT([yes])
4027 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4028           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4029 ], [
4030 solaris_tndb_get_tnip=no
4031 AC_MSG_RESULT([no])
4033 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4036 # Solaris-specific check determining if the new labelsys() syscall opcodes
4037 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4038 # added in Solaris 11 but are missing on illumos.
4040 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4041 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4043 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4044 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4045 #include <sys/tsol/tsyscall.h>
4046 ]], [[
4047   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4048 ]])], [
4049 solaris_tsol_clearance=yes
4050 AC_MSG_RESULT([yes])
4051 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4052           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4053 ], [
4054 solaris_tsol_clearance=no
4055 AC_MSG_RESULT([no])
4057 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4060 # Solaris-specific check determining if the new pset() syscall subcode
4061 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4062 # is missing on illumos and Solaris 11.3.
4064 # C-level symbol: SOLARIS_PSET_GET_NAME
4065 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4067 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4068 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4069 #include <sys/pset.h>
4070 ]], [[
4071   return !(PSET_GET_NAME);
4072 ]])], [
4073 solaris_pset_get_name=yes
4074 AC_MSG_RESULT([yes])
4075 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4076           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4077 ], [
4078 solaris_pset_get_name=no
4079 AC_MSG_RESULT([no])
4081 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4084 # Solaris-specific check determining if the utimesys() syscall is
4085 # available (on illumos and older Solaris).
4087 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4088 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4090 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4091 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4092 #include <sys/syscall.h>
4093 ]], [[
4094   return !SYS_utimesys;
4095 ]])], [
4096 solaris_utimesys_syscall=yes
4097 AC_MSG_RESULT([yes])
4098 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4099           [Define to 1 if you have the `utimesys' syscall.])
4100 ], [
4101 solaris_utimesys_syscall=no
4102 AC_MSG_RESULT([no])
4104 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4107 # Solaris-specific check determining if the utimensat() syscall is
4108 # available (on newer Solaris).
4110 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4111 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4113 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4114 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4115 #include <sys/syscall.h>
4116 ]], [[
4117   return !SYS_utimensat;
4118 ]])], [
4119 solaris_utimensat_syscall=yes
4120 AC_MSG_RESULT([yes])
4121 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4122           [Define to 1 if you have the `utimensat' syscall.])
4123 ], [
4124 solaris_utimensat_syscall=no
4125 AC_MSG_RESULT([no])
4127 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4130 # Solaris-specific check determining if the spawn() syscall is available
4131 # (on newer Solaris).
4133 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4134 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4136 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4137 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4138 #include <sys/syscall.h>
4139 ]], [[
4140   return !SYS_spawn;
4141 ]])], [
4142 solaris_spawn_syscall=yes
4143 AC_MSG_RESULT([yes])
4144 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4145           [Define to 1 if you have the `spawn' syscall.])
4146 ], [
4147 solaris_spawn_syscall=no
4148 AC_MSG_RESULT([no])
4150 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4153 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4154 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4156 # C-level symbol: SOLARIS_MODCTL_MODNVL
4157 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4159 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4160 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4161 #include <sys/modctl.h>
4162 ]], [[
4163   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4164 ]])], [
4165 solaris_modctl_modnvl=yes
4166 AC_MSG_RESULT([yes])
4167 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4168           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4169 ], [
4170 solaris_modctl_modnvl=no
4171 AC_MSG_RESULT([no])
4173 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4176 # Solaris-specific check determining whether nscd (name switch cache daemon)
4177 # attaches its door at /system/volatile/name_service_door (Solaris)
4178 # or at /var/run/name_service_door (illumos).
4180 # Note that /var/run is a symlink to /system/volatile on Solaris
4181 # but not vice versa on illumos.
4183 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4184 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4186 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4187 if test -e /system/volatile/name_service_door; then
4188     solaris_nscd_door_system_volatile=yes
4189     AC_MSG_RESULT([/system/volatile/name_service_door])
4190     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4191               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4192 else
4193     solaris_nscd_door_system_volatile=no
4194     AC_MSG_RESULT([/var/run/name_service_door])
4196 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4199 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4201 # New fasttrap (available on Solaris 11):
4202 # hrt_t *gethrt(void);
4204 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4205 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4207 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4208 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4209 #include <sys/trap.h>
4210 ]], [[
4211   return !T_GETHRT;
4212 ]])], [
4213 solaris_gethrt_fasttrap=yes
4214 AC_MSG_RESULT([yes])
4215 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4216           [Define to 1 if you have the new `gethrt' fasttrap.])
4217 ], [
4218 solaris_gethrt_fasttrap=no
4219 AC_MSG_RESULT([no])
4221 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4224 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4225 # is available.
4227 # New fasttrap (available on Solaris 11):
4228 # zonehrtoffset_t *get_zone_offset(void);
4230 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4231 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4233 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4234 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4235 #include <sys/trap.h>
4236 ]], [[
4237   return !T_GETZONEOFFSET;
4238 ]])], [
4239 solaris_getzoneoffset_fasttrap=yes
4240 AC_MSG_RESULT([yes])
4241 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4242           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4243 ], [
4244 solaris_getzoneoffset_fasttrap=no
4245 AC_MSG_RESULT([no])
4247 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4250 # Solaris-specific check determining if the execve() syscall
4251 # takes fourth argument (flags) or not.
4253 # Old syscall (available on illumos):
4254 # int execve(const char *fname, const char **argv, const char **envp);
4256 # New syscall (available on Solaris):
4257 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4259 # If the new syscall is present then it will fail with EINVAL (because flags
4260 # are invalid); if the old syscall is available then it will fail with ENOENT
4261 # (because the file could not be found).
4263 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4264 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4266 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4267 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4268 #include <sys/syscall.h>
4269 #include <errno.h>
4270 ]], [[
4271   errno = 0;
4272   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4273   return !(errno == EINVAL);
4274 ]])], [
4275 solaris_execve_syscall_takes_flags=yes
4276 AC_MSG_RESULT([yes])
4277 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4278           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4279 ], [
4280 solaris_execve_syscall_takes_flags=no
4281 AC_MSG_RESULT([no])
4283 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4284                test x$solaris_execve_syscall_takes_flags = xyes)
4287 # Solaris-specific check determining version of the repository cache protocol.
4288 # Every Solaris version uses a different one, ranging from 21 to current 25.
4289 # The check is very ugly, though.
4291 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4292 # Automake-level symbol: none
4294 AC_PATH_PROG(DIS_PATH, dis, false)
4295 if test "x$DIS_PATH" = "xfalse"; then
4296   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4298 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4299   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4300   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4303 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4304 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4305   libscf=/usr/lib/64/libscf.so.1
4306 else
4307   libscf=/usr/lib/libscf.so.1
4309 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
4310   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4311   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4313 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
4314 if test -z "$hex"; then
4315   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4316   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4318 version=$( printf "%d\n" 0x$hex )
4319 AC_MSG_RESULT([$version])
4320 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4321                    [Version number of the repository door cache protocol.])
4324 # Solaris-specific check determining if "sysstat" segment reservation type
4325 # is available.
4327 # New "sysstat" segment reservation (available on Solaris 11.4):
4328 # - program header type:    PT_SUNW_SYSSTAT
4329 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4331 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4332 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4334 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4335 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4336 #include <sys/auxv.h>
4337 ]], [[
4338   return !AT_SUN_SYSSTAT_ADDR;
4339 ]])], [
4340 solaris_reserve_sysstat_addr=yes
4341 AC_MSG_RESULT([yes])
4342 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4343           [Define to 1 if you have the new `sysstat' segment reservation.])
4344 ], [
4345 solaris_reserve_sysstat_addr=no
4346 AC_MSG_RESULT([no])
4348 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4351 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4352 # is available.
4354 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4355 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4356 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4358 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4359 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4361 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4363 #include <sys/auxv.h>
4364 ]], [[
4365   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4366 ]])], [
4367 solaris_reserve_sysstat_zone_addr=yes
4368 AC_MSG_RESULT([yes])
4369 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4370           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4371 ], [
4372 solaris_reserve_sysstat_zone_addr=no
4373 AC_MSG_RESULT([no])
4375 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4378 # Solaris-specific check determining if the system_stats() syscall is available
4379 # (on newer Solaris).
4381 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4382 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4384 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4385 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4386 #include <sys/syscall.h>
4387 ]], [[
4388   return !SYS_system_stats;
4389 ]])], [
4390 solaris_system_stats_syscall=yes
4391 AC_MSG_RESULT([yes])
4392 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4393           [Define to 1 if you have the `system_stats' syscall.])
4394 ], [
4395 solaris_system_stats_syscall=no
4396 AC_MSG_RESULT([no])
4398 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4401 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4402 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4404 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4405 # Automake-level symbol: none
4407 AC_CHECK_TYPE([struct _fpchip_state],
4408               [solaris_fpchip_state_takes_underscore=yes],
4409               [solaris_fpchip_state_takes_underscore=no],
4410               [[#include <sys/regset.h>]])
4411 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4412   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4413             [Define to 1 if fpregset_t defines struct _fpchip_state])
4417 # Solaris-specific check determining if schedctl page shared between kernel
4418 # and userspace program is executable (illumos, older Solaris) or not (newer
4419 # Solaris).
4421 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4422 # Automake-level symbol: none
4424 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4425 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4426 #include <assert.h>
4427 #include <fcntl.h>
4428 #include <procfs.h>
4429 #include <schedctl.h>
4430 #include <stdio.h>
4431 #include <unistd.h>
4432 ]], [[
4433     schedctl_t *scp = schedctl_init();
4434     if (scp == NULL)
4435         return 1;
4437     int fd = open("/proc/self/map", O_RDONLY);
4438     assert(fd >= 0);
4440     prmap_t map;
4441     ssize_t rd;
4442     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4443         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4444             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4445                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4446             return (map.pr_mflags & MA_EXEC);
4447         }
4448     }
4450     return 1;
4451 ]])], [
4452 solaris_schedctl_page_exec=no
4453 AC_MSG_RESULT([no])
4454 ], [
4455 solaris_schedctl_page_exec=yes
4456 AC_MSG_RESULT([yes])
4457 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4458           [Define to 1 if you have the schedctl page executable.])
4462 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4463 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4464 # an initial thread pointer for libc (newer Solaris).
4466 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4467 # Automake-level symbol: none
4469 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4470 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4471 #include <sys/fasttrap_isa.h>
4472 ]], [[
4473     return !FT_SCRATCHSIZE;
4474 ]])], [
4475 solaris_pt_sunwdtrace_thrp=yes
4476 AC_MSG_RESULT([yes])
4477 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4478           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4479 ], [
4480 solaris_pt_sunwdtrace_thrp=no
4481 AC_MSG_RESULT([no])
4484 else
4485 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4486 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4487 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4488 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4489 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4490 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4491 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4492 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4493 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4494 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4495 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4496 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4497 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4498 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4499 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4500 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4501 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4502 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4503 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4504 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4505 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4506 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4507 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4508 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4509 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4510 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4511 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4512 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4513 fi # test "$VGCONF_OS" = "solaris"
4516 #----------------------------------------------------------------------------
4517 # Checks for C header files.
4518 #----------------------------------------------------------------------------
4520 AC_CHECK_HEADERS([       \
4521         asm/unistd.h     \
4522         endian.h         \
4523         mqueue.h         \
4524         sys/endian.h     \
4525         sys/epoll.h      \
4526         sys/eventfd.h    \
4527         sys/klog.h       \
4528         sys/poll.h       \
4529         sys/prctl.h      \
4530         sys/signal.h     \
4531         sys/signalfd.h   \
4532         sys/syscall.h    \
4533         sys/sysnvl.h     \
4534         sys/time.h       \
4535         sys/types.h      \
4536         ])
4538 # Verify whether the <linux/futex.h> header is usable.
4539 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4541 save_CFLAGS="$CFLAGS"
4542 CFLAGS="$CFLAGS -D__user="
4543 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4544 #include <linux/futex.h>
4545 ]], [[
4546   return FUTEX_WAIT;
4547 ]])], [
4548 ac_have_usable_linux_futex_h=yes
4549 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4550           [Define to 1 if you have a usable <linux/futex.h> header file.])
4551 AC_MSG_RESULT([yes])
4552 ], [
4553 ac_have_usable_linux_futex_h=no
4554 AC_MSG_RESULT([no])
4556 CFLAGS="$save_CFLAGS"
4559 #----------------------------------------------------------------------------
4560 # Checks for typedefs, structures, and compiler characteristics.
4561 #----------------------------------------------------------------------------
4562 AC_TYPE_UID_T
4563 AC_TYPE_OFF_T
4564 AC_TYPE_SIZE_T
4565 AC_HEADER_TIME
4568 #----------------------------------------------------------------------------
4569 # Checks for library functions.
4570 #----------------------------------------------------------------------------
4571 AC_FUNC_MEMCMP
4572 AC_FUNC_MMAP
4574 AC_CHECK_LIB([pthread], [pthread_create])
4575 AC_CHECK_LIB([rt], [clock_gettime])
4577 AC_CHECK_FUNCS([     \
4578         clock_gettime\
4579         copy_file_range \
4580         epoll_create \
4581         epoll_pwait  \
4582         klogctl      \
4583         mallinfo     \
4584         memchr       \
4585         memfd_create \
4586         memset       \
4587         mkdir        \
4588         mremap       \
4589         ppoll        \
4590         preadv       \
4591         preadv2      \
4592         process_vm_readv  \
4593         process_vm_writev \
4594         pthread_barrier_init       \
4595         pthread_condattr_setclock  \
4596         pthread_mutex_timedlock    \
4597         pthread_rwlock_timedrdlock \
4598         pthread_rwlock_timedwrlock \
4599         pthread_setname_np         \
4600         pthread_spin_lock          \
4601         pthread_yield              \
4602         pwritev      \
4603         pwritev2     \
4604         readlinkat   \
4605         semtimedop   \
4606         setcontext   \
4607         signalfd     \
4608         sigwaitinfo  \
4609         strchr       \
4610         strdup       \
4611         strpbrk      \
4612         strrchr      \
4613         strstr       \
4614         swapcontext  \
4615         syscall      \
4616         utimensat    \
4617         ])
4619 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4620 # libraries with any shared object and/or executable. This is NOT what we
4621 # want for e.g. vgpreload_core-x86-linux.so
4622 LIBS=""
4624 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4625                [test x$ac_cv_func_pthread_barrier_init = xyes])
4626 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4627                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4628 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4629                [test x$ac_cv_func_pthread_spin_lock = xyes])
4630 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4631                [test x$ac_cv_func_pthread_setname_np = xyes])
4632 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4633                [test x$ac_cv_func_copy_file_range = xyes])
4634 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4635                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4636 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4637                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4638 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4639 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4640 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4641                [test x$ac_cv_func_memfd_create = xyes])
4643 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4644      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4645      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4646   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4647             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4650 #----------------------------------------------------------------------------
4651 # MPI checks
4652 #----------------------------------------------------------------------------
4653 # Do we have a useable MPI setup on the primary and/or secondary targets?
4654 # On Linux, by default, assumes mpicc and -m32/-m64
4655 # Note: this is a kludge in that it assumes the specified mpicc 
4656 # understands -m32/-m64 regardless of what is specified using
4657 # --with-mpicc=.
4658 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4659              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4661 mflag_primary=
4662 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4663      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4664      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4665      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4666      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4667      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4668      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4669   mflag_primary=$FLAG_M32
4670 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4671        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4672        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4673        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4674        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4675        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4676   mflag_primary=$FLAG_M64
4677 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4678   mflag_primary="$FLAG_M32 -arch i386"
4679 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4680   mflag_primary="$FLAG_M64 -arch x86_64"
4683 mflag_secondary=
4684 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4685      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4686      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4687      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4688      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4689   mflag_secondary=$FLAG_M32
4690 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4691   mflag_secondary="$FLAG_M32 -arch i386"
4695 AC_ARG_WITH(mpicc,
4696    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4697    MPI_CC=$withval
4699 AC_SUBST(MPI_CC)
4701 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4702 ## use these values in the check for a functioning mpicc.
4704 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4705 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4706 AM_COND_IF([VGCONF_OS_IS_LINUX],
4707            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4708             LDFLAGS_MPI="-fpic -shared"])
4709 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
4710            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4711             LDFLAGS_MPI="-fpic -shared"])
4712 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4713            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4714             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4715 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4716            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4717             LDFLAGS_MPI="-fpic -shared"])
4719 AC_SUBST([CFLAGS_MPI])
4720 AC_SUBST([LDFLAGS_MPI])
4723 ## See if MPI_CC works for the primary target
4725 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4726 saved_CC=$CC
4727 saved_CFLAGS=$CFLAGS
4728 CC=$MPI_CC
4729 CFLAGS="$CFLAGS_MPI $mflag_primary"
4730 saved_LDFLAGS="$LDFLAGS"
4731 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4732 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4733 #include <mpi.h>
4734 #include <stdio.h>
4735 ]], [[
4736   int ni, na, nd, comb;
4737   int r = MPI_Init(NULL,NULL);
4738   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4739   r |= MPI_Finalize();
4740   return r; 
4741 ]])], [
4742 ac_have_mpi2_pri=yes
4743 AC_MSG_RESULT([yes, $MPI_CC])
4744 ], [
4745 ac_have_mpi2_pri=no
4746 AC_MSG_RESULT([no])
4748 CC=$saved_CC
4749 CFLAGS=$saved_CFLAGS
4750 LDFLAGS="$saved_LDFLAGS"
4751 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4753 ## See if MPI_CC works for the secondary target.  Complication: what if
4754 ## there is no secondary target?  We need this to then fail.
4755 ## Kludge this by making MPI_CC something which will surely fail in
4756 ## such a case.
4758 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4759 saved_CC=$CC
4760 saved_CFLAGS=$CFLAGS
4761 saved_LDFLAGS="$LDFLAGS"
4762 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4763 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4764   CC="$MPI_CC this will surely fail"
4765 else
4766   CC=$MPI_CC
4768 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4769 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4770 #include <mpi.h>
4771 #include <stdio.h>
4772 ]], [[
4773   int ni, na, nd, comb;
4774   int r = MPI_Init(NULL,NULL);
4775   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4776   r |= MPI_Finalize();
4777   return r; 
4778 ]])], [
4779 ac_have_mpi2_sec=yes
4780 AC_MSG_RESULT([yes, $MPI_CC])
4781 ], [
4782 ac_have_mpi2_sec=no
4783 AC_MSG_RESULT([no])
4785 CC=$saved_CC
4786 CFLAGS=$saved_CFLAGS
4787 LDFLAGS="$saved_LDFLAGS"
4788 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4791 #----------------------------------------------------------------------------
4792 # Other library checks
4793 #----------------------------------------------------------------------------
4794 # There now follow some tests for Boost, and OpenMP.  These
4795 # tests are present because Drd has some regression tests that use
4796 # these packages.  All regression test programs all compiled only
4797 # for the primary target.  And so it is important that the configure
4798 # checks that follow, use the correct -m32 or -m64 flag for the
4799 # primary target (called $mflag_primary).  Otherwise, we can end up
4800 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4801 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4802 # only build (meaning, the primary target is x86-linux), the build
4803 # of the regtest programs that use Boost fails, because they are 
4804 # build as 32-bit (IN THIS EXAMPLE).
4806 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4807 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4810 # Check whether the boost library 1.35 or later has been installed.
4811 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4813 AC_MSG_CHECKING([for boost])
4815 AC_LANG(C++)
4816 safe_CXXFLAGS=$CXXFLAGS
4817 CXXFLAGS="$mflag_primary"
4818 safe_LIBS="$LIBS"
4819 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4821 AC_LINK_IFELSE([AC_LANG_SOURCE([
4822 #include <boost/thread.hpp>
4823 static void thread_func(void)
4824 { }
4825 int main(int argc, char** argv)
4827   boost::thread t(thread_func);
4828   return 0;
4830 ])],
4832 ac_have_boost_1_35=yes
4833 AC_SUBST([BOOST_CFLAGS], [])
4834 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4835 AC_MSG_RESULT([yes])
4836 ], [
4837 ac_have_boost_1_35=no
4838 AC_MSG_RESULT([no])
4841 LIBS="$safe_LIBS"
4842 CXXFLAGS=$safe_CXXFLAGS
4843 AC_LANG(C)
4845 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4848 # does this compiler support -fopenmp, does it have the include file
4849 # <omp.h> and does it have libgomp ?
4851 AC_MSG_CHECKING([for OpenMP])
4853 safe_CFLAGS=$CFLAGS
4854 CFLAGS="-fopenmp $mflag_primary -Werror"
4856 AC_LINK_IFELSE([AC_LANG_SOURCE([
4857 #include <omp.h> 
4858 int main(int argc, char** argv)
4860   omp_set_dynamic(0);
4861   return 0;
4863 ])],
4865 ac_have_openmp=yes
4866 AC_MSG_RESULT([yes])
4867 ], [
4868 ac_have_openmp=no
4869 AC_MSG_RESULT([no])
4871 CFLAGS=$safe_CFLAGS
4873 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4876 # Check for __builtin_popcount
4877 AC_MSG_CHECKING([for __builtin_popcount()])
4878 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4879 ]], [[
4880   __builtin_popcount(2);
4881   return 0;
4882 ]])], [
4883 AC_MSG_RESULT([yes])
4884 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4885           [Define to 1 if compiler provides __builtin_popcount().])
4886 ], [
4887 AC_MSG_RESULT([no])
4890 # Check for __builtin_clz
4891 AC_MSG_CHECKING([for __builtin_clz()])
4892 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4893 ]], [[
4894   __builtin_clz(2);
4895   return 0;
4896 ]])], [
4897 AC_MSG_RESULT([yes])
4898 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4899           [Define to 1 if compiler provides __builtin_clz().])
4900 ], [
4901 AC_MSG_RESULT([no])
4904 # Check for __builtin_ctz
4905 AC_MSG_CHECKING([for __builtin_ctz()])
4906 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4907 ]], [[
4908   __builtin_ctz(2);
4909   return 0;
4910 ]])], [
4911 AC_MSG_RESULT([yes])
4912 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4913           [Define to 1 if compiler provides __builtin_ctz().])
4914 ], [
4915 AC_MSG_RESULT([no])
4918 # does this compiler have built-in functions for atomic memory access for the
4919 # primary target ?
4920 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4922 safe_CFLAGS=$CFLAGS
4923 CFLAGS="$mflag_primary"
4925 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4926   int variable = 1;
4927   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4928           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4929 ]])], [
4930   ac_have_builtin_atomic_primary=yes
4931   AC_MSG_RESULT([yes])
4932   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])
4933 ], [
4934   ac_have_builtin_atomic_primary=no
4935   AC_MSG_RESULT([no])
4938 CFLAGS=$safe_CFLAGS
4940 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4941                [test x$ac_have_builtin_atomic_primary = xyes])
4944 # does this compiler have built-in functions for atomic memory access for the
4945 # secondary target ?
4947 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4949 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
4951 safe_CFLAGS=$CFLAGS
4952 CFLAGS="$mflag_secondary"
4954 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4955   int variable = 1;
4956   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
4957 ]])], [
4958   ac_have_builtin_atomic_secondary=yes
4959   AC_MSG_RESULT([yes])
4960 ], [
4961   ac_have_builtin_atomic_secondary=no
4962   AC_MSG_RESULT([no])
4965 CFLAGS=$safe_CFLAGS
4969 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
4970                [test x$ac_have_builtin_atomic_secondary = xyes])
4972 # does this compiler have built-in functions for atomic memory access on
4973 # 64-bit integers for all targets ?
4975 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
4977 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4978   #include <stdint.h>
4979 ]], [[
4980   uint64_t variable = 1;
4981   return __sync_add_and_fetch(&variable, 1)
4982 ]])], [
4983   ac_have_builtin_atomic64_primary=yes
4984 ], [
4985   ac_have_builtin_atomic64_primary=no
4988 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4990 safe_CFLAGS=$CFLAGS
4991 CFLAGS="$mflag_secondary"
4993 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4994   #include <stdint.h>
4995 ]], [[
4996   uint64_t variable = 1;
4997   return __sync_add_and_fetch(&variable, 1)
4998 ]])], [
4999   ac_have_builtin_atomic64_secondary=yes
5000 ], [
5001   ac_have_builtin_atomic64_secondary=no
5004 CFLAGS=$safe_CFLAGS
5008 if test x$ac_have_builtin_atomic64_primary = xyes && \
5009    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5010      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5011   AC_MSG_RESULT([yes])
5012   ac_have_builtin_atomic64=yes
5013 else
5014   AC_MSG_RESULT([no])
5015   ac_have_builtin_atomic64=no
5018 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5019                [test x$ac_have_builtin_atomic64 = xyes])
5022 # does g++ have built-in functions for atomic memory access ?
5023 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5025 safe_CXXFLAGS=$CXXFLAGS
5026 CXXFLAGS="$mflag_primary"
5028 AC_LANG_PUSH(C++)
5029 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5030   int variable = 1;
5031   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5032           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5033 ]])], [
5034   ac_have_builtin_atomic_cxx=yes
5035   AC_MSG_RESULT([yes])
5036   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5037 ], [
5038   ac_have_builtin_atomic_cxx=no
5039   AC_MSG_RESULT([no])
5041 AC_LANG_POP(C++)
5043 CXXFLAGS=$safe_CXXFLAGS
5045 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5048 if test x$ac_have_usable_linux_futex_h = xyes \
5049         -a x$ac_have_builtin_atomic_primary = xyes; then
5050   ac_enable_linux_ticket_lock_primary=yes
5052 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5053                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5055 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5056         -a x$ac_have_usable_linux_futex_h = xyes \
5057         -a x$ac_have_builtin_atomic_secondary = xyes; then
5058   ac_enable_linux_ticket_lock_secondary=yes
5060 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5061                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5064 # does libstdc++ support annotating shared pointers ?
5065 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5067 safe_CXXFLAGS=$CXXFLAGS
5068 CXXFLAGS="-std=c++0x"
5070 AC_LANG_PUSH(C++)
5071 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5072   #include <memory>
5073 ]], [[
5074   std::shared_ptr<int> p
5075 ]])], [
5076   ac_have_shared_ptr=yes
5077 ], [
5078   ac_have_shared_ptr=no
5080 if test x$ac_have_shared_ptr = xyes; then
5081   # If compilation of the program below fails because of a syntax error
5082   # triggered by substituting one of the annotation macros then that
5083   # means that libstdc++ supports these macros.
5084   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5085     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5086     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5087     #include <memory>
5088   ]], [[
5089     std::shared_ptr<int> p
5090   ]])], [
5091     ac_have_shared_pointer_annotation=no
5092     AC_MSG_RESULT([no])
5093   ], [
5094     ac_have_shared_pointer_annotation=yes
5095     AC_MSG_RESULT([yes])
5096     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5097               [Define to 1 if libstd++ supports annotating shared pointers])
5098   ])
5099 else
5100   ac_have_shared_pointer_annotation=no
5101   AC_MSG_RESULT([no])
5103 AC_LANG_POP(C++)
5105 CXXFLAGS=$safe_CXXFLAGS
5107 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5108                [test x$ac_have_shared_pointer_annotation = xyes])
5111 #----------------------------------------------------------------------------
5112 # Ok.  We're done checking.
5113 #----------------------------------------------------------------------------
5115 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5116 AC_CONFIG_FILES([
5117    Makefile 
5118    VEX/Makefile:Makefile.vex.in
5119    valgrind.spec
5120    valgrind.pc
5121    glibc-2.X.supp
5122    glibc-2.X-helgrind.supp
5123    glibc-2.X-drd.supp
5124    docs/Makefile 
5125    tests/Makefile 
5126    tests/vg_regtest 
5127    perf/Makefile 
5128    perf/vg_perf
5129    gdbserver_tests/Makefile
5130    gdbserver_tests/solaris/Makefile
5131    include/Makefile 
5132    auxprogs/Makefile
5133    mpi/Makefile
5134    coregrind/Makefile 
5135    memcheck/Makefile
5136    memcheck/tests/Makefile
5137    memcheck/tests/common/Makefile
5138    memcheck/tests/amd64/Makefile
5139    memcheck/tests/x86/Makefile
5140    memcheck/tests/linux/Makefile
5141    memcheck/tests/linux/debuginfod-check.vgtest
5142    memcheck/tests/darwin/Makefile
5143    memcheck/tests/solaris/Makefile
5144    memcheck/tests/freebsd/Makefile
5145    memcheck/tests/amd64-linux/Makefile
5146    memcheck/tests/arm64-linux/Makefile
5147    memcheck/tests/x86-linux/Makefile
5148    memcheck/tests/amd64-solaris/Makefile
5149    memcheck/tests/x86-solaris/Makefile
5150    memcheck/tests/amd64-freebsd/Makefile
5151    memcheck/tests/x86-freebsd/Makefile
5152    memcheck/tests/ppc32/Makefile
5153    memcheck/tests/ppc64/Makefile
5154    memcheck/tests/s390x/Makefile
5155    memcheck/tests/mips32/Makefile
5156    memcheck/tests/mips64/Makefile
5157    memcheck/tests/vbit-test/Makefile
5158    cachegrind/Makefile
5159    cachegrind/tests/Makefile
5160    cachegrind/tests/x86/Makefile
5161    cachegrind/cg_annotate
5162    cachegrind/cg_diff
5163    callgrind/Makefile
5164    callgrind/callgrind_annotate
5165    callgrind/callgrind_control
5166    callgrind/tests/Makefile
5167    helgrind/Makefile
5168    helgrind/tests/Makefile
5169    drd/Makefile
5170    drd/scripts/download-and-build-splash2
5171    drd/tests/Makefile
5172    massif/Makefile
5173    massif/tests/Makefile
5174    massif/ms_print
5175    dhat/Makefile
5176    dhat/tests/Makefile
5177    lackey/Makefile
5178    lackey/tests/Makefile
5179    none/Makefile
5180    none/tests/Makefile
5181    none/tests/scripts/Makefile
5182    none/tests/amd64/Makefile
5183    none/tests/ppc32/Makefile
5184    none/tests/ppc64/Makefile
5185    none/tests/x86/Makefile
5186    none/tests/arm/Makefile
5187    none/tests/arm64/Makefile
5188    none/tests/s390x/Makefile
5189    none/tests/mips32/Makefile
5190    none/tests/mips64/Makefile
5191    none/tests/nanomips/Makefile
5192    none/tests/linux/Makefile
5193    none/tests/darwin/Makefile
5194    none/tests/solaris/Makefile
5195    none/tests/freebsd/Makefile
5196    none/tests/amd64-linux/Makefile
5197    none/tests/x86-linux/Makefile
5198    none/tests/amd64-darwin/Makefile
5199    none/tests/x86-darwin/Makefile
5200    none/tests/amd64-solaris/Makefile
5201    none/tests/x86-solaris/Makefile
5202    exp-bbv/Makefile
5203    exp-bbv/tests/Makefile
5204    exp-bbv/tests/x86/Makefile
5205    exp-bbv/tests/x86-linux/Makefile
5206    exp-bbv/tests/amd64-linux/Makefile
5207    exp-bbv/tests/ppc32-linux/Makefile
5208    exp-bbv/tests/arm-linux/Makefile
5209    shared/Makefile
5210    solaris/Makefile
5212 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5213                 [chmod +x coregrind/link_tool_exe_linux])
5214 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5215                 [chmod +x coregrind/link_tool_exe_freebsd])
5216 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5217                 [chmod +x coregrind/link_tool_exe_darwin])
5218 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5219                 [chmod +x coregrind/link_tool_exe_solaris])
5220 AC_CONFIG_FILES([tests/filter_stderr_basic],
5221                 [chmod +x tests/filter_stderr_basic])
5222 AC_CONFIG_FILES([tests/filter_discards],
5223                 [chmod +x tests/filter_discards])
5224 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5225                 [chmod +x memcheck/tests/filter_stderr])
5226 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5227                 [chmod +x memcheck/tests/filter_dw4])
5228 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5229                 [chmod +x memcheck/tests/filter_overlaperror])
5230 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5231                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5232 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5233                 [chmod +x gdbserver_tests/filter_gdb])
5234 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5235                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5236 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5237                 [chmod +x gdbserver_tests/filter_stderr])
5238 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5239                 [chmod +x gdbserver_tests/filter_vgdb])
5240 AC_CONFIG_FILES([drd/tests/filter_stderr],
5241                 [chmod +x drd/tests/filter_stderr])
5242 AC_CONFIG_FILES([drd/tests/filter_error_count],
5243                 [chmod +x drd/tests/filter_error_count])
5244 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5245                 [chmod +x drd/tests/filter_error_summary])
5246 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5247                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5248 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5249                 [chmod +x drd/tests/filter_thread_no])
5250 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5251                 [chmod +x drd/tests/filter_xml_and_thread_no])
5252 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5253                 [chmod +x helgrind/tests/filter_stderr])
5254 AC_OUTPUT
5256 cat<<EOF
5258          Maximum build arch: ${ARCH_MAX}
5259          Primary build arch: ${VGCONF_ARCH_PRI}
5260        Secondary build arch: ${VGCONF_ARCH_SEC}
5261                    Build OS: ${VGCONF_OS}
5262      Link Time Optimisation: ${vg_cv_lto}
5263        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5264      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5265            Platform variant: ${VGCONF_PLATVARIANT}
5266       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5267          Default supp files: ${DEFAULT_SUPP}