regtest: silence a few warnings
[valgrind.git] / configure.ac
blob5ce94c318cbd5abeb080e0fe34ad81242ff66939
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], [22])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [GIT])
21 m4_define([v_rel_date], ["?? Oct 2023"])
22 m4_define([v_version],
23           m4_if(v_suffix_ver, [],
24                 [v_major_ver.v_minor_ver.v_micro_ver],
25                 [v_major_ver.v_minor_ver.v_micro_ver.v_suffix_ver]))
26 AC_INIT([Valgrind],[v_version],[valgrind-users@lists.sourceforge.net])
28 # For valgrind.h
29 AC_SUBST(VG_VER_MAJOR, v_major_ver)
30 AC_SUBST(VG_VER_MINOR, v_minor_ver)
32 # For docs/xml/vg-entities.xml
33 AC_SUBST(VG_DATE, v_rel_date)
35 AC_CONFIG_SRCDIR(coregrind/m_main.c)
36 AC_CONFIG_HEADERS([config.h])
37 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
39 AM_MAINTAINER_MODE
41 #----------------------------------------------------------------------------
42 # Do NOT modify these flags here. Except in feature tests in which case
43 # the original values must be properly restored.
44 #----------------------------------------------------------------------------
45 CFLAGS="$CFLAGS"
46 CXXFLAGS="$CXXFLAGS"
48 #----------------------------------------------------------------------------
49 # Checks for various programs.
50 #----------------------------------------------------------------------------
52 AC_PROG_LN_S
53 m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
54 # Make sure we can compile in C99 mode.
55 if test "$ac_cv_prog_cc_c99" = "no"; then
56     AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
58 AC_PROG_CPP
59 AC_PROG_CXX
60 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
61 # autoconf 2.59).  If we ever have any Objective-C code in the Valgrind code
62 # base (eg. most likely as Darwin-specific tests) we'll need one of the
63 # following:
64 # - put AC_PROG_OBJC in a Darwin-specific part of this file
65 # - Use AC_PROG_OBJC here and up the minimum autoconf version
66 # - Use the following, which is apparently equivalent:
67 #     m4_ifdef([AC_PROG_OBJC],
68 #        [AC_PROG_OBJC],
69 #        [AC_CHECK_TOOL([OBJC], [gcc])
70 #         AC_SUBST([OBJC])
71 #         AC_SUBST([OBJCFLAGS])
72 #        ])
73 AC_PROG_RANLIB
74 # Set LTO_RANLIB variable to an lto enabled ranlib
75 if test "x$LTO_RANLIB" = "x"; then
76   AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
78 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
80 # provide a very basic definition for AC_PROG_SED if it's not provided by
81 # autoconf (as e.g. in autoconf 2.59).
82 m4_ifndef([AC_PROG_SED],
83           [AC_DEFUN([AC_PROG_SED],
84                     [AC_ARG_VAR([SED])
85                      AC_CHECK_PROGS([SED],[gsed sed])])])
86 AC_PROG_SED
88 AC_DEFUN([AC_PROG_SHA256SUM],
89           [AC_ARG_VAR([SHA256SUM])
90           AC_CHECK_PROGS([SHA256SUM],[gsha256sum sha256sum])])
91 AC_PROG_SHA256SUM
93 # If no AR variable was specified, look up the name of the archiver. Otherwise
94 # do not touch the AR variable.
95 if test "x$AR" = "x"; then
96   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
98 AC_ARG_VAR([AR],[Archiver command])
100 # same for LTO_AR variable for lto enabled archiver
101 if test "x$LTO_AR" = "x"; then
102   AC_PATH_PROGS([LTO_AR], [gcc-ar])
104 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
106 # figure out where perl lives
107 AC_PATH_PROG(PERL, perl)
109 # figure out where gdb lives
110 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
111 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
113 # some older automake's don't have it so try something on our own
114 ifdef([AM_PROG_AS],[AM_PROG_AS],
116 AS="${CC}"
117 AC_SUBST(AS)
119 ASFLAGS=""
120 AC_SUBST(ASFLAGS)
124 # Check if 'diff' supports -u (universal diffs) and use it if possible.
126 AC_MSG_CHECKING([for diff -u])
127 AC_SUBST(DIFF)
129 # Comparing two identical files results in 0.
130 tmpfile="tmp-xxx-yyy-zzz"
131 touch $tmpfile;
132 if diff -u $tmpfile $tmpfile ; then
133     AC_MSG_RESULT([yes])
134     DIFF="diff -u"
135 else
136     AC_MSG_RESULT([no])
137     DIFF="diff"
139 rm $tmpfile
141 # We don't want gcc < 3.0
142 AC_MSG_CHECKING([for a supported version of gcc])
144 # Obtain the compiler version.
146 # A few examples of how the ${CC} --version output looks like:
148 # ######## gcc variants ########
149 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
150 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
151 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
152 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
153 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
154 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
155 # OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
157 # ######## clang variants ########
158 # Clang: clang version 2.9 (tags/RELEASE_29/final)
159 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
160 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
162 # ######## Apple LLVM variants ########
163 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
164 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
167 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
168 then
169     is_clang="applellvm"
170     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
171 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
172 then
173     is_clang="clang"
174     # Don't use -dumpversion with clang: it will always produce "4.2.1".
175     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
176 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
177 then
178     is_clang="icc"
179     gcc_version=`${CC} -dumpversion 2>/dev/null`
180 else
181     is_clang="notclang"
182     gcc_version=`${CC} -dumpversion 2>/dev/null`
183     if test "x$gcc_version" = x; then
184         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
185     fi
188 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
189 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
191 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
192 # statements have to be quoted.
193 case "${is_clang}-${gcc_version}" in
194      applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
195         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
196         ;;
197      icc-1[[3-9]].*|icc-202[[0-9]].*)
198         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
199         ;;
200      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
201         AC_MSG_RESULT([ok (${gcc_version})])
202         ;;
203      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
204         AC_MSG_RESULT([ok (clang-${gcc_version})])
205         ;;
206      *)
207         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
208         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
209         ;;
210 esac
212 #----------------------------------------------------------------------------
213 # Arch/OS/platform tests.
214 #----------------------------------------------------------------------------
215 # We create a number of arch/OS/platform-related variables.  We prefix them
216 # all with "VGCONF_" which indicates that they are defined at
217 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
218 # variables used when compiling C files.
220 AC_CANONICAL_HOST
222 AC_MSG_CHECKING([for a supported CPU])
224 # ARCH_MAX reflects the most that this CPU can do: for example if it
225 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
226 # Ditto for amd64.  It is used for more configuration below, but is not used
227 # outside this file.
229 # Power PC returns powerpc for Big Endian.  This was not changed when Little
230 # Endian support was added to the 64-bit architecture.  The 64-bit Little
231 # Endian systems explicitly state le in the host_cpu.  For clarity in the
232 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
233 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
234 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
235 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
236 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
237 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
238 # Little Endian.
240 case "${host_cpu}" in
241      i?86) 
242         AC_MSG_RESULT([ok (${host_cpu})])
243         ARCH_MAX="x86"
244         ;;
246      x86_64|amd64) 
247         AC_MSG_RESULT([ok (${host_cpu})])
248         ARCH_MAX="amd64"
249         ;;
251      powerpc64)
252      # this only referrs to 64-bit Big Endian
253         AC_MSG_RESULT([ok (${host_cpu})])
254         ARCH_MAX="ppc64be"
255         ;;
257      powerpc64le)
258      # this only referrs to 64-bit Little Endian
259         AC_MSG_RESULT([ok (${host_cpu})])
260         ARCH_MAX="ppc64le"
261         ;;
263      powerpc)
264         # On Linux this means only a 32-bit capable CPU.
265         AC_MSG_RESULT([ok (${host_cpu})])
266         ARCH_MAX="ppc32"
267         ;;
269      s390x)
270         AC_MSG_RESULT([ok (${host_cpu})])
271         ARCH_MAX="s390x"
272         ;;
274      armv7*)
275         AC_MSG_RESULT([ok (${host_cpu})])
276         ARCH_MAX="arm"
277         ;;
279      aarch64*)
280        AC_MSG_RESULT([ok (${host_cpu})])
281        ARCH_MAX="arm64"
282        ;;
284      mips)
285         AC_MSG_RESULT([ok (${host_cpu})])
286         ARCH_MAX="mips32"
287         ;;
289      mipsel)
290         AC_MSG_RESULT([ok (${host_cpu})])
291         ARCH_MAX="mips32"
292         ;;
294      mipsisa32r2)
295         AC_MSG_RESULT([ok (${host_cpu})])
296         ARCH_MAX="mips32"
297         ;;
299      mips64*)
300         AC_MSG_RESULT([ok (${host_cpu})])
301         ARCH_MAX="mips64"
302         ;;
304      mipsisa64*)
305         AC_MSG_RESULT([ok (${host_cpu})])
306         ARCH_MAX="mips64"
307         ;;
308      nanomips)
309         AC_MSG_RESULT([ok (${host_cpu})])
310         ARCH_MAX="nanomips"
311         ;;
313      *) 
314         AC_MSG_RESULT([no (${host_cpu})])
315         AC_MSG_ERROR([Unsupported host architecture. Sorry])
316         ;;
317 esac
319 #----------------------------------------------------------------------------
321 # Sometimes it's convenient to subvert the bi-arch build system and
322 # just have a single build even though the underlying platform is
323 # capable of both.  Hence handle --enable-only64bit and
324 # --enable-only32bit.  Complain if both are issued :-)
325 # [Actually, if either of these options are used, I think both get built,
326 # but only one gets installed.  So if you use an in-place build, both can be
327 # used. --njn]
329 # Check if a 64-bit only build has been requested
330 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
331    [AC_ARG_ENABLE(only64bit, 
332       [  --enable-only64bit      do a 64-bit only build],
333       [vg_cv_only64bit=$enableval],
334       [vg_cv_only64bit=no])])
336 # Check if a 32-bit only build has been requested
337 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
338    [AC_ARG_ENABLE(only32bit, 
339       [  --enable-only32bit      do a 32-bit only build],
340       [vg_cv_only32bit=$enableval],
341       [vg_cv_only32bit=no])])
343 # Stay sane
344 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
345    AC_MSG_ERROR(
346       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
349 #----------------------------------------------------------------------------
351 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
352 # compilation of many C files via -VGO_$(VGCONF_OS) and
353 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
354 AC_MSG_CHECKING([for a supported OS])
355 AC_SUBST(VGCONF_OS)
357 DEFAULT_SUPP=""
359 case "${host_os}" in
360      *linux*)
361         AC_MSG_RESULT([ok (${host_os})])
362         VGCONF_OS="linux"
364         # Ok, this is linux. Check the kernel version
365         AC_MSG_CHECKING([for the kernel version])
367         kernel=`uname -r`
369         case "${kernel}" in
370              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
371                     AC_MSG_RESULT([unsupported (${kernel})])
372                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
373                     ;;
375              *)
376                     AC_MSG_RESULT([2.6 or later (${kernel})])
377                     ;;
378         esac
380         ;;
382      *freebsd*)
383         AC_MSG_RESULT([ok (${host_os})])
384         VGCONF_OS="freebsd"
385         AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
386         freebsd_10=1000
387         AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
388         freebsd_11=1100
389         AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
390         freebsd_12=1200
391         AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
392         freebsd_12_2=1220
393         AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
394         freebsd_13_0=1300
395         AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1])
396         freebsd_13_1=1310
397         AC_DEFINE([FREEBSD_13_2], 1320, [FREEBSD_VERS value for FreeBSD 13.2])
398         freebsd_13_2=1320
399         AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
400         freebsd_14=1400
401         AC_DEFINE([FREEBSD_15], 1500, [FREEBSD_VERS value for FreeBSD 15.x])
402         freebsd_15=1500
404         AC_MSG_CHECKING([for the kernel version])
405         kernel=`uname -r`
407         case "${kernel}" in
408         10.*)
409            AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
410            AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
411            freebsd_vers=$freebsd_10
412            ;;
413         11.*)
414            AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
415            AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
416            freebsd_vers=$freebsd_11
417            ;;
418         12.*)
419            case "${kernel}" in
420            12.[[0-1]]-*)
421               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
422               AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
423               freebsd_vers=$freebsd_12
424               ;;
425            *)
426               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
427               AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
428               freebsd_vers=$freebsd_12_2
429               ;;
430            esac
431            ;;
432         13.*)
433            case "${kernel}" in
434            13.0-*)
435               AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
436               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
437               freebsd_vers=$freebsd_13_0
438               ;;
439            13.1-*)
440               AC_MSG_RESULT([FreeBSD 13.1 (${kernel})])
441               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
442               freebsd_vers=$freebsd_13_1
443               ;;
444            13.2-*)
445               AC_MSG_RESULT([FreeBSD 13.2 (${kernel})])
446               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_2, [FreeBSD version])
447               freebsd_vers=$freebsd_13_2
448               ;;
449            *)
450               AC_MSG_RESULT([unsupported (${kernel})])
451               AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 15.x])
452               ;;
453            esac
454            ;;
455         14.*)
456            AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
457            AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
458            freebsd_vers=$freebsd_14
459            ;;
460         15.*)
461            AC_MSG_RESULT([FreeBSD 15.x (${kernel})])
462            AC_DEFINE([FREEBSD_VERS], FREEBSD_15, [FreeBSD version])
463            freebsd_vers=$freebsd_15
464            ;;
465         *)
466            AC_MSG_RESULT([unsupported (${kernel})])
467            AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 15.x])
468            ;;
469         esac
471         DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
472         ;;
474      *darwin*)
475         AC_MSG_RESULT([ok (${host_os})])
476         VGCONF_OS="darwin"
477         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
478         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
479         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
480         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
481         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
482         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
483         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
484         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
485         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
487         AC_MSG_CHECKING([for the kernel version])
488         kernel=`uname -r`
490         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
491         # has only one relevant version, the OS version. The `uname` check
492         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
493         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
494         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
495         # and we don't know of an macros similar to __GLIBC__ to get that info.
496         #
497         # XXX: `uname -r` won't do the right thing for cross-compiles, but
498         # that's not a problem yet.
499         #
500         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
501         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
502         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
503         # time support for 10.5 (the 9.* pattern just below), I'll leave it
504         # in for now, just in case anybody wants to give it a try.  But I'm
505         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
506         case "${kernel}" in
507              9.*)
508                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
509                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
510                   DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
511                   DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
512                   ;;
513              10.*)
514                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
515                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
516                   DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
517                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
518                   ;;
519              11.*)
520                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
521                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
522                   DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
523                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
524                   ;;
525              12.*)
526                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
527                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
528                   DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
529                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
530                   ;;
531              13.*)
532                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
533                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
534                   DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
535                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
536                   ;;
537              14.*)
538                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
539                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
540                   DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
541                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
542                   ;;
543              15.*)
544                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
545                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
546                   DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
547                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
548                   ;;
549              16.*)
550                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
551                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
552                   DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
553                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
554                   ;;
555              17.*)
556                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
557                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
558                   DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
559                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
560                   ;;
561              *) 
562                   AC_MSG_RESULT([unsupported (${kernel})])
563                   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)])
564                   ;;
565         esac
566         ;;
568      solaris2.11*)
569         AC_MSG_RESULT([ok (${host_os})])
570         VGCONF_OS="solaris"
572         uname_v=$( uname -v )
573         case "$uname_v" in
574              11.4.*)
575                  DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
576                  ;;
577              *)
578                  DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
579                  ;;
580         esac
581         ;;
583      solaris2.12*)
584         AC_MSG_RESULT([ok (${host_os})])
585         VGCONF_OS="solaris"
586         DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
587         ;;
589      *) 
590         AC_MSG_RESULT([no (${host_os})])
591         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
592         ;;
593 esac
595 #----------------------------------------------------------------------------
597 # If we are building on a 64 bit platform test to see if the system
598 # supports building 32 bit programs and disable 32 bit support if it
599 # does not support building 32 bit programs
601 case "$ARCH_MAX-$VGCONF_OS" in
602      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
603         AC_MSG_CHECKING([for 32 bit build support])
604         safe_CFLAGS=$CFLAGS
605         CFLAGS="-m32"
606         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
607           return 0;
608         ]])], [
609         AC_MSG_RESULT([yes])
610         ], [
611         vg_cv_only64bit="yes"
612         AC_MSG_RESULT([no])
613         ])
614         CFLAGS=$safe_CFLAGS;;
615     mips64-linux)
616         AC_MSG_CHECKING([for 32 bit build support])
617         safe_CFLAGS=$CFLAGS
618         CFLAGS="$CFLAGS -mips32 -mabi=32"
619         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
620           #include <sys/prctl.h>
621         ]], [[]])], [
622         AC_MSG_RESULT([yes])
623         ], [
624         vg_cv_only64bit="yes"
625         AC_MSG_RESULT([no])
626         ])
627         CFLAGS=$safe_CFLAGS;;
628 esac
630 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
631    AC_MSG_ERROR(
632       [--enable-only32bit was specified but system does not support 32 bit builds])
635 #----------------------------------------------------------------------------
637 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
638 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
639 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
640 # above) will be "amd64" since that reflects the most that this cpu can do,
641 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
642 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
643 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
644 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
645 AC_SUBST(VGCONF_ARCH_PRI)
647 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
648 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
649 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
650 # It is empty if there is no secondary target.
651 AC_SUBST(VGCONF_ARCH_SEC)
653 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
654 # The entire system, including regression and performance tests, will be
655 # built for this target.  The "_CAPS" indicates that the name is in capital
656 # letters, and it also uses '_' rather than '-' as a separator, because it's
657 # used to create various Makefile variables, which are all in caps by
658 # convention and cannot contain '-' characters.  This is in contrast to
659 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
660 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
662 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
663 # Valgrind and tools will also be built for this target, but not the
664 # regression or performance tests.
666 # By default, the primary arch is the same as the "max" arch, as commented
667 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
668 # the big case statement just below here, in the case where we're building
669 # on a 64 bit machine but have been requested only to do a 32 bit build.
670 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
672 AC_MSG_CHECKING([for a supported CPU/OS combination])
674 # NB.  The load address for a given platform may be specified in more 
675 # than one place, in some cases, depending on whether we're doing a biarch,
676 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
677 # Be careful to give consistent values in all subcases.  Also, all four
678 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
679 # even if it is to "0xUNSET".
681 case "$ARCH_MAX-$VGCONF_OS" in
682      x86-linux)
683         VGCONF_ARCH_PRI="x86"
684         VGCONF_ARCH_SEC=""
685         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
686         VGCONF_PLATFORM_SEC_CAPS=""
687         valt_load_address_pri_norml="0x58000000"
688         valt_load_address_pri_inner="0x38000000"
689         valt_load_address_sec_norml="0xUNSET"
690         valt_load_address_sec_inner="0xUNSET"
691         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
692         ;;
693      amd64-linux)
694         valt_load_address_sec_norml="0xUNSET"
695         valt_load_address_sec_inner="0xUNSET"
696         if test x$vg_cv_only64bit = xyes; then
697            VGCONF_ARCH_PRI="amd64"
698            VGCONF_ARCH_SEC=""
699            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
700            VGCONF_PLATFORM_SEC_CAPS=""
701            valt_load_address_pri_norml="0x58000000"
702            valt_load_address_pri_inner="0x38000000"
703         elif test x$vg_cv_only32bit = xyes; then
704            VGCONF_ARCH_PRI="x86"
705            VGCONF_ARCH_SEC=""
706            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
707            VGCONF_PLATFORM_SEC_CAPS=""
708            valt_load_address_pri_norml="0x58000000"
709            valt_load_address_pri_inner="0x38000000"
710         else
711            VGCONF_ARCH_PRI="amd64"
712            VGCONF_ARCH_SEC="x86"
713            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
714            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
715            valt_load_address_pri_norml="0x58000000"
716            valt_load_address_pri_inner="0x38000000"
717            valt_load_address_sec_norml="0x58000000"
718            valt_load_address_sec_inner="0x38000000"
719         fi
720         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
721         ;;
722      ppc32-linux)
723         VGCONF_ARCH_PRI="ppc32"
724         VGCONF_ARCH_SEC=""
725         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
726         VGCONF_PLATFORM_SEC_CAPS=""
727         valt_load_address_pri_norml="0x58000000"
728         valt_load_address_pri_inner="0x38000000"
729         valt_load_address_sec_norml="0xUNSET"
730         valt_load_address_sec_inner="0xUNSET"
731         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
732         ;;
733      ppc64be-linux)
734         valt_load_address_sec_norml="0xUNSET"
735         valt_load_address_sec_inner="0xUNSET"
736         if test x$vg_cv_only64bit = xyes; then
737            VGCONF_ARCH_PRI="ppc64be"
738            VGCONF_ARCH_SEC=""
739            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
740            VGCONF_PLATFORM_SEC_CAPS=""
741            valt_load_address_pri_norml="0x58000000"
742            valt_load_address_pri_inner="0x38000000"
743         elif test x$vg_cv_only32bit = xyes; then
744            VGCONF_ARCH_PRI="ppc32"
745            VGCONF_ARCH_SEC=""
746            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
747            VGCONF_PLATFORM_SEC_CAPS=""
748            valt_load_address_pri_norml="0x58000000"
749            valt_load_address_pri_inner="0x38000000"
750         else
751            VGCONF_ARCH_PRI="ppc64be"
752            VGCONF_ARCH_SEC="ppc32"
753            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
754            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
755            valt_load_address_pri_norml="0x58000000"
756            valt_load_address_pri_inner="0x38000000"
757            valt_load_address_sec_norml="0x58000000"
758            valt_load_address_sec_inner="0x38000000"
759         fi
760         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
761         ;;
762      ppc64le-linux)
763         # Little Endian is only supported on PPC64
764         valt_load_address_sec_norml="0xUNSET"
765         valt_load_address_sec_inner="0xUNSET"
766         VGCONF_ARCH_PRI="ppc64le"
767         VGCONF_ARCH_SEC=""
768         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
769         VGCONF_PLATFORM_SEC_CAPS=""
770         valt_load_address_pri_norml="0x58000000"
771         valt_load_address_pri_inner="0x38000000"
772         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
773        ;;
774      x86-freebsd)
775         VGCONF_ARCH_PRI="x86"
776         VGCONF_ARCH_SEC=""
777         VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
778         VGCONF_PLATFORM_SEC_CAPS=""
779         valt_load_address_pri_norml="0x38000000"
780         valt_load_address_pri_inner="0x28000000"
781         valt_load_address_sec_norml="0xUNSET"
782         valt_load_address_sec_inner="0xUNSET"
783         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
784         ;;
785      amd64-freebsd)
786         if test x$vg_cv_only64bit = xyes; then
787            VGCONF_ARCH_PRI="amd64"
788            VGCONF_ARCH_SEC=""
789            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
790            VGCONF_PLATFORM_SEC_CAPS=""
791         elif test x$vg_cv_only32bit = xyes; then
792            VGCONF_ARCH_PRI="x86"
793            VGCONF_ARCH_SEC=""
794            VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
795            VGCONF_PLATFORM_SEC_CAPS=""
796         else
797            VGCONF_ARCH_PRI="amd64"
798            VGCONF_ARCH_SEC="x86"
799            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
800            VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
801         fi
802         # These work with either base clang or ports installed gcc
803         # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
804         if test x$is_clang = xclang ; then
805            FLAG_32ON64="-B/usr/lib32"
806         else
807            GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
808            FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
809         fi
810         valt_load_address_pri_norml="0x38000000"
811         valt_load_address_pri_inner="0x28000000"
812         valt_load_address_sec_norml="0x38000000"
813         valt_load_address_sec_inner="0x28000000"
814         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
815         ;;
816      # Darwin gets identified as 32-bit even when it supports 64-bit.
817      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
818      # all Macs support both 32-bit and 64-bit, so we just build both.  If
819      # someone has a really old 32-bit only machine they can (hopefully?)
820      # build with --enable-only32bit.  See bug 243362.
821      x86-darwin|amd64-darwin)
822         ARCH_MAX="amd64"
823         valt_load_address_sec_norml="0xUNSET"
824         valt_load_address_sec_inner="0xUNSET"
825         if test x$vg_cv_only64bit = xyes; then
826            VGCONF_ARCH_PRI="amd64"
827            VGCONF_ARCH_SEC=""
828            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
829            VGCONF_PLATFORM_SEC_CAPS=""
830            valt_load_address_pri_norml="0x158000000"
831            valt_load_address_pri_inner="0x138000000"
832         elif test x$vg_cv_only32bit = xyes; then
833            VGCONF_ARCH_PRI="x86"
834            VGCONF_ARCH_SEC=""
835            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
836            VGCONF_PLATFORM_SEC_CAPS=""
837            VGCONF_ARCH_PRI_CAPS="x86"
838            valt_load_address_pri_norml="0x58000000"
839            valt_load_address_pri_inner="0x38000000"
840         else
841            VGCONF_ARCH_PRI="amd64"
842            VGCONF_ARCH_SEC="x86"
843            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
844            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
845            valt_load_address_pri_norml="0x158000000"
846            valt_load_address_pri_inner="0x138000000"
847            valt_load_address_sec_norml="0x58000000"
848            valt_load_address_sec_inner="0x38000000"
849         fi
850         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
851         ;;
852      arm-linux) 
853         VGCONF_ARCH_PRI="arm"
854         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
855         VGCONF_PLATFORM_SEC_CAPS=""
856         valt_load_address_pri_norml="0x58000000"
857         valt_load_address_pri_inner="0x38000000"
858         valt_load_address_sec_norml="0xUNSET"
859         valt_load_address_sec_inner="0xUNSET"
860         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
861         ;;
862      arm64-linux)
863         valt_load_address_sec_norml="0xUNSET"
864         valt_load_address_sec_inner="0xUNSET"
865         if test x$vg_cv_only64bit = xyes; then
866            VGCONF_ARCH_PRI="arm64"
867            VGCONF_ARCH_SEC=""
868            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
869            VGCONF_PLATFORM_SEC_CAPS=""
870            valt_load_address_pri_norml="0x58000000"
871            valt_load_address_pri_inner="0x38000000"
872         elif test x$vg_cv_only32bit = xyes; then
873            VGCONF_ARCH_PRI="arm"
874            VGCONF_ARCH_SEC=""
875            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
876            VGCONF_PLATFORM_SEC_CAPS=""
877            valt_load_address_pri_norml="0x58000000"
878            valt_load_address_pri_inner="0x38000000"
879         else
880            VGCONF_ARCH_PRI="arm64"
881            VGCONF_ARCH_SEC="arm"
882            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
883            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
884            valt_load_address_pri_norml="0x58000000"
885            valt_load_address_pri_inner="0x38000000"
886            valt_load_address_sec_norml="0x58000000"
887            valt_load_address_sec_inner="0x38000000"
888         fi
889         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
890         ;;
891      s390x-linux)
892         VGCONF_ARCH_PRI="s390x"
893         VGCONF_ARCH_SEC=""
894         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
895         VGCONF_PLATFORM_SEC_CAPS=""
896         # To improve branch prediction hit rate we want to have
897         # the generated code close to valgrind (host) code
898         valt_load_address_pri_norml="0x800000000"
899         valt_load_address_pri_inner="0x810000000"
900         valt_load_address_sec_norml="0xUNSET"
901         valt_load_address_sec_inner="0xUNSET"
902         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
903         ;;
904      mips32-linux) 
905         VGCONF_ARCH_PRI="mips32"
906         VGCONF_ARCH_SEC=""
907         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
908         VGCONF_PLATFORM_SEC_CAPS=""
909         valt_load_address_pri_norml="0x58000000"
910         valt_load_address_pri_inner="0x38000000"
911         valt_load_address_sec_norml="0xUNSET"
912         valt_load_address_sec_inner="0xUNSET"
913         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
914         ;;
915      mips64-linux)
916         valt_load_address_sec_norml="0xUNSET"
917         valt_load_address_sec_inner="0xUNSET"
918         if test x$vg_cv_only64bit = xyes; then
919             VGCONF_ARCH_PRI="mips64"
920             VGCONF_PLATFORM_SEC_CAPS=""
921             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
922             VGCONF_PLATFORM_SEC_CAPS=""
923             valt_load_address_pri_norml="0x58000000"
924             valt_load_address_pri_inner="0x38000000"
925         elif test x$vg_cv_only32bit = xyes; then
926             VGCONF_ARCH_PRI="mips32"
927             VGCONF_ARCH_SEC=""
928             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
929             VGCONF_PLATFORM_SEC_CAPS=""
930             valt_load_address_pri_norml="0x58000000"
931             valt_load_address_pri_inner="0x38000000"
932         else
933             VGCONF_ARCH_PRI="mips64"
934             VGCONF_ARCH_SEC="mips32"
935             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
936             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
937             valt_load_address_pri_norml="0x58000000"
938             valt_load_address_pri_inner="0x38000000"
939             valt_load_address_sec_norml="0x58000000"
940             valt_load_address_sec_inner="0x38000000"
941         fi
942         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
943         ;;
944      nanomips-linux)
945         VGCONF_ARCH_PRI="nanomips"
946         VGCONF_ARCH_SEC=""
947         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
948         VGCONF_PLATFORM_SEC_CAPS=""
949         valt_load_address_pri_norml="0x58000000"
950         valt_load_address_pri_inner="0x38000000"
951         valt_load_address_sec_norml="0xUNSET"
952         valt_load_address_sec_inner="0xUNSET"
953         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
954         ;;
955      x86-solaris)
956         VGCONF_ARCH_PRI="x86"
957         VGCONF_ARCH_SEC=""
958         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
959         VGCONF_PLATFORM_SEC_CAPS=""
960         valt_load_address_pri_norml="0x58000000"
961         valt_load_address_pri_inner="0x38000000"
962         valt_load_address_sec_norml="0xUNSET"
963         valt_load_address_sec_inner="0xUNSET"
964         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
965         ;;
966      amd64-solaris)
967         valt_load_address_sec_norml="0xUNSET"
968         valt_load_address_sec_inner="0xUNSET"
969         if test x$vg_cv_only64bit = xyes; then
970            VGCONF_ARCH_PRI="amd64"
971            VGCONF_ARCH_SEC=""
972            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
973            VGCONF_PLATFORM_SEC_CAPS=""
974            valt_load_address_pri_norml="0x58000000"
975            valt_load_address_pri_inner="0x38000000"
976         elif test x$vg_cv_only32bit = xyes; then
977            VGCONF_ARCH_PRI="x86"
978            VGCONF_ARCH_SEC=""
979            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
980            VGCONF_PLATFORM_SEC_CAPS=""
981            valt_load_address_pri_norml="0x58000000"
982            valt_load_address_pri_inner="0x38000000"
983         else
984            VGCONF_ARCH_PRI="amd64"
985            VGCONF_ARCH_SEC="x86"
986            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
987            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
988            valt_load_address_pri_norml="0x58000000"
989            valt_load_address_pri_inner="0x38000000"
990            valt_load_address_sec_norml="0x58000000"
991            valt_load_address_sec_inner="0x38000000"
992         fi
993         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
994         ;;
995     *)
996         VGCONF_ARCH_PRI="unknown"
997         VGCONF_ARCH_SEC="unknown"
998         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
999         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
1000         valt_load_address_pri_norml="0xUNSET"
1001         valt_load_address_pri_inner="0xUNSET"
1002         valt_load_address_sec_norml="0xUNSET"
1003         valt_load_address_sec_inner="0xUNSET"
1004         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
1005         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
1006         ;;
1007 esac
1009 #----------------------------------------------------------------------------
1011 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
1012 # defined.
1013 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
1014                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1015                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1016                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1017                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1018                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1019                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1020                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1021                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1022 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
1023                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1024                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1025                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1026                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1027 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
1028                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1029                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1030 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
1031                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1032                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1033 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
1034                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1035                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1036 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
1037                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1038 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1039                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1040 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1041                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1042                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1043 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1044                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
1045 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1046                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1048 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
1049 # become defined.
1050 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
1051                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1052                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1053 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
1054                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1055 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
1056                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1057                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1058 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1059                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1060 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1061                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1062 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1063                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1064                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1065 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1066                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1067 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1068                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1069                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1070 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1071                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1072                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1073 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1074                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1075 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1076                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1077 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1078                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1079                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1080 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1081                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1082 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1083                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1084                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1085 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1086                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1087 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1088                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1089                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1090 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1091                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1094 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1095 # Relies on the assumption that the primary and secondary targets are 
1096 # for the same OS, so therefore only necessary to test the primary.
1097 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1098                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1099                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1100                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1101                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1102                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1103                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1104                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1105                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1106                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1107                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1108                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1109 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1110                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1111                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1112 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1113                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1114                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1115 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1116                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1117                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1118 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1119                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1120                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1121                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1122                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1125 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1126 # there is a secondary target.
1127 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1128                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1130 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1131 dnl fallback definition
1132 dnl The macro is courtesy of Dave Hart:
1133 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1134 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1135 if test -z "$$1_TRUE"; then :
1136   m4_n([$2])[]dnl
1137 m4_ifval([$3],
1138 [else
1139   $3
1140 ])dnl
1141 fi[]dnl
1142 ])])
1144 #----------------------------------------------------------------------------
1145 # Inner Valgrind?
1146 #----------------------------------------------------------------------------
1148 # Check if this should be built as an inner Valgrind, to be run within
1149 # another Valgrind.  Choose the load address accordingly.
1150 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1151 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1152 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1153    [AC_ARG_ENABLE(inner, 
1154       [  --enable-inner          enables self-hosting],
1155       [vg_cv_inner=$enableval],
1156       [vg_cv_inner=no])])
1157 if test "$vg_cv_inner" = yes; then
1158     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1159     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1160     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1161 else
1162     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1163     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1166 #----------------------------------------------------------------------------
1167 # Undefined behaviour sanitiser
1168 #----------------------------------------------------------------------------
1169 # Check whether we should build with the undefined beahviour sanitiser.
1171 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1172    [AC_ARG_ENABLE(ubsan, 
1173       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1174       [vg_cv_ubsan=$enableval],
1175       [vg_cv_ubsan=no])])
1177 #----------------------------------------------------------------------------
1178 # Extra fine-tuning of installation directories
1179 #----------------------------------------------------------------------------
1180 AC_ARG_WITH(tmpdir,
1181    [  --with-tmpdir=PATH      Specify path for temporary files],
1182    tmpdir="$withval",
1183    tmpdir="/tmp")
1184 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1185 AC_SUBST(VG_TMPDIR, [$tmpdir])
1187 #----------------------------------------------------------------------------
1188 # Detect xcode path
1189 #----------------------------------------------------------------------------
1190 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1191 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1192 AC_MSG_CHECKING([for xcode sdk include path])
1193 AC_ARG_WITH(xcodedir,
1194    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1195    [xcodedir="$withval"],
1196    [
1197       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1198          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1199          if test -z "$xcrundir"; then
1200             xcodedir="/usr/include"
1201          else
1202             xcodedir="$xcrundir/usr/include"
1203          fi
1204       else
1205          xcodedir="/usr/include"
1206       fi
1207    ])
1208 AC_MSG_RESULT([$xcodedir])
1209 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1210 AC_SUBST(XCODE_DIR, [$xcodedir])])
1212 #----------------------------------------------------------------------------
1213 # Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir)
1214 #----------------------------------------------------------------------------
1215 AC_MSG_CHECKING([where gdb scripts are installed])
1216 AC_ARG_WITH(gdbscripts-dir,
1217    [  --with-gdbscripts-dir=PATH  Specify path to install gdb scripts],
1218    [gdbscriptsdir=${withval}],
1219    [gdbscriptsdir=${libexecdir}/valgrind])
1220 AC_MSG_RESULT([$gdbscriptsdir])
1221 if test "x$gdbscriptsdir" != "xno"; then
1222   AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir])
1223   AM_CONDITIONAL(GDBSCRIPTS, true)
1224 else
1225   AC_SUBST(VG_GDBSCRIPTS_DIR, [])
1226   AM_CONDITIONAL(GDBSCRIPTS, false)
1229 #----------------------------------------------------------------------------
1230 # Libc and suppressions
1231 #----------------------------------------------------------------------------
1232 # This variable will collect the suppression files to be used.
1233 AC_SUBST(DEFAULT_SUPP)
1235 AC_CHECK_HEADER([features.h])
1237 if test x$ac_cv_header_features_h = xyes; then
1238   AC_DEFINE([HAVE_HEADER_FEATURES_H], 1,
1239           [Define to 1 if you have the `features.h' header.])
1240   rm -f conftest.$ac_ext
1241   cat <<_ACEOF >conftest.$ac_ext
1242 #include <features.h>
1243 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1244 glibc version is: __GLIBC__ __GLIBC_MINOR__
1245 #endif
1246 _ACEOF
1247   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1250 # not really a version check
1251 AC_EGREP_CPP([DARWIN_LIBC], [
1252 #include <sys/cdefs.h>
1253 #if defined(__DARWIN_VERS_1050)
1254   DARWIN_LIBC
1255 #endif
1257 GLIBC_VERSION="darwin")
1259 AC_EGREP_CPP([FREEBSD_LIBC], [
1260 #include <sys/cdefs.h>
1261 #if defined(__FreeBSD__)
1262   FREEBSD_LIBC
1263 #endif
1265 GLIBC_VERSION="freebsd")
1267 # not really a version check
1268 AC_EGREP_CPP([BIONIC_LIBC], [
1269 #if defined(__ANDROID__)
1270   BIONIC_LIBC
1271 #endif
1273 GLIBC_VERSION="bionic")
1275 # there is only one version of libc on Solaris
1276 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1277      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1278     GLIBC_VERSION="solaris"
1281 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1282 # in this case.
1283 if test x$GLIBC_VERSION = x; then
1284     if $CC -dumpmachine | grep -q musl; then
1285         GLIBC_VERSION=musl
1286     fi
1289 # If this is glibc then figure out the generic (in file) libc.so and
1290 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1291 # was a separate library, afterwards it was merged into libc.so and
1292 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1293 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1294 case ${GLIBC_VERSION} in
1296   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1297   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1298   [
1299     AC_MSG_RESULT([no])
1300     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1301     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1302   ], [
1303     AC_MSG_RESULT([yes])
1304     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1305     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1306   ])
1307   ;;
1309   AC_MSG_CHECKING([not glibc...])
1310   AC_MSG_RESULT([${GLIBC_VERSION}])
1311   ;;
1312 esac
1314 AC_MSG_CHECKING([the glibc version])
1316 case "${GLIBC_VERSION}" in
1317      2.2)
1318         AC_MSG_RESULT(${GLIBC_VERSION} family)
1319         DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1320         DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1321         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1322         ;;
1323      2.[[3-6]])
1324         AC_MSG_RESULT(${GLIBC_VERSION} family)
1325         DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1326         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1327         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1328         ;;
1329      2.[[7-9]])
1330         AC_MSG_RESULT(${GLIBC_VERSION} family)
1331         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1332         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1333         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1334         ;;
1335      2.10|2.11)
1336         AC_MSG_RESULT(${GLIBC_VERSION} family)
1337         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1338                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1339         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1340         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1341         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1342         ;;
1343      2.*)
1344         AC_MSG_RESULT(${GLIBC_VERSION} family)
1345         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1346                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1347         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1348                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1349         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1350         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1351         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1352         ;;
1353      darwin)
1354         AC_MSG_RESULT(Darwin)
1355         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1356         # DEFAULT_SUPP set by kernel version check above.
1357         ;;
1358      freebsd)
1359         AC_MSG_RESULT(FreeBSD)
1360         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1361         # DEFAULT_SUPP set by kernel version check above.
1362         ;;
1363      bionic)
1364         AC_MSG_RESULT(Bionic)
1365         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1366         DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1367         ;;
1368      solaris)
1369         AC_MSG_RESULT(Solaris)
1370         # DEFAULT_SUPP set in host_os switch-case above.
1371         # No other suppression file is used.
1372         ;;
1373      musl)
1374         AC_MSG_RESULT(Musl)
1375         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1376         DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1377         ;;
1378      2.0|2.1|*)
1379         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1380         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1381         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1382         ;;
1383 esac
1385 AC_SUBST(GLIBC_VERSION)
1386 AC_SUBST(GLIBC_LIBC_PATH)
1387 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1390 if test "$VGCONF_OS" != "solaris"; then
1391     # Add default suppressions for the X client libraries.  Make no
1392     # attempt to detect whether such libraries are installed on the
1393     # build machine (or even if any X facilities are present); just
1394     # add the suppressions antidisirregardless.
1395     DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1396     DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1400 #----------------------------------------------------------------------------
1401 # Platform variants?
1402 #----------------------------------------------------------------------------
1404 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1405 # But there are times where we need a bit more control.  The motivating
1406 # and currently only case is Android: this is almost identical to
1407 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1408 # platform variant tags, which get passed in the compile as
1409 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1411 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1412 # it is "android" instead.
1414 # Consequently (eg), plain arm-linux would build with
1416 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1418 # whilst an Android build would have
1420 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1422 # Same for x86. The setup of the platform variant is pushed relatively far
1423 # down this file in order that we can inspect any of the variables set above.
1425 # In the normal case ..
1426 VGCONF_PLATVARIANT="vanilla"
1428 # Android ?
1429 if test "$GLIBC_VERSION" = "bionic";
1430 then
1431    VGCONF_PLATVARIANT="android"
1434 AC_SUBST(VGCONF_PLATVARIANT)
1437 # FIXME: do we also want to define automake variables
1438 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1439 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1440 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1441 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1442 # that's what we'd need to do to use this, since what we'd want to write
1443 # is something like
1445 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1447 # Hmm.  Can't think of a nice clean solution to this.
1449 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1450                test x$VGCONF_PLATVARIANT = xvanilla)
1451 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1452                test x$VGCONF_PLATVARIANT = xandroid)
1455 #----------------------------------------------------------------------------
1456 # Checking for various library functions and other definitions
1457 #----------------------------------------------------------------------------
1459 # Check for AT_FDCWD
1461 AC_MSG_CHECKING([for AT_FDCWD])
1462 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1463 #define _GNU_SOURCE
1464 #include <fcntl.h>
1465 #include <unistd.h>
1466 ]], [[
1467   int a = AT_FDCWD;
1468 ]])], [
1469 ac_have_at_fdcwd=yes
1470 AC_MSG_RESULT([yes])
1471 ], [
1472 ac_have_at_fdcwd=no
1473 AC_MSG_RESULT([no])
1476 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1478 # Check for stpncpy function definition in string.h
1479 # This explicitly checks with _GNU_SOURCE defined since that is also
1480 # used in the test case (some systems might define it without anyway
1481 # since stpncpy is part of The Open Group Base Specifications Issue 7
1482 # IEEE Std 1003.1-2008.
1483 AC_MSG_CHECKING([for stpncpy])
1484 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1485 #define _GNU_SOURCE
1486 #include <string.h>
1487 ]], [[
1488   char *d;
1489   char *s;
1490   size_t n = 0;
1491   char *r = stpncpy(d, s, n);
1492 ]])], [
1493 ac_have_gnu_stpncpy=yes
1494 AC_MSG_RESULT([yes])
1495 ], [
1496 ac_have_gnu_stpncpy=no
1497 AC_MSG_RESULT([no])
1500 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1502 # Check for PTRACE_GETREGS
1504 AC_MSG_CHECKING([for PTRACE_GETREGS])
1505 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1506 #include <stdlib.h>
1507 #include <stddef.h>
1508 #include <sys/ptrace.h>
1509 #include <sys/user.h>
1510 ]], [[
1511   void *p;
1512   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1513 ]])], [
1514 AC_MSG_RESULT([yes])
1515 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1516           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1517 ], [
1518 AC_MSG_RESULT([no])
1522 # Check for CLOCK_MONOTONIC
1524 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1527 #include <time.h>
1528 ]], [[
1529   struct timespec t;
1530   clock_gettime(CLOCK_MONOTONIC, &t);
1531   return 0;
1532 ]])], [
1533 AC_MSG_RESULT([yes])
1534 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1535           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1536 ], [
1537 AC_MSG_RESULT([no])
1541 # Check for ELF32/64_CHDR
1543 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1546 # Check for PTHREAD_RWLOCK_T
1548 AC_MSG_CHECKING([for pthread_rwlock_t])
1550 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1551 #define _GNU_SOURCE
1552 #include <pthread.h>
1553 ]], [[
1554   pthread_rwlock_t rwl;
1555 ]])], [
1556 AC_MSG_RESULT([yes])
1557 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1558           [Define to 1 if you have the `pthread_rwlock_t' type.])
1559 ], [
1560 AC_MSG_RESULT([no])
1563 # Check for CLOCKID_T
1565 AC_MSG_CHECKING([for clockid_t])
1567 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1568 #include <time.h>
1569 ]], [[
1570   clockid_t c;
1571 ]])], [
1572 AC_MSG_RESULT([yes])
1573 AC_DEFINE([HAVE_CLOCKID_T], 1,
1574           [Define to 1 if you have the `clockid_t' type.])
1575 ], [
1576 AC_MSG_RESULT([no])
1579 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1581 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1583 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1584 #define _GNU_SOURCE
1585 #include <pthread.h>
1586 ]], [[
1587   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1588 ]])], [
1589 AC_MSG_RESULT([yes])
1590 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1591           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1592 ], [
1593 AC_MSG_RESULT([no])
1597 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1599 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1601 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1602 #define _GNU_SOURCE
1603 #include <pthread.h>
1604 ]], [[
1605   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1606 ]])], [
1607 AC_MSG_RESULT([yes])
1608 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1609           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1610 ], [
1611 AC_MSG_RESULT([no])
1615 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1617 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1619 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1620 #define _GNU_SOURCE
1621 #include <pthread.h>
1622 ]], [[
1623   return (PTHREAD_MUTEX_RECURSIVE_NP);
1624 ]])], [
1625 AC_MSG_RESULT([yes])
1626 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1627           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1628 ], [
1629 AC_MSG_RESULT([no])
1633 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1635 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1637 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1638 #define _GNU_SOURCE
1639 #include <pthread.h>
1640 ]], [[
1641   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1642   return 0;
1643 ]])], [
1644 AC_MSG_RESULT([yes])
1645 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1646           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1647 ], [
1648 AC_MSG_RESULT([no])
1652 # Check whether pthread_mutex_t has a member called __m_kind.
1654 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1655                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1656                            1,                                   
1657                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1658                 ],
1659                 [],
1660                 [#include <pthread.h>])
1663 # Check whether pthread_mutex_t has a member called __data.__kind.
1665 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1666                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1667                           1,
1668                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1669                 ],
1670                 [],
1671                 [#include <pthread.h>])
1673 # Convenience function.  Set flags based on the existing HWCAP entries.
1674 # The AT_HWCAP entries are generated by glibc, and are based on
1675 # functions supported by the hardware/system/libc.
1676 # Subsequent support for whether the capability will actually be utilized
1677 # will also be checked against the compiler capabilities.
1678 # called as
1679 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1680 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1681   AUXV_CHECK_FOR=$1
1682   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1683   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1684   then
1685     AC_MSG_RESULT([yes])
1686     AC_SUBST([$2],[yes])
1687   else
1688     AC_MSG_RESULT([no])
1689     AC_SUBST([$2],[])
1690   fi
1693 # gather hardware capabilities. (hardware/kernel/libc)
1694 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1695 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1696 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1697 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1698 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1699 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1700 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1701 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1702 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1703 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1705 # ISA Levels
1706 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1707 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1708 # compiler support for isa 2.07 level instructions
1709 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1710 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1711 ]], [[
1712   __asm__ __volatile__("mtvsrd 1,2 ");
1713 ]])], [
1714 ac_asm_have_isa_2_07=yes
1715 AC_MSG_RESULT([yes])
1716 ], [
1717 ac_asm_have_isa_2_07=no
1718 AC_MSG_RESULT([no])
1720 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1721                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1723 # altivec (vsx) support.
1724 # does this compiler support -maltivec and does it have the include file
1725 # <altivec.h> ?
1726 AC_MSG_CHECKING([for Altivec support in the compiler ])
1727 safe_CFLAGS=$CFLAGS
1728 CFLAGS="-maltivec -Werror"
1729 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1730 #include <altivec.h>
1731 ]], [[
1732   vector unsigned int v;
1733 ]])], [
1734 ac_have_altivec=yes
1735 AC_MSG_RESULT([yes])
1736 ], [
1737 ac_have_altivec=no
1738 AC_MSG_RESULT([no])
1740 CFLAGS=$safe_CFLAGS
1741 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1742                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1744 # Check that both: the compiler supports -mvsx and that the assembler
1745 # understands VSX instructions.  If either of those doesn't work,
1746 # conclude that we can't do VSX.
1747 AC_MSG_CHECKING([for VSX compiler flag support])
1748 safe_CFLAGS=$CFLAGS
1749 CFLAGS="-mvsx -Werror"
1750 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1751 ]], [[
1752 ]])], [
1753 ac_compiler_supports_vsx_flag=yes
1754 AC_MSG_RESULT([yes])
1755 ], [
1756 ac_compiler_supports_vsx_flag=no
1757 AC_MSG_RESULT([no])
1759 CFLAGS=$safe_CFLAGS
1761 AC_MSG_CHECKING([for VSX support in the assembler ])
1762 safe_CFLAGS=$CFLAGS
1763 CFLAGS="-mvsx -Werror"
1764 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1765 #include <altivec.h>
1766 ]], [[
1767   vector unsigned int v;
1768   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1769 ]])], [
1770 ac_compiler_supports_vsx=yes
1771 AC_MSG_RESULT([yes])
1772 ], [
1773 ac_compiler_supports_vsx=no
1774 AC_MSG_RESULT([no])
1776 CFLAGS=$safe_CFLAGS
1777 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1778                              -a x$ac_compiler_supports_vsx = xyes \
1779                              -a x$HWCAP_HAS_VSX = xyes ])
1781 # DFP (Decimal Float)
1782 # The initial DFP support was added in Power 6.  The dcffix instruction
1783 # support was added in Power 7.
1784 AC_MSG_CHECKING([that assembler knows DFP])
1785 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1786 ]], [[
1787   #ifdef __s390__
1788   __asm__ __volatile__("adtr 1, 2, 3")
1789   #else
1790 __asm__ __volatile__(".machine power7;\n" \
1791   "dadd 1, 2, 3;\n" \
1792   "dcffix 1, 2");
1793   #endif
1794 ]])], [
1795 ac_asm_have_dfp=yes
1796 AC_MSG_RESULT([yes])
1797 ], [
1798 ac_asm_have_dfp=no
1799 AC_MSG_RESULT([no])
1801 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1802 safe_CFLAGS=$CFLAGS
1803 CFLAGS="-mhard-dfp -Werror"
1805 # The dcffix instruction is Power 7
1806 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1807 ]], [[
1808   #ifdef __s390__
1809   __asm__ __volatile__("adtr 1, 2, 3")
1810   #else
1811   __asm__ __volatile__(".machine power7;\n" \
1812   "dadd 1, 2, 3;\n" \
1813   "dcffix 1, 2");
1814   #endif
1815 ]])], [
1816 ac_compiler_have_dfp=yes
1817 AC_MSG_RESULT([yes])
1818 ], [
1819 ac_compiler_have_dfp=no
1820 AC_MSG_RESULT([no])
1822 CFLAGS=$safe_CFLAGS
1823 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1824                           -a x$ac_compiler_have_dfp = xyes \
1825                           -a x$HWCAP_HAS_DFP = xyes )
1827 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1828 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1829 ]], [[
1830   _Decimal64 x = 0.0DD;
1831 ]])], [
1832 ac_compiler_have_dfp_type=yes
1833 AC_MSG_RESULT([yes])
1834 ], [
1835 ac_compiler_have_dfp_type=no
1836 AC_MSG_RESULT([no])
1838 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1839                                   -a x$HWCAP_HAS_DFP = xyes )
1842 # HTM (Hardware Transactional Memory)
1843 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1844 safe_CFLAGS=$CFLAGS
1845 CFLAGS="-mhtm -Werror"
1846 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1847 ]], [[
1848   return 0;
1849 ]])], [
1850 AC_MSG_RESULT([yes])
1851 ac_compiler_supports_htm=yes
1852 ], [
1853 AC_MSG_RESULT([no])
1854 ac_compiler_supports_htm=no
1856 CFLAGS=$safe_CFLAGS
1858 AC_MSG_CHECKING([if compiler can find the htm builtins])
1859 safe_CFLAGS=$CFLAGS
1860 CFLAGS="-mhtm -Werror"
1861  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1862  ]], [[
1863    if (__builtin_tbegin (0))
1864       __builtin_tend (0);
1865  ]])], [
1866  AC_MSG_RESULT([yes])
1867 ac_compiler_sees_htm_builtins=yes
1868  ], [
1869  AC_MSG_RESULT([no])
1870 ac_compiler_sees_htm_builtins=no
1871  ])
1872 CFLAGS=$safe_CFLAGS
1874 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1875                                -a x$ac_compiler_sees_htm_builtins = xyes \
1876                                -a x$HWCAP_HAS_HTM = xyes )
1878 # isa 3.0 checking. (actually 3.0 or newer)
1879 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1881 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1882 ]], [[
1883 __asm__ __volatile__ (".machine power9;\n" \
1884         "cnttzw   1,3; \n" );
1885 ]])], [
1886 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1887 # cpabort support
1888 safe_CFLAGS=$CFLAGS
1889 CFLAGS="-DHAS_ISA_3_00"
1890 ac_asm_have_isa_3_00=yes
1891 AC_MSG_RESULT([yes])
1892 ], [
1893 ac_asm_have_isa_3_00=no
1894 AC_MSG_RESULT([no])
1896 CFLAGS=$safe_CFLAGS
1898 # xscvhpdp checking
1899 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1901 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1902 ]], [[
1903 __asm__ __volatile__ (".machine power9;\n" \
1904         "xscvhpdp 1,2;\n" );
1905 ]])], [
1906 ac_asm_have_xscvhpdp=yes
1907 AC_MSG_RESULT([yes])
1908 ], [
1909 ac_asm_have_xscvhpdp=no
1910 AC_MSG_RESULT([no])
1913 # darn instruction checking
1914 AC_MSG_CHECKING([that assembler knows darn instruction ])
1916 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1917 ]], [[
1918   __asm__ __volatile__(".machine power9; darn 1,0 ");
1919 ]])], [
1920 ac_asm_have_darn_inst=yes
1921 AC_MSG_RESULT([yes])
1922 ], [
1923 ac_asm_have_darn_inst=no
1924 AC_MSG_RESULT([no])
1927 # isa 3.01 checking
1928 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1929 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1930 ]], [[
1931 __asm__ __volatile__ (".machine power10;\n" \
1932         "brh 1,2;\n ");
1933 ]])], [
1934 ac_asm_have_isa_3_1=yes
1935 AC_MSG_RESULT([yes])
1936 ], [
1937 ac_asm_have_isa_3_1=no
1938 AC_MSG_RESULT([no])
1942 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1943                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1945 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1946 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1948 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1949                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1951 # Check for pthread_create@GLIBC2.0
1952 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1954 safe_CFLAGS=$CFLAGS
1955 CFLAGS="-lpthread -Werror"
1956 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1957 extern int pthread_create_glibc_2_0(void*, const void*,
1958                                     void *(*)(void*), void*);
1959 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1960 ]], [[
1961 #ifdef __powerpc__
1963  * Apparently on PowerPC linking this program succeeds and generates an
1964  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1965  */
1966 #error This test does not work properly on PowerPC.
1967 #else
1968   pthread_create_glibc_2_0(0, 0, 0, 0);
1969 #endif
1970   return 0;
1971 ]])], [
1972 ac_have_pthread_create_glibc_2_0=yes
1973 AC_MSG_RESULT([yes])
1974 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1975           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1976 ], [
1977 ac_have_pthread_create_glibc_2_0=no
1978 AC_MSG_RESULT([no])
1980 CFLAGS=$safe_CFLAGS
1982 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1983                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1986 # Check for dlinfo RTLD_DI_TLS_MODID
1987 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1989 safe_LIBS="$LIBS"
1990 LIBS="-ldl"
1991 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1992 #ifndef _GNU_SOURCE
1993 #define _GNU_SOURCE
1994 #endif
1995 #include <link.h>
1996 #include <dlfcn.h>
1997 ]], [[
1998   size_t sizes[10000];
1999   size_t modid_offset;
2000   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
2001   return 0;
2002 ]])], [
2003 ac_have_dlinfo_rtld_di_tls_modid=yes
2004 AC_MSG_RESULT([yes])
2005 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
2006           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
2007 ], [
2008 ac_have_dlinfo_rtld_di_tls_modid=no
2009 AC_MSG_RESULT([no])
2011 LIBS=$safe_LIBS
2013 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
2014                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
2017 # Check for eventfd_t, eventfd() and eventfd_read()
2018 AC_MSG_CHECKING([for eventfd()])
2020 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2021 #include <sys/eventfd.h>
2022 ]], [[
2023   eventfd_t ev;
2024   int fd;
2026   fd = eventfd(5, 0);
2027   eventfd_read(fd, &ev);
2028   return 0;
2029 ]])], [
2030 AC_MSG_RESULT([yes])
2031 AC_DEFINE([HAVE_EVENTFD], 1,
2032           [Define to 1 if you have the `eventfd' function.])
2033 AC_DEFINE([HAVE_EVENTFD_READ], 1,
2034           [Define to 1 if you have the `eventfd_read' function.])
2035 ], [
2036 AC_MSG_RESULT([no])
2039 # Check whether compiler can process #include <thread> without errors
2040 # clang 3.3 cannot process <thread> from e.g.
2041 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
2043 AC_MSG_CHECKING([that C++ compiler can compile C++17 code])
2044 AC_LANG(C++)
2045 safe_CXXFLAGS=$CXXFLAGS
2046 CXXFLAGS=-std=c++17
2048 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2049 int x;
2050 ])],
2052 ac_have_cxx_17=yes
2053 AC_MSG_RESULT([yes])
2054 ], [
2055 ac_have_cxx_17=no
2056 AC_MSG_RESULT([no])
2058 CXXFLAGS=$safe_CXXFLAGS
2059 AC_LANG(C)
2061 AM_CONDITIONAL(HAVE_CXX17, test x$ac_have_cxx_17 = xyes)
2063 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
2064 AC_LANG(C++)
2065 safe_CXXFLAGS=$CXXFLAGS
2066 CXXFLAGS=-std=c++0x
2068 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2069 #include <thread> 
2070 ])],
2072 ac_cxx_can_include_thread_header=yes
2073 AC_MSG_RESULT([yes])
2074 ], [
2075 ac_cxx_can_include_thread_header=no
2076 AC_MSG_RESULT([no])
2078 CXXFLAGS=$safe_CXXFLAGS
2079 AC_LANG(C)
2081 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2083 # Check whether compiler can process #include <condition_variable> without errors
2085 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2086 AC_LANG(C++)
2087 safe_CXXFLAGS=$CXXFLAGS
2088 CXXFLAGS=-std=c++0x
2090 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2091 #include <condition_variable> 
2092 ])],
2094 ac_cxx_can_include_condition_variable_header=yes
2095 AC_MSG_RESULT([yes])
2096 ], [
2097 ac_cxx_can_include_condition_variable_header=no
2098 AC_MSG_RESULT([no])
2100 CXXFLAGS=$safe_CXXFLAGS
2101 AC_LANG(C)
2103 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2105 # check for std::shared_timed_mutex, this is a C++ 14 feature
2107 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2108 AC_LANG(C++)
2109 safe_CXXFLAGS=$CXXFLAGS
2110 CXXFLAGS="-std=c++1y -pthread"
2112 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2113 #include <shared_mutex>
2114 std::shared_timed_mutex test_mutex;
2115 ])],
2117 ac_cxx_can_use_shared_timed_mutex=yes
2118 AC_MSG_RESULT([yes])
2119 ], [
2120 ac_cxx_can_use_shared_timed_mutex=no
2121 AC_MSG_RESULT([no])
2123 CXXFLAGS=$safe_CXXFLAGS
2124 AC_LANG(C)
2126 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2128 # check for std::shared_mutex, this is a C++ 11 feature
2130 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2131 AC_LANG(C++)
2132 safe_CXXFLAGS=$CXXFLAGS
2133 CXXFLAGS="-std=c++0x -pthread"
2135 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2136 #include <mutex>
2137 std::timed_mutex test_mutex;
2138 ])],
2140 ac_cxx_can_use_timed_mutex=yes
2141 AC_MSG_RESULT([yes])
2142 ], [
2143 ac_cxx_can_use_timed_mutex=no
2144 AC_MSG_RESULT([no])
2146 CXXFLAGS=$safe_CXXFLAGS
2147 AC_LANG(C)
2149 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2151 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2152 # of the user_regs_struct from sys/user.h. They are structurally the same
2153 # but we get either one or the other.
2155 AC_CHECK_TYPE([struct user_regs_struct],
2156               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2157               [[#include <sys/ptrace.h>]
2158                [#include <sys/time.h>]
2159                [#include <sys/user.h>]])
2160 if test "$sys_user_has_user_regs" = "yes"; then
2161   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2162             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2165 AC_MSG_CHECKING([for __NR_membarrier])
2166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2167 #include <linux/unistd.h>
2168 ]], [[
2169 return __NR_membarrier
2170 ]])], [
2171 ac_have_nr_membarrier=yes
2172 AC_MSG_RESULT([yes])
2173 ], [
2174 ac_have_nr_membarrier=no
2175 AC_MSG_RESULT([no])
2178 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2180 #----------------------------------------------------------------------------
2181 # Checking for supported compiler flags.
2182 #----------------------------------------------------------------------------
2184 case "${host_cpu}" in
2185     mips*)
2186         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2187         if test -z "$ARCH"; then
2188           # does this compiler support -march=mips32 (mips32 default) ?
2189           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2191           safe_CFLAGS=$CFLAGS
2192           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2194           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2195             return 0;
2196           ]])], [
2197           FLAG_M32="-mips32 -mabi=32"
2198           AC_MSG_RESULT([yes])
2199           ], [
2200           FLAG_M32=""
2201           AC_MSG_RESULT([no])
2202           ])
2203           CFLAGS=$safe_CFLAGS
2205           AC_SUBST(FLAG_M32)
2208           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2209           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2211           safe_CFLAGS=$CFLAGS
2212           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2214           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2215             return 0;
2216           ]])], [
2217           FLAG_M64="-march=mips64r2 -mabi=64"
2218           AC_MSG_RESULT([yes])
2219           ], [
2220           FLAG_M64=""
2221           AC_MSG_RESULT([no])
2222           ])
2223           CFLAGS=$safe_CFLAGS
2225           AC_SUBST(FLAG_M64)
2226         fi
2227         ;;
2228     nanomips*)
2229         ;;
2230     *)
2231         # does this compiler support -m32 ?
2232         AC_MSG_CHECKING([if gcc accepts -m32])
2234         safe_CFLAGS=$CFLAGS
2235         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2237         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2238           return 0;
2239         ]])], [
2240         FLAG_M32="${FLAG_32ON64} -m32"
2241         AC_MSG_RESULT([yes])
2242         ], [
2243         FLAG_M32=""
2244         AC_MSG_RESULT([no])
2245         ])
2246         CFLAGS=$safe_CFLAGS
2248         AC_SUBST(FLAG_M32)
2251         # does this compiler support -m64 ?
2252         AC_MSG_CHECKING([if gcc accepts -m64])
2254         safe_CFLAGS=$CFLAGS
2255         CFLAGS="-m64 -Werror"
2257         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2258           return 0;
2259         ]])], [
2260         FLAG_M64="-m64"
2261         AC_MSG_RESULT([yes])
2262         ], [
2263         FLAG_M64=""
2264         AC_MSG_RESULT([no])
2265         ])
2266         CFLAGS=$safe_CFLAGS
2268         AC_SUBST(FLAG_M64)
2269         ;;
2270 esac
2273 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2274 if test -z "$ARCH"; then
2275   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2276   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2278   safe_CFLAGS=$CFLAGS
2279   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2281   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2282     return 0;
2283   ]])], [
2284   FLAG_OCTEON="-march=octeon"
2285   AC_MSG_RESULT([yes])
2286   ], [
2287   FLAG_OCTEON=""
2288   AC_MSG_RESULT([no])
2289   ])
2290   CFLAGS=$safe_CFLAGS
2292   AC_SUBST(FLAG_OCTEON)
2295   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2296   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2298   safe_CFLAGS=$CFLAGS
2299   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2301   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2302     return 0;
2303   ]])], [
2304   FLAG_OCTEON2="-march=octeon2"
2305   AC_MSG_RESULT([yes])
2306   ], [
2307   FLAG_OCTEON2=""
2308   AC_MSG_RESULT([no])
2309   ])
2310   CFLAGS=$safe_CFLAGS
2312   AC_SUBST(FLAG_OCTEON2)
2316 # does this compiler support -mmsa (MIPS MSA ASE) ?
2317 AC_MSG_CHECKING([if gcc accepts -mmsa])
2319 safe_CFLAGS=$CFLAGS
2320 CFLAGS="$CFLAGS -mmsa -Werror"
2322 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2323     return 0;
2324 ]])], [
2325 FLAG_MSA="-mmsa"
2326 AC_MSG_RESULT([yes])
2327 ], [
2328 FLAG_MSA=""
2329 AC_MSG_RESULT([no])
2331 CFLAGS=$safe_CFLAGS
2333 AC_SUBST(FLAG_MSA)
2335 # Are we compiling for the MIPS64 n32 ABI?
2336 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2337 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2338 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2339 #error NO
2340 #endif
2341 ]])], [
2342 VGCONF_ABI=N32
2343 FLAG_M64="-march=mips64r2 -mabi=n32"
2344 AC_MSG_RESULT([yes])
2345 ], [
2346 AC_MSG_RESULT([no])
2349 # Are we compiling for the MIPS64 n64 ABI?
2350 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2351 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2352 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2353 #error NO
2354 #endif
2355 ]])], [
2356 VGCONF_ABI=64
2357 AC_MSG_RESULT([yes])
2358 ], [
2359 AC_MSG_RESULT([no])
2362 # We enter the code block below in the following case:
2363 # Target architecture is set to mips64, the desired abi
2364 # was not specified and the compiler's default abi setting
2365 # is neither n32 nor n64.
2366 # Probe for and set the abi to either n64 or n32, in that order,
2367 # which is required for a mips64 build of valgrind.
2368 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2369   safe_CFLAGS=$CFLAGS
2370   CFLAGS="$CFLAGS -mabi=64 -Werror"
2371   AC_MSG_CHECKING([if gcc is n64 capable])
2372   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2373       return 0;
2374   ]])], [
2375   VGCONF_ABI=64
2376   AC_MSG_RESULT([yes])
2377   ], [
2378   AC_MSG_RESULT([no])
2379   ])
2380   CFLAGS=$safe_CFLAGS
2382   if test "x$VGCONF_ABI" = "x"; then
2383     safe_CFLAGS=$CFLAGS
2384     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2385     AC_MSG_CHECKING([if gcc is n32 capable])
2386     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2387         return 0;
2388     ]])], [
2389     VGCONF_ABI=N32
2390     FLAG_M64="-march=mips64r2 -mabi=n32"
2391     AC_MSG_RESULT([yes])
2392     ], [
2393     AC_MSG_RESULT([no])
2394     ])
2395     CFLAGS=$safe_CFLAGS
2396   fi
2399 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2400                [test x$VGCONF_ABI != x])
2401 AC_SUBST(VGCONF_ABI)
2404 # does this compiler support -mmmx ?
2405 AC_MSG_CHECKING([if gcc accepts -mmmx])
2407 safe_CFLAGS=$CFLAGS
2408 CFLAGS="-mmmx -Werror"
2410 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2411   return 0;
2412 ]])], [
2413 FLAG_MMMX="-mmmx"
2414 AC_MSG_RESULT([yes])
2415 ], [
2416 FLAG_MMMX=""
2417 AC_MSG_RESULT([no])
2419 CFLAGS=$safe_CFLAGS
2421 AC_SUBST(FLAG_MMMX)
2424 # does this compiler support -msse ?
2425 AC_MSG_CHECKING([if gcc accepts -msse])
2427 safe_CFLAGS=$CFLAGS
2428 CFLAGS="-msse -Werror"
2430 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2431   return 0;
2432 ]])], [
2433 FLAG_MSSE="-msse"
2434 AC_MSG_RESULT([yes])
2435 ], [
2436 FLAG_MSSE=""
2437 AC_MSG_RESULT([no])
2439 CFLAGS=$safe_CFLAGS
2441 AC_SUBST(FLAG_MSSE)
2444 # does this compiler support -mpreferred-stack-boundary=2 when
2445 # generating code for a 32-bit target?  Note that we only care about
2446 # this when generating code for (32-bit) x86, so if the compiler
2447 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2448 # the Memcheck and other helper functions, that is a bit slower than
2449 # it could be, on x86; and no difference at all on any other platform.
2450 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2452 safe_CFLAGS=$CFLAGS
2453 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2455 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2456   return 0;
2457 ]])], [
2458 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2459 AC_MSG_RESULT([yes])
2460 ], [
2461 PREFERRED_STACK_BOUNDARY_2=""
2462 AC_MSG_RESULT([no])
2464 CFLAGS=$safe_CFLAGS
2466 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2469 # does this compiler support -mlong-double-128 ?
2470 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2471 safe_CFLAGS=$CFLAGS
2472 CFLAGS="-mlong-double-128 -Werror"
2473 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2474   return 0;
2475 ]])], [
2476 ac_compiler_supports_mlong_double_128=yes
2477 AC_MSG_RESULT([yes])
2478 ], [
2479 ac_compiler_supports_mlong_double_128=no
2480 AC_MSG_RESULT([no])
2482 CFLAGS=$safe_CFLAGS
2483 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2484 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2485 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2487 # does this toolchain support lto ?
2488 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2489 # are not defined
2490 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2491 # a lot slower, and so not appropriate for Valgrind developments.
2492 # --enable-lto=yes should be used by distro packagers.
2493 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2494    [AC_ARG_ENABLE(lto,
2495       [  --enable-lto          enables building with link time optimisation],
2496       [vg_cv_lto=$enableval],
2497       [vg_cv_lto=no])])
2499 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2500 AC_MSG_CHECKING([if toolchain accepts lto])
2501 safe_CFLAGS=$CFLAGS
2502 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2503 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2504 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2505 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2507 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2508   extern void somefun(void);
2509   somefun();
2510   return 0;
2511 ]])], [
2512 LTO_CFLAGS=$TEST_LTO_CFLAGS
2513 AC_MSG_RESULT([yes])
2514 ], [
2515 LTO_CFLAGS=""
2516 AC_MSG_RESULT([no])
2518 CFLAGS=$safe_CFLAGS
2521 AC_SUBST(LTO_CFLAGS)
2523 # if we could not compile with lto args, or lto was disabled,
2524 # then set LTO_AR/LTO_RANLIB to the non lto values
2525 # define in config.h ENABLE_LTO (not needed by the code currently, but
2526 # this guarantees we recompile everything if we re-configure and rebuild
2527 # in a build dir previously build with another value of --enable-lto
2528 if test "x${LTO_CFLAGS}" = "x"; then
2529    LTO_AR=${AR}
2530    LTO_RANLIB=${RANLIB}
2531    vg_cv_lto=no
2532 else
2533    vg_cv_lto=yes
2534    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2537 # Convenience function to check whether GCC supports a particular
2538 # warning option. Takes two arguments,
2539 # first the warning flag name to check (without -W), then the
2540 # substitution name to set with -Wno-warning-flag if the flag exists,
2541 # or the empty string if the compiler doesn't accept the flag. Note
2542 # that checking is done against the warning flag itself, but the
2543 # substitution is then done to cancel the warning flag.
2544 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2545   AC_MSG_CHECKING([if gcc accepts -W$1])
2546   safe_CFLAGS=$CFLAGS
2547   CFLAGS="-W$1 -Werror"
2548   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2549   AC_SUBST([$2], [-Wno-$1])
2550   AC_MSG_RESULT([yes])], [
2551   AC_SUBST([$2], [])
2552   AC_MSG_RESULT([no])])
2553   CFLAGS=$safe_CFLAGS
2556 # A variation of the above for arguments that
2557 # take a value
2558 AC_DEFUN([AC_GCC_WARNING_SUBST_NO_VAL],[
2559   AC_MSG_CHECKING([if gcc accepts -W$1=$2])
2560   safe_CFLAGS=$CFLAGS
2561   CFLAGS="-W$1=$2 -Werror"
2562   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2563   AC_SUBST([$3], [-Wno-$1])
2564   AC_MSG_RESULT([yes])], [
2565   AC_SUBST([$3], [])
2566   AC_MSG_RESULT([no])])
2567   CFLAGS=$safe_CFLAGS
2570 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2571 # -W$1  (instead of -Wno-$1).
2572 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2573   AC_MSG_CHECKING([if gcc accepts -W$1])
2574   safe_CFLAGS=$CFLAGS
2575   CFLAGS="-W$1 -Werror"
2576   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2577   AC_SUBST([$2], [-W$1])
2578   AC_MSG_RESULT([yes])], [
2579   AC_SUBST([$2], [])
2580   AC_MSG_RESULT([no])])
2581   CFLAGS=$safe_CFLAGS
2584 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2585 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2586 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2587 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2588 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2589 AC_GCC_WARNING_SUBST_NO([maybe-uninitialized], [FLAG_W_NO_MAYBE_UNINITIALIZED])
2590 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2591 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2592 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2593 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2594 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2595 AC_GCC_WARNING_SUBST_NO([unused-variable], [FLAG_W_NO_UNUSED_VARIABLE])
2596 AC_GCC_WARNING_SUBST_NO([unused-but-set-variable], [FLAG_W_NO_UNUSED_BUT_SET_VARIABLE])
2597 AC_GCC_WARNING_SUBST_NO([non-power-of-two-alignment], [FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT])
2598 AC_GCC_WARNING_SUBST_NO([sign-compare], [FLAG_W_NO_SIGN_COMPARE])
2599 AC_GCC_WARNING_SUBST_NO([stringop-overflow], [FLAG_W_NO_STRINGOP_OVERFLOW])
2600 AC_GCC_WARNING_SUBST_NO([stringop-overread], [FLAG_W_NO_STRINGOP_OVERREAD])
2601 AC_GCC_WARNING_SUBST_NO([stringop-truncation], [FLAG_W_NO_STRINGOP_TRUNCATION])
2602 AC_GCC_WARNING_SUBST_NO([format-overflow], [FLAG_W_NO_FORMAT_OVERFLOW])
2603 AC_GCC_WARNING_SUBST_NO([use-after-free], [FLAG_W_NO_USE_AFTER_FREE])
2604 AC_GCC_WARNING_SUBST_NO([free-nonheap-object], [FLAG_W_NO_FREE_NONHEAP_OBJECT])
2605 AC_GCC_WARNING_SUBST_NO([fortify-source], [FLAG_W_NO_FORTIFY_SOURCE])
2606 AC_GCC_WARNING_SUBST_NO([builtin-memcpy-chk-size], [FLAG_W_NO_BUILTIN_MEMCPY_CHK_SIZE])
2607 AC_GCC_WARNING_SUBST_NO([incompatible-pointer-types-discards-qualifiers], [FLAG_W_NO_INCOMPATIBLE_POINTER_TYPES_DISCARDS_QUALIFIERS])
2608 AC_GCC_WARNING_SUBST_NO([suspicious-bzero], [FLAG_W_NO_SUSPICIOUS_BZERO])
2610 AC_GCC_WARNING_SUBST_NO_VAL([alloc-size-larger-than], [1677216], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN])
2612 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2613 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2614 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2615 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2616 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2617 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2618 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2619 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2620 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2621 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2622 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2624 # Does this compiler support -Wformat-security ?
2625 # Special handling is needed, because certain GCC versions require -Wformat
2626 # being present if -Wformat-security is given. Otherwise a warning is issued.
2627 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2628 # And with that the warning will be turned into an error with the result
2629 # that -Wformat-security is believed to be unsupported when in fact it is.
2630 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2631 safe_CFLAGS=$CFLAGS
2632 CFLAGS="-Wformat -Wformat-security -Werror"
2633 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2634 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2635 AC_MSG_RESULT([yes])], [
2636 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2637 AC_MSG_RESULT([no])])
2638 CFLAGS=$safe_CFLAGS
2640 # does this compiler support -Wextra or the older -W ?
2642 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2644 safe_CFLAGS=$CFLAGS
2645 CFLAGS="-Wextra -Werror"
2647 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2648   return 0;
2649 ]])], [
2650 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2651 AC_MSG_RESULT([-Wextra])
2652 ], [
2653   CFLAGS="-W -Werror"
2654   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2655     return 0;
2656   ]])], [
2657   AC_SUBST([FLAG_W_EXTRA], [-W])
2658   AC_MSG_RESULT([-W])
2659   ], [
2660   AC_SUBST([FLAG_W_EXTRA], [])
2661   AC_MSG_RESULT([not supported])
2662   ])
2664 CFLAGS=$safe_CFLAGS
2666 # On ARM we do not want to pass -Wcast-align as that produces loads
2667 # of warnings. GCC is just being conservative. See here:
2668 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2669 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2670   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2671 else
2672   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2675 # does this compiler support -faligned-new ?
2676 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2678 safe_CXXFLAGS=$CXXFLAGS
2679 CXXFLAGS="-faligned-new -Werror"
2681 AC_LANG(C++)
2682 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2683   return 0;
2684 ]])], [
2685 FLAG_FALIGNED_NEW="-faligned-new"
2686 AC_MSG_RESULT([yes])
2687 ], [
2688 FLAG_FALIGNED_NEW=""
2689 AC_MSG_RESULT([no])
2691 CXXFLAGS=$safe_CXXFLAGS
2692 AC_LANG(C)
2694 AC_SUBST(FLAG_FALIGNED_NEW)
2696 # does this compiler support -fsized-deallocation ?
2697 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2699 safe_CXXFLAGS=$CXXFLAGS
2700 CXXFLAGS="-fsized-deallocation -Werror"
2702 AC_LANG(C++)
2703 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2704   return 0;
2705 ]])], [
2706 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2707 ac_have_sized_deallocation=yes
2708 AC_MSG_RESULT([yes])
2709 ], [
2710 FLAG_FSIZED_DEALLOCATION=""
2711 ac_have_sized_deallocation=no
2712 AC_MSG_RESULT([no])
2714 CXXFLAGS=$safe_CXXFLAGS
2715 AC_LANG(C)
2717 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2718 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2720 # does this compiler support C++17 aligned new/delete?
2721 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2723 safe_CXXFLAGS=$CXXFLAGS
2724 CXXFLAGS="-std=c++17"
2726 AC_LANG(C++)
2727 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2728 #include <cstdlib>
2729 #include <new>
2730 ]], [[
2731   operator delete(nullptr, std::align_val_t(64U));
2732 ]])], [
2733 ac_have_aligned_cxx_alloc=yes
2734 AC_MSG_RESULT([yes])
2735 ], [
2736 ac_have_aligned_cxx_alloc=no
2737 AC_MSG_RESULT([no])
2739 CXXFLAGS=$safe_CXXFLAGS
2740 AC_LANG(C)
2742 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2744 # does this compiler support -fno-stack-protector ?
2745 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2747 safe_CFLAGS=$CFLAGS
2748 CFLAGS="-fno-stack-protector -Werror"
2750 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2751   return 0;
2752 ]])], [
2753 no_stack_protector=yes
2754 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2755 AC_MSG_RESULT([yes])
2756 ], [
2757 no_stack_protector=no
2758 FLAG_FNO_STACK_PROTECTOR=""
2759 AC_MSG_RESULT([no])
2761 CFLAGS=$safe_CFLAGS
2763 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2765 # does this compiler support -finline-functions ?
2766 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2768 safe_CFLAGS=$CFLAGS
2769 CFLAGS="-finline-functions -Werror"
2771 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2772   return 0;
2773 ]])], [
2774 inline_functions=yes
2775 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2776 AC_MSG_RESULT([yes])
2777 ], [
2778 inline_functions=no
2779 FLAG_FINLINE_FUNCTIONS=""
2780 AC_MSG_RESULT([no])
2782 CFLAGS=$safe_CFLAGS
2784 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2786 # Does GCC support disabling Identical Code Folding?
2787 # We want to disabled Identical Code Folding for the
2788 # tools preload shared objects to get better backraces.
2789 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2790 # "The optimization reduces code size and may disturb
2791 #  unwind stacks by replacing a function by equivalent
2792 #  one with a different name."
2793 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2795 safe_CFLAGS=$CFLAGS
2796 CFLAGS="-fno-ipa-icf -Werror"
2798 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2799   return 0;
2800 ]])], [
2801 no_ipa_icf=yes
2802 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2803 AC_MSG_RESULT([yes])
2804 ], [
2805 no_ipa_icf=no
2806 FLAG_FNO_IPA_ICF=""
2807 AC_MSG_RESULT([no])
2809 CFLAGS=$safe_CFLAGS
2811 AC_SUBST(FLAG_FNO_IPA_ICF)
2814 # Does this compiler support -fsanitize=undefined. This is true for
2815 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2816 # also checks for alignment violations on memory accesses which the valgrind
2817 # code base is sprinkled (if not littered) with. As those alignment issues
2818 # don't pose a problem we want to suppress warnings about them.
2819 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2820 # GCCs do not support that.
2822 # Only checked for if --enable-ubsan was given.
2823 if test "x${vg_cv_ubsan}" = "xyes"; then
2824 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2825 safe_CFLAGS=$CFLAGS
2826 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2827 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2828   return 0;
2829 ]])], [
2830 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2831 LIB_UBSAN="-static-libubsan"
2832 AC_MSG_RESULT([yes])
2833 ], [
2834 CFLAGS="-fsanitize=undefined -Werror"
2835 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2836   return 0;
2837 ]])], [
2838 FLAG_FSANITIZE="-fsanitize=undefined"
2839 LIB_UBSAN="-static-libubsan"
2840 AC_MSG_RESULT([yes])
2841 ], [
2842 FLAG_FSANITIZE=""
2843 LIB_UBSAN=""
2844 AC_MSG_RESULT([no])
2847 CFLAGS=$safe_CFLAGS
2848 AC_SUBST(FLAG_FSANITIZE)
2849 AC_SUBST(LIB_UBSAN)
2851 # does this compiler support --param inline-unit-growth=... ?
2853 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2855 safe_CFLAGS=$CFLAGS
2856 CFLAGS="--param inline-unit-growth=900 -Werror"
2858 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2859   return 0;
2860 ]])], [
2861 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2862          ["--param inline-unit-growth=900"])
2863 AC_MSG_RESULT([yes])
2864 ], [
2865 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2866 AC_MSG_RESULT([no])
2868 CFLAGS=$safe_CFLAGS
2871 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2873 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2875 safe_CFLAGS=$CFLAGS
2876 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2878 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2879   return 0;
2880 ]])], [
2881 ac_have_dwarf4=yes
2882 AC_MSG_RESULT([yes])
2883 ], [
2884 ac_have_dwarf4=no
2885 AC_MSG_RESULT([no])
2887 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2888 CFLAGS=$safe_CFLAGS
2891 # does this compiler support -g -gz=zlib ?
2893 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2895 safe_CFLAGS=$CFLAGS
2896 CFLAGS="-g -gz=zlib"
2898 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2899   return 0;
2900 ]])], [
2901 ac_have_gz_zlib=yes
2902 AC_MSG_RESULT([yes])
2903 ], [
2904 ac_have_gz_zlib=no
2905 AC_MSG_RESULT([no])
2907 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2908 CFLAGS=$safe_CFLAGS
2911 # does this compiler support -g -gz=zlib-gnu ?
2913 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2915 safe_CFLAGS=$CFLAGS
2916 CFLAGS="-g -gz=zlib-gnu"
2918 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2919   return 0;
2920 ]])], [
2921 ac_have_gz_zlib_gnu=yes
2922 AC_MSG_RESULT([yes])
2923 ], [
2924 ac_have_gz_zlib_gnu=no
2925 AC_MSG_RESULT([no])
2927 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2928 CFLAGS=$safe_CFLAGS
2931 # does this compiler support nested functions ?
2933 AC_MSG_CHECKING([if gcc accepts nested functions])
2935 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2936   int foo() { return 1; }
2937   return foo();
2938 ]])], [
2939 ac_have_nested_functions=yes
2940 AC_MSG_RESULT([yes])
2941 ], [
2942 ac_have_nested_functions=no
2943 AC_MSG_RESULT([no])
2945 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2948 # does this compiler support the 'p' constraint in ASM statements ?
2950 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2952 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2953    char *p;
2954    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2955 ]])], [
2956 ac_have_asm_constraint_p=yes
2957 AC_MSG_RESULT([yes])
2958 ], [
2959 ac_have_asm_constraint_p=no
2960 AC_MSG_RESULT([no])
2962 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2965 # Does this compiler and linker support -pie?
2966 # Some compilers actually do not support -pie and report its usage
2967 # as an error. We need to check if it is safe to use it first.
2969 AC_MSG_CHECKING([if gcc accepts -pie])
2971 safe_CFLAGS=$CFLAGS
2972 CFLAGS="-pie"
2974 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2975   return 0;
2976 ]])], [
2977 AC_SUBST([FLAG_PIE], ["-pie"])
2978 AC_MSG_RESULT([yes])
2979 ], [
2980 AC_SUBST([FLAG_PIE], [""])
2981 AC_MSG_RESULT([no])
2983 CFLAGS=$safe_CFLAGS
2985 AC_MSG_CHECKING([if gcc accepts -ansi])
2987 safe_CFLAGS=$CFLAGS
2988 CFLAGS="-ansi"
2990 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2991    return 0;
2992 ]])], [
2993 ac_have_ansi=yes
2994 AC_MSG_RESULT([yes])
2995 ], [
2996 ac_have_ansi=no
2997 AC_MSG_RESULT([no])
2999 AM_CONDITIONAL([HAVE_ANSI], [test x$ac_have_ansi = xyes])
3001 CFLAGS=$safe_CFLAGS
3004 # Does this compiler support -no-pie?
3005 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
3006 # default. However this gets in the way with some tests, we use -no-pie
3007 # for these.
3009 AC_MSG_CHECKING([if gcc accepts -no-pie])
3011 safe_CFLAGS=$CFLAGS
3012 CFLAGS="-no-pie -Werror"
3014 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
3015   return 0;
3016 ]])], [
3017 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
3018 AC_MSG_RESULT([yes])
3019 ], [
3020 AC_SUBST([FLAG_NO_PIE], [""])
3021 AC_MSG_RESULT([no])
3023 CFLAGS=$safe_CFLAGS
3026 # We want to use use the -Ttext-segment option to the linker.
3027 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
3028 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
3029 # semantics are NOT what we want (GNU gold -Ttext is fine).
3031 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
3032 # will reside. -Ttext aligns just the .text section start (but not any
3033 # other section).
3035 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
3036 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
3037 # The --image-base option (since version 6.0?) provides the semantics needed.
3038 # -Ttext-segment generates an error, but -Ttext now more closely
3039 # follows the GNU (bfd) ld's -Ttext.
3041 # So test first for --image-base support, and if that fails then
3042 # for -Ttext-segment which is supported by all bfd ld versions
3043 # and use that if it exists. If it doesn't exist it must be an older
3044 # version of gold and we can fall back to using -Ttext which has the
3045 # right semantics.
3047 safe_CFLAGS=$CFLAGS
3048 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
3050 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
3052 AC_LINK_IFELSE(
3053 [AC_LANG_SOURCE([int _start () { return 0; }])],
3055   linker_using_t_text="no"
3056   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
3057   AC_MSG_RESULT([yes])
3058 ], [
3059   AC_MSG_RESULT([no])
3061   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
3063   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
3065   AC_LINK_IFELSE(
3066   [AC_LANG_SOURCE([int _start () { return 0; }])],
3067   [
3068     linker_using_t_text="no"
3069     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
3070     AC_MSG_RESULT([yes])
3071   ], [
3072     linker_using_t_text="yes"
3073     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
3074     AC_MSG_RESULT([no])
3075   ])
3078 CFLAGS=$safe_CFLAGS
3080 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
3081 # have to strip any build-id ELF NOTEs from the statically linked tools.
3082 # Otherwise the build-id NOTE might end up at the default load address.
3083 # (Pedantically if the linker is gold then -Ttext is fine, but newer
3084 # gold versions also support -Ttext-segment. So just assume that unless
3085 # we can use -Ttext-segment we need to strip the build-id NOTEs.
3086 if test "x${linker_using_t_text}" = "xyes"; then
3087 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
3088 # does the linker support -Wl,--build-id=none ?  Note, it's
3089 # important that we test indirectly via whichever C compiler
3090 # is selected, rather than testing /usr/bin/ld or whatever
3091 # directly.
3092 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
3093 safe_CFLAGS=$CFLAGS
3094 CFLAGS="-Wl,--build-id=none -Werror"
3096 AC_LINK_IFELSE(
3097 [AC_LANG_PROGRAM([ ], [return 0;])],
3099   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
3100   AC_MSG_RESULT([yes])
3101 ], [
3102   AC_SUBST([FLAG_NO_BUILD_ID], [""])
3103   AC_MSG_RESULT([no])
3105 else
3106 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
3107 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3109 CFLAGS=$safe_CFLAGS
3111 # On s390x, if the linker supports -Wl,--s390-pgste, then we build the
3112 # tools with that flag.  This enables running programs that need it, such
3113 # as qemu-kvm.
3114 if test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX; then
3115 AC_MSG_CHECKING([if the linker accepts -Wl,--s390-pgste])
3116 safe_CFLAGS=$CFLAGS
3117 CFLAGS="-Wl,--s390-pgste"
3119 AC_LINK_IFELSE(
3120 [AC_LANG_PROGRAM([ ], [return 0;])],
3122   AC_SUBST([FLAG_S390_PGSTE], ["-Wl,--s390-pgste"])
3123   AC_MSG_RESULT([yes])
3124 ], [
3125   AC_SUBST([FLAG_S390_PGSTE], [""])
3126   AC_MSG_RESULT([no])
3128 CFLAGS=$safe_CFLAGS
3131 # does the ppc assembler support "mtocrf" et al?
3132 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
3134 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3135 __asm__ __volatile__("mtocrf 4,0");
3136 __asm__ __volatile__("mfocrf 0,4");
3137 ]])], [
3138 ac_have_as_ppc_mftocrf=yes
3139 AC_MSG_RESULT([yes])
3140 ], [
3141 ac_have_as_ppc_mftocrf=no
3142 AC_MSG_RESULT([no])
3144 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3145   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3149 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3150 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3152 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3153   do { typedef struct {
3154       double hi;
3155       double lo;
3156      } dbl_pair_t;
3157      dbl_pair_t dbl_pair[3];
3158      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3159    } while (0)
3160 ]])], [
3161 ac_have_as_ppc_fpPO=yes
3162 AC_MSG_RESULT([yes])
3163 ], [
3164 ac_have_as_ppc_fpPO=no
3165 AC_MSG_RESULT([no])
3167 if test x$ac_have_as_ppc_fpPO = xyes ; then
3168   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3172 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3173 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3175 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3176 void* p;
3177 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3178 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3179 ]])], [
3180 ac_have_as_amd64_fxsave64=yes
3181 AC_MSG_RESULT([yes])
3182 ], [
3183 ac_have_as_amd64_fxsave64=no
3184 AC_MSG_RESULT([no])
3186 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3187   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3190 # does the x86/amd64 assembler understand SSE3 instructions?
3191 # Note, this doesn't generate a C-level symbol.  It generates a
3192 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3193 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3195 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3196   do { long long int x; 
3197      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
3198   while (0)
3199 ]])], [
3200 ac_have_as_sse3=yes
3201 AC_MSG_RESULT([yes])
3202 ], [
3203 ac_have_as_sse3=no
3204 AC_MSG_RESULT([no])
3207 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3210 # Ditto for SSSE3 instructions (note extra S)
3211 # Note, this doesn't generate a C-level symbol.  It generates a
3212 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3213 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3215 save_CFLAGS="$CFLAGS"
3216 CFLAGS="$CFLAGS -msse -Werror"
3217 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3218   do { long long int x; 
3219    __asm__ __volatile__(
3220       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3221   while (0)
3222 ]])], [
3223 ac_have_as_ssse3=yes
3224 AC_MSG_RESULT([yes])
3225 ], [
3226 ac_have_as_ssse3=no
3227 AC_MSG_RESULT([no])
3229 CFLAGS="$save_CFLAGS"
3231 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3234 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3235 # Note, this doesn't generate a C-level symbol.  It generates a
3236 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3237 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3238 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3239   do {
3240    __asm__ __volatile__(
3241       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3242   while (0)
3243 ]])], [
3244 ac_have_as_pclmulqdq=yes
3245 AC_MSG_RESULT([yes])
3246 ], [
3247 ac_have_as_pclmulqdq=no
3248 AC_MSG_RESULT([no])
3251 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3254 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3255 # Note, this doesn't generate a C-level symbol.  It generates a
3256 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3257 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3258 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3259   do {
3260       /*
3261        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3262        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3263        * xmm2 should be used.
3264        */
3265    __asm__ __volatile__(
3266       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3267   } while (0)
3268 ]])], [
3269 ac_have_as_vpclmulqdq=yes
3270 AC_MSG_RESULT([yes])
3271 ], [
3272 ac_have_as_vpclmulqdq=no
3273 AC_MSG_RESULT([no])
3276 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3279 # does the x86/amd64 assembler understand FMA4 instructions?
3280 # Note, this doesn't generate a C-level symbol.  It generates a
3281 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3282 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3283 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3284   do {
3285    __asm__ __volatile__(
3286       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3287   } while (0)
3288 ]])], [
3289 ac_have_as_vfmaddpd=yes
3290 AC_MSG_RESULT([yes])
3291 ], [
3292 ac_have_as_vfmaddpd=no
3293 AC_MSG_RESULT([no])
3296 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3299 # does the x86/amd64 assembler understand the LZCNT instruction?
3300 # Note, this doesn't generate a C-level symbol.  It generates a
3301 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3302 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3304 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3305   do {           
3306       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3307   } while (0)
3308 ]])], [
3309   ac_have_as_lzcnt=yes
3310   AC_MSG_RESULT([yes])
3311 ], [
3312   ac_have_as_lzcnt=no
3313   AC_MSG_RESULT([no])
3316 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3319 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3320 # Note, this doesn't generate a C-level symbol.  It generates a
3321 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3322 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3325   do {           
3326       __asm__ __volatile__("1:  loopnel 1b\n");
3327   } while (0)
3328 ]])], [
3329   ac_have_as_loopnel=yes
3330   AC_MSG_RESULT([yes])
3331 ], [
3332   ac_have_as_loopnel=no
3333   AC_MSG_RESULT([no])
3336 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3339 # does the x86/amd64 assembler understand ADDR32 ?
3340 # Note, this doesn't generate a C-level symbol.  It generates a
3341 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3342 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3344 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3345   do {           
3346       asm volatile ("addr32 rep movsb");
3347   } while (0)
3348 ]])], [
3349   ac_have_as_addr32=yes
3350   AC_MSG_RESULT([yes])
3351 ], [
3352   ac_have_as_addr32=no
3353   AC_MSG_RESULT([no])
3356 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3359 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3360 # Note, this doesn't generate a C-level symbol.  It generates a
3361 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3362 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3365   do { long long int x; 
3366    __asm__ __volatile__(
3367       "crc32q %%r15,%%r15" : : : "r15" );
3368    __asm__ __volatile__(
3369       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3370    __asm__ __volatile__(
3371       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3372   while (0)
3373 ]])], [
3374 ac_have_as_sse42=yes
3375 AC_MSG_RESULT([yes])
3376 ], [
3377 ac_have_as_sse42=no
3378 AC_MSG_RESULT([no])
3381 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3384 # does the x86/amd64 assembler understand AVX instructions?
3385 # Note, this doesn't generate a C-level symbol.  It generates a
3386 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3387 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3389 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3390   do { long long int x; 
3391    __asm__ __volatile__(
3392       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3393    __asm__ __volatile__(
3394       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3395   while (0)
3396 ]])], [
3397 ac_have_as_avx=yes
3398 AC_MSG_RESULT([yes])
3399 ], [
3400 ac_have_as_avx=no
3401 AC_MSG_RESULT([no])
3404 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3407 # does the x86/amd64 assembler understand AVX2 instructions?
3408 # Note, this doesn't generate a C-level symbol.  It generates a
3409 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3410 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3412 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3413   do { long long int x; 
3414    __asm__ __volatile__(
3415       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3416    __asm__ __volatile__(
3417       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3418   while (0)
3419 ]])], [
3420 ac_have_as_avx2=yes
3421 AC_MSG_RESULT([yes])
3422 ], [
3423 ac_have_as_avx2=no
3424 AC_MSG_RESULT([no])
3427 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3430 # does the x86/amd64 assembler understand TSX instructions and
3431 # the XACQUIRE/XRELEASE prefixes?
3432 # Note, this doesn't generate a C-level symbol.  It generates a
3433 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3434 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3436 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3437   do {
3438    __asm__ __volatile__(
3439       "       xbegin Lfoo  \n\t"
3440       "Lfoo:  xend         \n\t"
3441       "       xacquire lock incq 0(%rsp)     \n\t"
3442       "       xrelease lock incq 0(%rsp)     \n"
3443    );
3444   } while (0)
3445 ]])], [
3446 ac_have_as_tsx=yes
3447 AC_MSG_RESULT([yes])
3448 ], [
3449 ac_have_as_tsx=no
3450 AC_MSG_RESULT([no])
3453 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3456 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3457 # Note, this doesn't generate a C-level symbol.  It generates a
3458 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3459 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3462   do { unsigned int h, l;
3463    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3464    __asm__ __volatile__(
3465       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3466    __asm__ __volatile__(
3467       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3468   while (0)
3469 ]])], [
3470 ac_have_as_bmi=yes
3471 AC_MSG_RESULT([yes])
3472 ], [
3473 ac_have_as_bmi=no
3474 AC_MSG_RESULT([no])
3477 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3480 # does the x86/amd64 assembler understand FMA instructions?
3481 # Note, this doesn't generate a C-level symbol.  It generates a
3482 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3483 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3485 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3486   do { unsigned int h, l;
3487    __asm__ __volatile__(
3488       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3489    __asm__ __volatile__(
3490       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3491    __asm__ __volatile__(
3492       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3493   while (0)
3494 ]])], [
3495 ac_have_as_fma=yes
3496 AC_MSG_RESULT([yes])
3497 ], [
3498 ac_have_as_fma=no
3499 AC_MSG_RESULT([no])
3502 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3505 # does the amd64 assembler understand MPX instructions?
3506 # Note, this doesn't generate a C-level symbol.  It generates a
3507 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3508 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3510 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3511   do {
3512     asm ("bndmov %bnd0,(%rsp)");
3513     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3514     asm ("bnd call foo\n"
3515          "bnd jmp  end\n"
3516          "foo: bnd ret\n"
3517          "end: nop");
3518   } while (0)
3519 ]])], [
3520 ac_have_as_mpx=yes
3521 AC_MSG_RESULT([yes])
3522 ], [
3523 ac_have_as_mpx=no
3524 AC_MSG_RESULT([no])
3527 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3530 # does the amd64 assembler understand ADX instructions?
3531 # Note, this doesn't generate a C-level symbol.  It generates a
3532 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3533 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3535 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3536   do {
3537     asm ("adcxq %r14,%r8");
3538   } while (0)
3539 ]])], [
3540 ac_have_as_adx=yes
3541 AC_MSG_RESULT([yes])
3542 ], [
3543 ac_have_as_adx=no
3544 AC_MSG_RESULT([no])
3547 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3550 # does the amd64 assembler understand the RDRAND instruction?
3551 # Note, this doesn't generate a C-level symbol.  It generates a
3552 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3553 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3555 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3556   do {
3557     asm ("rdrand %r14");
3558     asm ("rdrand %r14d");
3559     asm ("rdrand %r14w");
3560   } while (0)
3561 ]])], [
3562 ac_have_as_rdrand=yes
3563 AC_MSG_RESULT([yes])
3564 ], [
3565 ac_have_as_rdrand=no
3566 AC_MSG_RESULT([no])
3569 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3571 # does the amd64 assembler understand the RDSEED instruction?
3572 # Note, this doesn't generate a C-level symbol.  It generates a
3573 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3574 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3576 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3577   do {
3578     asm ("rdseed %r14");
3579     asm ("rdseed %r14d");
3580     asm ("rdseed %r14w");
3581   } while (0)
3582 ]])], [
3583 ac_have_as_rdseed=yes
3584 AC_MSG_RESULT([yes])
3585 ], [
3586 ac_have_as_rdseed=no
3587 AC_MSG_RESULT([no])
3590 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3592 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3593 # VCVTPS2PH) ?
3594 # Note, this doesn't generate a C-level symbol.  It generates a
3595 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3596 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3598 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3599   do {
3600     asm ("vcvtph2ps %xmm5, %ymm10");
3601     // If we put the dollar sign and zero together, the shell processing
3602     // this configure.ac script substitutes the command name in.  Sigh.
3603     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3604   } while (0)
3605 ]])], [
3606 ac_have_as_f16c=yes
3607 AC_MSG_RESULT([yes])
3608 ], [
3609 ac_have_as_f16c=no
3610 AC_MSG_RESULT([no])
3613 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3616 # does the x86/amd64 assembler understand MOVBE?
3617 # Note, this doesn't generate a C-level symbol.  It generates a
3618 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3619 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3621 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3622   do { long long int x; 
3623    __asm__ __volatile__(
3624       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3625   while (0)
3626 ]])], [
3627 ac_have_as_movbe=yes
3628 AC_MSG_RESULT([yes])
3629 ], [
3630 ac_have_as_movbe=no
3631 AC_MSG_RESULT([no])
3634 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3637 # Does the C compiler support the "ifunc" attribute
3638 # Note, this doesn't generate a C-level symbol.  It generates a
3639 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3640 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3642 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3643 static void mytest(void) {}
3645 static void (*resolve_test(void))(void)
3647     return (void (*)(void))&mytest;
3650 void test(void) __attribute__((ifunc("resolve_test")));
3652 int main()
3654     test();
3655     return 0;
3657 ]])], [
3658 ac_have_ifunc_attr=yes
3659 AC_MSG_RESULT([yes])
3660 ], [
3661 ac_have_ifunc_attr=no
3662 AC_MSG_RESULT([no])
3665 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3667 # Does the C compiler support the armv8 crc feature flag
3668 # Note, this doesn't generate a C-level symbol.  It generates a
3669 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3670 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3672 save_CFLAGS="$CFLAGS"
3673 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3674 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3675 int main()
3677     return 0;
3679 ]])], [
3680 ac_have_armv8_crc_feature=yes
3681 AC_MSG_RESULT([yes])
3682 ], [
3683 ac_have_armv8_crc_feature=no
3684 AC_MSG_RESULT([no])
3686 CFLAGS="$save_CFLAGS"
3688 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3691 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3692 # Note, this doesn't generate a C-level symbol.  It generates a
3693 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3694 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3696 save_CFLAGS="$CFLAGS"
3697 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3698 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3699 int main()
3701     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3702     return 0;
3704 ]])], [
3705 ac_have_armv81_feature=yes
3706 AC_MSG_RESULT([yes])
3707 ], [
3708 ac_have_armv81_feature=no
3709 AC_MSG_RESULT([no])
3711 CFLAGS="$save_CFLAGS"
3713 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3716 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3717 # Note, this doesn't generate a C-level symbol.  It generates a
3718 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3719 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3721 save_CFLAGS="$CFLAGS"
3722 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3723 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3724 int main()
3726     __asm__ __volatile__("faddp h0, v1.2h");
3727     return 0;
3729 ]])], [
3730 ac_have_armv82_feature=yes
3731 AC_MSG_RESULT([yes])
3732 ], [
3733 ac_have_armv82_feature=no
3734 AC_MSG_RESULT([no])
3736 CFLAGS="$save_CFLAGS"
3738 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3741 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3742 # when building the tool executables.  I think we should get rid of it.
3744 # Check for TLS support in the compiler and linker
3745 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3746                                 [[return foo;]])],
3747                                [vg_cv_linktime_tls=yes],
3748                                [vg_cv_linktime_tls=no])
3749 # Native compilation: check whether running a program using TLS succeeds.
3750 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3751 # succeeds but running programs using TLS fails.
3752 # Cross-compiling: check whether linking a program using TLS succeeds.
3753 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3754                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3755                 [vg_cv_tls=$enableval],
3756                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3757                                                 [[return foo;]])],
3758                                [vg_cv_tls=yes],
3759                                [vg_cv_tls=no],
3760                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3762 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3763 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3767 #----------------------------------------------------------------------------
3768 # Solaris-specific checks.
3769 #----------------------------------------------------------------------------
3771 if test "$VGCONF_OS" = "solaris" ; then
3772 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3774 # Solaris-specific check determining if the Sun Studio Assembler is used to
3775 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3776 # cmovl.l instruction, if yes then it's Sun Assembler.
3778 # C-level symbol: none
3779 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3781 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3782 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3783 ]], [[
3784   __asm__ __volatile__("cmovl.l %edx, %eax");
3785 ]])], [
3786 solaris_have_sun_studio_as=yes
3787 AC_MSG_RESULT([yes])
3788 ], [
3789 solaris_have_sun_studio_as=no
3790 AC_MSG_RESULT([no])
3792 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3794 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3795 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3796 # See solaris/vgpreload-solaris.mapfile for details.
3797 # gcc on older Solaris instructs linker to include these symbols,
3798 # gcc on illumos and newer Solaris does not.
3800 # C-level symbol: none
3801 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3803 save_CFLAGS="$CFLAGS"
3804 CFLAGS="$CFLAGS -std=gnu99"
3805 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3806 temp_dir=$( /usr/bin/mktemp -d )
3807 cat <<_ACEOF >${temp_dir}/mylib.c
3808 #include <stdio.h>
3809 int myfunc(void) { printf("LaPutyka\n"); }
3810 _ACEOF
3811 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3812 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3813 if test "x${xpg_present}" = "x" ; then
3814     solaris_xpg_symbols_present=no
3815     AC_MSG_RESULT([no])
3816 else
3817     solaris_xpg_symbols_present=yes
3818     AC_MSG_RESULT([yes])
3820 rm -rf ${temp_dir}
3821 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3822 CFLAGS="$save_CFLAGS"
3825 # Solaris-specific check determining if gcc enables largefile support by
3826 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3827 # variable with gcc flags which disable it.
3829 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3830 save_CFLAGS="$CFLAGS"
3831 CFLAGS="$CFLAGS -m32"
3832 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3833   return _LARGEFILE_SOURCE;
3834 ]])], [
3835 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3836 AC_MSG_RESULT([yes])
3837 ], [
3838 SOLARIS_UNDEF_LARGESOURCE=""
3839 AC_MSG_RESULT([no])
3841 CFLAGS=$safe_CFLAGS
3842 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3845 # Solaris-specific check determining if /proc/self/cmdline
3846 # or /proc/<pid>/cmdline is supported.
3848 # C-level symbol: SOLARIS_PROC_CMDLINE
3849 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3851 AC_CHECK_FILE([/proc/self/cmdline],
3853 solaris_proc_cmdline=yes
3854 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3855           [Define to 1 if you have /proc/self/cmdline.])
3856 ], [
3857 solaris_proc_cmdline=no
3859 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3862 # Solaris-specific check determining default platform for the Valgrind launcher.
3863 # Used in case the launcher cannot select platform by looking at the client
3864 # image (for example because the executable is a shell script).
3866 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3867 # Automake-level symbol: none
3869 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3870 # Get the ELF class of /bin/sh first.
3871 if ! test -f /bin/sh; then
3872   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3874 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3875 case "$elf_class" in
3876   64)
3877     default_arch="$VGCONF_ARCH_PRI";
3878     ;;
3879   32)
3880     if test "x$VGCONF_ARCH_SEC" != "x"; then
3881       default_arch="$VGCONF_ARCH_SEC"
3882     else
3883       default_arch="$VGCONF_ARCH_PRI";
3884     fi
3885     ;;
3886   *)
3887     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3888     ;;
3889 esac
3890 default_platform="$default_arch-$VGCONF_OS"
3891 AC_MSG_RESULT([$default_platform])
3892 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3893                    [Default platform for Valgrind launcher.])
3896 # Solaris-specific check determining if the old syscalls are available.
3898 # C-level symbol: SOLARIS_OLD_SYSCALLS
3899 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3901 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3902 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3903 #include <sys/syscall.h>
3904 ]], [[
3905   return !SYS_open;
3906 ]])], [
3907 solaris_old_syscalls=yes
3908 AC_MSG_RESULT([yes])
3909 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3910           [Define to 1 if you have the old Solaris syscalls.])
3911 ], [
3912 solaris_old_syscalls=no
3913 AC_MSG_RESULT([no])
3915 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3918 # Solaris-specific check determining if the new accept() syscall is available.
3920 # Old syscall:
3921 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3922 #            int version);
3924 # New syscall (available on illumos):
3925 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3926 #            int version, int flags);
3928 # If the old syscall is present then the following syscall will fail with
3929 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3930 # available then it will fail with EINVAL (because the flags parameter is
3931 # invalid).
3933 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3934 # Automake-level symbol: none
3936 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3937 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3938 #include <sys/syscall.h>
3939 #include <errno.h>
3940 ]], [[
3941   errno = 0;
3942   syscall(SYS_accept, 0, 0, 0, 0, -1);
3943   return !(errno == EINVAL);
3944 ]])], [
3945 AC_MSG_RESULT([yes])
3946 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3947           [Define to 1 if you have the new `accept' syscall.])
3948 ], [
3949 AC_MSG_RESULT([no])
3953 # Solaris-specific check determining if the new illumos pipe() syscall is
3954 # available.
3956 # Old syscall:
3957 # longlong_t pipe();
3959 # New syscall (available on illumos):
3960 # int pipe(intptr_t arg, int flags);
3962 # If the old syscall is present then the following call will succeed, if the
3963 # new syscall is available then it will fail with EFAULT (because address 0
3964 # cannot be accessed).
3966 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3967 # Automake-level symbol: none
3969 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3970 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3971 #include <sys/syscall.h>
3972 #include <errno.h>
3973 ]], [[
3974   errno = 0;
3975   syscall(SYS_pipe, 0, 0);
3976   return !(errno == EFAULT);
3977 ]])], [
3978 AC_MSG_RESULT([yes])
3979 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3980           [Define to 1 if you have the new `pipe' syscall.])
3981 ], [
3982 AC_MSG_RESULT([no])
3986 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3987 # available.
3989 # Old syscall:
3990 # int lwp_kill(id_t lwpid, int sig);
3992 # New syscall (available on Solaris 11):
3993 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3994 #                  int si_code, timespec_t *timeout);
3996 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3997 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3999 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
4000 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4001 #include <sys/syscall.h> 
4002 ]], [[
4003   return !SYS_lwp_sigqueue;
4004 ]])], [
4005 solaris_lwp_sigqueue_syscall=yes
4006 AC_MSG_RESULT([yes])
4007 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
4008           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
4009 ], [
4010 solaris_lwp_sigqueue_syscall=no
4011 AC_MSG_RESULT([no])
4013 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
4016 # Solaris-specific check determining if the lwp_sigqueue() syscall
4017 # takes both pid and thread id arguments or just thread id.
4019 # Old syscall (available up to Solaris 11.3):
4020 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
4021 #                  int si_code, timespec_t *timeout);
4023 # New syscall (available since Solaris 11.4):
4024 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
4025 #                  int si_code, timespec_t *timeout);
4027 # If the old syscall is present then the following syscall will fail with
4028 # EINVAL (because signal is out of range); if the new syscall is available
4029 # then it will fail with ESRCH (because it would not find such thread in the
4030 # current process).
4032 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
4033 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
4035 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
4036 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
4037 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4038 #include <sys/syscall.h>
4039 #include <errno.h>
4040 ]], [[
4041   errno = 0;
4042   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
4043   return !(errno == ESRCH);
4044 ]])], [
4045 solaris_lwp_sigqueue_syscall_takes_pid=yes
4046 AC_MSG_RESULT([yes])
4047 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
4048           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
4049 ], [
4050 solaris_lwp_sigqueue_syscall_takes_pid=no
4051 AC_MSG_RESULT([no])
4053 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
4054                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
4056 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
4060 # Solaris-specific check determining if the new lwp_name() syscall is
4061 # available.
4063 # New syscall (available on Solaris 11):
4064 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
4066 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
4067 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
4069 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
4070 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4071 #include <sys/syscall.h>
4072 ]], [[
4073   return !SYS_lwp_name;
4074 ]])], [
4075 solaris_lwp_name_syscall=yes
4076 AC_MSG_RESULT([yes])
4077 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
4078           [Define to 1 if you have the new `lwp_name' syscall.])
4079 ], [
4080 solaris_lwp_name_syscall=no
4081 AC_MSG_RESULT([no])
4083 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
4086 # Solaris-specific check determining if the new getrandom() syscall is
4087 # available.
4089 # New syscall (available on Solaris 11):
4090 # int getrandom(void *buf, size_t buflen, uint_t flags);
4092 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
4093 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
4095 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
4096 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4097 #include <sys/syscall.h>
4098 ]], [[
4099   return !SYS_getrandom;
4100 ]])], [
4101 solaris_getrandom_syscall=yes
4102 AC_MSG_RESULT([yes])
4103 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
4104           [Define to 1 if you have the new `getrandom' syscall.])
4105 ], [
4106 solaris_getrandom_syscall=no
4107 AC_MSG_RESULT([no])
4109 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
4112 # Solaris-specific check determining if the new zone() syscall subcodes
4113 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
4114 # were added in Solaris 11 but are missing on illumos.
4116 # C-level symbol: SOLARIS_ZONE_DEFUNCT
4117 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
4119 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
4120 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4121 #include <sys/zone.h>
4122 ]], [[
4123   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
4124 ]])], [
4125 solaris_zone_defunct=yes
4126 AC_MSG_RESULT([yes])
4127 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
4128           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
4129 ], [
4130 solaris_zone_defunct=no
4131 AC_MSG_RESULT([no])
4133 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
4136 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4137 # for auditon(2) subcode of the auditsys() syscall are available.
4138 # These commands are available in Solaris 11 and illumos but were removed
4139 # in Solaris 11.4.
4141 # C-level symbol: SOLARIS_AUDITON_STAT
4142 # Automake-level symbol: SOLARIS_AUDITON_STAT
4144 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4145 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4146 #include <bsm/audit.h>
4147 ]], [[
4148   return !(A_GETSTAT && A_SETSTAT);
4149 ]])], [
4150 solaris_auditon_stat=yes
4151 AC_MSG_RESULT([yes])
4152 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4153           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4154 ], [
4155 solaris_auditon_stat=no
4156 AC_MSG_RESULT([no])
4158 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4161 # Solaris-specific check determining if the new shmsys() syscall subcodes
4162 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4163 # These subcodes were added in Solaris 11 but are missing on illumos.
4165 # C-level symbol: SOLARIS_SHM_NEW
4166 # Automake-level symbol: SOLARIS_SHM_NEW
4168 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4169 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4170 #include <sys/ipc_impl.h>
4171 #include <sys/shm.h>
4172 #include <sys/shm_impl.h>
4173 ]], [[
4174   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4175 ]])], [
4176 solaris_shm_new=yes
4177 AC_MSG_RESULT([yes])
4178 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4179           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4180 ], [
4181 solaris_shm_new=no
4182 AC_MSG_RESULT([no])
4184 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4187 # Solaris-specific check determining if prxregset_t is available.  Illumos
4188 # currently does not define it on the x86 platform.
4190 # C-level symbol: SOLARIS_PRXREGSET_T
4191 # Automake-level symbol: SOLARIS_PRXREGSET_T
4193 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4194 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4195 #include <sys/procfs_isa.h>
4196 ]], [[
4197   return !sizeof(prxregset_t);
4198 ]])], [
4199 solaris_prxregset_t=yes
4200 AC_MSG_RESULT([yes])
4201 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4202           [Define to 1 if you have the `prxregset_t' type.])
4203 ], [
4204 solaris_prxregset_t=no
4205 AC_MSG_RESULT([no])
4207 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4210 # Solaris-specific check determining if the new frealpathat() syscall is
4211 # available.
4213 # New syscall (available on Solaris 11.1):
4214 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4216 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4217 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4219 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4220 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4221 #include <sys/syscall.h>
4222 ]], [[
4223   return !SYS_frealpathat;
4224 ]])], [
4225 solaris_frealpathat_syscall=yes
4226 AC_MSG_RESULT([yes])
4227 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4228           [Define to 1 if you have the new `frealpathat' syscall.])
4229 ], [
4230 solaris_frealpathat_syscall=no
4231 AC_MSG_RESULT([no])
4233 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4236 # Solaris-specific check determining if the new uuidsys() syscall is
4237 # available.
4239 # New syscall (available on newer Solaris):
4240 # int uuidsys(struct uuid *uuid);
4242 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4243 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4245 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4246 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4247 #include <sys/syscall.h>
4248 ]], [[
4249   return !SYS_uuidsys;
4250 ]])], [
4251 solaris_uuidsys_syscall=yes
4252 AC_MSG_RESULT([yes])
4253 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4254           [Define to 1 if you have the new `uuidsys' syscall.])
4255 ], [
4256 solaris_uuidsys_syscall=no
4257 AC_MSG_RESULT([no])
4259 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4262 # Solaris-specific check determining if the new labelsys() syscall subcode
4263 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4264 # missing on illumos.
4266 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4267 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4269 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4270 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4271 #include <sys/tsol/tndb.h>
4272 ]], [[
4273   return !TNDB_GET_TNIP;
4274 ]])], [
4275 solaris_tndb_get_tnip=yes
4276 AC_MSG_RESULT([yes])
4277 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4278           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4279 ], [
4280 solaris_tndb_get_tnip=no
4281 AC_MSG_RESULT([no])
4283 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4286 # Solaris-specific check determining if the new labelsys() syscall opcodes
4287 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4288 # added in Solaris 11 but are missing on illumos.
4290 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4291 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4293 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4294 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4295 #include <sys/tsol/tsyscall.h>
4296 ]], [[
4297   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4298 ]])], [
4299 solaris_tsol_clearance=yes
4300 AC_MSG_RESULT([yes])
4301 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4302           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4303 ], [
4304 solaris_tsol_clearance=no
4305 AC_MSG_RESULT([no])
4307 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4310 # Solaris-specific check determining if the new pset() syscall subcode
4311 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4312 # is missing on illumos and Solaris 11.3.
4314 # C-level symbol: SOLARIS_PSET_GET_NAME
4315 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4317 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4318 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4319 #include <sys/pset.h>
4320 ]], [[
4321   return !(PSET_GET_NAME);
4322 ]])], [
4323 solaris_pset_get_name=yes
4324 AC_MSG_RESULT([yes])
4325 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4326           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4327 ], [
4328 solaris_pset_get_name=no
4329 AC_MSG_RESULT([no])
4331 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4334 # Solaris-specific check determining if the utimesys() syscall is
4335 # available (on illumos and older Solaris).
4337 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4338 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4340 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4341 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4342 #include <sys/syscall.h>
4343 ]], [[
4344   return !SYS_utimesys;
4345 ]])], [
4346 solaris_utimesys_syscall=yes
4347 AC_MSG_RESULT([yes])
4348 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4349           [Define to 1 if you have the `utimesys' syscall.])
4350 ], [
4351 solaris_utimesys_syscall=no
4352 AC_MSG_RESULT([no])
4354 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4357 # Solaris-specific check determining if the utimensat() syscall is
4358 # available (on newer Solaris).
4360 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4361 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4363 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4365 #include <sys/syscall.h>
4366 ]], [[
4367   return !SYS_utimensat;
4368 ]])], [
4369 solaris_utimensat_syscall=yes
4370 AC_MSG_RESULT([yes])
4371 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4372           [Define to 1 if you have the `utimensat' syscall.])
4373 ], [
4374 solaris_utimensat_syscall=no
4375 AC_MSG_RESULT([no])
4377 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4380 # Solaris-specific check determining if the spawn() syscall is available
4381 # (on newer Solaris).
4383 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4384 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4386 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4387 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4388 #include <sys/syscall.h>
4389 ]], [[
4390   return !SYS_spawn;
4391 ]])], [
4392 solaris_spawn_syscall=yes
4393 AC_MSG_RESULT([yes])
4394 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4395           [Define to 1 if you have the `spawn' syscall.])
4396 ], [
4397 solaris_spawn_syscall=no
4398 AC_MSG_RESULT([no])
4400 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4403 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4404 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4406 # C-level symbol: SOLARIS_MODCTL_MODNVL
4407 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4409 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4410 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4411 #include <sys/modctl.h>
4412 ]], [[
4413   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4414 ]])], [
4415 solaris_modctl_modnvl=yes
4416 AC_MSG_RESULT([yes])
4417 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4418           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4419 ], [
4420 solaris_modctl_modnvl=no
4421 AC_MSG_RESULT([no])
4423 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4426 # Solaris-specific check determining whether nscd (name switch cache daemon)
4427 # attaches its door at /system/volatile/name_service_door (Solaris)
4428 # or at /var/run/name_service_door (illumos).
4430 # Note that /var/run is a symlink to /system/volatile on Solaris
4431 # but not vice versa on illumos.
4433 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4434 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4436 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4437 if test -e /system/volatile/name_service_door; then
4438     solaris_nscd_door_system_volatile=yes
4439     AC_MSG_RESULT([/system/volatile/name_service_door])
4440     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4441               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4442 else
4443     solaris_nscd_door_system_volatile=no
4444     AC_MSG_RESULT([/var/run/name_service_door])
4446 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4449 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4451 # New fasttrap (available on Solaris 11):
4452 # hrt_t *gethrt(void);
4454 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4455 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4457 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4458 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4459 #include <sys/trap.h>
4460 ]], [[
4461   return !T_GETHRT;
4462 ]])], [
4463 solaris_gethrt_fasttrap=yes
4464 AC_MSG_RESULT([yes])
4465 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4466           [Define to 1 if you have the new `gethrt' fasttrap.])
4467 ], [
4468 solaris_gethrt_fasttrap=no
4469 AC_MSG_RESULT([no])
4471 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4474 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4475 # is available.
4477 # New fasttrap (available on Solaris 11):
4478 # zonehrtoffset_t *get_zone_offset(void);
4480 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4481 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4483 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4484 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4485 #include <sys/trap.h>
4486 ]], [[
4487   return !T_GETZONEOFFSET;
4488 ]])], [
4489 solaris_getzoneoffset_fasttrap=yes
4490 AC_MSG_RESULT([yes])
4491 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4492           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4493 ], [
4494 solaris_getzoneoffset_fasttrap=no
4495 AC_MSG_RESULT([no])
4497 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4500 # Solaris-specific check determining if the execve() syscall
4501 # takes fourth argument (flags) or not.
4503 # Old syscall (available on illumos):
4504 # int execve(const char *fname, const char **argv, const char **envp);
4506 # New syscall (available on Solaris):
4507 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4509 # If the new syscall is present then it will fail with EINVAL (because flags
4510 # are invalid); if the old syscall is available then it will fail with ENOENT
4511 # (because the file could not be found).
4513 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4514 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4516 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4517 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4518 #include <sys/syscall.h>
4519 #include <errno.h>
4520 ]], [[
4521   errno = 0;
4522   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4523   return !(errno == EINVAL);
4524 ]])], [
4525 solaris_execve_syscall_takes_flags=yes
4526 AC_MSG_RESULT([yes])
4527 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4528           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4529 ], [
4530 solaris_execve_syscall_takes_flags=no
4531 AC_MSG_RESULT([no])
4533 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4534                test x$solaris_execve_syscall_takes_flags = xyes)
4537 # Solaris-specific check determining version of the repository cache protocol.
4538 # Every Solaris version uses a different one, ranging from 21 to current 25.
4539 # The check is very ugly, though.
4541 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4542 # Automake-level symbol: none
4544 AC_PATH_PROG(DIS_PATH, dis, false)
4545 if test "x$DIS_PATH" = "xfalse"; then
4546   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4548 # The illumos source is (or was) here
4549 # https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libscf/common/lowlevel.c#L1148
4550 # specifically the line
4552 # request.rdr_version = REPOSITORY_DOOR_VERSION;
4554 # rdr_version is a 32bit unsigned int
4555 # The macro REPOSITORY_DOOR_VERSION contains the ascii letters "Rep" in the top 3
4556 # bytes and the door version in the lowest byte. Hence we look for Rep which is 526570
4557 # in hex and then extrace the following byte.
4558 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4559   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4560   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4563 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4564 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4565   libscf=/usr/lib/64/libscf.so.1
4566 else
4567   libscf=/usr/lib/libscf.so.1
4569 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q -E '0x(4d01)?526570'; then
4570   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4571   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4573 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | grep 526570 | sed 's/.*526570//;s/,.*//' )
4574 if test -z "$hex"; then
4575   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4576   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4578 version=$( printf "%d\n" 0x$hex )
4579 AC_MSG_RESULT([$version])
4580 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4581                    [Version number of the repository door cache protocol.])
4584 # Solaris-specific check determining if "sysstat" segment reservation type
4585 # is available.
4587 # New "sysstat" segment reservation (available on Solaris 11.4):
4588 # - program header type:    PT_SUNW_SYSSTAT
4589 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4591 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4592 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4594 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4595 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4596 #include <sys/auxv.h>
4597 ]], [[
4598   return !AT_SUN_SYSSTAT_ADDR;
4599 ]])], [
4600 solaris_reserve_sysstat_addr=yes
4601 AC_MSG_RESULT([yes])
4602 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4603           [Define to 1 if you have the new `sysstat' segment reservation.])
4604 ], [
4605 solaris_reserve_sysstat_addr=no
4606 AC_MSG_RESULT([no])
4608 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4611 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4612 # is available.
4614 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4615 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4616 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4618 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4619 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4621 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4622 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4623 #include <sys/auxv.h>
4624 ]], [[
4625   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4626 ]])], [
4627 solaris_reserve_sysstat_zone_addr=yes
4628 AC_MSG_RESULT([yes])
4629 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4630           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4631 ], [
4632 solaris_reserve_sysstat_zone_addr=no
4633 AC_MSG_RESULT([no])
4635 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4638 # Solaris-specific check determining if the system_stats() syscall is available
4639 # (on newer Solaris).
4641 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4642 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4644 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4645 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4646 #include <sys/syscall.h>
4647 ]], [[
4648   return !SYS_system_stats;
4649 ]])], [
4650 solaris_system_stats_syscall=yes
4651 AC_MSG_RESULT([yes])
4652 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4653           [Define to 1 if you have the `system_stats' syscall.])
4654 ], [
4655 solaris_system_stats_syscall=no
4656 AC_MSG_RESULT([no])
4658 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4661 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4662 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4664 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4665 # Automake-level symbol: none
4667 AC_CHECK_TYPE([struct _fpchip_state],
4668               [solaris_fpchip_state_takes_underscore=yes],
4669               [solaris_fpchip_state_takes_underscore=no],
4670               [[#include <sys/regset.h>]])
4671 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4672   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4673             [Define to 1 if fpregset_t defines struct _fpchip_state])
4677 # Solaris-specific check determining if schedctl page shared between kernel
4678 # and userspace program is executable (illumos, older Solaris) or not (newer
4679 # Solaris).
4681 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4682 # Automake-level symbol: none
4684 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4685 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4686 #include <assert.h>
4687 #include <fcntl.h>
4688 #include <procfs.h>
4689 #include <schedctl.h>
4690 #include <stdio.h>
4691 #include <unistd.h>
4692 ]], [[
4693     schedctl_t *scp = schedctl_init();
4694     if (scp == NULL)
4695         return 1;
4697     int fd = open("/proc/self/map", O_RDONLY);
4698     assert(fd >= 0);
4700     prmap_t map;
4701     ssize_t rd;
4702     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4703         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4704             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4705                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4706             return (map.pr_mflags & MA_EXEC);
4707         }
4708     }
4710     return 1;
4711 ]])], [
4712 solaris_schedctl_page_exec=no
4713 AC_MSG_RESULT([no])
4714 ], [
4715 solaris_schedctl_page_exec=yes
4716 AC_MSG_RESULT([yes])
4717 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4718           [Define to 1 if you have the schedctl page executable.])
4722 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4723 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4724 # an initial thread pointer for libc (newer Solaris).
4726 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4727 # Automake-level symbol: none
4729 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4730 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4731 #include <sys/fasttrap_isa.h>
4732 ]], [[
4733     return !FT_SCRATCHSIZE;
4734 ]])], [
4735 solaris_pt_sunwdtrace_thrp=yes
4736 AC_MSG_RESULT([yes])
4737 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4738           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4739 ], [
4740 solaris_pt_sunwdtrace_thrp=no
4741 AC_MSG_RESULT([no])
4744 else
4745 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4746 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4747 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4748 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4749 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4750 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4751 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4752 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4753 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4754 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4755 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4756 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4757 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4758 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4759 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4760 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4761 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4762 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4763 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4764 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4765 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4766 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4767 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4768 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4769 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4770 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4771 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4772 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4773 fi # test "$VGCONF_OS" = "solaris"
4775 #----------------------------------------------------------------------------
4776 # FreeBSD-specific checks.
4777 #----------------------------------------------------------------------------
4779 # Rather than having a large number of feature test as above with Solaris
4780 # these tests are per-version. This may not be entirely relialable for
4781 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4782 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4784 if test "$VGCONF_OS" = "freebsd" ; then
4786 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4788 else
4790 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4792 fi # test "$VGCONF_OS" = "freebsd"
4795 #----------------------------------------------------------------------------
4796 # Checks for C header files.
4797 #----------------------------------------------------------------------------
4799 AC_CHECK_HEADERS([       \
4800         asm/unistd.h     \
4801         endian.h         \
4802         mqueue.h         \
4803         sys/endian.h     \
4804         sys/epoll.h      \
4805         sys/eventfd.h    \
4806         sys/klog.h       \
4807         sys/poll.h       \
4808         sys/prctl.h      \
4809         sys/signal.h     \
4810         sys/signalfd.h   \
4811         sys/syscall.h    \
4812         sys/sysnvl.h     \
4813         sys/time.h       \
4814         sys/types.h      \
4815         ])
4817 # Verify whether the <linux/futex.h> header is usable.
4818 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4820 save_CFLAGS="$CFLAGS"
4821 CFLAGS="$CFLAGS -D__user="
4822 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4823 #include <linux/futex.h>
4824 ]], [[
4825   return FUTEX_WAIT;
4826 ]])], [
4827 ac_have_usable_linux_futex_h=yes
4828 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4829           [Define to 1 if you have a usable <linux/futex.h> header file.])
4830 AC_MSG_RESULT([yes])
4831 ], [
4832 ac_have_usable_linux_futex_h=no
4833 AC_MSG_RESULT([no])
4835 CFLAGS="$save_CFLAGS"
4838 #----------------------------------------------------------------------------
4839 # Checks for typedefs, structures, and compiler characteristics.
4840 #----------------------------------------------------------------------------
4841 AC_TYPE_UID_T
4842 AC_TYPE_OFF_T
4843 AC_TYPE_SIZE_T
4844 AC_CHECK_HEADERS_ONCE([sys/time.h])
4846 AC_CHECK_TYPE([struct statx], [
4847   AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4848             [Define to 1 if <sys/stat.h> declares struct statx.])
4849 ], [], [
4850   #define _GNU_SOURCE
4851   #include <sys/stat.h>
4855 #----------------------------------------------------------------------------
4856 # Checks for library functions.
4857 #----------------------------------------------------------------------------
4858 AC_FUNC_MEMCMP
4859 AC_FUNC_MMAP
4861 AC_CHECK_LIB([pthread], [pthread_create])
4862 AC_CHECK_LIB([rt], [clock_gettime])
4864 AC_CHECK_FUNCS([     \
4865         aligned_alloc \
4866         clock_gettime\
4867         copy_file_range \
4868         epoll_create \
4869         epoll_pwait  \
4870         getaddrinfo  \
4871         klogctl      \
4872         mallinfo     \
4873         memchr       \
4874         memfd_create \
4875         memset       \
4876         mkdir        \
4877         mremap       \
4878         pipe2        \
4879         ppoll        \
4880         preadv       \
4881         preadv2      \
4882         process_vm_readv  \
4883         process_vm_writev \
4884         pthread_barrier_init       \
4885         pthread_condattr_setclock  \
4886         pthread_mutex_timedlock    \
4887         pthread_rwlock_timedrdlock \
4888         pthread_rwlock_timedwrlock \
4889         pthread_setname_np         \
4890         pthread_spin_lock          \
4891         pthread_yield              \
4892         pwritev      \
4893         pwritev2     \
4894         rawmemchr    \
4895         readlinkat   \
4896         semtimedop   \
4897         setcontext   \
4898         signalfd     \
4899         sigwaitinfo  \
4900         strchr       \
4901         strdup       \
4902         strpbrk      \
4903         strrchr      \
4904         strstr       \
4905         swapcontext  \
4906         syscall      \
4907         utimensat    \
4908         mempcpy      \
4909         stpncpy      \
4910         strchrnul    \
4911         memrchr      \
4912         strndup      \
4913         ])
4915 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4916 # libraries with any shared object and/or executable. This is NOT what we
4917 # want for e.g. vgpreload_core-x86-linux.so
4918 LIBS=""
4920 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4921                [test x$ac_cv_func_pthread_barrier_init = xyes])
4922 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4923                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4924 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4925                [test x$ac_cv_func_pthread_spin_lock = xyes])
4926 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4927                [test x$ac_cv_func_pthread_setname_np = xyes])
4928 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4929                [test x$ac_cv_func_copy_file_range = xyes])
4930 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4931                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4932 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4933                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4934 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4935 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4936 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4937                [test x$ac_cv_func_memfd_create = xyes])
4938 AM_CONDITIONAL([HAVE_GETADDRINFO],
4939                [test x$ac_cv_func_getaddrinfo = xyes])
4941 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4942      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4943      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4944   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4945             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4948 #----------------------------------------------------------------------------
4949 # MPI checks
4950 #----------------------------------------------------------------------------
4951 # Do we have a useable MPI setup on the primary and/or secondary targets?
4952 # On Linux, by default, assumes mpicc and -m32/-m64
4953 # Note: this is a kludge in that it assumes the specified mpicc 
4954 # understands -m32/-m64 regardless of what is specified using
4955 # --with-mpicc=.
4956 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4957              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4959 mflag_primary=
4960 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4961      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4962      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4963      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4964      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4965      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4966      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4967   mflag_primary=$FLAG_M32
4968 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4969        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4970        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4971        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4972        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4973        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4974   mflag_primary=$FLAG_M64
4975 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4976   mflag_primary="$FLAG_M32 -arch i386"
4977 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4978   mflag_primary="$FLAG_M64 -arch x86_64"
4981 mflag_secondary=
4982 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4983      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4984      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4985      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4986      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4987   mflag_secondary=$FLAG_M32
4988 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4989   mflag_secondary="$FLAG_M32 -arch i386"
4993 AC_ARG_WITH(mpicc,
4994    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4995    MPI_CC=$withval
4997 AC_SUBST(MPI_CC)
4999 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
5000 ## use these values in the check for a functioning mpicc.
5002 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
5003 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
5004 AM_COND_IF([VGCONF_OS_IS_LINUX],
5005            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5006             LDFLAGS_MPI="-fpic -shared"])
5007 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
5008            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5009             LDFLAGS_MPI="-fpic -shared"])
5010 AM_COND_IF([VGCONF_OS_IS_DARWIN],
5011            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
5012             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
5013 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
5014            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5015             LDFLAGS_MPI="-fpic -shared"])
5017 AC_SUBST([CFLAGS_MPI])
5018 AC_SUBST([LDFLAGS_MPI])
5021 ## See if MPI_CC works for the primary target
5023 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
5024 saved_CC=$CC
5025 saved_CFLAGS=$CFLAGS
5026 CC=$MPI_CC
5027 CFLAGS="$CFLAGS_MPI $mflag_primary"
5028 saved_LDFLAGS="$LDFLAGS"
5029 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
5030 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5031 #include <mpi.h>
5032 #include <stdio.h>
5033 ]], [[
5034   int ni, na, nd, comb;
5035   int r = MPI_Init(NULL,NULL);
5036   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5037   r |= MPI_Finalize();
5038   return r; 
5039 ]])], [
5040 ac_have_mpi2_pri=yes
5041 AC_MSG_RESULT([yes, $MPI_CC])
5042 ], [
5043 ac_have_mpi2_pri=no
5044 AC_MSG_RESULT([no])
5046 CC=$saved_CC
5047 CFLAGS=$saved_CFLAGS
5048 LDFLAGS="$saved_LDFLAGS"
5049 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
5051 ## See if MPI_CC works for the secondary target.  Complication: what if
5052 ## there is no secondary target?  We need this to then fail.
5053 ## Kludge this by making MPI_CC something which will surely fail in
5054 ## such a case.
5056 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
5057 saved_CC=$CC
5058 saved_CFLAGS=$CFLAGS
5059 saved_LDFLAGS="$LDFLAGS"
5060 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
5061 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
5062   CC="$MPI_CC this will surely fail"
5063 else
5064   CC=$MPI_CC
5066 CFLAGS="$CFLAGS_MPI $mflag_secondary"
5067 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5068 #include <mpi.h>
5069 #include <stdio.h>
5070 ]], [[
5071   int ni, na, nd, comb;
5072   int r = MPI_Init(NULL,NULL);
5073   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5074   r |= MPI_Finalize();
5075   return r; 
5076 ]])], [
5077 ac_have_mpi2_sec=yes
5078 AC_MSG_RESULT([yes, $MPI_CC])
5079 ], [
5080 ac_have_mpi2_sec=no
5081 AC_MSG_RESULT([no])
5083 CC=$saved_CC
5084 CFLAGS=$saved_CFLAGS
5085 LDFLAGS="$saved_LDFLAGS"
5086 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
5089 #----------------------------------------------------------------------------
5090 # Other library checks
5091 #----------------------------------------------------------------------------
5092 # There now follow some tests for Boost, and OpenMP.  These
5093 # tests are present because Drd has some regression tests that use
5094 # these packages.  All regression test programs all compiled only
5095 # for the primary target.  And so it is important that the configure
5096 # checks that follow, use the correct -m32 or -m64 flag for the
5097 # primary target (called $mflag_primary).  Otherwise, we can end up
5098 # in a situation (eg) where, on amd64-linux, the test for Boost checks
5099 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
5100 # only build (meaning, the primary target is x86-linux), the build
5101 # of the regtest programs that use Boost fails, because they are 
5102 # build as 32-bit (IN THIS EXAMPLE).
5104 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
5105 # NEEDED BY THE REGRESSION TEST PROGRAMS.
5108 # Check whether the boost library 1.35 or later has been installed.
5109 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
5111 AC_MSG_CHECKING([for boost])
5113 AC_LANG(C++)
5114 safe_CXXFLAGS=$CXXFLAGS
5115 CXXFLAGS="$mflag_primary"
5116 safe_LIBS="$LIBS"
5117 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
5119 AC_LINK_IFELSE([AC_LANG_SOURCE([
5120 #include <boost/thread.hpp>
5121 static void thread_func(void)
5122 { }
5123 int main(int argc, char** argv)
5125   boost::thread t(thread_func);
5126   return 0;
5128 ])],
5130 ac_have_boost_1_35=yes
5131 AC_SUBST([BOOST_CFLAGS], [])
5132 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
5133 AC_MSG_RESULT([yes])
5134 ], [
5135 ac_have_boost_1_35=no
5136 AC_MSG_RESULT([no])
5139 LIBS="$safe_LIBS"
5140 CXXFLAGS=$safe_CXXFLAGS
5141 AC_LANG(C)
5143 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
5146 # does this compiler support -fopenmp, does it have the include file
5147 # <omp.h> and does it have libgomp ?
5149 AC_MSG_CHECKING([for OpenMP])
5151 safe_CFLAGS=$CFLAGS
5152 CFLAGS="-fopenmp $mflag_primary -Werror"
5154 AC_LINK_IFELSE([AC_LANG_SOURCE([
5155 #include <omp.h> 
5156 int main(int argc, char** argv)
5158   omp_set_dynamic(0);
5159   return 0;
5161 ])],
5163 ac_have_openmp=yes
5164 AC_MSG_RESULT([yes])
5165 ], [
5166 ac_have_openmp=no
5167 AC_MSG_RESULT([no])
5169 CFLAGS=$safe_CFLAGS
5171 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5174 # Check for __builtin_popcount
5175 AC_MSG_CHECKING([for __builtin_popcount()])
5176 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5177 ]], [[
5178   __builtin_popcount(2);
5179   return 0;
5180 ]])], [
5181 AC_MSG_RESULT([yes])
5182 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5183           [Define to 1 if compiler provides __builtin_popcount().])
5184 ], [
5185 AC_MSG_RESULT([no])
5188 # Check for __builtin_clz
5189 AC_MSG_CHECKING([for __builtin_clz()])
5190 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5191 ]], [[
5192   __builtin_clz(2);
5193   return 0;
5194 ]])], [
5195 AC_MSG_RESULT([yes])
5196 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5197           [Define to 1 if compiler provides __builtin_clz().])
5198 ], [
5199 AC_MSG_RESULT([no])
5202 # Check for __builtin_ctz
5203 AC_MSG_CHECKING([for __builtin_ctz()])
5204 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5205 ]], [[
5206   __builtin_ctz(2);
5207   return 0;
5208 ]])], [
5209 AC_MSG_RESULT([yes])
5210 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5211           [Define to 1 if compiler provides __builtin_ctz().])
5212 ], [
5213 AC_MSG_RESULT([no])
5216 # does this compiler have built-in functions for atomic memory access for the
5217 # primary target ?
5218 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5220 safe_CFLAGS=$CFLAGS
5221 CFLAGS="$mflag_primary"
5223 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5224   int variable = 1;
5225   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5226           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5227 ]])], [
5228   ac_have_builtin_atomic_primary=yes
5229   AC_MSG_RESULT([yes])
5230   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])
5231 ], [
5232   ac_have_builtin_atomic_primary=no
5233   AC_MSG_RESULT([no])
5236 CFLAGS=$safe_CFLAGS
5238 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5239                [test x$ac_have_builtin_atomic_primary = xyes])
5242 # does this compiler have built-in functions for atomic memory access for the
5243 # secondary target ?
5245 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5247 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5249 safe_CFLAGS=$CFLAGS
5250 CFLAGS="$mflag_secondary"
5252 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5253   int variable = 1;
5254   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5255 ]])], [
5256   ac_have_builtin_atomic_secondary=yes
5257   AC_MSG_RESULT([yes])
5258 ], [
5259   ac_have_builtin_atomic_secondary=no
5260   AC_MSG_RESULT([no])
5263 CFLAGS=$safe_CFLAGS
5267 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5268                [test x$ac_have_builtin_atomic_secondary = xyes])
5270 # does this compiler have built-in functions for atomic memory access on
5271 # 64-bit integers for all targets ?
5273 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5275 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5276   #include <stdint.h>
5277 ]], [[
5278   uint64_t variable = 1;
5279   return __sync_add_and_fetch(&variable, 1)
5280 ]])], [
5281   ac_have_builtin_atomic64_primary=yes
5282 ], [
5283   ac_have_builtin_atomic64_primary=no
5286 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5288 safe_CFLAGS=$CFLAGS
5289 CFLAGS="$mflag_secondary"
5291 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5292   #include <stdint.h>
5293 ]], [[
5294   uint64_t variable = 1;
5295   return __sync_add_and_fetch(&variable, 1)
5296 ]])], [
5297   ac_have_builtin_atomic64_secondary=yes
5298 ], [
5299   ac_have_builtin_atomic64_secondary=no
5302 CFLAGS=$safe_CFLAGS
5306 if test x$ac_have_builtin_atomic64_primary = xyes && \
5307    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5308      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5309   AC_MSG_RESULT([yes])
5310   ac_have_builtin_atomic64=yes
5311 else
5312   AC_MSG_RESULT([no])
5313   ac_have_builtin_atomic64=no
5316 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5317                [test x$ac_have_builtin_atomic64 = xyes])
5319                
5320 AC_MSG_CHECKING([if platform has openat2 syscall])
5322 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5323   #include <sys/syscall.h>
5324 ]], [[
5325   return __NR_openat2
5326 ]])], [
5327   ac_have_openat2=yes
5328 ], [
5329   ac_have_openat2=no
5332 AM_CONDITIONAL([HAVE_OPENAT2],
5333                [test x$ac_have_openat2 = xyes])
5335 # does g++ have built-in functions for atomic memory access ?
5336 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5338 safe_CXXFLAGS=$CXXFLAGS
5339 CXXFLAGS="$mflag_primary"
5341 AC_LANG_PUSH(C++)
5342 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5343   int variable = 1;
5344   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5345           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5346 ]])], [
5347   ac_have_builtin_atomic_cxx=yes
5348   AC_MSG_RESULT([yes])
5349   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5350 ], [
5351   ac_have_builtin_atomic_cxx=no
5352   AC_MSG_RESULT([no])
5354 AC_LANG_POP(C++)
5356 CXXFLAGS=$safe_CXXFLAGS
5358 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5361 if test x$ac_have_usable_linux_futex_h = xyes \
5362         -a x$ac_have_builtin_atomic_primary = xyes; then
5363   ac_enable_linux_ticket_lock_primary=yes
5365 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5366                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5368 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5369         -a x$ac_have_usable_linux_futex_h = xyes \
5370         -a x$ac_have_builtin_atomic_secondary = xyes; then
5371   ac_enable_linux_ticket_lock_secondary=yes
5373 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5374                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5377 # does libstdc++ support annotating shared pointers ?
5378 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5380 safe_CXXFLAGS=$CXXFLAGS
5381 CXXFLAGS="-std=c++0x"
5383 AC_LANG_PUSH(C++)
5384 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5385   #include <memory>
5386 ]], [[
5387   std::shared_ptr<int> p
5388 ]])], [
5389   ac_have_shared_ptr=yes
5390 ], [
5391   ac_have_shared_ptr=no
5393 if test x$ac_have_shared_ptr = xyes; then
5394   # If compilation of the program below fails because of a syntax error
5395   # triggered by substituting one of the annotation macros then that
5396   # means that libstdc++ supports these macros.
5397   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5398     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5399     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5400     #include <memory>
5401   ]], [[
5402     std::shared_ptr<int> p
5403   ]])], [
5404     ac_have_shared_pointer_annotation=no
5405     AC_MSG_RESULT([no])
5406   ], [
5407     ac_have_shared_pointer_annotation=yes
5408     AC_MSG_RESULT([yes])
5409     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5410               [Define to 1 if libstd++ supports annotating shared pointers])
5411   ])
5412 else
5413   ac_have_shared_pointer_annotation=no
5414   AC_MSG_RESULT([no])
5416 AC_LANG_POP(C++)
5418 CXXFLAGS=$safe_CXXFLAGS
5420 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5421                [test x$ac_have_shared_pointer_annotation = xyes])
5424 #----------------------------------------------------------------------------
5425 # Ok.  We're done checking.
5426 #----------------------------------------------------------------------------
5428 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5429 AC_CONFIG_FILES([
5430    Makefile 
5431    VEX/Makefile:Makefile.vex.in
5432    valgrind.spec
5433    valgrind.pc
5434    glibc-2.X.supp
5435    glibc-2.X-helgrind.supp
5436    glibc-2.X-drd.supp
5437    include/valgrind.h
5438    docs/Makefile 
5439    docs/xml/vg-entities.xml
5440    tests/Makefile 
5441    tests/vg_regtest 
5442    perf/Makefile 
5443    perf/vg_perf
5444    gdbserver_tests/Makefile
5445    gdbserver_tests/solaris/Makefile
5446    include/Makefile 
5447    auxprogs/Makefile
5448    mpi/Makefile
5449    coregrind/Makefile 
5450    memcheck/Makefile
5451    memcheck/tests/Makefile
5452    memcheck/tests/common/Makefile
5453    memcheck/tests/amd64/Makefile
5454    memcheck/tests/x86/Makefile
5455    memcheck/tests/linux/Makefile
5456    memcheck/tests/linux/debuginfod-check.vgtest
5457    memcheck/tests/darwin/Makefile
5458    memcheck/tests/solaris/Makefile
5459    memcheck/tests/freebsd/Makefile
5460    memcheck/tests/amd64-linux/Makefile
5461    memcheck/tests/arm64-linux/Makefile
5462    memcheck/tests/x86-linux/Makefile
5463    memcheck/tests/amd64-solaris/Makefile
5464    memcheck/tests/x86-solaris/Makefile
5465    memcheck/tests/amd64-freebsd/Makefile
5466    memcheck/tests/x86-freebsd/Makefile
5467    memcheck/tests/ppc32/Makefile
5468    memcheck/tests/ppc64/Makefile
5469    memcheck/tests/s390x/Makefile
5470    memcheck/tests/mips32/Makefile
5471    memcheck/tests/mips64/Makefile
5472    memcheck/tests/vbit-test/Makefile
5473    cachegrind/Makefile
5474    cachegrind/tests/Makefile
5475    cachegrind/tests/x86/Makefile
5476    cachegrind/cg_annotate
5477    cachegrind/cg_diff
5478    cachegrind/cg_merge
5479    callgrind/Makefile
5480    callgrind/callgrind_annotate
5481    callgrind/callgrind_control
5482    callgrind/tests/Makefile
5483    helgrind/Makefile
5484    helgrind/tests/Makefile
5485    drd/Makefile
5486    drd/scripts/download-and-build-splash2
5487    drd/tests/Makefile
5488    massif/Makefile
5489    massif/tests/Makefile
5490    massif/ms_print
5491    dhat/Makefile
5492    dhat/tests/Makefile
5493    lackey/Makefile
5494    lackey/tests/Makefile
5495    none/Makefile
5496    none/tests/Makefile
5497    none/tests/scripts/Makefile
5498    none/tests/amd64/Makefile
5499    none/tests/ppc32/Makefile
5500    none/tests/ppc64/Makefile
5501    none/tests/x86/Makefile
5502    none/tests/arm/Makefile
5503    none/tests/arm64/Makefile
5504    none/tests/s390x/Makefile
5505    none/tests/mips32/Makefile
5506    none/tests/mips64/Makefile
5507    none/tests/nanomips/Makefile
5508    none/tests/linux/Makefile
5509    none/tests/darwin/Makefile
5510    none/tests/solaris/Makefile
5511    none/tests/freebsd/Makefile
5512    none/tests/amd64-linux/Makefile
5513    none/tests/x86-linux/Makefile
5514    none/tests/amd64-darwin/Makefile
5515    none/tests/x86-darwin/Makefile
5516    none/tests/amd64-solaris/Makefile
5517    none/tests/x86-solaris/Makefile
5518    none/tests/x86-freebsd/Makefile
5519    exp-bbv/Makefile
5520    exp-bbv/tests/Makefile
5521    exp-bbv/tests/x86/Makefile
5522    exp-bbv/tests/x86-linux/Makefile
5523    exp-bbv/tests/amd64-linux/Makefile
5524    exp-bbv/tests/ppc32-linux/Makefile
5525    exp-bbv/tests/arm-linux/Makefile
5526    shared/Makefile
5527    solaris/Makefile
5529 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5530                 [chmod +x coregrind/link_tool_exe_linux])
5531 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5532                 [chmod +x coregrind/link_tool_exe_freebsd])
5533 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5534                 [chmod +x coregrind/link_tool_exe_darwin])
5535 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5536                 [chmod +x coregrind/link_tool_exe_solaris])
5537 AC_CONFIG_FILES([tests/filter_stderr_basic],
5538                 [chmod +x tests/filter_stderr_basic])
5539 AC_CONFIG_FILES([tests/filter_discards],
5540                 [chmod +x tests/filter_discards])
5541 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5542                 [chmod +x memcheck/tests/filter_stderr])
5543 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5544                 [chmod +x memcheck/tests/filter_dw4])
5545 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5546                 [chmod +x memcheck/tests/filter_overlaperror])
5547 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5548                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5549 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5550                 [chmod +x gdbserver_tests/filter_gdb])
5551 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5552                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5553 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5554                 [chmod +x gdbserver_tests/filter_stderr])
5555 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5556                 [chmod +x gdbserver_tests/filter_vgdb])
5557 AC_CONFIG_FILES([drd/tests/filter_stderr],
5558                 [chmod +x drd/tests/filter_stderr])
5559 AC_CONFIG_FILES([drd/tests/filter_error_count],
5560                 [chmod +x drd/tests/filter_error_count])
5561 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5562                 [chmod +x drd/tests/filter_error_summary])
5563 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5564                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5565 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5566                 [chmod +x drd/tests/filter_thread_no])
5567 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5568                 [chmod +x drd/tests/filter_xml_and_thread_no])
5569 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5570                 [chmod +x helgrind/tests/filter_stderr])
5571 AC_OUTPUT
5573 cat<<EOF
5575                     Version: ${VERSION}
5576          Maximum build arch: ${ARCH_MAX}
5577          Primary build arch: ${VGCONF_ARCH_PRI}
5578        Secondary build arch: ${VGCONF_ARCH_SEC}
5579                    Build OS: ${VGCONF_OS}
5580      Link Time Optimisation: ${vg_cv_lto}
5581        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5582      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5583            Platform variant: ${VGCONF_PLATVARIANT}
5584       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5585          Default supp files: ${DEFAULT_SUPP}