Bug 445300 [PATCH] Fix building tests with Musl
[valgrind.git] / configure.ac
blob4623d12b5b1c94771a11aee099adf3ad8485c252
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], [19])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [GIT])
21 m4_define([v_rel_date], ["?? ??? 202?"])
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 AC_PROG_CC
54 AM_PROG_CC_C_O
55 AC_PROG_CPP
56 AC_PROG_CXX
57 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
58 # autoconf 2.59).  If we ever have any Objective-C code in the Valgrind code
59 # base (eg. most likely as Darwin-specific tests) we'll need one of the
60 # following:
61 # - put AC_PROG_OBJC in a Darwin-specific part of this file
62 # - Use AC_PROG_OBJC here and up the minimum autoconf version
63 # - Use the following, which is apparently equivalent:
64 #     m4_ifdef([AC_PROG_OBJC],
65 #        [AC_PROG_OBJC],
66 #        [AC_CHECK_TOOL([OBJC], [gcc])
67 #         AC_SUBST([OBJC])
68 #         AC_SUBST([OBJCFLAGS])
69 #        ])
70 AC_PROG_RANLIB
71 # Set LTO_RANLIB variable to an lto enabled ranlib
72 if test "x$LTO_RANLIB" = "x"; then
73   AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
75 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
77 # provide a very basic definition for AC_PROG_SED if it's not provided by
78 # autoconf (as e.g. in autoconf 2.59).
79 m4_ifndef([AC_PROG_SED],
80           [AC_DEFUN([AC_PROG_SED],
81                     [AC_ARG_VAR([SED])
82                      AC_CHECK_PROGS([SED],[gsed sed])])])
83 AC_PROG_SED
85 # If no AR variable was specified, look up the name of the archiver. Otherwise
86 # do not touch the AR variable.
87 if test "x$AR" = "x"; then
88   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
90 AC_ARG_VAR([AR],[Archiver command])
92 # same for LTO_AR variable for lto enabled archiver
93 if test "x$LTO_AR" = "x"; then
94   AC_PATH_PROGS([LTO_AR], [gcc-ar])
96 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
99 # Check for the compiler support
100 if test "${GCC}" != "yes" ; then
101    AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
104 # figure out where perl lives
105 AC_PATH_PROG(PERL, perl)
107 # figure out where gdb lives
108 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
109 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
111 # some older automake's don't have it so try something on our own
112 ifdef([AM_PROG_AS],[AM_PROG_AS],
114 AS="${CC}"
115 AC_SUBST(AS)
117 ASFLAGS=""
118 AC_SUBST(ASFLAGS)
122 # Check if 'diff' supports -u (universal diffs) and use it if possible.
124 AC_MSG_CHECKING([for diff -u])
125 AC_SUBST(DIFF)
127 # Comparing two identical files results in 0.
128 tmpfile="tmp-xxx-yyy-zzz"
129 touch $tmpfile;
130 if diff -u $tmpfile $tmpfile ; then
131     AC_MSG_RESULT([yes])
132     DIFF="diff -u"
133 else
134     AC_MSG_RESULT([no])
135     DIFF="diff"
137 rm $tmpfile
139 # Make sure we can compile in C99 mode.
140 AC_PROG_CC_C99
141 if test "$ac_cv_prog_cc_c99" = "no"; then
142     AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
145 # We don't want gcc < 3.0
146 AC_MSG_CHECKING([for a supported version of gcc])
148 # Obtain the compiler version.
150 # A few examples of how the ${CC} --version output looks like:
152 # ######## gcc variants ########
153 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
154 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
155 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
156 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
157 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
158 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
159 # 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)
161 # ######## clang variants ########
162 # Clang: clang version 2.9 (tags/RELEASE_29/final)
163 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
164 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
166 # ######## Apple LLVM variants ########
167 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
168 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
171 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
172 then
173     is_clang="applellvm"
174     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
175 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
176 then
177     is_clang="clang"
178     # Don't use -dumpversion with clang: it will always produce "4.2.1".
179     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
180 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
181 then
182     is_clang="icc"
183     gcc_version=`${CC} -dumpversion 2>/dev/null`
184 else
185     is_clang="notclang"
186     gcc_version=`${CC} -dumpversion 2>/dev/null`
187     if test "x$gcc_version" = x; then
188         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
189     fi
192 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
193 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
195 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
196 # statements have to be quoted.
197 case "${is_clang}-${gcc_version}" in
198      applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
199         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
200         ;;
201      icc-1[[3-9]].*|icc-202[[0-9]].*)
202         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
203         ;;
204      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
205         AC_MSG_RESULT([ok (${gcc_version})])
206         ;;
207      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
208         AC_MSG_RESULT([ok (clang-${gcc_version})])
209         ;;
210      *)
211         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
212         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
213         ;;
214 esac
216 #----------------------------------------------------------------------------
217 # Arch/OS/platform tests.
218 #----------------------------------------------------------------------------
219 # We create a number of arch/OS/platform-related variables.  We prefix them
220 # all with "VGCONF_" which indicates that they are defined at
221 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
222 # variables used when compiling C files.
224 AC_CANONICAL_HOST
226 AC_MSG_CHECKING([for a supported CPU])
228 # ARCH_MAX reflects the most that this CPU can do: for example if it
229 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
230 # Ditto for amd64.  It is used for more configuration below, but is not used
231 # outside this file.
233 # Power PC returns powerpc for Big Endian.  This was not changed when Little
234 # Endian support was added to the 64-bit architecture.  The 64-bit Little
235 # Endian systems explicitly state le in the host_cpu.  For clarity in the
236 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
237 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
238 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
239 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
240 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
241 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
242 # Little Endian.
244 case "${host_cpu}" in
245      i?86) 
246         AC_MSG_RESULT([ok (${host_cpu})])
247         ARCH_MAX="x86"
248         ;;
250      x86_64|amd64) 
251         AC_MSG_RESULT([ok (${host_cpu})])
252         ARCH_MAX="amd64"
253         ;;
255      powerpc64)
256      # this only referrs to 64-bit Big Endian
257         AC_MSG_RESULT([ok (${host_cpu})])
258         ARCH_MAX="ppc64be"
259         ;;
261      powerpc64le)
262      # this only referrs to 64-bit Little Endian
263         AC_MSG_RESULT([ok (${host_cpu})])
264         ARCH_MAX="ppc64le"
265         ;;
267      powerpc)
268         # On Linux this means only a 32-bit capable CPU.
269         AC_MSG_RESULT([ok (${host_cpu})])
270         ARCH_MAX="ppc32"
271         ;;
273      s390x)
274         AC_MSG_RESULT([ok (${host_cpu})])
275         ARCH_MAX="s390x"
276         ;;
278      armv7*)
279         AC_MSG_RESULT([ok (${host_cpu})])
280         ARCH_MAX="arm"
281         ;;
283      aarch64*)
284        AC_MSG_RESULT([ok (${host_cpu})])
285        ARCH_MAX="arm64"
286        ;;
288      mips)
289         AC_MSG_RESULT([ok (${host_cpu})])
290         ARCH_MAX="mips32"
291         ;;
293      mipsel)
294         AC_MSG_RESULT([ok (${host_cpu})])
295         ARCH_MAX="mips32"
296         ;;
298      mipsisa32r2)
299         AC_MSG_RESULT([ok (${host_cpu})])
300         ARCH_MAX="mips32"
301         ;;
303      mips64*)
304         AC_MSG_RESULT([ok (${host_cpu})])
305         ARCH_MAX="mips64"
306         ;;
308      mipsisa64*)
309         AC_MSG_RESULT([ok (${host_cpu})])
310         ARCH_MAX="mips64"
311         ;;
312      nanomips)
313         AC_MSG_RESULT([ok (${host_cpu})])
314         ARCH_MAX="nanomips"
315         ;;
317      *) 
318         AC_MSG_RESULT([no (${host_cpu})])
319         AC_MSG_ERROR([Unsupported host architecture. Sorry])
320         ;;
321 esac
323 #----------------------------------------------------------------------------
325 # Sometimes it's convenient to subvert the bi-arch build system and
326 # just have a single build even though the underlying platform is
327 # capable of both.  Hence handle --enable-only64bit and
328 # --enable-only32bit.  Complain if both are issued :-)
329 # [Actually, if either of these options are used, I think both get built,
330 # but only one gets installed.  So if you use an in-place build, both can be
331 # used. --njn]
333 # Check if a 64-bit only build has been requested
334 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
335    [AC_ARG_ENABLE(only64bit, 
336       [  --enable-only64bit      do a 64-bit only build],
337       [vg_cv_only64bit=$enableval],
338       [vg_cv_only64bit=no])])
340 # Check if a 32-bit only build has been requested
341 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
342    [AC_ARG_ENABLE(only32bit, 
343       [  --enable-only32bit      do a 32-bit only build],
344       [vg_cv_only32bit=$enableval],
345       [vg_cv_only32bit=no])])
347 # Stay sane
348 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
349    AC_MSG_ERROR(
350       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
353 #----------------------------------------------------------------------------
355 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
356 # compilation of many C files via -VGO_$(VGCONF_OS) and
357 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
358 AC_MSG_CHECKING([for a supported OS])
359 AC_SUBST(VGCONF_OS)
361 DEFAULT_SUPP=""
363 case "${host_os}" in
364      *linux*)
365         AC_MSG_RESULT([ok (${host_os})])
366         VGCONF_OS="linux"
368         # Ok, this is linux. Check the kernel version
369         AC_MSG_CHECKING([for the kernel version])
371         kernel=`uname -r`
373         case "${kernel}" in
374              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
375                     AC_MSG_RESULT([unsupported (${kernel})])
376                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
377                     ;;
379              *)
380                     AC_MSG_RESULT([2.6 or later (${kernel})])
381                     ;;
382         esac
384         ;;
386      *freebsd*)
387         AC_MSG_RESULT([ok (${host_os})])
388         VGCONF_OS="freebsd"
389         AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
390         AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
391         AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
392         AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
393         AC_DEFINE([FREEBSD_13], 1300, [FREEBSD_VERS value for FreeBSD 13.x])
394         AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
396         AC_MSG_CHECKING([for the kernel version])
397         kernel=`uname -r`
399         case "${kernel}" in
400         10.*)
401            AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
402            AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
403            ;;
404         11.*)
405            AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
406            AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
407            ;;
408         12.*)
409            case "${kernel}" in
410            12.[[0-1]]-*)
411               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
412               AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
413               ;;
414            *)
415               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
416               AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
417               ;;
418            esac
419            ;;
420         13.*)
421            AC_MSG_RESULT([FreeBSD 13.x (${kernel})])
422            AC_DEFINE([FREEBSD_VERS], FREEBSD_13, [FreeBSD version])
423            ;;
424         14.*)
425            AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
426            AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
427            ;;
428         *)
429            AC_MSG_RESULT([unsupported (${kernel})])
430            AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x])
431            ;;
432         esac
434         DEFAULT_SUPP="freebsd.supp freebsd-helgrind.supp freebsd-drd.supp ${DEFAULT_SUPP}"
435         ;;
437      *darwin*)
438         AC_MSG_RESULT([ok (${host_os})])
439         VGCONF_OS="darwin"
440         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
441         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
442         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
443         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
444         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
445         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
446         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
447         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
448         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
450         AC_MSG_CHECKING([for the kernel version])
451         kernel=`uname -r`
453         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
454         # has only one relevant version, the OS version. The `uname` check
455         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
456         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
457         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
458         # and we don't know of an macros similar to __GLIBC__ to get that info.
459         #
460         # XXX: `uname -r` won't do the right thing for cross-compiles, but
461         # that's not a problem yet.
462         #
463         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
464         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
465         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
466         # time support for 10.5 (the 9.* pattern just below), I'll leave it
467         # in for now, just in case anybody wants to give it a try.  But I'm
468         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
469         case "${kernel}" in
470              9.*)
471                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
472                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
473                   DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
474                   DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
475                   ;;
476              10.*)
477                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
478                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
479                   DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
480                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
481                   ;;
482              11.*)
483                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
484                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
485                   DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
486                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
487                   ;;
488              12.*)
489                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
490                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
491                   DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
492                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
493                   ;;
494              13.*)
495                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
496                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
497                   DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
498                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
499                   ;;
500              14.*)
501                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
502                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
503                   DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
504                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
505                   ;;
506              15.*)
507                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
508                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
509                   DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
510                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
511                   ;;
512              16.*)
513                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
514                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
515                   DEFAULT_SUPP="darwin16.supp ${DEFAULT_SUPP}"
516                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
517                   ;;
518              17.*)
519                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
520                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
521                   DEFAULT_SUPP="darwin17.supp ${DEFAULT_SUPP}"
522                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
523                   ;;
524              *) 
525                   AC_MSG_RESULT([unsupported (${kernel})])
526                   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)])
527                   ;;
528         esac
529         ;;
531      solaris2.11*)
532         AC_MSG_RESULT([ok (${host_os})])
533         VGCONF_OS="solaris"
535         uname_v=$( uname -v )
536         case "$uname_v" in
537              11.4.*)
538                  DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
539                  ;;
540              *)
541                  DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
542                  ;;
543         esac
544         ;;
546      solaris2.12*)
547         AC_MSG_RESULT([ok (${host_os})])
548         VGCONF_OS="solaris"
549         DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
550         ;;
552      *) 
553         AC_MSG_RESULT([no (${host_os})])
554         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
555         ;;
556 esac
558 #----------------------------------------------------------------------------
560 # If we are building on a 64 bit platform test to see if the system
561 # supports building 32 bit programs and disable 32 bit support if it
562 # does not support building 32 bit programs
564 case "$ARCH_MAX-$VGCONF_OS" in
565      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
566         AC_MSG_CHECKING([for 32 bit build support])
567         safe_CFLAGS=$CFLAGS
568         CFLAGS="-m32"
569         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
570           return 0;
571         ]])], [
572         AC_MSG_RESULT([yes])
573         ], [
574         vg_cv_only64bit="yes"
575         AC_MSG_RESULT([no])
576         ])
577         CFLAGS=$safe_CFLAGS;;
578     mips64-linux)
579         AC_MSG_CHECKING([for 32 bit build support])
580         safe_CFLAGS=$CFLAGS
581         CFLAGS="$CFLAGS -mips32 -mabi=32"
582         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
583           #include <sys/prctl.h>
584         ]], [[]])], [
585         AC_MSG_RESULT([yes])
586         ], [
587         vg_cv_only64bit="yes"
588         AC_MSG_RESULT([no])
589         ])
590         CFLAGS=$safe_CFLAGS;;
591 esac
593 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
594    AC_MSG_ERROR(
595       [--enable-only32bit was specified but system does not support 32 bit builds])
598 #----------------------------------------------------------------------------
600 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
601 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
602 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
603 # above) will be "amd64" since that reflects the most that this cpu can do,
604 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
605 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
606 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
607 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
608 AC_SUBST(VGCONF_ARCH_PRI)
610 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
611 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
612 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
613 # It is empty if there is no secondary target.
614 AC_SUBST(VGCONF_ARCH_SEC)
616 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
617 # The entire system, including regression and performance tests, will be
618 # built for this target.  The "_CAPS" indicates that the name is in capital
619 # letters, and it also uses '_' rather than '-' as a separator, because it's
620 # used to create various Makefile variables, which are all in caps by
621 # convention and cannot contain '-' characters.  This is in contrast to
622 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
623 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
625 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
626 # Valgrind and tools will also be built for this target, but not the
627 # regression or performance tests.
629 # By default, the primary arch is the same as the "max" arch, as commented
630 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
631 # the big case statement just below here, in the case where we're building
632 # on a 64 bit machine but have been requested only to do a 32 bit build.
633 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
635 AC_MSG_CHECKING([for a supported CPU/OS combination])
637 # NB.  The load address for a given platform may be specified in more 
638 # than one place, in some cases, depending on whether we're doing a biarch,
639 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
640 # Be careful to give consistent values in all subcases.  Also, all four
641 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
642 # even if it is to "0xUNSET".
644 case "$ARCH_MAX-$VGCONF_OS" in
645      x86-linux)
646         VGCONF_ARCH_PRI="x86"
647         VGCONF_ARCH_SEC=""
648         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
649         VGCONF_PLATFORM_SEC_CAPS=""
650         valt_load_address_pri_norml="0x58000000"
651         valt_load_address_pri_inner="0x38000000"
652         valt_load_address_sec_norml="0xUNSET"
653         valt_load_address_sec_inner="0xUNSET"
654         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
655         ;;
656      amd64-linux)
657         valt_load_address_sec_norml="0xUNSET"
658         valt_load_address_sec_inner="0xUNSET"
659         if test x$vg_cv_only64bit = xyes; then
660            VGCONF_ARCH_PRI="amd64"
661            VGCONF_ARCH_SEC=""
662            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
663            VGCONF_PLATFORM_SEC_CAPS=""
664            valt_load_address_pri_norml="0x58000000"
665            valt_load_address_pri_inner="0x38000000"
666         elif test x$vg_cv_only32bit = xyes; then
667            VGCONF_ARCH_PRI="x86"
668            VGCONF_ARCH_SEC=""
669            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
670            VGCONF_PLATFORM_SEC_CAPS=""
671            valt_load_address_pri_norml="0x58000000"
672            valt_load_address_pri_inner="0x38000000"
673         else
674            VGCONF_ARCH_PRI="amd64"
675            VGCONF_ARCH_SEC="x86"
676            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
677            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
678            valt_load_address_pri_norml="0x58000000"
679            valt_load_address_pri_inner="0x38000000"
680            valt_load_address_sec_norml="0x58000000"
681            valt_load_address_sec_inner="0x38000000"
682         fi
683         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
684         ;;
685      ppc32-linux)
686         VGCONF_ARCH_PRI="ppc32"
687         VGCONF_ARCH_SEC=""
688         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
689         VGCONF_PLATFORM_SEC_CAPS=""
690         valt_load_address_pri_norml="0x58000000"
691         valt_load_address_pri_inner="0x38000000"
692         valt_load_address_sec_norml="0xUNSET"
693         valt_load_address_sec_inner="0xUNSET"
694         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
695         ;;
696      ppc64be-linux)
697         valt_load_address_sec_norml="0xUNSET"
698         valt_load_address_sec_inner="0xUNSET"
699         if test x$vg_cv_only64bit = xyes; then
700            VGCONF_ARCH_PRI="ppc64be"
701            VGCONF_ARCH_SEC=""
702            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
703            VGCONF_PLATFORM_SEC_CAPS=""
704            valt_load_address_pri_norml="0x58000000"
705            valt_load_address_pri_inner="0x38000000"
706         elif test x$vg_cv_only32bit = xyes; then
707            VGCONF_ARCH_PRI="ppc32"
708            VGCONF_ARCH_SEC=""
709            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
710            VGCONF_PLATFORM_SEC_CAPS=""
711            valt_load_address_pri_norml="0x58000000"
712            valt_load_address_pri_inner="0x38000000"
713         else
714            VGCONF_ARCH_PRI="ppc64be"
715            VGCONF_ARCH_SEC="ppc32"
716            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
717            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
718            valt_load_address_pri_norml="0x58000000"
719            valt_load_address_pri_inner="0x38000000"
720            valt_load_address_sec_norml="0x58000000"
721            valt_load_address_sec_inner="0x38000000"
722         fi
723         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
724         ;;
725      ppc64le-linux)
726         # Little Endian is only supported on PPC64
727         valt_load_address_sec_norml="0xUNSET"
728         valt_load_address_sec_inner="0xUNSET"
729         VGCONF_ARCH_PRI="ppc64le"
730         VGCONF_ARCH_SEC=""
731         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
732         VGCONF_PLATFORM_SEC_CAPS=""
733         valt_load_address_pri_norml="0x58000000"
734         valt_load_address_pri_inner="0x38000000"
735         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
736        ;;
737      x86-freebsd)
738         VGCONF_ARCH_PRI="x86"
739         VGCONF_ARCH_SEC=""
740         VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
741         VGCONF_PLATFORM_SEC_CAPS=""
742         valt_load_address_pri_norml="0x38000000"
743         valt_load_address_pri_inner="0x28000000"
744         valt_load_address_sec_norml="0xUNSET"
745         valt_load_address_sec_inner="0xUNSET"
746         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
747         ;;
748      amd64-freebsd)
749         if test x$vg_cv_only64bit = xyes; then
750            VGCONF_ARCH_PRI="amd64"
751            VGCONF_ARCH_SEC=""
752            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
753            VGCONF_PLATFORM_SEC_CAPS=""
754         elif test x$vg_cv_only32bit = xyes; then
755            VGCONF_ARCH_PRI="x86"
756            VGCONF_ARCH_SEC=""
757            VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
758            VGCONF_PLATFORM_SEC_CAPS=""
759         else
760            VGCONF_ARCH_PRI="amd64"
761            VGCONF_ARCH_SEC="x86"
762            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
763            VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
764         fi
765         # These work with either base clang or ports installed gcc
766         # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
767         if test x$is_clang = xclang ; then
768            FLAG_32ON64="-B/usr/lib32"
769         else
770            GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
771            FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
772         fi
773         valt_load_address_pri_norml="0x38000000"
774         valt_load_address_pri_inner="0x28000000"
775         valt_load_address_sec_norml="0x38000000"
776         valt_load_address_sec_inner="0x28000000"
777         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
778         ;;
779      # Darwin gets identified as 32-bit even when it supports 64-bit.
780      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
781      # all Macs support both 32-bit and 64-bit, so we just build both.  If
782      # someone has a really old 32-bit only machine they can (hopefully?)
783      # build with --enable-only32bit.  See bug 243362.
784      x86-darwin|amd64-darwin)
785         ARCH_MAX="amd64"
786         valt_load_address_sec_norml="0xUNSET"
787         valt_load_address_sec_inner="0xUNSET"
788         if test x$vg_cv_only64bit = xyes; then
789            VGCONF_ARCH_PRI="amd64"
790            VGCONF_ARCH_SEC=""
791            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
792            VGCONF_PLATFORM_SEC_CAPS=""
793            valt_load_address_pri_norml="0x158000000"
794            valt_load_address_pri_inner="0x138000000"
795         elif test x$vg_cv_only32bit = xyes; then
796            VGCONF_ARCH_PRI="x86"
797            VGCONF_ARCH_SEC=""
798            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
799            VGCONF_PLATFORM_SEC_CAPS=""
800            VGCONF_ARCH_PRI_CAPS="x86"
801            valt_load_address_pri_norml="0x58000000"
802            valt_load_address_pri_inner="0x38000000"
803         else
804            VGCONF_ARCH_PRI="amd64"
805            VGCONF_ARCH_SEC="x86"
806            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
807            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
808            valt_load_address_pri_norml="0x158000000"
809            valt_load_address_pri_inner="0x138000000"
810            valt_load_address_sec_norml="0x58000000"
811            valt_load_address_sec_inner="0x38000000"
812         fi
813         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
814         ;;
815      arm-linux) 
816         VGCONF_ARCH_PRI="arm"
817         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
818         VGCONF_PLATFORM_SEC_CAPS=""
819         valt_load_address_pri_norml="0x58000000"
820         valt_load_address_pri_inner="0x38000000"
821         valt_load_address_sec_norml="0xUNSET"
822         valt_load_address_sec_inner="0xUNSET"
823         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
824         ;;
825      arm64-linux)
826         valt_load_address_sec_norml="0xUNSET"
827         valt_load_address_sec_inner="0xUNSET"
828         if test x$vg_cv_only64bit = xyes; then
829            VGCONF_ARCH_PRI="arm64"
830            VGCONF_ARCH_SEC=""
831            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
832            VGCONF_PLATFORM_SEC_CAPS=""
833            valt_load_address_pri_norml="0x58000000"
834            valt_load_address_pri_inner="0x38000000"
835         elif test x$vg_cv_only32bit = xyes; then
836            VGCONF_ARCH_PRI="arm"
837            VGCONF_ARCH_SEC=""
838            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
839            VGCONF_PLATFORM_SEC_CAPS=""
840            valt_load_address_pri_norml="0x58000000"
841            valt_load_address_pri_inner="0x38000000"
842         else
843            VGCONF_ARCH_PRI="arm64"
844            VGCONF_ARCH_SEC="arm"
845            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
846            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
847            valt_load_address_pri_norml="0x58000000"
848            valt_load_address_pri_inner="0x38000000"
849            valt_load_address_sec_norml="0x58000000"
850            valt_load_address_sec_inner="0x38000000"
851         fi
852         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
853         ;;
854      s390x-linux)
855         VGCONF_ARCH_PRI="s390x"
856         VGCONF_ARCH_SEC=""
857         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
858         VGCONF_PLATFORM_SEC_CAPS=""
859         # To improve branch prediction hit rate we want to have
860         # the generated code close to valgrind (host) code
861         valt_load_address_pri_norml="0x800000000"
862         valt_load_address_pri_inner="0x810000000"
863         valt_load_address_sec_norml="0xUNSET"
864         valt_load_address_sec_inner="0xUNSET"
865         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
866         ;;
867      mips32-linux) 
868         VGCONF_ARCH_PRI="mips32"
869         VGCONF_ARCH_SEC=""
870         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
871         VGCONF_PLATFORM_SEC_CAPS=""
872         valt_load_address_pri_norml="0x58000000"
873         valt_load_address_pri_inner="0x38000000"
874         valt_load_address_sec_norml="0xUNSET"
875         valt_load_address_sec_inner="0xUNSET"
876         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
877         ;;
878      mips64-linux)
879         valt_load_address_sec_norml="0xUNSET"
880         valt_load_address_sec_inner="0xUNSET"
881         if test x$vg_cv_only64bit = xyes; then
882             VGCONF_ARCH_PRI="mips64"
883             VGCONF_PLATFORM_SEC_CAPS=""
884             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
885             VGCONF_PLATFORM_SEC_CAPS=""
886             valt_load_address_pri_norml="0x58000000"
887             valt_load_address_pri_inner="0x38000000"
888         elif test x$vg_cv_only32bit = xyes; then
889             VGCONF_ARCH_PRI="mips32"
890             VGCONF_ARCH_SEC=""
891             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
892             VGCONF_PLATFORM_SEC_CAPS=""
893             valt_load_address_pri_norml="0x58000000"
894             valt_load_address_pri_inner="0x38000000"
895         else
896             VGCONF_ARCH_PRI="mips64"
897             VGCONF_ARCH_SEC="mips32"
898             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
899             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
900             valt_load_address_pri_norml="0x58000000"
901             valt_load_address_pri_inner="0x38000000"
902             valt_load_address_sec_norml="0x58000000"
903             valt_load_address_sec_inner="0x38000000"
904         fi
905         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
906         ;;
907      nanomips-linux)
908         VGCONF_ARCH_PRI="nanomips"
909         VGCONF_ARCH_SEC=""
910         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
911         VGCONF_PLATFORM_SEC_CAPS=""
912         valt_load_address_pri_norml="0x58000000"
913         valt_load_address_pri_inner="0x38000000"
914         valt_load_address_sec_norml="0xUNSET"
915         valt_load_address_sec_inner="0xUNSET"
916         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
917         ;;
918      x86-solaris)
919         VGCONF_ARCH_PRI="x86"
920         VGCONF_ARCH_SEC=""
921         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
922         VGCONF_PLATFORM_SEC_CAPS=""
923         valt_load_address_pri_norml="0x58000000"
924         valt_load_address_pri_inner="0x38000000"
925         valt_load_address_sec_norml="0xUNSET"
926         valt_load_address_sec_inner="0xUNSET"
927         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
928         ;;
929      amd64-solaris)
930         valt_load_address_sec_norml="0xUNSET"
931         valt_load_address_sec_inner="0xUNSET"
932         if test x$vg_cv_only64bit = xyes; then
933            VGCONF_ARCH_PRI="amd64"
934            VGCONF_ARCH_SEC=""
935            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
936            VGCONF_PLATFORM_SEC_CAPS=""
937            valt_load_address_pri_norml="0x58000000"
938            valt_load_address_pri_inner="0x38000000"
939         elif test x$vg_cv_only32bit = xyes; then
940            VGCONF_ARCH_PRI="x86"
941            VGCONF_ARCH_SEC=""
942            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
943            VGCONF_PLATFORM_SEC_CAPS=""
944            valt_load_address_pri_norml="0x58000000"
945            valt_load_address_pri_inner="0x38000000"
946         else
947            VGCONF_ARCH_PRI="amd64"
948            VGCONF_ARCH_SEC="x86"
949            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
950            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
951            valt_load_address_pri_norml="0x58000000"
952            valt_load_address_pri_inner="0x38000000"
953            valt_load_address_sec_norml="0x58000000"
954            valt_load_address_sec_inner="0x38000000"
955         fi
956         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
957         ;;
958     *)
959         VGCONF_ARCH_PRI="unknown"
960         VGCONF_ARCH_SEC="unknown"
961         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
962         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
963         valt_load_address_pri_norml="0xUNSET"
964         valt_load_address_pri_inner="0xUNSET"
965         valt_load_address_sec_norml="0xUNSET"
966         valt_load_address_sec_inner="0xUNSET"
967         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
968         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
969         ;;
970 esac
972 #----------------------------------------------------------------------------
974 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
975 # defined.
976 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
977                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
978                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
979                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
980                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
981                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
982                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
983                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
984                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
985 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
986                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
987                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
988                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
989                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
990 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
991                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
992                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
993 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
994                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
995                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
996 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
997                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
998                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
999 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
1000                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1001 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1002                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1003 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1004                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1005                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1006 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1007                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
1008 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1009                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1011 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
1012 # become defined.
1013 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
1014                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1015                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1016 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
1017                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1018 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
1019                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1020                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1021 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1022                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1023 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1024                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1025 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1026                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1027                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1028 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1029                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1030 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1031                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1032                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1033 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1034                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1035                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1036 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1037                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1038 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1039                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1040 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1041                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1042                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1043 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1044                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1045 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1046                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1047                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1048 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1049                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1050 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1051                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1052                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1053 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1054                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1057 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1058 # Relies on the assumption that the primary and secondary targets are 
1059 # for the same OS, so therefore only necessary to test the primary.
1060 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1061                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1062                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1063                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1064                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1065                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1066                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1067                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1068                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1069                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1070                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1071                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1072 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1073                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1074                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1075 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1076                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1077                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1078 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1079                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1080                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1081 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1082                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1083                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1084                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1085                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1088 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1089 # there is a secondary target.
1090 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1091                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1093 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1094 dnl fallback definition
1095 dnl The macro is courtesy of Dave Hart:
1096 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1097 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1098 if test -z "$$1_TRUE"; then :
1099   m4_n([$2])[]dnl
1100 m4_ifval([$3],
1101 [else
1102   $3
1103 ])dnl
1104 fi[]dnl
1105 ])])
1107 #----------------------------------------------------------------------------
1108 # Inner Valgrind?
1109 #----------------------------------------------------------------------------
1111 # Check if this should be built as an inner Valgrind, to be run within
1112 # another Valgrind.  Choose the load address accordingly.
1113 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1114 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1115 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1116    [AC_ARG_ENABLE(inner, 
1117       [  --enable-inner          enables self-hosting],
1118       [vg_cv_inner=$enableval],
1119       [vg_cv_inner=no])])
1120 if test "$vg_cv_inner" = yes; then
1121     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1122     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1123     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1124 else
1125     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1126     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1129 #----------------------------------------------------------------------------
1130 # Undefined behaviour sanitiser
1131 #----------------------------------------------------------------------------
1132 # Check whether we should build with the undefined beahviour sanitiser.
1134 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1135    [AC_ARG_ENABLE(ubsan, 
1136       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1137       [vg_cv_ubsan=$enableval],
1138       [vg_cv_ubsan=no])])
1140 #----------------------------------------------------------------------------
1141 # Extra fine-tuning of installation directories
1142 #----------------------------------------------------------------------------
1143 AC_ARG_WITH(tmpdir,
1144    [  --with-tmpdir=PATH      Specify path for temporary files],
1145    tmpdir="$withval",
1146    tmpdir="/tmp")
1147 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1148 AC_SUBST(VG_TMPDIR, [$tmpdir])
1150 #----------------------------------------------------------------------------
1151 # Detect xcode path
1152 #----------------------------------------------------------------------------
1153 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1154 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1155 AC_MSG_CHECKING([for xcode sdk include path])
1156 AC_ARG_WITH(xcodedir,
1157    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1158    [xcodedir="$withval"],
1159    [
1160       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1161          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1162          if test -z "$xcrundir"; then
1163             xcodedir="/usr/include"
1164          else
1165             xcodedir="$xcrundir/usr/include"
1166          fi
1167       else
1168          xcodedir="/usr/include"
1169       fi
1170    ])
1171 AC_MSG_RESULT([$xcodedir])
1172 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1173 AC_SUBST(XCODE_DIR, [$xcodedir])])
1175 #----------------------------------------------------------------------------
1176 # Libc and suppressions
1177 #----------------------------------------------------------------------------
1178 # This variable will collect the suppression files to be used.
1179 AC_SUBST(DEFAULT_SUPP)
1181 AC_CHECK_HEADER([features.h])
1183 if test x$ac_cv_header_features_h = xyes; then
1184   rm -f conftest.$ac_ext
1185   cat <<_ACEOF >conftest.$ac_ext
1186 #include <features.h>
1187 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1188 glibc version is: __GLIBC__ __GLIBC_MINOR__
1189 #endif
1190 _ACEOF
1191   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1194 # not really a version check
1195 AC_EGREP_CPP([DARWIN_LIBC], [
1196 #include <sys/cdefs.h>
1197 #if defined(__DARWIN_VERS_1050)
1198   DARWIN_LIBC
1199 #endif
1201 GLIBC_VERSION="darwin")
1203 AC_EGREP_CPP([FREEBSD_LIBC], [
1204 #include <sys/cdefs.h>
1205 #if defined(__FreeBSD__)
1206   FREEBSD_LIBC
1207 #endif
1209 GLIBC_VERSION="freebsd")
1211 # not really a version check
1212 AC_EGREP_CPP([BIONIC_LIBC], [
1213 #if defined(__ANDROID__)
1214   BIONIC_LIBC
1215 #endif
1217 GLIBC_VERSION="bionic")
1219 # there is only one version of libc on Solaris
1220 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1221      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1222     GLIBC_VERSION="solaris"
1225 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1226 # in this case.
1227 if test x$GLIBC_VERSION = x; then
1228     if $CC -dumpmachine | grep -q musl; then
1229         GLIBC_VERSION=musl
1230     fi
1233 # If this is glibc then figure out the generic (in file) libc.so and
1234 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1235 # was a separate library, afterwards it was merged into libc.so and
1236 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1237 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1238 case ${GLIBC_VERSION} in
1240   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1241   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1242   [
1243     AC_MSG_RESULT([no])
1244     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1245     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1246   ], [
1247     AC_MSG_RESULT([yes])
1248     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1249     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1250   ])
1251   ;;
1253   AC_MSG_CHECKING([not glibc...])
1254   AC_MSG_RESULT([${GLIBC_VERSION}])
1255   ;;
1256 esac
1258 AC_MSG_CHECKING([the glibc version])
1260 case "${GLIBC_VERSION}" in
1261      2.2)
1262         AC_MSG_RESULT(${GLIBC_VERSION} family)
1263         DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1264         DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1265         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1266         ;;
1267      2.[[3-6]])
1268         AC_MSG_RESULT(${GLIBC_VERSION} family)
1269         DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1270         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1271         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1272         ;;
1273      2.[[7-9]])
1274         AC_MSG_RESULT(${GLIBC_VERSION} family)
1275         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1276         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1277         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1278         ;;
1279      2.10|2.11)
1280         AC_MSG_RESULT(${GLIBC_VERSION} family)
1281         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1282                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1283         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1284         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1285         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1286         ;;
1287      2.*)
1288         AC_MSG_RESULT(${GLIBC_VERSION} family)
1289         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1290                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1291         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1292                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1293         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1294         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1295         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1296         ;;
1297      darwin)
1298         AC_MSG_RESULT(Darwin)
1299         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1300         # DEFAULT_SUPP set by kernel version check above.
1301         ;;
1302      freebsd)
1303         AC_MSG_RESULT(FreeBSD)
1304         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1305         # DEFAULT_SUPP set by kernel version check above.
1306         ;;
1307      bionic)
1308         AC_MSG_RESULT(Bionic)
1309         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1310         DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1311         ;;
1312      solaris)
1313         AC_MSG_RESULT(Solaris)
1314         # DEFAULT_SUPP set in host_os switch-case above.
1315         # No other suppression file is used.
1316         ;;
1317      musl)
1318         AC_MSG_RESULT(Musl)
1319         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1320         DEFAULT_SUPP="musl.supp ${DEFAULT_SUPP}"
1321         ;;
1322      2.0|2.1|*)
1323         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1324         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1325         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1326         ;;
1327 esac
1329 AC_SUBST(GLIBC_VERSION)
1330 AC_SUBST(GLIBC_LIBC_PATH)
1331 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1334 if test "$VGCONF_OS" != "solaris"; then
1335     # Add default suppressions for the X client libraries.  Make no
1336     # attempt to detect whether such libraries are installed on the
1337     # build machine (or even if any X facilities are present); just
1338     # add the suppressions antidisirregardless.
1339     DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1340     DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1344 #----------------------------------------------------------------------------
1345 # Platform variants?
1346 #----------------------------------------------------------------------------
1348 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1349 # But there are times where we need a bit more control.  The motivating
1350 # and currently only case is Android: this is almost identical to
1351 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1352 # platform variant tags, which get passed in the compile as
1353 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1355 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1356 # it is "android" instead.
1358 # Consequently (eg), plain arm-linux would build with
1360 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1362 # whilst an Android build would have
1364 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1366 # Same for x86. The setup of the platform variant is pushed relatively far
1367 # down this file in order that we can inspect any of the variables set above.
1369 # In the normal case ..
1370 VGCONF_PLATVARIANT="vanilla"
1372 # Android ?
1373 if test "$GLIBC_VERSION" = "bionic";
1374 then
1375    VGCONF_PLATVARIANT="android"
1378 AC_SUBST(VGCONF_PLATVARIANT)
1381 # FIXME: do we also want to define automake variables
1382 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1383 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1384 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1385 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1386 # that's what we'd need to do to use this, since what we'd want to write
1387 # is something like
1389 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1391 # Hmm.  Can't think of a nice clean solution to this.
1393 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1394                test x$VGCONF_PLATVARIANT = xvanilla)
1395 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1396                test x$VGCONF_PLATVARIANT = xandroid)
1399 #----------------------------------------------------------------------------
1400 # Checking for various library functions and other definitions
1401 #----------------------------------------------------------------------------
1403 # Check for AT_FDCWD
1405 AC_MSG_CHECKING([for AT_FDCWD])
1406 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1407 #define _GNU_SOURCE
1408 #include <fcntl.h>
1409 #include <unistd.h>
1410 ]], [[
1411   int a = AT_FDCWD;
1412 ]])], [
1413 ac_have_at_fdcwd=yes
1414 AC_MSG_RESULT([yes])
1415 ], [
1416 ac_have_at_fdcwd=no
1417 AC_MSG_RESULT([no])
1420 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1422 # Check for stpncpy function definition in string.h
1423 # This explicitly checks with _GNU_SOURCE defined since that is also
1424 # used in the test case (some systems might define it without anyway
1425 # since stpncpy is part of The Open Group Base Specifications Issue 7
1426 # IEEE Std 1003.1-2008.
1427 AC_MSG_CHECKING([for stpncpy])
1428 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1429 #define _GNU_SOURCE
1430 #include <string.h>
1431 ]], [[
1432   char *d;
1433   char *s;
1434   size_t n = 0;
1435   char *r = stpncpy(d, s, n);
1436 ]])], [
1437 ac_have_gnu_stpncpy=yes
1438 AC_MSG_RESULT([yes])
1439 ], [
1440 ac_have_gnu_stpncpy=no
1441 AC_MSG_RESULT([no])
1444 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1446 # Check for PTRACE_GETREGS
1448 AC_MSG_CHECKING([for PTRACE_GETREGS])
1449 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1450 #include <stdlib.h>
1451 #include <stddef.h>
1452 #include <sys/ptrace.h>
1453 #include <sys/user.h>
1454 ]], [[
1455   void *p;
1456   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1457 ]])], [
1458 AC_MSG_RESULT([yes])
1459 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1460           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1461 ], [
1462 AC_MSG_RESULT([no])
1466 # Check for CLOCK_MONOTONIC
1468 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1470 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1471 #include <time.h>
1472 ]], [[
1473   struct timespec t;
1474   clock_gettime(CLOCK_MONOTONIC, &t);
1475   return 0;
1476 ]])], [
1477 AC_MSG_RESULT([yes])
1478 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1479           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1480 ], [
1481 AC_MSG_RESULT([no])
1485 # Check for ELF32/64_CHDR
1487 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1490 # Check for PTHREAD_RWLOCK_T
1492 AC_MSG_CHECKING([for pthread_rwlock_t])
1494 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1495 #define _GNU_SOURCE
1496 #include <pthread.h>
1497 ]], [[
1498   pthread_rwlock_t rwl;
1499 ]])], [
1500 AC_MSG_RESULT([yes])
1501 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1502           [Define to 1 if you have the `pthread_rwlock_t' type.])
1503 ], [
1504 AC_MSG_RESULT([no])
1508 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1510 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1512 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1513 #define _GNU_SOURCE
1514 #include <pthread.h>
1515 ]], [[
1516   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1517 ]])], [
1518 AC_MSG_RESULT([yes])
1519 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1520           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1521 ], [
1522 AC_MSG_RESULT([no])
1526 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1528 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1530 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1531 #define _GNU_SOURCE
1532 #include <pthread.h>
1533 ]], [[
1534   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1535 ]])], [
1536 AC_MSG_RESULT([yes])
1537 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1538           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1539 ], [
1540 AC_MSG_RESULT([no])
1544 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1546 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1548 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1549 #define _GNU_SOURCE
1550 #include <pthread.h>
1551 ]], [[
1552   return (PTHREAD_MUTEX_RECURSIVE_NP);
1553 ]])], [
1554 AC_MSG_RESULT([yes])
1555 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1556           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1557 ], [
1558 AC_MSG_RESULT([no])
1562 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1564 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1566 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1567 #define _GNU_SOURCE
1568 #include <pthread.h>
1569 ]], [[
1570   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1571   return 0;
1572 ]])], [
1573 AC_MSG_RESULT([yes])
1574 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1575           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1576 ], [
1577 AC_MSG_RESULT([no])
1581 # Check whether pthread_mutex_t has a member called __m_kind.
1583 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1584                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1585                            1,                                   
1586                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1587                 ],
1588                 [],
1589                 [#include <pthread.h>])
1592 # Check whether pthread_mutex_t has a member called __data.__kind.
1594 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1595                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1596                           1,
1597                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1598                 ],
1599                 [],
1600                 [#include <pthread.h>])
1602 # Convenience function.  Set flags based on the existing HWCAP entries.
1603 # The AT_HWCAP entries are generated by glibc, and are based on
1604 # functions supported by the hardware/system/libc.
1605 # Subsequent support for whether the capability will actually be utilized
1606 # will also be checked against the compiler capabilities.
1607 # called as
1608 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1609 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1610   AUXV_CHECK_FOR=$1
1611   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1612   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1613   then
1614     AC_MSG_RESULT([yes])
1615     AC_SUBST([$2],[yes])
1616   else
1617     AC_MSG_RESULT([no])
1618     AC_SUBST([$2],[])
1619   fi
1622 # gather hardware capabilities. (hardware/kernel/libc)
1623 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1624 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1625 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1626 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1627 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1628 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1629 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1630 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1631 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1632 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1634 # ISA Levels
1635 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1636 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1637 # compiler support for isa 2.07 level instructions
1638 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1639 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1640 ]], [[
1641   __asm__ __volatile__("mtvsrd 1,2 ");
1642 ]])], [
1643 ac_asm_have_isa_2_07=yes
1644 AC_MSG_RESULT([yes])
1645 ], [
1646 ac_asm_have_isa_2_07=no
1647 AC_MSG_RESULT([no])
1649 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1650                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1652 # altivec (vsx) support.
1653 # does this compiler support -maltivec and does it have the include file
1654 # <altivec.h> ?
1655 AC_MSG_CHECKING([for Altivec support in the compiler ])
1656 safe_CFLAGS=$CFLAGS
1657 CFLAGS="-maltivec -Werror"
1658 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1659 #include <altivec.h>
1660 ]], [[
1661   vector unsigned int v;
1662 ]])], [
1663 ac_have_altivec=yes
1664 AC_MSG_RESULT([yes])
1665 ], [
1666 ac_have_altivec=no
1667 AC_MSG_RESULT([no])
1669 CFLAGS=$safe_CFLAGS
1670 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1671                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1673 # Check that both: the compiler supports -mvsx and that the assembler
1674 # understands VSX instructions.  If either of those doesn't work,
1675 # conclude that we can't do VSX.
1676 AC_MSG_CHECKING([for VSX compiler flag support])
1677 safe_CFLAGS=$CFLAGS
1678 CFLAGS="-mvsx -Werror"
1679 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1680 ]], [[
1681 ]])], [
1682 ac_compiler_supports_vsx_flag=yes
1683 AC_MSG_RESULT([yes])
1684 ], [
1685 ac_compiler_supports_vsx_flag=no
1686 AC_MSG_RESULT([no])
1688 CFLAGS=$safe_CFLAGS
1690 AC_MSG_CHECKING([for VSX support in the assembler ])
1691 safe_CFLAGS=$CFLAGS
1692 CFLAGS="-mvsx -Werror"
1693 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1694 #include <altivec.h>
1695 ]], [[
1696   vector unsigned int v;
1697   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1698 ]])], [
1699 ac_compiler_supports_vsx=yes
1700 AC_MSG_RESULT([yes])
1701 ], [
1702 ac_compiler_supports_vsx=no
1703 AC_MSG_RESULT([no])
1705 CFLAGS=$safe_CFLAGS
1706 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1707                              -a x$ac_compiler_supports_vsx = xyes \
1708                              -a x$HWCAP_HAS_VSX = xyes ])
1710 # DFP (Decimal Float)
1711 # The initial DFP support was added in Power 6.  The dcffix instruction
1712 # support was added in Power 7.
1713 AC_MSG_CHECKING([that assembler knows DFP])
1714 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1715 ]], [[
1716   #ifdef __s390__
1717   __asm__ __volatile__("adtr 1, 2, 3")
1718   #else
1719 __asm__ __volatile__(".machine power7;\n" \
1720   "dadd 1, 2, 3;\n" \
1721   "dcffix 1, 2");
1722   #endif
1723 ]])], [
1724 ac_asm_have_dfp=yes
1725 AC_MSG_RESULT([yes])
1726 ], [
1727 ac_asm_have_dfp=no
1728 AC_MSG_RESULT([no])
1730 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1731 safe_CFLAGS=$CFLAGS
1732 CFLAGS="-mhard-dfp -Werror"
1734 # The dcffix instruction is Power 7
1735 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1736 ]], [[
1737   #ifdef __s390__
1738   __asm__ __volatile__("adtr 1, 2, 3")
1739   #else
1740   __asm__ __volatile__(".machine power7;\n" \
1741   "dadd 1, 2, 3;\n" \
1742   "dcffix 1, 2");
1743   #endif
1744 ]])], [
1745 ac_compiler_have_dfp=yes
1746 AC_MSG_RESULT([yes])
1747 ], [
1748 ac_compiler_have_dfp=no
1749 AC_MSG_RESULT([no])
1751 CFLAGS=$safe_CFLAGS
1752 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1753                           -a x$ac_compiler_have_dfp = xyes \
1754                           -a x$HWCAP_HAS_DFP = xyes )
1756 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1757 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1758 ]], [[
1759   _Decimal64 x = 0.0DD;
1760 ]])], [
1761 ac_compiler_have_dfp_type=yes
1762 AC_MSG_RESULT([yes])
1763 ], [
1764 ac_compiler_have_dfp_type=no
1765 AC_MSG_RESULT([no])
1767 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1768                                   -a x$HWCAP_HAS_DFP = xyes )
1771 # HTM (Hardware Transactional Memory)
1772 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1773 safe_CFLAGS=$CFLAGS
1774 CFLAGS="-mhtm -Werror"
1775 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1776 ]], [[
1777   return 0;
1778 ]])], [
1779 AC_MSG_RESULT([yes])
1780 ac_compiler_supports_htm=yes
1781 ], [
1782 AC_MSG_RESULT([no])
1783 ac_compiler_supports_htm=no
1785 CFLAGS=$safe_CFLAGS
1787 AC_MSG_CHECKING([if compiler can find the htm builtins])
1788 safe_CFLAGS=$CFLAGS
1789 CFLAGS="-mhtm -Werror"
1790  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1791  ]], [[
1792    if (__builtin_tbegin (0))
1793       __builtin_tend (0);
1794  ]])], [
1795  AC_MSG_RESULT([yes])
1796 ac_compiler_sees_htm_builtins=yes
1797  ], [
1798  AC_MSG_RESULT([no])
1799 ac_compiler_sees_htm_builtins=no
1800  ])
1801 CFLAGS=$safe_CFLAGS
1803 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1804                                -a x$ac_compiler_sees_htm_builtins = xyes \
1805                                -a x$HWCAP_HAS_HTM = xyes )
1807 # isa 3.0 checking. (actually 3.0 or newer)
1808 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1810 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1811 ]], [[
1812 __asm__ __volatile__ (".machine power9;\n" \
1813         "cnttzw   1,3; \n" );
1814 ]])], [
1815 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1816 # cpabort support
1817 safe_CFLAGS=$CFLAGS
1818 CFLAGS="-DHAS_ISA_3_00"
1819 ac_asm_have_isa_3_00=yes
1820 AC_MSG_RESULT([yes])
1821 ], [
1822 ac_asm_have_isa_3_00=no
1823 AC_MSG_RESULT([no])
1825 CFLAGS=$safe_CFLAGS
1827 # xscvhpdp checking
1828 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1830 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1831 ]], [[
1832 __asm__ __volatile__ (".machine power9;\n" \
1833         "xscvhpdp 1,2;\n" );
1834 ]])], [
1835 ac_asm_have_xscvhpdp=yes
1836 AC_MSG_RESULT([yes])
1837 ], [
1838 ac_asm_have_xscvhpdp=no
1839 AC_MSG_RESULT([no])
1842 # darn instruction checking
1843 AC_MSG_CHECKING([that assembler knows darn instruction ])
1845 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1846 ]], [[
1847   __asm__ __volatile__(".machine power9; darn 1,0 ");
1848 ]])], [
1849 ac_asm_have_darn_inst=yes
1850 AC_MSG_RESULT([yes])
1851 ], [
1852 ac_asm_have_darn_inst=no
1853 AC_MSG_RESULT([no])
1856 # isa 3.01 checking
1857 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1858 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1859 ]], [[
1860 __asm__ __volatile__ (".machine power10;\n" \
1861         "brh 1,2;\n ");
1862 ]])], [
1863 ac_asm_have_isa_3_1=yes
1864 AC_MSG_RESULT([yes])
1865 ], [
1866 ac_asm_have_isa_3_1=no
1867 AC_MSG_RESULT([no])
1871 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1872                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1874 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1875 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1877 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1878                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1880 # Check for pthread_create@GLIBC2.0
1881 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1883 safe_CFLAGS=$CFLAGS
1884 CFLAGS="-lpthread -Werror"
1885 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1886 extern int pthread_create_glibc_2_0(void*, const void*,
1887                                     void *(*)(void*), void*);
1888 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1889 ]], [[
1890 #ifdef __powerpc__
1892  * Apparently on PowerPC linking this program succeeds and generates an
1893  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1894  */
1895 #error This test does not work properly on PowerPC.
1896 #else
1897   pthread_create_glibc_2_0(0, 0, 0, 0);
1898 #endif
1899   return 0;
1900 ]])], [
1901 ac_have_pthread_create_glibc_2_0=yes
1902 AC_MSG_RESULT([yes])
1903 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1904           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1905 ], [
1906 ac_have_pthread_create_glibc_2_0=no
1907 AC_MSG_RESULT([no])
1909 CFLAGS=$safe_CFLAGS
1911 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1912                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1915 # Check for dlinfo RTLD_DI_TLS_MODID
1916 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1918 safe_LIBS="$LIBS"
1919 LIBS="-ldl"
1920 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1921 #ifndef _GNU_SOURCE
1922 #define _GNU_SOURCE
1923 #endif
1924 #include <link.h>
1925 #include <dlfcn.h>
1926 ]], [[
1927   size_t sizes[10000];
1928   size_t modid_offset;
1929   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1930   return 0;
1931 ]])], [
1932 ac_have_dlinfo_rtld_di_tls_modid=yes
1933 AC_MSG_RESULT([yes])
1934 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1935           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1936 ], [
1937 ac_have_dlinfo_rtld_di_tls_modid=no
1938 AC_MSG_RESULT([no])
1940 LIBS=$safe_LIBS
1942 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1943                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1946 # Check for eventfd_t, eventfd() and eventfd_read()
1947 AC_MSG_CHECKING([for eventfd()])
1949 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1950 #include <sys/eventfd.h>
1951 ]], [[
1952   eventfd_t ev;
1953   int fd;
1955   fd = eventfd(5, 0);
1956   eventfd_read(fd, &ev);
1957   return 0;
1958 ]])], [
1959 AC_MSG_RESULT([yes])
1960 AC_DEFINE([HAVE_EVENTFD], 1,
1961           [Define to 1 if you have the `eventfd' function.])
1962 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1963           [Define to 1 if you have the `eventfd_read' function.])
1964 ], [
1965 AC_MSG_RESULT([no])
1968 # Check whether compiler can process #include <thread> without errors
1969 # clang 3.3 cannot process <thread> from e.g.
1970 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1972 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1973 AC_LANG(C++)
1974 safe_CXXFLAGS=$CXXFLAGS
1975 CXXFLAGS=-std=c++0x
1977 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1978 #include <thread> 
1979 ])],
1981 ac_cxx_can_include_thread_header=yes
1982 AC_MSG_RESULT([yes])
1983 ], [
1984 ac_cxx_can_include_thread_header=no
1985 AC_MSG_RESULT([no])
1987 CXXFLAGS=$safe_CXXFLAGS
1988 AC_LANG(C)
1990 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1992 # Check whether compiler can process #include <condition_variable> without errors
1994 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
1995 AC_LANG(C++)
1996 safe_CXXFLAGS=$CXXFLAGS
1997 CXXFLAGS=-std=c++0x
1999 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2000 #include <condition_variable> 
2001 ])],
2003 ac_cxx_can_include_condition_variable_header=yes
2004 AC_MSG_RESULT([yes])
2005 ], [
2006 ac_cxx_can_include_condition_variable_header=no
2007 AC_MSG_RESULT([no])
2009 CXXFLAGS=$safe_CXXFLAGS
2010 AC_LANG(C)
2012 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2014 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2015 # of the user_regs_struct from sys/user.h. They are structurally the same
2016 # but we get either one or the other.
2018 AC_CHECK_TYPE([struct user_regs_struct],
2019               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2020               [[#include <sys/ptrace.h>]
2021                [#include <sys/time.h>]
2022                [#include <sys/user.h>]])
2023 if test "$sys_user_has_user_regs" = "yes"; then
2024   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2025             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2028 AC_MSG_CHECKING([for __NR_membarrier])
2029 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2030 #include <linux/unistd.h>
2031 ]], [[
2032 return __NR_membarrier
2033 ]])], [
2034 ac_have_nr_membarrier=yes
2035 AC_MSG_RESULT([yes])
2036 ], [
2037 ac_have_nr_membarrier=no
2038 AC_MSG_RESULT([no])
2041 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2043 #----------------------------------------------------------------------------
2044 # Checking for supported compiler flags.
2045 #----------------------------------------------------------------------------
2047 case "${host_cpu}" in
2048     mips*)
2049         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2050         if test -z "$ARCH"; then
2051           # does this compiler support -march=mips32 (mips32 default) ?
2052           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2054           safe_CFLAGS=$CFLAGS
2055           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2057           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2058             return 0;
2059           ]])], [
2060           FLAG_M32="-mips32 -mabi=32"
2061           AC_MSG_RESULT([yes])
2062           ], [
2063           FLAG_M32=""
2064           AC_MSG_RESULT([no])
2065           ])
2066           CFLAGS=$safe_CFLAGS
2068           AC_SUBST(FLAG_M32)
2071           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2072           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2074           safe_CFLAGS=$CFLAGS
2075           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2077           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2078             return 0;
2079           ]])], [
2080           FLAG_M64="-march=mips64r2 -mabi=64"
2081           AC_MSG_RESULT([yes])
2082           ], [
2083           FLAG_M64=""
2084           AC_MSG_RESULT([no])
2085           ])
2086           CFLAGS=$safe_CFLAGS
2088           AC_SUBST(FLAG_M64)
2089         fi
2090         ;;
2091     nanomips*)
2092         ;;
2093     *)
2094         # does this compiler support -m32 ?
2095         AC_MSG_CHECKING([if gcc accepts -m32])
2097         safe_CFLAGS=$CFLAGS
2098         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2100         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2101           return 0;
2102         ]])], [
2103         FLAG_M32="${FLAG_32ON64} -m32"
2104         AC_MSG_RESULT([yes])
2105         ], [
2106         FLAG_M32=""
2107         AC_MSG_RESULT([no])
2108         ])
2109         CFLAGS=$safe_CFLAGS
2111         AC_SUBST(FLAG_M32)
2114         # does this compiler support -m64 ?
2115         AC_MSG_CHECKING([if gcc accepts -m64])
2117         safe_CFLAGS=$CFLAGS
2118         CFLAGS="-m64 -Werror"
2120         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2121           return 0;
2122         ]])], [
2123         FLAG_M64="-m64"
2124         AC_MSG_RESULT([yes])
2125         ], [
2126         FLAG_M64=""
2127         AC_MSG_RESULT([no])
2128         ])
2129         CFLAGS=$safe_CFLAGS
2131         AC_SUBST(FLAG_M64)
2132         ;;
2133 esac
2136 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2137 if test -z "$ARCH"; then
2138   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2139   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2141   safe_CFLAGS=$CFLAGS
2142   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2144   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2145     return 0;
2146   ]])], [
2147   FLAG_OCTEON="-march=octeon"
2148   AC_MSG_RESULT([yes])
2149   ], [
2150   FLAG_OCTEON=""
2151   AC_MSG_RESULT([no])
2152   ])
2153   CFLAGS=$safe_CFLAGS
2155   AC_SUBST(FLAG_OCTEON)
2158   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2159   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2161   safe_CFLAGS=$CFLAGS
2162   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2164   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2165     return 0;
2166   ]])], [
2167   FLAG_OCTEON2="-march=octeon2"
2168   AC_MSG_RESULT([yes])
2169   ], [
2170   FLAG_OCTEON2=""
2171   AC_MSG_RESULT([no])
2172   ])
2173   CFLAGS=$safe_CFLAGS
2175   AC_SUBST(FLAG_OCTEON2)
2179 # does this compiler support -mmsa (MIPS MSA ASE) ?
2180 AC_MSG_CHECKING([if gcc accepts -mmsa])
2182 safe_CFLAGS=$CFLAGS
2183 CFLAGS="$CFLAGS -mmsa -Werror"
2185 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2186     return 0;
2187 ]])], [
2188 FLAG_MSA="-mmsa"
2189 AC_MSG_RESULT([yes])
2190 ], [
2191 FLAG_MSA=""
2192 AC_MSG_RESULT([no])
2194 CFLAGS=$safe_CFLAGS
2196 AC_SUBST(FLAG_MSA)
2198 # Are we compiling for the MIPS64 n32 ABI?
2199 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2200 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2201 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2202 #error NO
2203 #endif
2204 ]])], [
2205 VGCONF_ABI=N32
2206 FLAG_M64="-march=mips64r2 -mabi=n32"
2207 AC_MSG_RESULT([yes])
2208 ], [
2209 AC_MSG_RESULT([no])
2212 # Are we compiling for the MIPS64 n64 ABI?
2213 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2214 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2215 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2216 #error NO
2217 #endif
2218 ]])], [
2219 VGCONF_ABI=64
2220 AC_MSG_RESULT([yes])
2221 ], [
2222 AC_MSG_RESULT([no])
2225 # We enter the code block below in the following case:
2226 # Target architecture is set to mips64, the desired abi
2227 # was not specified and the compiler's default abi setting
2228 # is neither n32 nor n64.
2229 # Probe for and set the abi to either n64 or n32, in that order,
2230 # which is required for a mips64 build of valgrind.
2231 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2232   safe_CFLAGS=$CFLAGS
2233   CFLAGS="$CFLAGS -mabi=64 -Werror"
2234   AC_MSG_CHECKING([if gcc is n64 capable])
2235   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2236       return 0;
2237   ]])], [
2238   VGCONF_ABI=64
2239   AC_MSG_RESULT([yes])
2240   ], [
2241   AC_MSG_RESULT([no])
2242   ])
2243   CFLAGS=$safe_CFLAGS
2245   if test "x$VGCONF_ABI" = "x"; then
2246     safe_CFLAGS=$CFLAGS
2247     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2248     AC_MSG_CHECKING([if gcc is n32 capable])
2249     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2250         return 0;
2251     ]])], [
2252     VGCONF_ABI=N32
2253     FLAG_M64="-march=mips64r2 -mabi=n32"
2254     AC_MSG_RESULT([yes])
2255     ], [
2256     AC_MSG_RESULT([no])
2257     ])
2258     CFLAGS=$safe_CFLAGS
2259   fi
2262 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2263                [test x$VGCONF_ABI != x])
2264 AC_SUBST(VGCONF_ABI)
2267 # does this compiler support -mmmx ?
2268 AC_MSG_CHECKING([if gcc accepts -mmmx])
2270 safe_CFLAGS=$CFLAGS
2271 CFLAGS="-mmmx -Werror"
2273 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2274   return 0;
2275 ]])], [
2276 FLAG_MMMX="-mmmx"
2277 AC_MSG_RESULT([yes])
2278 ], [
2279 FLAG_MMMX=""
2280 AC_MSG_RESULT([no])
2282 CFLAGS=$safe_CFLAGS
2284 AC_SUBST(FLAG_MMMX)
2287 # does this compiler support -msse ?
2288 AC_MSG_CHECKING([if gcc accepts -msse])
2290 safe_CFLAGS=$CFLAGS
2291 CFLAGS="-msse -Werror"
2293 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2294   return 0;
2295 ]])], [
2296 FLAG_MSSE="-msse"
2297 AC_MSG_RESULT([yes])
2298 ], [
2299 FLAG_MSSE=""
2300 AC_MSG_RESULT([no])
2302 CFLAGS=$safe_CFLAGS
2304 AC_SUBST(FLAG_MSSE)
2307 # does this compiler support -mpreferred-stack-boundary=2 when
2308 # generating code for a 32-bit target?  Note that we only care about
2309 # this when generating code for (32-bit) x86, so if the compiler
2310 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2311 # the Memcheck and other helper functions, that is a bit slower than
2312 # it could be, on x86; and no difference at all on any other platform.
2313 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2315 safe_CFLAGS=$CFLAGS
2316 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2318 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2319   return 0;
2320 ]])], [
2321 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2322 AC_MSG_RESULT([yes])
2323 ], [
2324 PREFERRED_STACK_BOUNDARY_2=""
2325 AC_MSG_RESULT([no])
2327 CFLAGS=$safe_CFLAGS
2329 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2332 # does this compiler support -mlong-double-128 ?
2333 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2334 safe_CFLAGS=$CFLAGS
2335 CFLAGS="-mlong-double-128 -Werror"
2336 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2337   return 0;
2338 ]])], [
2339 ac_compiler_supports_mlong_double_128=yes
2340 AC_MSG_RESULT([yes])
2341 ], [
2342 ac_compiler_supports_mlong_double_128=no
2343 AC_MSG_RESULT([no])
2345 CFLAGS=$safe_CFLAGS
2346 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2347 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2348 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2350 # does this toolchain support lto ?
2351 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2352 # are not defined
2353 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2354 # a lot slower, and so not appropriate for Valgrind developments.
2355 # --enable-lto=yes should be used by distro packagers.
2356 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2357    [AC_ARG_ENABLE(lto,
2358       [  --enable-lto          enables building with link time optimisation],
2359       [vg_cv_lto=$enableval],
2360       [vg_cv_lto=no])])
2362 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2363 AC_MSG_CHECKING([if toolchain accepts lto])
2364 safe_CFLAGS=$CFLAGS
2365 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2366 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2367 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2368 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2370 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2371   extern void somefun(void);
2372   somefun();
2373   return 0;
2374 ]])], [
2375 LTO_CFLAGS=$TEST_LTO_CFLAGS
2376 AC_MSG_RESULT([yes])
2377 ], [
2378 LTO_CFLAGS=""
2379 AC_MSG_RESULT([no])
2381 CFLAGS=$safe_CFLAGS
2384 AC_SUBST(LTO_CFLAGS)
2386 # if we could not compile with lto args, or lto was disabled,
2387 # then set LTO_AR/LTO_RANLIB to the non lto values
2388 # define in config.h ENABLE_LTO (not needed by the code currently, but
2389 # this guarantees we recompile everything if we re-configure and rebuild
2390 # in a build dir previously build with another value of --enable-lto
2391 if test "x${LTO_CFLAGS}" = "x"; then
2392    LTO_AR=${AR}
2393    LTO_RANLIB=${RANLIB}
2394    vg_cv_lto=no
2395 else
2396    vg_cv_lto=yes
2397    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2400 # Convenience function to check whether GCC supports a particular
2401 # warning option. Takes two arguments,
2402 # first the warning flag name to check (without -W), then the
2403 # substitution name to set with -Wno-warning-flag if the flag exists,
2404 # or the empty string if the compiler doesn't accept the flag. Note
2405 # that checking is done against the warning flag itself, but the
2406 # substitution is then done to cancel the warning flag.
2407 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2408   AC_MSG_CHECKING([if gcc accepts -W$1])
2409   safe_CFLAGS=$CFLAGS
2410   CFLAGS="-W$1 -Werror"
2411   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2412   AC_SUBST([$2], [-Wno-$1])
2413   AC_MSG_RESULT([yes])], [
2414   AC_SUBST([$2], [])
2415   AC_MSG_RESULT([no])])
2416   CFLAGS=$safe_CFLAGS
2419 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2420 # -W$1  (instead of -Wno-$1).
2421 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2422   AC_MSG_CHECKING([if gcc accepts -W$1])
2423   safe_CFLAGS=$CFLAGS
2424   CFLAGS="-W$1 -Werror"
2425   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2426   AC_SUBST([$2], [-W$1])
2427   AC_MSG_RESULT([yes])], [
2428   AC_SUBST([$2], [])
2429   AC_MSG_RESULT([no])])
2430   CFLAGS=$safe_CFLAGS
2433 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2434 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2435 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2436 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2437 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2438 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2439 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2440 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2441 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2442 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2444 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2445 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2446 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2447 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2448 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2449 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2450 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2451 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2452 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2453 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2454 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2456 # Does this compiler support -Wformat-security ?
2457 # Special handling is needed, because certain GCC versions require -Wformat
2458 # being present if -Wformat-security is given. Otherwise a warning is issued.
2459 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2460 # And with that the warning will be turned into an error with the result
2461 # that -Wformat-security is believed to be unsupported when in fact it is.
2462 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2463 safe_CFLAGS=$CFLAGS
2464 CFLAGS="-Wformat -Wformat-security -Werror"
2465 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2466 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2467 AC_MSG_RESULT([yes])], [
2468 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2469 AC_MSG_RESULT([no])])
2470 CFLAGS=$safe_CFLAGS
2472 # does this compiler support -Wextra or the older -W ?
2474 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2476 safe_CFLAGS=$CFLAGS
2477 CFLAGS="-Wextra -Werror"
2479 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2480   return 0;
2481 ]])], [
2482 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2483 AC_MSG_RESULT([-Wextra])
2484 ], [
2485   CFLAGS="-W -Werror"
2486   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2487     return 0;
2488   ]])], [
2489   AC_SUBST([FLAG_W_EXTRA], [-W])
2490   AC_MSG_RESULT([-W])
2491   ], [
2492   AC_SUBST([FLAG_W_EXTRA], [])
2493   AC_MSG_RESULT([not supported])
2494   ])
2496 CFLAGS=$safe_CFLAGS
2498 # On ARM we do not want to pass -Wcast-align as that produces loads
2499 # of warnings. GCC is just being conservative. See here:
2500 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2501 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2502   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2503 else
2504   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2507 # does this compiler support -faligned-new ?
2508 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2510 safe_CXXFLAGS=$CXXFLAGS
2511 CXXFLAGS="-faligned-new -Werror"
2513 AC_LANG(C++)
2514 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2515   return 0;
2516 ]])], [
2517 FLAG_FALIGNED_NEW="-faligned-new"
2518 AC_MSG_RESULT([yes])
2519 ], [
2520 FLAG_FALIGNED_NEW=""
2521 AC_MSG_RESULT([no])
2523 CXXFLAGS=$safe_CXXFLAGS
2524 AC_LANG(C)
2526 AC_SUBST(FLAG_FALIGNED_NEW)
2528 # does this compiler support -fsized-deallocation ?
2529 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2531 safe_CXXFLAGS=$CXXFLAGS
2532 CXXFLAGS="-fsized-deallocation -Werror"
2534 AC_LANG(C++)
2535 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2536   return 0;
2537 ]])], [
2538 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2539 ac_have_sized_deallocation=yes
2540 AC_MSG_RESULT([yes])
2541 ], [
2542 FLAG_FSIZED_DEALLOCATION=""
2543 ac_have_sized_deallocation=no
2544 AC_MSG_RESULT([no])
2546 CXXFLAGS=$safe_CXXFLAGS
2547 AC_LANG(C)
2549 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2550 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2552 # does this compiler support C++17 aligned new/delete?
2553 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2555 safe_CXXFLAGS=$CXXFLAGS
2556 CXXFLAGS="-std=c++17"
2558 AC_LANG(C++)
2559 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2560 #include <cstdlib>
2561 #include <new>
2562 ]], [[
2563   operator delete(nullptr, std::align_val_t(64U));
2564 ]])], [
2565 ac_have_aligned_cxx_alloc=yes
2566 AC_MSG_RESULT([yes])
2567 ], [
2568 ac_have_aligned_cxx_alloc=no
2569 AC_MSG_RESULT([no])
2571 CXXFLAGS=$safe_CXXFLAGS
2572 AC_LANG(C)
2574 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2576 # does this compiler support -fno-stack-protector ?
2577 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2579 safe_CFLAGS=$CFLAGS
2580 CFLAGS="-fno-stack-protector -Werror"
2582 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2583   return 0;
2584 ]])], [
2585 no_stack_protector=yes
2586 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2587 AC_MSG_RESULT([yes])
2588 ], [
2589 no_stack_protector=no
2590 FLAG_FNO_STACK_PROTECTOR=""
2591 AC_MSG_RESULT([no])
2593 CFLAGS=$safe_CFLAGS
2595 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2597 # does this compiler support -finline-functions ?
2598 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2600 safe_CFLAGS=$CFLAGS
2601 CFLAGS="-finline-functions -Werror"
2603 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2604   return 0;
2605 ]])], [
2606 inline_functions=yes
2607 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2608 AC_MSG_RESULT([yes])
2609 ], [
2610 inline_functions=no
2611 FLAG_FINLINE_FUNCTIONS=""
2612 AC_MSG_RESULT([no])
2614 CFLAGS=$safe_CFLAGS
2616 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2618 # Does GCC support disabling Identical Code Folding?
2619 # We want to disabled Identical Code Folding for the
2620 # tools preload shared objects to get better backraces.
2621 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2622 # "The optimization reduces code size and may disturb
2623 #  unwind stacks by replacing a function by equivalent
2624 #  one with a different name."
2625 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2627 safe_CFLAGS=$CFLAGS
2628 CFLAGS="-fno-ipa-icf -Werror"
2630 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2631   return 0;
2632 ]])], [
2633 no_ipa_icf=yes
2634 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2635 AC_MSG_RESULT([yes])
2636 ], [
2637 no_ipa_icf=no
2638 FLAG_FNO_IPA_ICF=""
2639 AC_MSG_RESULT([no])
2641 CFLAGS=$safe_CFLAGS
2643 AC_SUBST(FLAG_FNO_IPA_ICF)
2646 # Does this compiler support -fsanitize=undefined. This is true for
2647 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2648 # also checks for alignment violations on memory accesses which the valgrind
2649 # code base is sprinkled (if not littered) with. As those alignment issues
2650 # don't pose a problem we want to suppress warnings about them.
2651 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2652 # GCCs do not support that.
2654 # Only checked for if --enable-ubsan was given.
2655 if test "x${vg_cv_ubsan}" = "xyes"; then
2656 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2657 safe_CFLAGS=$CFLAGS
2658 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2659 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2660   return 0;
2661 ]])], [
2662 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2663 LIB_UBSAN="-static-libubsan"
2664 AC_MSG_RESULT([yes])
2665 ], [
2666 CFLAGS="-fsanitize=undefined -Werror"
2667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2668   return 0;
2669 ]])], [
2670 FLAG_FSANITIZE="-fsanitize=undefined"
2671 LIB_UBSAN="-static-libubsan"
2672 AC_MSG_RESULT([yes])
2673 ], [
2674 FLAG_FSANITIZE=""
2675 LIB_UBSAN=""
2676 AC_MSG_RESULT([no])
2679 CFLAGS=$safe_CFLAGS
2680 AC_SUBST(FLAG_FSANITIZE)
2681 AC_SUBST(LIB_UBSAN)
2683 # does this compiler support --param inline-unit-growth=... ?
2685 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2687 safe_CFLAGS=$CFLAGS
2688 CFLAGS="--param inline-unit-growth=900 -Werror"
2690 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2691   return 0;
2692 ]])], [
2693 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2694          ["--param inline-unit-growth=900"])
2695 AC_MSG_RESULT([yes])
2696 ], [
2697 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2698 AC_MSG_RESULT([no])
2700 CFLAGS=$safe_CFLAGS
2703 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2705 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2707 safe_CFLAGS=$CFLAGS
2708 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2710 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2711   return 0;
2712 ]])], [
2713 ac_have_dwarf4=yes
2714 AC_MSG_RESULT([yes])
2715 ], [
2716 ac_have_dwarf4=no
2717 AC_MSG_RESULT([no])
2719 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2720 CFLAGS=$safe_CFLAGS
2723 # does this compiler support -g -gz=zlib ?
2725 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2727 safe_CFLAGS=$CFLAGS
2728 CFLAGS="-g -gz=zlib"
2730 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2731   return 0;
2732 ]])], [
2733 ac_have_gz_zlib=yes
2734 AC_MSG_RESULT([yes])
2735 ], [
2736 ac_have_gz_zlib=no
2737 AC_MSG_RESULT([no])
2739 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2740 CFLAGS=$safe_CFLAGS
2743 # does this compiler support -g -gz=zlib-gnu ?
2745 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2747 safe_CFLAGS=$CFLAGS
2748 CFLAGS="-g -gz=zlib-gnu"
2750 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2751   return 0;
2752 ]])], [
2753 ac_have_gz_zlib_gnu=yes
2754 AC_MSG_RESULT([yes])
2755 ], [
2756 ac_have_gz_zlib_gnu=no
2757 AC_MSG_RESULT([no])
2759 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2760 CFLAGS=$safe_CFLAGS
2763 # does this compiler support nested functions ?
2765 AC_MSG_CHECKING([if gcc accepts nested functions])
2767 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2768   int foo() { return 1; }
2769   return foo();
2770 ]])], [
2771 ac_have_nested_functions=yes
2772 AC_MSG_RESULT([yes])
2773 ], [
2774 ac_have_nested_functions=no
2775 AC_MSG_RESULT([no])
2777 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2780 # does this compiler support the 'p' constraint in ASM statements ?
2782 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2784 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2785    char *p;
2786    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2787 ]])], [
2788 ac_have_asm_constraint_p=yes
2789 AC_MSG_RESULT([yes])
2790 ], [
2791 ac_have_asm_constraint_p=no
2792 AC_MSG_RESULT([no])
2794 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2797 # Does this compiler and linker support -pie?
2798 # Some compilers actually do not support -pie and report its usage
2799 # as an error. We need to check if it is safe to use it first.
2801 AC_MSG_CHECKING([if gcc accepts -pie])
2803 safe_CFLAGS=$CFLAGS
2804 CFLAGS="-pie"
2806 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2807   return 0;
2808 ]])], [
2809 AC_SUBST([FLAG_PIE], ["-pie"])
2810 AC_MSG_RESULT([yes])
2811 ], [
2812 AC_SUBST([FLAG_PIE], [""])
2813 AC_MSG_RESULT([no])
2815 CFLAGS=$safe_CFLAGS
2818 # Does this compiler support -no-pie?
2819 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2820 # default. However this gets in the way with some tests, we use -no-pie
2821 # for these.
2823 AC_MSG_CHECKING([if gcc accepts -no-pie])
2825 safe_CFLAGS=$CFLAGS
2826 CFLAGS="-no-pie -Werror"
2828 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2829   return 0;
2830 ]])], [
2831 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2832 AC_MSG_RESULT([yes])
2833 ], [
2834 AC_SUBST([FLAG_NO_PIE], [""])
2835 AC_MSG_RESULT([no])
2837 CFLAGS=$safe_CFLAGS
2840 # We want to use use the -Ttext-segment option to the linker.
2841 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2842 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2843 # semantics are NOT what we want (GNU gold -Ttext is fine).
2845 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2846 # will reside. -Ttext aligns just the .text section start (but not any
2847 # other section).
2849 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
2850 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
2851 # The --image-base option (since version 6.0?) provides the semantics needed.
2852 # -Ttext-segment generates an error, but -Ttext now more closely
2853 # follows the GNU (bfd) ld's -Ttext.
2855 # So test first for --image-base support, and if that fails then
2856 # for -Ttext-segment which is supported by all bfd ld versions
2857 # and use that if it exists. If it doesn't exist it must be an older
2858 # version of gold and we can fall back to using -Ttext which has the
2859 # right semantics.
2861 safe_CFLAGS=$CFLAGS
2862 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
2864 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
2866 AC_LINK_IFELSE(
2867 [AC_LANG_SOURCE([int _start () { return 0; }])],
2869   linker_using_t_text="no"
2870   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
2871   AC_MSG_RESULT([yes])
2872 ], [
2873   AC_MSG_RESULT([no])
2875   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2877   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2879   AC_LINK_IFELSE(
2880   [AC_LANG_SOURCE([int _start () { return 0; }])],
2881   [
2882     linker_using_t_text="no"
2883     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2884     AC_MSG_RESULT([yes])
2885   ], [
2886     linker_using_t_text="yes"
2887     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2888     AC_MSG_RESULT([no])
2889   ])
2892 CFLAGS=$safe_CFLAGS
2894 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
2895 # have to strip any build-id ELF NOTEs from the statically linked tools.
2896 # Otherwise the build-id NOTE might end up at the default load address.
2897 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2898 # gold versions also support -Ttext-segment. So just assume that unless
2899 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2900 if test "x${linker_using_t_text}" = "xyes"; then
2901 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2902 # does the linker support -Wl,--build-id=none ?  Note, it's
2903 # important that we test indirectly via whichever C compiler
2904 # is selected, rather than testing /usr/bin/ld or whatever
2905 # directly.
2906 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2907 safe_CFLAGS=$CFLAGS
2908 CFLAGS="-Wl,--build-id=none -Werror"
2910 AC_LINK_IFELSE(
2911 [AC_LANG_PROGRAM([ ], [return 0;])],
2913   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2914   AC_MSG_RESULT([yes])
2915 ], [
2916   AC_SUBST([FLAG_NO_BUILD_ID], [""])
2917   AC_MSG_RESULT([no])
2919 else
2920 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
2921 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2923 CFLAGS=$safe_CFLAGS
2925 # does the ppc assembler support "mtocrf" et al?
2926 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2928 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2929 __asm__ __volatile__("mtocrf 4,0");
2930 __asm__ __volatile__("mfocrf 0,4");
2931 ]])], [
2932 ac_have_as_ppc_mftocrf=yes
2933 AC_MSG_RESULT([yes])
2934 ], [
2935 ac_have_as_ppc_mftocrf=no
2936 AC_MSG_RESULT([no])
2938 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2939   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2943 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2944 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2946 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2947   do { typedef struct {
2948       double hi;
2949       double lo;
2950      } dbl_pair_t;
2951      dbl_pair_t dbl_pair[3];
2952      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2953    } while (0)
2954 ]])], [
2955 ac_have_as_ppc_fpPO=yes
2956 AC_MSG_RESULT([yes])
2957 ], [
2958 ac_have_as_ppc_fpPO=no
2959 AC_MSG_RESULT([no])
2961 if test x$ac_have_as_ppc_fpPO = xyes ; then
2962   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2966 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2967 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2969 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2970 void* p;
2971 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2972 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2973 ]])], [
2974 ac_have_as_amd64_fxsave64=yes
2975 AC_MSG_RESULT([yes])
2976 ], [
2977 ac_have_as_amd64_fxsave64=no
2978 AC_MSG_RESULT([no])
2980 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2981   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2984 # does the x86/amd64 assembler understand SSE3 instructions?
2985 # Note, this doesn't generate a C-level symbol.  It generates a
2986 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2987 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2989 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2990   do { long long int x; 
2991      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
2992   while (0)
2993 ]])], [
2994 ac_have_as_sse3=yes
2995 AC_MSG_RESULT([yes])
2996 ], [
2997 ac_have_as_sse3=no
2998 AC_MSG_RESULT([no])
3001 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3004 # Ditto for SSSE3 instructions (note extra S)
3005 # Note, this doesn't generate a C-level symbol.  It generates a
3006 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3007 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3009 save_CFLAGS="$CFLAGS"
3010 CFLAGS="$CFLAGS -msse -Werror"
3011 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3012   do { long long int x; 
3013    __asm__ __volatile__(
3014       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3015   while (0)
3016 ]])], [
3017 ac_have_as_ssse3=yes
3018 AC_MSG_RESULT([yes])
3019 ], [
3020 ac_have_as_ssse3=no
3021 AC_MSG_RESULT([no])
3023 CFLAGS="$save_CFLAGS"
3025 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3028 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3029 # Note, this doesn't generate a C-level symbol.  It generates a
3030 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3031 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3032 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3033   do {
3034    __asm__ __volatile__(
3035       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3036   while (0)
3037 ]])], [
3038 ac_have_as_pclmulqdq=yes
3039 AC_MSG_RESULT([yes])
3040 ], [
3041 ac_have_as_pclmulqdq=no
3042 AC_MSG_RESULT([no])
3045 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3048 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3049 # Note, this doesn't generate a C-level symbol.  It generates a
3050 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3051 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3052 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3053   do {
3054       /*
3055        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3056        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3057        * xmm2 should be used.
3058        */
3059    __asm__ __volatile__(
3060       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3061   } while (0)
3062 ]])], [
3063 ac_have_as_vpclmulqdq=yes
3064 AC_MSG_RESULT([yes])
3065 ], [
3066 ac_have_as_vpclmulqdq=no
3067 AC_MSG_RESULT([no])
3070 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3073 # does the x86/amd64 assembler understand FMA4 instructions?
3074 # Note, this doesn't generate a C-level symbol.  It generates a
3075 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3076 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3077 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3078   do {
3079    __asm__ __volatile__(
3080       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3081   } while (0)
3082 ]])], [
3083 ac_have_as_vfmaddpd=yes
3084 AC_MSG_RESULT([yes])
3085 ], [
3086 ac_have_as_vfmaddpd=no
3087 AC_MSG_RESULT([no])
3090 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3093 # does the x86/amd64 assembler understand the LZCNT instruction?
3094 # Note, this doesn't generate a C-level symbol.  It generates a
3095 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3096 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3098 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3099   do {           
3100       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3101   } while (0)
3102 ]])], [
3103   ac_have_as_lzcnt=yes
3104   AC_MSG_RESULT([yes])
3105 ], [
3106   ac_have_as_lzcnt=no
3107   AC_MSG_RESULT([no])
3110 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3113 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3114 # Note, this doesn't generate a C-level symbol.  It generates a
3115 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3116 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3118 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3119   do {           
3120       __asm__ __volatile__("1:  loopnel 1b\n");
3121   } while (0)
3122 ]])], [
3123   ac_have_as_loopnel=yes
3124   AC_MSG_RESULT([yes])
3125 ], [
3126   ac_have_as_loopnel=no
3127   AC_MSG_RESULT([no])
3130 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3133 # does the x86/amd64 assembler understand ADDR32 ?
3134 # Note, this doesn't generate a C-level symbol.  It generates a
3135 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3136 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3138 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3139   do {           
3140       asm volatile ("addr32 rep movsb");
3141   } while (0)
3142 ]])], [
3143   ac_have_as_addr32=yes
3144   AC_MSG_RESULT([yes])
3145 ], [
3146   ac_have_as_addr32=no
3147   AC_MSG_RESULT([no])
3150 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3153 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3154 # Note, this doesn't generate a C-level symbol.  It generates a
3155 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3156 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3158 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3159   do { long long int x; 
3160    __asm__ __volatile__(
3161       "crc32q %%r15,%%r15" : : : "r15" );
3162    __asm__ __volatile__(
3163       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3164    __asm__ __volatile__(
3165       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3166   while (0)
3167 ]])], [
3168 ac_have_as_sse42=yes
3169 AC_MSG_RESULT([yes])
3170 ], [
3171 ac_have_as_sse42=no
3172 AC_MSG_RESULT([no])
3175 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3178 # does the x86/amd64 assembler understand AVX instructions?
3179 # Note, this doesn't generate a C-level symbol.  It generates a
3180 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3181 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3183 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3184   do { long long int x; 
3185    __asm__ __volatile__(
3186       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3187    __asm__ __volatile__(
3188       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3189   while (0)
3190 ]])], [
3191 ac_have_as_avx=yes
3192 AC_MSG_RESULT([yes])
3193 ], [
3194 ac_have_as_avx=no
3195 AC_MSG_RESULT([no])
3198 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3201 # does the x86/amd64 assembler understand AVX2 instructions?
3202 # Note, this doesn't generate a C-level symbol.  It generates a
3203 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3204 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3207   do { long long int x; 
3208    __asm__ __volatile__(
3209       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3210    __asm__ __volatile__(
3211       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3212   while (0)
3213 ]])], [
3214 ac_have_as_avx2=yes
3215 AC_MSG_RESULT([yes])
3216 ], [
3217 ac_have_as_avx2=no
3218 AC_MSG_RESULT([no])
3221 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3224 # does the x86/amd64 assembler understand TSX instructions and
3225 # the XACQUIRE/XRELEASE prefixes?
3226 # Note, this doesn't generate a C-level symbol.  It generates a
3227 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3228 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3230 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3231   do {
3232    __asm__ __volatile__(
3233       "       xbegin Lfoo  \n\t"
3234       "Lfoo:  xend         \n\t"
3235       "       xacquire lock incq 0(%rsp)     \n\t"
3236       "       xrelease lock incq 0(%rsp)     \n"
3237    );
3238   } while (0)
3239 ]])], [
3240 ac_have_as_tsx=yes
3241 AC_MSG_RESULT([yes])
3242 ], [
3243 ac_have_as_tsx=no
3244 AC_MSG_RESULT([no])
3247 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3250 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3251 # Note, this doesn't generate a C-level symbol.  It generates a
3252 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3253 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3255 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3256   do { unsigned int h, l;
3257    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3258    __asm__ __volatile__(
3259       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3260    __asm__ __volatile__(
3261       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3262   while (0)
3263 ]])], [
3264 ac_have_as_bmi=yes
3265 AC_MSG_RESULT([yes])
3266 ], [
3267 ac_have_as_bmi=no
3268 AC_MSG_RESULT([no])
3271 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3274 # does the x86/amd64 assembler understand FMA instructions?
3275 # Note, this doesn't generate a C-level symbol.  It generates a
3276 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3277 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3279 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3280   do { unsigned int h, l;
3281    __asm__ __volatile__(
3282       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3283    __asm__ __volatile__(
3284       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3285    __asm__ __volatile__(
3286       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3287   while (0)
3288 ]])], [
3289 ac_have_as_fma=yes
3290 AC_MSG_RESULT([yes])
3291 ], [
3292 ac_have_as_fma=no
3293 AC_MSG_RESULT([no])
3296 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3299 # does the amd64 assembler understand MPX instructions?
3300 # Note, this doesn't generate a C-level symbol.  It generates a
3301 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3302 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3304 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3305   do {
3306     asm ("bndmov %bnd0,(%rsp)");
3307     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3308     asm ("bnd call foo\n"
3309           bnd jmp  end\n"
3310           foo: bnd ret\n"
3311           end: nop");
3312   } while (0)
3313 ]])], [
3314 ac_have_as_mpx=yes
3315 AC_MSG_RESULT([yes])
3316 ], [
3317 ac_have_as_mpx=no
3318 AC_MSG_RESULT([no])
3321 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3324 # does the amd64 assembler understand ADX instructions?
3325 # Note, this doesn't generate a C-level symbol.  It generates a
3326 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3327 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3329 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3330   do {
3331     asm ("adcxq %r14,%r8");
3332   } while (0)
3333 ]])], [
3334 ac_have_as_adx=yes
3335 AC_MSG_RESULT([yes])
3336 ], [
3337 ac_have_as_adx=no
3338 AC_MSG_RESULT([no])
3341 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3344 # does the amd64 assembler understand the RDRAND instruction?
3345 # Note, this doesn't generate a C-level symbol.  It generates a
3346 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3347 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3349 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3350   do {
3351     asm ("rdrand %r14");
3352     asm ("rdrand %r14d");
3353     asm ("rdrand %r14w");
3354   } while (0)
3355 ]])], [
3356 ac_have_as_rdrand=yes
3357 AC_MSG_RESULT([yes])
3358 ], [
3359 ac_have_as_rdrand=no
3360 AC_MSG_RESULT([no])
3363 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3365 # does the amd64 assembler understand the RDSEED instruction?
3366 # Note, this doesn't generate a C-level symbol.  It generates a
3367 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3368 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3370 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3371   do {
3372     asm ("rdseed %r14");
3373     asm ("rdseed %r14d");
3374     asm ("rdseed %r14w");
3375   } while (0)
3376 ]])], [
3377 ac_have_as_rdseed=yes
3378 AC_MSG_RESULT([yes])
3379 ], [
3380 ac_have_as_rdseed=no
3381 AC_MSG_RESULT([no])
3384 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3386 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3387 # VCVTPS2PH) ?
3388 # Note, this doesn't generate a C-level symbol.  It generates a
3389 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3390 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3392 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3393   do {
3394     asm ("vcvtph2ps %xmm5, %ymm10");
3395     // If we put the dollar sign and zero together, the shell processing
3396     // this configure.ac script substitutes the command name in.  Sigh.
3397     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3398   } while (0)
3399 ]])], [
3400 ac_have_as_f16c=yes
3401 AC_MSG_RESULT([yes])
3402 ], [
3403 ac_have_as_f16c=no
3404 AC_MSG_RESULT([no])
3407 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3410 # does the x86/amd64 assembler understand MOVBE?
3411 # Note, this doesn't generate a C-level symbol.  It generates a
3412 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3413 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3415 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3416   do { long long int x; 
3417    __asm__ __volatile__(
3418       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3419   while (0)
3420 ]])], [
3421 ac_have_as_movbe=yes
3422 AC_MSG_RESULT([yes])
3423 ], [
3424 ac_have_as_movbe=no
3425 AC_MSG_RESULT([no])
3428 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3431 # Does the C compiler support the "ifunc" attribute
3432 # Note, this doesn't generate a C-level symbol.  It generates a
3433 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3434 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3436 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3437 static void mytest(void) {}
3439 static void (*resolve_test(void))(void)
3441     return (void (*)(void))&mytest;
3444 void test(void) __attribute__((ifunc("resolve_test")));
3446 int main()
3448     test();
3449     return 0;
3451 ]])], [
3452 ac_have_ifunc_attr=yes
3453 AC_MSG_RESULT([yes])
3454 ], [
3455 ac_have_ifunc_attr=no
3456 AC_MSG_RESULT([no])
3459 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3461 # Does the C compiler support the armv8 crc feature flag
3462 # Note, this doesn't generate a C-level symbol.  It generates a
3463 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3464 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3466 save_CFLAGS="$CFLAGS"
3467 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3468 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3469 int main()
3471     return 0;
3473 ]])], [
3474 ac_have_armv8_crc_feature=yes
3475 AC_MSG_RESULT([yes])
3476 ], [
3477 ac_have_armv8_crc_feature=no
3478 AC_MSG_RESULT([no])
3480 CFLAGS="$save_CFLAGS"
3482 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3485 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3486 # Note, this doesn't generate a C-level symbol.  It generates a
3487 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3488 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3490 save_CFLAGS="$CFLAGS"
3491 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3492 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3493 int main()
3495     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3496     return 0;
3498 ]])], [
3499 ac_have_armv81_feature=yes
3500 AC_MSG_RESULT([yes])
3501 ], [
3502 ac_have_armv81_feature=no
3503 AC_MSG_RESULT([no])
3505 CFLAGS="$save_CFLAGS"
3507 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3510 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3511 # Note, this doesn't generate a C-level symbol.  It generates a
3512 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3513 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3515 save_CFLAGS="$CFLAGS"
3516 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3517 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3518 int main()
3520     __asm__ __volatile__("faddp h0, v1.2h");
3521     return 0;
3523 ]])], [
3524 ac_have_armv82_feature=yes
3525 AC_MSG_RESULT([yes])
3526 ], [
3527 ac_have_armv82_feature=no
3528 AC_MSG_RESULT([no])
3530 CFLAGS="$save_CFLAGS"
3532 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3535 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3536 # when building the tool executables.  I think we should get rid of it.
3538 # Check for TLS support in the compiler and linker
3539 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3540                                 [[return foo;]])],
3541                                [vg_cv_linktime_tls=yes],
3542                                [vg_cv_linktime_tls=no])
3543 # Native compilation: check whether running a program using TLS succeeds.
3544 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3545 # succeeds but running programs using TLS fails.
3546 # Cross-compiling: check whether linking a program using TLS succeeds.
3547 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3548                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3549                 [vg_cv_tls=$enableval],
3550                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3551                                                 [[return foo;]])],
3552                                [vg_cv_tls=yes],
3553                                [vg_cv_tls=no],
3554                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3556 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3557 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3561 #----------------------------------------------------------------------------
3562 # Solaris-specific checks.
3563 #----------------------------------------------------------------------------
3565 if test "$VGCONF_OS" = "solaris" ; then
3566 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3568 # Solaris-specific check determining if the Sun Studio Assembler is used to
3569 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3570 # cmovl.l instruction, if yes then it's Sun Assembler.
3572 # C-level symbol: none
3573 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3575 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3576 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3577 ]], [[
3578   __asm__ __volatile__("cmovl.l %edx, %eax");
3579 ]])], [
3580 solaris_have_sun_studio_as=yes
3581 AC_MSG_RESULT([yes])
3582 ], [
3583 solaris_have_sun_studio_as=no
3584 AC_MSG_RESULT([no])
3586 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3588 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3589 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3590 # See solaris/vgpreload-solaris.mapfile for details.
3591 # gcc on older Solaris instructs linker to include these symbols,
3592 # gcc on illumos and newer Solaris does not.
3594 # C-level symbol: none
3595 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3597 save_CFLAGS="$CFLAGS"
3598 CFLAGS="$CFLAGS -std=gnu99"
3599 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3600 temp_dir=$( /usr/bin/mktemp -d )
3601 cat <<_ACEOF >${temp_dir}/mylib.c
3602 #include <stdio.h>
3603 int myfunc(void) { printf("LaPutyka\n"); }
3604 _ACEOF
3605 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3606 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3607 if test "x${xpg_present}" = "x" ; then
3608     solaris_xpg_symbols_present=no
3609     AC_MSG_RESULT([no])
3610 else
3611     solaris_xpg_symbols_present=yes
3612     AC_MSG_RESULT([yes])
3614 rm -rf ${temp_dir}
3615 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3616 CFLAGS="$save_CFLAGS"
3619 # Solaris-specific check determining if gcc enables largefile support by
3620 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3621 # variable with gcc flags which disable it.
3623 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3624 save_CFLAGS="$CFLAGS"
3625 CFLAGS="$CFLAGS -m32"
3626 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3627   return _LARGEFILE_SOURCE;
3628 ]])], [
3629 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3630 AC_MSG_RESULT([yes])
3631 ], [
3632 SOLARIS_UNDEF_LARGESOURCE=""
3633 AC_MSG_RESULT([no])
3635 CFLAGS=$safe_CFLAGS
3636 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3639 # Solaris-specific check determining if /proc/self/cmdline
3640 # or /proc/<pid>/cmdline is supported.
3642 # C-level symbol: SOLARIS_PROC_CMDLINE
3643 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3645 AC_CHECK_FILE([/proc/self/cmdline],
3647 solaris_proc_cmdline=yes
3648 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3649           [Define to 1 if you have /proc/self/cmdline.])
3650 ], [
3651 solaris_proc_cmdline=no
3653 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3656 # Solaris-specific check determining default platform for the Valgrind launcher.
3657 # Used in case the launcher cannot select platform by looking at the client
3658 # image (for example because the executable is a shell script).
3660 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3661 # Automake-level symbol: none
3663 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3664 # Get the ELF class of /bin/sh first.
3665 if ! test -f /bin/sh; then
3666   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3668 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3669 case "$elf_class" in
3670   64)
3671     default_arch="$VGCONF_ARCH_PRI";
3672     ;;
3673   32)
3674     if test "x$VGCONF_ARCH_SEC" != "x"; then
3675       default_arch="$VGCONF_ARCH_SEC"
3676     else
3677       default_arch="$VGCONF_ARCH_PRI";
3678     fi
3679     ;;
3680   *)
3681     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3682     ;;
3683 esac
3684 default_platform="$default_arch-$VGCONF_OS"
3685 AC_MSG_RESULT([$default_platform])
3686 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3687                    [Default platform for Valgrind launcher.])
3690 # Solaris-specific check determining if the old syscalls are available.
3692 # C-level symbol: SOLARIS_OLD_SYSCALLS
3693 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3695 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3696 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3697 #include <sys/syscall.h>
3698 ]], [[
3699   return !SYS_open;
3700 ]])], [
3701 solaris_old_syscalls=yes
3702 AC_MSG_RESULT([yes])
3703 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3704           [Define to 1 if you have the old Solaris syscalls.])
3705 ], [
3706 solaris_old_syscalls=no
3707 AC_MSG_RESULT([no])
3709 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3712 # Solaris-specific check determining if the new accept() syscall is available.
3714 # Old syscall:
3715 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3716 #            int version);
3718 # New syscall (available on illumos):
3719 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3720 #            int version, int flags);
3722 # If the old syscall is present then the following syscall will fail with
3723 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3724 # available then it will fail with EINVAL (because the flags parameter is
3725 # invalid).
3727 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3728 # Automake-level symbol: none
3730 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3731 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3732 #include <sys/syscall.h>
3733 #include <errno.h>
3734 ]], [[
3735   errno = 0;
3736   syscall(SYS_accept, 0, 0, 0, 0, -1);
3737   return !(errno == EINVAL);
3738 ]])], [
3739 AC_MSG_RESULT([yes])
3740 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3741           [Define to 1 if you have the new `accept' syscall.])
3742 ], [
3743 AC_MSG_RESULT([no])
3747 # Solaris-specific check determining if the new illumos pipe() syscall is
3748 # available.
3750 # Old syscall:
3751 # longlong_t pipe();
3753 # New syscall (available on illumos):
3754 # int pipe(intptr_t arg, int flags);
3756 # If the old syscall is present then the following call will succeed, if the
3757 # new syscall is available then it will fail with EFAULT (because address 0
3758 # cannot be accessed).
3760 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3761 # Automake-level symbol: none
3763 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3764 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3765 #include <sys/syscall.h>
3766 #include <errno.h>
3767 ]], [[
3768   errno = 0;
3769   syscall(SYS_pipe, 0, 0);
3770   return !(errno == EFAULT);
3771 ]])], [
3772 AC_MSG_RESULT([yes])
3773 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3774           [Define to 1 if you have the new `pipe' syscall.])
3775 ], [
3776 AC_MSG_RESULT([no])
3780 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3781 # available.
3783 # Old syscall:
3784 # int lwp_kill(id_t lwpid, int sig);
3786 # New syscall (available on Solaris 11):
3787 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3788 #                  int si_code, timespec_t *timeout);
3790 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3791 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3793 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3794 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3795 #include <sys/syscall.h> 
3796 ]], [[
3797   return !SYS_lwp_sigqueue;
3798 ]])], [
3799 solaris_lwp_sigqueue_syscall=yes
3800 AC_MSG_RESULT([yes])
3801 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3802           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3803 ], [
3804 solaris_lwp_sigqueue_syscall=no
3805 AC_MSG_RESULT([no])
3807 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3810 # Solaris-specific check determining if the lwp_sigqueue() syscall
3811 # takes both pid and thread id arguments or just thread id.
3813 # Old syscall (available up to Solaris 11.3):
3814 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3815 #                  int si_code, timespec_t *timeout);
3817 # New syscall (available since Solaris 11.4):
3818 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3819 #                  int si_code, timespec_t *timeout);
3821 # If the old syscall is present then the following syscall will fail with
3822 # EINVAL (because signal is out of range); if the new syscall is available
3823 # then it will fail with ESRCH (because it would not find such thread in the
3824 # current process).
3826 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3827 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3829 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3830 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3831 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3832 #include <sys/syscall.h>
3833 #include <errno.h>
3834 ]], [[
3835   errno = 0;
3836   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3837   return !(errno == ESRCH);
3838 ]])], [
3839 solaris_lwp_sigqueue_syscall_takes_pid=yes
3840 AC_MSG_RESULT([yes])
3841 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3842           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3843 ], [
3844 solaris_lwp_sigqueue_syscall_takes_pid=no
3845 AC_MSG_RESULT([no])
3847 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3848                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3850 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3854 # Solaris-specific check determining if the new lwp_name() syscall is
3855 # available.
3857 # New syscall (available on Solaris 11):
3858 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3860 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3861 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3863 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3864 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3865 #include <sys/syscall.h>
3866 ]], [[
3867   return !SYS_lwp_name;
3868 ]])], [
3869 solaris_lwp_name_syscall=yes
3870 AC_MSG_RESULT([yes])
3871 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3872           [Define to 1 if you have the new `lwp_name' syscall.])
3873 ], [
3874 solaris_lwp_name_syscall=no
3875 AC_MSG_RESULT([no])
3877 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3880 # Solaris-specific check determining if the new getrandom() syscall is
3881 # available.
3883 # New syscall (available on Solaris 11):
3884 # int getrandom(void *buf, size_t buflen, uint_t flags);
3886 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3887 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3889 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3890 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3891 #include <sys/syscall.h>
3892 ]], [[
3893   return !SYS_getrandom;
3894 ]])], [
3895 solaris_getrandom_syscall=yes
3896 AC_MSG_RESULT([yes])
3897 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3898           [Define to 1 if you have the new `getrandom' syscall.])
3899 ], [
3900 solaris_getrandom_syscall=no
3901 AC_MSG_RESULT([no])
3903 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3906 # Solaris-specific check determining if the new zone() syscall subcodes
3907 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
3908 # were added in Solaris 11 but are missing on illumos.
3910 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3911 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3913 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3914 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3915 #include <sys/zone.h>
3916 ]], [[
3917   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3918 ]])], [
3919 solaris_zone_defunct=yes
3920 AC_MSG_RESULT([yes])
3921 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3922           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3923 ], [
3924 solaris_zone_defunct=no
3925 AC_MSG_RESULT([no])
3927 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3930 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3931 # for auditon(2) subcode of the auditsys() syscall are available.
3932 # These commands are available in Solaris 11 and illumos but were removed
3933 # in Solaris 11.4.
3935 # C-level symbol: SOLARIS_AUDITON_STAT
3936 # Automake-level symbol: SOLARIS_AUDITON_STAT
3938 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3939 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3940 #include <bsm/audit.h>
3941 ]], [[
3942   return !(A_GETSTAT && A_SETSTAT);
3943 ]])], [
3944 solaris_auditon_stat=yes
3945 AC_MSG_RESULT([yes])
3946 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3947           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3948 ], [
3949 solaris_auditon_stat=no
3950 AC_MSG_RESULT([no])
3952 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3955 # Solaris-specific check determining if the new shmsys() syscall subcodes
3956 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3957 # These subcodes were added in Solaris 11 but are missing on illumos.
3959 # C-level symbol: SOLARIS_SHM_NEW
3960 # Automake-level symbol: SOLARIS_SHM_NEW
3962 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3963 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3964 #include <sys/ipc_impl.h>
3965 #include <sys/shm.h>
3966 #include <sys/shm_impl.h>
3967 ]], [[
3968   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3969 ]])], [
3970 solaris_shm_new=yes
3971 AC_MSG_RESULT([yes])
3972 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3973           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3974 ], [
3975 solaris_shm_new=no
3976 AC_MSG_RESULT([no])
3978 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3981 # Solaris-specific check determining if prxregset_t is available.  Illumos
3982 # currently does not define it on the x86 platform.
3984 # C-level symbol: SOLARIS_PRXREGSET_T
3985 # Automake-level symbol: SOLARIS_PRXREGSET_T
3987 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3988 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3989 #include <sys/procfs_isa.h>
3990 ]], [[
3991   return !sizeof(prxregset_t);
3992 ]])], [
3993 solaris_prxregset_t=yes
3994 AC_MSG_RESULT([yes])
3995 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3996           [Define to 1 if you have the `prxregset_t' type.])
3997 ], [
3998 solaris_prxregset_t=no
3999 AC_MSG_RESULT([no])
4001 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4004 # Solaris-specific check determining if the new frealpathat() syscall is
4005 # available.
4007 # New syscall (available on Solaris 11.1):
4008 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4010 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4011 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4013 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4014 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4015 #include <sys/syscall.h>
4016 ]], [[
4017   return !SYS_frealpathat;
4018 ]])], [
4019 solaris_frealpathat_syscall=yes
4020 AC_MSG_RESULT([yes])
4021 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4022           [Define to 1 if you have the new `frealpathat' syscall.])
4023 ], [
4024 solaris_frealpathat_syscall=no
4025 AC_MSG_RESULT([no])
4027 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4030 # Solaris-specific check determining if the new uuidsys() syscall is
4031 # available.
4033 # New syscall (available on newer Solaris):
4034 # int uuidsys(struct uuid *uuid);
4036 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4037 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4039 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4040 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4041 #include <sys/syscall.h>
4042 ]], [[
4043   return !SYS_uuidsys;
4044 ]])], [
4045 solaris_uuidsys_syscall=yes
4046 AC_MSG_RESULT([yes])
4047 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4048           [Define to 1 if you have the new `uuidsys' syscall.])
4049 ], [
4050 solaris_uuidsys_syscall=no
4051 AC_MSG_RESULT([no])
4053 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4056 # Solaris-specific check determining if the new labelsys() syscall subcode
4057 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4058 # missing on illumos.
4060 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4061 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4063 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4064 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4065 #include <sys/tsol/tndb.h>
4066 ]], [[
4067   return !TNDB_GET_TNIP;
4068 ]])], [
4069 solaris_tndb_get_tnip=yes
4070 AC_MSG_RESULT([yes])
4071 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4072           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4073 ], [
4074 solaris_tndb_get_tnip=no
4075 AC_MSG_RESULT([no])
4077 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4080 # Solaris-specific check determining if the new labelsys() syscall opcodes
4081 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4082 # added in Solaris 11 but are missing on illumos.
4084 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4085 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4087 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4088 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4089 #include <sys/tsol/tsyscall.h>
4090 ]], [[
4091   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4092 ]])], [
4093 solaris_tsol_clearance=yes
4094 AC_MSG_RESULT([yes])
4095 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4096           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4097 ], [
4098 solaris_tsol_clearance=no
4099 AC_MSG_RESULT([no])
4101 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4104 # Solaris-specific check determining if the new pset() syscall subcode
4105 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4106 # is missing on illumos and Solaris 11.3.
4108 # C-level symbol: SOLARIS_PSET_GET_NAME
4109 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4111 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4112 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4113 #include <sys/pset.h>
4114 ]], [[
4115   return !(PSET_GET_NAME);
4116 ]])], [
4117 solaris_pset_get_name=yes
4118 AC_MSG_RESULT([yes])
4119 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4120           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4121 ], [
4122 solaris_pset_get_name=no
4123 AC_MSG_RESULT([no])
4125 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4128 # Solaris-specific check determining if the utimesys() syscall is
4129 # available (on illumos and older Solaris).
4131 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4132 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4134 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4135 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4136 #include <sys/syscall.h>
4137 ]], [[
4138   return !SYS_utimesys;
4139 ]])], [
4140 solaris_utimesys_syscall=yes
4141 AC_MSG_RESULT([yes])
4142 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4143           [Define to 1 if you have the `utimesys' syscall.])
4144 ], [
4145 solaris_utimesys_syscall=no
4146 AC_MSG_RESULT([no])
4148 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4151 # Solaris-specific check determining if the utimensat() syscall is
4152 # available (on newer Solaris).
4154 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4155 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4157 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4158 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4159 #include <sys/syscall.h>
4160 ]], [[
4161   return !SYS_utimensat;
4162 ]])], [
4163 solaris_utimensat_syscall=yes
4164 AC_MSG_RESULT([yes])
4165 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4166           [Define to 1 if you have the `utimensat' syscall.])
4167 ], [
4168 solaris_utimensat_syscall=no
4169 AC_MSG_RESULT([no])
4171 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4174 # Solaris-specific check determining if the spawn() syscall is available
4175 # (on newer Solaris).
4177 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4178 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4180 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4181 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4182 #include <sys/syscall.h>
4183 ]], [[
4184   return !SYS_spawn;
4185 ]])], [
4186 solaris_spawn_syscall=yes
4187 AC_MSG_RESULT([yes])
4188 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4189           [Define to 1 if you have the `spawn' syscall.])
4190 ], [
4191 solaris_spawn_syscall=no
4192 AC_MSG_RESULT([no])
4194 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4197 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4198 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4200 # C-level symbol: SOLARIS_MODCTL_MODNVL
4201 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4203 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4204 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4205 #include <sys/modctl.h>
4206 ]], [[
4207   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4208 ]])], [
4209 solaris_modctl_modnvl=yes
4210 AC_MSG_RESULT([yes])
4211 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4212           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4213 ], [
4214 solaris_modctl_modnvl=no
4215 AC_MSG_RESULT([no])
4217 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4220 # Solaris-specific check determining whether nscd (name switch cache daemon)
4221 # attaches its door at /system/volatile/name_service_door (Solaris)
4222 # or at /var/run/name_service_door (illumos).
4224 # Note that /var/run is a symlink to /system/volatile on Solaris
4225 # but not vice versa on illumos.
4227 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4228 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4230 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4231 if test -e /system/volatile/name_service_door; then
4232     solaris_nscd_door_system_volatile=yes
4233     AC_MSG_RESULT([/system/volatile/name_service_door])
4234     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4235               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4236 else
4237     solaris_nscd_door_system_volatile=no
4238     AC_MSG_RESULT([/var/run/name_service_door])
4240 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4243 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4245 # New fasttrap (available on Solaris 11):
4246 # hrt_t *gethrt(void);
4248 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4249 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4251 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4252 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4253 #include <sys/trap.h>
4254 ]], [[
4255   return !T_GETHRT;
4256 ]])], [
4257 solaris_gethrt_fasttrap=yes
4258 AC_MSG_RESULT([yes])
4259 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4260           [Define to 1 if you have the new `gethrt' fasttrap.])
4261 ], [
4262 solaris_gethrt_fasttrap=no
4263 AC_MSG_RESULT([no])
4265 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4268 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4269 # is available.
4271 # New fasttrap (available on Solaris 11):
4272 # zonehrtoffset_t *get_zone_offset(void);
4274 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4275 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4277 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4278 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4279 #include <sys/trap.h>
4280 ]], [[
4281   return !T_GETZONEOFFSET;
4282 ]])], [
4283 solaris_getzoneoffset_fasttrap=yes
4284 AC_MSG_RESULT([yes])
4285 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4286           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4287 ], [
4288 solaris_getzoneoffset_fasttrap=no
4289 AC_MSG_RESULT([no])
4291 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4294 # Solaris-specific check determining if the execve() syscall
4295 # takes fourth argument (flags) or not.
4297 # Old syscall (available on illumos):
4298 # int execve(const char *fname, const char **argv, const char **envp);
4300 # New syscall (available on Solaris):
4301 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4303 # If the new syscall is present then it will fail with EINVAL (because flags
4304 # are invalid); if the old syscall is available then it will fail with ENOENT
4305 # (because the file could not be found).
4307 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4308 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4310 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4311 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4312 #include <sys/syscall.h>
4313 #include <errno.h>
4314 ]], [[
4315   errno = 0;
4316   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4317   return !(errno == EINVAL);
4318 ]])], [
4319 solaris_execve_syscall_takes_flags=yes
4320 AC_MSG_RESULT([yes])
4321 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4322           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4323 ], [
4324 solaris_execve_syscall_takes_flags=no
4325 AC_MSG_RESULT([no])
4327 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4328                test x$solaris_execve_syscall_takes_flags = xyes)
4331 # Solaris-specific check determining version of the repository cache protocol.
4332 # Every Solaris version uses a different one, ranging from 21 to current 25.
4333 # The check is very ugly, though.
4335 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4336 # Automake-level symbol: none
4338 AC_PATH_PROG(DIS_PATH, dis, false)
4339 if test "x$DIS_PATH" = "xfalse"; then
4340   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4342 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4343   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4344   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4347 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4348 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4349   libscf=/usr/lib/64/libscf.so.1
4350 else
4351   libscf=/usr/lib/libscf.so.1
4353 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
4354   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4355   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4357 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
4358 if test -z "$hex"; then
4359   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4360   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4362 version=$( printf "%d\n" 0x$hex )
4363 AC_MSG_RESULT([$version])
4364 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4365                    [Version number of the repository door cache protocol.])
4368 # Solaris-specific check determining if "sysstat" segment reservation type
4369 # is available.
4371 # New "sysstat" segment reservation (available on Solaris 11.4):
4372 # - program header type:    PT_SUNW_SYSSTAT
4373 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4375 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4376 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4378 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4379 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4380 #include <sys/auxv.h>
4381 ]], [[
4382   return !AT_SUN_SYSSTAT_ADDR;
4383 ]])], [
4384 solaris_reserve_sysstat_addr=yes
4385 AC_MSG_RESULT([yes])
4386 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4387           [Define to 1 if you have the new `sysstat' segment reservation.])
4388 ], [
4389 solaris_reserve_sysstat_addr=no
4390 AC_MSG_RESULT([no])
4392 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4395 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4396 # is available.
4398 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4399 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4400 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4402 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4403 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4405 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4406 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4407 #include <sys/auxv.h>
4408 ]], [[
4409   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4410 ]])], [
4411 solaris_reserve_sysstat_zone_addr=yes
4412 AC_MSG_RESULT([yes])
4413 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4414           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4415 ], [
4416 solaris_reserve_sysstat_zone_addr=no
4417 AC_MSG_RESULT([no])
4419 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4422 # Solaris-specific check determining if the system_stats() syscall is available
4423 # (on newer Solaris).
4425 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4426 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4428 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4429 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4430 #include <sys/syscall.h>
4431 ]], [[
4432   return !SYS_system_stats;
4433 ]])], [
4434 solaris_system_stats_syscall=yes
4435 AC_MSG_RESULT([yes])
4436 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4437           [Define to 1 if you have the `system_stats' syscall.])
4438 ], [
4439 solaris_system_stats_syscall=no
4440 AC_MSG_RESULT([no])
4442 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4445 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4446 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4448 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4449 # Automake-level symbol: none
4451 AC_CHECK_TYPE([struct _fpchip_state],
4452               [solaris_fpchip_state_takes_underscore=yes],
4453               [solaris_fpchip_state_takes_underscore=no],
4454               [[#include <sys/regset.h>]])
4455 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4456   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4457             [Define to 1 if fpregset_t defines struct _fpchip_state])
4461 # Solaris-specific check determining if schedctl page shared between kernel
4462 # and userspace program is executable (illumos, older Solaris) or not (newer
4463 # Solaris).
4465 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4466 # Automake-level symbol: none
4468 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4469 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4470 #include <assert.h>
4471 #include <fcntl.h>
4472 #include <procfs.h>
4473 #include <schedctl.h>
4474 #include <stdio.h>
4475 #include <unistd.h>
4476 ]], [[
4477     schedctl_t *scp = schedctl_init();
4478     if (scp == NULL)
4479         return 1;
4481     int fd = open("/proc/self/map", O_RDONLY);
4482     assert(fd >= 0);
4484     prmap_t map;
4485     ssize_t rd;
4486     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4487         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4488             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4489                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4490             return (map.pr_mflags & MA_EXEC);
4491         }
4492     }
4494     return 1;
4495 ]])], [
4496 solaris_schedctl_page_exec=no
4497 AC_MSG_RESULT([no])
4498 ], [
4499 solaris_schedctl_page_exec=yes
4500 AC_MSG_RESULT([yes])
4501 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4502           [Define to 1 if you have the schedctl page executable.])
4506 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4507 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4508 # an initial thread pointer for libc (newer Solaris).
4510 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4511 # Automake-level symbol: none
4513 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4514 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4515 #include <sys/fasttrap_isa.h>
4516 ]], [[
4517     return !FT_SCRATCHSIZE;
4518 ]])], [
4519 solaris_pt_sunwdtrace_thrp=yes
4520 AC_MSG_RESULT([yes])
4521 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4522           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4523 ], [
4524 solaris_pt_sunwdtrace_thrp=no
4525 AC_MSG_RESULT([no])
4528 else
4529 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4530 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4531 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4532 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4533 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4534 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4535 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4536 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4537 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4538 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4539 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4540 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4541 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4542 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4543 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4544 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4545 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4546 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4547 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4548 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4549 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4550 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4551 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4552 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4553 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4554 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4555 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4556 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4557 fi # test "$VGCONF_OS" = "solaris"
4560 #----------------------------------------------------------------------------
4561 # Checks for C header files.
4562 #----------------------------------------------------------------------------
4564 AC_CHECK_HEADERS([       \
4565         asm/unistd.h     \
4566         endian.h         \
4567         mqueue.h         \
4568         sys/endian.h     \
4569         sys/epoll.h      \
4570         sys/eventfd.h    \
4571         sys/klog.h       \
4572         sys/poll.h       \
4573         sys/prctl.h      \
4574         sys/signal.h     \
4575         sys/signalfd.h   \
4576         sys/syscall.h    \
4577         sys/sysnvl.h     \
4578         sys/time.h       \
4579         sys/types.h      \
4580         ])
4582 # Verify whether the <linux/futex.h> header is usable.
4583 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4585 save_CFLAGS="$CFLAGS"
4586 CFLAGS="$CFLAGS -D__user="
4587 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4588 #include <linux/futex.h>
4589 ]], [[
4590   return FUTEX_WAIT;
4591 ]])], [
4592 ac_have_usable_linux_futex_h=yes
4593 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4594           [Define to 1 if you have a usable <linux/futex.h> header file.])
4595 AC_MSG_RESULT([yes])
4596 ], [
4597 ac_have_usable_linux_futex_h=no
4598 AC_MSG_RESULT([no])
4600 CFLAGS="$save_CFLAGS"
4603 #----------------------------------------------------------------------------
4604 # Checks for typedefs, structures, and compiler characteristics.
4605 #----------------------------------------------------------------------------
4606 AC_TYPE_UID_T
4607 AC_TYPE_OFF_T
4608 AC_TYPE_SIZE_T
4609 AC_HEADER_TIME
4611 AC_CHECK_TYPE([struct statx], [
4612   AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4613             [Define to 1 if <sys/stat.h> declares struct statx.])
4614 ], [], [
4615   #define _GNU_SOURCE
4616   #include <sys/stat.h>
4620 #----------------------------------------------------------------------------
4621 # Checks for library functions.
4622 #----------------------------------------------------------------------------
4623 AC_FUNC_MEMCMP
4624 AC_FUNC_MMAP
4626 AC_CHECK_LIB([pthread], [pthread_create])
4627 AC_CHECK_LIB([rt], [clock_gettime])
4629 AC_CHECK_FUNCS([     \
4630         clock_gettime\
4631         copy_file_range \
4632         epoll_create \
4633         epoll_pwait  \
4634         klogctl      \
4635         mallinfo     \
4636         memchr       \
4637         memfd_create \
4638         memset       \
4639         mkdir        \
4640         mremap       \
4641         ppoll        \
4642         preadv       \
4643         preadv2      \
4644         process_vm_readv  \
4645         process_vm_writev \
4646         pthread_barrier_init       \
4647         pthread_condattr_setclock  \
4648         pthread_mutex_timedlock    \
4649         pthread_rwlock_timedrdlock \
4650         pthread_rwlock_timedwrlock \
4651         pthread_setname_np         \
4652         pthread_spin_lock          \
4653         pthread_yield              \
4654         pwritev      \
4655         pwritev2     \
4656         rawmemchr    \
4657         readlinkat   \
4658         semtimedop   \
4659         setcontext   \
4660         signalfd     \
4661         sigwaitinfo  \
4662         strchr       \
4663         strdup       \
4664         strpbrk      \
4665         strrchr      \
4666         strstr       \
4667         swapcontext  \
4668         syscall      \
4669         utimensat    \
4670         ])
4672 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4673 # libraries with any shared object and/or executable. This is NOT what we
4674 # want for e.g. vgpreload_core-x86-linux.so
4675 LIBS=""
4677 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4678                [test x$ac_cv_func_pthread_barrier_init = xyes])
4679 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4680                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4681 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4682                [test x$ac_cv_func_pthread_spin_lock = xyes])
4683 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4684                [test x$ac_cv_func_pthread_setname_np = xyes])
4685 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4686                [test x$ac_cv_func_copy_file_range = xyes])
4687 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4688                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4689 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4690                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4691 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4692 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4693 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4694                [test x$ac_cv_func_memfd_create = xyes])
4696 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4697      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4698      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4699   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4700             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4703 #----------------------------------------------------------------------------
4704 # MPI checks
4705 #----------------------------------------------------------------------------
4706 # Do we have a useable MPI setup on the primary and/or secondary targets?
4707 # On Linux, by default, assumes mpicc and -m32/-m64
4708 # Note: this is a kludge in that it assumes the specified mpicc 
4709 # understands -m32/-m64 regardless of what is specified using
4710 # --with-mpicc=.
4711 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4712              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4714 mflag_primary=
4715 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4716      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4717      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4718      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4719      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4720      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4721      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4722   mflag_primary=$FLAG_M32
4723 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4724        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4725        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4726        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4727        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4728        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4729   mflag_primary=$FLAG_M64
4730 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4731   mflag_primary="$FLAG_M32 -arch i386"
4732 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4733   mflag_primary="$FLAG_M64 -arch x86_64"
4736 mflag_secondary=
4737 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4738      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4739      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4740      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4741      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4742   mflag_secondary=$FLAG_M32
4743 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4744   mflag_secondary="$FLAG_M32 -arch i386"
4748 AC_ARG_WITH(mpicc,
4749    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4750    MPI_CC=$withval
4752 AC_SUBST(MPI_CC)
4754 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4755 ## use these values in the check for a functioning mpicc.
4757 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4758 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4759 AM_COND_IF([VGCONF_OS_IS_LINUX],
4760            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4761             LDFLAGS_MPI="-fpic -shared"])
4762 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
4763            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4764             LDFLAGS_MPI="-fpic -shared"])
4765 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4766            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4767             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4768 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4769            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4770             LDFLAGS_MPI="-fpic -shared"])
4772 AC_SUBST([CFLAGS_MPI])
4773 AC_SUBST([LDFLAGS_MPI])
4776 ## See if MPI_CC works for the primary target
4778 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4779 saved_CC=$CC
4780 saved_CFLAGS=$CFLAGS
4781 CC=$MPI_CC
4782 CFLAGS="$CFLAGS_MPI $mflag_primary"
4783 saved_LDFLAGS="$LDFLAGS"
4784 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4785 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4786 #include <mpi.h>
4787 #include <stdio.h>
4788 ]], [[
4789   int ni, na, nd, comb;
4790   int r = MPI_Init(NULL,NULL);
4791   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4792   r |= MPI_Finalize();
4793   return r; 
4794 ]])], [
4795 ac_have_mpi2_pri=yes
4796 AC_MSG_RESULT([yes, $MPI_CC])
4797 ], [
4798 ac_have_mpi2_pri=no
4799 AC_MSG_RESULT([no])
4801 CC=$saved_CC
4802 CFLAGS=$saved_CFLAGS
4803 LDFLAGS="$saved_LDFLAGS"
4804 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4806 ## See if MPI_CC works for the secondary target.  Complication: what if
4807 ## there is no secondary target?  We need this to then fail.
4808 ## Kludge this by making MPI_CC something which will surely fail in
4809 ## such a case.
4811 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4812 saved_CC=$CC
4813 saved_CFLAGS=$CFLAGS
4814 saved_LDFLAGS="$LDFLAGS"
4815 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4816 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4817   CC="$MPI_CC this will surely fail"
4818 else
4819   CC=$MPI_CC
4821 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4822 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4823 #include <mpi.h>
4824 #include <stdio.h>
4825 ]], [[
4826   int ni, na, nd, comb;
4827   int r = MPI_Init(NULL,NULL);
4828   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4829   r |= MPI_Finalize();
4830   return r; 
4831 ]])], [
4832 ac_have_mpi2_sec=yes
4833 AC_MSG_RESULT([yes, $MPI_CC])
4834 ], [
4835 ac_have_mpi2_sec=no
4836 AC_MSG_RESULT([no])
4838 CC=$saved_CC
4839 CFLAGS=$saved_CFLAGS
4840 LDFLAGS="$saved_LDFLAGS"
4841 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4844 #----------------------------------------------------------------------------
4845 # Other library checks
4846 #----------------------------------------------------------------------------
4847 # There now follow some tests for Boost, and OpenMP.  These
4848 # tests are present because Drd has some regression tests that use
4849 # these packages.  All regression test programs all compiled only
4850 # for the primary target.  And so it is important that the configure
4851 # checks that follow, use the correct -m32 or -m64 flag for the
4852 # primary target (called $mflag_primary).  Otherwise, we can end up
4853 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4854 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4855 # only build (meaning, the primary target is x86-linux), the build
4856 # of the regtest programs that use Boost fails, because they are 
4857 # build as 32-bit (IN THIS EXAMPLE).
4859 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4860 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4863 # Check whether the boost library 1.35 or later has been installed.
4864 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4866 AC_MSG_CHECKING([for boost])
4868 AC_LANG(C++)
4869 safe_CXXFLAGS=$CXXFLAGS
4870 CXXFLAGS="$mflag_primary"
4871 safe_LIBS="$LIBS"
4872 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4874 AC_LINK_IFELSE([AC_LANG_SOURCE([
4875 #include <boost/thread.hpp>
4876 static void thread_func(void)
4877 { }
4878 int main(int argc, char** argv)
4880   boost::thread t(thread_func);
4881   return 0;
4883 ])],
4885 ac_have_boost_1_35=yes
4886 AC_SUBST([BOOST_CFLAGS], [])
4887 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4888 AC_MSG_RESULT([yes])
4889 ], [
4890 ac_have_boost_1_35=no
4891 AC_MSG_RESULT([no])
4894 LIBS="$safe_LIBS"
4895 CXXFLAGS=$safe_CXXFLAGS
4896 AC_LANG(C)
4898 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4901 # does this compiler support -fopenmp, does it have the include file
4902 # <omp.h> and does it have libgomp ?
4904 AC_MSG_CHECKING([for OpenMP])
4906 safe_CFLAGS=$CFLAGS
4907 CFLAGS="-fopenmp $mflag_primary -Werror"
4909 AC_LINK_IFELSE([AC_LANG_SOURCE([
4910 #include <omp.h> 
4911 int main(int argc, char** argv)
4913   omp_set_dynamic(0);
4914   return 0;
4916 ])],
4918 ac_have_openmp=yes
4919 AC_MSG_RESULT([yes])
4920 ], [
4921 ac_have_openmp=no
4922 AC_MSG_RESULT([no])
4924 CFLAGS=$safe_CFLAGS
4926 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4929 # Check for __builtin_popcount
4930 AC_MSG_CHECKING([for __builtin_popcount()])
4931 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4932 ]], [[
4933   __builtin_popcount(2);
4934   return 0;
4935 ]])], [
4936 AC_MSG_RESULT([yes])
4937 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4938           [Define to 1 if compiler provides __builtin_popcount().])
4939 ], [
4940 AC_MSG_RESULT([no])
4943 # Check for __builtin_clz
4944 AC_MSG_CHECKING([for __builtin_clz()])
4945 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4946 ]], [[
4947   __builtin_clz(2);
4948   return 0;
4949 ]])], [
4950 AC_MSG_RESULT([yes])
4951 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4952           [Define to 1 if compiler provides __builtin_clz().])
4953 ], [
4954 AC_MSG_RESULT([no])
4957 # Check for __builtin_ctz
4958 AC_MSG_CHECKING([for __builtin_ctz()])
4959 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4960 ]], [[
4961   __builtin_ctz(2);
4962   return 0;
4963 ]])], [
4964 AC_MSG_RESULT([yes])
4965 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4966           [Define to 1 if compiler provides __builtin_ctz().])
4967 ], [
4968 AC_MSG_RESULT([no])
4971 # does this compiler have built-in functions for atomic memory access for the
4972 # primary target ?
4973 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4975 safe_CFLAGS=$CFLAGS
4976 CFLAGS="$mflag_primary"
4978 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4979   int variable = 1;
4980   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4981           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4982 ]])], [
4983   ac_have_builtin_atomic_primary=yes
4984   AC_MSG_RESULT([yes])
4985   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])
4986 ], [
4987   ac_have_builtin_atomic_primary=no
4988   AC_MSG_RESULT([no])
4991 CFLAGS=$safe_CFLAGS
4993 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4994                [test x$ac_have_builtin_atomic_primary = xyes])
4997 # does this compiler have built-in functions for atomic memory access for the
4998 # secondary target ?
5000 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5002 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5004 safe_CFLAGS=$CFLAGS
5005 CFLAGS="$mflag_secondary"
5007 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5008   int variable = 1;
5009   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5010 ]])], [
5011   ac_have_builtin_atomic_secondary=yes
5012   AC_MSG_RESULT([yes])
5013 ], [
5014   ac_have_builtin_atomic_secondary=no
5015   AC_MSG_RESULT([no])
5018 CFLAGS=$safe_CFLAGS
5022 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5023                [test x$ac_have_builtin_atomic_secondary = xyes])
5025 # does this compiler have built-in functions for atomic memory access on
5026 # 64-bit integers for all targets ?
5028 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5030 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5031   #include <stdint.h>
5032 ]], [[
5033   uint64_t variable = 1;
5034   return __sync_add_and_fetch(&variable, 1)
5035 ]])], [
5036   ac_have_builtin_atomic64_primary=yes
5037 ], [
5038   ac_have_builtin_atomic64_primary=no
5041 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5043 safe_CFLAGS=$CFLAGS
5044 CFLAGS="$mflag_secondary"
5046 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5047   #include <stdint.h>
5048 ]], [[
5049   uint64_t variable = 1;
5050   return __sync_add_and_fetch(&variable, 1)
5051 ]])], [
5052   ac_have_builtin_atomic64_secondary=yes
5053 ], [
5054   ac_have_builtin_atomic64_secondary=no
5057 CFLAGS=$safe_CFLAGS
5061 if test x$ac_have_builtin_atomic64_primary = xyes && \
5062    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5063      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5064   AC_MSG_RESULT([yes])
5065   ac_have_builtin_atomic64=yes
5066 else
5067   AC_MSG_RESULT([no])
5068   ac_have_builtin_atomic64=no
5071 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5072                [test x$ac_have_builtin_atomic64 = xyes])
5075 # does g++ have built-in functions for atomic memory access ?
5076 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5078 safe_CXXFLAGS=$CXXFLAGS
5079 CXXFLAGS="$mflag_primary"
5081 AC_LANG_PUSH(C++)
5082 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5083   int variable = 1;
5084   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5085           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5086 ]])], [
5087   ac_have_builtin_atomic_cxx=yes
5088   AC_MSG_RESULT([yes])
5089   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5090 ], [
5091   ac_have_builtin_atomic_cxx=no
5092   AC_MSG_RESULT([no])
5094 AC_LANG_POP(C++)
5096 CXXFLAGS=$safe_CXXFLAGS
5098 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5101 if test x$ac_have_usable_linux_futex_h = xyes \
5102         -a x$ac_have_builtin_atomic_primary = xyes; then
5103   ac_enable_linux_ticket_lock_primary=yes
5105 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5106                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5108 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5109         -a x$ac_have_usable_linux_futex_h = xyes \
5110         -a x$ac_have_builtin_atomic_secondary = xyes; then
5111   ac_enable_linux_ticket_lock_secondary=yes
5113 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5114                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5117 # does libstdc++ support annotating shared pointers ?
5118 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5120 safe_CXXFLAGS=$CXXFLAGS
5121 CXXFLAGS="-std=c++0x"
5123 AC_LANG_PUSH(C++)
5124 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5125   #include <memory>
5126 ]], [[
5127   std::shared_ptr<int> p
5128 ]])], [
5129   ac_have_shared_ptr=yes
5130 ], [
5131   ac_have_shared_ptr=no
5133 if test x$ac_have_shared_ptr = xyes; then
5134   # If compilation of the program below fails because of a syntax error
5135   # triggered by substituting one of the annotation macros then that
5136   # means that libstdc++ supports these macros.
5137   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5138     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5139     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5140     #include <memory>
5141   ]], [[
5142     std::shared_ptr<int> p
5143   ]])], [
5144     ac_have_shared_pointer_annotation=no
5145     AC_MSG_RESULT([no])
5146   ], [
5147     ac_have_shared_pointer_annotation=yes
5148     AC_MSG_RESULT([yes])
5149     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5150               [Define to 1 if libstd++ supports annotating shared pointers])
5151   ])
5152 else
5153   ac_have_shared_pointer_annotation=no
5154   AC_MSG_RESULT([no])
5156 AC_LANG_POP(C++)
5158 CXXFLAGS=$safe_CXXFLAGS
5160 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5161                [test x$ac_have_shared_pointer_annotation = xyes])
5164 #----------------------------------------------------------------------------
5165 # Ok.  We're done checking.
5166 #----------------------------------------------------------------------------
5168 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5169 AC_CONFIG_FILES([
5170    Makefile 
5171    VEX/Makefile:Makefile.vex.in
5172    valgrind.spec
5173    valgrind.pc
5174    glibc-2.X.supp
5175    glibc-2.X-helgrind.supp
5176    glibc-2.X-drd.supp
5177    include/valgrind.h
5178    docs/Makefile 
5179    docs/xml/vg-entities.xml
5180    tests/Makefile 
5181    tests/vg_regtest 
5182    perf/Makefile 
5183    perf/vg_perf
5184    gdbserver_tests/Makefile
5185    gdbserver_tests/solaris/Makefile
5186    include/Makefile 
5187    auxprogs/Makefile
5188    mpi/Makefile
5189    coregrind/Makefile 
5190    memcheck/Makefile
5191    memcheck/tests/Makefile
5192    memcheck/tests/common/Makefile
5193    memcheck/tests/amd64/Makefile
5194    memcheck/tests/x86/Makefile
5195    memcheck/tests/linux/Makefile
5196    memcheck/tests/linux/debuginfod-check.vgtest
5197    memcheck/tests/darwin/Makefile
5198    memcheck/tests/solaris/Makefile
5199    memcheck/tests/freebsd/Makefile
5200    memcheck/tests/amd64-linux/Makefile
5201    memcheck/tests/arm64-linux/Makefile
5202    memcheck/tests/x86-linux/Makefile
5203    memcheck/tests/amd64-solaris/Makefile
5204    memcheck/tests/x86-solaris/Makefile
5205    memcheck/tests/amd64-freebsd/Makefile
5206    memcheck/tests/x86-freebsd/Makefile
5207    memcheck/tests/ppc32/Makefile
5208    memcheck/tests/ppc64/Makefile
5209    memcheck/tests/s390x/Makefile
5210    memcheck/tests/mips32/Makefile
5211    memcheck/tests/mips64/Makefile
5212    memcheck/tests/vbit-test/Makefile
5213    cachegrind/Makefile
5214    cachegrind/tests/Makefile
5215    cachegrind/tests/x86/Makefile
5216    cachegrind/cg_annotate
5217    cachegrind/cg_diff
5218    callgrind/Makefile
5219    callgrind/callgrind_annotate
5220    callgrind/callgrind_control
5221    callgrind/tests/Makefile
5222    helgrind/Makefile
5223    helgrind/tests/Makefile
5224    drd/Makefile
5225    drd/scripts/download-and-build-splash2
5226    drd/tests/Makefile
5227    massif/Makefile
5228    massif/tests/Makefile
5229    massif/ms_print
5230    dhat/Makefile
5231    dhat/tests/Makefile
5232    lackey/Makefile
5233    lackey/tests/Makefile
5234    none/Makefile
5235    none/tests/Makefile
5236    none/tests/scripts/Makefile
5237    none/tests/amd64/Makefile
5238    none/tests/ppc32/Makefile
5239    none/tests/ppc64/Makefile
5240    none/tests/x86/Makefile
5241    none/tests/arm/Makefile
5242    none/tests/arm64/Makefile
5243    none/tests/s390x/Makefile
5244    none/tests/mips32/Makefile
5245    none/tests/mips64/Makefile
5246    none/tests/nanomips/Makefile
5247    none/tests/linux/Makefile
5248    none/tests/darwin/Makefile
5249    none/tests/solaris/Makefile
5250    none/tests/freebsd/Makefile
5251    none/tests/amd64-linux/Makefile
5252    none/tests/x86-linux/Makefile
5253    none/tests/amd64-darwin/Makefile
5254    none/tests/x86-darwin/Makefile
5255    none/tests/amd64-solaris/Makefile
5256    none/tests/x86-solaris/Makefile
5257    exp-bbv/Makefile
5258    exp-bbv/tests/Makefile
5259    exp-bbv/tests/x86/Makefile
5260    exp-bbv/tests/x86-linux/Makefile
5261    exp-bbv/tests/amd64-linux/Makefile
5262    exp-bbv/tests/ppc32-linux/Makefile
5263    exp-bbv/tests/arm-linux/Makefile
5264    shared/Makefile
5265    solaris/Makefile
5267 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5268                 [chmod +x coregrind/link_tool_exe_linux])
5269 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5270                 [chmod +x coregrind/link_tool_exe_freebsd])
5271 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5272                 [chmod +x coregrind/link_tool_exe_darwin])
5273 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5274                 [chmod +x coregrind/link_tool_exe_solaris])
5275 AC_CONFIG_FILES([tests/filter_stderr_basic],
5276                 [chmod +x tests/filter_stderr_basic])
5277 AC_CONFIG_FILES([tests/filter_discards],
5278                 [chmod +x tests/filter_discards])
5279 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5280                 [chmod +x memcheck/tests/filter_stderr])
5281 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5282                 [chmod +x memcheck/tests/filter_dw4])
5283 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5284                 [chmod +x memcheck/tests/filter_overlaperror])
5285 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5286                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5287 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5288                 [chmod +x gdbserver_tests/filter_gdb])
5289 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5290                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5291 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5292                 [chmod +x gdbserver_tests/filter_stderr])
5293 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5294                 [chmod +x gdbserver_tests/filter_vgdb])
5295 AC_CONFIG_FILES([drd/tests/filter_stderr],
5296                 [chmod +x drd/tests/filter_stderr])
5297 AC_CONFIG_FILES([drd/tests/filter_error_count],
5298                 [chmod +x drd/tests/filter_error_count])
5299 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5300                 [chmod +x drd/tests/filter_error_summary])
5301 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5302                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5303 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5304                 [chmod +x drd/tests/filter_thread_no])
5305 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5306                 [chmod +x drd/tests/filter_xml_and_thread_no])
5307 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5308                 [chmod +x helgrind/tests/filter_stderr])
5309 AC_OUTPUT
5311 cat<<EOF
5313                     Version: ${VERSION}
5314          Maximum build arch: ${ARCH_MAX}
5315          Primary build arch: ${VGCONF_ARCH_PRI}
5316        Secondary build arch: ${VGCONF_ARCH_SEC}
5317                    Build OS: ${VGCONF_OS}
5318      Link Time Optimisation: ${vg_cv_lto}
5319        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5320      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5321            Platform variant: ${VGCONF_PLATVARIANT}
5322       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5323          Default supp files: ${DEFAULT_SUPP}