mc-manual.xml fix new/delete expresions -> expression
[valgrind.git] / configure.ac
blob46efdc7590bc0b41ed592309aa5c3d01ae843439
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.
12 # Define major, minor, micro and suffix here once, then reuse them
13 # for version number in valgrind.h and vg-entities (documentation).
14 # suffix must be empty for a release, otherwise it is GIT or RC1, etc.
15 # Also set the (expected/last) release date here.
16 # Do not forget to rerun ./autogen.sh
17 m4_define([v_major_ver], [3])
18 m4_define([v_minor_ver], [24])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [GIT])
21 m4_define([v_rel_date], ["?? Oct 2024"])
22 m4_define([v_version],
23           m4_if(v_suffix_ver, [],
24                 [v_major_ver.v_minor_ver.v_micro_ver],
25                 [v_major_ver.v_minor_ver.v_micro_ver.v_suffix_ver]))
26 AC_INIT([Valgrind],[v_version],[valgrind-users@lists.sourceforge.net])
28 # For valgrind.h
29 AC_SUBST(VG_VER_MAJOR, v_major_ver)
30 AC_SUBST(VG_VER_MINOR, v_minor_ver)
32 # For docs/xml/vg-entities.xml
33 AC_SUBST(VG_DATE, v_rel_date)
35 AC_CONFIG_SRCDIR(coregrind/m_main.c)
36 AC_CONFIG_HEADERS([config.h])
37 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
39 AM_MAINTAINER_MODE
41 #----------------------------------------------------------------------------
42 # Do NOT modify these flags here. Except in feature tests in which case
43 # the original values must be properly restored.
44 #----------------------------------------------------------------------------
45 CFLAGS="$CFLAGS"
46 CXXFLAGS="$CXXFLAGS"
48 #----------------------------------------------------------------------------
49 # Checks for various programs.
50 #----------------------------------------------------------------------------
52 AC_PROG_LN_S
53 m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
54 # Make sure we can compile in C99 mode.
55 if test "$ac_cv_prog_cc_c99" = "no"; then
56     AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
58 AC_PROG_CPP
59 AC_PROG_CXX
60 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
61 # autoconf 2.59).  If we ever have any Objective-C code in the Valgrind code
62 # base (eg. most likely as Darwin-specific tests) we'll need one of the
63 # following:
64 # - put AC_PROG_OBJC in a Darwin-specific part of this file
65 # - Use AC_PROG_OBJC here and up the minimum autoconf version
66 # - Use the following, which is apparently equivalent:
67 #     m4_ifdef([AC_PROG_OBJC],
68 #        [AC_PROG_OBJC],
69 #        [AC_CHECK_TOOL([OBJC], [gcc])
70 #         AC_SUBST([OBJC])
71 #         AC_SUBST([OBJCFLAGS])
72 #        ])
73 AC_PROG_RANLIB
74 # Set LTO_RANLIB variable to an lto enabled ranlib
75 if test "x$LTO_RANLIB" = "x"; then
76   AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
78 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
80 # provide a very basic definition for AC_PROG_SED if it's not provided by
81 # autoconf (as e.g. in autoconf 2.59).
82 m4_ifndef([AC_PROG_SED],
83           [AC_DEFUN([AC_PROG_SED],
84                     [AC_ARG_VAR([SED])
85                      AC_CHECK_PROGS([SED],[gsed sed])])])
86 AC_PROG_SED
88 AC_DEFUN([AC_PROG_SHA256SUM],
89           [AC_ARG_VAR([SHA256SUM])
90           AC_CHECK_PROGS([SHA256SUM],[gsha256sum sha256sum])])
91 AC_PROG_SHA256SUM
93 # If no AR variable was specified, look up the name of the archiver. Otherwise
94 # do not touch the AR variable.
95 if test "x$AR" = "x"; then
96   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
98 AC_ARG_VAR([AR],[Archiver command])
100 # same for LTO_AR variable for lto enabled archiver
101 if test "x$LTO_AR" = "x"; then
102   AC_PATH_PROGS([LTO_AR], [gcc-ar])
104 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
106 # figure out where perl lives
107 AC_PATH_PROG(PERL, perl)
109 # figure out where gdb lives
110 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
111 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
113 # some older automake's don't have it so try something on our own
114 ifdef([AM_PROG_AS],[AM_PROG_AS],
116 AS="${CC}"
117 AC_SUBST(AS)
119 ASFLAGS=""
120 AC_SUBST(ASFLAGS)
124 # Check if 'diff' supports -u (universal diffs) and use it if possible.
126 AC_MSG_CHECKING([for diff -u])
127 AC_SUBST(DIFF)
129 # Comparing two identical files results in 0.
130 tmpfile="tmp-xxx-yyy-zzz"
131 touch $tmpfile;
132 if diff -u $tmpfile $tmpfile ; then
133     AC_MSG_RESULT([yes])
134     DIFF="diff -u"
135 else
136     AC_MSG_RESULT([no])
137     DIFF="diff"
139 rm $tmpfile
141 # We don't want gcc < 3.0
142 AC_MSG_CHECKING([for a supported version of gcc])
144 # Obtain the compiler version.
146 # A few examples of how the ${CC} --version output looks like:
148 # ######## gcc variants ########
149 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
150 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
151 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
152 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
153 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
154 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
155 # 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)
157 # ######## clang variants ########
158 # Clang: clang version 2.9 (tags/RELEASE_29/final)
159 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
160 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
162 # ######## Apple LLVM variants ########
163 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
164 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
167 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
168 then
169     is_clang="applellvm"
170     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
171 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
172 then
173     is_clang="clang"
174     # Don't use -dumpversion with clang: it will always produce "4.2.1".
175     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
176 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
177 then
178     is_clang="icc"
179     gcc_version=`${CC} -dumpversion 2>/dev/null`
180 else
181     is_clang="notclang"
182     gcc_version=`${CC} -dumpversion 2>/dev/null`
183     if test "x$gcc_version" = x; then
184         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
185     fi
188 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
189 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
191 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
192 # statements have to be quoted.
193 case "${is_clang}-${gcc_version}" in
194      applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
195         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
196         ;;
197      icc-1[[3-9]].*|icc-202[[0-9]].*)
198         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
199         ;;
200      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
201         AC_MSG_RESULT([ok (${gcc_version})])
202         ;;
203      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
204         AC_MSG_RESULT([ok (clang-${gcc_version})])
205         ;;
206      *)
207         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
208         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
209         ;;
210 esac
212 #----------------------------------------------------------------------------
213 # Arch/OS/platform tests.
214 #----------------------------------------------------------------------------
215 # We create a number of arch/OS/platform-related variables.  We prefix them
216 # all with "VGCONF_" which indicates that they are defined at
217 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
218 # variables used when compiling C files.
220 AC_CANONICAL_HOST
222 AC_MSG_CHECKING([for a supported CPU])
224 # ARCH_MAX reflects the most that this CPU can do: for example if it
225 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
226 # Ditto for amd64.  It is used for more configuration below, but is not used
227 # outside this file.
229 # Power PC returns powerpc for Big Endian.  This was not changed when Little
230 # Endian support was added to the 64-bit architecture.  The 64-bit Little
231 # Endian systems explicitly state le in the host_cpu.  For clarity in the
232 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
233 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
234 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
235 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
236 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
237 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
238 # Little Endian.
240 VGCONF_PLATFORM_ARM_ARCH=
242 case "${host_cpu}" in
243      i?86) 
244         AC_MSG_RESULT([ok (${host_cpu})])
245         ARCH_MAX="x86"
246         ;;
248      x86_64|amd64) 
249         AC_MSG_RESULT([ok (${host_cpu})])
250         ARCH_MAX="amd64"
251         ;;
253      powerpc64)
254      # this only referrs to 64-bit Big Endian
255         AC_MSG_RESULT([ok (${host_cpu})])
256         ARCH_MAX="ppc64be"
257         ;;
259      powerpc64le)
260      # this only referrs to 64-bit Little Endian
261         AC_MSG_RESULT([ok (${host_cpu})])
262         ARCH_MAX="ppc64le"
263         ;;
265      powerpc)
266         # On Linux this means only a 32-bit capable CPU.
267         AC_MSG_RESULT([ok (${host_cpu})])
268         ARCH_MAX="ppc32"
269         ;;
271      s390x)
272         AC_MSG_RESULT([ok (${host_cpu})])
273         ARCH_MAX="s390x"
274         ;;
276      armv8*)
277         AC_MSG_RESULT([ok (${host_cpu})])
278         VGCONF_PLATFORM_ARM_ARCH="-marm -mcpu=cortex-a8"
279         ARCH_MAX="arm"
280         ;;
282      armv7*)
283         AC_MSG_RESULT([ok (${host_cpu})])
284         VGCONF_PLATFORM_ARM_ARCH="-marm -mcpu=cortex-a8"
285         ARCH_MAX="arm"
286         ;;
288      arm*)
289         AC_MSG_RESULT([ok (${host_cpu})])
290         VGCONF_PLATFORM_ARM_ARCH="-march=armv6"
291         ARCH_MAX="arm"
292         ;;
294      aarch64*)
295        AC_MSG_RESULT([ok (${host_cpu})])
296        ARCH_MAX="arm64"
297        ;;
299      mips)
300         AC_MSG_RESULT([ok (${host_cpu})])
301         ARCH_MAX="mips32"
302         ;;
304      mipsel)
305         AC_MSG_RESULT([ok (${host_cpu})])
306         ARCH_MAX="mips32"
307         ;;
309      mipsisa32r2)
310         AC_MSG_RESULT([ok (${host_cpu})])
311         ARCH_MAX="mips32"
312         ;;
314      mips64*)
315         AC_MSG_RESULT([ok (${host_cpu})])
316         ARCH_MAX="mips64"
317         ;;
319      mipsisa64*)
320         AC_MSG_RESULT([ok (${host_cpu})])
321         ARCH_MAX="mips64"
322         ;;
323      nanomips)
324         AC_MSG_RESULT([ok (${host_cpu})])
325         ARCH_MAX="nanomips"
326         ;;
328      *) 
329         AC_MSG_RESULT([no (${host_cpu})])
330         AC_MSG_ERROR([Unsupported host architecture. Sorry])
331         ;;
332 esac
334 AC_SUBST(VGCONF_PLATFORM_ARM_ARCH)
336 #----------------------------------------------------------------------------
338 # Sometimes it's convenient to subvert the bi-arch build system and
339 # just have a single build even though the underlying platform is
340 # capable of both.  Hence handle --enable-only64bit and
341 # --enable-only32bit.  Complain if both are issued :-)
342 # [Actually, if either of these options are used, I think both get built,
343 # but only one gets installed.  So if you use an in-place build, both can be
344 # used. --njn]
346 # Check if a 64-bit only build has been requested
347 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
348    [AC_ARG_ENABLE(only64bit, 
349       [  --enable-only64bit      do a 64-bit only build],
350       [vg_cv_only64bit=$enableval],
351       [vg_cv_only64bit=no])])
353 # Check if a 32-bit only build has been requested
354 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
355    [AC_ARG_ENABLE(only32bit, 
356       [  --enable-only32bit      do a 32-bit only build],
357       [vg_cv_only32bit=$enableval],
358       [vg_cv_only32bit=no])])
360 # Stay sane
361 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
362    AC_MSG_ERROR(
363       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
366 #----------------------------------------------------------------------------
368 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
369 # compilation of many C files via -VGO_$(VGCONF_OS) and
370 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
371 AC_MSG_CHECKING([for a supported OS])
372 AC_SUBST(VGCONF_OS)
374 DEFAULT_SUPP=""
376 case "${host_os}" in
377      *linux*)
378         AC_MSG_RESULT([ok (${host_os})])
379         VGCONF_OS="linux"
381         # Ok, this is linux. Check the kernel version
382         AC_MSG_CHECKING([for the kernel version])
384         kernel=`uname -r`
386         case "${kernel}" in
387              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
388                     AC_MSG_RESULT([unsupported (${kernel})])
389                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
390                     ;;
392              *)
393                     AC_MSG_RESULT([2.6 or later (${kernel})])
394                     ;;
395         esac
397         ;;
399      *freebsd*)
400         AC_MSG_RESULT([ok (${host_os})])
401         VGCONF_OS="freebsd"
402         AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
403         freebsd_10=1000
404         AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
405         freebsd_11=1100
406         AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
407         freebsd_12=1200
408         AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
409         freebsd_12_2=1220
410         AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
411         freebsd_13_0=1300
412         AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1])
413         freebsd_13_1=1310
414         AC_DEFINE([FREEBSD_13_2], 1320, [FREEBSD_VERS value for FreeBSD 13.2])
415         freebsd_13_2=1320
416         AC_DEFINE([FREEBSD_13_3], 1330, [FREEBSD_VERS value for FreeBSD 13.3])
417         freebsd_13_3=1330
418         AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
419         freebsd_14=1400
420         AC_DEFINE([FREEBSD_15], 1500, [FREEBSD_VERS value for FreeBSD 15.x])
421         freebsd_15=1500
423         AC_MSG_CHECKING([for the kernel version])
424         kernel=`uname -r`
426         case "${kernel}" in
427         10.*)
428            AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
429            AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
430            freebsd_vers=$freebsd_10
431            ;;
432         11.*)
433            AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
434            AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
435            freebsd_vers=$freebsd_11
436            ;;
437         12.*)
438            case "${kernel}" in
439            12.[[0-1]]-*)
440               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
441               AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
442               freebsd_vers=$freebsd_12
443               ;;
444            *)
445               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
446               AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
447               freebsd_vers=$freebsd_12_2
448               ;;
449            esac
450            ;;
451         13.*)
452            case "${kernel}" in
453            13.0-*)
454               AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
455               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
456               freebsd_vers=$freebsd_13_0
457               ;;
458            13.1-*)
459               AC_MSG_RESULT([FreeBSD 13.1 (${kernel})])
460               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
461               freebsd_vers=$freebsd_13_1
462               ;;
463            13.2-*)
464               AC_MSG_RESULT([FreeBSD 13.2 (${kernel})])
465               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_2, [FreeBSD version])
466               freebsd_vers=$freebsd_13_2
467               ;;
468            13.3-*)
469               AC_MSG_RESULT([FreeBSD 13.3 (${kernel})])
470               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_3, [FreeBSD version])
471               freebsd_vers=$freebsd_13_3
472               ;;
473            *)
474               AC_MSG_RESULT([unsupported (${kernel})])
475               AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 15.x])
476               ;;
477            esac
478            ;;
479         14.*)
480            AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
481            AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
482            freebsd_vers=$freebsd_14
483            ;;
484         15.*)
485            AC_MSG_RESULT([FreeBSD 15.x (${kernel})])
486            AC_DEFINE([FREEBSD_VERS], FREEBSD_15, [FreeBSD version])
487            freebsd_vers=$freebsd_15
488            ;;
489         *)
490            AC_MSG_RESULT([unsupported (${kernel})])
491            AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 15.x])
492            ;;
493         esac
495         DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
496         ;;
498      *darwin*)
499         AC_MSG_RESULT([ok (${host_os})])
500         VGCONF_OS="darwin"
501         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
502         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
503         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
504         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
505         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
506         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
507         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
508         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
509         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
511         AC_MSG_CHECKING([for the kernel version])
512         kernel=`uname -r`
514         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
515         # has only one relevant version, the OS version. The `uname` check
516         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
517         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
518         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
519         # and we don't know of an macros similar to __GLIBC__ to get that info.
520         #
521         # XXX: `uname -r` won't do the right thing for cross-compiles, but
522         # that's not a problem yet.
523         #
524         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
525         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
526         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
527         # time support for 10.5 (the 9.* pattern just below), I'll leave it
528         # in for now, just in case anybody wants to give it a try.  But I'm
529         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
530         case "${kernel}" in
531              9.*)
532                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
533                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
534                   DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
535                   DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
536                   ;;
537              10.*)
538                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
539                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
540                   DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
541                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
542                   ;;
543              11.*)
544                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
545                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
546                   DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
547                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
548                   ;;
549              12.*)
550                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
551                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
552                   DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
553                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
554                   ;;
555              13.*)
556                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
557                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
558                   DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
559                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
560                   ;;
561              14.*)
562                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
563                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
564                   DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
565                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
566                   ;;
567              15.*)
568                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
569                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
570                   DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
571                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
572                   ;;
573              16.*)
574                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
575                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
576                   DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
577                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
578                   ;;
579              17.*)
580                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
581                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
582                   DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
583                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
584                   ;;
585              *) 
586                   AC_MSG_RESULT([unsupported (${kernel})])
587                   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)])
588                   ;;
589         esac
590         ;;
592      solaris2.11*)
593         AC_MSG_RESULT([ok (${host_os})])
594         VGCONF_OS="solaris"
596         uname_v=$( uname -v )
597         case "$uname_v" in
598              11.4.*)
599                  DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
600                  ;;
601              *)
602                  DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
603                  ;;
604         esac
605         ;;
607      solaris2.12*)
608         AC_MSG_RESULT([ok (${host_os})])
609         VGCONF_OS="solaris"
610         DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
611         ;;
613      *) 
614         AC_MSG_RESULT([no (${host_os})])
615         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
616         ;;
617 esac
619 #----------------------------------------------------------------------------
621 # If we are building on a 64 bit platform test to see if the system
622 # supports building 32 bit programs and disable 32 bit support if it
623 # does not support building 32 bit programs
625 case "$ARCH_MAX-$VGCONF_OS" in
626      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
627         AC_MSG_CHECKING([for 32 bit build support])
628         safe_CFLAGS=$CFLAGS
629         CFLAGS="-m32"
630         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
631           return 0;
632         ]])], [
633         AC_MSG_RESULT([yes])
634         ], [
635         vg_cv_only64bit="yes"
636         AC_MSG_RESULT([no])
637         ])
638         CFLAGS=$safe_CFLAGS;;
639     mips64-linux)
640         AC_MSG_CHECKING([for 32 bit build support])
641         safe_CFLAGS=$CFLAGS
642         CFLAGS="$CFLAGS -mips32 -mabi=32"
643         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
644           #include <sys/prctl.h>
645         ]], [[]])], [
646         AC_MSG_RESULT([yes])
647         ], [
648         vg_cv_only64bit="yes"
649         AC_MSG_RESULT([no])
650         ])
651         CFLAGS=$safe_CFLAGS;;
652 esac
654 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
655    AC_MSG_ERROR(
656       [--enable-only32bit was specified but system does not support 32 bit builds])
659 #----------------------------------------------------------------------------
661 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
662 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
663 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
664 # above) will be "amd64" since that reflects the most that this cpu can do,
665 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
666 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
667 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
668 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
669 AC_SUBST(VGCONF_ARCH_PRI)
671 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
672 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
673 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
674 # It is empty if there is no secondary target.
675 AC_SUBST(VGCONF_ARCH_SEC)
677 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
678 # The entire system, including regression and performance tests, will be
679 # built for this target.  The "_CAPS" indicates that the name is in capital
680 # letters, and it also uses '_' rather than '-' as a separator, because it's
681 # used to create various Makefile variables, which are all in caps by
682 # convention and cannot contain '-' characters.  This is in contrast to
683 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
684 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
686 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
687 # Valgrind and tools will also be built for this target, but not the
688 # regression or performance tests.
690 # By default, the primary arch is the same as the "max" arch, as commented
691 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
692 # the big case statement just below here, in the case where we're building
693 # on a 64 bit machine but have been requested only to do a 32 bit build.
694 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
696 AC_MSG_CHECKING([for a supported CPU/OS combination])
698 # NB.  The load address for a given platform may be specified in more 
699 # than one place, in some cases, depending on whether we're doing a biarch,
700 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
701 # Be careful to give consistent values in all subcases.  Also, all four
702 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
703 # even if it is to "0xUNSET".
705 case "$ARCH_MAX-$VGCONF_OS" in
706      x86-linux)
707         VGCONF_ARCH_PRI="x86"
708         VGCONF_ARCH_SEC=""
709         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
710         VGCONF_PLATFORM_SEC_CAPS=""
711         valt_load_address_pri_norml="0x58000000"
712         valt_load_address_pri_inner="0x38000000"
713         valt_load_address_sec_norml="0xUNSET"
714         valt_load_address_sec_inner="0xUNSET"
715         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
716         ;;
717      amd64-linux)
718         valt_load_address_sec_norml="0xUNSET"
719         valt_load_address_sec_inner="0xUNSET"
720         if test x$vg_cv_only64bit = xyes; then
721            VGCONF_ARCH_PRI="amd64"
722            VGCONF_ARCH_SEC=""
723            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
724            VGCONF_PLATFORM_SEC_CAPS=""
725            valt_load_address_pri_norml="0x58000000"
726            valt_load_address_pri_inner="0x38000000"
727         elif test x$vg_cv_only32bit = xyes; then
728            VGCONF_ARCH_PRI="x86"
729            VGCONF_ARCH_SEC=""
730            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
731            VGCONF_PLATFORM_SEC_CAPS=""
732            valt_load_address_pri_norml="0x58000000"
733            valt_load_address_pri_inner="0x38000000"
734         else
735            VGCONF_ARCH_PRI="amd64"
736            VGCONF_ARCH_SEC="x86"
737            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
738            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
739            valt_load_address_pri_norml="0x58000000"
740            valt_load_address_pri_inner="0x38000000"
741            valt_load_address_sec_norml="0x58000000"
742            valt_load_address_sec_inner="0x38000000"
743         fi
744         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
745         ;;
746      ppc32-linux)
747         VGCONF_ARCH_PRI="ppc32"
748         VGCONF_ARCH_SEC=""
749         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
750         VGCONF_PLATFORM_SEC_CAPS=""
751         valt_load_address_pri_norml="0x58000000"
752         valt_load_address_pri_inner="0x38000000"
753         valt_load_address_sec_norml="0xUNSET"
754         valt_load_address_sec_inner="0xUNSET"
755         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
756         ;;
757      ppc64be-linux)
758         valt_load_address_sec_norml="0xUNSET"
759         valt_load_address_sec_inner="0xUNSET"
760         if test x$vg_cv_only64bit = xyes; then
761            VGCONF_ARCH_PRI="ppc64be"
762            VGCONF_ARCH_SEC=""
763            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
764            VGCONF_PLATFORM_SEC_CAPS=""
765            valt_load_address_pri_norml="0x58000000"
766            valt_load_address_pri_inner="0x38000000"
767         elif test x$vg_cv_only32bit = xyes; then
768            VGCONF_ARCH_PRI="ppc32"
769            VGCONF_ARCH_SEC=""
770            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
771            VGCONF_PLATFORM_SEC_CAPS=""
772            valt_load_address_pri_norml="0x58000000"
773            valt_load_address_pri_inner="0x38000000"
774         else
775            VGCONF_ARCH_PRI="ppc64be"
776            VGCONF_ARCH_SEC="ppc32"
777            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
778            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
779            valt_load_address_pri_norml="0x58000000"
780            valt_load_address_pri_inner="0x38000000"
781            valt_load_address_sec_norml="0x58000000"
782            valt_load_address_sec_inner="0x38000000"
783         fi
784         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
785         ;;
786      ppc64le-linux)
787         # Little Endian is only supported on PPC64
788         valt_load_address_sec_norml="0xUNSET"
789         valt_load_address_sec_inner="0xUNSET"
790         VGCONF_ARCH_PRI="ppc64le"
791         VGCONF_ARCH_SEC=""
792         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
793         VGCONF_PLATFORM_SEC_CAPS=""
794         valt_load_address_pri_norml="0x58000000"
795         valt_load_address_pri_inner="0x38000000"
796         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
797        ;;
798      x86-freebsd)
799         VGCONF_ARCH_PRI="x86"
800         VGCONF_ARCH_SEC=""
801         VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
802         VGCONF_PLATFORM_SEC_CAPS=""
803         valt_load_address_pri_norml="0x38000000"
804         valt_load_address_pri_inner="0x28000000"
805         valt_load_address_sec_norml="0xUNSET"
806         valt_load_address_sec_inner="0xUNSET"
807         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
808         ;;
809      amd64-freebsd)
810         if test x$vg_cv_only64bit = xyes; then
811            VGCONF_ARCH_PRI="amd64"
812            VGCONF_ARCH_SEC=""
813            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
814            VGCONF_PLATFORM_SEC_CAPS=""
815         elif test x$vg_cv_only32bit = xyes; then
816            VGCONF_ARCH_PRI="x86"
817            VGCONF_ARCH_SEC=""
818            VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
819            VGCONF_PLATFORM_SEC_CAPS=""
820         else
821            VGCONF_ARCH_PRI="amd64"
822            VGCONF_ARCH_SEC="x86"
823            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
824            VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
825         fi
826         # These work with either base clang or ports installed gcc
827         # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
828         if test x$is_clang = xclang ; then
829            FLAG_32ON64="-B/usr/lib32"
830         else
831            GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
832            FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
833            FLAG_32ON64_GXX="-L/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -lgcc_s"
834            AC_SUBST(FLAG_32ON64_GXX)
835         fi
836         valt_load_address_pri_norml="0x38000000"
837         valt_load_address_pri_inner="0x28000000"
838         valt_load_address_sec_norml="0x38000000"
839         valt_load_address_sec_inner="0x28000000"
840         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
841         ;;
842      arm64-freebsd)
843         VGCONF_ARCH_PRI="arm64"
844         VGCONF_ARCH_SEC=""
845         VGCONF_PLATFORM_PRI_CAPS="ARM64_FREEBSD"
846         VGCONF_PLATFORM_SEC_CAPS=""
847         valt_load_address_pri_norml="0x38000000"
848         valt_load_address_pri_inner="0x28000000"
849         valt_load_address_sec_norml="0xUNSET"
850         valt_load_address_sec_inner="0xUNSET"
851         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
852         ;;
853      # Darwin gets identified as 32-bit even when it supports 64-bit.
854      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
855      # all Macs support both 32-bit and 64-bit, so we just build both.  If
856      # someone has a really old 32-bit only machine they can (hopefully?)
857      # build with --enable-only32bit.  See bug 243362.
858      x86-darwin|amd64-darwin)
859         ARCH_MAX="amd64"
860         valt_load_address_sec_norml="0xUNSET"
861         valt_load_address_sec_inner="0xUNSET"
862         if test x$vg_cv_only64bit = xyes; then
863            VGCONF_ARCH_PRI="amd64"
864            VGCONF_ARCH_SEC=""
865            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
866            VGCONF_PLATFORM_SEC_CAPS=""
867            valt_load_address_pri_norml="0x158000000"
868            valt_load_address_pri_inner="0x138000000"
869         elif test x$vg_cv_only32bit = xyes; then
870            VGCONF_ARCH_PRI="x86"
871            VGCONF_ARCH_SEC=""
872            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
873            VGCONF_PLATFORM_SEC_CAPS=""
874            VGCONF_ARCH_PRI_CAPS="x86"
875            valt_load_address_pri_norml="0x58000000"
876            valt_load_address_pri_inner="0x38000000"
877         else
878            VGCONF_ARCH_PRI="amd64"
879            VGCONF_ARCH_SEC="x86"
880            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
881            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
882            valt_load_address_pri_norml="0x158000000"
883            valt_load_address_pri_inner="0x138000000"
884            valt_load_address_sec_norml="0x58000000"
885            valt_load_address_sec_inner="0x38000000"
886         fi
887         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
888         ;;
889      arm-linux) 
890         VGCONF_ARCH_PRI="arm"
891         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
892         VGCONF_PLATFORM_SEC_CAPS=""
893         valt_load_address_pri_norml="0x58000000"
894         valt_load_address_pri_inner="0x38000000"
895         valt_load_address_sec_norml="0xUNSET"
896         valt_load_address_sec_inner="0xUNSET"
897         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
898         ;;
899      arm64-linux)
900         valt_load_address_sec_norml="0xUNSET"
901         valt_load_address_sec_inner="0xUNSET"
902         if test x$vg_cv_only64bit = xyes; then
903            VGCONF_ARCH_PRI="arm64"
904            VGCONF_ARCH_SEC=""
905            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
906            VGCONF_PLATFORM_SEC_CAPS=""
907            valt_load_address_pri_norml="0x58000000"
908            valt_load_address_pri_inner="0x38000000"
909         elif test x$vg_cv_only32bit = xyes; then
910            VGCONF_ARCH_PRI="arm"
911            VGCONF_ARCH_SEC=""
912            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
913            VGCONF_PLATFORM_SEC_CAPS=""
914            valt_load_address_pri_norml="0x58000000"
915            valt_load_address_pri_inner="0x38000000"
916         else
917            VGCONF_ARCH_PRI="arm64"
918            VGCONF_ARCH_SEC="arm"
919            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
920            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
921            valt_load_address_pri_norml="0x58000000"
922            valt_load_address_pri_inner="0x38000000"
923            valt_load_address_sec_norml="0x58000000"
924            valt_load_address_sec_inner="0x38000000"
925         fi
926         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
927         ;;
928      s390x-linux)
929         VGCONF_ARCH_PRI="s390x"
930         VGCONF_ARCH_SEC=""
931         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
932         VGCONF_PLATFORM_SEC_CAPS=""
933         # To improve branch prediction hit rate we want to have
934         # the generated code close to valgrind (host) code
935         valt_load_address_pri_norml="0x800000000"
936         valt_load_address_pri_inner="0x810000000"
937         valt_load_address_sec_norml="0xUNSET"
938         valt_load_address_sec_inner="0xUNSET"
939         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
940         ;;
941      mips32-linux) 
942         VGCONF_ARCH_PRI="mips32"
943         VGCONF_ARCH_SEC=""
944         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
945         VGCONF_PLATFORM_SEC_CAPS=""
946         valt_load_address_pri_norml="0x58000000"
947         valt_load_address_pri_inner="0x38000000"
948         valt_load_address_sec_norml="0xUNSET"
949         valt_load_address_sec_inner="0xUNSET"
950         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
951         ;;
952      mips64-linux)
953         valt_load_address_sec_norml="0xUNSET"
954         valt_load_address_sec_inner="0xUNSET"
955         if test x$vg_cv_only64bit = xyes; then
956             VGCONF_ARCH_PRI="mips64"
957             VGCONF_PLATFORM_SEC_CAPS=""
958             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
959             VGCONF_PLATFORM_SEC_CAPS=""
960             valt_load_address_pri_norml="0x58000000"
961             valt_load_address_pri_inner="0x38000000"
962         elif test x$vg_cv_only32bit = xyes; then
963             VGCONF_ARCH_PRI="mips32"
964             VGCONF_ARCH_SEC=""
965             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
966             VGCONF_PLATFORM_SEC_CAPS=""
967             valt_load_address_pri_norml="0x58000000"
968             valt_load_address_pri_inner="0x38000000"
969         else
970             VGCONF_ARCH_PRI="mips64"
971             VGCONF_ARCH_SEC="mips32"
972             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
973             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
974             valt_load_address_pri_norml="0x58000000"
975             valt_load_address_pri_inner="0x38000000"
976             valt_load_address_sec_norml="0x58000000"
977             valt_load_address_sec_inner="0x38000000"
978         fi
979         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
980         ;;
981      nanomips-linux)
982         VGCONF_ARCH_PRI="nanomips"
983         VGCONF_ARCH_SEC=""
984         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
985         VGCONF_PLATFORM_SEC_CAPS=""
986         valt_load_address_pri_norml="0x58000000"
987         valt_load_address_pri_inner="0x38000000"
988         valt_load_address_sec_norml="0xUNSET"
989         valt_load_address_sec_inner="0xUNSET"
990         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
991         ;;
992      x86-solaris)
993         VGCONF_ARCH_PRI="x86"
994         VGCONF_ARCH_SEC=""
995         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
996         VGCONF_PLATFORM_SEC_CAPS=""
997         valt_load_address_pri_norml="0x58000000"
998         valt_load_address_pri_inner="0x38000000"
999         valt_load_address_sec_norml="0xUNSET"
1000         valt_load_address_sec_inner="0xUNSET"
1001         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
1002         ;;
1003      amd64-solaris)
1004         valt_load_address_sec_norml="0xUNSET"
1005         valt_load_address_sec_inner="0xUNSET"
1006         if test x$vg_cv_only64bit = xyes; then
1007            VGCONF_ARCH_PRI="amd64"
1008            VGCONF_ARCH_SEC=""
1009            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
1010            VGCONF_PLATFORM_SEC_CAPS=""
1011            valt_load_address_pri_norml="0x58000000"
1012            valt_load_address_pri_inner="0x38000000"
1013         elif test x$vg_cv_only32bit = xyes; then
1014            VGCONF_ARCH_PRI="x86"
1015            VGCONF_ARCH_SEC=""
1016            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
1017            VGCONF_PLATFORM_SEC_CAPS=""
1018            valt_load_address_pri_norml="0x58000000"
1019            valt_load_address_pri_inner="0x38000000"
1020         else
1021            VGCONF_ARCH_PRI="amd64"
1022            VGCONF_ARCH_SEC="x86"
1023            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
1024            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
1025            valt_load_address_pri_norml="0x58000000"
1026            valt_load_address_pri_inner="0x38000000"
1027            valt_load_address_sec_norml="0x58000000"
1028            valt_load_address_sec_inner="0x38000000"
1029         fi
1030         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
1031         ;;
1032     *)
1033         VGCONF_ARCH_PRI="unknown"
1034         VGCONF_ARCH_SEC="unknown"
1035         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
1036         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
1037         valt_load_address_pri_norml="0xUNSET"
1038         valt_load_address_pri_inner="0xUNSET"
1039         valt_load_address_sec_norml="0xUNSET"
1040         valt_load_address_sec_inner="0xUNSET"
1041         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
1042         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
1043         ;;
1044 esac
1046 #----------------------------------------------------------------------------
1048 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
1049 # defined.
1050 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
1051                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1052                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1053                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1054                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1055                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1056                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1057                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1058                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1059 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
1060                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1061                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1062                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1063                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1064 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
1065                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1066                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1067 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
1068                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1069                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1070 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
1071                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1072                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1073 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
1074                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1075                -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_FREEBSD )
1076 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1077                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1078 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1079                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1080                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1081 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1082                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
1083 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1084                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1086 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
1087 # become defined.
1088 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
1089                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1090                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1091 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
1092                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1093 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
1094                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1095                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1096 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1097                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1098 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1099                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1100 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1101                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1102                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1103 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1104                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1105 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1106                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1107                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1108 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1109                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1110                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1111 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1112                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1113 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1114                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1115 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1116                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1117                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1118 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1119                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1120 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_FREEBSD, 
1121                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_FREEBSD)
1122 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1123                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1124                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1125 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1126                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1127 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1128                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1129                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1130 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1131                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1134 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1135 # Relies on the assumption that the primary and secondary targets are 
1136 # for the same OS, so therefore only necessary to test the primary.
1137 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1138                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1139                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1140                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1141                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1142                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1143                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1144                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1145                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1146                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1147                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1148                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1149 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1150                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1151                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1152                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_FREEBSD)
1153 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1154                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1155                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1156 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1157                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1158                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1159 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1160                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1161                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1162                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_FREEBSD \
1163                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1164                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1167 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1168 # there is a secondary target.
1169 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1170                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1172 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1173 dnl fallback definition
1174 dnl The macro is courtesy of Dave Hart:
1175 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1176 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1177 if test -z "$$1_TRUE"; then :
1178   m4_n([$2])[]dnl
1179 m4_ifval([$3],
1180 [else
1181   $3
1182 ])dnl
1183 fi[]dnl
1184 ])])
1186 #----------------------------------------------------------------------------
1187 # Inner Valgrind?
1188 #----------------------------------------------------------------------------
1190 # Check if this should be built as an inner Valgrind, to be run within
1191 # another Valgrind.  Choose the load address accordingly.
1192 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1193 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1194 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1195    [AC_ARG_ENABLE(inner, 
1196       [  --enable-inner          enables self-hosting],
1197       [vg_cv_inner=$enableval],
1198       [vg_cv_inner=no])])
1199 if test "$vg_cv_inner" = yes; then
1200     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1201     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1202     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1203 else
1204     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1205     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1208 #----------------------------------------------------------------------------
1209 # Undefined behaviour sanitiser
1210 #----------------------------------------------------------------------------
1211 # Check whether we should build with the undefined beahviour sanitiser.
1213 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1214    [AC_ARG_ENABLE(ubsan, 
1215       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1216       [vg_cv_ubsan=$enableval],
1217       [vg_cv_ubsan=no])])
1219 #----------------------------------------------------------------------------
1220 # Extra fine-tuning of installation directories
1221 #----------------------------------------------------------------------------
1222 AC_ARG_WITH(tmpdir,
1223    [  --with-tmpdir=PATH      Specify path for temporary files],
1224    tmpdir="$withval",
1225    tmpdir="/tmp")
1226 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1227 AC_SUBST(VG_TMPDIR, [$tmpdir])
1229 #----------------------------------------------------------------------------
1230 # Detect xcode path
1231 #----------------------------------------------------------------------------
1232 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1233 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1234 AC_MSG_CHECKING([for xcode sdk include path])
1235 AC_ARG_WITH(xcodedir,
1236    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1237    [xcodedir="$withval"],
1238    [
1239       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1240          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1241          if test -z "$xcrundir"; then
1242             xcodedir="/usr/include"
1243          else
1244             xcodedir="$xcrundir/usr/include"
1245          fi
1246       else
1247          xcodedir="/usr/include"
1248       fi
1249    ])
1250 AC_MSG_RESULT([$xcodedir])
1251 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1252 AC_SUBST(XCODE_DIR, [$xcodedir])])
1254 #----------------------------------------------------------------------------
1255 # Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir)
1256 #----------------------------------------------------------------------------
1257 AC_MSG_CHECKING([where gdb scripts are installed])
1258 AC_ARG_WITH(gdbscripts-dir,
1259    [  --with-gdbscripts-dir=PATH  Specify path to install gdb scripts],
1260    [gdbscriptsdir=${withval}],
1261    [gdbscriptsdir=${libexecdir}/valgrind])
1262 AC_MSG_RESULT([$gdbscriptsdir])
1263 if test "x$gdbscriptsdir" != "xno"; then
1264   AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir])
1265   AM_CONDITIONAL(GDBSCRIPTS, true)
1266 else
1267   AC_SUBST(VG_GDBSCRIPTS_DIR, [])
1268   AM_CONDITIONAL(GDBSCRIPTS, false)
1271 #----------------------------------------------------------------------------
1272 # Libc and suppressions
1273 #----------------------------------------------------------------------------
1274 # This variable will collect the suppression files to be used.
1275 AC_SUBST(DEFAULT_SUPP)
1277 AC_CHECK_HEADER([features.h])
1279 if test x$ac_cv_header_features_h = xyes; then
1280   AC_DEFINE([HAVE_HEADER_FEATURES_H], 1,
1281           [Define to 1 if you have the `features.h' header.])
1282   rm -f conftest.$ac_ext
1283   cat <<_ACEOF >conftest.$ac_ext
1284 #include <features.h>
1285 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1286 glibc version is: __GLIBC__ __GLIBC_MINOR__
1287 #endif
1288 _ACEOF
1289   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1292 # not really a version check
1293 AC_EGREP_CPP([DARWIN_LIBC], [
1294 #include <sys/cdefs.h>
1295 #if defined(__DARWIN_VERS_1050)
1296   DARWIN_LIBC
1297 #endif
1299 GLIBC_VERSION="darwin")
1301 AC_EGREP_CPP([FREEBSD_LIBC], [
1302 #include <sys/cdefs.h>
1303 #if defined(__FreeBSD__)
1304   FREEBSD_LIBC
1305 #endif
1307 GLIBC_VERSION="freebsd")
1309 # not really a version check
1310 AC_EGREP_CPP([BIONIC_LIBC], [
1311 #if defined(__ANDROID__)
1312   BIONIC_LIBC
1313 #endif
1315 GLIBC_VERSION="bionic")
1317 # there is only one version of libc on Solaris
1318 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1319      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1320     GLIBC_VERSION="solaris"
1323 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1324 # in this case.
1325 if test x$GLIBC_VERSION = x; then
1326     if $CC -dumpmachine | grep -q musl; then
1327         GLIBC_VERSION=musl
1328     fi
1331 # If this is glibc then figure out the generic (in file) libc.so and
1332 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1333 # was a separate library, afterwards it was merged into libc.so and
1334 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1335 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1336 case ${GLIBC_VERSION} in
1338   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1339   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1340   [
1341     AC_MSG_RESULT([no])
1342     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1343     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1344   ], [
1345     AC_MSG_RESULT([yes])
1346     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1347     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1348   ])
1349   ;;
1351   AC_MSG_CHECKING([not glibc...])
1352   AC_MSG_RESULT([${GLIBC_VERSION}])
1353   ;;
1354 esac
1356 AC_MSG_CHECKING([the glibc version])
1358 case "${GLIBC_VERSION}" in
1359      2.2)
1360         AC_MSG_RESULT(${GLIBC_VERSION} family)
1361         DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1362         DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1363         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1364         ;;
1365      2.[[3-6]])
1366         AC_MSG_RESULT(${GLIBC_VERSION} family)
1367         DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1368         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1369         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1370         ;;
1371      2.[[7-9]])
1372         AC_MSG_RESULT(${GLIBC_VERSION} family)
1373         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1374         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1375         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1376         ;;
1377      2.10|2.11)
1378         AC_MSG_RESULT(${GLIBC_VERSION} family)
1379         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1380                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1381         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1382         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1383         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1384         ;;
1385      2.*)
1386         AC_MSG_RESULT(${GLIBC_VERSION} family)
1387         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1388                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1389         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1390                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1391         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1392         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1393         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1394         ;;
1395      darwin)
1396         AC_MSG_RESULT(Darwin)
1397         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1398         # DEFAULT_SUPP set by kernel version check above.
1399         ;;
1400      freebsd)
1401         AC_MSG_RESULT(FreeBSD)
1402         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1403         # DEFAULT_SUPP set by kernel version check above.
1404         ;;
1405      bionic)
1406         AC_MSG_RESULT(Bionic)
1407         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1408         DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1409         ;;
1410      solaris)
1411         AC_MSG_RESULT(Solaris)
1412         # DEFAULT_SUPP set in host_os switch-case above.
1413         # No other suppression file is used.
1414         ;;
1415      musl)
1416         AC_MSG_RESULT(Musl)
1417         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1418         DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1419         ;;
1420      2.0|2.1|*)
1421         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1422         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1423         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1424         ;;
1425 esac
1427 AC_SUBST(GLIBC_VERSION)
1428 AC_SUBST(GLIBC_LIBC_PATH)
1429 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1432 if test "$VGCONF_OS" != "solaris"; then
1433     # Add default suppressions for the X client libraries.  Make no
1434     # attempt to detect whether such libraries are installed on the
1435     # build machine (or even if any X facilities are present); just
1436     # add the suppressions antidisirregardless.
1437     DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1438     DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1442 #----------------------------------------------------------------------------
1443 # Platform variants?
1444 #----------------------------------------------------------------------------
1446 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1447 # But there are times where we need a bit more control.  The motivating
1448 # and currently only case is Android: this is almost identical to
1449 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1450 # platform variant tags, which get passed in the compile as
1451 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1453 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1454 # it is "android" instead.
1456 # Consequently (eg), plain arm-linux would build with
1458 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1460 # whilst an Android build would have
1462 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1464 # Same for x86. The setup of the platform variant is pushed relatively far
1465 # down this file in order that we can inspect any of the variables set above.
1467 # In the normal case ..
1468 VGCONF_PLATVARIANT="vanilla"
1470 # Android ?
1471 if test "$GLIBC_VERSION" = "bionic";
1472 then
1473    VGCONF_PLATVARIANT="android"
1476 AC_SUBST(VGCONF_PLATVARIANT)
1479 # FIXME: do we also want to define automake variables
1480 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1481 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1482 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1483 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1484 # that's what we'd need to do to use this, since what we'd want to write
1485 # is something like
1487 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1489 # Hmm.  Can't think of a nice clean solution to this.
1491 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1492                test x$VGCONF_PLATVARIANT = xvanilla)
1493 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1494                test x$VGCONF_PLATVARIANT = xandroid)
1497 #----------------------------------------------------------------------------
1498 # Checking for various library functions and other definitions
1499 #----------------------------------------------------------------------------
1501 # Check for AT_FDCWD
1503 AC_MSG_CHECKING([for AT_FDCWD])
1504 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1505 #define _GNU_SOURCE
1506 #include <fcntl.h>
1507 #include <unistd.h>
1508 ]], [[
1509   int a = AT_FDCWD;
1510 ]])], [
1511 ac_have_at_fdcwd=yes
1512 AC_MSG_RESULT([yes])
1513 ], [
1514 ac_have_at_fdcwd=no
1515 AC_MSG_RESULT([no])
1518 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1520 # Check for stpncpy function definition in string.h
1521 # This explicitly checks with _GNU_SOURCE defined since that is also
1522 # used in the test case (some systems might define it without anyway
1523 # since stpncpy is part of The Open Group Base Specifications Issue 7
1524 # IEEE Std 1003.1-2008.
1525 AC_MSG_CHECKING([for stpncpy])
1526 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1527 #define _GNU_SOURCE
1528 #include <string.h>
1529 ]], [[
1530   char *d;
1531   char *s;
1532   size_t n = 0;
1533   char *r = stpncpy(d, s, n);
1534 ]])], [
1535 ac_have_gnu_stpncpy=yes
1536 AC_MSG_RESULT([yes])
1537 ], [
1538 ac_have_gnu_stpncpy=no
1539 AC_MSG_RESULT([no])
1542 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1544 # Check for PTRACE_GETREGS
1546 AC_MSG_CHECKING([for PTRACE_GETREGS])
1547 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1548 #include <stdlib.h>
1549 #include <stddef.h>
1550 #include <sys/ptrace.h>
1551 #include <sys/user.h>
1552 ]], [[
1553   void *p;
1554   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1555 ]])], [
1556 AC_MSG_RESULT([yes])
1557 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1558           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1559 ], [
1560 AC_MSG_RESULT([no])
1564 # Check for CLOCK_MONOTONIC
1566 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1568 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1569 #include <time.h>
1570 ]], [[
1571   struct timespec t;
1572   clock_gettime(CLOCK_MONOTONIC, &t);
1573   return 0;
1574 ]])], [
1575 AC_MSG_RESULT([yes])
1576 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1577           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1578 ], [
1579 AC_MSG_RESULT([no])
1583 # Check for ELF32/64_CHDR
1585 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1588 # Check for PTHREAD_RWLOCK_T
1590 AC_MSG_CHECKING([for pthread_rwlock_t])
1592 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1593 #define _GNU_SOURCE
1594 #include <pthread.h>
1595 ]], [[
1596   pthread_rwlock_t rwl;
1597 ]])], [
1598 AC_MSG_RESULT([yes])
1599 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1600           [Define to 1 if you have the `pthread_rwlock_t' type.])
1601 ], [
1602 AC_MSG_RESULT([no])
1605 # Check for CLOCKID_T
1607 AC_MSG_CHECKING([for clockid_t])
1609 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1610 #include <time.h>
1611 ]], [[
1612   clockid_t c;
1613 ]])], [
1614 AC_MSG_RESULT([yes])
1615 AC_DEFINE([HAVE_CLOCKID_T], 1,
1616           [Define to 1 if you have the `clockid_t' type.])
1617 ], [
1618 AC_MSG_RESULT([no])
1621 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1623 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1625 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1626 #define _GNU_SOURCE
1627 #include <pthread.h>
1628 ]], [[
1629   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1630 ]])], [
1631 AC_MSG_RESULT([yes])
1632 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1633           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1634 ], [
1635 AC_MSG_RESULT([no])
1639 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1641 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1643 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1644 #define _GNU_SOURCE
1645 #include <pthread.h>
1646 ]], [[
1647   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1648 ]])], [
1649 AC_MSG_RESULT([yes])
1650 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1651           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1652 ], [
1653 AC_MSG_RESULT([no])
1657 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1659 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1661 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1662 #define _GNU_SOURCE
1663 #include <pthread.h>
1664 ]], [[
1665   return (PTHREAD_MUTEX_RECURSIVE_NP);
1666 ]])], [
1667 AC_MSG_RESULT([yes])
1668 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1669           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1670 ], [
1671 AC_MSG_RESULT([no])
1675 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1677 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1679 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1680 #define _GNU_SOURCE
1681 #include <pthread.h>
1682 ]], [[
1683   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1684   return 0;
1685 ]])], [
1686 AC_MSG_RESULT([yes])
1687 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1688           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1689 ], [
1690 AC_MSG_RESULT([no])
1694 # Check whether pthread_mutex_t has a member called __m_kind.
1696 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1697                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1698                            1,                                   
1699                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1700                 ],
1701                 [],
1702                 [#include <pthread.h>])
1705 # Check whether pthread_mutex_t has a member called __data.__kind.
1707 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1708                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1709                           1,
1710                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1711                 ],
1712                 [],
1713                 [#include <pthread.h>])
1715 # Convenience function.  Set flags based on the existing HWCAP entries.
1716 # The AT_HWCAP entries are generated by glibc, and are based on
1717 # functions supported by the hardware/system/libc.
1718 # Subsequent support for whether the capability will actually be utilized
1719 # will also be checked against the compiler capabilities.
1720 # called as
1721 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1722 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1723   AUXV_CHECK_FOR=$1
1724   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1725   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1726   then
1727     AC_MSG_RESULT([yes])
1728     AC_SUBST([$2],[yes])
1729   else
1730     AC_MSG_RESULT([no])
1731     AC_SUBST([$2],[])
1732   fi
1735 # gather hardware capabilities. (hardware/kernel/libc)
1736 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1737 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1738 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1739 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1740 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1741 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1742 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1743 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1744 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1745 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1747 # ISA Levels
1748 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1749 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1750 # compiler support for isa 2.07 level instructions
1751 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1753 ]], [[
1754   __asm__ __volatile__("mtvsrd 1,2 ");
1755 ]])], [
1756 ac_asm_have_isa_2_07=yes
1757 AC_MSG_RESULT([yes])
1758 ], [
1759 ac_asm_have_isa_2_07=no
1760 AC_MSG_RESULT([no])
1762 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1763                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1765 # altivec (vsx) support.
1766 # does this compiler support -maltivec and does it have the include file
1767 # <altivec.h> ?
1768 AC_MSG_CHECKING([for Altivec support in the compiler ])
1769 safe_CFLAGS=$CFLAGS
1770 CFLAGS="-maltivec -Werror"
1771 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1772 #include <altivec.h>
1773 ]], [[
1774   vector unsigned int v;
1775 ]])], [
1776 ac_have_altivec=yes
1777 AC_MSG_RESULT([yes])
1778 ], [
1779 ac_have_altivec=no
1780 AC_MSG_RESULT([no])
1782 CFLAGS=$safe_CFLAGS
1783 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1784                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1786 # Check that both: the compiler supports -mvsx and that the assembler
1787 # understands VSX instructions.  If either of those doesn't work,
1788 # conclude that we can't do VSX.
1789 AC_MSG_CHECKING([for VSX compiler flag support])
1790 safe_CFLAGS=$CFLAGS
1791 CFLAGS="-mvsx -Werror"
1792 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1793 ]], [[
1794 ]])], [
1795 ac_compiler_supports_vsx_flag=yes
1796 AC_MSG_RESULT([yes])
1797 ], [
1798 ac_compiler_supports_vsx_flag=no
1799 AC_MSG_RESULT([no])
1801 CFLAGS=$safe_CFLAGS
1803 AC_MSG_CHECKING([for VSX support in the assembler ])
1804 safe_CFLAGS=$CFLAGS
1805 CFLAGS="-mvsx -Werror"
1806 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1807 #include <altivec.h>
1808 ]], [[
1809   vector unsigned int v;
1810   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1811 ]])], [
1812 ac_compiler_supports_vsx=yes
1813 AC_MSG_RESULT([yes])
1814 ], [
1815 ac_compiler_supports_vsx=no
1816 AC_MSG_RESULT([no])
1818 CFLAGS=$safe_CFLAGS
1819 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1820                              -a x$ac_compiler_supports_vsx = xyes \
1821                              -a x$HWCAP_HAS_VSX = xyes ])
1823 # DFP (Decimal Float)
1824 # The initial DFP support was added in Power 6.  The dcffix instruction
1825 # support was added in Power 7.
1826 AC_MSG_CHECKING([that assembler knows DFP])
1827 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1828 ]], [[
1829   #ifdef __s390__
1830   __asm__ __volatile__("adtr 1, 2, 3")
1831   #else
1832 __asm__ __volatile__(".machine power7;\n" \
1833   "dadd 1, 2, 3;\n" \
1834   "dcffix 1, 2");
1835   #endif
1836 ]])], [
1837 ac_asm_have_dfp=yes
1838 AC_MSG_RESULT([yes])
1839 ], [
1840 ac_asm_have_dfp=no
1841 AC_MSG_RESULT([no])
1843 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1844 safe_CFLAGS=$CFLAGS
1845 CFLAGS="-mhard-dfp -Werror"
1847 # The dcffix instruction is Power 7
1848 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1849 ]], [[
1850   #ifdef __s390__
1851   __asm__ __volatile__("adtr 1, 2, 3")
1852   #else
1853   __asm__ __volatile__(".machine power7;\n" \
1854   "dadd 1, 2, 3;\n" \
1855   "dcffix 1, 2");
1856   #endif
1857 ]])], [
1858 ac_compiler_have_dfp=yes
1859 AC_MSG_RESULT([yes])
1860 ], [
1861 ac_compiler_have_dfp=no
1862 AC_MSG_RESULT([no])
1864 CFLAGS=$safe_CFLAGS
1865 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1866                           -a x$ac_compiler_have_dfp = xyes \
1867                           -a x$HWCAP_HAS_DFP = xyes )
1869 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1870 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1871 ]], [[
1872   _Decimal64 x = 0.0DD;
1873 ]])], [
1874 ac_compiler_have_dfp_type=yes
1875 AC_MSG_RESULT([yes])
1876 ], [
1877 ac_compiler_have_dfp_type=no
1878 AC_MSG_RESULT([no])
1880 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1881                                   -a x$HWCAP_HAS_DFP = xyes )
1884 # HTM (Hardware Transactional Memory)
1885 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1886 safe_CFLAGS=$CFLAGS
1887 CFLAGS="-mhtm -Werror"
1888 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1889 ]], [[
1890   return 0;
1891 ]])], [
1892 AC_MSG_RESULT([yes])
1893 ac_compiler_supports_htm=yes
1894 ], [
1895 AC_MSG_RESULT([no])
1896 ac_compiler_supports_htm=no
1898 CFLAGS=$safe_CFLAGS
1900 AC_MSG_CHECKING([if compiler can find the htm builtins])
1901 safe_CFLAGS=$CFLAGS
1902 CFLAGS="-mhtm -Werror"
1903  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1904  ]], [[
1905    if (__builtin_tbegin (0))
1906       __builtin_tend (0);
1907  ]])], [
1908  AC_MSG_RESULT([yes])
1909 ac_compiler_sees_htm_builtins=yes
1910  ], [
1911  AC_MSG_RESULT([no])
1912 ac_compiler_sees_htm_builtins=no
1913  ])
1914 CFLAGS=$safe_CFLAGS
1916 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1917                                -a x$ac_compiler_sees_htm_builtins = xyes \
1918                                -a x$HWCAP_HAS_HTM = xyes )
1920 # isa 3.0 checking. (actually 3.0 or newer)
1921 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1923 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1924 ]], [[
1925 __asm__ __volatile__ (".machine power9;\n" \
1926         "cnttzw   1,3; \n" );
1927 ]])], [
1928 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1929 # cpabort support
1930 safe_CFLAGS=$CFLAGS
1931 CFLAGS="-DHAS_ISA_3_00"
1932 ac_asm_have_isa_3_00=yes
1933 AC_MSG_RESULT([yes])
1934 ], [
1935 ac_asm_have_isa_3_00=no
1936 AC_MSG_RESULT([no])
1938 CFLAGS=$safe_CFLAGS
1940 # xscvhpdp checking
1941 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1943 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1944 ]], [[
1945 __asm__ __volatile__ (".machine power9;\n" \
1946         "xscvhpdp 1,2;\n" );
1947 ]])], [
1948 ac_asm_have_xscvhpdp=yes
1949 AC_MSG_RESULT([yes])
1950 ], [
1951 ac_asm_have_xscvhpdp=no
1952 AC_MSG_RESULT([no])
1955 # darn instruction checking
1956 AC_MSG_CHECKING([that assembler knows darn instruction ])
1958 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1959 ]], [[
1960   __asm__ __volatile__(".machine power9; darn 1,0 ");
1961 ]])], [
1962 ac_asm_have_darn_inst=yes
1963 AC_MSG_RESULT([yes])
1964 ], [
1965 ac_asm_have_darn_inst=no
1966 AC_MSG_RESULT([no])
1969 # isa 3.01 checking
1970 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1971 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1972 ]], [[
1973 __asm__ __volatile__ (".machine power10;\n" \
1974         "brh 1,2;\n ");
1975 ]])], [
1976 ac_asm_have_isa_3_1=yes
1977 AC_MSG_RESULT([yes])
1978 ], [
1979 ac_asm_have_isa_3_1=no
1980 AC_MSG_RESULT([no])
1984 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1985                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1987 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1988 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1990 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1991                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1993 # Check for pthread_create@GLIBC2.0
1994 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1996 safe_CFLAGS=$CFLAGS
1997 CFLAGS="-lpthread -Werror"
1998 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1999 extern int pthread_create_glibc_2_0(void*, const void*,
2000                                     void *(*)(void*), void*);
2001 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
2002 ]], [[
2003 #ifdef __powerpc__
2005  * Apparently on PowerPC linking this program succeeds and generates an
2006  * executable with the undefined symbol pthread_create@GLIBC_2.0.
2007  */
2008 #error This test does not work properly on PowerPC.
2009 #else
2010   pthread_create_glibc_2_0(0, 0, 0, 0);
2011 #endif
2012   return 0;
2013 ]])], [
2014 ac_have_pthread_create_glibc_2_0=yes
2015 AC_MSG_RESULT([yes])
2016 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
2017           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
2018 ], [
2019 ac_have_pthread_create_glibc_2_0=no
2020 AC_MSG_RESULT([no])
2022 CFLAGS=$safe_CFLAGS
2024 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
2025                test x$ac_have_pthread_create_glibc_2_0 = xyes)
2028 # Check for dlinfo RTLD_DI_TLS_MODID
2029 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
2031 safe_LIBS="$LIBS"
2032 LIBS="-ldl"
2033 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2034 #ifndef _GNU_SOURCE
2035 #define _GNU_SOURCE
2036 #endif
2037 #include <link.h>
2038 #include <dlfcn.h>
2039 ]], [[
2040   size_t sizes[10000];
2041   size_t modid_offset;
2042   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
2043   return 0;
2044 ]])], [
2045 ac_have_dlinfo_rtld_di_tls_modid=yes
2046 AC_MSG_RESULT([yes])
2047 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
2048           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
2049 ], [
2050 ac_have_dlinfo_rtld_di_tls_modid=no
2051 AC_MSG_RESULT([no])
2053 LIBS=$safe_LIBS
2055 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
2056                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
2059 # Check for eventfd_t, eventfd() and eventfd_read()
2060 AC_MSG_CHECKING([for eventfd()])
2062 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2063 #include <sys/eventfd.h>
2064 ]], [[
2065   eventfd_t ev;
2066   int fd;
2068   fd = eventfd(5, 0);
2069   eventfd_read(fd, &ev);
2070   return 0;
2071 ]])], [
2072 AC_MSG_RESULT([yes])
2073 AC_DEFINE([HAVE_EVENTFD], 1,
2074           [Define to 1 if you have the `eventfd' function.])
2075 AC_DEFINE([HAVE_EVENTFD_READ], 1,
2076           [Define to 1 if you have the `eventfd_read' function.])
2077 ], [
2078 AC_MSG_RESULT([no])
2081 # Check whether compiler can process #include <thread> without errors
2082 # clang 3.3 cannot process <thread> from e.g.
2083 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
2085 AC_MSG_CHECKING([that C++ compiler can compile C++17 code])
2086 AC_LANG(C++)
2087 safe_CXXFLAGS=$CXXFLAGS
2088 CXXFLAGS=-std=c++17
2090 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2091 int x;
2092 ])],
2094 ac_have_cxx_17=yes
2095 AC_MSG_RESULT([yes])
2096 ], [
2097 ac_have_cxx_17=no
2098 AC_MSG_RESULT([no])
2100 CXXFLAGS=$safe_CXXFLAGS
2101 AC_LANG(C)
2103 AM_CONDITIONAL(HAVE_CXX17, test x$ac_have_cxx_17 = xyes)
2105 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
2106 AC_LANG(C++)
2107 safe_CXXFLAGS=$CXXFLAGS
2108 CXXFLAGS=-std=c++0x
2110 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2111 #include <thread> 
2112 ])],
2114 ac_cxx_can_include_thread_header=yes
2115 AC_MSG_RESULT([yes])
2116 ], [
2117 ac_cxx_can_include_thread_header=no
2118 AC_MSG_RESULT([no])
2120 CXXFLAGS=$safe_CXXFLAGS
2121 AC_LANG(C)
2123 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2125 # Check whether compiler can process #include <condition_variable> without errors
2127 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2128 AC_LANG(C++)
2129 safe_CXXFLAGS=$CXXFLAGS
2130 CXXFLAGS=-std=c++0x
2132 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2133 #include <condition_variable> 
2134 ])],
2136 ac_cxx_can_include_condition_variable_header=yes
2137 AC_MSG_RESULT([yes])
2138 ], [
2139 ac_cxx_can_include_condition_variable_header=no
2140 AC_MSG_RESULT([no])
2142 CXXFLAGS=$safe_CXXFLAGS
2143 AC_LANG(C)
2145 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2147 # check for std::shared_timed_mutex, this is a C++ 14 feature
2149 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2150 AC_LANG(C++)
2151 safe_CXXFLAGS=$CXXFLAGS
2152 CXXFLAGS="-std=c++1y -pthread"
2154 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2155 #include <shared_mutex>
2156 std::shared_timed_mutex test_mutex;
2157 ])],
2159 ac_cxx_can_use_shared_timed_mutex=yes
2160 AC_MSG_RESULT([yes])
2161 ], [
2162 ac_cxx_can_use_shared_timed_mutex=no
2163 AC_MSG_RESULT([no])
2165 CXXFLAGS=$safe_CXXFLAGS
2166 AC_LANG(C)
2168 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2170 # check for std::shared_mutex, this is a C++ 11 feature
2172 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2173 AC_LANG(C++)
2174 safe_CXXFLAGS=$CXXFLAGS
2175 CXXFLAGS="-std=c++0x -pthread"
2177 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2178 #include <mutex>
2179 std::timed_mutex test_mutex;
2180 ])],
2182 ac_cxx_can_use_timed_mutex=yes
2183 AC_MSG_RESULT([yes])
2184 ], [
2185 ac_cxx_can_use_timed_mutex=no
2186 AC_MSG_RESULT([no])
2188 CXXFLAGS=$safe_CXXFLAGS
2189 AC_LANG(C)
2191 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2193 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2194 # of the user_regs_struct from sys/user.h. They are structurally the same
2195 # but we get either one or the other.
2197 AC_CHECK_TYPE([struct user_regs_struct],
2198               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2199               [[#include <sys/ptrace.h>]
2200                [#include <sys/time.h>]
2201                [#include <sys/user.h>]])
2202 if test "$sys_user_has_user_regs" = "yes"; then
2203   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2204             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2207 AC_MSG_CHECKING([for __NR_membarrier])
2208 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2209 #include <linux/unistd.h>
2210 ]], [[
2211 return __NR_membarrier
2212 ]])], [
2213 ac_have_nr_membarrier=yes
2214 AC_MSG_RESULT([yes])
2215 ], [
2216 ac_have_nr_membarrier=no
2217 AC_MSG_RESULT([no])
2220 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2222 #----------------------------------------------------------------------------
2223 # Checking for supported compiler flags.
2224 #----------------------------------------------------------------------------
2226 case "${host_cpu}" in
2227     mips*)
2228         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2229         if test -z "$ARCH"; then
2230           # does this compiler support -march=mips32 (mips32 default) ?
2231           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2233           safe_CFLAGS=$CFLAGS
2234           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2236           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2237             return 0;
2238           ]])], [
2239           FLAG_M32="-mips32 -mabi=32"
2240           AC_MSG_RESULT([yes])
2241           ], [
2242           FLAG_M32=""
2243           AC_MSG_RESULT([no])
2244           ])
2245           CFLAGS=$safe_CFLAGS
2247           AC_SUBST(FLAG_M32)
2250           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2251           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2253           safe_CFLAGS=$CFLAGS
2254           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2256           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2257             return 0;
2258           ]])], [
2259           FLAG_M64="-march=mips64r2 -mabi=64"
2260           AC_MSG_RESULT([yes])
2261           ], [
2262           FLAG_M64=""
2263           AC_MSG_RESULT([no])
2264           ])
2265           CFLAGS=$safe_CFLAGS
2267           AC_SUBST(FLAG_M64)
2268         fi
2269         ;;
2270     nanomips*)
2271         ;;
2272     *)
2273         # does this compiler support -m32 ?
2274         AC_MSG_CHECKING([if gcc accepts -m32])
2276         safe_CFLAGS=$CFLAGS
2277         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2279         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2280           return 0;
2281         ]])], [
2282         FLAG_M32="${FLAG_32ON64} -m32"
2283         AC_MSG_RESULT([yes])
2284         ], [
2285         FLAG_M32=""
2286         AC_MSG_RESULT([no])
2287         ])
2288         CFLAGS=$safe_CFLAGS
2290         AC_SUBST(FLAG_M32)
2293         # does this compiler support -m64 ?
2294         AC_MSG_CHECKING([if gcc accepts -m64])
2296         safe_CFLAGS=$CFLAGS
2297         CFLAGS="-m64 -Werror"
2299         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2300           return 0;
2301         ]])], [
2302         FLAG_M64="-m64"
2303         AC_MSG_RESULT([yes])
2304         ], [
2305         FLAG_M64=""
2306         AC_MSG_RESULT([no])
2307         ])
2308         CFLAGS=$safe_CFLAGS
2310         AC_SUBST(FLAG_M64)
2311         ;;
2312 esac
2315 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2316 if test -z "$ARCH"; then
2317   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2318   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2320   safe_CFLAGS=$CFLAGS
2321   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2323   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2324     return 0;
2325   ]])], [
2326   FLAG_OCTEON="-march=octeon"
2327   AC_MSG_RESULT([yes])
2328   ], [
2329   FLAG_OCTEON=""
2330   AC_MSG_RESULT([no])
2331   ])
2332   CFLAGS=$safe_CFLAGS
2334   AC_SUBST(FLAG_OCTEON)
2337   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2338   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2340   safe_CFLAGS=$CFLAGS
2341   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2343   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2344     return 0;
2345   ]])], [
2346   FLAG_OCTEON2="-march=octeon2"
2347   AC_MSG_RESULT([yes])
2348   ], [
2349   FLAG_OCTEON2=""
2350   AC_MSG_RESULT([no])
2351   ])
2352   CFLAGS=$safe_CFLAGS
2354   AC_SUBST(FLAG_OCTEON2)
2358 # does this compiler support -mmsa (MIPS MSA ASE) ?
2359 AC_MSG_CHECKING([if gcc accepts -mmsa])
2361 safe_CFLAGS=$CFLAGS
2362 CFLAGS="$CFLAGS -mmsa -Werror"
2364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2365     return 0;
2366 ]])], [
2367 FLAG_MSA="-mmsa"
2368 AC_MSG_RESULT([yes])
2369 ], [
2370 FLAG_MSA=""
2371 AC_MSG_RESULT([no])
2373 CFLAGS=$safe_CFLAGS
2375 AC_SUBST(FLAG_MSA)
2377 # Are we compiling for the MIPS64 n32 ABI?
2378 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2379 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2380 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2381 #error NO
2382 #endif
2383 ]])], [
2384 VGCONF_ABI=N32
2385 FLAG_M64="-march=mips64r2 -mabi=n32"
2386 AC_MSG_RESULT([yes])
2387 ], [
2388 AC_MSG_RESULT([no])
2391 # Are we compiling for the MIPS64 n64 ABI?
2392 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2393 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2394 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2395 #error NO
2396 #endif
2397 ]])], [
2398 VGCONF_ABI=64
2399 AC_MSG_RESULT([yes])
2400 ], [
2401 AC_MSG_RESULT([no])
2404 # We enter the code block below in the following case:
2405 # Target architecture is set to mips64, the desired abi
2406 # was not specified and the compiler's default abi setting
2407 # is neither n32 nor n64.
2408 # Probe for and set the abi to either n64 or n32, in that order,
2409 # which is required for a mips64 build of valgrind.
2410 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2411   safe_CFLAGS=$CFLAGS
2412   CFLAGS="$CFLAGS -mabi=64 -Werror"
2413   AC_MSG_CHECKING([if gcc is n64 capable])
2414   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2415       return 0;
2416   ]])], [
2417   VGCONF_ABI=64
2418   AC_MSG_RESULT([yes])
2419   ], [
2420   AC_MSG_RESULT([no])
2421   ])
2422   CFLAGS=$safe_CFLAGS
2424   if test "x$VGCONF_ABI" = "x"; then
2425     safe_CFLAGS=$CFLAGS
2426     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2427     AC_MSG_CHECKING([if gcc is n32 capable])
2428     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2429         return 0;
2430     ]])], [
2431     VGCONF_ABI=N32
2432     FLAG_M64="-march=mips64r2 -mabi=n32"
2433     AC_MSG_RESULT([yes])
2434     ], [
2435     AC_MSG_RESULT([no])
2436     ])
2437     CFLAGS=$safe_CFLAGS
2438   fi
2441 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2442                [test x$VGCONF_ABI != x])
2443 AC_SUBST(VGCONF_ABI)
2446 # does this compiler support -mmmx ?
2447 AC_MSG_CHECKING([if gcc accepts -mmmx])
2449 safe_CFLAGS=$CFLAGS
2450 CFLAGS="-mmmx -Werror"
2452 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2453   return 0;
2454 ]])], [
2455 FLAG_MMMX="-mmmx"
2456 AC_MSG_RESULT([yes])
2457 ], [
2458 FLAG_MMMX=""
2459 AC_MSG_RESULT([no])
2461 CFLAGS=$safe_CFLAGS
2463 AC_SUBST(FLAG_MMMX)
2466 # does this compiler support -msse ?
2467 AC_MSG_CHECKING([if gcc accepts -msse])
2469 safe_CFLAGS=$CFLAGS
2470 CFLAGS="-msse -Werror"
2472 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2473   return 0;
2474 ]])], [
2475 FLAG_MSSE="-msse"
2476 AC_MSG_RESULT([yes])
2477 ], [
2478 FLAG_MSSE=""
2479 AC_MSG_RESULT([no])
2481 CFLAGS=$safe_CFLAGS
2483 AC_SUBST(FLAG_MSSE)
2486 # does this compiler support -mpreferred-stack-boundary=2 when
2487 # generating code for a 32-bit target?  Note that we only care about
2488 # this when generating code for (32-bit) x86, so if the compiler
2489 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2490 # the Memcheck and other helper functions, that is a bit slower than
2491 # it could be, on x86; and no difference at all on any other platform.
2492 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2494 safe_CFLAGS=$CFLAGS
2495 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2497 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2498   return 0;
2499 ]])], [
2500 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2501 AC_MSG_RESULT([yes])
2502 ], [
2503 PREFERRED_STACK_BOUNDARY_2=""
2504 AC_MSG_RESULT([no])
2506 CFLAGS=$safe_CFLAGS
2508 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2511 # does this compiler support -mlong-double-128 ?
2512 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2513 safe_CFLAGS=$CFLAGS
2514 CFLAGS="-mlong-double-128 -Werror"
2515 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2516   return 0;
2517 ]])], [
2518 ac_compiler_supports_mlong_double_128=yes
2519 AC_MSG_RESULT([yes])
2520 ], [
2521 ac_compiler_supports_mlong_double_128=no
2522 AC_MSG_RESULT([no])
2524 CFLAGS=$safe_CFLAGS
2525 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2526 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2527 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2529 # does this toolchain support lto ?
2530 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2531 # are not defined
2532 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2533 # a lot slower, and so not appropriate for Valgrind developments.
2534 # --enable-lto=yes should be used by distro packagers.
2535 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2536    [AC_ARG_ENABLE(lto,
2537       [  --enable-lto          enables building with link time optimisation],
2538       [vg_cv_lto=$enableval],
2539       [vg_cv_lto=no])])
2541 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2542 AC_MSG_CHECKING([if toolchain accepts lto])
2543 safe_CFLAGS=$CFLAGS
2544 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2545 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2546 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2547 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2549 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2550   extern void somefun(void);
2551   somefun();
2552   return 0;
2553 ]])], [
2554 LTO_CFLAGS=$TEST_LTO_CFLAGS
2555 AC_MSG_RESULT([yes])
2556 ], [
2557 LTO_CFLAGS=""
2558 AC_MSG_RESULT([no])
2560 CFLAGS=$safe_CFLAGS
2563 AC_SUBST(LTO_CFLAGS)
2565 # if we could not compile with lto args, or lto was disabled,
2566 # then set LTO_AR/LTO_RANLIB to the non lto values
2567 # define in config.h ENABLE_LTO (not needed by the code currently, but
2568 # this guarantees we recompile everything if we re-configure and rebuild
2569 # in a build dir previously build with another value of --enable-lto
2570 if test "x${LTO_CFLAGS}" = "x"; then
2571    LTO_AR=${AR}
2572    LTO_RANLIB=${RANLIB}
2573    vg_cv_lto=no
2574 else
2575    vg_cv_lto=yes
2576    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2579 # Convenience function to check whether GCC supports a particular
2580 # warning option. Takes two arguments,
2581 # first the warning flag name to check (without -W), then the
2582 # substitution name to set with -Wno-warning-flag if the flag exists,
2583 # or the empty string if the compiler doesn't accept the flag. Note
2584 # that checking is done against the warning flag itself, but the
2585 # substitution is then done to cancel the warning flag.
2586 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2587   AC_MSG_CHECKING([if gcc accepts -W$1])
2588   safe_CFLAGS=$CFLAGS
2589   CFLAGS="-W$1 -Werror"
2590   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2591   AC_SUBST([$2], [-Wno-$1])
2592   AC_MSG_RESULT([yes])], [
2593   AC_SUBST([$2], [])
2594   AC_MSG_RESULT([no])])
2595   CFLAGS=$safe_CFLAGS
2598 # A variation of the above for arguments that
2599 # take a value
2600 AC_DEFUN([AC_GCC_WARNING_SUBST_NO_VAL],[
2601   AC_MSG_CHECKING([if gcc accepts -W$1=$2])
2602   safe_CFLAGS=$CFLAGS
2603   CFLAGS="-W$1=$2 -Werror"
2604   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2605   AC_SUBST([$3], [-Wno-$1])
2606   AC_MSG_RESULT([yes])], [
2607   AC_SUBST([$3], [])
2608   AC_MSG_RESULT([no])])
2609   CFLAGS=$safe_CFLAGS
2612 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2613 # -W$1  (instead of -Wno-$1).
2614 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2615   AC_MSG_CHECKING([if gcc accepts -W$1])
2616   safe_CFLAGS=$CFLAGS
2617   CFLAGS="-W$1 -Werror"
2618   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2619   AC_SUBST([$2], [-W$1])
2620   AC_MSG_RESULT([yes])], [
2621   AC_SUBST([$2], [])
2622   AC_MSG_RESULT([no])])
2623   CFLAGS=$safe_CFLAGS
2626 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2627 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2628 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2629 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2630 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2631 AC_GCC_WARNING_SUBST_NO([maybe-uninitialized], [FLAG_W_NO_MAYBE_UNINITIALIZED])
2632 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2633 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2634 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2635 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2636 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2637 AC_GCC_WARNING_SUBST_NO([unused-variable], [FLAG_W_NO_UNUSED_VARIABLE])
2638 AC_GCC_WARNING_SUBST_NO([unused-but-set-variable], [FLAG_W_NO_UNUSED_BUT_SET_VARIABLE])
2639 AC_GCC_WARNING_SUBST_NO([non-power-of-two-alignment], [FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT])
2640 AC_GCC_WARNING_SUBST_NO([sign-compare], [FLAG_W_NO_SIGN_COMPARE])
2641 AC_GCC_WARNING_SUBST_NO([stringop-overflow], [FLAG_W_NO_STRINGOP_OVERFLOW])
2642 AC_GCC_WARNING_SUBST_NO([stringop-overread], [FLAG_W_NO_STRINGOP_OVERREAD])
2643 AC_GCC_WARNING_SUBST_NO([stringop-truncation], [FLAG_W_NO_STRINGOP_TRUNCATION])
2644 AC_GCC_WARNING_SUBST_NO([format-overflow], [FLAG_W_NO_FORMAT_OVERFLOW])
2645 AC_GCC_WARNING_SUBST_NO([use-after-free], [FLAG_W_NO_USE_AFTER_FREE])
2646 AC_GCC_WARNING_SUBST_NO([free-nonheap-object], [FLAG_W_NO_FREE_NONHEAP_OBJECT])
2647 AC_GCC_WARNING_SUBST_NO([fortify-source], [FLAG_W_NO_FORTIFY_SOURCE])
2648 AC_GCC_WARNING_SUBST_NO([builtin-memcpy-chk-size], [FLAG_W_NO_BUILTIN_MEMCPY_CHK_SIZE])
2649 AC_GCC_WARNING_SUBST_NO([incompatible-pointer-types-discards-qualifiers], [FLAG_W_NO_INCOMPATIBLE_POINTER_TYPES_DISCARDS_QUALIFIERS])
2650 AC_GCC_WARNING_SUBST_NO([suspicious-bzero], [FLAG_W_NO_SUSPICIOUS_BZERO])
2651 AC_GCC_WARNING_SUBST_NO([attributes], [FLAG_W_NO_ATTRIBUTES])
2653 AC_GCC_WARNING_SUBST_NO_VAL([alloc-size-larger-than], [1677216], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN])
2655 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2656 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2657 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2658 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2659 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2660 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2661 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2662 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2663 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2664 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2665 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2667 # Does this compiler support -Wformat-security ?
2668 # Special handling is needed, because certain GCC versions require -Wformat
2669 # being present if -Wformat-security is given. Otherwise a warning is issued.
2670 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2671 # And with that the warning will be turned into an error with the result
2672 # that -Wformat-security is believed to be unsupported when in fact it is.
2673 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2674 safe_CFLAGS=$CFLAGS
2675 CFLAGS="-Wformat -Wformat-security -Werror"
2676 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2677 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2678 AC_MSG_RESULT([yes])], [
2679 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2680 AC_MSG_RESULT([no])])
2681 CFLAGS=$safe_CFLAGS
2683 # does this compiler support -Wextra or the older -W ?
2685 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2687 safe_CFLAGS=$CFLAGS
2688 CFLAGS="-Wextra -Werror"
2690 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2691   return 0;
2692 ]])], [
2693 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2694 AC_MSG_RESULT([-Wextra])
2695 ], [
2696   CFLAGS="-W -Werror"
2697   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2698     return 0;
2699   ]])], [
2700   AC_SUBST([FLAG_W_EXTRA], [-W])
2701   AC_MSG_RESULT([-W])
2702   ], [
2703   AC_SUBST([FLAG_W_EXTRA], [])
2704   AC_MSG_RESULT([not supported])
2705   ])
2707 CFLAGS=$safe_CFLAGS
2709 # On ARM we do not want to pass -Wcast-align as that produces loads
2710 # of warnings. GCC is just being conservative. See here:
2711 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2712 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2713   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2714 else
2715   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2718 # does this compiler support -faligned-new ?
2719 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2721 safe_CXXFLAGS=$CXXFLAGS
2722 CXXFLAGS="-faligned-new -Werror"
2724 AC_LANG(C++)
2725 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2726   return 0;
2727 ]])], [
2728 FLAG_FALIGNED_NEW="-faligned-new"
2729 AC_MSG_RESULT([yes])
2730 ], [
2731 FLAG_FALIGNED_NEW=""
2732 AC_MSG_RESULT([no])
2734 CXXFLAGS=$safe_CXXFLAGS
2735 AC_LANG(C)
2737 AC_SUBST(FLAG_FALIGNED_NEW)
2739 # does this compiler support -fsized-deallocation ?
2740 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2742 safe_CXXFLAGS=$CXXFLAGS
2743 CXXFLAGS="-fsized-deallocation -Werror"
2745 AC_LANG(C++)
2746 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2747   return 0;
2748 ]])], [
2749 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2750 ac_have_sized_deallocation=yes
2751 AC_MSG_RESULT([yes])
2752 ], [
2753 FLAG_FSIZED_DEALLOCATION=""
2754 ac_have_sized_deallocation=no
2755 AC_MSG_RESULT([no])
2757 CXXFLAGS=$safe_CXXFLAGS
2758 AC_LANG(C)
2760 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2761 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2763 # does this compiler support C++17 aligned new/delete?
2764 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2766 safe_CXXFLAGS=$CXXFLAGS
2767 CXXFLAGS="-std=c++17"
2769 AC_LANG(C++)
2770 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2771 #include <cstdlib>
2772 #include <new>
2773 ]], [[
2774   operator delete(nullptr, std::align_val_t(64U));
2775 ]])], [
2776 ac_have_aligned_cxx_alloc=yes
2777 AC_MSG_RESULT([yes])
2778 ], [
2779 ac_have_aligned_cxx_alloc=no
2780 AC_MSG_RESULT([no])
2782 CXXFLAGS=$safe_CXXFLAGS
2783 AC_LANG(C)
2785 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2787 # does this compiler support -fno-stack-protector ?
2788 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2790 safe_CFLAGS=$CFLAGS
2791 CFLAGS="-fno-stack-protector -Werror"
2793 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2794   return 0;
2795 ]])], [
2796 no_stack_protector=yes
2797 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2798 AC_MSG_RESULT([yes])
2799 ], [
2800 no_stack_protector=no
2801 FLAG_FNO_STACK_PROTECTOR=""
2802 AC_MSG_RESULT([no])
2804 CFLAGS=$safe_CFLAGS
2806 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2808 # does this compiler support -finline-functions ?
2809 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2811 safe_CFLAGS=$CFLAGS
2812 CFLAGS="-finline-functions -Werror"
2814 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2815   return 0;
2816 ]])], [
2817 inline_functions=yes
2818 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2819 AC_MSG_RESULT([yes])
2820 ], [
2821 inline_functions=no
2822 FLAG_FINLINE_FUNCTIONS=""
2823 AC_MSG_RESULT([no])
2825 CFLAGS=$safe_CFLAGS
2827 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2829 # Does GCC support disabling Identical Code Folding?
2830 # We want to disabled Identical Code Folding for the
2831 # tools preload shared objects to get better backraces.
2832 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2833 # "The optimization reduces code size and may disturb
2834 #  unwind stacks by replacing a function by equivalent
2835 #  one with a different name."
2836 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2838 safe_CFLAGS=$CFLAGS
2839 CFLAGS="-fno-ipa-icf -Werror"
2841 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2842   return 0;
2843 ]])], [
2844 no_ipa_icf=yes
2845 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2846 AC_MSG_RESULT([yes])
2847 ], [
2848 no_ipa_icf=no
2849 FLAG_FNO_IPA_ICF=""
2850 AC_MSG_RESULT([no])
2852 CFLAGS=$safe_CFLAGS
2854 AC_SUBST(FLAG_FNO_IPA_ICF)
2857 # Does this compiler support -fsanitize=undefined. This is true for
2858 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2859 # also checks for alignment violations on memory accesses which the valgrind
2860 # code base is sprinkled (if not littered) with. As those alignment issues
2861 # don't pose a problem we want to suppress warnings about them.
2862 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2863 # GCCs do not support that.
2865 # Only checked for if --enable-ubsan was given.
2866 if test "x${vg_cv_ubsan}" = "xyes"; then
2867 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2868 safe_CFLAGS=$CFLAGS
2869 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2870 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2871   return 0;
2872 ]])], [
2873 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2874 LIB_UBSAN="-static-libubsan"
2875 AC_MSG_RESULT([yes])
2876 ], [
2877 CFLAGS="-fsanitize=undefined -Werror"
2878 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2879   return 0;
2880 ]])], [
2881 FLAG_FSANITIZE="-fsanitize=undefined"
2882 LIB_UBSAN="-static-libubsan"
2883 AC_MSG_RESULT([yes])
2884 ], [
2885 FLAG_FSANITIZE=""
2886 LIB_UBSAN=""
2887 AC_MSG_RESULT([no])
2890 CFLAGS=$safe_CFLAGS
2891 AC_SUBST(FLAG_FSANITIZE)
2892 AC_SUBST(LIB_UBSAN)
2894 # does this compiler support --param inline-unit-growth=... ?
2896 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2898 safe_CFLAGS=$CFLAGS
2899 CFLAGS="--param inline-unit-growth=900 -Werror"
2901 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2902   return 0;
2903 ]])], [
2904 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2905          ["--param inline-unit-growth=900"])
2906 AC_MSG_RESULT([yes])
2907 ], [
2908 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2909 AC_MSG_RESULT([no])
2911 CFLAGS=$safe_CFLAGS
2914 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2916 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2918 safe_CFLAGS=$CFLAGS
2919 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2921 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2922   return 0;
2923 ]])], [
2924 ac_have_dwarf4=yes
2925 AC_MSG_RESULT([yes])
2926 ], [
2927 ac_have_dwarf4=no
2928 AC_MSG_RESULT([no])
2930 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2931 CFLAGS=$safe_CFLAGS
2934 # does this compiler support -g -gz=zlib ?
2936 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2938 safe_CFLAGS=$CFLAGS
2939 CFLAGS="-g -gz=zlib"
2941 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2942   return 0;
2943 ]])], [
2944 ac_have_gz_zlib=yes
2945 AC_MSG_RESULT([yes])
2946 ], [
2947 ac_have_gz_zlib=no
2948 AC_MSG_RESULT([no])
2950 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2951 CFLAGS=$safe_CFLAGS
2954 # does this compiler support -g -gz=zlib-gnu ?
2956 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2958 safe_CFLAGS=$CFLAGS
2959 CFLAGS="-g -gz=zlib-gnu"
2961 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2962   return 0;
2963 ]])], [
2964 ac_have_gz_zlib_gnu=yes
2965 AC_MSG_RESULT([yes])
2966 ], [
2967 ac_have_gz_zlib_gnu=no
2968 AC_MSG_RESULT([no])
2970 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2971 CFLAGS=$safe_CFLAGS
2974 # does this compiler support nested functions ?
2976 AC_MSG_CHECKING([if gcc accepts nested functions])
2978 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2979   int foo() { return 1; }
2980   return foo();
2981 ]])], [
2982 ac_have_nested_functions=yes
2983 AC_MSG_RESULT([yes])
2984 ], [
2985 ac_have_nested_functions=no
2986 AC_MSG_RESULT([no])
2988 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2991 # does this compiler support the 'p' constraint in ASM statements ?
2993 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2995 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2996    char *p;
2997    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2998 ]])], [
2999 ac_have_asm_constraint_p=yes
3000 AC_MSG_RESULT([yes])
3001 ], [
3002 ac_have_asm_constraint_p=no
3003 AC_MSG_RESULT([no])
3005 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
3008 # Does this compiler and linker support -pie?
3009 # Some compilers actually do not support -pie and report its usage
3010 # as an error. We need to check if it is safe to use it first.
3012 AC_MSG_CHECKING([if gcc accepts -pie])
3014 safe_CFLAGS=$CFLAGS
3015 CFLAGS="-pie"
3017 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
3018   return 0;
3019 ]])], [
3020 AC_SUBST([FLAG_PIE], ["-pie"])
3021 AC_MSG_RESULT([yes])
3022 ], [
3023 AC_SUBST([FLAG_PIE], [""])
3024 AC_MSG_RESULT([no])
3026 CFLAGS=$safe_CFLAGS
3028 AC_MSG_CHECKING([if gcc accepts -ansi])
3030 safe_CFLAGS=$CFLAGS
3031 CFLAGS="-ansi"
3033 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3034    return 0;
3035 ]])], [
3036 ac_have_ansi=yes
3037 AC_MSG_RESULT([yes])
3038 ], [
3039 ac_have_ansi=no
3040 AC_MSG_RESULT([no])
3042 AM_CONDITIONAL([HAVE_ANSI], [test x$ac_have_ansi = xyes])
3044 CFLAGS=$safe_CFLAGS
3047 # Does this compiler support -no-pie?
3048 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
3049 # default. However this gets in the way with some tests, we use -no-pie
3050 # for these.
3052 AC_MSG_CHECKING([if gcc accepts -no-pie])
3054 safe_CFLAGS=$CFLAGS
3055 CFLAGS="-no-pie -Werror"
3057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
3058   return 0;
3059 ]])], [
3060 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
3061 AC_MSG_RESULT([yes])
3062 ], [
3063 AC_SUBST([FLAG_NO_PIE], [""])
3064 AC_MSG_RESULT([no])
3066 CFLAGS=$safe_CFLAGS
3069 # We want to use use the -Ttext-segment option to the linker.
3070 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
3071 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
3072 # semantics are NOT what we want (GNU gold -Ttext is fine).
3074 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
3075 # will reside. -Ttext aligns just the .text section start (but not any
3076 # other section).
3078 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
3079 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
3080 # The --image-base option (since version 6.0?) provides the semantics needed.
3081 # -Ttext-segment generates an error, but -Ttext now more closely
3082 # follows the GNU (bfd) ld's -Ttext.
3084 # So test first for --image-base support, and if that fails then
3085 # for -Ttext-segment which is supported by all bfd ld versions
3086 # and use that if it exists. If it doesn't exist it must be an older
3087 # version of gold and we can fall back to using -Ttext which has the
3088 # right semantics.
3090 safe_CFLAGS=$CFLAGS
3091 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
3093 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
3095 AC_LINK_IFELSE(
3096 [AC_LANG_SOURCE([int _start () { return 0; }])],
3098   linker_using_t_text="no"
3099   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
3100   AC_MSG_RESULT([yes])
3101 ], [
3102   AC_MSG_RESULT([no])
3104   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
3106   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
3108   AC_LINK_IFELSE(
3109   [AC_LANG_SOURCE([int _start () { return 0; }])],
3110   [
3111     linker_using_t_text="no"
3112     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
3113     AC_MSG_RESULT([yes])
3114   ], [
3115     linker_using_t_text="yes"
3116     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
3117     AC_MSG_RESULT([no])
3118   ])
3121 CFLAGS=$safe_CFLAGS
3123 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
3124 # have to strip any build-id ELF NOTEs from the statically linked tools.
3125 # Otherwise the build-id NOTE might end up at the default load address.
3126 # (Pedantically if the linker is gold then -Ttext is fine, but newer
3127 # gold versions also support -Ttext-segment. So just assume that unless
3128 # we can use -Ttext-segment we need to strip the build-id NOTEs.
3129 if test "x${linker_using_t_text}" = "xyes"; then
3130 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
3131 # does the linker support -Wl,--build-id=none ?  Note, it's
3132 # important that we test indirectly via whichever C compiler
3133 # is selected, rather than testing /usr/bin/ld or whatever
3134 # directly.
3135 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
3136 safe_CFLAGS=$CFLAGS
3137 CFLAGS="-Wl,--build-id=none -Werror"
3139 AC_LINK_IFELSE(
3140 [AC_LANG_PROGRAM([ ], [return 0;])],
3142   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
3143   AC_MSG_RESULT([yes])
3144 ], [
3145   AC_SUBST([FLAG_NO_BUILD_ID], [""])
3146   AC_MSG_RESULT([no])
3148 else
3149 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
3150 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3152 CFLAGS=$safe_CFLAGS
3154 # On s390x, if the linker supports -Wl,--s390-pgste, then we build the
3155 # tools with that flag.  This enables running programs that need it, such
3156 # as qemu-kvm.
3157 if test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX; then
3158 AC_MSG_CHECKING([if the linker accepts -Wl,--s390-pgste])
3159 safe_CFLAGS=$CFLAGS
3160 CFLAGS="-Wl,--s390-pgste"
3162 AC_LINK_IFELSE(
3163 [AC_LANG_PROGRAM([ ], [return 0;])],
3165   AC_SUBST([FLAG_S390_PGSTE], ["-Wl,--s390-pgste"])
3166   AC_MSG_RESULT([yes])
3167 ], [
3168   AC_SUBST([FLAG_S390_PGSTE], [""])
3169   AC_MSG_RESULT([no])
3171 CFLAGS=$safe_CFLAGS
3174 # does the ppc assembler support "mtocrf" et al?
3175 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
3177 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3178 __asm__ __volatile__("mtocrf 4,0");
3179 __asm__ __volatile__("mfocrf 0,4");
3180 ]])], [
3181 ac_have_as_ppc_mftocrf=yes
3182 AC_MSG_RESULT([yes])
3183 ], [
3184 ac_have_as_ppc_mftocrf=no
3185 AC_MSG_RESULT([no])
3187 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3188   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3192 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3193 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3195 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3196   do { typedef struct {
3197       double hi;
3198       double lo;
3199      } dbl_pair_t;
3200      dbl_pair_t dbl_pair[3];
3201      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3202    } while (0)
3203 ]])], [
3204 ac_have_as_ppc_fpPO=yes
3205 AC_MSG_RESULT([yes])
3206 ], [
3207 ac_have_as_ppc_fpPO=no
3208 AC_MSG_RESULT([no])
3210 if test x$ac_have_as_ppc_fpPO = xyes ; then
3211   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3215 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3216 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3218 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3219 void* p;
3220 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3221 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3222 ]])], [
3223 ac_have_as_amd64_fxsave64=yes
3224 AC_MSG_RESULT([yes])
3225 ], [
3226 ac_have_as_amd64_fxsave64=no
3227 AC_MSG_RESULT([no])
3229 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3230   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3233 # does the x86/amd64 assembler understand SSE3 instructions?
3234 # Note, this doesn't generate a C-level symbol.  It generates a
3235 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3236 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3238 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3239   do { long long int x; 
3240      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
3241   while (0)
3242 ]])], [
3243 ac_have_as_sse3=yes
3244 AC_MSG_RESULT([yes])
3245 ], [
3246 ac_have_as_sse3=no
3247 AC_MSG_RESULT([no])
3250 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3253 # Ditto for SSSE3 instructions (note extra S)
3254 # Note, this doesn't generate a C-level symbol.  It generates a
3255 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3256 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3258 save_CFLAGS="$CFLAGS"
3259 CFLAGS="$CFLAGS -msse -Werror"
3260 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3261   do { long long int x; 
3262    __asm__ __volatile__(
3263       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3264   while (0)
3265 ]])], [
3266 ac_have_as_ssse3=yes
3267 AC_MSG_RESULT([yes])
3268 ], [
3269 ac_have_as_ssse3=no
3270 AC_MSG_RESULT([no])
3272 CFLAGS="$save_CFLAGS"
3274 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3277 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3278 # Note, this doesn't generate a C-level symbol.  It generates a
3279 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3280 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3281 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3282   do {
3283    __asm__ __volatile__(
3284       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3285   while (0)
3286 ]])], [
3287 ac_have_as_pclmulqdq=yes
3288 AC_MSG_RESULT([yes])
3289 ], [
3290 ac_have_as_pclmulqdq=no
3291 AC_MSG_RESULT([no])
3294 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3297 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3298 # Note, this doesn't generate a C-level symbol.  It generates a
3299 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3300 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3301 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3302   do {
3303       /*
3304        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3305        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3306        * xmm2 should be used.
3307        */
3308    __asm__ __volatile__(
3309       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3310   } while (0)
3311 ]])], [
3312 ac_have_as_vpclmulqdq=yes
3313 AC_MSG_RESULT([yes])
3314 ], [
3315 ac_have_as_vpclmulqdq=no
3316 AC_MSG_RESULT([no])
3319 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3322 # does the x86/amd64 assembler understand FMA4 instructions?
3323 # Note, this doesn't generate a C-level symbol.  It generates a
3324 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3325 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3326 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3327   do {
3328    __asm__ __volatile__(
3329       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3330   } while (0)
3331 ]])], [
3332 ac_have_as_vfmaddpd=yes
3333 AC_MSG_RESULT([yes])
3334 ], [
3335 ac_have_as_vfmaddpd=no
3336 AC_MSG_RESULT([no])
3339 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3342 # does the x86/amd64 assembler understand the LZCNT instruction?
3343 # Note, this doesn't generate a C-level symbol.  It generates a
3344 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3345 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3347 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3348   do {           
3349       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3350   } while (0)
3351 ]])], [
3352   ac_have_as_lzcnt=yes
3353   AC_MSG_RESULT([yes])
3354 ], [
3355   ac_have_as_lzcnt=no
3356   AC_MSG_RESULT([no])
3359 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3362 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3363 # Note, this doesn't generate a C-level symbol.  It generates a
3364 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3365 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3367 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3368   do {           
3369       __asm__ __volatile__("1:  loopnel 1b\n");
3370   } while (0)
3371 ]])], [
3372   ac_have_as_loopnel=yes
3373   AC_MSG_RESULT([yes])
3374 ], [
3375   ac_have_as_loopnel=no
3376   AC_MSG_RESULT([no])
3379 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3382 # does the x86/amd64 assembler understand ADDR32 ?
3383 # Note, this doesn't generate a C-level symbol.  It generates a
3384 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3385 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3387 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3388   do {           
3389       asm volatile ("addr32 rep movsb");
3390   } while (0)
3391 ]])], [
3392   ac_have_as_addr32=yes
3393   AC_MSG_RESULT([yes])
3394 ], [
3395   ac_have_as_addr32=no
3396   AC_MSG_RESULT([no])
3399 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3402 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3403 # Note, this doesn't generate a C-level symbol.  It generates a
3404 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3405 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3407 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3408   do { long long int x; 
3409    __asm__ __volatile__(
3410       "crc32q %%r15,%%r15" : : : "r15" );
3411    __asm__ __volatile__(
3412       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3413    __asm__ __volatile__(
3414       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3415   while (0)
3416 ]])], [
3417 ac_have_as_sse42=yes
3418 AC_MSG_RESULT([yes])
3419 ], [
3420 ac_have_as_sse42=no
3421 AC_MSG_RESULT([no])
3424 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3427 # does the x86/amd64 assembler understand AVX instructions?
3428 # Note, this doesn't generate a C-level symbol.  It generates a
3429 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3430 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3432 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3433   do { long long int x; 
3434    __asm__ __volatile__(
3435       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3436    __asm__ __volatile__(
3437       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3438   while (0)
3439 ]])], [
3440 ac_have_as_avx=yes
3441 AC_MSG_RESULT([yes])
3442 ], [
3443 ac_have_as_avx=no
3444 AC_MSG_RESULT([no])
3447 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3450 # does the x86/amd64 assembler understand AVX2 instructions?
3451 # Note, this doesn't generate a C-level symbol.  It generates a
3452 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3453 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3455 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3456   do { long long int x; 
3457    __asm__ __volatile__(
3458       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3459    __asm__ __volatile__(
3460       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3461   while (0)
3462 ]])], [
3463 ac_have_as_avx2=yes
3464 AC_MSG_RESULT([yes])
3465 ], [
3466 ac_have_as_avx2=no
3467 AC_MSG_RESULT([no])
3470 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3473 # does the x86/amd64 assembler understand TSX instructions and
3474 # the XACQUIRE/XRELEASE prefixes?
3475 # Note, this doesn't generate a C-level symbol.  It generates a
3476 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3477 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3479 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3480   do {
3481    __asm__ __volatile__(
3482       "       xbegin Lfoo  \n\t"
3483       "Lfoo:  xend         \n\t"
3484       "       xacquire lock incq 0(%rsp)     \n\t"
3485       "       xrelease lock incq 0(%rsp)     \n"
3486    );
3487   } while (0)
3488 ]])], [
3489 ac_have_as_tsx=yes
3490 AC_MSG_RESULT([yes])
3491 ], [
3492 ac_have_as_tsx=no
3493 AC_MSG_RESULT([no])
3496 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3499 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3500 # Note, this doesn't generate a C-level symbol.  It generates a
3501 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3502 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3504 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3505   do { unsigned int h, l;
3506    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3507    __asm__ __volatile__(
3508       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3509    __asm__ __volatile__(
3510       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3511   while (0)
3512 ]])], [
3513 ac_have_as_bmi=yes
3514 AC_MSG_RESULT([yes])
3515 ], [
3516 ac_have_as_bmi=no
3517 AC_MSG_RESULT([no])
3520 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3523 # does the x86/amd64 assembler understand FMA instructions?
3524 # Note, this doesn't generate a C-level symbol.  It generates a
3525 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3526 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3528 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3529   do { unsigned int h, l;
3530    __asm__ __volatile__(
3531       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3532    __asm__ __volatile__(
3533       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3534    __asm__ __volatile__(
3535       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3536   while (0)
3537 ]])], [
3538 ac_have_as_fma=yes
3539 AC_MSG_RESULT([yes])
3540 ], [
3541 ac_have_as_fma=no
3542 AC_MSG_RESULT([no])
3545 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3548 # does the amd64 assembler understand MPX instructions?
3549 # Note, this doesn't generate a C-level symbol.  It generates a
3550 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3551 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3553 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3554   do {
3555     asm ("bndmov %bnd0,(%rsp)");
3556     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3557     asm ("bnd call foo\n"
3558          "bnd jmp  end\n"
3559          "foo: bnd ret\n"
3560          "end: nop");
3561   } while (0)
3562 ]])], [
3563 ac_have_as_mpx=yes
3564 AC_MSG_RESULT([yes])
3565 ], [
3566 ac_have_as_mpx=no
3567 AC_MSG_RESULT([no])
3570 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3573 # does the amd64 assembler understand ADX instructions?
3574 # Note, this doesn't generate a C-level symbol.  It generates a
3575 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3576 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3578 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3579   do {
3580     asm ("adcxq %r14,%r8");
3581   } while (0)
3582 ]])], [
3583 ac_have_as_adx=yes
3584 AC_MSG_RESULT([yes])
3585 ], [
3586 ac_have_as_adx=no
3587 AC_MSG_RESULT([no])
3590 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3593 # does the amd64 assembler understand the RDRAND instruction?
3594 # Note, this doesn't generate a C-level symbol.  It generates a
3595 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3596 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3598 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3599   do {
3600     asm ("rdrand %r14");
3601     asm ("rdrand %r14d");
3602     asm ("rdrand %r14w");
3603   } while (0)
3604 ]])], [
3605 ac_have_as_rdrand=yes
3606 AC_MSG_RESULT([yes])
3607 ], [
3608 ac_have_as_rdrand=no
3609 AC_MSG_RESULT([no])
3612 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3614 # does the amd64 assembler understand the RDSEED instruction?
3615 # Note, this doesn't generate a C-level symbol.  It generates a
3616 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3617 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3619 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3620   do {
3621     asm ("rdseed %r14");
3622     asm ("rdseed %r14d");
3623     asm ("rdseed %r14w");
3624   } while (0)
3625 ]])], [
3626 ac_have_as_rdseed=yes
3627 AC_MSG_RESULT([yes])
3628 ], [
3629 ac_have_as_rdseed=no
3630 AC_MSG_RESULT([no])
3633 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3635 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3636 # VCVTPS2PH) ?
3637 # Note, this doesn't generate a C-level symbol.  It generates a
3638 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3639 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3641 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3642   do {
3643     asm ("vcvtph2ps %xmm5, %ymm10");
3644     // If we put the dollar sign and zero together, the shell processing
3645     // this configure.ac script substitutes the command name in.  Sigh.
3646     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3647   } while (0)
3648 ]])], [
3649 ac_have_as_f16c=yes
3650 AC_MSG_RESULT([yes])
3651 ], [
3652 ac_have_as_f16c=no
3653 AC_MSG_RESULT([no])
3656 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3659 # does the x86/amd64 assembler understand MOVBE?
3660 # Note, this doesn't generate a C-level symbol.  It generates a
3661 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3662 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3664 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3665   do { long long int x; 
3666    __asm__ __volatile__(
3667       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3668   while (0)
3669 ]])], [
3670 ac_have_as_movbe=yes
3671 AC_MSG_RESULT([yes])
3672 ], [
3673 ac_have_as_movbe=no
3674 AC_MSG_RESULT([no])
3677 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3680 # Does the C compiler support the "ifunc" attribute
3681 # Note, this doesn't generate a C-level symbol.  It generates a
3682 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3683 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3685 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3686 static void mytest(void) {}
3688 static void (*resolve_test(void))(void)
3690     return (void (*)(void))&mytest;
3693 void test(void) __attribute__((ifunc("resolve_test")));
3695 int main()
3697     test();
3698     return 0;
3700 ]])], [
3701 ac_have_ifunc_attr=yes
3702 AC_MSG_RESULT([yes])
3703 ], [
3704 ac_have_ifunc_attr=no
3705 AC_MSG_RESULT([no])
3708 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3710 # Does the C compiler support the armv8 crc feature flag
3711 # Note, this doesn't generate a C-level symbol.  It generates a
3712 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3713 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3715 save_CFLAGS="$CFLAGS"
3716 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3717 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3718 int main()
3720     return 0;
3722 ]])], [
3723 ac_have_armv8_crc_feature=yes
3724 AC_MSG_RESULT([yes])
3725 ], [
3726 ac_have_armv8_crc_feature=no
3727 AC_MSG_RESULT([no])
3729 CFLAGS="$save_CFLAGS"
3731 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3734 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3735 # Note, this doesn't generate a C-level symbol.  It generates a
3736 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3737 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3739 save_CFLAGS="$CFLAGS"
3740 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3741 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3742 int main()
3744     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3745     return 0;
3747 ]])], [
3748 ac_have_armv81_feature=yes
3749 AC_MSG_RESULT([yes])
3750 ], [
3751 ac_have_armv81_feature=no
3752 AC_MSG_RESULT([no])
3754 CFLAGS="$save_CFLAGS"
3756 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3759 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3760 # Note, this doesn't generate a C-level symbol.  It generates a
3761 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3762 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3764 save_CFLAGS="$CFLAGS"
3765 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3766 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3767 int main()
3769     __asm__ __volatile__("faddp h0, v1.2h");
3770     return 0;
3772 ]])], [
3773 ac_have_armv82_feature=yes
3774 AC_MSG_RESULT([yes])
3775 ], [
3776 ac_have_armv82_feature=no
3777 AC_MSG_RESULT([no])
3779 CFLAGS="$save_CFLAGS"
3781 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3784 # Does the C compiler support the armv82-a+dotprod flag and assembler dotprod instructions
3785 # Note, this doesn't generate a C-level symbol.  It generates a
3786 # automake-level symbol (BUILD_ARMV82_DOTPROD_TESTS), used in test Makefile.am's
3787 AC_MSG_CHECKING([if gcc supports the armv82-a+dotprod feature flag and assembler supports dotprod instructions])
3789 save_CFLAGS="$CFLAGS"
3790 CFLAGS="$CFLAGS -march=armv8.2-a+dotprod -Werror"
3791 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3792 int main()
3794     __asm__ __volatile__("sdot v1.4s, v2.16b, v3.16b");
3795     return 0;
3797 ]])], [
3798 ac_have_armv82_dotprod_feature=yes
3799 AC_MSG_RESULT([yes])
3800 ], [
3801 ac_have_armv82_dotprod_feature=no
3802 AC_MSG_RESULT([no])
3804 CFLAGS="$save_CFLAGS"
3806 AM_CONDITIONAL(BUILD_ARMV82_DOTPROD_TESTS, test x$ac_have_armv82_dotprod_feature = xyes)
3809 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3810 # when building the tool executables.  I think we should get rid of it.
3812 # Check for TLS support in the compiler and linker
3813 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3814                                 [[return foo;]])],
3815                                [vg_cv_linktime_tls=yes],
3816                                [vg_cv_linktime_tls=no])
3817 # Native compilation: check whether running a program using TLS succeeds.
3818 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3819 # succeeds but running programs using TLS fails.
3820 # Cross-compiling: check whether linking a program using TLS succeeds.
3821 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3822                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3823                 [vg_cv_tls=$enableval],
3824                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3825                                                 [[return foo;]])],
3826                                [vg_cv_tls=yes],
3827                                [vg_cv_tls=no],
3828                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3830 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3831 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3835 #----------------------------------------------------------------------------
3836 # Solaris-specific checks.
3837 #----------------------------------------------------------------------------
3839 if test "$VGCONF_OS" = "solaris" ; then
3840 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3842 # Solaris-specific check determining if the Sun Studio Assembler is used to
3843 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3844 # cmovl.l instruction, if yes then it's Sun Assembler.
3846 # C-level symbol: none
3847 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3849 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3850 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3851 ]], [[
3852   __asm__ __volatile__("cmovl.l %edx, %eax");
3853 ]])], [
3854 solaris_have_sun_studio_as=yes
3855 AC_MSG_RESULT([yes])
3856 ], [
3857 solaris_have_sun_studio_as=no
3858 AC_MSG_RESULT([no])
3860 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3862 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3863 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3864 # See solaris/vgpreload-solaris.mapfile for details.
3865 # gcc on older Solaris instructs linker to include these symbols,
3866 # gcc on illumos and newer Solaris does not.
3868 # C-level symbol: none
3869 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3871 save_CFLAGS="$CFLAGS"
3872 CFLAGS="$CFLAGS -std=gnu99"
3873 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3874 temp_dir=$( /usr/bin/mktemp -d )
3875 cat <<_ACEOF >${temp_dir}/mylib.c
3876 #include <stdio.h>
3877 int myfunc(void) { printf("LaPutyka\n"); }
3878 _ACEOF
3879 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3880 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3881 if test "x${xpg_present}" = "x" ; then
3882     solaris_xpg_symbols_present=no
3883     AC_MSG_RESULT([no])
3884 else
3885     solaris_xpg_symbols_present=yes
3886     AC_MSG_RESULT([yes])
3888 rm -rf ${temp_dir}
3889 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3890 CFLAGS="$save_CFLAGS"
3893 # Solaris-specific check determining if gcc enables largefile support by
3894 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3895 # variable with gcc flags which disable it.
3897 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3898 save_CFLAGS="$CFLAGS"
3899 CFLAGS="$CFLAGS -m32"
3900 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3901   return _LARGEFILE_SOURCE;
3902 ]])], [
3903 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3904 AC_MSG_RESULT([yes])
3905 ], [
3906 SOLARIS_UNDEF_LARGESOURCE=""
3907 AC_MSG_RESULT([no])
3909 CFLAGS=$safe_CFLAGS
3910 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3913 # Solaris-specific check determining if /proc/self/cmdline
3914 # or /proc/<pid>/cmdline is supported.
3916 # C-level symbol: SOLARIS_PROC_CMDLINE
3917 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3919 AC_CHECK_FILE([/proc/self/cmdline],
3921 solaris_proc_cmdline=yes
3922 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3923           [Define to 1 if you have /proc/self/cmdline.])
3924 ], [
3925 solaris_proc_cmdline=no
3927 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3930 # Solaris-specific check determining default platform for the Valgrind launcher.
3931 # Used in case the launcher cannot select platform by looking at the client
3932 # image (for example because the executable is a shell script).
3934 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3935 # Automake-level symbol: none
3937 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3938 # Get the ELF class of /bin/sh first.
3939 if ! test -f /bin/sh; then
3940   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3942 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3943 case "$elf_class" in
3944   64)
3945     default_arch="$VGCONF_ARCH_PRI";
3946     ;;
3947   32)
3948     if test "x$VGCONF_ARCH_SEC" != "x"; then
3949       default_arch="$VGCONF_ARCH_SEC"
3950     else
3951       default_arch="$VGCONF_ARCH_PRI";
3952     fi
3953     ;;
3954   *)
3955     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3956     ;;
3957 esac
3958 default_platform="$default_arch-$VGCONF_OS"
3959 AC_MSG_RESULT([$default_platform])
3960 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3961                    [Default platform for Valgrind launcher.])
3964 # Solaris-specific check determining if the old syscalls are available.
3966 # C-level symbol: SOLARIS_OLD_SYSCALLS
3967 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3969 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3970 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3971 #include <sys/syscall.h>
3972 ]], [[
3973   return !SYS_open;
3974 ]])], [
3975 solaris_old_syscalls=yes
3976 AC_MSG_RESULT([yes])
3977 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3978           [Define to 1 if you have the old Solaris syscalls.])
3979 ], [
3980 solaris_old_syscalls=no
3981 AC_MSG_RESULT([no])
3983 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3986 # Solaris-specific check determining if the new accept() syscall is available.
3988 # Old syscall:
3989 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3990 #            int version);
3992 # New syscall (available on illumos):
3993 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3994 #            int version, int flags);
3996 # If the old syscall is present then the following syscall will fail with
3997 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3998 # available then it will fail with EINVAL (because the flags parameter is
3999 # invalid).
4001 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
4002 # Automake-level symbol: none
4004 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
4005 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4006 #include <sys/syscall.h>
4007 #include <errno.h>
4008 ]], [[
4009   errno = 0;
4010   syscall(SYS_accept, 0, 0, 0, 0, -1);
4011   return !(errno == EINVAL);
4012 ]])], [
4013 AC_MSG_RESULT([yes])
4014 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
4015           [Define to 1 if you have the new `accept' syscall.])
4016 ], [
4017 AC_MSG_RESULT([no])
4021 # Solaris-specific check determining if the new illumos pipe() syscall is
4022 # available.
4024 # Old syscall:
4025 # longlong_t pipe();
4027 # New syscall (available on illumos):
4028 # int pipe(intptr_t arg, int flags);
4030 # If the old syscall is present then the following call will succeed, if the
4031 # new syscall is available then it will fail with EFAULT (because address 0
4032 # cannot be accessed).
4034 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
4035 # Automake-level symbol: none
4037 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
4038 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4039 #include <sys/syscall.h>
4040 #include <errno.h>
4041 ]], [[
4042   errno = 0;
4043   syscall(SYS_pipe, 0, 0);
4044   return !(errno == EFAULT);
4045 ]])], [
4046 AC_MSG_RESULT([yes])
4047 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
4048           [Define to 1 if you have the new `pipe' syscall.])
4049 ], [
4050 AC_MSG_RESULT([no])
4054 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
4055 # available.
4057 # Old syscall:
4058 # int lwp_kill(id_t lwpid, int sig);
4060 # New syscall (available on Solaris 11):
4061 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
4062 #                  int si_code, timespec_t *timeout);
4064 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
4065 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
4067 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
4068 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4069 #include <sys/syscall.h> 
4070 ]], [[
4071   return !SYS_lwp_sigqueue;
4072 ]])], [
4073 solaris_lwp_sigqueue_syscall=yes
4074 AC_MSG_RESULT([yes])
4075 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
4076           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
4077 ], [
4078 solaris_lwp_sigqueue_syscall=no
4079 AC_MSG_RESULT([no])
4081 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
4084 # Solaris-specific check determining if the lwp_sigqueue() syscall
4085 # takes both pid and thread id arguments or just thread id.
4087 # Old syscall (available up to Solaris 11.3):
4088 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
4089 #                  int si_code, timespec_t *timeout);
4091 # New syscall (available since Solaris 11.4):
4092 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
4093 #                  int si_code, timespec_t *timeout);
4095 # If the old syscall is present then the following syscall will fail with
4096 # EINVAL (because signal is out of range); if the new syscall is available
4097 # then it will fail with ESRCH (because it would not find such thread in the
4098 # current process).
4100 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
4101 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
4103 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
4104 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
4105 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4106 #include <sys/syscall.h>
4107 #include <errno.h>
4108 ]], [[
4109   errno = 0;
4110   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
4111   return !(errno == ESRCH);
4112 ]])], [
4113 solaris_lwp_sigqueue_syscall_takes_pid=yes
4114 AC_MSG_RESULT([yes])
4115 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
4116           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
4117 ], [
4118 solaris_lwp_sigqueue_syscall_takes_pid=no
4119 AC_MSG_RESULT([no])
4121 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
4122                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
4124 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
4128 # Solaris-specific check determining if the new lwp_name() syscall is
4129 # available.
4131 # New syscall (available on Solaris 11):
4132 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
4134 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
4135 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
4137 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
4138 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4139 #include <sys/syscall.h>
4140 ]], [[
4141   return !SYS_lwp_name;
4142 ]])], [
4143 solaris_lwp_name_syscall=yes
4144 AC_MSG_RESULT([yes])
4145 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
4146           [Define to 1 if you have the new `lwp_name' syscall.])
4147 ], [
4148 solaris_lwp_name_syscall=no
4149 AC_MSG_RESULT([no])
4151 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
4154 # Solaris-specific check determining if the new getrandom() syscall is
4155 # available.
4157 # New syscall (available on Solaris 11):
4158 # int getrandom(void *buf, size_t buflen, uint_t flags);
4160 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
4161 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
4163 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
4164 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4165 #include <sys/syscall.h>
4166 ]], [[
4167   return !SYS_getrandom;
4168 ]])], [
4169 solaris_getrandom_syscall=yes
4170 AC_MSG_RESULT([yes])
4171 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
4172           [Define to 1 if you have the new `getrandom' syscall.])
4173 ], [
4174 solaris_getrandom_syscall=no
4175 AC_MSG_RESULT([no])
4177 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
4180 # Solaris-specific check determining if the new zone() syscall subcodes
4181 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
4182 # were added in Solaris 11 but are missing on illumos.
4184 # C-level symbol: SOLARIS_ZONE_DEFUNCT
4185 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
4187 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
4188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4189 #include <sys/zone.h>
4190 ]], [[
4191   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
4192 ]])], [
4193 solaris_zone_defunct=yes
4194 AC_MSG_RESULT([yes])
4195 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
4196           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
4197 ], [
4198 solaris_zone_defunct=no
4199 AC_MSG_RESULT([no])
4201 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
4204 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4205 # for auditon(2) subcode of the auditsys() syscall are available.
4206 # These commands are available in Solaris 11 and illumos but were removed
4207 # in Solaris 11.4.
4209 # C-level symbol: SOLARIS_AUDITON_STAT
4210 # Automake-level symbol: SOLARIS_AUDITON_STAT
4212 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4213 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4214 #include <bsm/audit.h>
4215 ]], [[
4216   return !(A_GETSTAT && A_SETSTAT);
4217 ]])], [
4218 solaris_auditon_stat=yes
4219 AC_MSG_RESULT([yes])
4220 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4221           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4222 ], [
4223 solaris_auditon_stat=no
4224 AC_MSG_RESULT([no])
4226 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4229 # Solaris-specific check determining if the new shmsys() syscall subcodes
4230 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4231 # These subcodes were added in Solaris 11 but are missing on illumos.
4233 # C-level symbol: SOLARIS_SHM_NEW
4234 # Automake-level symbol: SOLARIS_SHM_NEW
4236 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4237 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4238 #include <sys/ipc_impl.h>
4239 #include <sys/shm.h>
4240 #include <sys/shm_impl.h>
4241 ]], [[
4242   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4243 ]])], [
4244 solaris_shm_new=yes
4245 AC_MSG_RESULT([yes])
4246 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4247           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4248 ], [
4249 solaris_shm_new=no
4250 AC_MSG_RESULT([no])
4252 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4255 # Solaris-specific check determining if prxregset_t is available.  Illumos
4256 # currently does not define it on the x86 platform.
4258 # C-level symbol: SOLARIS_PRXREGSET_T
4259 # Automake-level symbol: SOLARIS_PRXREGSET_T
4261 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4262 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4263 #include <sys/procfs_isa.h>
4264 ]], [[
4265   return !sizeof(prxregset_t);
4266 ]])], [
4267 solaris_prxregset_t=yes
4268 AC_MSG_RESULT([yes])
4269 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4270           [Define to 1 if you have the `prxregset_t' type.])
4271 ], [
4272 solaris_prxregset_t=no
4273 AC_MSG_RESULT([no])
4275 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4278 # Solaris-specific check determining if the new frealpathat() syscall is
4279 # available.
4281 # New syscall (available on Solaris 11.1):
4282 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4284 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4285 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4287 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4288 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4289 #include <sys/syscall.h>
4290 ]], [[
4291   return !SYS_frealpathat;
4292 ]])], [
4293 solaris_frealpathat_syscall=yes
4294 AC_MSG_RESULT([yes])
4295 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4296           [Define to 1 if you have the new `frealpathat' syscall.])
4297 ], [
4298 solaris_frealpathat_syscall=no
4299 AC_MSG_RESULT([no])
4301 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4304 # Solaris-specific check determining if the new uuidsys() syscall is
4305 # available.
4307 # New syscall (available on newer Solaris):
4308 # int uuidsys(struct uuid *uuid);
4310 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4311 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4313 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4314 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4315 #include <sys/syscall.h>
4316 ]], [[
4317   return !SYS_uuidsys;
4318 ]])], [
4319 solaris_uuidsys_syscall=yes
4320 AC_MSG_RESULT([yes])
4321 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4322           [Define to 1 if you have the new `uuidsys' syscall.])
4323 ], [
4324 solaris_uuidsys_syscall=no
4325 AC_MSG_RESULT([no])
4327 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4330 # Solaris-specific check determining if the new labelsys() syscall subcode
4331 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4332 # missing on illumos.
4334 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4335 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4337 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4338 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4339 #include <sys/tsol/tndb.h>
4340 ]], [[
4341   return !TNDB_GET_TNIP;
4342 ]])], [
4343 solaris_tndb_get_tnip=yes
4344 AC_MSG_RESULT([yes])
4345 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4346           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4347 ], [
4348 solaris_tndb_get_tnip=no
4349 AC_MSG_RESULT([no])
4351 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4354 # Solaris-specific check determining if the new labelsys() syscall opcodes
4355 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4356 # added in Solaris 11 but are missing on illumos.
4358 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4359 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4361 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4363 #include <sys/tsol/tsyscall.h>
4364 ]], [[
4365   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4366 ]])], [
4367 solaris_tsol_clearance=yes
4368 AC_MSG_RESULT([yes])
4369 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4370           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4371 ], [
4372 solaris_tsol_clearance=no
4373 AC_MSG_RESULT([no])
4375 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4378 # Solaris-specific check determining if the new pset() syscall subcode
4379 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4380 # is missing on illumos and Solaris 11.3.
4382 # C-level symbol: SOLARIS_PSET_GET_NAME
4383 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4385 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4386 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4387 #include <sys/pset.h>
4388 ]], [[
4389   return !(PSET_GET_NAME);
4390 ]])], [
4391 solaris_pset_get_name=yes
4392 AC_MSG_RESULT([yes])
4393 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4394           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4395 ], [
4396 solaris_pset_get_name=no
4397 AC_MSG_RESULT([no])
4399 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4402 # Solaris-specific check determining if the utimesys() syscall is
4403 # available (on illumos and older Solaris).
4405 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4406 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4408 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4409 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4410 #include <sys/syscall.h>
4411 ]], [[
4412   return !SYS_utimesys;
4413 ]])], [
4414 solaris_utimesys_syscall=yes
4415 AC_MSG_RESULT([yes])
4416 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4417           [Define to 1 if you have the `utimesys' syscall.])
4418 ], [
4419 solaris_utimesys_syscall=no
4420 AC_MSG_RESULT([no])
4422 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4425 # Solaris-specific check determining if the utimensat() syscall is
4426 # available (on newer Solaris).
4428 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4429 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4431 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4432 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4433 #include <sys/syscall.h>
4434 ]], [[
4435   return !SYS_utimensat;
4436 ]])], [
4437 solaris_utimensat_syscall=yes
4438 AC_MSG_RESULT([yes])
4439 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4440           [Define to 1 if you have the `utimensat' syscall.])
4441 ], [
4442 solaris_utimensat_syscall=no
4443 AC_MSG_RESULT([no])
4445 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4448 # Solaris-specific check determining if the spawn() syscall is available
4449 # (on newer Solaris).
4451 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4452 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4454 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4455 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4456 #include <sys/syscall.h>
4457 ]], [[
4458   return !SYS_spawn;
4459 ]])], [
4460 solaris_spawn_syscall=yes
4461 AC_MSG_RESULT([yes])
4462 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4463           [Define to 1 if you have the `spawn' syscall.])
4464 ], [
4465 solaris_spawn_syscall=no
4466 AC_MSG_RESULT([no])
4468 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4471 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4472 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4474 # C-level symbol: SOLARIS_MODCTL_MODNVL
4475 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4477 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4478 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4479 #include <sys/modctl.h>
4480 ]], [[
4481   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4482 ]])], [
4483 solaris_modctl_modnvl=yes
4484 AC_MSG_RESULT([yes])
4485 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4486           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4487 ], [
4488 solaris_modctl_modnvl=no
4489 AC_MSG_RESULT([no])
4491 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4494 # Solaris-specific check determining whether nscd (name switch cache daemon)
4495 # attaches its door at /system/volatile/name_service_door (Solaris)
4496 # or at /var/run/name_service_door (illumos).
4498 # Note that /var/run is a symlink to /system/volatile on Solaris
4499 # but not vice versa on illumos.
4501 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4502 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4504 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4505 if test -e /system/volatile/name_service_door; then
4506     solaris_nscd_door_system_volatile=yes
4507     AC_MSG_RESULT([/system/volatile/name_service_door])
4508     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4509               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4510 else
4511     solaris_nscd_door_system_volatile=no
4512     AC_MSG_RESULT([/var/run/name_service_door])
4514 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4517 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4519 # New fasttrap (available on Solaris 11):
4520 # hrt_t *gethrt(void);
4522 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4523 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4525 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4527 #include <sys/trap.h>
4528 ]], [[
4529   return !T_GETHRT;
4530 ]])], [
4531 solaris_gethrt_fasttrap=yes
4532 AC_MSG_RESULT([yes])
4533 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4534           [Define to 1 if you have the new `gethrt' fasttrap.])
4535 ], [
4536 solaris_gethrt_fasttrap=no
4537 AC_MSG_RESULT([no])
4539 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4542 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4543 # is available.
4545 # New fasttrap (available on Solaris 11):
4546 # zonehrtoffset_t *get_zone_offset(void);
4548 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4549 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4551 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4552 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4553 #include <sys/trap.h>
4554 ]], [[
4555   return !T_GETZONEOFFSET;
4556 ]])], [
4557 solaris_getzoneoffset_fasttrap=yes
4558 AC_MSG_RESULT([yes])
4559 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4560           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4561 ], [
4562 solaris_getzoneoffset_fasttrap=no
4563 AC_MSG_RESULT([no])
4565 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4568 # Solaris-specific check determining if the execve() syscall
4569 # takes fourth argument (flags) or not.
4571 # Old syscall (available on illumos):
4572 # int execve(const char *fname, const char **argv, const char **envp);
4574 # New syscall (available on Solaris):
4575 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4577 # If the new syscall is present then it will fail with EINVAL (because flags
4578 # are invalid); if the old syscall is available then it will fail with ENOENT
4579 # (because the file could not be found).
4581 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4582 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4584 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4585 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4586 #include <sys/syscall.h>
4587 #include <errno.h>
4588 ]], [[
4589   errno = 0;
4590   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4591   return !(errno == EINVAL);
4592 ]])], [
4593 solaris_execve_syscall_takes_flags=yes
4594 AC_MSG_RESULT([yes])
4595 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4596           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4597 ], [
4598 solaris_execve_syscall_takes_flags=no
4599 AC_MSG_RESULT([no])
4601 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4602                test x$solaris_execve_syscall_takes_flags = xyes)
4605 # Solaris-specific check determining version of the repository cache protocol.
4606 # Every Solaris version uses a different one, ranging from 21 to current 25.
4607 # The check is very ugly, though.
4609 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4610 # Automake-level symbol: none
4612 AC_PATH_PROG(DIS_PATH, dis, false)
4613 if test "x$DIS_PATH" = "xfalse"; then
4614   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4616 # The illumos source is (or was) here
4617 # https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libscf/common/lowlevel.c#L1148
4618 # specifically the line
4620 # request.rdr_version = REPOSITORY_DOOR_VERSION;
4622 # rdr_version is a 32bit unsigned int
4623 # The macro REPOSITORY_DOOR_VERSION contains the ascii letters "Rep" in the top 3
4624 # bytes and the door version in the lowest byte. Hence we look for Rep which is 526570
4625 # in hex and then extrace the following byte.
4626 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4627   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4628   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4631 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4632 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4633   libscf=/usr/lib/64/libscf.so.1
4634 else
4635   libscf=/usr/lib/libscf.so.1
4637 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q -E '0x(4d01)?526570'; then
4638   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4639   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4641 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | grep 526570 | sed 's/.*526570//;s/,.*//' )
4642 if test -z "$hex"; then
4643   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4644   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4646 version=$( printf "%d\n" 0x$hex )
4647 AC_MSG_RESULT([$version])
4648 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4649                    [Version number of the repository door cache protocol.])
4652 # Solaris-specific check determining if "sysstat" segment reservation type
4653 # is available.
4655 # New "sysstat" segment reservation (available on Solaris 11.4):
4656 # - program header type:    PT_SUNW_SYSSTAT
4657 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4659 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4660 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4662 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4663 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4664 #include <sys/auxv.h>
4665 ]], [[
4666   return !AT_SUN_SYSSTAT_ADDR;
4667 ]])], [
4668 solaris_reserve_sysstat_addr=yes
4669 AC_MSG_RESULT([yes])
4670 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4671           [Define to 1 if you have the new `sysstat' segment reservation.])
4672 ], [
4673 solaris_reserve_sysstat_addr=no
4674 AC_MSG_RESULT([no])
4676 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4679 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4680 # is available.
4682 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4683 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4684 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4686 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4687 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4689 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4690 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4691 #include <sys/auxv.h>
4692 ]], [[
4693   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4694 ]])], [
4695 solaris_reserve_sysstat_zone_addr=yes
4696 AC_MSG_RESULT([yes])
4697 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4698           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4699 ], [
4700 solaris_reserve_sysstat_zone_addr=no
4701 AC_MSG_RESULT([no])
4703 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4706 # Solaris-specific check determining if the system_stats() syscall is available
4707 # (on newer Solaris).
4709 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4710 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4712 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4713 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4714 #include <sys/syscall.h>
4715 ]], [[
4716   return !SYS_system_stats;
4717 ]])], [
4718 solaris_system_stats_syscall=yes
4719 AC_MSG_RESULT([yes])
4720 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4721           [Define to 1 if you have the `system_stats' syscall.])
4722 ], [
4723 solaris_system_stats_syscall=no
4724 AC_MSG_RESULT([no])
4726 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4729 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4730 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4732 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4733 # Automake-level symbol: none
4735 AC_CHECK_TYPE([struct _fpchip_state],
4736               [solaris_fpchip_state_takes_underscore=yes],
4737               [solaris_fpchip_state_takes_underscore=no],
4738               [[#include <sys/regset.h>]])
4739 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4740   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4741             [Define to 1 if fpregset_t defines struct _fpchip_state])
4745 # Solaris-specific check determining if schedctl page shared between kernel
4746 # and userspace program is executable (illumos, older Solaris) or not (newer
4747 # Solaris).
4749 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4750 # Automake-level symbol: none
4752 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4753 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4754 #include <assert.h>
4755 #include <fcntl.h>
4756 #include <procfs.h>
4757 #include <schedctl.h>
4758 #include <stdio.h>
4759 #include <unistd.h>
4760 ]], [[
4761     schedctl_t *scp = schedctl_init();
4762     if (scp == NULL)
4763         return 1;
4765     int fd = open("/proc/self/map", O_RDONLY);
4766     assert(fd >= 0);
4768     prmap_t map;
4769     ssize_t rd;
4770     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4771         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4772             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4773                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4774             return (map.pr_mflags & MA_EXEC);
4775         }
4776     }
4778     return 1;
4779 ]])], [
4780 solaris_schedctl_page_exec=no
4781 AC_MSG_RESULT([no])
4782 ], [
4783 solaris_schedctl_page_exec=yes
4784 AC_MSG_RESULT([yes])
4785 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4786           [Define to 1 if you have the schedctl page executable.])
4790 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4791 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4792 # an initial thread pointer for libc (newer Solaris).
4794 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4795 # Automake-level symbol: none
4797 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4798 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4799 #include <sys/fasttrap_isa.h>
4800 ]], [[
4801     return !FT_SCRATCHSIZE;
4802 ]])], [
4803 solaris_pt_sunwdtrace_thrp=yes
4804 AC_MSG_RESULT([yes])
4805 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4806           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4807 ], [
4808 solaris_pt_sunwdtrace_thrp=no
4809 AC_MSG_RESULT([no])
4812 else
4813 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4814 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4815 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4816 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4817 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4818 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4819 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4820 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4821 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4822 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4823 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4824 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4825 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4826 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4827 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4828 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4829 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4830 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4831 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4832 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4833 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4834 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4835 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4836 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4837 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4838 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4839 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4840 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4841 fi # test "$VGCONF_OS" = "solaris"
4843 #----------------------------------------------------------------------------
4844 # FreeBSD-specific checks.
4845 #----------------------------------------------------------------------------
4847 # Rather than having a large number of feature test as above with Solaris
4848 # these tests are per-version. This may not be entirely reliable for
4849 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4850 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4852 if test "$VGCONF_OS" = "freebsd" ; then
4854 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4855 AM_CONDITIONAL(FREEBSD_VERS_15_PLUS, test $freebsd_vers -ge $freebsd_15)
4857 else
4859 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4860 AM_CONDITIONAL(FREEBSD_VERS_15_PLUS, false)
4862 fi # test "$VGCONF_OS" = "freebsd"
4865 #----------------------------------------------------------------------------
4866 # Checks for C header files.
4867 #----------------------------------------------------------------------------
4869 AC_CHECK_HEADERS([       \
4870         asm/unistd.h     \
4871         endian.h         \
4872         mqueue.h         \
4873         sys/endian.h     \
4874         sys/epoll.h      \
4875         sys/eventfd.h    \
4876         sys/klog.h       \
4877         sys/poll.h       \
4878         sys/prctl.h      \
4879         sys/signal.h     \
4880         sys/signalfd.h   \
4881         sys/syscall.h    \
4882         sys/sysnvl.h     \
4883         sys/time.h       \
4884         sys/types.h      \
4885         ])
4887 # Verify whether the <linux/futex.h> header is usable.
4888 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4890 save_CFLAGS="$CFLAGS"
4891 CFLAGS="$CFLAGS -D__user="
4892 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4893 #include <linux/futex.h>
4894 ]], [[
4895   return FUTEX_WAIT;
4896 ]])], [
4897 ac_have_usable_linux_futex_h=yes
4898 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4899           [Define to 1 if you have a usable <linux/futex.h> header file.])
4900 AC_MSG_RESULT([yes])
4901 ], [
4902 ac_have_usable_linux_futex_h=no
4903 AC_MSG_RESULT([no])
4905 CFLAGS="$save_CFLAGS"
4908 #----------------------------------------------------------------------------
4909 # Checks for typedefs, structures, and compiler characteristics.
4910 #----------------------------------------------------------------------------
4911 AC_TYPE_UID_T
4912 AC_TYPE_OFF_T
4913 AC_TYPE_SIZE_T
4914 AC_CHECK_HEADERS_ONCE([sys/time.h])
4916 AC_CHECK_TYPE([struct statx], [
4917   AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4918             [Define to 1 if <sys/stat.h> declares struct statx.])
4919 ], [], [
4920   #define _GNU_SOURCE
4921   #include <sys/stat.h>
4925 #----------------------------------------------------------------------------
4926 # Checks for library functions.
4927 #----------------------------------------------------------------------------
4928 AC_FUNC_MEMCMP
4929 AC_FUNC_MMAP
4931 AC_CHECK_LIB([pthread], [pthread_create])
4932 AC_CHECK_LIB([rt], [clock_gettime])
4934 AC_CHECK_FUNCS([     \
4935         aligned_alloc \
4936         clock_gettime\
4937         copy_file_range \
4938         epoll_create \
4939         epoll_pwait  \
4940         getaddrinfo  \
4941         klogctl      \
4942         mallinfo     \
4943         memchr       \
4944         memfd_create \
4945         memset       \
4946         mkdir        \
4947         mremap       \
4948         pipe2        \
4949         ppoll        \
4950         preadv       \
4951         preadv2      \
4952         process_vm_readv  \
4953         process_vm_writev \
4954         pthread_barrier_init       \
4955         pthread_condattr_setclock  \
4956         pthread_mutex_timedlock    \
4957         pthread_rwlock_timedrdlock \
4958         pthread_rwlock_timedwrlock \
4959         pthread_setname_np         \
4960         pthread_spin_lock          \
4961         pthread_yield              \
4962         pwritev      \
4963         pwritev2     \
4964         rawmemchr    \
4965         readlinkat   \
4966         reallocarray \
4967         semtimedop   \
4968         setcontext   \
4969         signalfd     \
4970         sigwaitinfo  \
4971         strchr       \
4972         strdup       \
4973         strpbrk      \
4974         strrchr      \
4975         strstr       \
4976         swapcontext  \
4977         syscall      \
4978         utimensat    \
4979         mempcpy      \
4980         strlcat      \
4981         strlcpy      \
4982         stpncpy      \
4983         strchrnul    \
4984         memrchr      \
4985         strndup      \
4986         close_range  \
4987         wcsncpy      \
4988         free_aligned_sized \
4989         sbrk         \
4990         wcpncpy      \
4991         wcsxfrm      \
4992         sem_timedwait \
4993         sem_clockwait_np
4994         ])
4996 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4997 # libraries with any shared object and/or executable. This is NOT what we
4998 # want for e.g. vgpreload_core-x86-linux.so
4999 LIBS=""
5001 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
5002                [test x$ac_cv_func_pthread_barrier_init = xyes])
5003 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
5004                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
5005 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
5006                [test x$ac_cv_func_pthread_spin_lock = xyes])
5007 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
5008                [test x$ac_cv_func_pthread_setname_np = xyes])
5009 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
5010                [test x$ac_cv_func_copy_file_range = xyes])
5011 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
5012                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
5013 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
5014                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
5015 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
5016 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
5017 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
5018                [test x$ac_cv_func_memfd_create = xyes])
5019 AM_CONDITIONAL([HAVE_GETADDRINFO],
5020                [test x$ac_cv_func_getaddrinfo = xyes])
5021 AM_CONDITIONAL([HAVE_CLOSE_RANGE],
5022                [test x$ac_cv_func_close_range = xyes])
5023 AM_CONDITIONAL([HAVE_REALLOCARRAY],
5024                [test x$ac_cv_func_reallocarray = xyes])
5025 AM_CONDITIONAL([HAVE_WCSNCPY],
5026                [test x$ac_cv_func_wcsncpy = xyes])
5027 AM_CONDITIONAL([HAVE_STRLCAT],
5028                [test x$ac_cv_func_strlcat = xyes])
5029 AM_CONDITIONAL([HAVE_STRLCPY],
5030                [test x$ac_cv_func_strlcpy = xyes])
5031 AM_CONDITIONAL([HAVE_FREE_ALIGNED_SIZED],
5032                [test x$ac_cv_func_free_aligned_sized = xyes])
5033 AM_CONDITIONAL([HAVE_SBRK],
5034                [test x$ac_cv_func_sbrk = xyes])
5035 AM_CONDITIONAL([HAVE_WCPNCPY],
5036                [test x$ac_cv_func_wcpncpy = xyes])
5037 AM_CONDITIONAL([HAVE_WCSXFRM],
5038                [test x$ac_cv_func_wcsxfrm = xyes])
5039 AM_CONDITIONAL([HAVE_SEM_TIMEDWAIT],
5040                [test x$ac_cv_func_sem_timedwait = xyes])
5041 AM_CONDITIONAL([HAVE_SEM_CLOCKWAIT_NP],
5042                [test x$ac_cv_func_sem_clockwait_np = xyes])
5044 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
5045      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
5046      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
5047   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
5048             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
5051 #----------------------------------------------------------------------------
5052 # MPI checks
5053 #----------------------------------------------------------------------------
5054 # Do we have a useable MPI setup on the primary and/or secondary targets?
5055 # On Linux, by default, assumes mpicc and -m32/-m64
5056 # Note: this is a kludge in that it assumes the specified mpicc 
5057 # understands -m32/-m64 regardless of what is specified using
5058 # --with-mpicc=.
5059 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
5060              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
5062 mflag_primary=
5063 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
5064      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
5065      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
5066      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
5067      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
5068      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
5069      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
5070   mflag_primary=$FLAG_M32
5071 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
5072        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
5073        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
5074        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
5075        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_FREEBSD \
5076        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
5077        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
5078   mflag_primary=$FLAG_M64
5079 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
5080   mflag_primary="$FLAG_M32 -arch i386"
5081 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
5082   mflag_primary="$FLAG_M64 -arch x86_64"
5085 mflag_secondary=
5086 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
5087      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
5088      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
5089      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
5090      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
5091   mflag_secondary=$FLAG_M32
5092 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
5093   mflag_secondary="$FLAG_M32 -arch i386"
5097 AC_ARG_WITH(mpicc,
5098    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
5099    MPI_CC=$withval
5101 AC_SUBST(MPI_CC)
5103 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
5104 ## use these values in the check for a functioning mpicc.
5106 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
5107 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
5108 AM_COND_IF([VGCONF_OS_IS_LINUX],
5109            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5110             LDFLAGS_MPI="-fpic -shared"])
5111 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
5112            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5113             LDFLAGS_MPI="-fpic -shared"])
5114 AM_COND_IF([VGCONF_OS_IS_DARWIN],
5115            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
5116             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
5117 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
5118            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5119             LDFLAGS_MPI="-fpic -shared"])
5121 AC_SUBST([CFLAGS_MPI])
5122 AC_SUBST([LDFLAGS_MPI])
5125 ## See if MPI_CC works for the primary target
5127 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
5128 saved_CC=$CC
5129 saved_CFLAGS=$CFLAGS
5130 CC=$MPI_CC
5131 CFLAGS="$CFLAGS_MPI $mflag_primary"
5132 saved_LDFLAGS="$LDFLAGS"
5133 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
5134 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5135 #include <mpi.h>
5136 #include <stdio.h>
5137 ]], [[
5138   int ni, na, nd, comb;
5139   int r = MPI_Init(NULL,NULL);
5140   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5141   r |= MPI_Finalize();
5142   return r; 
5143 ]])], [
5144 ac_have_mpi2_pri=yes
5145 AC_MSG_RESULT([yes, $MPI_CC])
5146 ], [
5147 ac_have_mpi2_pri=no
5148 AC_MSG_RESULT([no])
5150 CC=$saved_CC
5151 CFLAGS=$saved_CFLAGS
5152 LDFLAGS="$saved_LDFLAGS"
5153 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
5155 ## See if MPI_CC works for the secondary target.  Complication: what if
5156 ## there is no secondary target?  We need this to then fail.
5157 ## Kludge this by making MPI_CC something which will surely fail in
5158 ## such a case.
5160 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
5161 saved_CC=$CC
5162 saved_CFLAGS=$CFLAGS
5163 saved_LDFLAGS="$LDFLAGS"
5164 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
5165 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
5166   CC="$MPI_CC this will surely fail"
5167 else
5168   CC=$MPI_CC
5170 CFLAGS="$CFLAGS_MPI $mflag_secondary"
5171 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5172 #include <mpi.h>
5173 #include <stdio.h>
5174 ]], [[
5175   int ni, na, nd, comb;
5176   int r = MPI_Init(NULL,NULL);
5177   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5178   r |= MPI_Finalize();
5179   return r; 
5180 ]])], [
5181 ac_have_mpi2_sec=yes
5182 AC_MSG_RESULT([yes, $MPI_CC])
5183 ], [
5184 ac_have_mpi2_sec=no
5185 AC_MSG_RESULT([no])
5187 CC=$saved_CC
5188 CFLAGS=$saved_CFLAGS
5189 LDFLAGS="$saved_LDFLAGS"
5190 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
5193 #----------------------------------------------------------------------------
5194 # Other library checks
5195 #----------------------------------------------------------------------------
5196 # There now follow some tests for Boost, and OpenMP.  These
5197 # tests are present because Drd has some regression tests that use
5198 # these packages.  All regression test programs all compiled only
5199 # for the primary target.  And so it is important that the configure
5200 # checks that follow, use the correct -m32 or -m64 flag for the
5201 # primary target (called $mflag_primary).  Otherwise, we can end up
5202 # in a situation (eg) where, on amd64-linux, the test for Boost checks
5203 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
5204 # only build (meaning, the primary target is x86-linux), the build
5205 # of the regtest programs that use Boost fails, because they are 
5206 # build as 32-bit (IN THIS EXAMPLE).
5208 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
5209 # NEEDED BY THE REGRESSION TEST PROGRAMS.
5212 # Check whether the boost library 1.35 or later has been installed.
5213 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
5215 AC_MSG_CHECKING([for boost])
5217 AC_LANG(C++)
5218 safe_CXXFLAGS=$CXXFLAGS
5219 CXXFLAGS="$mflag_primary"
5220 safe_LIBS="$LIBS"
5221 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
5223 AC_LINK_IFELSE([AC_LANG_SOURCE([
5224 #include <boost/thread.hpp>
5225 static void thread_func(void)
5226 { }
5227 int main(int argc, char** argv)
5229   boost::thread t(thread_func);
5230   return 0;
5232 ])],
5234 ac_have_boost_1_35=yes
5235 AC_SUBST([BOOST_CFLAGS], [])
5236 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
5237 AC_MSG_RESULT([yes])
5238 ], [
5239 ac_have_boost_1_35=no
5240 AC_MSG_RESULT([no])
5243 LIBS="$safe_LIBS"
5244 CXXFLAGS=$safe_CXXFLAGS
5245 AC_LANG(C)
5247 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
5250 # does this compiler support -fopenmp, does it have the include file
5251 # <omp.h> and does it have libgomp ?
5253 AC_MSG_CHECKING([for OpenMP])
5255 safe_CFLAGS=$CFLAGS
5256 CFLAGS="-fopenmp $mflag_primary -Werror"
5258 AC_LINK_IFELSE([AC_LANG_SOURCE([
5259 #include <omp.h> 
5260 int main(int argc, char** argv)
5262   omp_set_dynamic(0);
5263   return 0;
5265 ])],
5267 ac_have_openmp=yes
5268 AC_MSG_RESULT([yes])
5269 ], [
5270 ac_have_openmp=no
5271 AC_MSG_RESULT([no])
5273 CFLAGS=$safe_CFLAGS
5275 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5278 # Check for __builtin_popcount
5279 AC_MSG_CHECKING([for __builtin_popcount()])
5280 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5281 ]], [[
5282   __builtin_popcount(2);
5283   return 0;
5284 ]])], [
5285 AC_MSG_RESULT([yes])
5286 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5287           [Define to 1 if compiler provides __builtin_popcount().])
5288 ], [
5289 AC_MSG_RESULT([no])
5292 # Check for __builtin_clz
5293 AC_MSG_CHECKING([for __builtin_clz()])
5294 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5295 ]], [[
5296   __builtin_clz(2);
5297   return 0;
5298 ]])], [
5299 AC_MSG_RESULT([yes])
5300 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5301           [Define to 1 if compiler provides __builtin_clz().])
5302 ], [
5303 AC_MSG_RESULT([no])
5306 # Check for __builtin_ctz
5307 AC_MSG_CHECKING([for __builtin_ctz()])
5308 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5309 ]], [[
5310   __builtin_ctz(2);
5311   return 0;
5312 ]])], [
5313 AC_MSG_RESULT([yes])
5314 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5315           [Define to 1 if compiler provides __builtin_ctz().])
5316 ], [
5317 AC_MSG_RESULT([no])
5320 # does this compiler have built-in functions for atomic memory access for the
5321 # primary target ?
5322 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5324 safe_CFLAGS=$CFLAGS
5325 CFLAGS="$mflag_primary"
5327 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5328   int variable = 1;
5329   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5330           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5331 ]])], [
5332   ac_have_builtin_atomic_primary=yes
5333   AC_MSG_RESULT([yes])
5334   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])
5335 ], [
5336   ac_have_builtin_atomic_primary=no
5337   AC_MSG_RESULT([no])
5340 CFLAGS=$safe_CFLAGS
5342 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5343                [test x$ac_have_builtin_atomic_primary = xyes])
5346 # does this compiler have built-in functions for atomic memory access for the
5347 # secondary target ?
5349 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5351 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5353 safe_CFLAGS=$CFLAGS
5354 CFLAGS="$mflag_secondary"
5356 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5357   int variable = 1;
5358   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5359 ]])], [
5360   ac_have_builtin_atomic_secondary=yes
5361   AC_MSG_RESULT([yes])
5362 ], [
5363   ac_have_builtin_atomic_secondary=no
5364   AC_MSG_RESULT([no])
5367 CFLAGS=$safe_CFLAGS
5371 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5372                [test x$ac_have_builtin_atomic_secondary = xyes])
5374 # does this compiler have built-in functions for atomic memory access on
5375 # 64-bit integers for all targets ?
5377 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5379 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5380   #include <stdint.h>
5381 ]], [[
5382   uint64_t variable = 1;
5383   return __sync_add_and_fetch(&variable, 1)
5384 ]])], [
5385   ac_have_builtin_atomic64_primary=yes
5386 ], [
5387   ac_have_builtin_atomic64_primary=no
5390 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5392 safe_CFLAGS=$CFLAGS
5393 CFLAGS="$mflag_secondary"
5395 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5396   #include <stdint.h>
5397 ]], [[
5398   uint64_t variable = 1;
5399   return __sync_add_and_fetch(&variable, 1)
5400 ]])], [
5401   ac_have_builtin_atomic64_secondary=yes
5402 ], [
5403   ac_have_builtin_atomic64_secondary=no
5406 CFLAGS=$safe_CFLAGS
5410 if test x$ac_have_builtin_atomic64_primary = xyes && \
5411    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5412      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5413   AC_MSG_RESULT([yes])
5414   ac_have_builtin_atomic64=yes
5415 else
5416   AC_MSG_RESULT([no])
5417   ac_have_builtin_atomic64=no
5420 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5421                [test x$ac_have_builtin_atomic64 = xyes])
5423                
5424 AC_MSG_CHECKING([if platform has openat2 syscall])
5426 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5427   #include <sys/syscall.h>
5428 ]], [[
5429   return __NR_openat2
5430 ]])], [
5431   ac_have_openat2=yes
5432   AC_MSG_RESULT([yes])
5433 ], [
5434   ac_have_openat2=no
5435   AC_MSG_RESULT([no])
5438 AM_CONDITIONAL([HAVE_OPENAT2],
5439                [test x$ac_have_openat2 = xyes])
5441 # check for crypto
5443 safe_LIBS="$LIBS"
5444 LIBS="-lcrypto"
5445 AC_MSG_CHECKING([if platform has openssl crypto])
5447 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5448   #include <openssl/crypto.h>
5449 ]], [[
5450   CRYPTO_secure_malloc_init(1<<20, 8);
5451 ]])], [
5452   ac_have_openssl=yes
5453   AC_MSG_RESULT([yes])
5454 ], [
5455   ac_have_openssl=no
5456   AC_MSG_RESULT([no])
5458 LIBS=$safe_LIBS
5460 AM_CONDITIONAL([HAVE_OPENSSL],
5461                [test x$ac_have_openssl = xyes])
5463 AC_MSG_CHECKING([if platform has aio_readv])
5465 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5466   #include <aio.h>
5467   #include <stdlib.h>
5468 ]], [[
5469   aio_readv(NULL);
5470 ]])], [
5471   ac_have_aio_readv=yes
5472   AC_MSG_RESULT([yes])
5474 ], [
5475   ac_have_aio_readv=no
5476   AC_MSG_RESULT([no])
5479 AM_CONDITIONAL([HAVE_AIO_READV],
5480                [test x$ac_have_aio_readv = xyes])
5482 # does g++ have built-in functions for atomic memory access ?
5483 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5485 safe_CXXFLAGS=$CXXFLAGS
5486 CXXFLAGS="$mflag_primary"
5488 AC_LANG_PUSH(C++)
5489 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5490   int variable = 1;
5491   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5492           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5493 ]])], [
5494   ac_have_builtin_atomic_cxx=yes
5495   AC_MSG_RESULT([yes])
5496   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5497 ], [
5498   ac_have_builtin_atomic_cxx=no
5499   AC_MSG_RESULT([no])
5501 AC_LANG_POP(C++)
5503 CXXFLAGS=$safe_CXXFLAGS
5505 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5508 if test x$ac_have_usable_linux_futex_h = xyes \
5509         -a x$ac_have_builtin_atomic_primary = xyes; then
5510   ac_enable_linux_ticket_lock_primary=yes
5512 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5513                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5515 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5516         -a x$ac_have_usable_linux_futex_h = xyes \
5517         -a x$ac_have_builtin_atomic_secondary = xyes; then
5518   ac_enable_linux_ticket_lock_secondary=yes
5520 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5521                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5524 # does libstdc++ support annotating shared pointers ?
5525 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5527 safe_CXXFLAGS=$CXXFLAGS
5528 CXXFLAGS="-std=c++0x"
5530 AC_LANG_PUSH(C++)
5531 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5532   #include <memory>
5533 ]], [[
5534   std::shared_ptr<int> p
5535 ]])], [
5536   ac_have_shared_ptr=yes
5537 ], [
5538   ac_have_shared_ptr=no
5540 if test x$ac_have_shared_ptr = xyes; then
5541   # If compilation of the program below fails because of a syntax error
5542   # triggered by substituting one of the annotation macros then that
5543   # means that libstdc++ supports these macros.
5544   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5545     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5546     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5547     #include <memory>
5548   ]], [[
5549     std::shared_ptr<int> p
5550   ]])], [
5551     ac_have_shared_pointer_annotation=no
5552     AC_MSG_RESULT([no])
5553   ], [
5554     ac_have_shared_pointer_annotation=yes
5555     AC_MSG_RESULT([yes])
5556     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5557               [Define to 1 if libstd++ supports annotating shared pointers])
5558   ])
5559 else
5560   ac_have_shared_pointer_annotation=no
5561   AC_MSG_RESULT([no])
5563 AC_LANG_POP(C++)
5565 CXXFLAGS=$safe_CXXFLAGS
5567 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5568                [test x$ac_have_shared_pointer_annotation = xyes])
5570 # checking for GNU libc C17 aligned_alloc
5571 # just check glibc version rather than trying to muck around
5572 # checking the runtime behaviour or seeing if it is a weak alias
5573 AC_MSG_CHECKING([for AT_GNU_LIBC_C17_ALIGNED_ALLOC])
5574 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5575 #include <features.h>
5576 ]], [[
5577 #if !defined(__GLIBC__) || __GLIBC__ != 2 || !defined(__GLIBC_MINOR__) || __GLIBC_MINOR__ < 38
5578 #error "not GNU libc 2.38 or later"
5579 #endif
5580 ]])], [
5581     AC_MSG_RESULT([yes])
5582     AC_DEFINE([HAVE_GNU_LIBC_C17_ALIGNED_ALLOC], 1,
5583               [Define to 1 if you have GNU libc C17 aligned_alloc.])
5585 ], [
5586     AC_MSG_RESULT([no])
5589 # Check for C11 thrd_create()
5590 AC_MSG_CHECKING([for thrd_create()])
5591 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
5592 #include <threads.h>
5593 int thrd_entry(void *arg) { return 0; }
5594 ], [[thrd_t thr; return thrd_create(&thr, thrd_entry, NULL);]])],
5596 ac_cxx_have_thrd_create=yes
5597 AC_MSG_RESULT([yes])
5598 ], [
5599 ac_cxx_have_thrd_create=no
5600 AC_MSG_RESULT([no])
5603 AM_CONDITIONAL(HAVE_THRD_CREATE, test x$ac_cxx_have_thrd_create = xyes)
5607 #----------------------------------------------------------------------------
5608 # Ok.  We're done checking.
5609 #----------------------------------------------------------------------------
5611 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5612 AC_CONFIG_FILES([
5613    Makefile 
5614    VEX/Makefile:Makefile.vex.in
5615    valgrind.spec
5616    valgrind.pc
5617    glibc-2.X.supp
5618    glibc-2.X-helgrind.supp
5619    glibc-2.X-drd.supp
5620    include/valgrind.h
5621    docs/Makefile 
5622    docs/xml/vg-entities.xml
5623    tests/Makefile 
5624    tests/vg_regtest 
5625    perf/Makefile 
5626    perf/vg_perf
5627    gdbserver_tests/Makefile
5628    gdbserver_tests/solaris/Makefile
5629    include/Makefile 
5630    auxprogs/Makefile
5631    mpi/Makefile
5632    coregrind/Makefile 
5633    memcheck/Makefile
5634    memcheck/tests/Makefile
5635    memcheck/tests/common/Makefile
5636    memcheck/tests/amd64/Makefile
5637    memcheck/tests/arm64/Makefile
5638    memcheck/tests/x86/Makefile
5639    memcheck/tests/linux/Makefile
5640    memcheck/tests/linux/debuginfod-check.vgtest
5641    memcheck/tests/darwin/Makefile
5642    memcheck/tests/solaris/Makefile
5643    memcheck/tests/freebsd/Makefile
5644    memcheck/tests/amd64-linux/Makefile
5645    memcheck/tests/arm64-linux/Makefile
5646    memcheck/tests/x86-linux/Makefile
5647    memcheck/tests/amd64-solaris/Makefile
5648    memcheck/tests/x86-solaris/Makefile
5649    memcheck/tests/amd64-freebsd/Makefile
5650    memcheck/tests/x86-freebsd/Makefile
5651    memcheck/tests/ppc32/Makefile
5652    memcheck/tests/ppc64/Makefile
5653    memcheck/tests/s390x/Makefile
5654    memcheck/tests/mips32/Makefile
5655    memcheck/tests/mips64/Makefile
5656    memcheck/tests/vbit-test/Makefile
5657    cachegrind/Makefile
5658    cachegrind/tests/Makefile
5659    cachegrind/tests/x86/Makefile
5660    cachegrind/cg_annotate
5661    cachegrind/cg_diff
5662    cachegrind/cg_merge
5663    callgrind/Makefile
5664    callgrind/callgrind_annotate
5665    callgrind/callgrind_control
5666    callgrind/tests/Makefile
5667    helgrind/Makefile
5668    helgrind/tests/Makefile
5669    drd/Makefile
5670    drd/scripts/download-and-build-splash2
5671    drd/tests/Makefile
5672    massif/Makefile
5673    massif/tests/Makefile
5674    massif/ms_print
5675    dhat/Makefile
5676    dhat/tests/Makefile
5677    lackey/Makefile
5678    lackey/tests/Makefile
5679    none/Makefile
5680    none/tests/Makefile
5681    none/tests/scripts/Makefile
5682    none/tests/amd64/Makefile
5683    none/tests/ppc32/Makefile
5684    none/tests/ppc64/Makefile
5685    none/tests/x86/Makefile
5686    none/tests/arm/Makefile
5687    none/tests/arm64/Makefile
5688    none/tests/s390x/Makefile
5689    none/tests/mips32/Makefile
5690    none/tests/mips64/Makefile
5691    none/tests/nanomips/Makefile
5692    none/tests/linux/Makefile
5693    none/tests/darwin/Makefile
5694    none/tests/solaris/Makefile
5695    none/tests/freebsd/Makefile
5696    none/tests/amd64-linux/Makefile
5697    none/tests/x86-linux/Makefile
5698    none/tests/amd64-darwin/Makefile
5699    none/tests/x86-darwin/Makefile
5700    none/tests/amd64-solaris/Makefile
5701    none/tests/x86-solaris/Makefile
5702    none/tests/x86-freebsd/Makefile
5703    exp-bbv/Makefile
5704    exp-bbv/tests/Makefile
5705    exp-bbv/tests/x86/Makefile
5706    exp-bbv/tests/x86-linux/Makefile
5707    exp-bbv/tests/amd64-linux/Makefile
5708    exp-bbv/tests/ppc32-linux/Makefile
5709    exp-bbv/tests/arm-linux/Makefile
5710    shared/Makefile
5711    solaris/Makefile
5713 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5714                 [chmod +x coregrind/link_tool_exe_linux])
5715 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5716                 [chmod +x coregrind/link_tool_exe_freebsd])
5717 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5718                 [chmod +x coregrind/link_tool_exe_darwin])
5719 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5720                 [chmod +x coregrind/link_tool_exe_solaris])
5721 AC_CONFIG_FILES([tests/filter_stderr_basic],
5722                 [chmod +x tests/filter_stderr_basic])
5723 AC_CONFIG_FILES([tests/filter_discards],
5724                 [chmod +x tests/filter_discards])
5725 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5726                 [chmod +x memcheck/tests/filter_stderr])
5727 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5728                 [chmod +x memcheck/tests/filter_dw4])
5729 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5730                 [chmod +x memcheck/tests/filter_overlaperror])
5731 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5732                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5733 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5734                 [chmod +x gdbserver_tests/filter_gdb])
5735 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5736                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5737 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5738                 [chmod +x gdbserver_tests/filter_stderr])
5739 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5740                 [chmod +x gdbserver_tests/filter_vgdb])
5741 AC_CONFIG_FILES([drd/tests/filter_stderr],
5742                 [chmod +x drd/tests/filter_stderr])
5743 AC_CONFIG_FILES([drd/tests/filter_error_count],
5744                 [chmod +x drd/tests/filter_error_count])
5745 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5746                 [chmod +x drd/tests/filter_error_summary])
5747 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5748                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5749 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5750                 [chmod +x drd/tests/filter_thread_no])
5751 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5752                 [chmod +x drd/tests/filter_xml_and_thread_no])
5753 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5754                 [chmod +x helgrind/tests/filter_stderr])
5755 AC_OUTPUT
5757 cat<<EOF
5759                     Version: ${VERSION}
5760          Maximum build arch: ${ARCH_MAX}
5761          Primary build arch: ${VGCONF_ARCH_PRI}
5762        Secondary build arch: ${VGCONF_ARCH_SEC}
5763                    Build OS: ${VGCONF_OS}
5764      Link Time Optimisation: ${vg_cv_lto}
5765        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5766      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5767            Platform variant: ${VGCONF_PLATVARIANT}
5768       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5769          Default supp files: ${DEFAULT_SUPP}