ARM: handle v6 to v8 in configure.ac
[valgrind.git] / configure.ac
blob7925c9a3e9dc049f08d69fb8515cde1c33d743ed
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], [23])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [GIT])
21 m4_define([v_rel_date], ["?? Apr 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="-march=armv7 -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_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
417         freebsd_14=1400
418         AC_DEFINE([FREEBSD_15], 1500, [FREEBSD_VERS value for FreeBSD 15.x])
419         freebsd_15=1500
421         AC_MSG_CHECKING([for the kernel version])
422         kernel=`uname -r`
424         case "${kernel}" in
425         10.*)
426            AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
427            AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
428            freebsd_vers=$freebsd_10
429            ;;
430         11.*)
431            AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
432            AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
433            freebsd_vers=$freebsd_11
434            ;;
435         12.*)
436            case "${kernel}" in
437            12.[[0-1]]-*)
438               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
439               AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
440               freebsd_vers=$freebsd_12
441               ;;
442            *)
443               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
444               AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
445               freebsd_vers=$freebsd_12_2
446               ;;
447            esac
448            ;;
449         13.*)
450            case "${kernel}" in
451            13.0-*)
452               AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
453               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
454               freebsd_vers=$freebsd_13_0
455               ;;
456            13.1-*)
457               AC_MSG_RESULT([FreeBSD 13.1 (${kernel})])
458               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
459               freebsd_vers=$freebsd_13_1
460               ;;
461            13.2-*)
462               AC_MSG_RESULT([FreeBSD 13.2 (${kernel})])
463               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_2, [FreeBSD version])
464               freebsd_vers=$freebsd_13_2
465               ;;
466            *)
467               AC_MSG_RESULT([unsupported (${kernel})])
468               AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 15.x])
469               ;;
470            esac
471            ;;
472         14.*)
473            AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
474            AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
475            freebsd_vers=$freebsd_14
476            ;;
477         15.*)
478            AC_MSG_RESULT([FreeBSD 15.x (${kernel})])
479            AC_DEFINE([FREEBSD_VERS], FREEBSD_15, [FreeBSD version])
480            freebsd_vers=$freebsd_15
481            ;;
482         *)
483            AC_MSG_RESULT([unsupported (${kernel})])
484            AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 15.x])
485            ;;
486         esac
488         DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
489         ;;
491      *darwin*)
492         AC_MSG_RESULT([ok (${host_os})])
493         VGCONF_OS="darwin"
494         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
495         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
496         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
497         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
498         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
499         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
500         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
501         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
502         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
504         AC_MSG_CHECKING([for the kernel version])
505         kernel=`uname -r`
507         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
508         # has only one relevant version, the OS version. The `uname` check
509         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
510         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
511         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
512         # and we don't know of an macros similar to __GLIBC__ to get that info.
513         #
514         # XXX: `uname -r` won't do the right thing for cross-compiles, but
515         # that's not a problem yet.
516         #
517         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
518         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
519         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
520         # time support for 10.5 (the 9.* pattern just below), I'll leave it
521         # in for now, just in case anybody wants to give it a try.  But I'm
522         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
523         case "${kernel}" in
524              9.*)
525                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
526                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
527                   DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
528                   DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
529                   ;;
530              10.*)
531                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
532                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
533                   DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
534                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
535                   ;;
536              11.*)
537                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
538                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
539                   DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
540                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
541                   ;;
542              12.*)
543                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
544                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
545                   DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
546                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
547                   ;;
548              13.*)
549                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
550                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
551                   DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
552                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
553                   ;;
554              14.*)
555                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
556                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
557                   DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
558                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
559                   ;;
560              15.*)
561                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
562                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
563                   DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
564                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
565                   ;;
566              16.*)
567                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
568                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
569                   DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
570                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
571                   ;;
572              17.*)
573                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
574                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
575                   DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
576                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
577                   ;;
578              *) 
579                   AC_MSG_RESULT([unsupported (${kernel})])
580                   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)])
581                   ;;
582         esac
583         ;;
585      solaris2.11*)
586         AC_MSG_RESULT([ok (${host_os})])
587         VGCONF_OS="solaris"
589         uname_v=$( uname -v )
590         case "$uname_v" in
591              11.4.*)
592                  DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
593                  ;;
594              *)
595                  DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
596                  ;;
597         esac
598         ;;
600      solaris2.12*)
601         AC_MSG_RESULT([ok (${host_os})])
602         VGCONF_OS="solaris"
603         DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
604         ;;
606      *) 
607         AC_MSG_RESULT([no (${host_os})])
608         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
609         ;;
610 esac
612 #----------------------------------------------------------------------------
614 # If we are building on a 64 bit platform test to see if the system
615 # supports building 32 bit programs and disable 32 bit support if it
616 # does not support building 32 bit programs
618 case "$ARCH_MAX-$VGCONF_OS" in
619      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
620         AC_MSG_CHECKING([for 32 bit build support])
621         safe_CFLAGS=$CFLAGS
622         CFLAGS="-m32"
623         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
624           return 0;
625         ]])], [
626         AC_MSG_RESULT([yes])
627         ], [
628         vg_cv_only64bit="yes"
629         AC_MSG_RESULT([no])
630         ])
631         CFLAGS=$safe_CFLAGS;;
632     mips64-linux)
633         AC_MSG_CHECKING([for 32 bit build support])
634         safe_CFLAGS=$CFLAGS
635         CFLAGS="$CFLAGS -mips32 -mabi=32"
636         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
637           #include <sys/prctl.h>
638         ]], [[]])], [
639         AC_MSG_RESULT([yes])
640         ], [
641         vg_cv_only64bit="yes"
642         AC_MSG_RESULT([no])
643         ])
644         CFLAGS=$safe_CFLAGS;;
645 esac
647 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
648    AC_MSG_ERROR(
649       [--enable-only32bit was specified but system does not support 32 bit builds])
652 #----------------------------------------------------------------------------
654 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
655 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
656 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
657 # above) will be "amd64" since that reflects the most that this cpu can do,
658 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
659 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
660 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
661 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
662 AC_SUBST(VGCONF_ARCH_PRI)
664 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
665 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
666 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
667 # It is empty if there is no secondary target.
668 AC_SUBST(VGCONF_ARCH_SEC)
670 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
671 # The entire system, including regression and performance tests, will be
672 # built for this target.  The "_CAPS" indicates that the name is in capital
673 # letters, and it also uses '_' rather than '-' as a separator, because it's
674 # used to create various Makefile variables, which are all in caps by
675 # convention and cannot contain '-' characters.  This is in contrast to
676 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
677 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
679 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
680 # Valgrind and tools will also be built for this target, but not the
681 # regression or performance tests.
683 # By default, the primary arch is the same as the "max" arch, as commented
684 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
685 # the big case statement just below here, in the case where we're building
686 # on a 64 bit machine but have been requested only to do a 32 bit build.
687 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
689 AC_MSG_CHECKING([for a supported CPU/OS combination])
691 # NB.  The load address for a given platform may be specified in more 
692 # than one place, in some cases, depending on whether we're doing a biarch,
693 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
694 # Be careful to give consistent values in all subcases.  Also, all four
695 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
696 # even if it is to "0xUNSET".
698 case "$ARCH_MAX-$VGCONF_OS" in
699      x86-linux)
700         VGCONF_ARCH_PRI="x86"
701         VGCONF_ARCH_SEC=""
702         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
703         VGCONF_PLATFORM_SEC_CAPS=""
704         valt_load_address_pri_norml="0x58000000"
705         valt_load_address_pri_inner="0x38000000"
706         valt_load_address_sec_norml="0xUNSET"
707         valt_load_address_sec_inner="0xUNSET"
708         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
709         ;;
710      amd64-linux)
711         valt_load_address_sec_norml="0xUNSET"
712         valt_load_address_sec_inner="0xUNSET"
713         if test x$vg_cv_only64bit = xyes; then
714            VGCONF_ARCH_PRI="amd64"
715            VGCONF_ARCH_SEC=""
716            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
717            VGCONF_PLATFORM_SEC_CAPS=""
718            valt_load_address_pri_norml="0x58000000"
719            valt_load_address_pri_inner="0x38000000"
720         elif test x$vg_cv_only32bit = xyes; then
721            VGCONF_ARCH_PRI="x86"
722            VGCONF_ARCH_SEC=""
723            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
724            VGCONF_PLATFORM_SEC_CAPS=""
725            valt_load_address_pri_norml="0x58000000"
726            valt_load_address_pri_inner="0x38000000"
727         else
728            VGCONF_ARCH_PRI="amd64"
729            VGCONF_ARCH_SEC="x86"
730            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
731            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
732            valt_load_address_pri_norml="0x58000000"
733            valt_load_address_pri_inner="0x38000000"
734            valt_load_address_sec_norml="0x58000000"
735            valt_load_address_sec_inner="0x38000000"
736         fi
737         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
738         ;;
739      ppc32-linux)
740         VGCONF_ARCH_PRI="ppc32"
741         VGCONF_ARCH_SEC=""
742         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
743         VGCONF_PLATFORM_SEC_CAPS=""
744         valt_load_address_pri_norml="0x58000000"
745         valt_load_address_pri_inner="0x38000000"
746         valt_load_address_sec_norml="0xUNSET"
747         valt_load_address_sec_inner="0xUNSET"
748         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
749         ;;
750      ppc64be-linux)
751         valt_load_address_sec_norml="0xUNSET"
752         valt_load_address_sec_inner="0xUNSET"
753         if test x$vg_cv_only64bit = xyes; then
754            VGCONF_ARCH_PRI="ppc64be"
755            VGCONF_ARCH_SEC=""
756            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
757            VGCONF_PLATFORM_SEC_CAPS=""
758            valt_load_address_pri_norml="0x58000000"
759            valt_load_address_pri_inner="0x38000000"
760         elif test x$vg_cv_only32bit = xyes; then
761            VGCONF_ARCH_PRI="ppc32"
762            VGCONF_ARCH_SEC=""
763            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
764            VGCONF_PLATFORM_SEC_CAPS=""
765            valt_load_address_pri_norml="0x58000000"
766            valt_load_address_pri_inner="0x38000000"
767         else
768            VGCONF_ARCH_PRI="ppc64be"
769            VGCONF_ARCH_SEC="ppc32"
770            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
771            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
772            valt_load_address_pri_norml="0x58000000"
773            valt_load_address_pri_inner="0x38000000"
774            valt_load_address_sec_norml="0x58000000"
775            valt_load_address_sec_inner="0x38000000"
776         fi
777         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
778         ;;
779      ppc64le-linux)
780         # Little Endian is only supported on PPC64
781         valt_load_address_sec_norml="0xUNSET"
782         valt_load_address_sec_inner="0xUNSET"
783         VGCONF_ARCH_PRI="ppc64le"
784         VGCONF_ARCH_SEC=""
785         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
786         VGCONF_PLATFORM_SEC_CAPS=""
787         valt_load_address_pri_norml="0x58000000"
788         valt_load_address_pri_inner="0x38000000"
789         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
790        ;;
791      x86-freebsd)
792         VGCONF_ARCH_PRI="x86"
793         VGCONF_ARCH_SEC=""
794         VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
795         VGCONF_PLATFORM_SEC_CAPS=""
796         valt_load_address_pri_norml="0x38000000"
797         valt_load_address_pri_inner="0x28000000"
798         valt_load_address_sec_norml="0xUNSET"
799         valt_load_address_sec_inner="0xUNSET"
800         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
801         ;;
802      amd64-freebsd)
803         if test x$vg_cv_only64bit = xyes; then
804            VGCONF_ARCH_PRI="amd64"
805            VGCONF_ARCH_SEC=""
806            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
807            VGCONF_PLATFORM_SEC_CAPS=""
808         elif test x$vg_cv_only32bit = xyes; then
809            VGCONF_ARCH_PRI="x86"
810            VGCONF_ARCH_SEC=""
811            VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
812            VGCONF_PLATFORM_SEC_CAPS=""
813         else
814            VGCONF_ARCH_PRI="amd64"
815            VGCONF_ARCH_SEC="x86"
816            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
817            VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
818         fi
819         # These work with either base clang or ports installed gcc
820         # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
821         if test x$is_clang = xclang ; then
822            FLAG_32ON64="-B/usr/lib32"
823         else
824            GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
825            FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
826            FLAG_32ON64_GXX="-L/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -lgcc_s"
827            AC_SUBST(FLAG_32ON64_GXX)
828         fi
829         valt_load_address_pri_norml="0x38000000"
830         valt_load_address_pri_inner="0x28000000"
831         valt_load_address_sec_norml="0x38000000"
832         valt_load_address_sec_inner="0x28000000"
833         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
834         ;;
835      # Darwin gets identified as 32-bit even when it supports 64-bit.
836      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
837      # all Macs support both 32-bit and 64-bit, so we just build both.  If
838      # someone has a really old 32-bit only machine they can (hopefully?)
839      # build with --enable-only32bit.  See bug 243362.
840      x86-darwin|amd64-darwin)
841         ARCH_MAX="amd64"
842         valt_load_address_sec_norml="0xUNSET"
843         valt_load_address_sec_inner="0xUNSET"
844         if test x$vg_cv_only64bit = xyes; then
845            VGCONF_ARCH_PRI="amd64"
846            VGCONF_ARCH_SEC=""
847            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
848            VGCONF_PLATFORM_SEC_CAPS=""
849            valt_load_address_pri_norml="0x158000000"
850            valt_load_address_pri_inner="0x138000000"
851         elif test x$vg_cv_only32bit = xyes; then
852            VGCONF_ARCH_PRI="x86"
853            VGCONF_ARCH_SEC=""
854            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
855            VGCONF_PLATFORM_SEC_CAPS=""
856            VGCONF_ARCH_PRI_CAPS="x86"
857            valt_load_address_pri_norml="0x58000000"
858            valt_load_address_pri_inner="0x38000000"
859         else
860            VGCONF_ARCH_PRI="amd64"
861            VGCONF_ARCH_SEC="x86"
862            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
863            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
864            valt_load_address_pri_norml="0x158000000"
865            valt_load_address_pri_inner="0x138000000"
866            valt_load_address_sec_norml="0x58000000"
867            valt_load_address_sec_inner="0x38000000"
868         fi
869         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
870         ;;
871      arm-linux) 
872         VGCONF_ARCH_PRI="arm"
873         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
874         VGCONF_PLATFORM_SEC_CAPS=""
875         valt_load_address_pri_norml="0x58000000"
876         valt_load_address_pri_inner="0x38000000"
877         valt_load_address_sec_norml="0xUNSET"
878         valt_load_address_sec_inner="0xUNSET"
879         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
880         ;;
881      arm64-linux)
882         valt_load_address_sec_norml="0xUNSET"
883         valt_load_address_sec_inner="0xUNSET"
884         if test x$vg_cv_only64bit = xyes; then
885            VGCONF_ARCH_PRI="arm64"
886            VGCONF_ARCH_SEC=""
887            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
888            VGCONF_PLATFORM_SEC_CAPS=""
889            valt_load_address_pri_norml="0x58000000"
890            valt_load_address_pri_inner="0x38000000"
891         elif test x$vg_cv_only32bit = xyes; then
892            VGCONF_ARCH_PRI="arm"
893            VGCONF_ARCH_SEC=""
894            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
895            VGCONF_PLATFORM_SEC_CAPS=""
896            valt_load_address_pri_norml="0x58000000"
897            valt_load_address_pri_inner="0x38000000"
898         else
899            VGCONF_ARCH_PRI="arm64"
900            VGCONF_ARCH_SEC="arm"
901            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
902            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
903            valt_load_address_pri_norml="0x58000000"
904            valt_load_address_pri_inner="0x38000000"
905            valt_load_address_sec_norml="0x58000000"
906            valt_load_address_sec_inner="0x38000000"
907         fi
908         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
909         ;;
910      s390x-linux)
911         VGCONF_ARCH_PRI="s390x"
912         VGCONF_ARCH_SEC=""
913         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
914         VGCONF_PLATFORM_SEC_CAPS=""
915         # To improve branch prediction hit rate we want to have
916         # the generated code close to valgrind (host) code
917         valt_load_address_pri_norml="0x800000000"
918         valt_load_address_pri_inner="0x810000000"
919         valt_load_address_sec_norml="0xUNSET"
920         valt_load_address_sec_inner="0xUNSET"
921         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
922         ;;
923      mips32-linux) 
924         VGCONF_ARCH_PRI="mips32"
925         VGCONF_ARCH_SEC=""
926         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
927         VGCONF_PLATFORM_SEC_CAPS=""
928         valt_load_address_pri_norml="0x58000000"
929         valt_load_address_pri_inner="0x38000000"
930         valt_load_address_sec_norml="0xUNSET"
931         valt_load_address_sec_inner="0xUNSET"
932         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
933         ;;
934      mips64-linux)
935         valt_load_address_sec_norml="0xUNSET"
936         valt_load_address_sec_inner="0xUNSET"
937         if test x$vg_cv_only64bit = xyes; then
938             VGCONF_ARCH_PRI="mips64"
939             VGCONF_PLATFORM_SEC_CAPS=""
940             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
941             VGCONF_PLATFORM_SEC_CAPS=""
942             valt_load_address_pri_norml="0x58000000"
943             valt_load_address_pri_inner="0x38000000"
944         elif test x$vg_cv_only32bit = xyes; then
945             VGCONF_ARCH_PRI="mips32"
946             VGCONF_ARCH_SEC=""
947             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
948             VGCONF_PLATFORM_SEC_CAPS=""
949             valt_load_address_pri_norml="0x58000000"
950             valt_load_address_pri_inner="0x38000000"
951         else
952             VGCONF_ARCH_PRI="mips64"
953             VGCONF_ARCH_SEC="mips32"
954             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
955             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
956             valt_load_address_pri_norml="0x58000000"
957             valt_load_address_pri_inner="0x38000000"
958             valt_load_address_sec_norml="0x58000000"
959             valt_load_address_sec_inner="0x38000000"
960         fi
961         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
962         ;;
963      nanomips-linux)
964         VGCONF_ARCH_PRI="nanomips"
965         VGCONF_ARCH_SEC=""
966         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
967         VGCONF_PLATFORM_SEC_CAPS=""
968         valt_load_address_pri_norml="0x58000000"
969         valt_load_address_pri_inner="0x38000000"
970         valt_load_address_sec_norml="0xUNSET"
971         valt_load_address_sec_inner="0xUNSET"
972         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
973         ;;
974      x86-solaris)
975         VGCONF_ARCH_PRI="x86"
976         VGCONF_ARCH_SEC=""
977         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
978         VGCONF_PLATFORM_SEC_CAPS=""
979         valt_load_address_pri_norml="0x58000000"
980         valt_load_address_pri_inner="0x38000000"
981         valt_load_address_sec_norml="0xUNSET"
982         valt_load_address_sec_inner="0xUNSET"
983         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
984         ;;
985      amd64-solaris)
986         valt_load_address_sec_norml="0xUNSET"
987         valt_load_address_sec_inner="0xUNSET"
988         if test x$vg_cv_only64bit = xyes; then
989            VGCONF_ARCH_PRI="amd64"
990            VGCONF_ARCH_SEC=""
991            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
992            VGCONF_PLATFORM_SEC_CAPS=""
993            valt_load_address_pri_norml="0x58000000"
994            valt_load_address_pri_inner="0x38000000"
995         elif test x$vg_cv_only32bit = xyes; then
996            VGCONF_ARCH_PRI="x86"
997            VGCONF_ARCH_SEC=""
998            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
999            VGCONF_PLATFORM_SEC_CAPS=""
1000            valt_load_address_pri_norml="0x58000000"
1001            valt_load_address_pri_inner="0x38000000"
1002         else
1003            VGCONF_ARCH_PRI="amd64"
1004            VGCONF_ARCH_SEC="x86"
1005            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
1006            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
1007            valt_load_address_pri_norml="0x58000000"
1008            valt_load_address_pri_inner="0x38000000"
1009            valt_load_address_sec_norml="0x58000000"
1010            valt_load_address_sec_inner="0x38000000"
1011         fi
1012         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
1013         ;;
1014     *)
1015         VGCONF_ARCH_PRI="unknown"
1016         VGCONF_ARCH_SEC="unknown"
1017         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
1018         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
1019         valt_load_address_pri_norml="0xUNSET"
1020         valt_load_address_pri_inner="0xUNSET"
1021         valt_load_address_sec_norml="0xUNSET"
1022         valt_load_address_sec_inner="0xUNSET"
1023         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
1024         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
1025         ;;
1026 esac
1028 #----------------------------------------------------------------------------
1030 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
1031 # defined.
1032 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
1033                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1034                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1035                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1036                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1037                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1038                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1039                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1040                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1041 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
1042                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1043                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1044                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1045                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1046 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
1047                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1048                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1049 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
1050                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1051                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1052 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
1053                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1054                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1055 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
1056                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1057 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1058                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1059 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1060                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1061                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1062 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1063                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
1064 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1065                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1067 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
1068 # become defined.
1069 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
1070                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1071                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1072 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
1073                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1074 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
1075                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1076                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1077 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1078                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1079 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1080                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1081 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1082                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1083                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1084 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1085                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1086 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1087                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1088                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1089 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1090                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1091                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1092 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1093                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1094 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1095                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1096 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1097                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1098                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1099 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1100                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1101 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1102                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1103                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1104 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1105                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1106 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1107                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1108                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1109 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1110                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1113 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1114 # Relies on the assumption that the primary and secondary targets are 
1115 # for the same OS, so therefore only necessary to test the primary.
1116 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1117                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1118                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1119                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1120                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1121                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1122                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1123                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1124                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1125                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1126                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1127                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1128 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1129                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1130                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1131 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1132                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1133                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1134 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1135                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1136                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1137 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1138                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1139                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1140                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1141                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1144 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1145 # there is a secondary target.
1146 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1147                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1149 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1150 dnl fallback definition
1151 dnl The macro is courtesy of Dave Hart:
1152 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1153 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1154 if test -z "$$1_TRUE"; then :
1155   m4_n([$2])[]dnl
1156 m4_ifval([$3],
1157 [else
1158   $3
1159 ])dnl
1160 fi[]dnl
1161 ])])
1163 #----------------------------------------------------------------------------
1164 # Inner Valgrind?
1165 #----------------------------------------------------------------------------
1167 # Check if this should be built as an inner Valgrind, to be run within
1168 # another Valgrind.  Choose the load address accordingly.
1169 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1170 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1171 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1172    [AC_ARG_ENABLE(inner, 
1173       [  --enable-inner          enables self-hosting],
1174       [vg_cv_inner=$enableval],
1175       [vg_cv_inner=no])])
1176 if test "$vg_cv_inner" = yes; then
1177     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1178     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1179     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1180 else
1181     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1182     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1185 #----------------------------------------------------------------------------
1186 # Undefined behaviour sanitiser
1187 #----------------------------------------------------------------------------
1188 # Check whether we should build with the undefined beahviour sanitiser.
1190 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1191    [AC_ARG_ENABLE(ubsan, 
1192       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1193       [vg_cv_ubsan=$enableval],
1194       [vg_cv_ubsan=no])])
1196 #----------------------------------------------------------------------------
1197 # Extra fine-tuning of installation directories
1198 #----------------------------------------------------------------------------
1199 AC_ARG_WITH(tmpdir,
1200    [  --with-tmpdir=PATH      Specify path for temporary files],
1201    tmpdir="$withval",
1202    tmpdir="/tmp")
1203 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1204 AC_SUBST(VG_TMPDIR, [$tmpdir])
1206 #----------------------------------------------------------------------------
1207 # Detect xcode path
1208 #----------------------------------------------------------------------------
1209 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1210 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1211 AC_MSG_CHECKING([for xcode sdk include path])
1212 AC_ARG_WITH(xcodedir,
1213    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1214    [xcodedir="$withval"],
1215    [
1216       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1217          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1218          if test -z "$xcrundir"; then
1219             xcodedir="/usr/include"
1220          else
1221             xcodedir="$xcrundir/usr/include"
1222          fi
1223       else
1224          xcodedir="/usr/include"
1225       fi
1226    ])
1227 AC_MSG_RESULT([$xcodedir])
1228 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1229 AC_SUBST(XCODE_DIR, [$xcodedir])])
1231 #----------------------------------------------------------------------------
1232 # Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir)
1233 #----------------------------------------------------------------------------
1234 AC_MSG_CHECKING([where gdb scripts are installed])
1235 AC_ARG_WITH(gdbscripts-dir,
1236    [  --with-gdbscripts-dir=PATH  Specify path to install gdb scripts],
1237    [gdbscriptsdir=${withval}],
1238    [gdbscriptsdir=${libexecdir}/valgrind])
1239 AC_MSG_RESULT([$gdbscriptsdir])
1240 if test "x$gdbscriptsdir" != "xno"; then
1241   AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir])
1242   AM_CONDITIONAL(GDBSCRIPTS, true)
1243 else
1244   AC_SUBST(VG_GDBSCRIPTS_DIR, [])
1245   AM_CONDITIONAL(GDBSCRIPTS, false)
1248 #----------------------------------------------------------------------------
1249 # Libc and suppressions
1250 #----------------------------------------------------------------------------
1251 # This variable will collect the suppression files to be used.
1252 AC_SUBST(DEFAULT_SUPP)
1254 AC_CHECK_HEADER([features.h])
1256 if test x$ac_cv_header_features_h = xyes; then
1257   AC_DEFINE([HAVE_HEADER_FEATURES_H], 1,
1258           [Define to 1 if you have the `features.h' header.])
1259   rm -f conftest.$ac_ext
1260   cat <<_ACEOF >conftest.$ac_ext
1261 #include <features.h>
1262 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1263 glibc version is: __GLIBC__ __GLIBC_MINOR__
1264 #endif
1265 _ACEOF
1266   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1269 # not really a version check
1270 AC_EGREP_CPP([DARWIN_LIBC], [
1271 #include <sys/cdefs.h>
1272 #if defined(__DARWIN_VERS_1050)
1273   DARWIN_LIBC
1274 #endif
1276 GLIBC_VERSION="darwin")
1278 AC_EGREP_CPP([FREEBSD_LIBC], [
1279 #include <sys/cdefs.h>
1280 #if defined(__FreeBSD__)
1281   FREEBSD_LIBC
1282 #endif
1284 GLIBC_VERSION="freebsd")
1286 # not really a version check
1287 AC_EGREP_CPP([BIONIC_LIBC], [
1288 #if defined(__ANDROID__)
1289   BIONIC_LIBC
1290 #endif
1292 GLIBC_VERSION="bionic")
1294 # there is only one version of libc on Solaris
1295 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1296      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1297     GLIBC_VERSION="solaris"
1300 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1301 # in this case.
1302 if test x$GLIBC_VERSION = x; then
1303     if $CC -dumpmachine | grep -q musl; then
1304         GLIBC_VERSION=musl
1305     fi
1308 # If this is glibc then figure out the generic (in file) libc.so and
1309 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1310 # was a separate library, afterwards it was merged into libc.so and
1311 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1312 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1313 case ${GLIBC_VERSION} in
1315   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1316   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1317   [
1318     AC_MSG_RESULT([no])
1319     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1320     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1321   ], [
1322     AC_MSG_RESULT([yes])
1323     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1324     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1325   ])
1326   ;;
1328   AC_MSG_CHECKING([not glibc...])
1329   AC_MSG_RESULT([${GLIBC_VERSION}])
1330   ;;
1331 esac
1333 AC_MSG_CHECKING([the glibc version])
1335 case "${GLIBC_VERSION}" in
1336      2.2)
1337         AC_MSG_RESULT(${GLIBC_VERSION} family)
1338         DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1339         DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1340         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1341         ;;
1342      2.[[3-6]])
1343         AC_MSG_RESULT(${GLIBC_VERSION} family)
1344         DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1345         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1346         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1347         ;;
1348      2.[[7-9]])
1349         AC_MSG_RESULT(${GLIBC_VERSION} family)
1350         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1351         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1352         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1353         ;;
1354      2.10|2.11)
1355         AC_MSG_RESULT(${GLIBC_VERSION} family)
1356         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1357                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1358         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1359         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1360         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1361         ;;
1362      2.*)
1363         AC_MSG_RESULT(${GLIBC_VERSION} family)
1364         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1365                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1366         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1367                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1368         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1369         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1370         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1371         ;;
1372      darwin)
1373         AC_MSG_RESULT(Darwin)
1374         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1375         # DEFAULT_SUPP set by kernel version check above.
1376         ;;
1377      freebsd)
1378         AC_MSG_RESULT(FreeBSD)
1379         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1380         # DEFAULT_SUPP set by kernel version check above.
1381         ;;
1382      bionic)
1383         AC_MSG_RESULT(Bionic)
1384         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1385         DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1386         ;;
1387      solaris)
1388         AC_MSG_RESULT(Solaris)
1389         # DEFAULT_SUPP set in host_os switch-case above.
1390         # No other suppression file is used.
1391         ;;
1392      musl)
1393         AC_MSG_RESULT(Musl)
1394         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1395         DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1396         ;;
1397      2.0|2.1|*)
1398         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1399         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1400         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1401         ;;
1402 esac
1404 AC_SUBST(GLIBC_VERSION)
1405 AC_SUBST(GLIBC_LIBC_PATH)
1406 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1409 if test "$VGCONF_OS" != "solaris"; then
1410     # Add default suppressions for the X client libraries.  Make no
1411     # attempt to detect whether such libraries are installed on the
1412     # build machine (or even if any X facilities are present); just
1413     # add the suppressions antidisirregardless.
1414     DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1415     DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1419 #----------------------------------------------------------------------------
1420 # Platform variants?
1421 #----------------------------------------------------------------------------
1423 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1424 # But there are times where we need a bit more control.  The motivating
1425 # and currently only case is Android: this is almost identical to
1426 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1427 # platform variant tags, which get passed in the compile as
1428 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1430 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1431 # it is "android" instead.
1433 # Consequently (eg), plain arm-linux would build with
1435 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1437 # whilst an Android build would have
1439 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1441 # Same for x86. The setup of the platform variant is pushed relatively far
1442 # down this file in order that we can inspect any of the variables set above.
1444 # In the normal case ..
1445 VGCONF_PLATVARIANT="vanilla"
1447 # Android ?
1448 if test "$GLIBC_VERSION" = "bionic";
1449 then
1450    VGCONF_PLATVARIANT="android"
1453 AC_SUBST(VGCONF_PLATVARIANT)
1456 # FIXME: do we also want to define automake variables
1457 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1458 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1459 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1460 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1461 # that's what we'd need to do to use this, since what we'd want to write
1462 # is something like
1464 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1466 # Hmm.  Can't think of a nice clean solution to this.
1468 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1469                test x$VGCONF_PLATVARIANT = xvanilla)
1470 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1471                test x$VGCONF_PLATVARIANT = xandroid)
1474 #----------------------------------------------------------------------------
1475 # Checking for various library functions and other definitions
1476 #----------------------------------------------------------------------------
1478 # Check for AT_FDCWD
1480 AC_MSG_CHECKING([for AT_FDCWD])
1481 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1482 #define _GNU_SOURCE
1483 #include <fcntl.h>
1484 #include <unistd.h>
1485 ]], [[
1486   int a = AT_FDCWD;
1487 ]])], [
1488 ac_have_at_fdcwd=yes
1489 AC_MSG_RESULT([yes])
1490 ], [
1491 ac_have_at_fdcwd=no
1492 AC_MSG_RESULT([no])
1495 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1497 # Check for stpncpy function definition in string.h
1498 # This explicitly checks with _GNU_SOURCE defined since that is also
1499 # used in the test case (some systems might define it without anyway
1500 # since stpncpy is part of The Open Group Base Specifications Issue 7
1501 # IEEE Std 1003.1-2008.
1502 AC_MSG_CHECKING([for stpncpy])
1503 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1504 #define _GNU_SOURCE
1505 #include <string.h>
1506 ]], [[
1507   char *d;
1508   char *s;
1509   size_t n = 0;
1510   char *r = stpncpy(d, s, n);
1511 ]])], [
1512 ac_have_gnu_stpncpy=yes
1513 AC_MSG_RESULT([yes])
1514 ], [
1515 ac_have_gnu_stpncpy=no
1516 AC_MSG_RESULT([no])
1519 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1521 # Check for PTRACE_GETREGS
1523 AC_MSG_CHECKING([for PTRACE_GETREGS])
1524 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1525 #include <stdlib.h>
1526 #include <stddef.h>
1527 #include <sys/ptrace.h>
1528 #include <sys/user.h>
1529 ]], [[
1530   void *p;
1531   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1532 ]])], [
1533 AC_MSG_RESULT([yes])
1534 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1535           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1536 ], [
1537 AC_MSG_RESULT([no])
1541 # Check for CLOCK_MONOTONIC
1543 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1545 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1546 #include <time.h>
1547 ]], [[
1548   struct timespec t;
1549   clock_gettime(CLOCK_MONOTONIC, &t);
1550   return 0;
1551 ]])], [
1552 AC_MSG_RESULT([yes])
1553 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1554           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1555 ], [
1556 AC_MSG_RESULT([no])
1560 # Check for ELF32/64_CHDR
1562 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1565 # Check for PTHREAD_RWLOCK_T
1567 AC_MSG_CHECKING([for pthread_rwlock_t])
1569 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1570 #define _GNU_SOURCE
1571 #include <pthread.h>
1572 ]], [[
1573   pthread_rwlock_t rwl;
1574 ]])], [
1575 AC_MSG_RESULT([yes])
1576 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1577           [Define to 1 if you have the `pthread_rwlock_t' type.])
1578 ], [
1579 AC_MSG_RESULT([no])
1582 # Check for CLOCKID_T
1584 AC_MSG_CHECKING([for clockid_t])
1586 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1587 #include <time.h>
1588 ]], [[
1589   clockid_t c;
1590 ]])], [
1591 AC_MSG_RESULT([yes])
1592 AC_DEFINE([HAVE_CLOCKID_T], 1,
1593           [Define to 1 if you have the `clockid_t' type.])
1594 ], [
1595 AC_MSG_RESULT([no])
1598 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1600 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1602 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1603 #define _GNU_SOURCE
1604 #include <pthread.h>
1605 ]], [[
1606   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1607 ]])], [
1608 AC_MSG_RESULT([yes])
1609 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1610           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1611 ], [
1612 AC_MSG_RESULT([no])
1616 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1618 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1620 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1621 #define _GNU_SOURCE
1622 #include <pthread.h>
1623 ]], [[
1624   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1625 ]])], [
1626 AC_MSG_RESULT([yes])
1627 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1628           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1629 ], [
1630 AC_MSG_RESULT([no])
1634 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1636 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1638 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1639 #define _GNU_SOURCE
1640 #include <pthread.h>
1641 ]], [[
1642   return (PTHREAD_MUTEX_RECURSIVE_NP);
1643 ]])], [
1644 AC_MSG_RESULT([yes])
1645 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1646           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1647 ], [
1648 AC_MSG_RESULT([no])
1652 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1654 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1656 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1657 #define _GNU_SOURCE
1658 #include <pthread.h>
1659 ]], [[
1660   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1661   return 0;
1662 ]])], [
1663 AC_MSG_RESULT([yes])
1664 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1665           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1666 ], [
1667 AC_MSG_RESULT([no])
1671 # Check whether pthread_mutex_t has a member called __m_kind.
1673 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1674                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1675                            1,                                   
1676                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1677                 ],
1678                 [],
1679                 [#include <pthread.h>])
1682 # Check whether pthread_mutex_t has a member called __data.__kind.
1684 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1685                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1686                           1,
1687                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1688                 ],
1689                 [],
1690                 [#include <pthread.h>])
1692 # Convenience function.  Set flags based on the existing HWCAP entries.
1693 # The AT_HWCAP entries are generated by glibc, and are based on
1694 # functions supported by the hardware/system/libc.
1695 # Subsequent support for whether the capability will actually be utilized
1696 # will also be checked against the compiler capabilities.
1697 # called as
1698 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1699 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1700   AUXV_CHECK_FOR=$1
1701   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1702   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1703   then
1704     AC_MSG_RESULT([yes])
1705     AC_SUBST([$2],[yes])
1706   else
1707     AC_MSG_RESULT([no])
1708     AC_SUBST([$2],[])
1709   fi
1712 # gather hardware capabilities. (hardware/kernel/libc)
1713 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1714 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1715 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1716 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1717 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1718 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1719 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1720 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1721 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1722 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1724 # ISA Levels
1725 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1726 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1727 # compiler support for isa 2.07 level instructions
1728 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1729 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1730 ]], [[
1731   __asm__ __volatile__("mtvsrd 1,2 ");
1732 ]])], [
1733 ac_asm_have_isa_2_07=yes
1734 AC_MSG_RESULT([yes])
1735 ], [
1736 ac_asm_have_isa_2_07=no
1737 AC_MSG_RESULT([no])
1739 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1740                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1742 # altivec (vsx) support.
1743 # does this compiler support -maltivec and does it have the include file
1744 # <altivec.h> ?
1745 AC_MSG_CHECKING([for Altivec support in the compiler ])
1746 safe_CFLAGS=$CFLAGS
1747 CFLAGS="-maltivec -Werror"
1748 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1749 #include <altivec.h>
1750 ]], [[
1751   vector unsigned int v;
1752 ]])], [
1753 ac_have_altivec=yes
1754 AC_MSG_RESULT([yes])
1755 ], [
1756 ac_have_altivec=no
1757 AC_MSG_RESULT([no])
1759 CFLAGS=$safe_CFLAGS
1760 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1761                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1763 # Check that both: the compiler supports -mvsx and that the assembler
1764 # understands VSX instructions.  If either of those doesn't work,
1765 # conclude that we can't do VSX.
1766 AC_MSG_CHECKING([for VSX compiler flag support])
1767 safe_CFLAGS=$CFLAGS
1768 CFLAGS="-mvsx -Werror"
1769 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1770 ]], [[
1771 ]])], [
1772 ac_compiler_supports_vsx_flag=yes
1773 AC_MSG_RESULT([yes])
1774 ], [
1775 ac_compiler_supports_vsx_flag=no
1776 AC_MSG_RESULT([no])
1778 CFLAGS=$safe_CFLAGS
1780 AC_MSG_CHECKING([for VSX support in the assembler ])
1781 safe_CFLAGS=$CFLAGS
1782 CFLAGS="-mvsx -Werror"
1783 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1784 #include <altivec.h>
1785 ]], [[
1786   vector unsigned int v;
1787   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1788 ]])], [
1789 ac_compiler_supports_vsx=yes
1790 AC_MSG_RESULT([yes])
1791 ], [
1792 ac_compiler_supports_vsx=no
1793 AC_MSG_RESULT([no])
1795 CFLAGS=$safe_CFLAGS
1796 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1797                              -a x$ac_compiler_supports_vsx = xyes \
1798                              -a x$HWCAP_HAS_VSX = xyes ])
1800 # DFP (Decimal Float)
1801 # The initial DFP support was added in Power 6.  The dcffix instruction
1802 # support was added in Power 7.
1803 AC_MSG_CHECKING([that assembler knows DFP])
1804 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1805 ]], [[
1806   #ifdef __s390__
1807   __asm__ __volatile__("adtr 1, 2, 3")
1808   #else
1809 __asm__ __volatile__(".machine power7;\n" \
1810   "dadd 1, 2, 3;\n" \
1811   "dcffix 1, 2");
1812   #endif
1813 ]])], [
1814 ac_asm_have_dfp=yes
1815 AC_MSG_RESULT([yes])
1816 ], [
1817 ac_asm_have_dfp=no
1818 AC_MSG_RESULT([no])
1820 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1821 safe_CFLAGS=$CFLAGS
1822 CFLAGS="-mhard-dfp -Werror"
1824 # The dcffix instruction is Power 7
1825 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1826 ]], [[
1827   #ifdef __s390__
1828   __asm__ __volatile__("adtr 1, 2, 3")
1829   #else
1830   __asm__ __volatile__(".machine power7;\n" \
1831   "dadd 1, 2, 3;\n" \
1832   "dcffix 1, 2");
1833   #endif
1834 ]])], [
1835 ac_compiler_have_dfp=yes
1836 AC_MSG_RESULT([yes])
1837 ], [
1838 ac_compiler_have_dfp=no
1839 AC_MSG_RESULT([no])
1841 CFLAGS=$safe_CFLAGS
1842 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1843                           -a x$ac_compiler_have_dfp = xyes \
1844                           -a x$HWCAP_HAS_DFP = xyes )
1846 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1847 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1848 ]], [[
1849   _Decimal64 x = 0.0DD;
1850 ]])], [
1851 ac_compiler_have_dfp_type=yes
1852 AC_MSG_RESULT([yes])
1853 ], [
1854 ac_compiler_have_dfp_type=no
1855 AC_MSG_RESULT([no])
1857 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1858                                   -a x$HWCAP_HAS_DFP = xyes )
1861 # HTM (Hardware Transactional Memory)
1862 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1863 safe_CFLAGS=$CFLAGS
1864 CFLAGS="-mhtm -Werror"
1865 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1866 ]], [[
1867   return 0;
1868 ]])], [
1869 AC_MSG_RESULT([yes])
1870 ac_compiler_supports_htm=yes
1871 ], [
1872 AC_MSG_RESULT([no])
1873 ac_compiler_supports_htm=no
1875 CFLAGS=$safe_CFLAGS
1877 AC_MSG_CHECKING([if compiler can find the htm builtins])
1878 safe_CFLAGS=$CFLAGS
1879 CFLAGS="-mhtm -Werror"
1880  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1881  ]], [[
1882    if (__builtin_tbegin (0))
1883       __builtin_tend (0);
1884  ]])], [
1885  AC_MSG_RESULT([yes])
1886 ac_compiler_sees_htm_builtins=yes
1887  ], [
1888  AC_MSG_RESULT([no])
1889 ac_compiler_sees_htm_builtins=no
1890  ])
1891 CFLAGS=$safe_CFLAGS
1893 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1894                                -a x$ac_compiler_sees_htm_builtins = xyes \
1895                                -a x$HWCAP_HAS_HTM = xyes )
1897 # isa 3.0 checking. (actually 3.0 or newer)
1898 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1900 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1901 ]], [[
1902 __asm__ __volatile__ (".machine power9;\n" \
1903         "cnttzw   1,3; \n" );
1904 ]])], [
1905 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1906 # cpabort support
1907 safe_CFLAGS=$CFLAGS
1908 CFLAGS="-DHAS_ISA_3_00"
1909 ac_asm_have_isa_3_00=yes
1910 AC_MSG_RESULT([yes])
1911 ], [
1912 ac_asm_have_isa_3_00=no
1913 AC_MSG_RESULT([no])
1915 CFLAGS=$safe_CFLAGS
1917 # xscvhpdp checking
1918 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1920 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1921 ]], [[
1922 __asm__ __volatile__ (".machine power9;\n" \
1923         "xscvhpdp 1,2;\n" );
1924 ]])], [
1925 ac_asm_have_xscvhpdp=yes
1926 AC_MSG_RESULT([yes])
1927 ], [
1928 ac_asm_have_xscvhpdp=no
1929 AC_MSG_RESULT([no])
1932 # darn instruction checking
1933 AC_MSG_CHECKING([that assembler knows darn instruction ])
1935 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1936 ]], [[
1937   __asm__ __volatile__(".machine power9; darn 1,0 ");
1938 ]])], [
1939 ac_asm_have_darn_inst=yes
1940 AC_MSG_RESULT([yes])
1941 ], [
1942 ac_asm_have_darn_inst=no
1943 AC_MSG_RESULT([no])
1946 # isa 3.01 checking
1947 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1948 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1949 ]], [[
1950 __asm__ __volatile__ (".machine power10;\n" \
1951         "brh 1,2;\n ");
1952 ]])], [
1953 ac_asm_have_isa_3_1=yes
1954 AC_MSG_RESULT([yes])
1955 ], [
1956 ac_asm_have_isa_3_1=no
1957 AC_MSG_RESULT([no])
1961 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1962                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1964 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1965 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1967 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1968                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1970 # Check for pthread_create@GLIBC2.0
1971 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1973 safe_CFLAGS=$CFLAGS
1974 CFLAGS="-lpthread -Werror"
1975 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1976 extern int pthread_create_glibc_2_0(void*, const void*,
1977                                     void *(*)(void*), void*);
1978 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1979 ]], [[
1980 #ifdef __powerpc__
1982  * Apparently on PowerPC linking this program succeeds and generates an
1983  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1984  */
1985 #error This test does not work properly on PowerPC.
1986 #else
1987   pthread_create_glibc_2_0(0, 0, 0, 0);
1988 #endif
1989   return 0;
1990 ]])], [
1991 ac_have_pthread_create_glibc_2_0=yes
1992 AC_MSG_RESULT([yes])
1993 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1994           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1995 ], [
1996 ac_have_pthread_create_glibc_2_0=no
1997 AC_MSG_RESULT([no])
1999 CFLAGS=$safe_CFLAGS
2001 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
2002                test x$ac_have_pthread_create_glibc_2_0 = xyes)
2005 # Check for dlinfo RTLD_DI_TLS_MODID
2006 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
2008 safe_LIBS="$LIBS"
2009 LIBS="-ldl"
2010 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2011 #ifndef _GNU_SOURCE
2012 #define _GNU_SOURCE
2013 #endif
2014 #include <link.h>
2015 #include <dlfcn.h>
2016 ]], [[
2017   size_t sizes[10000];
2018   size_t modid_offset;
2019   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
2020   return 0;
2021 ]])], [
2022 ac_have_dlinfo_rtld_di_tls_modid=yes
2023 AC_MSG_RESULT([yes])
2024 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
2025           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
2026 ], [
2027 ac_have_dlinfo_rtld_di_tls_modid=no
2028 AC_MSG_RESULT([no])
2030 LIBS=$safe_LIBS
2032 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
2033                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
2036 # Check for eventfd_t, eventfd() and eventfd_read()
2037 AC_MSG_CHECKING([for eventfd()])
2039 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2040 #include <sys/eventfd.h>
2041 ]], [[
2042   eventfd_t ev;
2043   int fd;
2045   fd = eventfd(5, 0);
2046   eventfd_read(fd, &ev);
2047   return 0;
2048 ]])], [
2049 AC_MSG_RESULT([yes])
2050 AC_DEFINE([HAVE_EVENTFD], 1,
2051           [Define to 1 if you have the `eventfd' function.])
2052 AC_DEFINE([HAVE_EVENTFD_READ], 1,
2053           [Define to 1 if you have the `eventfd_read' function.])
2054 ], [
2055 AC_MSG_RESULT([no])
2058 # Check whether compiler can process #include <thread> without errors
2059 # clang 3.3 cannot process <thread> from e.g.
2060 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
2062 AC_MSG_CHECKING([that C++ compiler can compile C++17 code])
2063 AC_LANG(C++)
2064 safe_CXXFLAGS=$CXXFLAGS
2065 CXXFLAGS=-std=c++17
2067 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2068 int x;
2069 ])],
2071 ac_have_cxx_17=yes
2072 AC_MSG_RESULT([yes])
2073 ], [
2074 ac_have_cxx_17=no
2075 AC_MSG_RESULT([no])
2077 CXXFLAGS=$safe_CXXFLAGS
2078 AC_LANG(C)
2080 AM_CONDITIONAL(HAVE_CXX17, test x$ac_have_cxx_17 = xyes)
2082 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
2083 AC_LANG(C++)
2084 safe_CXXFLAGS=$CXXFLAGS
2085 CXXFLAGS=-std=c++0x
2087 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2088 #include <thread> 
2089 ])],
2091 ac_cxx_can_include_thread_header=yes
2092 AC_MSG_RESULT([yes])
2093 ], [
2094 ac_cxx_can_include_thread_header=no
2095 AC_MSG_RESULT([no])
2097 CXXFLAGS=$safe_CXXFLAGS
2098 AC_LANG(C)
2100 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2102 # Check whether compiler can process #include <condition_variable> without errors
2104 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2105 AC_LANG(C++)
2106 safe_CXXFLAGS=$CXXFLAGS
2107 CXXFLAGS=-std=c++0x
2109 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2110 #include <condition_variable> 
2111 ])],
2113 ac_cxx_can_include_condition_variable_header=yes
2114 AC_MSG_RESULT([yes])
2115 ], [
2116 ac_cxx_can_include_condition_variable_header=no
2117 AC_MSG_RESULT([no])
2119 CXXFLAGS=$safe_CXXFLAGS
2120 AC_LANG(C)
2122 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2124 # check for std::shared_timed_mutex, this is a C++ 14 feature
2126 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2127 AC_LANG(C++)
2128 safe_CXXFLAGS=$CXXFLAGS
2129 CXXFLAGS="-std=c++1y -pthread"
2131 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2132 #include <shared_mutex>
2133 std::shared_timed_mutex test_mutex;
2134 ])],
2136 ac_cxx_can_use_shared_timed_mutex=yes
2137 AC_MSG_RESULT([yes])
2138 ], [
2139 ac_cxx_can_use_shared_timed_mutex=no
2140 AC_MSG_RESULT([no])
2142 CXXFLAGS=$safe_CXXFLAGS
2143 AC_LANG(C)
2145 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2147 # check for std::shared_mutex, this is a C++ 11 feature
2149 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2150 AC_LANG(C++)
2151 safe_CXXFLAGS=$CXXFLAGS
2152 CXXFLAGS="-std=c++0x -pthread"
2154 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2155 #include <mutex>
2156 std::timed_mutex test_mutex;
2157 ])],
2159 ac_cxx_can_use_timed_mutex=yes
2160 AC_MSG_RESULT([yes])
2161 ], [
2162 ac_cxx_can_use_timed_mutex=no
2163 AC_MSG_RESULT([no])
2165 CXXFLAGS=$safe_CXXFLAGS
2166 AC_LANG(C)
2168 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2170 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2171 # of the user_regs_struct from sys/user.h. They are structurally the same
2172 # but we get either one or the other.
2174 AC_CHECK_TYPE([struct user_regs_struct],
2175               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2176               [[#include <sys/ptrace.h>]
2177                [#include <sys/time.h>]
2178                [#include <sys/user.h>]])
2179 if test "$sys_user_has_user_regs" = "yes"; then
2180   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2181             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2184 AC_MSG_CHECKING([for __NR_membarrier])
2185 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2186 #include <linux/unistd.h>
2187 ]], [[
2188 return __NR_membarrier
2189 ]])], [
2190 ac_have_nr_membarrier=yes
2191 AC_MSG_RESULT([yes])
2192 ], [
2193 ac_have_nr_membarrier=no
2194 AC_MSG_RESULT([no])
2197 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2199 #----------------------------------------------------------------------------
2200 # Checking for supported compiler flags.
2201 #----------------------------------------------------------------------------
2203 case "${host_cpu}" in
2204     mips*)
2205         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2206         if test -z "$ARCH"; then
2207           # does this compiler support -march=mips32 (mips32 default) ?
2208           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2210           safe_CFLAGS=$CFLAGS
2211           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2213           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2214             return 0;
2215           ]])], [
2216           FLAG_M32="-mips32 -mabi=32"
2217           AC_MSG_RESULT([yes])
2218           ], [
2219           FLAG_M32=""
2220           AC_MSG_RESULT([no])
2221           ])
2222           CFLAGS=$safe_CFLAGS
2224           AC_SUBST(FLAG_M32)
2227           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2228           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2230           safe_CFLAGS=$CFLAGS
2231           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2233           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2234             return 0;
2235           ]])], [
2236           FLAG_M64="-march=mips64r2 -mabi=64"
2237           AC_MSG_RESULT([yes])
2238           ], [
2239           FLAG_M64=""
2240           AC_MSG_RESULT([no])
2241           ])
2242           CFLAGS=$safe_CFLAGS
2244           AC_SUBST(FLAG_M64)
2245         fi
2246         ;;
2247     nanomips*)
2248         ;;
2249     *)
2250         # does this compiler support -m32 ?
2251         AC_MSG_CHECKING([if gcc accepts -m32])
2253         safe_CFLAGS=$CFLAGS
2254         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2256         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2257           return 0;
2258         ]])], [
2259         FLAG_M32="${FLAG_32ON64} -m32"
2260         AC_MSG_RESULT([yes])
2261         ], [
2262         FLAG_M32=""
2263         AC_MSG_RESULT([no])
2264         ])
2265         CFLAGS=$safe_CFLAGS
2267         AC_SUBST(FLAG_M32)
2270         # does this compiler support -m64 ?
2271         AC_MSG_CHECKING([if gcc accepts -m64])
2273         safe_CFLAGS=$CFLAGS
2274         CFLAGS="-m64 -Werror"
2276         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2277           return 0;
2278         ]])], [
2279         FLAG_M64="-m64"
2280         AC_MSG_RESULT([yes])
2281         ], [
2282         FLAG_M64=""
2283         AC_MSG_RESULT([no])
2284         ])
2285         CFLAGS=$safe_CFLAGS
2287         AC_SUBST(FLAG_M64)
2288         ;;
2289 esac
2292 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2293 if test -z "$ARCH"; then
2294   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2295   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2297   safe_CFLAGS=$CFLAGS
2298   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2300   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2301     return 0;
2302   ]])], [
2303   FLAG_OCTEON="-march=octeon"
2304   AC_MSG_RESULT([yes])
2305   ], [
2306   FLAG_OCTEON=""
2307   AC_MSG_RESULT([no])
2308   ])
2309   CFLAGS=$safe_CFLAGS
2311   AC_SUBST(FLAG_OCTEON)
2314   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2315   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2317   safe_CFLAGS=$CFLAGS
2318   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2320   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2321     return 0;
2322   ]])], [
2323   FLAG_OCTEON2="-march=octeon2"
2324   AC_MSG_RESULT([yes])
2325   ], [
2326   FLAG_OCTEON2=""
2327   AC_MSG_RESULT([no])
2328   ])
2329   CFLAGS=$safe_CFLAGS
2331   AC_SUBST(FLAG_OCTEON2)
2335 # does this compiler support -mmsa (MIPS MSA ASE) ?
2336 AC_MSG_CHECKING([if gcc accepts -mmsa])
2338 safe_CFLAGS=$CFLAGS
2339 CFLAGS="$CFLAGS -mmsa -Werror"
2341 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2342     return 0;
2343 ]])], [
2344 FLAG_MSA="-mmsa"
2345 AC_MSG_RESULT([yes])
2346 ], [
2347 FLAG_MSA=""
2348 AC_MSG_RESULT([no])
2350 CFLAGS=$safe_CFLAGS
2352 AC_SUBST(FLAG_MSA)
2354 # Are we compiling for the MIPS64 n32 ABI?
2355 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2356 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2357 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2358 #error NO
2359 #endif
2360 ]])], [
2361 VGCONF_ABI=N32
2362 FLAG_M64="-march=mips64r2 -mabi=n32"
2363 AC_MSG_RESULT([yes])
2364 ], [
2365 AC_MSG_RESULT([no])
2368 # Are we compiling for the MIPS64 n64 ABI?
2369 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2370 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2371 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2372 #error NO
2373 #endif
2374 ]])], [
2375 VGCONF_ABI=64
2376 AC_MSG_RESULT([yes])
2377 ], [
2378 AC_MSG_RESULT([no])
2381 # We enter the code block below in the following case:
2382 # Target architecture is set to mips64, the desired abi
2383 # was not specified and the compiler's default abi setting
2384 # is neither n32 nor n64.
2385 # Probe for and set the abi to either n64 or n32, in that order,
2386 # which is required for a mips64 build of valgrind.
2387 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2388   safe_CFLAGS=$CFLAGS
2389   CFLAGS="$CFLAGS -mabi=64 -Werror"
2390   AC_MSG_CHECKING([if gcc is n64 capable])
2391   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2392       return 0;
2393   ]])], [
2394   VGCONF_ABI=64
2395   AC_MSG_RESULT([yes])
2396   ], [
2397   AC_MSG_RESULT([no])
2398   ])
2399   CFLAGS=$safe_CFLAGS
2401   if test "x$VGCONF_ABI" = "x"; then
2402     safe_CFLAGS=$CFLAGS
2403     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2404     AC_MSG_CHECKING([if gcc is n32 capable])
2405     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2406         return 0;
2407     ]])], [
2408     VGCONF_ABI=N32
2409     FLAG_M64="-march=mips64r2 -mabi=n32"
2410     AC_MSG_RESULT([yes])
2411     ], [
2412     AC_MSG_RESULT([no])
2413     ])
2414     CFLAGS=$safe_CFLAGS
2415   fi
2418 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2419                [test x$VGCONF_ABI != x])
2420 AC_SUBST(VGCONF_ABI)
2423 # does this compiler support -mmmx ?
2424 AC_MSG_CHECKING([if gcc accepts -mmmx])
2426 safe_CFLAGS=$CFLAGS
2427 CFLAGS="-mmmx -Werror"
2429 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2430   return 0;
2431 ]])], [
2432 FLAG_MMMX="-mmmx"
2433 AC_MSG_RESULT([yes])
2434 ], [
2435 FLAG_MMMX=""
2436 AC_MSG_RESULT([no])
2438 CFLAGS=$safe_CFLAGS
2440 AC_SUBST(FLAG_MMMX)
2443 # does this compiler support -msse ?
2444 AC_MSG_CHECKING([if gcc accepts -msse])
2446 safe_CFLAGS=$CFLAGS
2447 CFLAGS="-msse -Werror"
2449 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2450   return 0;
2451 ]])], [
2452 FLAG_MSSE="-msse"
2453 AC_MSG_RESULT([yes])
2454 ], [
2455 FLAG_MSSE=""
2456 AC_MSG_RESULT([no])
2458 CFLAGS=$safe_CFLAGS
2460 AC_SUBST(FLAG_MSSE)
2463 # does this compiler support -mpreferred-stack-boundary=2 when
2464 # generating code for a 32-bit target?  Note that we only care about
2465 # this when generating code for (32-bit) x86, so if the compiler
2466 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2467 # the Memcheck and other helper functions, that is a bit slower than
2468 # it could be, on x86; and no difference at all on any other platform.
2469 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2471 safe_CFLAGS=$CFLAGS
2472 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2474 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2475   return 0;
2476 ]])], [
2477 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2478 AC_MSG_RESULT([yes])
2479 ], [
2480 PREFERRED_STACK_BOUNDARY_2=""
2481 AC_MSG_RESULT([no])
2483 CFLAGS=$safe_CFLAGS
2485 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2488 # does this compiler support -mlong-double-128 ?
2489 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2490 safe_CFLAGS=$CFLAGS
2491 CFLAGS="-mlong-double-128 -Werror"
2492 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2493   return 0;
2494 ]])], [
2495 ac_compiler_supports_mlong_double_128=yes
2496 AC_MSG_RESULT([yes])
2497 ], [
2498 ac_compiler_supports_mlong_double_128=no
2499 AC_MSG_RESULT([no])
2501 CFLAGS=$safe_CFLAGS
2502 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2503 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2504 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2506 # does this toolchain support lto ?
2507 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2508 # are not defined
2509 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2510 # a lot slower, and so not appropriate for Valgrind developments.
2511 # --enable-lto=yes should be used by distro packagers.
2512 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2513    [AC_ARG_ENABLE(lto,
2514       [  --enable-lto          enables building with link time optimisation],
2515       [vg_cv_lto=$enableval],
2516       [vg_cv_lto=no])])
2518 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2519 AC_MSG_CHECKING([if toolchain accepts lto])
2520 safe_CFLAGS=$CFLAGS
2521 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2522 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2523 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2524 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2527   extern void somefun(void);
2528   somefun();
2529   return 0;
2530 ]])], [
2531 LTO_CFLAGS=$TEST_LTO_CFLAGS
2532 AC_MSG_RESULT([yes])
2533 ], [
2534 LTO_CFLAGS=""
2535 AC_MSG_RESULT([no])
2537 CFLAGS=$safe_CFLAGS
2540 AC_SUBST(LTO_CFLAGS)
2542 # if we could not compile with lto args, or lto was disabled,
2543 # then set LTO_AR/LTO_RANLIB to the non lto values
2544 # define in config.h ENABLE_LTO (not needed by the code currently, but
2545 # this guarantees we recompile everything if we re-configure and rebuild
2546 # in a build dir previously build with another value of --enable-lto
2547 if test "x${LTO_CFLAGS}" = "x"; then
2548    LTO_AR=${AR}
2549    LTO_RANLIB=${RANLIB}
2550    vg_cv_lto=no
2551 else
2552    vg_cv_lto=yes
2553    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2556 # Convenience function to check whether GCC supports a particular
2557 # warning option. Takes two arguments,
2558 # first the warning flag name to check (without -W), then the
2559 # substitution name to set with -Wno-warning-flag if the flag exists,
2560 # or the empty string if the compiler doesn't accept the flag. Note
2561 # that checking is done against the warning flag itself, but the
2562 # substitution is then done to cancel the warning flag.
2563 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2564   AC_MSG_CHECKING([if gcc accepts -W$1])
2565   safe_CFLAGS=$CFLAGS
2566   CFLAGS="-W$1 -Werror"
2567   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2568   AC_SUBST([$2], [-Wno-$1])
2569   AC_MSG_RESULT([yes])], [
2570   AC_SUBST([$2], [])
2571   AC_MSG_RESULT([no])])
2572   CFLAGS=$safe_CFLAGS
2575 # A variation of the above for arguments that
2576 # take a value
2577 AC_DEFUN([AC_GCC_WARNING_SUBST_NO_VAL],[
2578   AC_MSG_CHECKING([if gcc accepts -W$1=$2])
2579   safe_CFLAGS=$CFLAGS
2580   CFLAGS="-W$1=$2 -Werror"
2581   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2582   AC_SUBST([$3], [-Wno-$1])
2583   AC_MSG_RESULT([yes])], [
2584   AC_SUBST([$3], [])
2585   AC_MSG_RESULT([no])])
2586   CFLAGS=$safe_CFLAGS
2589 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2590 # -W$1  (instead of -Wno-$1).
2591 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2592   AC_MSG_CHECKING([if gcc accepts -W$1])
2593   safe_CFLAGS=$CFLAGS
2594   CFLAGS="-W$1 -Werror"
2595   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2596   AC_SUBST([$2], [-W$1])
2597   AC_MSG_RESULT([yes])], [
2598   AC_SUBST([$2], [])
2599   AC_MSG_RESULT([no])])
2600   CFLAGS=$safe_CFLAGS
2603 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2604 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2605 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2606 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2607 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2608 AC_GCC_WARNING_SUBST_NO([maybe-uninitialized], [FLAG_W_NO_MAYBE_UNINITIALIZED])
2609 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2610 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2611 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2612 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2613 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2614 AC_GCC_WARNING_SUBST_NO([unused-variable], [FLAG_W_NO_UNUSED_VARIABLE])
2615 AC_GCC_WARNING_SUBST_NO([unused-but-set-variable], [FLAG_W_NO_UNUSED_BUT_SET_VARIABLE])
2616 AC_GCC_WARNING_SUBST_NO([non-power-of-two-alignment], [FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT])
2617 AC_GCC_WARNING_SUBST_NO([sign-compare], [FLAG_W_NO_SIGN_COMPARE])
2618 AC_GCC_WARNING_SUBST_NO([stringop-overflow], [FLAG_W_NO_STRINGOP_OVERFLOW])
2619 AC_GCC_WARNING_SUBST_NO([stringop-overread], [FLAG_W_NO_STRINGOP_OVERREAD])
2620 AC_GCC_WARNING_SUBST_NO([stringop-truncation], [FLAG_W_NO_STRINGOP_TRUNCATION])
2621 AC_GCC_WARNING_SUBST_NO([format-overflow], [FLAG_W_NO_FORMAT_OVERFLOW])
2622 AC_GCC_WARNING_SUBST_NO([use-after-free], [FLAG_W_NO_USE_AFTER_FREE])
2623 AC_GCC_WARNING_SUBST_NO([free-nonheap-object], [FLAG_W_NO_FREE_NONHEAP_OBJECT])
2624 AC_GCC_WARNING_SUBST_NO([fortify-source], [FLAG_W_NO_FORTIFY_SOURCE])
2625 AC_GCC_WARNING_SUBST_NO([builtin-memcpy-chk-size], [FLAG_W_NO_BUILTIN_MEMCPY_CHK_SIZE])
2626 AC_GCC_WARNING_SUBST_NO([incompatible-pointer-types-discards-qualifiers], [FLAG_W_NO_INCOMPATIBLE_POINTER_TYPES_DISCARDS_QUALIFIERS])
2627 AC_GCC_WARNING_SUBST_NO([suspicious-bzero], [FLAG_W_NO_SUSPICIOUS_BZERO])
2628 AC_GCC_WARNING_SUBST_NO([attributes], [FLAG_W_NO_ATTRIBUTES])
2630 AC_GCC_WARNING_SUBST_NO_VAL([alloc-size-larger-than], [1677216], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN])
2632 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2633 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2634 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2635 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2636 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2637 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2638 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2639 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2640 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2641 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2642 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2644 # Does this compiler support -Wformat-security ?
2645 # Special handling is needed, because certain GCC versions require -Wformat
2646 # being present if -Wformat-security is given. Otherwise a warning is issued.
2647 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2648 # And with that the warning will be turned into an error with the result
2649 # that -Wformat-security is believed to be unsupported when in fact it is.
2650 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2651 safe_CFLAGS=$CFLAGS
2652 CFLAGS="-Wformat -Wformat-security -Werror"
2653 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2654 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2655 AC_MSG_RESULT([yes])], [
2656 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2657 AC_MSG_RESULT([no])])
2658 CFLAGS=$safe_CFLAGS
2660 # does this compiler support -Wextra or the older -W ?
2662 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2664 safe_CFLAGS=$CFLAGS
2665 CFLAGS="-Wextra -Werror"
2667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2668   return 0;
2669 ]])], [
2670 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2671 AC_MSG_RESULT([-Wextra])
2672 ], [
2673   CFLAGS="-W -Werror"
2674   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2675     return 0;
2676   ]])], [
2677   AC_SUBST([FLAG_W_EXTRA], [-W])
2678   AC_MSG_RESULT([-W])
2679   ], [
2680   AC_SUBST([FLAG_W_EXTRA], [])
2681   AC_MSG_RESULT([not supported])
2682   ])
2684 CFLAGS=$safe_CFLAGS
2686 # On ARM we do not want to pass -Wcast-align as that produces loads
2687 # of warnings. GCC is just being conservative. See here:
2688 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2689 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2690   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2691 else
2692   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2695 # does this compiler support -faligned-new ?
2696 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2698 safe_CXXFLAGS=$CXXFLAGS
2699 CXXFLAGS="-faligned-new -Werror"
2701 AC_LANG(C++)
2702 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2703   return 0;
2704 ]])], [
2705 FLAG_FALIGNED_NEW="-faligned-new"
2706 AC_MSG_RESULT([yes])
2707 ], [
2708 FLAG_FALIGNED_NEW=""
2709 AC_MSG_RESULT([no])
2711 CXXFLAGS=$safe_CXXFLAGS
2712 AC_LANG(C)
2714 AC_SUBST(FLAG_FALIGNED_NEW)
2716 # does this compiler support -fsized-deallocation ?
2717 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2719 safe_CXXFLAGS=$CXXFLAGS
2720 CXXFLAGS="-fsized-deallocation -Werror"
2722 AC_LANG(C++)
2723 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2724   return 0;
2725 ]])], [
2726 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2727 ac_have_sized_deallocation=yes
2728 AC_MSG_RESULT([yes])
2729 ], [
2730 FLAG_FSIZED_DEALLOCATION=""
2731 ac_have_sized_deallocation=no
2732 AC_MSG_RESULT([no])
2734 CXXFLAGS=$safe_CXXFLAGS
2735 AC_LANG(C)
2737 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2738 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2740 # does this compiler support C++17 aligned new/delete?
2741 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2743 safe_CXXFLAGS=$CXXFLAGS
2744 CXXFLAGS="-std=c++17"
2746 AC_LANG(C++)
2747 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2748 #include <cstdlib>
2749 #include <new>
2750 ]], [[
2751   operator delete(nullptr, std::align_val_t(64U));
2752 ]])], [
2753 ac_have_aligned_cxx_alloc=yes
2754 AC_MSG_RESULT([yes])
2755 ], [
2756 ac_have_aligned_cxx_alloc=no
2757 AC_MSG_RESULT([no])
2759 CXXFLAGS=$safe_CXXFLAGS
2760 AC_LANG(C)
2762 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2764 # does this compiler support -fno-stack-protector ?
2765 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2767 safe_CFLAGS=$CFLAGS
2768 CFLAGS="-fno-stack-protector -Werror"
2770 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2771   return 0;
2772 ]])], [
2773 no_stack_protector=yes
2774 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2775 AC_MSG_RESULT([yes])
2776 ], [
2777 no_stack_protector=no
2778 FLAG_FNO_STACK_PROTECTOR=""
2779 AC_MSG_RESULT([no])
2781 CFLAGS=$safe_CFLAGS
2783 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2785 # does this compiler support -finline-functions ?
2786 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2788 safe_CFLAGS=$CFLAGS
2789 CFLAGS="-finline-functions -Werror"
2791 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2792   return 0;
2793 ]])], [
2794 inline_functions=yes
2795 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2796 AC_MSG_RESULT([yes])
2797 ], [
2798 inline_functions=no
2799 FLAG_FINLINE_FUNCTIONS=""
2800 AC_MSG_RESULT([no])
2802 CFLAGS=$safe_CFLAGS
2804 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2806 # Does GCC support disabling Identical Code Folding?
2807 # We want to disabled Identical Code Folding for the
2808 # tools preload shared objects to get better backraces.
2809 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2810 # "The optimization reduces code size and may disturb
2811 #  unwind stacks by replacing a function by equivalent
2812 #  one with a different name."
2813 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2815 safe_CFLAGS=$CFLAGS
2816 CFLAGS="-fno-ipa-icf -Werror"
2818 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2819   return 0;
2820 ]])], [
2821 no_ipa_icf=yes
2822 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2823 AC_MSG_RESULT([yes])
2824 ], [
2825 no_ipa_icf=no
2826 FLAG_FNO_IPA_ICF=""
2827 AC_MSG_RESULT([no])
2829 CFLAGS=$safe_CFLAGS
2831 AC_SUBST(FLAG_FNO_IPA_ICF)
2834 # Does this compiler support -fsanitize=undefined. This is true for
2835 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2836 # also checks for alignment violations on memory accesses which the valgrind
2837 # code base is sprinkled (if not littered) with. As those alignment issues
2838 # don't pose a problem we want to suppress warnings about them.
2839 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2840 # GCCs do not support that.
2842 # Only checked for if --enable-ubsan was given.
2843 if test "x${vg_cv_ubsan}" = "xyes"; then
2844 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2845 safe_CFLAGS=$CFLAGS
2846 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2847 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2848   return 0;
2849 ]])], [
2850 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2851 LIB_UBSAN="-static-libubsan"
2852 AC_MSG_RESULT([yes])
2853 ], [
2854 CFLAGS="-fsanitize=undefined -Werror"
2855 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2856   return 0;
2857 ]])], [
2858 FLAG_FSANITIZE="-fsanitize=undefined"
2859 LIB_UBSAN="-static-libubsan"
2860 AC_MSG_RESULT([yes])
2861 ], [
2862 FLAG_FSANITIZE=""
2863 LIB_UBSAN=""
2864 AC_MSG_RESULT([no])
2867 CFLAGS=$safe_CFLAGS
2868 AC_SUBST(FLAG_FSANITIZE)
2869 AC_SUBST(LIB_UBSAN)
2871 # does this compiler support --param inline-unit-growth=... ?
2873 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2875 safe_CFLAGS=$CFLAGS
2876 CFLAGS="--param inline-unit-growth=900 -Werror"
2878 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2879   return 0;
2880 ]])], [
2881 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2882          ["--param inline-unit-growth=900"])
2883 AC_MSG_RESULT([yes])
2884 ], [
2885 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2886 AC_MSG_RESULT([no])
2888 CFLAGS=$safe_CFLAGS
2891 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2893 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2895 safe_CFLAGS=$CFLAGS
2896 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2898 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2899   return 0;
2900 ]])], [
2901 ac_have_dwarf4=yes
2902 AC_MSG_RESULT([yes])
2903 ], [
2904 ac_have_dwarf4=no
2905 AC_MSG_RESULT([no])
2907 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2908 CFLAGS=$safe_CFLAGS
2911 # does this compiler support -g -gz=zlib ?
2913 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2915 safe_CFLAGS=$CFLAGS
2916 CFLAGS="-g -gz=zlib"
2918 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2919   return 0;
2920 ]])], [
2921 ac_have_gz_zlib=yes
2922 AC_MSG_RESULT([yes])
2923 ], [
2924 ac_have_gz_zlib=no
2925 AC_MSG_RESULT([no])
2927 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2928 CFLAGS=$safe_CFLAGS
2931 # does this compiler support -g -gz=zlib-gnu ?
2933 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2935 safe_CFLAGS=$CFLAGS
2936 CFLAGS="-g -gz=zlib-gnu"
2938 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2939   return 0;
2940 ]])], [
2941 ac_have_gz_zlib_gnu=yes
2942 AC_MSG_RESULT([yes])
2943 ], [
2944 ac_have_gz_zlib_gnu=no
2945 AC_MSG_RESULT([no])
2947 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2948 CFLAGS=$safe_CFLAGS
2951 # does this compiler support nested functions ?
2953 AC_MSG_CHECKING([if gcc accepts nested functions])
2955 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2956   int foo() { return 1; }
2957   return foo();
2958 ]])], [
2959 ac_have_nested_functions=yes
2960 AC_MSG_RESULT([yes])
2961 ], [
2962 ac_have_nested_functions=no
2963 AC_MSG_RESULT([no])
2965 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2968 # does this compiler support the 'p' constraint in ASM statements ?
2970 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2972 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2973    char *p;
2974    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2975 ]])], [
2976 ac_have_asm_constraint_p=yes
2977 AC_MSG_RESULT([yes])
2978 ], [
2979 ac_have_asm_constraint_p=no
2980 AC_MSG_RESULT([no])
2982 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2985 # Does this compiler and linker support -pie?
2986 # Some compilers actually do not support -pie and report its usage
2987 # as an error. We need to check if it is safe to use it first.
2989 AC_MSG_CHECKING([if gcc accepts -pie])
2991 safe_CFLAGS=$CFLAGS
2992 CFLAGS="-pie"
2994 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2995   return 0;
2996 ]])], [
2997 AC_SUBST([FLAG_PIE], ["-pie"])
2998 AC_MSG_RESULT([yes])
2999 ], [
3000 AC_SUBST([FLAG_PIE], [""])
3001 AC_MSG_RESULT([no])
3003 CFLAGS=$safe_CFLAGS
3005 AC_MSG_CHECKING([if gcc accepts -ansi])
3007 safe_CFLAGS=$CFLAGS
3008 CFLAGS="-ansi"
3010 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3011    return 0;
3012 ]])], [
3013 ac_have_ansi=yes
3014 AC_MSG_RESULT([yes])
3015 ], [
3016 ac_have_ansi=no
3017 AC_MSG_RESULT([no])
3019 AM_CONDITIONAL([HAVE_ANSI], [test x$ac_have_ansi = xyes])
3021 CFLAGS=$safe_CFLAGS
3024 # Does this compiler support -no-pie?
3025 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
3026 # default. However this gets in the way with some tests, we use -no-pie
3027 # for these.
3029 AC_MSG_CHECKING([if gcc accepts -no-pie])
3031 safe_CFLAGS=$CFLAGS
3032 CFLAGS="-no-pie -Werror"
3034 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
3035   return 0;
3036 ]])], [
3037 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
3038 AC_MSG_RESULT([yes])
3039 ], [
3040 AC_SUBST([FLAG_NO_PIE], [""])
3041 AC_MSG_RESULT([no])
3043 CFLAGS=$safe_CFLAGS
3046 # We want to use use the -Ttext-segment option to the linker.
3047 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
3048 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
3049 # semantics are NOT what we want (GNU gold -Ttext is fine).
3051 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
3052 # will reside. -Ttext aligns just the .text section start (but not any
3053 # other section).
3055 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
3056 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
3057 # The --image-base option (since version 6.0?) provides the semantics needed.
3058 # -Ttext-segment generates an error, but -Ttext now more closely
3059 # follows the GNU (bfd) ld's -Ttext.
3061 # So test first for --image-base support, and if that fails then
3062 # for -Ttext-segment which is supported by all bfd ld versions
3063 # and use that if it exists. If it doesn't exist it must be an older
3064 # version of gold and we can fall back to using -Ttext which has the
3065 # right semantics.
3067 safe_CFLAGS=$CFLAGS
3068 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
3070 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
3072 AC_LINK_IFELSE(
3073 [AC_LANG_SOURCE([int _start () { return 0; }])],
3075   linker_using_t_text="no"
3076   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
3077   AC_MSG_RESULT([yes])
3078 ], [
3079   AC_MSG_RESULT([no])
3081   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
3083   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
3085   AC_LINK_IFELSE(
3086   [AC_LANG_SOURCE([int _start () { return 0; }])],
3087   [
3088     linker_using_t_text="no"
3089     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
3090     AC_MSG_RESULT([yes])
3091   ], [
3092     linker_using_t_text="yes"
3093     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
3094     AC_MSG_RESULT([no])
3095   ])
3098 CFLAGS=$safe_CFLAGS
3100 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
3101 # have to strip any build-id ELF NOTEs from the statically linked tools.
3102 # Otherwise the build-id NOTE might end up at the default load address.
3103 # (Pedantically if the linker is gold then -Ttext is fine, but newer
3104 # gold versions also support -Ttext-segment. So just assume that unless
3105 # we can use -Ttext-segment we need to strip the build-id NOTEs.
3106 if test "x${linker_using_t_text}" = "xyes"; then
3107 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
3108 # does the linker support -Wl,--build-id=none ?  Note, it's
3109 # important that we test indirectly via whichever C compiler
3110 # is selected, rather than testing /usr/bin/ld or whatever
3111 # directly.
3112 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
3113 safe_CFLAGS=$CFLAGS
3114 CFLAGS="-Wl,--build-id=none -Werror"
3116 AC_LINK_IFELSE(
3117 [AC_LANG_PROGRAM([ ], [return 0;])],
3119   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
3120   AC_MSG_RESULT([yes])
3121 ], [
3122   AC_SUBST([FLAG_NO_BUILD_ID], [""])
3123   AC_MSG_RESULT([no])
3125 else
3126 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
3127 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3129 CFLAGS=$safe_CFLAGS
3131 # On s390x, if the linker supports -Wl,--s390-pgste, then we build the
3132 # tools with that flag.  This enables running programs that need it, such
3133 # as qemu-kvm.
3134 if test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX; then
3135 AC_MSG_CHECKING([if the linker accepts -Wl,--s390-pgste])
3136 safe_CFLAGS=$CFLAGS
3137 CFLAGS="-Wl,--s390-pgste"
3139 AC_LINK_IFELSE(
3140 [AC_LANG_PROGRAM([ ], [return 0;])],
3142   AC_SUBST([FLAG_S390_PGSTE], ["-Wl,--s390-pgste"])
3143   AC_MSG_RESULT([yes])
3144 ], [
3145   AC_SUBST([FLAG_S390_PGSTE], [""])
3146   AC_MSG_RESULT([no])
3148 CFLAGS=$safe_CFLAGS
3151 # does the ppc assembler support "mtocrf" et al?
3152 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
3154 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3155 __asm__ __volatile__("mtocrf 4,0");
3156 __asm__ __volatile__("mfocrf 0,4");
3157 ]])], [
3158 ac_have_as_ppc_mftocrf=yes
3159 AC_MSG_RESULT([yes])
3160 ], [
3161 ac_have_as_ppc_mftocrf=no
3162 AC_MSG_RESULT([no])
3164 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3165   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3169 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3170 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3172 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3173   do { typedef struct {
3174       double hi;
3175       double lo;
3176      } dbl_pair_t;
3177      dbl_pair_t dbl_pair[3];
3178      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3179    } while (0)
3180 ]])], [
3181 ac_have_as_ppc_fpPO=yes
3182 AC_MSG_RESULT([yes])
3183 ], [
3184 ac_have_as_ppc_fpPO=no
3185 AC_MSG_RESULT([no])
3187 if test x$ac_have_as_ppc_fpPO = xyes ; then
3188   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3192 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3193 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3195 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3196 void* p;
3197 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3198 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3199 ]])], [
3200 ac_have_as_amd64_fxsave64=yes
3201 AC_MSG_RESULT([yes])
3202 ], [
3203 ac_have_as_amd64_fxsave64=no
3204 AC_MSG_RESULT([no])
3206 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3207   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3210 # does the x86/amd64 assembler understand SSE3 instructions?
3211 # Note, this doesn't generate a C-level symbol.  It generates a
3212 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3213 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3215 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3216   do { long long int x; 
3217      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
3218   while (0)
3219 ]])], [
3220 ac_have_as_sse3=yes
3221 AC_MSG_RESULT([yes])
3222 ], [
3223 ac_have_as_sse3=no
3224 AC_MSG_RESULT([no])
3227 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3230 # Ditto for SSSE3 instructions (note extra S)
3231 # Note, this doesn't generate a C-level symbol.  It generates a
3232 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3233 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3235 save_CFLAGS="$CFLAGS"
3236 CFLAGS="$CFLAGS -msse -Werror"
3237 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3238   do { long long int x; 
3239    __asm__ __volatile__(
3240       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3241   while (0)
3242 ]])], [
3243 ac_have_as_ssse3=yes
3244 AC_MSG_RESULT([yes])
3245 ], [
3246 ac_have_as_ssse3=no
3247 AC_MSG_RESULT([no])
3249 CFLAGS="$save_CFLAGS"
3251 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3254 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3255 # Note, this doesn't generate a C-level symbol.  It generates a
3256 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3257 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3258 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3259   do {
3260    __asm__ __volatile__(
3261       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3262   while (0)
3263 ]])], [
3264 ac_have_as_pclmulqdq=yes
3265 AC_MSG_RESULT([yes])
3266 ], [
3267 ac_have_as_pclmulqdq=no
3268 AC_MSG_RESULT([no])
3271 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3274 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3275 # Note, this doesn't generate a C-level symbol.  It generates a
3276 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3277 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3278 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3279   do {
3280       /*
3281        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3282        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3283        * xmm2 should be used.
3284        */
3285    __asm__ __volatile__(
3286       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3287   } while (0)
3288 ]])], [
3289 ac_have_as_vpclmulqdq=yes
3290 AC_MSG_RESULT([yes])
3291 ], [
3292 ac_have_as_vpclmulqdq=no
3293 AC_MSG_RESULT([no])
3296 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3299 # does the x86/amd64 assembler understand FMA4 instructions?
3300 # Note, this doesn't generate a C-level symbol.  It generates a
3301 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3302 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3303 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3304   do {
3305    __asm__ __volatile__(
3306       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3307   } while (0)
3308 ]])], [
3309 ac_have_as_vfmaddpd=yes
3310 AC_MSG_RESULT([yes])
3311 ], [
3312 ac_have_as_vfmaddpd=no
3313 AC_MSG_RESULT([no])
3316 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3319 # does the x86/amd64 assembler understand the LZCNT instruction?
3320 # Note, this doesn't generate a C-level symbol.  It generates a
3321 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3322 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3325   do {           
3326       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3327   } while (0)
3328 ]])], [
3329   ac_have_as_lzcnt=yes
3330   AC_MSG_RESULT([yes])
3331 ], [
3332   ac_have_as_lzcnt=no
3333   AC_MSG_RESULT([no])
3336 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3339 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3340 # Note, this doesn't generate a C-level symbol.  It generates a
3341 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3342 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3344 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3345   do {           
3346       __asm__ __volatile__("1:  loopnel 1b\n");
3347   } while (0)
3348 ]])], [
3349   ac_have_as_loopnel=yes
3350   AC_MSG_RESULT([yes])
3351 ], [
3352   ac_have_as_loopnel=no
3353   AC_MSG_RESULT([no])
3356 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3359 # does the x86/amd64 assembler understand ADDR32 ?
3360 # Note, this doesn't generate a C-level symbol.  It generates a
3361 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3362 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3365   do {           
3366       asm volatile ("addr32 rep movsb");
3367   } while (0)
3368 ]])], [
3369   ac_have_as_addr32=yes
3370   AC_MSG_RESULT([yes])
3371 ], [
3372   ac_have_as_addr32=no
3373   AC_MSG_RESULT([no])
3376 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3379 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3380 # Note, this doesn't generate a C-level symbol.  It generates a
3381 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3382 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3384 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3385   do { long long int x; 
3386    __asm__ __volatile__(
3387       "crc32q %%r15,%%r15" : : : "r15" );
3388    __asm__ __volatile__(
3389       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3390    __asm__ __volatile__(
3391       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3392   while (0)
3393 ]])], [
3394 ac_have_as_sse42=yes
3395 AC_MSG_RESULT([yes])
3396 ], [
3397 ac_have_as_sse42=no
3398 AC_MSG_RESULT([no])
3401 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3404 # does the x86/amd64 assembler understand AVX instructions?
3405 # Note, this doesn't generate a C-level symbol.  It generates a
3406 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3407 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3409 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3410   do { long long int x; 
3411    __asm__ __volatile__(
3412       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3413    __asm__ __volatile__(
3414       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3415   while (0)
3416 ]])], [
3417 ac_have_as_avx=yes
3418 AC_MSG_RESULT([yes])
3419 ], [
3420 ac_have_as_avx=no
3421 AC_MSG_RESULT([no])
3424 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3427 # does the x86/amd64 assembler understand AVX2 instructions?
3428 # Note, this doesn't generate a C-level symbol.  It generates a
3429 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3430 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3432 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3433   do { long long int x; 
3434    __asm__ __volatile__(
3435       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3436    __asm__ __volatile__(
3437       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3438   while (0)
3439 ]])], [
3440 ac_have_as_avx2=yes
3441 AC_MSG_RESULT([yes])
3442 ], [
3443 ac_have_as_avx2=no
3444 AC_MSG_RESULT([no])
3447 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3450 # does the x86/amd64 assembler understand TSX instructions and
3451 # the XACQUIRE/XRELEASE prefixes?
3452 # Note, this doesn't generate a C-level symbol.  It generates a
3453 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3454 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3456 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3457   do {
3458    __asm__ __volatile__(
3459       "       xbegin Lfoo  \n\t"
3460       "Lfoo:  xend         \n\t"
3461       "       xacquire lock incq 0(%rsp)     \n\t"
3462       "       xrelease lock incq 0(%rsp)     \n"
3463    );
3464   } while (0)
3465 ]])], [
3466 ac_have_as_tsx=yes
3467 AC_MSG_RESULT([yes])
3468 ], [
3469 ac_have_as_tsx=no
3470 AC_MSG_RESULT([no])
3473 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3476 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3477 # Note, this doesn't generate a C-level symbol.  It generates a
3478 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3479 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3481 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3482   do { unsigned int h, l;
3483    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3484    __asm__ __volatile__(
3485       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3486    __asm__ __volatile__(
3487       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3488   while (0)
3489 ]])], [
3490 ac_have_as_bmi=yes
3491 AC_MSG_RESULT([yes])
3492 ], [
3493 ac_have_as_bmi=no
3494 AC_MSG_RESULT([no])
3497 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3500 # does the x86/amd64 assembler understand FMA instructions?
3501 # Note, this doesn't generate a C-level symbol.  It generates a
3502 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3503 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3505 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3506   do { unsigned int h, l;
3507    __asm__ __volatile__(
3508       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3509    __asm__ __volatile__(
3510       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3511    __asm__ __volatile__(
3512       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3513   while (0)
3514 ]])], [
3515 ac_have_as_fma=yes
3516 AC_MSG_RESULT([yes])
3517 ], [
3518 ac_have_as_fma=no
3519 AC_MSG_RESULT([no])
3522 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3525 # does the amd64 assembler understand MPX instructions?
3526 # Note, this doesn't generate a C-level symbol.  It generates a
3527 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3528 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3530 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3531   do {
3532     asm ("bndmov %bnd0,(%rsp)");
3533     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3534     asm ("bnd call foo\n"
3535          "bnd jmp  end\n"
3536          "foo: bnd ret\n"
3537          "end: nop");
3538   } while (0)
3539 ]])], [
3540 ac_have_as_mpx=yes
3541 AC_MSG_RESULT([yes])
3542 ], [
3543 ac_have_as_mpx=no
3544 AC_MSG_RESULT([no])
3547 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3550 # does the amd64 assembler understand ADX instructions?
3551 # Note, this doesn't generate a C-level symbol.  It generates a
3552 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3553 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3555 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3556   do {
3557     asm ("adcxq %r14,%r8");
3558   } while (0)
3559 ]])], [
3560 ac_have_as_adx=yes
3561 AC_MSG_RESULT([yes])
3562 ], [
3563 ac_have_as_adx=no
3564 AC_MSG_RESULT([no])
3567 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3570 # does the amd64 assembler understand the RDRAND instruction?
3571 # Note, this doesn't generate a C-level symbol.  It generates a
3572 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3573 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3575 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3576   do {
3577     asm ("rdrand %r14");
3578     asm ("rdrand %r14d");
3579     asm ("rdrand %r14w");
3580   } while (0)
3581 ]])], [
3582 ac_have_as_rdrand=yes
3583 AC_MSG_RESULT([yes])
3584 ], [
3585 ac_have_as_rdrand=no
3586 AC_MSG_RESULT([no])
3589 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3591 # does the amd64 assembler understand the RDSEED instruction?
3592 # Note, this doesn't generate a C-level symbol.  It generates a
3593 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3594 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3596 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3597   do {
3598     asm ("rdseed %r14");
3599     asm ("rdseed %r14d");
3600     asm ("rdseed %r14w");
3601   } while (0)
3602 ]])], [
3603 ac_have_as_rdseed=yes
3604 AC_MSG_RESULT([yes])
3605 ], [
3606 ac_have_as_rdseed=no
3607 AC_MSG_RESULT([no])
3610 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3612 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3613 # VCVTPS2PH) ?
3614 # Note, this doesn't generate a C-level symbol.  It generates a
3615 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3616 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3618 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3619   do {
3620     asm ("vcvtph2ps %xmm5, %ymm10");
3621     // If we put the dollar sign and zero together, the shell processing
3622     // this configure.ac script substitutes the command name in.  Sigh.
3623     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3624   } while (0)
3625 ]])], [
3626 ac_have_as_f16c=yes
3627 AC_MSG_RESULT([yes])
3628 ], [
3629 ac_have_as_f16c=no
3630 AC_MSG_RESULT([no])
3633 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3636 # does the x86/amd64 assembler understand MOVBE?
3637 # Note, this doesn't generate a C-level symbol.  It generates a
3638 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3639 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3641 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3642   do { long long int x; 
3643    __asm__ __volatile__(
3644       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3645   while (0)
3646 ]])], [
3647 ac_have_as_movbe=yes
3648 AC_MSG_RESULT([yes])
3649 ], [
3650 ac_have_as_movbe=no
3651 AC_MSG_RESULT([no])
3654 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3657 # Does the C compiler support the "ifunc" attribute
3658 # Note, this doesn't generate a C-level symbol.  It generates a
3659 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3660 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3662 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3663 static void mytest(void) {}
3665 static void (*resolve_test(void))(void)
3667     return (void (*)(void))&mytest;
3670 void test(void) __attribute__((ifunc("resolve_test")));
3672 int main()
3674     test();
3675     return 0;
3677 ]])], [
3678 ac_have_ifunc_attr=yes
3679 AC_MSG_RESULT([yes])
3680 ], [
3681 ac_have_ifunc_attr=no
3682 AC_MSG_RESULT([no])
3685 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3687 # Does the C compiler support the armv8 crc feature flag
3688 # Note, this doesn't generate a C-level symbol.  It generates a
3689 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3690 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3692 save_CFLAGS="$CFLAGS"
3693 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3694 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3695 int main()
3697     return 0;
3699 ]])], [
3700 ac_have_armv8_crc_feature=yes
3701 AC_MSG_RESULT([yes])
3702 ], [
3703 ac_have_armv8_crc_feature=no
3704 AC_MSG_RESULT([no])
3706 CFLAGS="$save_CFLAGS"
3708 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3711 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3712 # Note, this doesn't generate a C-level symbol.  It generates a
3713 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3714 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3716 save_CFLAGS="$CFLAGS"
3717 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3718 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3719 int main()
3721     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3722     return 0;
3724 ]])], [
3725 ac_have_armv81_feature=yes
3726 AC_MSG_RESULT([yes])
3727 ], [
3728 ac_have_armv81_feature=no
3729 AC_MSG_RESULT([no])
3731 CFLAGS="$save_CFLAGS"
3733 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3736 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3737 # Note, this doesn't generate a C-level symbol.  It generates a
3738 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3739 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3741 save_CFLAGS="$CFLAGS"
3742 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3743 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3744 int main()
3746     __asm__ __volatile__("faddp h0, v1.2h");
3747     return 0;
3749 ]])], [
3750 ac_have_armv82_feature=yes
3751 AC_MSG_RESULT([yes])
3752 ], [
3753 ac_have_armv82_feature=no
3754 AC_MSG_RESULT([no])
3756 CFLAGS="$save_CFLAGS"
3758 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3761 # Does the C compiler support the armv82-a+dotprod flag and assembler dotprod instructions
3762 # Note, this doesn't generate a C-level symbol.  It generates a
3763 # automake-level symbol (BUILD_ARMV82_DOTPROD_TESTS), used in test Makefile.am's
3764 AC_MSG_CHECKING([if gcc supports the armv82-a+dotprod feature flag and assembler supports dotprod instructions])
3766 save_CFLAGS="$CFLAGS"
3767 CFLAGS="$CFLAGS -march=armv8.2-a+dotprod -Werror"
3768 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3769 int main()
3771     __asm__ __volatile__("sdot v1.4s, v2.16b, v3.16b");
3772     return 0;
3774 ]])], [
3775 ac_have_armv82_dotprod_feature=yes
3776 AC_MSG_RESULT([yes])
3777 ], [
3778 ac_have_armv82_dotprod_feature=no
3779 AC_MSG_RESULT([no])
3781 CFLAGS="$save_CFLAGS"
3783 AM_CONDITIONAL(BUILD_ARMV82_DOTPROD_TESTS, test x$ac_have_armv82_dotprod_feature = xyes)
3786 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3787 # when building the tool executables.  I think we should get rid of it.
3789 # Check for TLS support in the compiler and linker
3790 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3791                                 [[return foo;]])],
3792                                [vg_cv_linktime_tls=yes],
3793                                [vg_cv_linktime_tls=no])
3794 # Native compilation: check whether running a program using TLS succeeds.
3795 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3796 # succeeds but running programs using TLS fails.
3797 # Cross-compiling: check whether linking a program using TLS succeeds.
3798 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3799                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3800                 [vg_cv_tls=$enableval],
3801                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3802                                                 [[return foo;]])],
3803                                [vg_cv_tls=yes],
3804                                [vg_cv_tls=no],
3805                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3807 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3808 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3812 #----------------------------------------------------------------------------
3813 # Solaris-specific checks.
3814 #----------------------------------------------------------------------------
3816 if test "$VGCONF_OS" = "solaris" ; then
3817 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3819 # Solaris-specific check determining if the Sun Studio Assembler is used to
3820 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3821 # cmovl.l instruction, if yes then it's Sun Assembler.
3823 # C-level symbol: none
3824 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3826 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3827 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3828 ]], [[
3829   __asm__ __volatile__("cmovl.l %edx, %eax");
3830 ]])], [
3831 solaris_have_sun_studio_as=yes
3832 AC_MSG_RESULT([yes])
3833 ], [
3834 solaris_have_sun_studio_as=no
3835 AC_MSG_RESULT([no])
3837 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3839 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3840 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3841 # See solaris/vgpreload-solaris.mapfile for details.
3842 # gcc on older Solaris instructs linker to include these symbols,
3843 # gcc on illumos and newer Solaris does not.
3845 # C-level symbol: none
3846 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3848 save_CFLAGS="$CFLAGS"
3849 CFLAGS="$CFLAGS -std=gnu99"
3850 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3851 temp_dir=$( /usr/bin/mktemp -d )
3852 cat <<_ACEOF >${temp_dir}/mylib.c
3853 #include <stdio.h>
3854 int myfunc(void) { printf("LaPutyka\n"); }
3855 _ACEOF
3856 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3857 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3858 if test "x${xpg_present}" = "x" ; then
3859     solaris_xpg_symbols_present=no
3860     AC_MSG_RESULT([no])
3861 else
3862     solaris_xpg_symbols_present=yes
3863     AC_MSG_RESULT([yes])
3865 rm -rf ${temp_dir}
3866 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3867 CFLAGS="$save_CFLAGS"
3870 # Solaris-specific check determining if gcc enables largefile support by
3871 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3872 # variable with gcc flags which disable it.
3874 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3875 save_CFLAGS="$CFLAGS"
3876 CFLAGS="$CFLAGS -m32"
3877 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3878   return _LARGEFILE_SOURCE;
3879 ]])], [
3880 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3881 AC_MSG_RESULT([yes])
3882 ], [
3883 SOLARIS_UNDEF_LARGESOURCE=""
3884 AC_MSG_RESULT([no])
3886 CFLAGS=$safe_CFLAGS
3887 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3890 # Solaris-specific check determining if /proc/self/cmdline
3891 # or /proc/<pid>/cmdline is supported.
3893 # C-level symbol: SOLARIS_PROC_CMDLINE
3894 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3896 AC_CHECK_FILE([/proc/self/cmdline],
3898 solaris_proc_cmdline=yes
3899 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3900           [Define to 1 if you have /proc/self/cmdline.])
3901 ], [
3902 solaris_proc_cmdline=no
3904 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3907 # Solaris-specific check determining default platform for the Valgrind launcher.
3908 # Used in case the launcher cannot select platform by looking at the client
3909 # image (for example because the executable is a shell script).
3911 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3912 # Automake-level symbol: none
3914 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3915 # Get the ELF class of /bin/sh first.
3916 if ! test -f /bin/sh; then
3917   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3919 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3920 case "$elf_class" in
3921   64)
3922     default_arch="$VGCONF_ARCH_PRI";
3923     ;;
3924   32)
3925     if test "x$VGCONF_ARCH_SEC" != "x"; then
3926       default_arch="$VGCONF_ARCH_SEC"
3927     else
3928       default_arch="$VGCONF_ARCH_PRI";
3929     fi
3930     ;;
3931   *)
3932     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3933     ;;
3934 esac
3935 default_platform="$default_arch-$VGCONF_OS"
3936 AC_MSG_RESULT([$default_platform])
3937 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3938                    [Default platform for Valgrind launcher.])
3941 # Solaris-specific check determining if the old syscalls are available.
3943 # C-level symbol: SOLARIS_OLD_SYSCALLS
3944 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3946 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3947 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3948 #include <sys/syscall.h>
3949 ]], [[
3950   return !SYS_open;
3951 ]])], [
3952 solaris_old_syscalls=yes
3953 AC_MSG_RESULT([yes])
3954 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3955           [Define to 1 if you have the old Solaris syscalls.])
3956 ], [
3957 solaris_old_syscalls=no
3958 AC_MSG_RESULT([no])
3960 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3963 # Solaris-specific check determining if the new accept() syscall is available.
3965 # Old syscall:
3966 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3967 #            int version);
3969 # New syscall (available on illumos):
3970 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3971 #            int version, int flags);
3973 # If the old syscall is present then the following syscall will fail with
3974 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3975 # available then it will fail with EINVAL (because the flags parameter is
3976 # invalid).
3978 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3979 # Automake-level symbol: none
3981 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3982 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3983 #include <sys/syscall.h>
3984 #include <errno.h>
3985 ]], [[
3986   errno = 0;
3987   syscall(SYS_accept, 0, 0, 0, 0, -1);
3988   return !(errno == EINVAL);
3989 ]])], [
3990 AC_MSG_RESULT([yes])
3991 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3992           [Define to 1 if you have the new `accept' syscall.])
3993 ], [
3994 AC_MSG_RESULT([no])
3998 # Solaris-specific check determining if the new illumos pipe() syscall is
3999 # available.
4001 # Old syscall:
4002 # longlong_t pipe();
4004 # New syscall (available on illumos):
4005 # int pipe(intptr_t arg, int flags);
4007 # If the old syscall is present then the following call will succeed, if the
4008 # new syscall is available then it will fail with EFAULT (because address 0
4009 # cannot be accessed).
4011 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
4012 # Automake-level symbol: none
4014 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
4015 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4016 #include <sys/syscall.h>
4017 #include <errno.h>
4018 ]], [[
4019   errno = 0;
4020   syscall(SYS_pipe, 0, 0);
4021   return !(errno == EFAULT);
4022 ]])], [
4023 AC_MSG_RESULT([yes])
4024 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
4025           [Define to 1 if you have the new `pipe' syscall.])
4026 ], [
4027 AC_MSG_RESULT([no])
4031 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
4032 # available.
4034 # Old syscall:
4035 # int lwp_kill(id_t lwpid, int sig);
4037 # New syscall (available on Solaris 11):
4038 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
4039 #                  int si_code, timespec_t *timeout);
4041 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
4042 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
4044 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
4045 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4046 #include <sys/syscall.h> 
4047 ]], [[
4048   return !SYS_lwp_sigqueue;
4049 ]])], [
4050 solaris_lwp_sigqueue_syscall=yes
4051 AC_MSG_RESULT([yes])
4052 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
4053           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
4054 ], [
4055 solaris_lwp_sigqueue_syscall=no
4056 AC_MSG_RESULT([no])
4058 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
4061 # Solaris-specific check determining if the lwp_sigqueue() syscall
4062 # takes both pid and thread id arguments or just thread id.
4064 # Old syscall (available up to Solaris 11.3):
4065 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
4066 #                  int si_code, timespec_t *timeout);
4068 # New syscall (available since Solaris 11.4):
4069 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
4070 #                  int si_code, timespec_t *timeout);
4072 # If the old syscall is present then the following syscall will fail with
4073 # EINVAL (because signal is out of range); if the new syscall is available
4074 # then it will fail with ESRCH (because it would not find such thread in the
4075 # current process).
4077 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
4078 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
4080 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
4081 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
4082 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4083 #include <sys/syscall.h>
4084 #include <errno.h>
4085 ]], [[
4086   errno = 0;
4087   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
4088   return !(errno == ESRCH);
4089 ]])], [
4090 solaris_lwp_sigqueue_syscall_takes_pid=yes
4091 AC_MSG_RESULT([yes])
4092 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
4093           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
4094 ], [
4095 solaris_lwp_sigqueue_syscall_takes_pid=no
4096 AC_MSG_RESULT([no])
4098 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
4099                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
4101 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
4105 # Solaris-specific check determining if the new lwp_name() syscall is
4106 # available.
4108 # New syscall (available on Solaris 11):
4109 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
4111 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
4112 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
4114 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
4115 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4116 #include <sys/syscall.h>
4117 ]], [[
4118   return !SYS_lwp_name;
4119 ]])], [
4120 solaris_lwp_name_syscall=yes
4121 AC_MSG_RESULT([yes])
4122 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
4123           [Define to 1 if you have the new `lwp_name' syscall.])
4124 ], [
4125 solaris_lwp_name_syscall=no
4126 AC_MSG_RESULT([no])
4128 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
4131 # Solaris-specific check determining if the new getrandom() syscall is
4132 # available.
4134 # New syscall (available on Solaris 11):
4135 # int getrandom(void *buf, size_t buflen, uint_t flags);
4137 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
4138 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
4140 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
4141 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4142 #include <sys/syscall.h>
4143 ]], [[
4144   return !SYS_getrandom;
4145 ]])], [
4146 solaris_getrandom_syscall=yes
4147 AC_MSG_RESULT([yes])
4148 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
4149           [Define to 1 if you have the new `getrandom' syscall.])
4150 ], [
4151 solaris_getrandom_syscall=no
4152 AC_MSG_RESULT([no])
4154 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
4157 # Solaris-specific check determining if the new zone() syscall subcodes
4158 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
4159 # were added in Solaris 11 but are missing on illumos.
4161 # C-level symbol: SOLARIS_ZONE_DEFUNCT
4162 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
4164 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
4165 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4166 #include <sys/zone.h>
4167 ]], [[
4168   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
4169 ]])], [
4170 solaris_zone_defunct=yes
4171 AC_MSG_RESULT([yes])
4172 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
4173           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
4174 ], [
4175 solaris_zone_defunct=no
4176 AC_MSG_RESULT([no])
4178 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
4181 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4182 # for auditon(2) subcode of the auditsys() syscall are available.
4183 # These commands are available in Solaris 11 and illumos but were removed
4184 # in Solaris 11.4.
4186 # C-level symbol: SOLARIS_AUDITON_STAT
4187 # Automake-level symbol: SOLARIS_AUDITON_STAT
4189 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4191 #include <bsm/audit.h>
4192 ]], [[
4193   return !(A_GETSTAT && A_SETSTAT);
4194 ]])], [
4195 solaris_auditon_stat=yes
4196 AC_MSG_RESULT([yes])
4197 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4198           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4199 ], [
4200 solaris_auditon_stat=no
4201 AC_MSG_RESULT([no])
4203 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4206 # Solaris-specific check determining if the new shmsys() syscall subcodes
4207 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4208 # These subcodes were added in Solaris 11 but are missing on illumos.
4210 # C-level symbol: SOLARIS_SHM_NEW
4211 # Automake-level symbol: SOLARIS_SHM_NEW
4213 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4214 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4215 #include <sys/ipc_impl.h>
4216 #include <sys/shm.h>
4217 #include <sys/shm_impl.h>
4218 ]], [[
4219   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4220 ]])], [
4221 solaris_shm_new=yes
4222 AC_MSG_RESULT([yes])
4223 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4224           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4225 ], [
4226 solaris_shm_new=no
4227 AC_MSG_RESULT([no])
4229 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4232 # Solaris-specific check determining if prxregset_t is available.  Illumos
4233 # currently does not define it on the x86 platform.
4235 # C-level symbol: SOLARIS_PRXREGSET_T
4236 # Automake-level symbol: SOLARIS_PRXREGSET_T
4238 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4239 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4240 #include <sys/procfs_isa.h>
4241 ]], [[
4242   return !sizeof(prxregset_t);
4243 ]])], [
4244 solaris_prxregset_t=yes
4245 AC_MSG_RESULT([yes])
4246 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4247           [Define to 1 if you have the `prxregset_t' type.])
4248 ], [
4249 solaris_prxregset_t=no
4250 AC_MSG_RESULT([no])
4252 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4255 # Solaris-specific check determining if the new frealpathat() syscall is
4256 # available.
4258 # New syscall (available on Solaris 11.1):
4259 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4261 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4262 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4264 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4265 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4266 #include <sys/syscall.h>
4267 ]], [[
4268   return !SYS_frealpathat;
4269 ]])], [
4270 solaris_frealpathat_syscall=yes
4271 AC_MSG_RESULT([yes])
4272 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4273           [Define to 1 if you have the new `frealpathat' syscall.])
4274 ], [
4275 solaris_frealpathat_syscall=no
4276 AC_MSG_RESULT([no])
4278 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4281 # Solaris-specific check determining if the new uuidsys() syscall is
4282 # available.
4284 # New syscall (available on newer Solaris):
4285 # int uuidsys(struct uuid *uuid);
4287 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4288 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4290 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4291 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4292 #include <sys/syscall.h>
4293 ]], [[
4294   return !SYS_uuidsys;
4295 ]])], [
4296 solaris_uuidsys_syscall=yes
4297 AC_MSG_RESULT([yes])
4298 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4299           [Define to 1 if you have the new `uuidsys' syscall.])
4300 ], [
4301 solaris_uuidsys_syscall=no
4302 AC_MSG_RESULT([no])
4304 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4307 # Solaris-specific check determining if the new labelsys() syscall subcode
4308 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4309 # missing on illumos.
4311 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4312 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4314 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4316 #include <sys/tsol/tndb.h>
4317 ]], [[
4318   return !TNDB_GET_TNIP;
4319 ]])], [
4320 solaris_tndb_get_tnip=yes
4321 AC_MSG_RESULT([yes])
4322 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4323           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4324 ], [
4325 solaris_tndb_get_tnip=no
4326 AC_MSG_RESULT([no])
4328 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4331 # Solaris-specific check determining if the new labelsys() syscall opcodes
4332 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4333 # added in Solaris 11 but are missing on illumos.
4335 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4336 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4338 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4339 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4340 #include <sys/tsol/tsyscall.h>
4341 ]], [[
4342   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4343 ]])], [
4344 solaris_tsol_clearance=yes
4345 AC_MSG_RESULT([yes])
4346 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4347           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4348 ], [
4349 solaris_tsol_clearance=no
4350 AC_MSG_RESULT([no])
4352 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4355 # Solaris-specific check determining if the new pset() syscall subcode
4356 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4357 # is missing on illumos and Solaris 11.3.
4359 # C-level symbol: SOLARIS_PSET_GET_NAME
4360 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4362 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4363 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4364 #include <sys/pset.h>
4365 ]], [[
4366   return !(PSET_GET_NAME);
4367 ]])], [
4368 solaris_pset_get_name=yes
4369 AC_MSG_RESULT([yes])
4370 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4371           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4372 ], [
4373 solaris_pset_get_name=no
4374 AC_MSG_RESULT([no])
4376 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4379 # Solaris-specific check determining if the utimesys() syscall is
4380 # available (on illumos and older Solaris).
4382 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4383 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4385 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4386 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4387 #include <sys/syscall.h>
4388 ]], [[
4389   return !SYS_utimesys;
4390 ]])], [
4391 solaris_utimesys_syscall=yes
4392 AC_MSG_RESULT([yes])
4393 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4394           [Define to 1 if you have the `utimesys' syscall.])
4395 ], [
4396 solaris_utimesys_syscall=no
4397 AC_MSG_RESULT([no])
4399 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4402 # Solaris-specific check determining if the utimensat() syscall is
4403 # available (on newer Solaris).
4405 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4406 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4408 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4409 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4410 #include <sys/syscall.h>
4411 ]], [[
4412   return !SYS_utimensat;
4413 ]])], [
4414 solaris_utimensat_syscall=yes
4415 AC_MSG_RESULT([yes])
4416 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4417           [Define to 1 if you have the `utimensat' syscall.])
4418 ], [
4419 solaris_utimensat_syscall=no
4420 AC_MSG_RESULT([no])
4422 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4425 # Solaris-specific check determining if the spawn() syscall is available
4426 # (on newer Solaris).
4428 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4429 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4431 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4432 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4433 #include <sys/syscall.h>
4434 ]], [[
4435   return !SYS_spawn;
4436 ]])], [
4437 solaris_spawn_syscall=yes
4438 AC_MSG_RESULT([yes])
4439 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4440           [Define to 1 if you have the `spawn' syscall.])
4441 ], [
4442 solaris_spawn_syscall=no
4443 AC_MSG_RESULT([no])
4445 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4448 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4449 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4451 # C-level symbol: SOLARIS_MODCTL_MODNVL
4452 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4454 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4455 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4456 #include <sys/modctl.h>
4457 ]], [[
4458   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4459 ]])], [
4460 solaris_modctl_modnvl=yes
4461 AC_MSG_RESULT([yes])
4462 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4463           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4464 ], [
4465 solaris_modctl_modnvl=no
4466 AC_MSG_RESULT([no])
4468 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4471 # Solaris-specific check determining whether nscd (name switch cache daemon)
4472 # attaches its door at /system/volatile/name_service_door (Solaris)
4473 # or at /var/run/name_service_door (illumos).
4475 # Note that /var/run is a symlink to /system/volatile on Solaris
4476 # but not vice versa on illumos.
4478 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4479 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4481 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4482 if test -e /system/volatile/name_service_door; then
4483     solaris_nscd_door_system_volatile=yes
4484     AC_MSG_RESULT([/system/volatile/name_service_door])
4485     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4486               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4487 else
4488     solaris_nscd_door_system_volatile=no
4489     AC_MSG_RESULT([/var/run/name_service_door])
4491 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4494 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4496 # New fasttrap (available on Solaris 11):
4497 # hrt_t *gethrt(void);
4499 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4500 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4502 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4503 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4504 #include <sys/trap.h>
4505 ]], [[
4506   return !T_GETHRT;
4507 ]])], [
4508 solaris_gethrt_fasttrap=yes
4509 AC_MSG_RESULT([yes])
4510 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4511           [Define to 1 if you have the new `gethrt' fasttrap.])
4512 ], [
4513 solaris_gethrt_fasttrap=no
4514 AC_MSG_RESULT([no])
4516 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4519 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4520 # is available.
4522 # New fasttrap (available on Solaris 11):
4523 # zonehrtoffset_t *get_zone_offset(void);
4525 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4526 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4528 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4529 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4530 #include <sys/trap.h>
4531 ]], [[
4532   return !T_GETZONEOFFSET;
4533 ]])], [
4534 solaris_getzoneoffset_fasttrap=yes
4535 AC_MSG_RESULT([yes])
4536 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4537           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4538 ], [
4539 solaris_getzoneoffset_fasttrap=no
4540 AC_MSG_RESULT([no])
4542 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4545 # Solaris-specific check determining if the execve() syscall
4546 # takes fourth argument (flags) or not.
4548 # Old syscall (available on illumos):
4549 # int execve(const char *fname, const char **argv, const char **envp);
4551 # New syscall (available on Solaris):
4552 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4554 # If the new syscall is present then it will fail with EINVAL (because flags
4555 # are invalid); if the old syscall is available then it will fail with ENOENT
4556 # (because the file could not be found).
4558 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4559 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4561 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4562 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4563 #include <sys/syscall.h>
4564 #include <errno.h>
4565 ]], [[
4566   errno = 0;
4567   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4568   return !(errno == EINVAL);
4569 ]])], [
4570 solaris_execve_syscall_takes_flags=yes
4571 AC_MSG_RESULT([yes])
4572 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4573           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4574 ], [
4575 solaris_execve_syscall_takes_flags=no
4576 AC_MSG_RESULT([no])
4578 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4579                test x$solaris_execve_syscall_takes_flags = xyes)
4582 # Solaris-specific check determining version of the repository cache protocol.
4583 # Every Solaris version uses a different one, ranging from 21 to current 25.
4584 # The check is very ugly, though.
4586 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4587 # Automake-level symbol: none
4589 AC_PATH_PROG(DIS_PATH, dis, false)
4590 if test "x$DIS_PATH" = "xfalse"; then
4591   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4593 # The illumos source is (or was) here
4594 # https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libscf/common/lowlevel.c#L1148
4595 # specifically the line
4597 # request.rdr_version = REPOSITORY_DOOR_VERSION;
4599 # rdr_version is a 32bit unsigned int
4600 # The macro REPOSITORY_DOOR_VERSION contains the ascii letters "Rep" in the top 3
4601 # bytes and the door version in the lowest byte. Hence we look for Rep which is 526570
4602 # in hex and then extrace the following byte.
4603 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4604   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4605   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4608 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4609 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4610   libscf=/usr/lib/64/libscf.so.1
4611 else
4612   libscf=/usr/lib/libscf.so.1
4614 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q -E '0x(4d01)?526570'; then
4615   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4616   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4618 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | grep 526570 | sed 's/.*526570//;s/,.*//' )
4619 if test -z "$hex"; then
4620   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4621   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4623 version=$( printf "%d\n" 0x$hex )
4624 AC_MSG_RESULT([$version])
4625 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4626                    [Version number of the repository door cache protocol.])
4629 # Solaris-specific check determining if "sysstat" segment reservation type
4630 # is available.
4632 # New "sysstat" segment reservation (available on Solaris 11.4):
4633 # - program header type:    PT_SUNW_SYSSTAT
4634 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4636 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4637 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4639 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4640 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4641 #include <sys/auxv.h>
4642 ]], [[
4643   return !AT_SUN_SYSSTAT_ADDR;
4644 ]])], [
4645 solaris_reserve_sysstat_addr=yes
4646 AC_MSG_RESULT([yes])
4647 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4648           [Define to 1 if you have the new `sysstat' segment reservation.])
4649 ], [
4650 solaris_reserve_sysstat_addr=no
4651 AC_MSG_RESULT([no])
4653 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4656 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4657 # is available.
4659 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4660 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4661 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4663 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4664 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4666 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4668 #include <sys/auxv.h>
4669 ]], [[
4670   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4671 ]])], [
4672 solaris_reserve_sysstat_zone_addr=yes
4673 AC_MSG_RESULT([yes])
4674 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4675           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4676 ], [
4677 solaris_reserve_sysstat_zone_addr=no
4678 AC_MSG_RESULT([no])
4680 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4683 # Solaris-specific check determining if the system_stats() syscall is available
4684 # (on newer Solaris).
4686 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4687 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4689 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4690 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4691 #include <sys/syscall.h>
4692 ]], [[
4693   return !SYS_system_stats;
4694 ]])], [
4695 solaris_system_stats_syscall=yes
4696 AC_MSG_RESULT([yes])
4697 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4698           [Define to 1 if you have the `system_stats' syscall.])
4699 ], [
4700 solaris_system_stats_syscall=no
4701 AC_MSG_RESULT([no])
4703 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4706 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4707 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4709 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4710 # Automake-level symbol: none
4712 AC_CHECK_TYPE([struct _fpchip_state],
4713               [solaris_fpchip_state_takes_underscore=yes],
4714               [solaris_fpchip_state_takes_underscore=no],
4715               [[#include <sys/regset.h>]])
4716 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4717   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4718             [Define to 1 if fpregset_t defines struct _fpchip_state])
4722 # Solaris-specific check determining if schedctl page shared between kernel
4723 # and userspace program is executable (illumos, older Solaris) or not (newer
4724 # Solaris).
4726 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4727 # Automake-level symbol: none
4729 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4730 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4731 #include <assert.h>
4732 #include <fcntl.h>
4733 #include <procfs.h>
4734 #include <schedctl.h>
4735 #include <stdio.h>
4736 #include <unistd.h>
4737 ]], [[
4738     schedctl_t *scp = schedctl_init();
4739     if (scp == NULL)
4740         return 1;
4742     int fd = open("/proc/self/map", O_RDONLY);
4743     assert(fd >= 0);
4745     prmap_t map;
4746     ssize_t rd;
4747     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4748         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4749             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4750                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4751             return (map.pr_mflags & MA_EXEC);
4752         }
4753     }
4755     return 1;
4756 ]])], [
4757 solaris_schedctl_page_exec=no
4758 AC_MSG_RESULT([no])
4759 ], [
4760 solaris_schedctl_page_exec=yes
4761 AC_MSG_RESULT([yes])
4762 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4763           [Define to 1 if you have the schedctl page executable.])
4767 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4768 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4769 # an initial thread pointer for libc (newer Solaris).
4771 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4772 # Automake-level symbol: none
4774 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4775 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4776 #include <sys/fasttrap_isa.h>
4777 ]], [[
4778     return !FT_SCRATCHSIZE;
4779 ]])], [
4780 solaris_pt_sunwdtrace_thrp=yes
4781 AC_MSG_RESULT([yes])
4782 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4783           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4784 ], [
4785 solaris_pt_sunwdtrace_thrp=no
4786 AC_MSG_RESULT([no])
4789 else
4790 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4791 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4792 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4793 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4794 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4795 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4796 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4797 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4798 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4799 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4800 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4801 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4802 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4803 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4804 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4805 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4806 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4807 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4808 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4809 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4810 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4811 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4812 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4813 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4814 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4815 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4816 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4817 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4818 fi # test "$VGCONF_OS" = "solaris"
4820 #----------------------------------------------------------------------------
4821 # FreeBSD-specific checks.
4822 #----------------------------------------------------------------------------
4824 # Rather than having a large number of feature test as above with Solaris
4825 # these tests are per-version. This may not be entirely reliable for
4826 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4827 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4829 if test "$VGCONF_OS" = "freebsd" ; then
4831 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4832 AM_CONDITIONAL(FREEBSD_VERS_15_PLUS, test $freebsd_vers -ge $freebsd_15)
4834 else
4836 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4837 AM_CONDITIONAL(FREEBSD_VERS_15_PLUS, false)
4839 fi # test "$VGCONF_OS" = "freebsd"
4842 #----------------------------------------------------------------------------
4843 # Checks for C header files.
4844 #----------------------------------------------------------------------------
4846 AC_CHECK_HEADERS([       \
4847         asm/unistd.h     \
4848         endian.h         \
4849         mqueue.h         \
4850         sys/endian.h     \
4851         sys/epoll.h      \
4852         sys/eventfd.h    \
4853         sys/klog.h       \
4854         sys/poll.h       \
4855         sys/prctl.h      \
4856         sys/signal.h     \
4857         sys/signalfd.h   \
4858         sys/syscall.h    \
4859         sys/sysnvl.h     \
4860         sys/time.h       \
4861         sys/types.h      \
4862         ])
4864 # Verify whether the <linux/futex.h> header is usable.
4865 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4867 save_CFLAGS="$CFLAGS"
4868 CFLAGS="$CFLAGS -D__user="
4869 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4870 #include <linux/futex.h>
4871 ]], [[
4872   return FUTEX_WAIT;
4873 ]])], [
4874 ac_have_usable_linux_futex_h=yes
4875 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4876           [Define to 1 if you have a usable <linux/futex.h> header file.])
4877 AC_MSG_RESULT([yes])
4878 ], [
4879 ac_have_usable_linux_futex_h=no
4880 AC_MSG_RESULT([no])
4882 CFLAGS="$save_CFLAGS"
4885 #----------------------------------------------------------------------------
4886 # Checks for typedefs, structures, and compiler characteristics.
4887 #----------------------------------------------------------------------------
4888 AC_TYPE_UID_T
4889 AC_TYPE_OFF_T
4890 AC_TYPE_SIZE_T
4891 AC_CHECK_HEADERS_ONCE([sys/time.h])
4893 AC_CHECK_TYPE([struct statx], [
4894   AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4895             [Define to 1 if <sys/stat.h> declares struct statx.])
4896 ], [], [
4897   #define _GNU_SOURCE
4898   #include <sys/stat.h>
4902 #----------------------------------------------------------------------------
4903 # Checks for library functions.
4904 #----------------------------------------------------------------------------
4905 AC_FUNC_MEMCMP
4906 AC_FUNC_MMAP
4908 AC_CHECK_LIB([pthread], [pthread_create])
4909 AC_CHECK_LIB([rt], [clock_gettime])
4911 AC_CHECK_FUNCS([     \
4912         aligned_alloc \
4913         clock_gettime\
4914         copy_file_range \
4915         epoll_create \
4916         epoll_pwait  \
4917         getaddrinfo  \
4918         klogctl      \
4919         mallinfo     \
4920         memchr       \
4921         memfd_create \
4922         memset       \
4923         mkdir        \
4924         mremap       \
4925         pipe2        \
4926         ppoll        \
4927         preadv       \
4928         preadv2      \
4929         process_vm_readv  \
4930         process_vm_writev \
4931         pthread_barrier_init       \
4932         pthread_condattr_setclock  \
4933         pthread_mutex_timedlock    \
4934         pthread_rwlock_timedrdlock \
4935         pthread_rwlock_timedwrlock \
4936         pthread_setname_np         \
4937         pthread_spin_lock          \
4938         pthread_yield              \
4939         pwritev      \
4940         pwritev2     \
4941         rawmemchr    \
4942         readlinkat   \
4943         reallocarray \
4944         semtimedop   \
4945         setcontext   \
4946         signalfd     \
4947         sigwaitinfo  \
4948         strchr       \
4949         strdup       \
4950         strpbrk      \
4951         strrchr      \
4952         strstr       \
4953         swapcontext  \
4954         syscall      \
4955         utimensat    \
4956         mempcpy      \
4957         strlcat      \
4958         strlcpy      \
4959         stpncpy      \
4960         strchrnul    \
4961         memrchr      \
4962         strndup      \
4963         close_range  \
4964         wcsncpy
4965         ])
4967 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4968 # libraries with any shared object and/or executable. This is NOT what we
4969 # want for e.g. vgpreload_core-x86-linux.so
4970 LIBS=""
4972 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4973                [test x$ac_cv_func_pthread_barrier_init = xyes])
4974 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4975                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4976 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4977                [test x$ac_cv_func_pthread_spin_lock = xyes])
4978 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4979                [test x$ac_cv_func_pthread_setname_np = xyes])
4980 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4981                [test x$ac_cv_func_copy_file_range = xyes])
4982 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4983                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4984 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4985                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4986 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4987 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4988 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4989                [test x$ac_cv_func_memfd_create = xyes])
4990 AM_CONDITIONAL([HAVE_GETADDRINFO],
4991                [test x$ac_cv_func_getaddrinfo = xyes])
4992 AM_CONDITIONAL([HAVE_CLOSE_RANGE],
4993                [test x$ac_cv_func_close_range = xyes])
4994 AM_CONDITIONAL([HAVE_REALLOCARRAY],
4995                [test x$ac_cv_func_reallocarray = xyes])
4996 AM_CONDITIONAL([HAVE_WCSNCPY],
4997                [test x$ac_cv_func_wcsncpy = xyes])
4998 AM_CONDITIONAL([HAVE_STRLCAT],
4999                [test x$ac_cv_func_strlcat = xyes])
5000 AM_CONDITIONAL([HAVE_STRLCPY],
5001                [test x$ac_cv_func_strlcpy = xyes])
5003 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
5004      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
5005      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
5006   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
5007             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
5010 #----------------------------------------------------------------------------
5011 # MPI checks
5012 #----------------------------------------------------------------------------
5013 # Do we have a useable MPI setup on the primary and/or secondary targets?
5014 # On Linux, by default, assumes mpicc and -m32/-m64
5015 # Note: this is a kludge in that it assumes the specified mpicc 
5016 # understands -m32/-m64 regardless of what is specified using
5017 # --with-mpicc=.
5018 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
5019              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
5021 mflag_primary=
5022 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
5023      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
5024      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
5025      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
5026      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
5027      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
5028      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
5029   mflag_primary=$FLAG_M32
5030 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
5031        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
5032        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
5033        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
5034        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
5035        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
5036   mflag_primary=$FLAG_M64
5037 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
5038   mflag_primary="$FLAG_M32 -arch i386"
5039 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
5040   mflag_primary="$FLAG_M64 -arch x86_64"
5043 mflag_secondary=
5044 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
5045      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
5046      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
5047      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
5048      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
5049   mflag_secondary=$FLAG_M32
5050 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
5051   mflag_secondary="$FLAG_M32 -arch i386"
5055 AC_ARG_WITH(mpicc,
5056    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
5057    MPI_CC=$withval
5059 AC_SUBST(MPI_CC)
5061 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
5062 ## use these values in the check for a functioning mpicc.
5064 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
5065 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
5066 AM_COND_IF([VGCONF_OS_IS_LINUX],
5067            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5068             LDFLAGS_MPI="-fpic -shared"])
5069 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
5070            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5071             LDFLAGS_MPI="-fpic -shared"])
5072 AM_COND_IF([VGCONF_OS_IS_DARWIN],
5073            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
5074             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
5075 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
5076            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5077             LDFLAGS_MPI="-fpic -shared"])
5079 AC_SUBST([CFLAGS_MPI])
5080 AC_SUBST([LDFLAGS_MPI])
5083 ## See if MPI_CC works for the primary target
5085 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
5086 saved_CC=$CC
5087 saved_CFLAGS=$CFLAGS
5088 CC=$MPI_CC
5089 CFLAGS="$CFLAGS_MPI $mflag_primary"
5090 saved_LDFLAGS="$LDFLAGS"
5091 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
5092 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5093 #include <mpi.h>
5094 #include <stdio.h>
5095 ]], [[
5096   int ni, na, nd, comb;
5097   int r = MPI_Init(NULL,NULL);
5098   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5099   r |= MPI_Finalize();
5100   return r; 
5101 ]])], [
5102 ac_have_mpi2_pri=yes
5103 AC_MSG_RESULT([yes, $MPI_CC])
5104 ], [
5105 ac_have_mpi2_pri=no
5106 AC_MSG_RESULT([no])
5108 CC=$saved_CC
5109 CFLAGS=$saved_CFLAGS
5110 LDFLAGS="$saved_LDFLAGS"
5111 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
5113 ## See if MPI_CC works for the secondary target.  Complication: what if
5114 ## there is no secondary target?  We need this to then fail.
5115 ## Kludge this by making MPI_CC something which will surely fail in
5116 ## such a case.
5118 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
5119 saved_CC=$CC
5120 saved_CFLAGS=$CFLAGS
5121 saved_LDFLAGS="$LDFLAGS"
5122 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
5123 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
5124   CC="$MPI_CC this will surely fail"
5125 else
5126   CC=$MPI_CC
5128 CFLAGS="$CFLAGS_MPI $mflag_secondary"
5129 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5130 #include <mpi.h>
5131 #include <stdio.h>
5132 ]], [[
5133   int ni, na, nd, comb;
5134   int r = MPI_Init(NULL,NULL);
5135   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5136   r |= MPI_Finalize();
5137   return r; 
5138 ]])], [
5139 ac_have_mpi2_sec=yes
5140 AC_MSG_RESULT([yes, $MPI_CC])
5141 ], [
5142 ac_have_mpi2_sec=no
5143 AC_MSG_RESULT([no])
5145 CC=$saved_CC
5146 CFLAGS=$saved_CFLAGS
5147 LDFLAGS="$saved_LDFLAGS"
5148 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
5151 #----------------------------------------------------------------------------
5152 # Other library checks
5153 #----------------------------------------------------------------------------
5154 # There now follow some tests for Boost, and OpenMP.  These
5155 # tests are present because Drd has some regression tests that use
5156 # these packages.  All regression test programs all compiled only
5157 # for the primary target.  And so it is important that the configure
5158 # checks that follow, use the correct -m32 or -m64 flag for the
5159 # primary target (called $mflag_primary).  Otherwise, we can end up
5160 # in a situation (eg) where, on amd64-linux, the test for Boost checks
5161 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
5162 # only build (meaning, the primary target is x86-linux), the build
5163 # of the regtest programs that use Boost fails, because they are 
5164 # build as 32-bit (IN THIS EXAMPLE).
5166 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
5167 # NEEDED BY THE REGRESSION TEST PROGRAMS.
5170 # Check whether the boost library 1.35 or later has been installed.
5171 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
5173 AC_MSG_CHECKING([for boost])
5175 AC_LANG(C++)
5176 safe_CXXFLAGS=$CXXFLAGS
5177 CXXFLAGS="$mflag_primary"
5178 safe_LIBS="$LIBS"
5179 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
5181 AC_LINK_IFELSE([AC_LANG_SOURCE([
5182 #include <boost/thread.hpp>
5183 static void thread_func(void)
5184 { }
5185 int main(int argc, char** argv)
5187   boost::thread t(thread_func);
5188   return 0;
5190 ])],
5192 ac_have_boost_1_35=yes
5193 AC_SUBST([BOOST_CFLAGS], [])
5194 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
5195 AC_MSG_RESULT([yes])
5196 ], [
5197 ac_have_boost_1_35=no
5198 AC_MSG_RESULT([no])
5201 LIBS="$safe_LIBS"
5202 CXXFLAGS=$safe_CXXFLAGS
5203 AC_LANG(C)
5205 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
5208 # does this compiler support -fopenmp, does it have the include file
5209 # <omp.h> and does it have libgomp ?
5211 AC_MSG_CHECKING([for OpenMP])
5213 safe_CFLAGS=$CFLAGS
5214 CFLAGS="-fopenmp $mflag_primary -Werror"
5216 AC_LINK_IFELSE([AC_LANG_SOURCE([
5217 #include <omp.h> 
5218 int main(int argc, char** argv)
5220   omp_set_dynamic(0);
5221   return 0;
5223 ])],
5225 ac_have_openmp=yes
5226 AC_MSG_RESULT([yes])
5227 ], [
5228 ac_have_openmp=no
5229 AC_MSG_RESULT([no])
5231 CFLAGS=$safe_CFLAGS
5233 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5236 # Check for __builtin_popcount
5237 AC_MSG_CHECKING([for __builtin_popcount()])
5238 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5239 ]], [[
5240   __builtin_popcount(2);
5241   return 0;
5242 ]])], [
5243 AC_MSG_RESULT([yes])
5244 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5245           [Define to 1 if compiler provides __builtin_popcount().])
5246 ], [
5247 AC_MSG_RESULT([no])
5250 # Check for __builtin_clz
5251 AC_MSG_CHECKING([for __builtin_clz()])
5252 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5253 ]], [[
5254   __builtin_clz(2);
5255   return 0;
5256 ]])], [
5257 AC_MSG_RESULT([yes])
5258 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5259           [Define to 1 if compiler provides __builtin_clz().])
5260 ], [
5261 AC_MSG_RESULT([no])
5264 # Check for __builtin_ctz
5265 AC_MSG_CHECKING([for __builtin_ctz()])
5266 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5267 ]], [[
5268   __builtin_ctz(2);
5269   return 0;
5270 ]])], [
5271 AC_MSG_RESULT([yes])
5272 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5273           [Define to 1 if compiler provides __builtin_ctz().])
5274 ], [
5275 AC_MSG_RESULT([no])
5278 # does this compiler have built-in functions for atomic memory access for the
5279 # primary target ?
5280 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5282 safe_CFLAGS=$CFLAGS
5283 CFLAGS="$mflag_primary"
5285 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5286   int variable = 1;
5287   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5288           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5289 ]])], [
5290   ac_have_builtin_atomic_primary=yes
5291   AC_MSG_RESULT([yes])
5292   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])
5293 ], [
5294   ac_have_builtin_atomic_primary=no
5295   AC_MSG_RESULT([no])
5298 CFLAGS=$safe_CFLAGS
5300 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5301                [test x$ac_have_builtin_atomic_primary = xyes])
5304 # does this compiler have built-in functions for atomic memory access for the
5305 # secondary target ?
5307 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5309 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5311 safe_CFLAGS=$CFLAGS
5312 CFLAGS="$mflag_secondary"
5314 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5315   int variable = 1;
5316   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5317 ]])], [
5318   ac_have_builtin_atomic_secondary=yes
5319   AC_MSG_RESULT([yes])
5320 ], [
5321   ac_have_builtin_atomic_secondary=no
5322   AC_MSG_RESULT([no])
5325 CFLAGS=$safe_CFLAGS
5329 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5330                [test x$ac_have_builtin_atomic_secondary = xyes])
5332 # does this compiler have built-in functions for atomic memory access on
5333 # 64-bit integers for all targets ?
5335 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5337 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5338   #include <stdint.h>
5339 ]], [[
5340   uint64_t variable = 1;
5341   return __sync_add_and_fetch(&variable, 1)
5342 ]])], [
5343   ac_have_builtin_atomic64_primary=yes
5344 ], [
5345   ac_have_builtin_atomic64_primary=no
5348 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5350 safe_CFLAGS=$CFLAGS
5351 CFLAGS="$mflag_secondary"
5353 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5354   #include <stdint.h>
5355 ]], [[
5356   uint64_t variable = 1;
5357   return __sync_add_and_fetch(&variable, 1)
5358 ]])], [
5359   ac_have_builtin_atomic64_secondary=yes
5360 ], [
5361   ac_have_builtin_atomic64_secondary=no
5364 CFLAGS=$safe_CFLAGS
5368 if test x$ac_have_builtin_atomic64_primary = xyes && \
5369    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5370      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5371   AC_MSG_RESULT([yes])
5372   ac_have_builtin_atomic64=yes
5373 else
5374   AC_MSG_RESULT([no])
5375   ac_have_builtin_atomic64=no
5378 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5379                [test x$ac_have_builtin_atomic64 = xyes])
5381                
5382 AC_MSG_CHECKING([if platform has openat2 syscall])
5384 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5385   #include <sys/syscall.h>
5386 ]], [[
5387   return __NR_openat2
5388 ]])], [
5389   ac_have_openat2=yes
5390 ], [
5391   ac_have_openat2=no
5394 AM_CONDITIONAL([HAVE_OPENAT2],
5395                [test x$ac_have_openat2 = xyes])
5397 # does g++ have built-in functions for atomic memory access ?
5398 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5400 safe_CXXFLAGS=$CXXFLAGS
5401 CXXFLAGS="$mflag_primary"
5403 AC_LANG_PUSH(C++)
5404 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5405   int variable = 1;
5406   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5407           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5408 ]])], [
5409   ac_have_builtin_atomic_cxx=yes
5410   AC_MSG_RESULT([yes])
5411   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5412 ], [
5413   ac_have_builtin_atomic_cxx=no
5414   AC_MSG_RESULT([no])
5416 AC_LANG_POP(C++)
5418 CXXFLAGS=$safe_CXXFLAGS
5420 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5423 if test x$ac_have_usable_linux_futex_h = xyes \
5424         -a x$ac_have_builtin_atomic_primary = xyes; then
5425   ac_enable_linux_ticket_lock_primary=yes
5427 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5428                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5430 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5431         -a x$ac_have_usable_linux_futex_h = xyes \
5432         -a x$ac_have_builtin_atomic_secondary = xyes; then
5433   ac_enable_linux_ticket_lock_secondary=yes
5435 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5436                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5439 # does libstdc++ support annotating shared pointers ?
5440 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5442 safe_CXXFLAGS=$CXXFLAGS
5443 CXXFLAGS="-std=c++0x"
5445 AC_LANG_PUSH(C++)
5446 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5447   #include <memory>
5448 ]], [[
5449   std::shared_ptr<int> p
5450 ]])], [
5451   ac_have_shared_ptr=yes
5452 ], [
5453   ac_have_shared_ptr=no
5455 if test x$ac_have_shared_ptr = xyes; then
5456   # If compilation of the program below fails because of a syntax error
5457   # triggered by substituting one of the annotation macros then that
5458   # means that libstdc++ supports these macros.
5459   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5460     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5461     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5462     #include <memory>
5463   ]], [[
5464     std::shared_ptr<int> p
5465   ]])], [
5466     ac_have_shared_pointer_annotation=no
5467     AC_MSG_RESULT([no])
5468   ], [
5469     ac_have_shared_pointer_annotation=yes
5470     AC_MSG_RESULT([yes])
5471     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5472               [Define to 1 if libstd++ supports annotating shared pointers])
5473   ])
5474 else
5475   ac_have_shared_pointer_annotation=no
5476   AC_MSG_RESULT([no])
5478 AC_LANG_POP(C++)
5480 CXXFLAGS=$safe_CXXFLAGS
5482 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5483                [test x$ac_have_shared_pointer_annotation = xyes])
5485 # checking for GNU libc C17 aligned_alloc
5486 # just check glibc version rather than trying to muck around
5487 # checking the runtime behaviour or seeing if it is a weak alias
5488 AC_MSG_CHECKING([for AT_GNU_LIBC_C17_ALIGNED_ALLOC])
5489 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5490 #include <features.h>
5491 ]], [[
5492 #if !defined(__GLIBC__) || __GLIBC__ != 2 || !defined(__GLIBC_MINOR__) || __GLIBC_MINOR__ < 38
5493 #error "not GNU libc 2.38 or later"
5494 #endif
5495 ]])], [
5496     AC_MSG_RESULT([yes])
5497     AC_DEFINE([HAVE_GNU_LIBC_C17_ALIGNED_ALLOC], 1,
5498               [Define to 1 if you have GNU libc C17 aligned_alloc.])
5500 ], [
5501     AC_MSG_RESULT([no])
5504 # Check for C11 thrd_create()
5505 AC_MSG_CHECKING([for thrd_create()])
5506 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
5507 #include <threads.h>
5508 int thrd_entry(void *arg) { return 0; }
5509 ], [[thrd_t thr; return thrd_create(&thr, thrd_entry, NULL);]])],
5511 ac_cxx_have_thrd_create=yes
5512 AC_MSG_RESULT([yes])
5513 ], [
5514 ac_cxx_have_thrd_create=no
5515 AC_MSG_RESULT([no])
5518 AM_CONDITIONAL(HAVE_THRD_CREATE, test x$ac_cxx_have_thrd_create = xyes)
5522 #----------------------------------------------------------------------------
5523 # Ok.  We're done checking.
5524 #----------------------------------------------------------------------------
5526 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5527 AC_CONFIG_FILES([
5528    Makefile 
5529    VEX/Makefile:Makefile.vex.in
5530    valgrind.spec
5531    valgrind.pc
5532    glibc-2.X.supp
5533    glibc-2.X-helgrind.supp
5534    glibc-2.X-drd.supp
5535    include/valgrind.h
5536    docs/Makefile 
5537    docs/xml/vg-entities.xml
5538    tests/Makefile 
5539    tests/vg_regtest 
5540    perf/Makefile 
5541    perf/vg_perf
5542    gdbserver_tests/Makefile
5543    gdbserver_tests/solaris/Makefile
5544    include/Makefile 
5545    auxprogs/Makefile
5546    mpi/Makefile
5547    coregrind/Makefile 
5548    memcheck/Makefile
5549    memcheck/tests/Makefile
5550    memcheck/tests/common/Makefile
5551    memcheck/tests/amd64/Makefile
5552    memcheck/tests/x86/Makefile
5553    memcheck/tests/linux/Makefile
5554    memcheck/tests/linux/debuginfod-check.vgtest
5555    memcheck/tests/darwin/Makefile
5556    memcheck/tests/solaris/Makefile
5557    memcheck/tests/freebsd/Makefile
5558    memcheck/tests/amd64-linux/Makefile
5559    memcheck/tests/arm64-linux/Makefile
5560    memcheck/tests/x86-linux/Makefile
5561    memcheck/tests/amd64-solaris/Makefile
5562    memcheck/tests/x86-solaris/Makefile
5563    memcheck/tests/amd64-freebsd/Makefile
5564    memcheck/tests/x86-freebsd/Makefile
5565    memcheck/tests/ppc32/Makefile
5566    memcheck/tests/ppc64/Makefile
5567    memcheck/tests/s390x/Makefile
5568    memcheck/tests/mips32/Makefile
5569    memcheck/tests/mips64/Makefile
5570    memcheck/tests/vbit-test/Makefile
5571    cachegrind/Makefile
5572    cachegrind/tests/Makefile
5573    cachegrind/tests/x86/Makefile
5574    cachegrind/cg_annotate
5575    cachegrind/cg_diff
5576    cachegrind/cg_merge
5577    callgrind/Makefile
5578    callgrind/callgrind_annotate
5579    callgrind/callgrind_control
5580    callgrind/tests/Makefile
5581    helgrind/Makefile
5582    helgrind/tests/Makefile
5583    drd/Makefile
5584    drd/scripts/download-and-build-splash2
5585    drd/tests/Makefile
5586    massif/Makefile
5587    massif/tests/Makefile
5588    massif/ms_print
5589    dhat/Makefile
5590    dhat/tests/Makefile
5591    lackey/Makefile
5592    lackey/tests/Makefile
5593    none/Makefile
5594    none/tests/Makefile
5595    none/tests/scripts/Makefile
5596    none/tests/amd64/Makefile
5597    none/tests/ppc32/Makefile
5598    none/tests/ppc64/Makefile
5599    none/tests/x86/Makefile
5600    none/tests/arm/Makefile
5601    none/tests/arm64/Makefile
5602    none/tests/s390x/Makefile
5603    none/tests/mips32/Makefile
5604    none/tests/mips64/Makefile
5605    none/tests/nanomips/Makefile
5606    none/tests/linux/Makefile
5607    none/tests/darwin/Makefile
5608    none/tests/solaris/Makefile
5609    none/tests/freebsd/Makefile
5610    none/tests/amd64-linux/Makefile
5611    none/tests/x86-linux/Makefile
5612    none/tests/amd64-darwin/Makefile
5613    none/tests/x86-darwin/Makefile
5614    none/tests/amd64-solaris/Makefile
5615    none/tests/x86-solaris/Makefile
5616    none/tests/x86-freebsd/Makefile
5617    exp-bbv/Makefile
5618    exp-bbv/tests/Makefile
5619    exp-bbv/tests/x86/Makefile
5620    exp-bbv/tests/x86-linux/Makefile
5621    exp-bbv/tests/amd64-linux/Makefile
5622    exp-bbv/tests/ppc32-linux/Makefile
5623    exp-bbv/tests/arm-linux/Makefile
5624    shared/Makefile
5625    solaris/Makefile
5627 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5628                 [chmod +x coregrind/link_tool_exe_linux])
5629 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5630                 [chmod +x coregrind/link_tool_exe_freebsd])
5631 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5632                 [chmod +x coregrind/link_tool_exe_darwin])
5633 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5634                 [chmod +x coregrind/link_tool_exe_solaris])
5635 AC_CONFIG_FILES([tests/filter_stderr_basic],
5636                 [chmod +x tests/filter_stderr_basic])
5637 AC_CONFIG_FILES([tests/filter_discards],
5638                 [chmod +x tests/filter_discards])
5639 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5640                 [chmod +x memcheck/tests/filter_stderr])
5641 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5642                 [chmod +x memcheck/tests/filter_dw4])
5643 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5644                 [chmod +x memcheck/tests/filter_overlaperror])
5645 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5646                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5647 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5648                 [chmod +x gdbserver_tests/filter_gdb])
5649 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5650                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5651 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5652                 [chmod +x gdbserver_tests/filter_stderr])
5653 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5654                 [chmod +x gdbserver_tests/filter_vgdb])
5655 AC_CONFIG_FILES([drd/tests/filter_stderr],
5656                 [chmod +x drd/tests/filter_stderr])
5657 AC_CONFIG_FILES([drd/tests/filter_error_count],
5658                 [chmod +x drd/tests/filter_error_count])
5659 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5660                 [chmod +x drd/tests/filter_error_summary])
5661 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5662                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5663 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5664                 [chmod +x drd/tests/filter_thread_no])
5665 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5666                 [chmod +x drd/tests/filter_xml_and_thread_no])
5667 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5668                 [chmod +x helgrind/tests/filter_stderr])
5669 AC_OUTPUT
5671 cat<<EOF
5673                     Version: ${VERSION}
5674          Maximum build arch: ${ARCH_MAX}
5675          Primary build arch: ${VGCONF_ARCH_PRI}
5676        Secondary build arch: ${VGCONF_ARCH_SEC}
5677                    Build OS: ${VGCONF_OS}
5678      Link Time Optimisation: ${vg_cv_lto}
5679        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5680      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5681            Platform variant: ${VGCONF_PLATVARIANT}
5682       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5683          Default supp files: ${DEFAULT_SUPP}