valgrind-monitor.py regular expressions should use raw strings
[valgrind.git] / configure.ac
blob5d491b9c3bc4a0599fda8b55f9cd47caff61ff4e
2 ##------------------------------------------------------------##
3
4 # The multiple-architecture stuff in this file is pretty
5 # cryptic.  Read docs/internals/multiple-architectures.txt
6 # for at least a partial explanation of what is going on.
8 ##------------------------------------------------------------##
10 # Process this file with autoconf to produce a configure script.
12 # Define major, minor, micro and suffix here once, then reuse them
13 # for version number in valgrind.h and vg-entities (documentation).
14 # suffix must be empty for a release, otherwise it is GIT or RC1, etc.
15 # Also set the (expected/last) release date here.
16 # Do not forget to rerun ./autogen.sh
17 m4_define([v_major_ver], [3])
18 m4_define([v_minor_ver], [23])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [GIT])
21 m4_define([v_rel_date], ["?? Apr 2024"])
22 m4_define([v_version],
23           m4_if(v_suffix_ver, [],
24                 [v_major_ver.v_minor_ver.v_micro_ver],
25                 [v_major_ver.v_minor_ver.v_micro_ver.v_suffix_ver]))
26 AC_INIT([Valgrind],[v_version],[valgrind-users@lists.sourceforge.net])
28 # For valgrind.h
29 AC_SUBST(VG_VER_MAJOR, v_major_ver)
30 AC_SUBST(VG_VER_MINOR, v_minor_ver)
32 # For docs/xml/vg-entities.xml
33 AC_SUBST(VG_DATE, v_rel_date)
35 AC_CONFIG_SRCDIR(coregrind/m_main.c)
36 AC_CONFIG_HEADERS([config.h])
37 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
39 AM_MAINTAINER_MODE
41 #----------------------------------------------------------------------------
42 # Do NOT modify these flags here. Except in feature tests in which case
43 # the original values must be properly restored.
44 #----------------------------------------------------------------------------
45 CFLAGS="$CFLAGS"
46 CXXFLAGS="$CXXFLAGS"
48 #----------------------------------------------------------------------------
49 # Checks for various programs.
50 #----------------------------------------------------------------------------
52 AC_PROG_LN_S
53 m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
54 # Make sure we can compile in C99 mode.
55 if test "$ac_cv_prog_cc_c99" = "no"; then
56     AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
58 AC_PROG_CPP
59 AC_PROG_CXX
60 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
61 # autoconf 2.59).  If we ever have any Objective-C code in the Valgrind code
62 # base (eg. most likely as Darwin-specific tests) we'll need one of the
63 # following:
64 # - put AC_PROG_OBJC in a Darwin-specific part of this file
65 # - Use AC_PROG_OBJC here and up the minimum autoconf version
66 # - Use the following, which is apparently equivalent:
67 #     m4_ifdef([AC_PROG_OBJC],
68 #        [AC_PROG_OBJC],
69 #        [AC_CHECK_TOOL([OBJC], [gcc])
70 #         AC_SUBST([OBJC])
71 #         AC_SUBST([OBJCFLAGS])
72 #        ])
73 AC_PROG_RANLIB
74 # Set LTO_RANLIB variable to an lto enabled ranlib
75 if test "x$LTO_RANLIB" = "x"; then
76   AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
78 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
80 # provide a very basic definition for AC_PROG_SED if it's not provided by
81 # autoconf (as e.g. in autoconf 2.59).
82 m4_ifndef([AC_PROG_SED],
83           [AC_DEFUN([AC_PROG_SED],
84                     [AC_ARG_VAR([SED])
85                      AC_CHECK_PROGS([SED],[gsed sed])])])
86 AC_PROG_SED
88 AC_DEFUN([AC_PROG_SHA256SUM],
89           [AC_ARG_VAR([SHA256SUM])
90           AC_CHECK_PROGS([SHA256SUM],[gsha256sum sha256sum])])
91 AC_PROG_SHA256SUM
93 # If no AR variable was specified, look up the name of the archiver. Otherwise
94 # do not touch the AR variable.
95 if test "x$AR" = "x"; then
96   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
98 AC_ARG_VAR([AR],[Archiver command])
100 # same for LTO_AR variable for lto enabled archiver
101 if test "x$LTO_AR" = "x"; then
102   AC_PATH_PROGS([LTO_AR], [gcc-ar])
104 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
106 # figure out where perl lives
107 AC_PATH_PROG(PERL, perl)
109 # figure out where gdb lives
110 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
111 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
113 # some older automake's don't have it so try something on our own
114 ifdef([AM_PROG_AS],[AM_PROG_AS],
116 AS="${CC}"
117 AC_SUBST(AS)
119 ASFLAGS=""
120 AC_SUBST(ASFLAGS)
124 # Check if 'diff' supports -u (universal diffs) and use it if possible.
126 AC_MSG_CHECKING([for diff -u])
127 AC_SUBST(DIFF)
129 # Comparing two identical files results in 0.
130 tmpfile="tmp-xxx-yyy-zzz"
131 touch $tmpfile;
132 if diff -u $tmpfile $tmpfile ; then
133     AC_MSG_RESULT([yes])
134     DIFF="diff -u"
135 else
136     AC_MSG_RESULT([no])
137     DIFF="diff"
139 rm $tmpfile
141 # We don't want gcc < 3.0
142 AC_MSG_CHECKING([for a supported version of gcc])
144 # Obtain the compiler version.
146 # A few examples of how the ${CC} --version output looks like:
148 # ######## gcc variants ########
149 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
150 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
151 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
152 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
153 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
154 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
155 # OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
157 # ######## clang variants ########
158 # Clang: clang version 2.9 (tags/RELEASE_29/final)
159 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
160 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
162 # ######## Apple LLVM variants ########
163 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
164 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
167 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
168 then
169     is_clang="applellvm"
170     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
171 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
172 then
173     is_clang="clang"
174     # Don't use -dumpversion with clang: it will always produce "4.2.1".
175     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
176 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
177 then
178     is_clang="icc"
179     gcc_version=`${CC} -dumpversion 2>/dev/null`
180 else
181     is_clang="notclang"
182     gcc_version=`${CC} -dumpversion 2>/dev/null`
183     if test "x$gcc_version" = x; then
184         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
185     fi
188 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
189 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
191 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
192 # statements have to be quoted.
193 case "${is_clang}-${gcc_version}" in
194      applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
195         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
196         ;;
197      icc-1[[3-9]].*|icc-202[[0-9]].*)
198         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
199         ;;
200      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
201         AC_MSG_RESULT([ok (${gcc_version})])
202         ;;
203      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
204         AC_MSG_RESULT([ok (clang-${gcc_version})])
205         ;;
206      *)
207         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
208         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
209         ;;
210 esac
212 #----------------------------------------------------------------------------
213 # Arch/OS/platform tests.
214 #----------------------------------------------------------------------------
215 # We create a number of arch/OS/platform-related variables.  We prefix them
216 # all with "VGCONF_" which indicates that they are defined at
217 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
218 # variables used when compiling C files.
220 AC_CANONICAL_HOST
222 AC_MSG_CHECKING([for a supported CPU])
224 # ARCH_MAX reflects the most that this CPU can do: for example if it
225 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
226 # Ditto for amd64.  It is used for more configuration below, but is not used
227 # outside this file.
229 # Power PC returns powerpc for Big Endian.  This was not changed when Little
230 # Endian support was added to the 64-bit architecture.  The 64-bit Little
231 # Endian systems explicitly state le in the host_cpu.  For clarity in the
232 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
233 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
234 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
235 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
236 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
237 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
238 # Little Endian.
240 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            FLAG_32ON64_GXX="-L/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -lgcc_s"
810            AC_SUBST(FLAG_32ON64_GXX)
811         fi
812         valt_load_address_pri_norml="0x38000000"
813         valt_load_address_pri_inner="0x28000000"
814         valt_load_address_sec_norml="0x38000000"
815         valt_load_address_sec_inner="0x28000000"
816         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
817         ;;
818      # Darwin gets identified as 32-bit even when it supports 64-bit.
819      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
820      # all Macs support both 32-bit and 64-bit, so we just build both.  If
821      # someone has a really old 32-bit only machine they can (hopefully?)
822      # build with --enable-only32bit.  See bug 243362.
823      x86-darwin|amd64-darwin)
824         ARCH_MAX="amd64"
825         valt_load_address_sec_norml="0xUNSET"
826         valt_load_address_sec_inner="0xUNSET"
827         if test x$vg_cv_only64bit = xyes; then
828            VGCONF_ARCH_PRI="amd64"
829            VGCONF_ARCH_SEC=""
830            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
831            VGCONF_PLATFORM_SEC_CAPS=""
832            valt_load_address_pri_norml="0x158000000"
833            valt_load_address_pri_inner="0x138000000"
834         elif test x$vg_cv_only32bit = xyes; then
835            VGCONF_ARCH_PRI="x86"
836            VGCONF_ARCH_SEC=""
837            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
838            VGCONF_PLATFORM_SEC_CAPS=""
839            VGCONF_ARCH_PRI_CAPS="x86"
840            valt_load_address_pri_norml="0x58000000"
841            valt_load_address_pri_inner="0x38000000"
842         else
843            VGCONF_ARCH_PRI="amd64"
844            VGCONF_ARCH_SEC="x86"
845            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
846            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
847            valt_load_address_pri_norml="0x158000000"
848            valt_load_address_pri_inner="0x138000000"
849            valt_load_address_sec_norml="0x58000000"
850            valt_load_address_sec_inner="0x38000000"
851         fi
852         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
853         ;;
854      arm-linux) 
855         VGCONF_ARCH_PRI="arm"
856         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
857         VGCONF_PLATFORM_SEC_CAPS=""
858         valt_load_address_pri_norml="0x58000000"
859         valt_load_address_pri_inner="0x38000000"
860         valt_load_address_sec_norml="0xUNSET"
861         valt_load_address_sec_inner="0xUNSET"
862         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
863         ;;
864      arm64-linux)
865         valt_load_address_sec_norml="0xUNSET"
866         valt_load_address_sec_inner="0xUNSET"
867         if test x$vg_cv_only64bit = xyes; then
868            VGCONF_ARCH_PRI="arm64"
869            VGCONF_ARCH_SEC=""
870            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
871            VGCONF_PLATFORM_SEC_CAPS=""
872            valt_load_address_pri_norml="0x58000000"
873            valt_load_address_pri_inner="0x38000000"
874         elif test x$vg_cv_only32bit = xyes; then
875            VGCONF_ARCH_PRI="arm"
876            VGCONF_ARCH_SEC=""
877            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
878            VGCONF_PLATFORM_SEC_CAPS=""
879            valt_load_address_pri_norml="0x58000000"
880            valt_load_address_pri_inner="0x38000000"
881         else
882            VGCONF_ARCH_PRI="arm64"
883            VGCONF_ARCH_SEC="arm"
884            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
885            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
886            valt_load_address_pri_norml="0x58000000"
887            valt_load_address_pri_inner="0x38000000"
888            valt_load_address_sec_norml="0x58000000"
889            valt_load_address_sec_inner="0x38000000"
890         fi
891         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
892         ;;
893      s390x-linux)
894         VGCONF_ARCH_PRI="s390x"
895         VGCONF_ARCH_SEC=""
896         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
897         VGCONF_PLATFORM_SEC_CAPS=""
898         # To improve branch prediction hit rate we want to have
899         # the generated code close to valgrind (host) code
900         valt_load_address_pri_norml="0x800000000"
901         valt_load_address_pri_inner="0x810000000"
902         valt_load_address_sec_norml="0xUNSET"
903         valt_load_address_sec_inner="0xUNSET"
904         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
905         ;;
906      mips32-linux) 
907         VGCONF_ARCH_PRI="mips32"
908         VGCONF_ARCH_SEC=""
909         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
910         VGCONF_PLATFORM_SEC_CAPS=""
911         valt_load_address_pri_norml="0x58000000"
912         valt_load_address_pri_inner="0x38000000"
913         valt_load_address_sec_norml="0xUNSET"
914         valt_load_address_sec_inner="0xUNSET"
915         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
916         ;;
917      mips64-linux)
918         valt_load_address_sec_norml="0xUNSET"
919         valt_load_address_sec_inner="0xUNSET"
920         if test x$vg_cv_only64bit = xyes; then
921             VGCONF_ARCH_PRI="mips64"
922             VGCONF_PLATFORM_SEC_CAPS=""
923             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
924             VGCONF_PLATFORM_SEC_CAPS=""
925             valt_load_address_pri_norml="0x58000000"
926             valt_load_address_pri_inner="0x38000000"
927         elif test x$vg_cv_only32bit = xyes; then
928             VGCONF_ARCH_PRI="mips32"
929             VGCONF_ARCH_SEC=""
930             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
931             VGCONF_PLATFORM_SEC_CAPS=""
932             valt_load_address_pri_norml="0x58000000"
933             valt_load_address_pri_inner="0x38000000"
934         else
935             VGCONF_ARCH_PRI="mips64"
936             VGCONF_ARCH_SEC="mips32"
937             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
938             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
939             valt_load_address_pri_norml="0x58000000"
940             valt_load_address_pri_inner="0x38000000"
941             valt_load_address_sec_norml="0x58000000"
942             valt_load_address_sec_inner="0x38000000"
943         fi
944         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
945         ;;
946      nanomips-linux)
947         VGCONF_ARCH_PRI="nanomips"
948         VGCONF_ARCH_SEC=""
949         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
950         VGCONF_PLATFORM_SEC_CAPS=""
951         valt_load_address_pri_norml="0x58000000"
952         valt_load_address_pri_inner="0x38000000"
953         valt_load_address_sec_norml="0xUNSET"
954         valt_load_address_sec_inner="0xUNSET"
955         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
956         ;;
957      x86-solaris)
958         VGCONF_ARCH_PRI="x86"
959         VGCONF_ARCH_SEC=""
960         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
961         VGCONF_PLATFORM_SEC_CAPS=""
962         valt_load_address_pri_norml="0x58000000"
963         valt_load_address_pri_inner="0x38000000"
964         valt_load_address_sec_norml="0xUNSET"
965         valt_load_address_sec_inner="0xUNSET"
966         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
967         ;;
968      amd64-solaris)
969         valt_load_address_sec_norml="0xUNSET"
970         valt_load_address_sec_inner="0xUNSET"
971         if test x$vg_cv_only64bit = xyes; then
972            VGCONF_ARCH_PRI="amd64"
973            VGCONF_ARCH_SEC=""
974            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
975            VGCONF_PLATFORM_SEC_CAPS=""
976            valt_load_address_pri_norml="0x58000000"
977            valt_load_address_pri_inner="0x38000000"
978         elif test x$vg_cv_only32bit = xyes; then
979            VGCONF_ARCH_PRI="x86"
980            VGCONF_ARCH_SEC=""
981            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
982            VGCONF_PLATFORM_SEC_CAPS=""
983            valt_load_address_pri_norml="0x58000000"
984            valt_load_address_pri_inner="0x38000000"
985         else
986            VGCONF_ARCH_PRI="amd64"
987            VGCONF_ARCH_SEC="x86"
988            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
989            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
990            valt_load_address_pri_norml="0x58000000"
991            valt_load_address_pri_inner="0x38000000"
992            valt_load_address_sec_norml="0x58000000"
993            valt_load_address_sec_inner="0x38000000"
994         fi
995         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
996         ;;
997     *)
998         VGCONF_ARCH_PRI="unknown"
999         VGCONF_ARCH_SEC="unknown"
1000         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
1001         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
1002         valt_load_address_pri_norml="0xUNSET"
1003         valt_load_address_pri_inner="0xUNSET"
1004         valt_load_address_sec_norml="0xUNSET"
1005         valt_load_address_sec_inner="0xUNSET"
1006         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
1007         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
1008         ;;
1009 esac
1011 #----------------------------------------------------------------------------
1013 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
1014 # defined.
1015 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
1016                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1017                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1018                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1019                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1020                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1021                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1022                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1023                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1024 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
1025                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1026                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1027                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1028                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1029 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
1030                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1031                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1032 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
1033                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1034                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1035 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
1036                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1037                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1038 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
1039                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1040 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1041                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1042 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1043                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1044                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1045 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1046                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
1047 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1048                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1050 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
1051 # become defined.
1052 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
1053                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1054                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1055 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
1056                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1057 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
1058                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1059                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1060 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1061                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1062 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1063                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1064 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1065                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1066                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1067 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1068                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1069 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1070                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1071                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1072 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1073                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1074                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1075 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1076                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1077 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1078                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1079 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1080                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1081                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1082 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1083                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1084 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1085                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1086                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1087 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1088                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1089 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1090                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1091                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1092 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1093                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1096 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1097 # Relies on the assumption that the primary and secondary targets are 
1098 # for the same OS, so therefore only necessary to test the primary.
1099 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1100                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1101                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1102                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1103                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1104                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1105                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1106                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1107                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1108                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1109                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1110                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1111 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1112                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1113                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1114 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1115                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1116                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1117 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1118                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1119                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1120 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1121                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1122                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1123                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1124                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1127 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1128 # there is a secondary target.
1129 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1130                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1132 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1133 dnl fallback definition
1134 dnl The macro is courtesy of Dave Hart:
1135 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1136 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1137 if test -z "$$1_TRUE"; then :
1138   m4_n([$2])[]dnl
1139 m4_ifval([$3],
1140 [else
1141   $3
1142 ])dnl
1143 fi[]dnl
1144 ])])
1146 #----------------------------------------------------------------------------
1147 # Inner Valgrind?
1148 #----------------------------------------------------------------------------
1150 # Check if this should be built as an inner Valgrind, to be run within
1151 # another Valgrind.  Choose the load address accordingly.
1152 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1153 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1154 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1155    [AC_ARG_ENABLE(inner, 
1156       [  --enable-inner          enables self-hosting],
1157       [vg_cv_inner=$enableval],
1158       [vg_cv_inner=no])])
1159 if test "$vg_cv_inner" = yes; then
1160     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1161     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1162     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1163 else
1164     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1165     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1168 #----------------------------------------------------------------------------
1169 # Undefined behaviour sanitiser
1170 #----------------------------------------------------------------------------
1171 # Check whether we should build with the undefined beahviour sanitiser.
1173 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1174    [AC_ARG_ENABLE(ubsan, 
1175       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1176       [vg_cv_ubsan=$enableval],
1177       [vg_cv_ubsan=no])])
1179 #----------------------------------------------------------------------------
1180 # Extra fine-tuning of installation directories
1181 #----------------------------------------------------------------------------
1182 AC_ARG_WITH(tmpdir,
1183    [  --with-tmpdir=PATH      Specify path for temporary files],
1184    tmpdir="$withval",
1185    tmpdir="/tmp")
1186 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1187 AC_SUBST(VG_TMPDIR, [$tmpdir])
1189 #----------------------------------------------------------------------------
1190 # Detect xcode path
1191 #----------------------------------------------------------------------------
1192 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1193 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1194 AC_MSG_CHECKING([for xcode sdk include path])
1195 AC_ARG_WITH(xcodedir,
1196    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1197    [xcodedir="$withval"],
1198    [
1199       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1200          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1201          if test -z "$xcrundir"; then
1202             xcodedir="/usr/include"
1203          else
1204             xcodedir="$xcrundir/usr/include"
1205          fi
1206       else
1207          xcodedir="/usr/include"
1208       fi
1209    ])
1210 AC_MSG_RESULT([$xcodedir])
1211 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1212 AC_SUBST(XCODE_DIR, [$xcodedir])])
1214 #----------------------------------------------------------------------------
1215 # Where to install gdb scripts, defaults to VG_LIBDIR (pkglibexecdir)
1216 #----------------------------------------------------------------------------
1217 AC_MSG_CHECKING([where gdb scripts are installed])
1218 AC_ARG_WITH(gdbscripts-dir,
1219    [  --with-gdbscripts-dir=PATH  Specify path to install gdb scripts],
1220    [gdbscriptsdir=${withval}],
1221    [gdbscriptsdir=${libexecdir}/valgrind])
1222 AC_MSG_RESULT([$gdbscriptsdir])
1223 if test "x$gdbscriptsdir" != "xno"; then
1224   AC_SUBST(VG_GDBSCRIPTS_DIR, [$gdbscriptsdir])
1225   AM_CONDITIONAL(GDBSCRIPTS, true)
1226 else
1227   AC_SUBST(VG_GDBSCRIPTS_DIR, [])
1228   AM_CONDITIONAL(GDBSCRIPTS, false)
1231 #----------------------------------------------------------------------------
1232 # Libc and suppressions
1233 #----------------------------------------------------------------------------
1234 # This variable will collect the suppression files to be used.
1235 AC_SUBST(DEFAULT_SUPP)
1237 AC_CHECK_HEADER([features.h])
1239 if test x$ac_cv_header_features_h = xyes; then
1240   AC_DEFINE([HAVE_HEADER_FEATURES_H], 1,
1241           [Define to 1 if you have the `features.h' header.])
1242   rm -f conftest.$ac_ext
1243   cat <<_ACEOF >conftest.$ac_ext
1244 #include <features.h>
1245 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1246 glibc version is: __GLIBC__ __GLIBC_MINOR__
1247 #endif
1248 _ACEOF
1249   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1252 # not really a version check
1253 AC_EGREP_CPP([DARWIN_LIBC], [
1254 #include <sys/cdefs.h>
1255 #if defined(__DARWIN_VERS_1050)
1256   DARWIN_LIBC
1257 #endif
1259 GLIBC_VERSION="darwin")
1261 AC_EGREP_CPP([FREEBSD_LIBC], [
1262 #include <sys/cdefs.h>
1263 #if defined(__FreeBSD__)
1264   FREEBSD_LIBC
1265 #endif
1267 GLIBC_VERSION="freebsd")
1269 # not really a version check
1270 AC_EGREP_CPP([BIONIC_LIBC], [
1271 #if defined(__ANDROID__)
1272   BIONIC_LIBC
1273 #endif
1275 GLIBC_VERSION="bionic")
1277 # there is only one version of libc on Solaris
1278 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1279      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1280     GLIBC_VERSION="solaris"
1283 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1284 # in this case.
1285 if test x$GLIBC_VERSION = x; then
1286     if $CC -dumpmachine | grep -q musl; then
1287         GLIBC_VERSION=musl
1288     fi
1291 # If this is glibc then figure out the generic (in file) libc.so and
1292 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1293 # was a separate library, afterwards it was merged into libc.so and
1294 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1295 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1296 case ${GLIBC_VERSION} in
1298   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1299   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1300   [
1301     AC_MSG_RESULT([no])
1302     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1303     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1304   ], [
1305     AC_MSG_RESULT([yes])
1306     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1307     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1308   ])
1309   ;;
1311   AC_MSG_CHECKING([not glibc...])
1312   AC_MSG_RESULT([${GLIBC_VERSION}])
1313   ;;
1314 esac
1316 AC_MSG_CHECKING([the glibc version])
1318 case "${GLIBC_VERSION}" in
1319      2.2)
1320         AC_MSG_RESULT(${GLIBC_VERSION} family)
1321         DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1322         DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1323         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1324         ;;
1325      2.[[3-6]])
1326         AC_MSG_RESULT(${GLIBC_VERSION} family)
1327         DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1328         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1329         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1330         ;;
1331      2.[[7-9]])
1332         AC_MSG_RESULT(${GLIBC_VERSION} family)
1333         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1334         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1335         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1336         ;;
1337      2.10|2.11)
1338         AC_MSG_RESULT(${GLIBC_VERSION} family)
1339         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1340                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1341         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1342         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1343         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1344         ;;
1345      2.*)
1346         AC_MSG_RESULT(${GLIBC_VERSION} family)
1347         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1348                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1349         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1350                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1351         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1352         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1353         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1354         ;;
1355      darwin)
1356         AC_MSG_RESULT(Darwin)
1357         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1358         # DEFAULT_SUPP set by kernel version check above.
1359         ;;
1360      freebsd)
1361         AC_MSG_RESULT(FreeBSD)
1362         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1363         # DEFAULT_SUPP set by kernel version check above.
1364         ;;
1365      bionic)
1366         AC_MSG_RESULT(Bionic)
1367         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1368         DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1369         ;;
1370      solaris)
1371         AC_MSG_RESULT(Solaris)
1372         # DEFAULT_SUPP set in host_os switch-case above.
1373         # No other suppression file is used.
1374         ;;
1375      musl)
1376         AC_MSG_RESULT(Musl)
1377         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1378         DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1379         ;;
1380      2.0|2.1|*)
1381         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1382         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1383         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1384         ;;
1385 esac
1387 AC_SUBST(GLIBC_VERSION)
1388 AC_SUBST(GLIBC_LIBC_PATH)
1389 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1392 if test "$VGCONF_OS" != "solaris"; then
1393     # Add default suppressions for the X client libraries.  Make no
1394     # attempt to detect whether such libraries are installed on the
1395     # build machine (or even if any X facilities are present); just
1396     # add the suppressions antidisirregardless.
1397     DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1398     DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1402 #----------------------------------------------------------------------------
1403 # Platform variants?
1404 #----------------------------------------------------------------------------
1406 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1407 # But there are times where we need a bit more control.  The motivating
1408 # and currently only case is Android: this is almost identical to
1409 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1410 # platform variant tags, which get passed in the compile as
1411 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1413 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1414 # it is "android" instead.
1416 # Consequently (eg), plain arm-linux would build with
1418 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1420 # whilst an Android build would have
1422 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1424 # Same for x86. The setup of the platform variant is pushed relatively far
1425 # down this file in order that we can inspect any of the variables set above.
1427 # In the normal case ..
1428 VGCONF_PLATVARIANT="vanilla"
1430 # Android ?
1431 if test "$GLIBC_VERSION" = "bionic";
1432 then
1433    VGCONF_PLATVARIANT="android"
1436 AC_SUBST(VGCONF_PLATVARIANT)
1439 # FIXME: do we also want to define automake variables
1440 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1441 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1442 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1443 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1444 # that's what we'd need to do to use this, since what we'd want to write
1445 # is something like
1447 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1449 # Hmm.  Can't think of a nice clean solution to this.
1451 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1452                test x$VGCONF_PLATVARIANT = xvanilla)
1453 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1454                test x$VGCONF_PLATVARIANT = xandroid)
1457 #----------------------------------------------------------------------------
1458 # Checking for various library functions and other definitions
1459 #----------------------------------------------------------------------------
1461 # Check for AT_FDCWD
1463 AC_MSG_CHECKING([for AT_FDCWD])
1464 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1465 #define _GNU_SOURCE
1466 #include <fcntl.h>
1467 #include <unistd.h>
1468 ]], [[
1469   int a = AT_FDCWD;
1470 ]])], [
1471 ac_have_at_fdcwd=yes
1472 AC_MSG_RESULT([yes])
1473 ], [
1474 ac_have_at_fdcwd=no
1475 AC_MSG_RESULT([no])
1478 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1480 # Check for stpncpy function definition in string.h
1481 # This explicitly checks with _GNU_SOURCE defined since that is also
1482 # used in the test case (some systems might define it without anyway
1483 # since stpncpy is part of The Open Group Base Specifications Issue 7
1484 # IEEE Std 1003.1-2008.
1485 AC_MSG_CHECKING([for stpncpy])
1486 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1487 #define _GNU_SOURCE
1488 #include <string.h>
1489 ]], [[
1490   char *d;
1491   char *s;
1492   size_t n = 0;
1493   char *r = stpncpy(d, s, n);
1494 ]])], [
1495 ac_have_gnu_stpncpy=yes
1496 AC_MSG_RESULT([yes])
1497 ], [
1498 ac_have_gnu_stpncpy=no
1499 AC_MSG_RESULT([no])
1502 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1504 # Check for PTRACE_GETREGS
1506 AC_MSG_CHECKING([for PTRACE_GETREGS])
1507 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1508 #include <stdlib.h>
1509 #include <stddef.h>
1510 #include <sys/ptrace.h>
1511 #include <sys/user.h>
1512 ]], [[
1513   void *p;
1514   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1515 ]])], [
1516 AC_MSG_RESULT([yes])
1517 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1518           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1519 ], [
1520 AC_MSG_RESULT([no])
1524 # Check for CLOCK_MONOTONIC
1526 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1528 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1529 #include <time.h>
1530 ]], [[
1531   struct timespec t;
1532   clock_gettime(CLOCK_MONOTONIC, &t);
1533   return 0;
1534 ]])], [
1535 AC_MSG_RESULT([yes])
1536 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1537           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1538 ], [
1539 AC_MSG_RESULT([no])
1543 # Check for ELF32/64_CHDR
1545 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1548 # Check for PTHREAD_RWLOCK_T
1550 AC_MSG_CHECKING([for pthread_rwlock_t])
1552 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1553 #define _GNU_SOURCE
1554 #include <pthread.h>
1555 ]], [[
1556   pthread_rwlock_t rwl;
1557 ]])], [
1558 AC_MSG_RESULT([yes])
1559 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1560           [Define to 1 if you have the `pthread_rwlock_t' type.])
1561 ], [
1562 AC_MSG_RESULT([no])
1565 # Check for CLOCKID_T
1567 AC_MSG_CHECKING([for clockid_t])
1569 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1570 #include <time.h>
1571 ]], [[
1572   clockid_t c;
1573 ]])], [
1574 AC_MSG_RESULT([yes])
1575 AC_DEFINE([HAVE_CLOCKID_T], 1,
1576           [Define to 1 if you have the `clockid_t' type.])
1577 ], [
1578 AC_MSG_RESULT([no])
1581 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1583 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1586 #define _GNU_SOURCE
1587 #include <pthread.h>
1588 ]], [[
1589   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1590 ]])], [
1591 AC_MSG_RESULT([yes])
1592 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1593           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1594 ], [
1595 AC_MSG_RESULT([no])
1599 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1601 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1603 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1604 #define _GNU_SOURCE
1605 #include <pthread.h>
1606 ]], [[
1607   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1608 ]])], [
1609 AC_MSG_RESULT([yes])
1610 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1611           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1612 ], [
1613 AC_MSG_RESULT([no])
1617 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1619 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1621 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1622 #define _GNU_SOURCE
1623 #include <pthread.h>
1624 ]], [[
1625   return (PTHREAD_MUTEX_RECURSIVE_NP);
1626 ]])], [
1627 AC_MSG_RESULT([yes])
1628 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1629           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1630 ], [
1631 AC_MSG_RESULT([no])
1635 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1637 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1639 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1640 #define _GNU_SOURCE
1641 #include <pthread.h>
1642 ]], [[
1643   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1644   return 0;
1645 ]])], [
1646 AC_MSG_RESULT([yes])
1647 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1648           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1649 ], [
1650 AC_MSG_RESULT([no])
1654 # Check whether pthread_mutex_t has a member called __m_kind.
1656 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1657                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1658                            1,                                   
1659                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1660                 ],
1661                 [],
1662                 [#include <pthread.h>])
1665 # Check whether pthread_mutex_t has a member called __data.__kind.
1667 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1668                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1669                           1,
1670                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1671                 ],
1672                 [],
1673                 [#include <pthread.h>])
1675 # Convenience function.  Set flags based on the existing HWCAP entries.
1676 # The AT_HWCAP entries are generated by glibc, and are based on
1677 # functions supported by the hardware/system/libc.
1678 # Subsequent support for whether the capability will actually be utilized
1679 # will also be checked against the compiler capabilities.
1680 # called as
1681 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1682 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1683   AUXV_CHECK_FOR=$1
1684   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1685   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1686   then
1687     AC_MSG_RESULT([yes])
1688     AC_SUBST([$2],[yes])
1689   else
1690     AC_MSG_RESULT([no])
1691     AC_SUBST([$2],[])
1692   fi
1695 # gather hardware capabilities. (hardware/kernel/libc)
1696 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1697 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1698 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1699 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1700 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1701 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1702 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1703 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1704 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1705 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1707 # ISA Levels
1708 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1709 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1710 # compiler support for isa 2.07 level instructions
1711 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1712 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1713 ]], [[
1714   __asm__ __volatile__("mtvsrd 1,2 ");
1715 ]])], [
1716 ac_asm_have_isa_2_07=yes
1717 AC_MSG_RESULT([yes])
1718 ], [
1719 ac_asm_have_isa_2_07=no
1720 AC_MSG_RESULT([no])
1722 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1723                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1725 # altivec (vsx) support.
1726 # does this compiler support -maltivec and does it have the include file
1727 # <altivec.h> ?
1728 AC_MSG_CHECKING([for Altivec support in the compiler ])
1729 safe_CFLAGS=$CFLAGS
1730 CFLAGS="-maltivec -Werror"
1731 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1732 #include <altivec.h>
1733 ]], [[
1734   vector unsigned int v;
1735 ]])], [
1736 ac_have_altivec=yes
1737 AC_MSG_RESULT([yes])
1738 ], [
1739 ac_have_altivec=no
1740 AC_MSG_RESULT([no])
1742 CFLAGS=$safe_CFLAGS
1743 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1744                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1746 # Check that both: the compiler supports -mvsx and that the assembler
1747 # understands VSX instructions.  If either of those doesn't work,
1748 # conclude that we can't do VSX.
1749 AC_MSG_CHECKING([for VSX compiler flag support])
1750 safe_CFLAGS=$CFLAGS
1751 CFLAGS="-mvsx -Werror"
1752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1753 ]], [[
1754 ]])], [
1755 ac_compiler_supports_vsx_flag=yes
1756 AC_MSG_RESULT([yes])
1757 ], [
1758 ac_compiler_supports_vsx_flag=no
1759 AC_MSG_RESULT([no])
1761 CFLAGS=$safe_CFLAGS
1763 AC_MSG_CHECKING([for VSX support in the assembler ])
1764 safe_CFLAGS=$CFLAGS
1765 CFLAGS="-mvsx -Werror"
1766 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1767 #include <altivec.h>
1768 ]], [[
1769   vector unsigned int v;
1770   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1771 ]])], [
1772 ac_compiler_supports_vsx=yes
1773 AC_MSG_RESULT([yes])
1774 ], [
1775 ac_compiler_supports_vsx=no
1776 AC_MSG_RESULT([no])
1778 CFLAGS=$safe_CFLAGS
1779 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1780                              -a x$ac_compiler_supports_vsx = xyes \
1781                              -a x$HWCAP_HAS_VSX = xyes ])
1783 # DFP (Decimal Float)
1784 # The initial DFP support was added in Power 6.  The dcffix instruction
1785 # support was added in Power 7.
1786 AC_MSG_CHECKING([that assembler knows DFP])
1787 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1788 ]], [[
1789   #ifdef __s390__
1790   __asm__ __volatile__("adtr 1, 2, 3")
1791   #else
1792 __asm__ __volatile__(".machine power7;\n" \
1793   "dadd 1, 2, 3;\n" \
1794   "dcffix 1, 2");
1795   #endif
1796 ]])], [
1797 ac_asm_have_dfp=yes
1798 AC_MSG_RESULT([yes])
1799 ], [
1800 ac_asm_have_dfp=no
1801 AC_MSG_RESULT([no])
1803 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1804 safe_CFLAGS=$CFLAGS
1805 CFLAGS="-mhard-dfp -Werror"
1807 # The dcffix instruction is Power 7
1808 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1809 ]], [[
1810   #ifdef __s390__
1811   __asm__ __volatile__("adtr 1, 2, 3")
1812   #else
1813   __asm__ __volatile__(".machine power7;\n" \
1814   "dadd 1, 2, 3;\n" \
1815   "dcffix 1, 2");
1816   #endif
1817 ]])], [
1818 ac_compiler_have_dfp=yes
1819 AC_MSG_RESULT([yes])
1820 ], [
1821 ac_compiler_have_dfp=no
1822 AC_MSG_RESULT([no])
1824 CFLAGS=$safe_CFLAGS
1825 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1826                           -a x$ac_compiler_have_dfp = xyes \
1827                           -a x$HWCAP_HAS_DFP = xyes )
1829 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1830 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1831 ]], [[
1832   _Decimal64 x = 0.0DD;
1833 ]])], [
1834 ac_compiler_have_dfp_type=yes
1835 AC_MSG_RESULT([yes])
1836 ], [
1837 ac_compiler_have_dfp_type=no
1838 AC_MSG_RESULT([no])
1840 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1841                                   -a x$HWCAP_HAS_DFP = xyes )
1844 # HTM (Hardware Transactional Memory)
1845 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1846 safe_CFLAGS=$CFLAGS
1847 CFLAGS="-mhtm -Werror"
1848 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1849 ]], [[
1850   return 0;
1851 ]])], [
1852 AC_MSG_RESULT([yes])
1853 ac_compiler_supports_htm=yes
1854 ], [
1855 AC_MSG_RESULT([no])
1856 ac_compiler_supports_htm=no
1858 CFLAGS=$safe_CFLAGS
1860 AC_MSG_CHECKING([if compiler can find the htm builtins])
1861 safe_CFLAGS=$CFLAGS
1862 CFLAGS="-mhtm -Werror"
1863  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1864  ]], [[
1865    if (__builtin_tbegin (0))
1866       __builtin_tend (0);
1867  ]])], [
1868  AC_MSG_RESULT([yes])
1869 ac_compiler_sees_htm_builtins=yes
1870  ], [
1871  AC_MSG_RESULT([no])
1872 ac_compiler_sees_htm_builtins=no
1873  ])
1874 CFLAGS=$safe_CFLAGS
1876 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1877                                -a x$ac_compiler_sees_htm_builtins = xyes \
1878                                -a x$HWCAP_HAS_HTM = xyes )
1880 # isa 3.0 checking. (actually 3.0 or newer)
1881 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1883 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1884 ]], [[
1885 __asm__ __volatile__ (".machine power9;\n" \
1886         "cnttzw   1,3; \n" );
1887 ]])], [
1888 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1889 # cpabort support
1890 safe_CFLAGS=$CFLAGS
1891 CFLAGS="-DHAS_ISA_3_00"
1892 ac_asm_have_isa_3_00=yes
1893 AC_MSG_RESULT([yes])
1894 ], [
1895 ac_asm_have_isa_3_00=no
1896 AC_MSG_RESULT([no])
1898 CFLAGS=$safe_CFLAGS
1900 # xscvhpdp checking
1901 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1903 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1904 ]], [[
1905 __asm__ __volatile__ (".machine power9;\n" \
1906         "xscvhpdp 1,2;\n" );
1907 ]])], [
1908 ac_asm_have_xscvhpdp=yes
1909 AC_MSG_RESULT([yes])
1910 ], [
1911 ac_asm_have_xscvhpdp=no
1912 AC_MSG_RESULT([no])
1915 # darn instruction checking
1916 AC_MSG_CHECKING([that assembler knows darn instruction ])
1918 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1919 ]], [[
1920   __asm__ __volatile__(".machine power9; darn 1,0 ");
1921 ]])], [
1922 ac_asm_have_darn_inst=yes
1923 AC_MSG_RESULT([yes])
1924 ], [
1925 ac_asm_have_darn_inst=no
1926 AC_MSG_RESULT([no])
1929 # isa 3.01 checking
1930 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1931 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1932 ]], [[
1933 __asm__ __volatile__ (".machine power10;\n" \
1934         "brh 1,2;\n ");
1935 ]])], [
1936 ac_asm_have_isa_3_1=yes
1937 AC_MSG_RESULT([yes])
1938 ], [
1939 ac_asm_have_isa_3_1=no
1940 AC_MSG_RESULT([no])
1944 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1945                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1947 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1948 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1950 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1951                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1953 # Check for pthread_create@GLIBC2.0
1954 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1956 safe_CFLAGS=$CFLAGS
1957 CFLAGS="-lpthread -Werror"
1958 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1959 extern int pthread_create_glibc_2_0(void*, const void*,
1960                                     void *(*)(void*), void*);
1961 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1962 ]], [[
1963 #ifdef __powerpc__
1965  * Apparently on PowerPC linking this program succeeds and generates an
1966  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1967  */
1968 #error This test does not work properly on PowerPC.
1969 #else
1970   pthread_create_glibc_2_0(0, 0, 0, 0);
1971 #endif
1972   return 0;
1973 ]])], [
1974 ac_have_pthread_create_glibc_2_0=yes
1975 AC_MSG_RESULT([yes])
1976 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1977           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1978 ], [
1979 ac_have_pthread_create_glibc_2_0=no
1980 AC_MSG_RESULT([no])
1982 CFLAGS=$safe_CFLAGS
1984 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1985                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1988 # Check for dlinfo RTLD_DI_TLS_MODID
1989 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1991 safe_LIBS="$LIBS"
1992 LIBS="-ldl"
1993 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1994 #ifndef _GNU_SOURCE
1995 #define _GNU_SOURCE
1996 #endif
1997 #include <link.h>
1998 #include <dlfcn.h>
1999 ]], [[
2000   size_t sizes[10000];
2001   size_t modid_offset;
2002   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
2003   return 0;
2004 ]])], [
2005 ac_have_dlinfo_rtld_di_tls_modid=yes
2006 AC_MSG_RESULT([yes])
2007 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
2008           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
2009 ], [
2010 ac_have_dlinfo_rtld_di_tls_modid=no
2011 AC_MSG_RESULT([no])
2013 LIBS=$safe_LIBS
2015 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
2016                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
2019 # Check for eventfd_t, eventfd() and eventfd_read()
2020 AC_MSG_CHECKING([for eventfd()])
2022 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2023 #include <sys/eventfd.h>
2024 ]], [[
2025   eventfd_t ev;
2026   int fd;
2028   fd = eventfd(5, 0);
2029   eventfd_read(fd, &ev);
2030   return 0;
2031 ]])], [
2032 AC_MSG_RESULT([yes])
2033 AC_DEFINE([HAVE_EVENTFD], 1,
2034           [Define to 1 if you have the `eventfd' function.])
2035 AC_DEFINE([HAVE_EVENTFD_READ], 1,
2036           [Define to 1 if you have the `eventfd_read' function.])
2037 ], [
2038 AC_MSG_RESULT([no])
2041 # Check whether compiler can process #include <thread> without errors
2042 # clang 3.3 cannot process <thread> from e.g.
2043 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
2045 AC_MSG_CHECKING([that C++ compiler can compile C++17 code])
2046 AC_LANG(C++)
2047 safe_CXXFLAGS=$CXXFLAGS
2048 CXXFLAGS=-std=c++17
2050 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2051 int x;
2052 ])],
2054 ac_have_cxx_17=yes
2055 AC_MSG_RESULT([yes])
2056 ], [
2057 ac_have_cxx_17=no
2058 AC_MSG_RESULT([no])
2060 CXXFLAGS=$safe_CXXFLAGS
2061 AC_LANG(C)
2063 AM_CONDITIONAL(HAVE_CXX17, test x$ac_have_cxx_17 = xyes)
2065 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
2066 AC_LANG(C++)
2067 safe_CXXFLAGS=$CXXFLAGS
2068 CXXFLAGS=-std=c++0x
2070 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2071 #include <thread> 
2072 ])],
2074 ac_cxx_can_include_thread_header=yes
2075 AC_MSG_RESULT([yes])
2076 ], [
2077 ac_cxx_can_include_thread_header=no
2078 AC_MSG_RESULT([no])
2080 CXXFLAGS=$safe_CXXFLAGS
2081 AC_LANG(C)
2083 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2085 # Check whether compiler can process #include <condition_variable> without errors
2087 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2088 AC_LANG(C++)
2089 safe_CXXFLAGS=$CXXFLAGS
2090 CXXFLAGS=-std=c++0x
2092 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2093 #include <condition_variable> 
2094 ])],
2096 ac_cxx_can_include_condition_variable_header=yes
2097 AC_MSG_RESULT([yes])
2098 ], [
2099 ac_cxx_can_include_condition_variable_header=no
2100 AC_MSG_RESULT([no])
2102 CXXFLAGS=$safe_CXXFLAGS
2103 AC_LANG(C)
2105 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2107 # check for std::shared_timed_mutex, this is a C++ 14 feature
2109 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2110 AC_LANG(C++)
2111 safe_CXXFLAGS=$CXXFLAGS
2112 CXXFLAGS="-std=c++1y -pthread"
2114 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2115 #include <shared_mutex>
2116 std::shared_timed_mutex test_mutex;
2117 ])],
2119 ac_cxx_can_use_shared_timed_mutex=yes
2120 AC_MSG_RESULT([yes])
2121 ], [
2122 ac_cxx_can_use_shared_timed_mutex=no
2123 AC_MSG_RESULT([no])
2125 CXXFLAGS=$safe_CXXFLAGS
2126 AC_LANG(C)
2128 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2130 # check for std::shared_mutex, this is a C++ 11 feature
2132 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2133 AC_LANG(C++)
2134 safe_CXXFLAGS=$CXXFLAGS
2135 CXXFLAGS="-std=c++0x -pthread"
2137 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2138 #include <mutex>
2139 std::timed_mutex test_mutex;
2140 ])],
2142 ac_cxx_can_use_timed_mutex=yes
2143 AC_MSG_RESULT([yes])
2144 ], [
2145 ac_cxx_can_use_timed_mutex=no
2146 AC_MSG_RESULT([no])
2148 CXXFLAGS=$safe_CXXFLAGS
2149 AC_LANG(C)
2151 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2153 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2154 # of the user_regs_struct from sys/user.h. They are structurally the same
2155 # but we get either one or the other.
2157 AC_CHECK_TYPE([struct user_regs_struct],
2158               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2159               [[#include <sys/ptrace.h>]
2160                [#include <sys/time.h>]
2161                [#include <sys/user.h>]])
2162 if test "$sys_user_has_user_regs" = "yes"; then
2163   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2164             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2167 AC_MSG_CHECKING([for __NR_membarrier])
2168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2169 #include <linux/unistd.h>
2170 ]], [[
2171 return __NR_membarrier
2172 ]])], [
2173 ac_have_nr_membarrier=yes
2174 AC_MSG_RESULT([yes])
2175 ], [
2176 ac_have_nr_membarrier=no
2177 AC_MSG_RESULT([no])
2180 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2182 #----------------------------------------------------------------------------
2183 # Checking for supported compiler flags.
2184 #----------------------------------------------------------------------------
2186 case "${host_cpu}" in
2187     mips*)
2188         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2189         if test -z "$ARCH"; then
2190           # does this compiler support -march=mips32 (mips32 default) ?
2191           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2193           safe_CFLAGS=$CFLAGS
2194           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2196           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2197             return 0;
2198           ]])], [
2199           FLAG_M32="-mips32 -mabi=32"
2200           AC_MSG_RESULT([yes])
2201           ], [
2202           FLAG_M32=""
2203           AC_MSG_RESULT([no])
2204           ])
2205           CFLAGS=$safe_CFLAGS
2207           AC_SUBST(FLAG_M32)
2210           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2211           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2213           safe_CFLAGS=$CFLAGS
2214           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2216           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2217             return 0;
2218           ]])], [
2219           FLAG_M64="-march=mips64r2 -mabi=64"
2220           AC_MSG_RESULT([yes])
2221           ], [
2222           FLAG_M64=""
2223           AC_MSG_RESULT([no])
2224           ])
2225           CFLAGS=$safe_CFLAGS
2227           AC_SUBST(FLAG_M64)
2228         fi
2229         ;;
2230     nanomips*)
2231         ;;
2232     *)
2233         # does this compiler support -m32 ?
2234         AC_MSG_CHECKING([if gcc accepts -m32])
2236         safe_CFLAGS=$CFLAGS
2237         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2239         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2240           return 0;
2241         ]])], [
2242         FLAG_M32="${FLAG_32ON64} -m32"
2243         AC_MSG_RESULT([yes])
2244         ], [
2245         FLAG_M32=""
2246         AC_MSG_RESULT([no])
2247         ])
2248         CFLAGS=$safe_CFLAGS
2250         AC_SUBST(FLAG_M32)
2253         # does this compiler support -m64 ?
2254         AC_MSG_CHECKING([if gcc accepts -m64])
2256         safe_CFLAGS=$CFLAGS
2257         CFLAGS="-m64 -Werror"
2259         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2260           return 0;
2261         ]])], [
2262         FLAG_M64="-m64"
2263         AC_MSG_RESULT([yes])
2264         ], [
2265         FLAG_M64=""
2266         AC_MSG_RESULT([no])
2267         ])
2268         CFLAGS=$safe_CFLAGS
2270         AC_SUBST(FLAG_M64)
2271         ;;
2272 esac
2275 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2276 if test -z "$ARCH"; then
2277   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2278   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2280   safe_CFLAGS=$CFLAGS
2281   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2283   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2284     return 0;
2285   ]])], [
2286   FLAG_OCTEON="-march=octeon"
2287   AC_MSG_RESULT([yes])
2288   ], [
2289   FLAG_OCTEON=""
2290   AC_MSG_RESULT([no])
2291   ])
2292   CFLAGS=$safe_CFLAGS
2294   AC_SUBST(FLAG_OCTEON)
2297   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2298   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2300   safe_CFLAGS=$CFLAGS
2301   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2303   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2304     return 0;
2305   ]])], [
2306   FLAG_OCTEON2="-march=octeon2"
2307   AC_MSG_RESULT([yes])
2308   ], [
2309   FLAG_OCTEON2=""
2310   AC_MSG_RESULT([no])
2311   ])
2312   CFLAGS=$safe_CFLAGS
2314   AC_SUBST(FLAG_OCTEON2)
2318 # does this compiler support -mmsa (MIPS MSA ASE) ?
2319 AC_MSG_CHECKING([if gcc accepts -mmsa])
2321 safe_CFLAGS=$CFLAGS
2322 CFLAGS="$CFLAGS -mmsa -Werror"
2324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2325     return 0;
2326 ]])], [
2327 FLAG_MSA="-mmsa"
2328 AC_MSG_RESULT([yes])
2329 ], [
2330 FLAG_MSA=""
2331 AC_MSG_RESULT([no])
2333 CFLAGS=$safe_CFLAGS
2335 AC_SUBST(FLAG_MSA)
2337 # Are we compiling for the MIPS64 n32 ABI?
2338 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2339 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2340 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2341 #error NO
2342 #endif
2343 ]])], [
2344 VGCONF_ABI=N32
2345 FLAG_M64="-march=mips64r2 -mabi=n32"
2346 AC_MSG_RESULT([yes])
2347 ], [
2348 AC_MSG_RESULT([no])
2351 # Are we compiling for the MIPS64 n64 ABI?
2352 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2353 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2354 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2355 #error NO
2356 #endif
2357 ]])], [
2358 VGCONF_ABI=64
2359 AC_MSG_RESULT([yes])
2360 ], [
2361 AC_MSG_RESULT([no])
2364 # We enter the code block below in the following case:
2365 # Target architecture is set to mips64, the desired abi
2366 # was not specified and the compiler's default abi setting
2367 # is neither n32 nor n64.
2368 # Probe for and set the abi to either n64 or n32, in that order,
2369 # which is required for a mips64 build of valgrind.
2370 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2371   safe_CFLAGS=$CFLAGS
2372   CFLAGS="$CFLAGS -mabi=64 -Werror"
2373   AC_MSG_CHECKING([if gcc is n64 capable])
2374   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2375       return 0;
2376   ]])], [
2377   VGCONF_ABI=64
2378   AC_MSG_RESULT([yes])
2379   ], [
2380   AC_MSG_RESULT([no])
2381   ])
2382   CFLAGS=$safe_CFLAGS
2384   if test "x$VGCONF_ABI" = "x"; then
2385     safe_CFLAGS=$CFLAGS
2386     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2387     AC_MSG_CHECKING([if gcc is n32 capable])
2388     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2389         return 0;
2390     ]])], [
2391     VGCONF_ABI=N32
2392     FLAG_M64="-march=mips64r2 -mabi=n32"
2393     AC_MSG_RESULT([yes])
2394     ], [
2395     AC_MSG_RESULT([no])
2396     ])
2397     CFLAGS=$safe_CFLAGS
2398   fi
2401 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2402                [test x$VGCONF_ABI != x])
2403 AC_SUBST(VGCONF_ABI)
2406 # does this compiler support -mmmx ?
2407 AC_MSG_CHECKING([if gcc accepts -mmmx])
2409 safe_CFLAGS=$CFLAGS
2410 CFLAGS="-mmmx -Werror"
2412 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2413   return 0;
2414 ]])], [
2415 FLAG_MMMX="-mmmx"
2416 AC_MSG_RESULT([yes])
2417 ], [
2418 FLAG_MMMX=""
2419 AC_MSG_RESULT([no])
2421 CFLAGS=$safe_CFLAGS
2423 AC_SUBST(FLAG_MMMX)
2426 # does this compiler support -msse ?
2427 AC_MSG_CHECKING([if gcc accepts -msse])
2429 safe_CFLAGS=$CFLAGS
2430 CFLAGS="-msse -Werror"
2432 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2433   return 0;
2434 ]])], [
2435 FLAG_MSSE="-msse"
2436 AC_MSG_RESULT([yes])
2437 ], [
2438 FLAG_MSSE=""
2439 AC_MSG_RESULT([no])
2441 CFLAGS=$safe_CFLAGS
2443 AC_SUBST(FLAG_MSSE)
2446 # does this compiler support -mpreferred-stack-boundary=2 when
2447 # generating code for a 32-bit target?  Note that we only care about
2448 # this when generating code for (32-bit) x86, so if the compiler
2449 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2450 # the Memcheck and other helper functions, that is a bit slower than
2451 # it could be, on x86; and no difference at all on any other platform.
2452 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2454 safe_CFLAGS=$CFLAGS
2455 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2457 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2458   return 0;
2459 ]])], [
2460 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2461 AC_MSG_RESULT([yes])
2462 ], [
2463 PREFERRED_STACK_BOUNDARY_2=""
2464 AC_MSG_RESULT([no])
2466 CFLAGS=$safe_CFLAGS
2468 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2471 # does this compiler support -mlong-double-128 ?
2472 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2473 safe_CFLAGS=$CFLAGS
2474 CFLAGS="-mlong-double-128 -Werror"
2475 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2476   return 0;
2477 ]])], [
2478 ac_compiler_supports_mlong_double_128=yes
2479 AC_MSG_RESULT([yes])
2480 ], [
2481 ac_compiler_supports_mlong_double_128=no
2482 AC_MSG_RESULT([no])
2484 CFLAGS=$safe_CFLAGS
2485 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2486 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2487 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2489 # does this toolchain support lto ?
2490 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2491 # are not defined
2492 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2493 # a lot slower, and so not appropriate for Valgrind developments.
2494 # --enable-lto=yes should be used by distro packagers.
2495 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2496    [AC_ARG_ENABLE(lto,
2497       [  --enable-lto          enables building with link time optimisation],
2498       [vg_cv_lto=$enableval],
2499       [vg_cv_lto=no])])
2501 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2502 AC_MSG_CHECKING([if toolchain accepts lto])
2503 safe_CFLAGS=$CFLAGS
2504 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2505 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2506 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2507 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2509 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2510   extern void somefun(void);
2511   somefun();
2512   return 0;
2513 ]])], [
2514 LTO_CFLAGS=$TEST_LTO_CFLAGS
2515 AC_MSG_RESULT([yes])
2516 ], [
2517 LTO_CFLAGS=""
2518 AC_MSG_RESULT([no])
2520 CFLAGS=$safe_CFLAGS
2523 AC_SUBST(LTO_CFLAGS)
2525 # if we could not compile with lto args, or lto was disabled,
2526 # then set LTO_AR/LTO_RANLIB to the non lto values
2527 # define in config.h ENABLE_LTO (not needed by the code currently, but
2528 # this guarantees we recompile everything if we re-configure and rebuild
2529 # in a build dir previously build with another value of --enable-lto
2530 if test "x${LTO_CFLAGS}" = "x"; then
2531    LTO_AR=${AR}
2532    LTO_RANLIB=${RANLIB}
2533    vg_cv_lto=no
2534 else
2535    vg_cv_lto=yes
2536    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2539 # Convenience function to check whether GCC supports a particular
2540 # warning option. Takes two arguments,
2541 # first the warning flag name to check (without -W), then the
2542 # substitution name to set with -Wno-warning-flag if the flag exists,
2543 # or the empty string if the compiler doesn't accept the flag. Note
2544 # that checking is done against the warning flag itself, but the
2545 # substitution is then done to cancel the warning flag.
2546 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2547   AC_MSG_CHECKING([if gcc accepts -W$1])
2548   safe_CFLAGS=$CFLAGS
2549   CFLAGS="-W$1 -Werror"
2550   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2551   AC_SUBST([$2], [-Wno-$1])
2552   AC_MSG_RESULT([yes])], [
2553   AC_SUBST([$2], [])
2554   AC_MSG_RESULT([no])])
2555   CFLAGS=$safe_CFLAGS
2558 # A variation of the above for arguments that
2559 # take a value
2560 AC_DEFUN([AC_GCC_WARNING_SUBST_NO_VAL],[
2561   AC_MSG_CHECKING([if gcc accepts -W$1=$2])
2562   safe_CFLAGS=$CFLAGS
2563   CFLAGS="-W$1=$2 -Werror"
2564   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2565   AC_SUBST([$3], [-Wno-$1])
2566   AC_MSG_RESULT([yes])], [
2567   AC_SUBST([$3], [])
2568   AC_MSG_RESULT([no])])
2569   CFLAGS=$safe_CFLAGS
2572 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2573 # -W$1  (instead of -Wno-$1).
2574 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2575   AC_MSG_CHECKING([if gcc accepts -W$1])
2576   safe_CFLAGS=$CFLAGS
2577   CFLAGS="-W$1 -Werror"
2578   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2579   AC_SUBST([$2], [-W$1])
2580   AC_MSG_RESULT([yes])], [
2581   AC_SUBST([$2], [])
2582   AC_MSG_RESULT([no])])
2583   CFLAGS=$safe_CFLAGS
2586 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2587 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2588 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2589 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2590 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2591 AC_GCC_WARNING_SUBST_NO([maybe-uninitialized], [FLAG_W_NO_MAYBE_UNINITIALIZED])
2592 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2593 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2594 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2595 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2596 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2597 AC_GCC_WARNING_SUBST_NO([unused-variable], [FLAG_W_NO_UNUSED_VARIABLE])
2598 AC_GCC_WARNING_SUBST_NO([unused-but-set-variable], [FLAG_W_NO_UNUSED_BUT_SET_VARIABLE])
2599 AC_GCC_WARNING_SUBST_NO([non-power-of-two-alignment], [FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT])
2600 AC_GCC_WARNING_SUBST_NO([sign-compare], [FLAG_W_NO_SIGN_COMPARE])
2601 AC_GCC_WARNING_SUBST_NO([stringop-overflow], [FLAG_W_NO_STRINGOP_OVERFLOW])
2602 AC_GCC_WARNING_SUBST_NO([stringop-overread], [FLAG_W_NO_STRINGOP_OVERREAD])
2603 AC_GCC_WARNING_SUBST_NO([stringop-truncation], [FLAG_W_NO_STRINGOP_TRUNCATION])
2604 AC_GCC_WARNING_SUBST_NO([format-overflow], [FLAG_W_NO_FORMAT_OVERFLOW])
2605 AC_GCC_WARNING_SUBST_NO([use-after-free], [FLAG_W_NO_USE_AFTER_FREE])
2606 AC_GCC_WARNING_SUBST_NO([free-nonheap-object], [FLAG_W_NO_FREE_NONHEAP_OBJECT])
2607 AC_GCC_WARNING_SUBST_NO([fortify-source], [FLAG_W_NO_FORTIFY_SOURCE])
2608 AC_GCC_WARNING_SUBST_NO([builtin-memcpy-chk-size], [FLAG_W_NO_BUILTIN_MEMCPY_CHK_SIZE])
2609 AC_GCC_WARNING_SUBST_NO([incompatible-pointer-types-discards-qualifiers], [FLAG_W_NO_INCOMPATIBLE_POINTER_TYPES_DISCARDS_QUALIFIERS])
2610 AC_GCC_WARNING_SUBST_NO([suspicious-bzero], [FLAG_W_NO_SUSPICIOUS_BZERO])
2611 AC_GCC_WARNING_SUBST_NO([attributes], [FLAG_W_NO_ATTRIBUTES])
2613 AC_GCC_WARNING_SUBST_NO_VAL([alloc-size-larger-than], [1677216], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN])
2615 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2616 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2617 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2618 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2619 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2620 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2621 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2622 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2623 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2624 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2625 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2627 # Does this compiler support -Wformat-security ?
2628 # Special handling is needed, because certain GCC versions require -Wformat
2629 # being present if -Wformat-security is given. Otherwise a warning is issued.
2630 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2631 # And with that the warning will be turned into an error with the result
2632 # that -Wformat-security is believed to be unsupported when in fact it is.
2633 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2634 safe_CFLAGS=$CFLAGS
2635 CFLAGS="-Wformat -Wformat-security -Werror"
2636 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2637 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2638 AC_MSG_RESULT([yes])], [
2639 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2640 AC_MSG_RESULT([no])])
2641 CFLAGS=$safe_CFLAGS
2643 # does this compiler support -Wextra or the older -W ?
2645 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2647 safe_CFLAGS=$CFLAGS
2648 CFLAGS="-Wextra -Werror"
2650 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2651   return 0;
2652 ]])], [
2653 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2654 AC_MSG_RESULT([-Wextra])
2655 ], [
2656   CFLAGS="-W -Werror"
2657   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2658     return 0;
2659   ]])], [
2660   AC_SUBST([FLAG_W_EXTRA], [-W])
2661   AC_MSG_RESULT([-W])
2662   ], [
2663   AC_SUBST([FLAG_W_EXTRA], [])
2664   AC_MSG_RESULT([not supported])
2665   ])
2667 CFLAGS=$safe_CFLAGS
2669 # On ARM we do not want to pass -Wcast-align as that produces loads
2670 # of warnings. GCC is just being conservative. See here:
2671 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2672 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2673   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2674 else
2675   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2678 # does this compiler support -faligned-new ?
2679 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2681 safe_CXXFLAGS=$CXXFLAGS
2682 CXXFLAGS="-faligned-new -Werror"
2684 AC_LANG(C++)
2685 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2686   return 0;
2687 ]])], [
2688 FLAG_FALIGNED_NEW="-faligned-new"
2689 AC_MSG_RESULT([yes])
2690 ], [
2691 FLAG_FALIGNED_NEW=""
2692 AC_MSG_RESULT([no])
2694 CXXFLAGS=$safe_CXXFLAGS
2695 AC_LANG(C)
2697 AC_SUBST(FLAG_FALIGNED_NEW)
2699 # does this compiler support -fsized-deallocation ?
2700 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2702 safe_CXXFLAGS=$CXXFLAGS
2703 CXXFLAGS="-fsized-deallocation -Werror"
2705 AC_LANG(C++)
2706 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2707   return 0;
2708 ]])], [
2709 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2710 ac_have_sized_deallocation=yes
2711 AC_MSG_RESULT([yes])
2712 ], [
2713 FLAG_FSIZED_DEALLOCATION=""
2714 ac_have_sized_deallocation=no
2715 AC_MSG_RESULT([no])
2717 CXXFLAGS=$safe_CXXFLAGS
2718 AC_LANG(C)
2720 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2721 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2723 # does this compiler support C++17 aligned new/delete?
2724 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2726 safe_CXXFLAGS=$CXXFLAGS
2727 CXXFLAGS="-std=c++17"
2729 AC_LANG(C++)
2730 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2731 #include <cstdlib>
2732 #include <new>
2733 ]], [[
2734   operator delete(nullptr, std::align_val_t(64U));
2735 ]])], [
2736 ac_have_aligned_cxx_alloc=yes
2737 AC_MSG_RESULT([yes])
2738 ], [
2739 ac_have_aligned_cxx_alloc=no
2740 AC_MSG_RESULT([no])
2742 CXXFLAGS=$safe_CXXFLAGS
2743 AC_LANG(C)
2745 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2747 # does this compiler support -fno-stack-protector ?
2748 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2750 safe_CFLAGS=$CFLAGS
2751 CFLAGS="-fno-stack-protector -Werror"
2753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2754   return 0;
2755 ]])], [
2756 no_stack_protector=yes
2757 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2758 AC_MSG_RESULT([yes])
2759 ], [
2760 no_stack_protector=no
2761 FLAG_FNO_STACK_PROTECTOR=""
2762 AC_MSG_RESULT([no])
2764 CFLAGS=$safe_CFLAGS
2766 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2768 # does this compiler support -finline-functions ?
2769 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2771 safe_CFLAGS=$CFLAGS
2772 CFLAGS="-finline-functions -Werror"
2774 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2775   return 0;
2776 ]])], [
2777 inline_functions=yes
2778 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2779 AC_MSG_RESULT([yes])
2780 ], [
2781 inline_functions=no
2782 FLAG_FINLINE_FUNCTIONS=""
2783 AC_MSG_RESULT([no])
2785 CFLAGS=$safe_CFLAGS
2787 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2789 # Does GCC support disabling Identical Code Folding?
2790 # We want to disabled Identical Code Folding for the
2791 # tools preload shared objects to get better backraces.
2792 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2793 # "The optimization reduces code size and may disturb
2794 #  unwind stacks by replacing a function by equivalent
2795 #  one with a different name."
2796 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2798 safe_CFLAGS=$CFLAGS
2799 CFLAGS="-fno-ipa-icf -Werror"
2801 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2802   return 0;
2803 ]])], [
2804 no_ipa_icf=yes
2805 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2806 AC_MSG_RESULT([yes])
2807 ], [
2808 no_ipa_icf=no
2809 FLAG_FNO_IPA_ICF=""
2810 AC_MSG_RESULT([no])
2812 CFLAGS=$safe_CFLAGS
2814 AC_SUBST(FLAG_FNO_IPA_ICF)
2817 # Does this compiler support -fsanitize=undefined. This is true for
2818 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2819 # also checks for alignment violations on memory accesses which the valgrind
2820 # code base is sprinkled (if not littered) with. As those alignment issues
2821 # don't pose a problem we want to suppress warnings about them.
2822 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2823 # GCCs do not support that.
2825 # Only checked for if --enable-ubsan was given.
2826 if test "x${vg_cv_ubsan}" = "xyes"; then
2827 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2828 safe_CFLAGS=$CFLAGS
2829 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2830 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2831   return 0;
2832 ]])], [
2833 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2834 LIB_UBSAN="-static-libubsan"
2835 AC_MSG_RESULT([yes])
2836 ], [
2837 CFLAGS="-fsanitize=undefined -Werror"
2838 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2839   return 0;
2840 ]])], [
2841 FLAG_FSANITIZE="-fsanitize=undefined"
2842 LIB_UBSAN="-static-libubsan"
2843 AC_MSG_RESULT([yes])
2844 ], [
2845 FLAG_FSANITIZE=""
2846 LIB_UBSAN=""
2847 AC_MSG_RESULT([no])
2850 CFLAGS=$safe_CFLAGS
2851 AC_SUBST(FLAG_FSANITIZE)
2852 AC_SUBST(LIB_UBSAN)
2854 # does this compiler support --param inline-unit-growth=... ?
2856 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2858 safe_CFLAGS=$CFLAGS
2859 CFLAGS="--param inline-unit-growth=900 -Werror"
2861 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2862   return 0;
2863 ]])], [
2864 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2865          ["--param inline-unit-growth=900"])
2866 AC_MSG_RESULT([yes])
2867 ], [
2868 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2869 AC_MSG_RESULT([no])
2871 CFLAGS=$safe_CFLAGS
2874 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2876 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2878 safe_CFLAGS=$CFLAGS
2879 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2881 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2882   return 0;
2883 ]])], [
2884 ac_have_dwarf4=yes
2885 AC_MSG_RESULT([yes])
2886 ], [
2887 ac_have_dwarf4=no
2888 AC_MSG_RESULT([no])
2890 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2891 CFLAGS=$safe_CFLAGS
2894 # does this compiler support -g -gz=zlib ?
2896 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2898 safe_CFLAGS=$CFLAGS
2899 CFLAGS="-g -gz=zlib"
2901 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2902   return 0;
2903 ]])], [
2904 ac_have_gz_zlib=yes
2905 AC_MSG_RESULT([yes])
2906 ], [
2907 ac_have_gz_zlib=no
2908 AC_MSG_RESULT([no])
2910 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2911 CFLAGS=$safe_CFLAGS
2914 # does this compiler support -g -gz=zlib-gnu ?
2916 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2918 safe_CFLAGS=$CFLAGS
2919 CFLAGS="-g -gz=zlib-gnu"
2921 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2922   return 0;
2923 ]])], [
2924 ac_have_gz_zlib_gnu=yes
2925 AC_MSG_RESULT([yes])
2926 ], [
2927 ac_have_gz_zlib_gnu=no
2928 AC_MSG_RESULT([no])
2930 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2931 CFLAGS=$safe_CFLAGS
2934 # does this compiler support nested functions ?
2936 AC_MSG_CHECKING([if gcc accepts nested functions])
2938 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2939   int foo() { return 1; }
2940   return foo();
2941 ]])], [
2942 ac_have_nested_functions=yes
2943 AC_MSG_RESULT([yes])
2944 ], [
2945 ac_have_nested_functions=no
2946 AC_MSG_RESULT([no])
2948 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2951 # does this compiler support the 'p' constraint in ASM statements ?
2953 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2955 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2956    char *p;
2957    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2958 ]])], [
2959 ac_have_asm_constraint_p=yes
2960 AC_MSG_RESULT([yes])
2961 ], [
2962 ac_have_asm_constraint_p=no
2963 AC_MSG_RESULT([no])
2965 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2968 # Does this compiler and linker support -pie?
2969 # Some compilers actually do not support -pie and report its usage
2970 # as an error. We need to check if it is safe to use it first.
2972 AC_MSG_CHECKING([if gcc accepts -pie])
2974 safe_CFLAGS=$CFLAGS
2975 CFLAGS="-pie"
2977 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2978   return 0;
2979 ]])], [
2980 AC_SUBST([FLAG_PIE], ["-pie"])
2981 AC_MSG_RESULT([yes])
2982 ], [
2983 AC_SUBST([FLAG_PIE], [""])
2984 AC_MSG_RESULT([no])
2986 CFLAGS=$safe_CFLAGS
2988 AC_MSG_CHECKING([if gcc accepts -ansi])
2990 safe_CFLAGS=$CFLAGS
2991 CFLAGS="-ansi"
2993 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2994    return 0;
2995 ]])], [
2996 ac_have_ansi=yes
2997 AC_MSG_RESULT([yes])
2998 ], [
2999 ac_have_ansi=no
3000 AC_MSG_RESULT([no])
3002 AM_CONDITIONAL([HAVE_ANSI], [test x$ac_have_ansi = xyes])
3004 CFLAGS=$safe_CFLAGS
3007 # Does this compiler support -no-pie?
3008 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
3009 # default. However this gets in the way with some tests, we use -no-pie
3010 # for these.
3012 AC_MSG_CHECKING([if gcc accepts -no-pie])
3014 safe_CFLAGS=$CFLAGS
3015 CFLAGS="-no-pie -Werror"
3017 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
3018   return 0;
3019 ]])], [
3020 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
3021 AC_MSG_RESULT([yes])
3022 ], [
3023 AC_SUBST([FLAG_NO_PIE], [""])
3024 AC_MSG_RESULT([no])
3026 CFLAGS=$safe_CFLAGS
3029 # We want to use use the -Ttext-segment option to the linker.
3030 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
3031 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
3032 # semantics are NOT what we want (GNU gold -Ttext is fine).
3034 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
3035 # will reside. -Ttext aligns just the .text section start (but not any
3036 # other section).
3038 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
3039 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
3040 # The --image-base option (since version 6.0?) provides the semantics needed.
3041 # -Ttext-segment generates an error, but -Ttext now more closely
3042 # follows the GNU (bfd) ld's -Ttext.
3044 # So test first for --image-base support, and if that fails then
3045 # for -Ttext-segment which is supported by all bfd ld versions
3046 # and use that if it exists. If it doesn't exist it must be an older
3047 # version of gold and we can fall back to using -Ttext which has the
3048 # right semantics.
3050 safe_CFLAGS=$CFLAGS
3051 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
3053 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
3055 AC_LINK_IFELSE(
3056 [AC_LANG_SOURCE([int _start () { return 0; }])],
3058   linker_using_t_text="no"
3059   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
3060   AC_MSG_RESULT([yes])
3061 ], [
3062   AC_MSG_RESULT([no])
3064   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
3066   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
3068   AC_LINK_IFELSE(
3069   [AC_LANG_SOURCE([int _start () { return 0; }])],
3070   [
3071     linker_using_t_text="no"
3072     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
3073     AC_MSG_RESULT([yes])
3074   ], [
3075     linker_using_t_text="yes"
3076     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
3077     AC_MSG_RESULT([no])
3078   ])
3081 CFLAGS=$safe_CFLAGS
3083 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
3084 # have to strip any build-id ELF NOTEs from the statically linked tools.
3085 # Otherwise the build-id NOTE might end up at the default load address.
3086 # (Pedantically if the linker is gold then -Ttext is fine, but newer
3087 # gold versions also support -Ttext-segment. So just assume that unless
3088 # we can use -Ttext-segment we need to strip the build-id NOTEs.
3089 if test "x${linker_using_t_text}" = "xyes"; then
3090 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
3091 # does the linker support -Wl,--build-id=none ?  Note, it's
3092 # important that we test indirectly via whichever C compiler
3093 # is selected, rather than testing /usr/bin/ld or whatever
3094 # directly.
3095 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
3096 safe_CFLAGS=$CFLAGS
3097 CFLAGS="-Wl,--build-id=none -Werror"
3099 AC_LINK_IFELSE(
3100 [AC_LANG_PROGRAM([ ], [return 0;])],
3102   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
3103   AC_MSG_RESULT([yes])
3104 ], [
3105   AC_SUBST([FLAG_NO_BUILD_ID], [""])
3106   AC_MSG_RESULT([no])
3108 else
3109 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
3110 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3112 CFLAGS=$safe_CFLAGS
3114 # On s390x, if the linker supports -Wl,--s390-pgste, then we build the
3115 # tools with that flag.  This enables running programs that need it, such
3116 # as qemu-kvm.
3117 if test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX; then
3118 AC_MSG_CHECKING([if the linker accepts -Wl,--s390-pgste])
3119 safe_CFLAGS=$CFLAGS
3120 CFLAGS="-Wl,--s390-pgste"
3122 AC_LINK_IFELSE(
3123 [AC_LANG_PROGRAM([ ], [return 0;])],
3125   AC_SUBST([FLAG_S390_PGSTE], ["-Wl,--s390-pgste"])
3126   AC_MSG_RESULT([yes])
3127 ], [
3128   AC_SUBST([FLAG_S390_PGSTE], [""])
3129   AC_MSG_RESULT([no])
3131 CFLAGS=$safe_CFLAGS
3134 # does the ppc assembler support "mtocrf" et al?
3135 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
3137 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3138 __asm__ __volatile__("mtocrf 4,0");
3139 __asm__ __volatile__("mfocrf 0,4");
3140 ]])], [
3141 ac_have_as_ppc_mftocrf=yes
3142 AC_MSG_RESULT([yes])
3143 ], [
3144 ac_have_as_ppc_mftocrf=no
3145 AC_MSG_RESULT([no])
3147 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3148   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3152 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3153 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3155 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3156   do { typedef struct {
3157       double hi;
3158       double lo;
3159      } dbl_pair_t;
3160      dbl_pair_t dbl_pair[3];
3161      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3162    } while (0)
3163 ]])], [
3164 ac_have_as_ppc_fpPO=yes
3165 AC_MSG_RESULT([yes])
3166 ], [
3167 ac_have_as_ppc_fpPO=no
3168 AC_MSG_RESULT([no])
3170 if test x$ac_have_as_ppc_fpPO = xyes ; then
3171   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3175 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3176 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3178 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3179 void* p;
3180 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3181 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3182 ]])], [
3183 ac_have_as_amd64_fxsave64=yes
3184 AC_MSG_RESULT([yes])
3185 ], [
3186 ac_have_as_amd64_fxsave64=no
3187 AC_MSG_RESULT([no])
3189 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3190   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3193 # does the x86/amd64 assembler understand SSE3 instructions?
3194 # Note, this doesn't generate a C-level symbol.  It generates a
3195 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3196 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3198 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3199   do { long long int x; 
3200      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
3201   while (0)
3202 ]])], [
3203 ac_have_as_sse3=yes
3204 AC_MSG_RESULT([yes])
3205 ], [
3206 ac_have_as_sse3=no
3207 AC_MSG_RESULT([no])
3210 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3213 # Ditto for SSSE3 instructions (note extra S)
3214 # Note, this doesn't generate a C-level symbol.  It generates a
3215 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3216 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3218 save_CFLAGS="$CFLAGS"
3219 CFLAGS="$CFLAGS -msse -Werror"
3220 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3221   do { long long int x; 
3222    __asm__ __volatile__(
3223       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3224   while (0)
3225 ]])], [
3226 ac_have_as_ssse3=yes
3227 AC_MSG_RESULT([yes])
3228 ], [
3229 ac_have_as_ssse3=no
3230 AC_MSG_RESULT([no])
3232 CFLAGS="$save_CFLAGS"
3234 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3237 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3238 # Note, this doesn't generate a C-level symbol.  It generates a
3239 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3240 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3241 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3242   do {
3243    __asm__ __volatile__(
3244       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3245   while (0)
3246 ]])], [
3247 ac_have_as_pclmulqdq=yes
3248 AC_MSG_RESULT([yes])
3249 ], [
3250 ac_have_as_pclmulqdq=no
3251 AC_MSG_RESULT([no])
3254 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3257 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3258 # Note, this doesn't generate a C-level symbol.  It generates a
3259 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3260 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3261 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3262   do {
3263       /*
3264        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3265        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3266        * xmm2 should be used.
3267        */
3268    __asm__ __volatile__(
3269       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3270   } while (0)
3271 ]])], [
3272 ac_have_as_vpclmulqdq=yes
3273 AC_MSG_RESULT([yes])
3274 ], [
3275 ac_have_as_vpclmulqdq=no
3276 AC_MSG_RESULT([no])
3279 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3282 # does the x86/amd64 assembler understand FMA4 instructions?
3283 # Note, this doesn't generate a C-level symbol.  It generates a
3284 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3285 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3286 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3287   do {
3288    __asm__ __volatile__(
3289       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3290   } while (0)
3291 ]])], [
3292 ac_have_as_vfmaddpd=yes
3293 AC_MSG_RESULT([yes])
3294 ], [
3295 ac_have_as_vfmaddpd=no
3296 AC_MSG_RESULT([no])
3299 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3302 # does the x86/amd64 assembler understand the LZCNT instruction?
3303 # Note, this doesn't generate a C-level symbol.  It generates a
3304 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3305 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3307 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3308   do {           
3309       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3310   } while (0)
3311 ]])], [
3312   ac_have_as_lzcnt=yes
3313   AC_MSG_RESULT([yes])
3314 ], [
3315   ac_have_as_lzcnt=no
3316   AC_MSG_RESULT([no])
3319 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3322 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3323 # Note, this doesn't generate a C-level symbol.  It generates a
3324 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3325 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3327 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3328   do {           
3329       __asm__ __volatile__("1:  loopnel 1b\n");
3330   } while (0)
3331 ]])], [
3332   ac_have_as_loopnel=yes
3333   AC_MSG_RESULT([yes])
3334 ], [
3335   ac_have_as_loopnel=no
3336   AC_MSG_RESULT([no])
3339 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3342 # does the x86/amd64 assembler understand ADDR32 ?
3343 # Note, this doesn't generate a C-level symbol.  It generates a
3344 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3345 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3347 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3348   do {           
3349       asm volatile ("addr32 rep movsb");
3350   } while (0)
3351 ]])], [
3352   ac_have_as_addr32=yes
3353   AC_MSG_RESULT([yes])
3354 ], [
3355   ac_have_as_addr32=no
3356   AC_MSG_RESULT([no])
3359 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3362 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3363 # Note, this doesn't generate a C-level symbol.  It generates a
3364 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3365 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3367 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3368   do { long long int x; 
3369    __asm__ __volatile__(
3370       "crc32q %%r15,%%r15" : : : "r15" );
3371    __asm__ __volatile__(
3372       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3373    __asm__ __volatile__(
3374       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3375   while (0)
3376 ]])], [
3377 ac_have_as_sse42=yes
3378 AC_MSG_RESULT([yes])
3379 ], [
3380 ac_have_as_sse42=no
3381 AC_MSG_RESULT([no])
3384 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3387 # does the x86/amd64 assembler understand AVX instructions?
3388 # Note, this doesn't generate a C-level symbol.  It generates a
3389 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3390 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3392 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3393   do { long long int x; 
3394    __asm__ __volatile__(
3395       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3396    __asm__ __volatile__(
3397       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3398   while (0)
3399 ]])], [
3400 ac_have_as_avx=yes
3401 AC_MSG_RESULT([yes])
3402 ], [
3403 ac_have_as_avx=no
3404 AC_MSG_RESULT([no])
3407 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3410 # does the x86/amd64 assembler understand AVX2 instructions?
3411 # Note, this doesn't generate a C-level symbol.  It generates a
3412 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3413 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3415 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3416   do { long long int x; 
3417    __asm__ __volatile__(
3418       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3419    __asm__ __volatile__(
3420       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3421   while (0)
3422 ]])], [
3423 ac_have_as_avx2=yes
3424 AC_MSG_RESULT([yes])
3425 ], [
3426 ac_have_as_avx2=no
3427 AC_MSG_RESULT([no])
3430 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3433 # does the x86/amd64 assembler understand TSX instructions and
3434 # the XACQUIRE/XRELEASE prefixes?
3435 # Note, this doesn't generate a C-level symbol.  It generates a
3436 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3437 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3440   do {
3441    __asm__ __volatile__(
3442       "       xbegin Lfoo  \n\t"
3443       "Lfoo:  xend         \n\t"
3444       "       xacquire lock incq 0(%rsp)     \n\t"
3445       "       xrelease lock incq 0(%rsp)     \n"
3446    );
3447   } while (0)
3448 ]])], [
3449 ac_have_as_tsx=yes
3450 AC_MSG_RESULT([yes])
3451 ], [
3452 ac_have_as_tsx=no
3453 AC_MSG_RESULT([no])
3456 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3459 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3460 # Note, this doesn't generate a C-level symbol.  It generates a
3461 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3462 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3464 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3465   do { unsigned int h, l;
3466    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3467    __asm__ __volatile__(
3468       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3469    __asm__ __volatile__(
3470       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3471   while (0)
3472 ]])], [
3473 ac_have_as_bmi=yes
3474 AC_MSG_RESULT([yes])
3475 ], [
3476 ac_have_as_bmi=no
3477 AC_MSG_RESULT([no])
3480 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3483 # does the x86/amd64 assembler understand FMA instructions?
3484 # Note, this doesn't generate a C-level symbol.  It generates a
3485 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3486 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3488 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3489   do { unsigned int h, l;
3490    __asm__ __volatile__(
3491       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3492    __asm__ __volatile__(
3493       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3494    __asm__ __volatile__(
3495       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3496   while (0)
3497 ]])], [
3498 ac_have_as_fma=yes
3499 AC_MSG_RESULT([yes])
3500 ], [
3501 ac_have_as_fma=no
3502 AC_MSG_RESULT([no])
3505 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3508 # does the amd64 assembler understand MPX instructions?
3509 # Note, this doesn't generate a C-level symbol.  It generates a
3510 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3511 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3513 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3514   do {
3515     asm ("bndmov %bnd0,(%rsp)");
3516     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3517     asm ("bnd call foo\n"
3518          "bnd jmp  end\n"
3519          "foo: bnd ret\n"
3520          "end: nop");
3521   } while (0)
3522 ]])], [
3523 ac_have_as_mpx=yes
3524 AC_MSG_RESULT([yes])
3525 ], [
3526 ac_have_as_mpx=no
3527 AC_MSG_RESULT([no])
3530 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3533 # does the amd64 assembler understand ADX instructions?
3534 # Note, this doesn't generate a C-level symbol.  It generates a
3535 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3536 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3539   do {
3540     asm ("adcxq %r14,%r8");
3541   } while (0)
3542 ]])], [
3543 ac_have_as_adx=yes
3544 AC_MSG_RESULT([yes])
3545 ], [
3546 ac_have_as_adx=no
3547 AC_MSG_RESULT([no])
3550 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3553 # does the amd64 assembler understand the RDRAND instruction?
3554 # Note, this doesn't generate a C-level symbol.  It generates a
3555 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3556 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3558 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3559   do {
3560     asm ("rdrand %r14");
3561     asm ("rdrand %r14d");
3562     asm ("rdrand %r14w");
3563   } while (0)
3564 ]])], [
3565 ac_have_as_rdrand=yes
3566 AC_MSG_RESULT([yes])
3567 ], [
3568 ac_have_as_rdrand=no
3569 AC_MSG_RESULT([no])
3572 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3574 # does the amd64 assembler understand the RDSEED instruction?
3575 # Note, this doesn't generate a C-level symbol.  It generates a
3576 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3577 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3579 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3580   do {
3581     asm ("rdseed %r14");
3582     asm ("rdseed %r14d");
3583     asm ("rdseed %r14w");
3584   } while (0)
3585 ]])], [
3586 ac_have_as_rdseed=yes
3587 AC_MSG_RESULT([yes])
3588 ], [
3589 ac_have_as_rdseed=no
3590 AC_MSG_RESULT([no])
3593 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3595 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3596 # VCVTPS2PH) ?
3597 # Note, this doesn't generate a C-level symbol.  It generates a
3598 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3599 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3601 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3602   do {
3603     asm ("vcvtph2ps %xmm5, %ymm10");
3604     // If we put the dollar sign and zero together, the shell processing
3605     // this configure.ac script substitutes the command name in.  Sigh.
3606     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3607   } while (0)
3608 ]])], [
3609 ac_have_as_f16c=yes
3610 AC_MSG_RESULT([yes])
3611 ], [
3612 ac_have_as_f16c=no
3613 AC_MSG_RESULT([no])
3616 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3619 # does the x86/amd64 assembler understand MOVBE?
3620 # Note, this doesn't generate a C-level symbol.  It generates a
3621 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3622 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3624 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3625   do { long long int x; 
3626    __asm__ __volatile__(
3627       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3628   while (0)
3629 ]])], [
3630 ac_have_as_movbe=yes
3631 AC_MSG_RESULT([yes])
3632 ], [
3633 ac_have_as_movbe=no
3634 AC_MSG_RESULT([no])
3637 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3640 # Does the C compiler support the "ifunc" attribute
3641 # Note, this doesn't generate a C-level symbol.  It generates a
3642 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3643 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3645 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3646 static void mytest(void) {}
3648 static void (*resolve_test(void))(void)
3650     return (void (*)(void))&mytest;
3653 void test(void) __attribute__((ifunc("resolve_test")));
3655 int main()
3657     test();
3658     return 0;
3660 ]])], [
3661 ac_have_ifunc_attr=yes
3662 AC_MSG_RESULT([yes])
3663 ], [
3664 ac_have_ifunc_attr=no
3665 AC_MSG_RESULT([no])
3668 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3670 # Does the C compiler support the armv8 crc feature flag
3671 # Note, this doesn't generate a C-level symbol.  It generates a
3672 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3673 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3675 save_CFLAGS="$CFLAGS"
3676 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3677 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3678 int main()
3680     return 0;
3682 ]])], [
3683 ac_have_armv8_crc_feature=yes
3684 AC_MSG_RESULT([yes])
3685 ], [
3686 ac_have_armv8_crc_feature=no
3687 AC_MSG_RESULT([no])
3689 CFLAGS="$save_CFLAGS"
3691 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3694 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3695 # Note, this doesn't generate a C-level symbol.  It generates a
3696 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3697 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3699 save_CFLAGS="$CFLAGS"
3700 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3701 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3702 int main()
3704     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3705     return 0;
3707 ]])], [
3708 ac_have_armv81_feature=yes
3709 AC_MSG_RESULT([yes])
3710 ], [
3711 ac_have_armv81_feature=no
3712 AC_MSG_RESULT([no])
3714 CFLAGS="$save_CFLAGS"
3716 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3719 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3720 # Note, this doesn't generate a C-level symbol.  It generates a
3721 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3722 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3724 save_CFLAGS="$CFLAGS"
3725 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3726 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3727 int main()
3729     __asm__ __volatile__("faddp h0, v1.2h");
3730     return 0;
3732 ]])], [
3733 ac_have_armv82_feature=yes
3734 AC_MSG_RESULT([yes])
3735 ], [
3736 ac_have_armv82_feature=no
3737 AC_MSG_RESULT([no])
3739 CFLAGS="$save_CFLAGS"
3741 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3744 # Does the C compiler support the armv82-a+dotprod flag and assembler dotprod instructions
3745 # Note, this doesn't generate a C-level symbol.  It generates a
3746 # automake-level symbol (BUILD_ARMV82_DOTPROD_TESTS), used in test Makefile.am's
3747 AC_MSG_CHECKING([if gcc supports the armv82-a+dotprod feature flag and assembler supports dotprod instructions])
3749 save_CFLAGS="$CFLAGS"
3750 CFLAGS="$CFLAGS -march=armv8.2-a+dotprod -Werror"
3751 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3752 int main()
3754     __asm__ __volatile__("sdot v1.4s, v2.16b, v3.16b");
3755     return 0;
3757 ]])], [
3758 ac_have_armv82_dotprod_feature=yes
3759 AC_MSG_RESULT([yes])
3760 ], [
3761 ac_have_armv82_dotprod_feature=no
3762 AC_MSG_RESULT([no])
3764 CFLAGS="$save_CFLAGS"
3766 AM_CONDITIONAL(BUILD_ARMV82_DOTPROD_TESTS, test x$ac_have_armv82_dotprod_feature = xyes)
3769 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3770 # when building the tool executables.  I think we should get rid of it.
3772 # Check for TLS support in the compiler and linker
3773 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3774                                 [[return foo;]])],
3775                                [vg_cv_linktime_tls=yes],
3776                                [vg_cv_linktime_tls=no])
3777 # Native compilation: check whether running a program using TLS succeeds.
3778 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3779 # succeeds but running programs using TLS fails.
3780 # Cross-compiling: check whether linking a program using TLS succeeds.
3781 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3782                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3783                 [vg_cv_tls=$enableval],
3784                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3785                                                 [[return foo;]])],
3786                                [vg_cv_tls=yes],
3787                                [vg_cv_tls=no],
3788                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3790 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3791 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3795 #----------------------------------------------------------------------------
3796 # Solaris-specific checks.
3797 #----------------------------------------------------------------------------
3799 if test "$VGCONF_OS" = "solaris" ; then
3800 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3802 # Solaris-specific check determining if the Sun Studio Assembler is used to
3803 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3804 # cmovl.l instruction, if yes then it's Sun Assembler.
3806 # C-level symbol: none
3807 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3809 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3810 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3811 ]], [[
3812   __asm__ __volatile__("cmovl.l %edx, %eax");
3813 ]])], [
3814 solaris_have_sun_studio_as=yes
3815 AC_MSG_RESULT([yes])
3816 ], [
3817 solaris_have_sun_studio_as=no
3818 AC_MSG_RESULT([no])
3820 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3822 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3823 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3824 # See solaris/vgpreload-solaris.mapfile for details.
3825 # gcc on older Solaris instructs linker to include these symbols,
3826 # gcc on illumos and newer Solaris does not.
3828 # C-level symbol: none
3829 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3831 save_CFLAGS="$CFLAGS"
3832 CFLAGS="$CFLAGS -std=gnu99"
3833 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3834 temp_dir=$( /usr/bin/mktemp -d )
3835 cat <<_ACEOF >${temp_dir}/mylib.c
3836 #include <stdio.h>
3837 int myfunc(void) { printf("LaPutyka\n"); }
3838 _ACEOF
3839 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3840 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3841 if test "x${xpg_present}" = "x" ; then
3842     solaris_xpg_symbols_present=no
3843     AC_MSG_RESULT([no])
3844 else
3845     solaris_xpg_symbols_present=yes
3846     AC_MSG_RESULT([yes])
3848 rm -rf ${temp_dir}
3849 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3850 CFLAGS="$save_CFLAGS"
3853 # Solaris-specific check determining if gcc enables largefile support by
3854 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3855 # variable with gcc flags which disable it.
3857 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3858 save_CFLAGS="$CFLAGS"
3859 CFLAGS="$CFLAGS -m32"
3860 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3861   return _LARGEFILE_SOURCE;
3862 ]])], [
3863 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3864 AC_MSG_RESULT([yes])
3865 ], [
3866 SOLARIS_UNDEF_LARGESOURCE=""
3867 AC_MSG_RESULT([no])
3869 CFLAGS=$safe_CFLAGS
3870 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3873 # Solaris-specific check determining if /proc/self/cmdline
3874 # or /proc/<pid>/cmdline is supported.
3876 # C-level symbol: SOLARIS_PROC_CMDLINE
3877 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3879 AC_CHECK_FILE([/proc/self/cmdline],
3881 solaris_proc_cmdline=yes
3882 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3883           [Define to 1 if you have /proc/self/cmdline.])
3884 ], [
3885 solaris_proc_cmdline=no
3887 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3890 # Solaris-specific check determining default platform for the Valgrind launcher.
3891 # Used in case the launcher cannot select platform by looking at the client
3892 # image (for example because the executable is a shell script).
3894 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3895 # Automake-level symbol: none
3897 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3898 # Get the ELF class of /bin/sh first.
3899 if ! test -f /bin/sh; then
3900   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3902 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3903 case "$elf_class" in
3904   64)
3905     default_arch="$VGCONF_ARCH_PRI";
3906     ;;
3907   32)
3908     if test "x$VGCONF_ARCH_SEC" != "x"; then
3909       default_arch="$VGCONF_ARCH_SEC"
3910     else
3911       default_arch="$VGCONF_ARCH_PRI";
3912     fi
3913     ;;
3914   *)
3915     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3916     ;;
3917 esac
3918 default_platform="$default_arch-$VGCONF_OS"
3919 AC_MSG_RESULT([$default_platform])
3920 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3921                    [Default platform for Valgrind launcher.])
3924 # Solaris-specific check determining if the old syscalls are available.
3926 # C-level symbol: SOLARIS_OLD_SYSCALLS
3927 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3929 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3930 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3931 #include <sys/syscall.h>
3932 ]], [[
3933   return !SYS_open;
3934 ]])], [
3935 solaris_old_syscalls=yes
3936 AC_MSG_RESULT([yes])
3937 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3938           [Define to 1 if you have the old Solaris syscalls.])
3939 ], [
3940 solaris_old_syscalls=no
3941 AC_MSG_RESULT([no])
3943 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3946 # Solaris-specific check determining if the new accept() syscall is available.
3948 # Old syscall:
3949 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3950 #            int version);
3952 # New syscall (available on illumos):
3953 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3954 #            int version, int flags);
3956 # If the old syscall is present then the following syscall will fail with
3957 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3958 # available then it will fail with EINVAL (because the flags parameter is
3959 # invalid).
3961 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3962 # Automake-level symbol: none
3964 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3965 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3966 #include <sys/syscall.h>
3967 #include <errno.h>
3968 ]], [[
3969   errno = 0;
3970   syscall(SYS_accept, 0, 0, 0, 0, -1);
3971   return !(errno == EINVAL);
3972 ]])], [
3973 AC_MSG_RESULT([yes])
3974 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3975           [Define to 1 if you have the new `accept' syscall.])
3976 ], [
3977 AC_MSG_RESULT([no])
3981 # Solaris-specific check determining if the new illumos pipe() syscall is
3982 # available.
3984 # Old syscall:
3985 # longlong_t pipe();
3987 # New syscall (available on illumos):
3988 # int pipe(intptr_t arg, int flags);
3990 # If the old syscall is present then the following call will succeed, if the
3991 # new syscall is available then it will fail with EFAULT (because address 0
3992 # cannot be accessed).
3994 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3995 # Automake-level symbol: none
3997 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3998 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3999 #include <sys/syscall.h>
4000 #include <errno.h>
4001 ]], [[
4002   errno = 0;
4003   syscall(SYS_pipe, 0, 0);
4004   return !(errno == EFAULT);
4005 ]])], [
4006 AC_MSG_RESULT([yes])
4007 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
4008           [Define to 1 if you have the new `pipe' syscall.])
4009 ], [
4010 AC_MSG_RESULT([no])
4014 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
4015 # available.
4017 # Old syscall:
4018 # int lwp_kill(id_t lwpid, int sig);
4020 # New syscall (available on Solaris 11):
4021 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
4022 #                  int si_code, timespec_t *timeout);
4024 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
4025 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
4027 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
4028 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4029 #include <sys/syscall.h> 
4030 ]], [[
4031   return !SYS_lwp_sigqueue;
4032 ]])], [
4033 solaris_lwp_sigqueue_syscall=yes
4034 AC_MSG_RESULT([yes])
4035 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
4036           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
4037 ], [
4038 solaris_lwp_sigqueue_syscall=no
4039 AC_MSG_RESULT([no])
4041 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
4044 # Solaris-specific check determining if the lwp_sigqueue() syscall
4045 # takes both pid and thread id arguments or just thread id.
4047 # Old syscall (available up to Solaris 11.3):
4048 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
4049 #                  int si_code, timespec_t *timeout);
4051 # New syscall (available since Solaris 11.4):
4052 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
4053 #                  int si_code, timespec_t *timeout);
4055 # If the old syscall is present then the following syscall will fail with
4056 # EINVAL (because signal is out of range); if the new syscall is available
4057 # then it will fail with ESRCH (because it would not find such thread in the
4058 # current process).
4060 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
4061 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
4063 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
4064 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
4065 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4066 #include <sys/syscall.h>
4067 #include <errno.h>
4068 ]], [[
4069   errno = 0;
4070   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
4071   return !(errno == ESRCH);
4072 ]])], [
4073 solaris_lwp_sigqueue_syscall_takes_pid=yes
4074 AC_MSG_RESULT([yes])
4075 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
4076           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
4077 ], [
4078 solaris_lwp_sigqueue_syscall_takes_pid=no
4079 AC_MSG_RESULT([no])
4081 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
4082                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
4084 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
4088 # Solaris-specific check determining if the new lwp_name() syscall is
4089 # available.
4091 # New syscall (available on Solaris 11):
4092 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
4094 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
4095 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
4097 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
4098 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4099 #include <sys/syscall.h>
4100 ]], [[
4101   return !SYS_lwp_name;
4102 ]])], [
4103 solaris_lwp_name_syscall=yes
4104 AC_MSG_RESULT([yes])
4105 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
4106           [Define to 1 if you have the new `lwp_name' syscall.])
4107 ], [
4108 solaris_lwp_name_syscall=no
4109 AC_MSG_RESULT([no])
4111 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
4114 # Solaris-specific check determining if the new getrandom() syscall is
4115 # available.
4117 # New syscall (available on Solaris 11):
4118 # int getrandom(void *buf, size_t buflen, uint_t flags);
4120 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
4121 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
4123 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
4124 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4125 #include <sys/syscall.h>
4126 ]], [[
4127   return !SYS_getrandom;
4128 ]])], [
4129 solaris_getrandom_syscall=yes
4130 AC_MSG_RESULT([yes])
4131 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
4132           [Define to 1 if you have the new `getrandom' syscall.])
4133 ], [
4134 solaris_getrandom_syscall=no
4135 AC_MSG_RESULT([no])
4137 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
4140 # Solaris-specific check determining if the new zone() syscall subcodes
4141 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
4142 # were added in Solaris 11 but are missing on illumos.
4144 # C-level symbol: SOLARIS_ZONE_DEFUNCT
4145 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
4147 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
4148 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4149 #include <sys/zone.h>
4150 ]], [[
4151   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
4152 ]])], [
4153 solaris_zone_defunct=yes
4154 AC_MSG_RESULT([yes])
4155 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
4156           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
4157 ], [
4158 solaris_zone_defunct=no
4159 AC_MSG_RESULT([no])
4161 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
4164 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4165 # for auditon(2) subcode of the auditsys() syscall are available.
4166 # These commands are available in Solaris 11 and illumos but were removed
4167 # in Solaris 11.4.
4169 # C-level symbol: SOLARIS_AUDITON_STAT
4170 # Automake-level symbol: SOLARIS_AUDITON_STAT
4172 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4173 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4174 #include <bsm/audit.h>
4175 ]], [[
4176   return !(A_GETSTAT && A_SETSTAT);
4177 ]])], [
4178 solaris_auditon_stat=yes
4179 AC_MSG_RESULT([yes])
4180 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4181           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4182 ], [
4183 solaris_auditon_stat=no
4184 AC_MSG_RESULT([no])
4186 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4189 # Solaris-specific check determining if the new shmsys() syscall subcodes
4190 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4191 # These subcodes were added in Solaris 11 but are missing on illumos.
4193 # C-level symbol: SOLARIS_SHM_NEW
4194 # Automake-level symbol: SOLARIS_SHM_NEW
4196 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4197 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4198 #include <sys/ipc_impl.h>
4199 #include <sys/shm.h>
4200 #include <sys/shm_impl.h>
4201 ]], [[
4202   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4203 ]])], [
4204 solaris_shm_new=yes
4205 AC_MSG_RESULT([yes])
4206 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4207           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4208 ], [
4209 solaris_shm_new=no
4210 AC_MSG_RESULT([no])
4212 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4215 # Solaris-specific check determining if prxregset_t is available.  Illumos
4216 # currently does not define it on the x86 platform.
4218 # C-level symbol: SOLARIS_PRXREGSET_T
4219 # Automake-level symbol: SOLARIS_PRXREGSET_T
4221 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4222 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4223 #include <sys/procfs_isa.h>
4224 ]], [[
4225   return !sizeof(prxregset_t);
4226 ]])], [
4227 solaris_prxregset_t=yes
4228 AC_MSG_RESULT([yes])
4229 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4230           [Define to 1 if you have the `prxregset_t' type.])
4231 ], [
4232 solaris_prxregset_t=no
4233 AC_MSG_RESULT([no])
4235 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4238 # Solaris-specific check determining if the new frealpathat() syscall is
4239 # available.
4241 # New syscall (available on Solaris 11.1):
4242 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4244 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4245 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4247 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4248 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4249 #include <sys/syscall.h>
4250 ]], [[
4251   return !SYS_frealpathat;
4252 ]])], [
4253 solaris_frealpathat_syscall=yes
4254 AC_MSG_RESULT([yes])
4255 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4256           [Define to 1 if you have the new `frealpathat' syscall.])
4257 ], [
4258 solaris_frealpathat_syscall=no
4259 AC_MSG_RESULT([no])
4261 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4264 # Solaris-specific check determining if the new uuidsys() syscall is
4265 # available.
4267 # New syscall (available on newer Solaris):
4268 # int uuidsys(struct uuid *uuid);
4270 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4271 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4273 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4274 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4275 #include <sys/syscall.h>
4276 ]], [[
4277   return !SYS_uuidsys;
4278 ]])], [
4279 solaris_uuidsys_syscall=yes
4280 AC_MSG_RESULT([yes])
4281 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4282           [Define to 1 if you have the new `uuidsys' syscall.])
4283 ], [
4284 solaris_uuidsys_syscall=no
4285 AC_MSG_RESULT([no])
4287 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4290 # Solaris-specific check determining if the new labelsys() syscall subcode
4291 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4292 # missing on illumos.
4294 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4295 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4297 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4298 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4299 #include <sys/tsol/tndb.h>
4300 ]], [[
4301   return !TNDB_GET_TNIP;
4302 ]])], [
4303 solaris_tndb_get_tnip=yes
4304 AC_MSG_RESULT([yes])
4305 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4306           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4307 ], [
4308 solaris_tndb_get_tnip=no
4309 AC_MSG_RESULT([no])
4311 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4314 # Solaris-specific check determining if the new labelsys() syscall opcodes
4315 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4316 # added in Solaris 11 but are missing on illumos.
4318 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4319 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4321 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4322 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4323 #include <sys/tsol/tsyscall.h>
4324 ]], [[
4325   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4326 ]])], [
4327 solaris_tsol_clearance=yes
4328 AC_MSG_RESULT([yes])
4329 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4330           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4331 ], [
4332 solaris_tsol_clearance=no
4333 AC_MSG_RESULT([no])
4335 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4338 # Solaris-specific check determining if the new pset() syscall subcode
4339 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4340 # is missing on illumos and Solaris 11.3.
4342 # C-level symbol: SOLARIS_PSET_GET_NAME
4343 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4345 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4346 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4347 #include <sys/pset.h>
4348 ]], [[
4349   return !(PSET_GET_NAME);
4350 ]])], [
4351 solaris_pset_get_name=yes
4352 AC_MSG_RESULT([yes])
4353 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4354           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4355 ], [
4356 solaris_pset_get_name=no
4357 AC_MSG_RESULT([no])
4359 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4362 # Solaris-specific check determining if the utimesys() syscall is
4363 # available (on illumos and older Solaris).
4365 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4366 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4368 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4369 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4370 #include <sys/syscall.h>
4371 ]], [[
4372   return !SYS_utimesys;
4373 ]])], [
4374 solaris_utimesys_syscall=yes
4375 AC_MSG_RESULT([yes])
4376 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4377           [Define to 1 if you have the `utimesys' syscall.])
4378 ], [
4379 solaris_utimesys_syscall=no
4380 AC_MSG_RESULT([no])
4382 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4385 # Solaris-specific check determining if the utimensat() syscall is
4386 # available (on newer Solaris).
4388 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4389 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4391 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4392 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4393 #include <sys/syscall.h>
4394 ]], [[
4395   return !SYS_utimensat;
4396 ]])], [
4397 solaris_utimensat_syscall=yes
4398 AC_MSG_RESULT([yes])
4399 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4400           [Define to 1 if you have the `utimensat' syscall.])
4401 ], [
4402 solaris_utimensat_syscall=no
4403 AC_MSG_RESULT([no])
4405 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4408 # Solaris-specific check determining if the spawn() syscall is available
4409 # (on newer Solaris).
4411 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4412 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4414 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4415 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4416 #include <sys/syscall.h>
4417 ]], [[
4418   return !SYS_spawn;
4419 ]])], [
4420 solaris_spawn_syscall=yes
4421 AC_MSG_RESULT([yes])
4422 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4423           [Define to 1 if you have the `spawn' syscall.])
4424 ], [
4425 solaris_spawn_syscall=no
4426 AC_MSG_RESULT([no])
4428 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4431 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4432 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4434 # C-level symbol: SOLARIS_MODCTL_MODNVL
4435 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4437 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4438 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4439 #include <sys/modctl.h>
4440 ]], [[
4441   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4442 ]])], [
4443 solaris_modctl_modnvl=yes
4444 AC_MSG_RESULT([yes])
4445 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4446           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4447 ], [
4448 solaris_modctl_modnvl=no
4449 AC_MSG_RESULT([no])
4451 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4454 # Solaris-specific check determining whether nscd (name switch cache daemon)
4455 # attaches its door at /system/volatile/name_service_door (Solaris)
4456 # or at /var/run/name_service_door (illumos).
4458 # Note that /var/run is a symlink to /system/volatile on Solaris
4459 # but not vice versa on illumos.
4461 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4462 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4464 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4465 if test -e /system/volatile/name_service_door; then
4466     solaris_nscd_door_system_volatile=yes
4467     AC_MSG_RESULT([/system/volatile/name_service_door])
4468     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4469               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4470 else
4471     solaris_nscd_door_system_volatile=no
4472     AC_MSG_RESULT([/var/run/name_service_door])
4474 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4477 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4479 # New fasttrap (available on Solaris 11):
4480 # hrt_t *gethrt(void);
4482 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4483 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4485 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4486 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4487 #include <sys/trap.h>
4488 ]], [[
4489   return !T_GETHRT;
4490 ]])], [
4491 solaris_gethrt_fasttrap=yes
4492 AC_MSG_RESULT([yes])
4493 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4494           [Define to 1 if you have the new `gethrt' fasttrap.])
4495 ], [
4496 solaris_gethrt_fasttrap=no
4497 AC_MSG_RESULT([no])
4499 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4502 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4503 # is available.
4505 # New fasttrap (available on Solaris 11):
4506 # zonehrtoffset_t *get_zone_offset(void);
4508 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4509 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4511 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4512 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4513 #include <sys/trap.h>
4514 ]], [[
4515   return !T_GETZONEOFFSET;
4516 ]])], [
4517 solaris_getzoneoffset_fasttrap=yes
4518 AC_MSG_RESULT([yes])
4519 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4520           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4521 ], [
4522 solaris_getzoneoffset_fasttrap=no
4523 AC_MSG_RESULT([no])
4525 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4528 # Solaris-specific check determining if the execve() syscall
4529 # takes fourth argument (flags) or not.
4531 # Old syscall (available on illumos):
4532 # int execve(const char *fname, const char **argv, const char **envp);
4534 # New syscall (available on Solaris):
4535 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4537 # If the new syscall is present then it will fail with EINVAL (because flags
4538 # are invalid); if the old syscall is available then it will fail with ENOENT
4539 # (because the file could not be found).
4541 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4542 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4544 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4545 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4546 #include <sys/syscall.h>
4547 #include <errno.h>
4548 ]], [[
4549   errno = 0;
4550   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4551   return !(errno == EINVAL);
4552 ]])], [
4553 solaris_execve_syscall_takes_flags=yes
4554 AC_MSG_RESULT([yes])
4555 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4556           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4557 ], [
4558 solaris_execve_syscall_takes_flags=no
4559 AC_MSG_RESULT([no])
4561 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4562                test x$solaris_execve_syscall_takes_flags = xyes)
4565 # Solaris-specific check determining version of the repository cache protocol.
4566 # Every Solaris version uses a different one, ranging from 21 to current 25.
4567 # The check is very ugly, though.
4569 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4570 # Automake-level symbol: none
4572 AC_PATH_PROG(DIS_PATH, dis, false)
4573 if test "x$DIS_PATH" = "xfalse"; then
4574   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4576 # The illumos source is (or was) here
4577 # https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libscf/common/lowlevel.c#L1148
4578 # specifically the line
4580 # request.rdr_version = REPOSITORY_DOOR_VERSION;
4582 # rdr_version is a 32bit unsigned int
4583 # The macro REPOSITORY_DOOR_VERSION contains the ascii letters "Rep" in the top 3
4584 # bytes and the door version in the lowest byte. Hence we look for Rep which is 526570
4585 # in hex and then extrace the following byte.
4586 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4587   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4588   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4591 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4592 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4593   libscf=/usr/lib/64/libscf.so.1
4594 else
4595   libscf=/usr/lib/libscf.so.1
4597 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q -E '0x(4d01)?526570'; then
4598   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4599   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4601 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | grep 526570 | sed 's/.*526570//;s/,.*//' )
4602 if test -z "$hex"; then
4603   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4604   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4606 version=$( printf "%d\n" 0x$hex )
4607 AC_MSG_RESULT([$version])
4608 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4609                    [Version number of the repository door cache protocol.])
4612 # Solaris-specific check determining if "sysstat" segment reservation type
4613 # is available.
4615 # New "sysstat" segment reservation (available on Solaris 11.4):
4616 # - program header type:    PT_SUNW_SYSSTAT
4617 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4619 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4620 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4622 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4623 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4624 #include <sys/auxv.h>
4625 ]], [[
4626   return !AT_SUN_SYSSTAT_ADDR;
4627 ]])], [
4628 solaris_reserve_sysstat_addr=yes
4629 AC_MSG_RESULT([yes])
4630 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4631           [Define to 1 if you have the new `sysstat' segment reservation.])
4632 ], [
4633 solaris_reserve_sysstat_addr=no
4634 AC_MSG_RESULT([no])
4636 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4639 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4640 # is available.
4642 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4643 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4644 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4646 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4647 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4649 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4650 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4651 #include <sys/auxv.h>
4652 ]], [[
4653   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4654 ]])], [
4655 solaris_reserve_sysstat_zone_addr=yes
4656 AC_MSG_RESULT([yes])
4657 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4658           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4659 ], [
4660 solaris_reserve_sysstat_zone_addr=no
4661 AC_MSG_RESULT([no])
4663 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4666 # Solaris-specific check determining if the system_stats() syscall is available
4667 # (on newer Solaris).
4669 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4670 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4672 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4673 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4674 #include <sys/syscall.h>
4675 ]], [[
4676   return !SYS_system_stats;
4677 ]])], [
4678 solaris_system_stats_syscall=yes
4679 AC_MSG_RESULT([yes])
4680 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4681           [Define to 1 if you have the `system_stats' syscall.])
4682 ], [
4683 solaris_system_stats_syscall=no
4684 AC_MSG_RESULT([no])
4686 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4689 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4690 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4692 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4693 # Automake-level symbol: none
4695 AC_CHECK_TYPE([struct _fpchip_state],
4696               [solaris_fpchip_state_takes_underscore=yes],
4697               [solaris_fpchip_state_takes_underscore=no],
4698               [[#include <sys/regset.h>]])
4699 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4700   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4701             [Define to 1 if fpregset_t defines struct _fpchip_state])
4705 # Solaris-specific check determining if schedctl page shared between kernel
4706 # and userspace program is executable (illumos, older Solaris) or not (newer
4707 # Solaris).
4709 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4710 # Automake-level symbol: none
4712 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4713 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4714 #include <assert.h>
4715 #include <fcntl.h>
4716 #include <procfs.h>
4717 #include <schedctl.h>
4718 #include <stdio.h>
4719 #include <unistd.h>
4720 ]], [[
4721     schedctl_t *scp = schedctl_init();
4722     if (scp == NULL)
4723         return 1;
4725     int fd = open("/proc/self/map", O_RDONLY);
4726     assert(fd >= 0);
4728     prmap_t map;
4729     ssize_t rd;
4730     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4731         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4732             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4733                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4734             return (map.pr_mflags & MA_EXEC);
4735         }
4736     }
4738     return 1;
4739 ]])], [
4740 solaris_schedctl_page_exec=no
4741 AC_MSG_RESULT([no])
4742 ], [
4743 solaris_schedctl_page_exec=yes
4744 AC_MSG_RESULT([yes])
4745 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4746           [Define to 1 if you have the schedctl page executable.])
4750 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4751 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4752 # an initial thread pointer for libc (newer Solaris).
4754 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4755 # Automake-level symbol: none
4757 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4758 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4759 #include <sys/fasttrap_isa.h>
4760 ]], [[
4761     return !FT_SCRATCHSIZE;
4762 ]])], [
4763 solaris_pt_sunwdtrace_thrp=yes
4764 AC_MSG_RESULT([yes])
4765 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4766           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4767 ], [
4768 solaris_pt_sunwdtrace_thrp=no
4769 AC_MSG_RESULT([no])
4772 else
4773 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4774 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4775 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4776 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4777 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4778 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4779 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4780 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4781 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4782 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4783 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4784 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4785 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4786 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4787 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4788 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4789 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4790 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4791 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4792 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4793 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4794 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4795 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4796 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4797 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4798 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4799 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4800 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4801 fi # test "$VGCONF_OS" = "solaris"
4803 #----------------------------------------------------------------------------
4804 # FreeBSD-specific checks.
4805 #----------------------------------------------------------------------------
4807 # Rather than having a large number of feature test as above with Solaris
4808 # these tests are per-version. This may not be entirely reliable for
4809 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4810 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4812 if test "$VGCONF_OS" = "freebsd" ; then
4814 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4815 AM_CONDITIONAL(FREEBSD_VERS_15_PLUS, test $freebsd_vers -ge $freebsd_15)
4817 else
4819 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4820 AM_CONDITIONAL(FREEBSD_VERS_15_PLUS, false)
4822 fi # test "$VGCONF_OS" = "freebsd"
4825 #----------------------------------------------------------------------------
4826 # Checks for C header files.
4827 #----------------------------------------------------------------------------
4829 AC_CHECK_HEADERS([       \
4830         asm/unistd.h     \
4831         endian.h         \
4832         mqueue.h         \
4833         sys/endian.h     \
4834         sys/epoll.h      \
4835         sys/eventfd.h    \
4836         sys/klog.h       \
4837         sys/poll.h       \
4838         sys/prctl.h      \
4839         sys/signal.h     \
4840         sys/signalfd.h   \
4841         sys/syscall.h    \
4842         sys/sysnvl.h     \
4843         sys/time.h       \
4844         sys/types.h      \
4845         ])
4847 # Verify whether the <linux/futex.h> header is usable.
4848 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4850 save_CFLAGS="$CFLAGS"
4851 CFLAGS="$CFLAGS -D__user="
4852 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4853 #include <linux/futex.h>
4854 ]], [[
4855   return FUTEX_WAIT;
4856 ]])], [
4857 ac_have_usable_linux_futex_h=yes
4858 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4859           [Define to 1 if you have a usable <linux/futex.h> header file.])
4860 AC_MSG_RESULT([yes])
4861 ], [
4862 ac_have_usable_linux_futex_h=no
4863 AC_MSG_RESULT([no])
4865 CFLAGS="$save_CFLAGS"
4868 #----------------------------------------------------------------------------
4869 # Checks for typedefs, structures, and compiler characteristics.
4870 #----------------------------------------------------------------------------
4871 AC_TYPE_UID_T
4872 AC_TYPE_OFF_T
4873 AC_TYPE_SIZE_T
4874 AC_CHECK_HEADERS_ONCE([sys/time.h])
4876 AC_CHECK_TYPE([struct statx], [
4877   AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4878             [Define to 1 if <sys/stat.h> declares struct statx.])
4879 ], [], [
4880   #define _GNU_SOURCE
4881   #include <sys/stat.h>
4885 #----------------------------------------------------------------------------
4886 # Checks for library functions.
4887 #----------------------------------------------------------------------------
4888 AC_FUNC_MEMCMP
4889 AC_FUNC_MMAP
4891 AC_CHECK_LIB([pthread], [pthread_create])
4892 AC_CHECK_LIB([rt], [clock_gettime])
4894 AC_CHECK_FUNCS([     \
4895         aligned_alloc \
4896         clock_gettime\
4897         copy_file_range \
4898         epoll_create \
4899         epoll_pwait  \
4900         getaddrinfo  \
4901         klogctl      \
4902         mallinfo     \
4903         memchr       \
4904         memfd_create \
4905         memset       \
4906         mkdir        \
4907         mremap       \
4908         pipe2        \
4909         ppoll        \
4910         preadv       \
4911         preadv2      \
4912         process_vm_readv  \
4913         process_vm_writev \
4914         pthread_barrier_init       \
4915         pthread_condattr_setclock  \
4916         pthread_mutex_timedlock    \
4917         pthread_rwlock_timedrdlock \
4918         pthread_rwlock_timedwrlock \
4919         pthread_setname_np         \
4920         pthread_spin_lock          \
4921         pthread_yield              \
4922         pwritev      \
4923         pwritev2     \
4924         rawmemchr    \
4925         readlinkat   \
4926         reallocarray \
4927         semtimedop   \
4928         setcontext   \
4929         signalfd     \
4930         sigwaitinfo  \
4931         strchr       \
4932         strdup       \
4933         strpbrk      \
4934         strrchr      \
4935         strstr       \
4936         swapcontext  \
4937         syscall      \
4938         utimensat    \
4939         mempcpy      \
4940         strlcat      \
4941         strlcpy      \
4942         stpncpy      \
4943         strchrnul    \
4944         memrchr      \
4945         strndup      \
4946         close_range  \
4947         wcsncpy
4948         ])
4950 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4951 # libraries with any shared object and/or executable. This is NOT what we
4952 # want for e.g. vgpreload_core-x86-linux.so
4953 LIBS=""
4955 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4956                [test x$ac_cv_func_pthread_barrier_init = xyes])
4957 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4958                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4959 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4960                [test x$ac_cv_func_pthread_spin_lock = xyes])
4961 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4962                [test x$ac_cv_func_pthread_setname_np = xyes])
4963 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4964                [test x$ac_cv_func_copy_file_range = xyes])
4965 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4966                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4967 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4968                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4969 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4970 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4971 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4972                [test x$ac_cv_func_memfd_create = xyes])
4973 AM_CONDITIONAL([HAVE_GETADDRINFO],
4974                [test x$ac_cv_func_getaddrinfo = xyes])
4975 AM_CONDITIONAL([HAVE_CLOSE_RANGE],
4976                [test x$ac_cv_func_close_range = xyes])
4977 AM_CONDITIONAL([HAVE_REALLOCARRAY],
4978                [test x$ac_cv_func_reallocarray = xyes])
4979 AM_CONDITIONAL([HAVE_WCSNCPY],
4980                [test x$ac_cv_func_wcsncpy = xyes])
4981 AM_CONDITIONAL([HAVE_STRLCAT],
4982                [test x$ac_cv_func_strlcat = xyes])
4983 AM_CONDITIONAL([HAVE_STRLCPY],
4984                [test x$ac_cv_func_strlcpy = xyes])
4986 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4987      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4988      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4989   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4990             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4993 #----------------------------------------------------------------------------
4994 # MPI checks
4995 #----------------------------------------------------------------------------
4996 # Do we have a useable MPI setup on the primary and/or secondary targets?
4997 # On Linux, by default, assumes mpicc and -m32/-m64
4998 # Note: this is a kludge in that it assumes the specified mpicc 
4999 # understands -m32/-m64 regardless of what is specified using
5000 # --with-mpicc=.
5001 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
5002              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
5004 mflag_primary=
5005 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
5006      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
5007      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
5008      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
5009      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
5010      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
5011      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
5012   mflag_primary=$FLAG_M32
5013 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
5014        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
5015        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
5016        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
5017        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
5018        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
5019   mflag_primary=$FLAG_M64
5020 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
5021   mflag_primary="$FLAG_M32 -arch i386"
5022 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
5023   mflag_primary="$FLAG_M64 -arch x86_64"
5026 mflag_secondary=
5027 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
5028      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
5029      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
5030      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
5031      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
5032   mflag_secondary=$FLAG_M32
5033 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
5034   mflag_secondary="$FLAG_M32 -arch i386"
5038 AC_ARG_WITH(mpicc,
5039    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
5040    MPI_CC=$withval
5042 AC_SUBST(MPI_CC)
5044 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
5045 ## use these values in the check for a functioning mpicc.
5047 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
5048 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
5049 AM_COND_IF([VGCONF_OS_IS_LINUX],
5050            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5051             LDFLAGS_MPI="-fpic -shared"])
5052 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
5053            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5054             LDFLAGS_MPI="-fpic -shared"])
5055 AM_COND_IF([VGCONF_OS_IS_DARWIN],
5056            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
5057             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
5058 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
5059            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
5060             LDFLAGS_MPI="-fpic -shared"])
5062 AC_SUBST([CFLAGS_MPI])
5063 AC_SUBST([LDFLAGS_MPI])
5066 ## See if MPI_CC works for the primary target
5068 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
5069 saved_CC=$CC
5070 saved_CFLAGS=$CFLAGS
5071 CC=$MPI_CC
5072 CFLAGS="$CFLAGS_MPI $mflag_primary"
5073 saved_LDFLAGS="$LDFLAGS"
5074 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
5075 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5076 #include <mpi.h>
5077 #include <stdio.h>
5078 ]], [[
5079   int ni, na, nd, comb;
5080   int r = MPI_Init(NULL,NULL);
5081   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5082   r |= MPI_Finalize();
5083   return r; 
5084 ]])], [
5085 ac_have_mpi2_pri=yes
5086 AC_MSG_RESULT([yes, $MPI_CC])
5087 ], [
5088 ac_have_mpi2_pri=no
5089 AC_MSG_RESULT([no])
5091 CC=$saved_CC
5092 CFLAGS=$saved_CFLAGS
5093 LDFLAGS="$saved_LDFLAGS"
5094 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
5096 ## See if MPI_CC works for the secondary target.  Complication: what if
5097 ## there is no secondary target?  We need this to then fail.
5098 ## Kludge this by making MPI_CC something which will surely fail in
5099 ## such a case.
5101 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
5102 saved_CC=$CC
5103 saved_CFLAGS=$CFLAGS
5104 saved_LDFLAGS="$LDFLAGS"
5105 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
5106 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
5107   CC="$MPI_CC this will surely fail"
5108 else
5109   CC=$MPI_CC
5111 CFLAGS="$CFLAGS_MPI $mflag_secondary"
5112 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5113 #include <mpi.h>
5114 #include <stdio.h>
5115 ]], [[
5116   int ni, na, nd, comb;
5117   int r = MPI_Init(NULL,NULL);
5118   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5119   r |= MPI_Finalize();
5120   return r; 
5121 ]])], [
5122 ac_have_mpi2_sec=yes
5123 AC_MSG_RESULT([yes, $MPI_CC])
5124 ], [
5125 ac_have_mpi2_sec=no
5126 AC_MSG_RESULT([no])
5128 CC=$saved_CC
5129 CFLAGS=$saved_CFLAGS
5130 LDFLAGS="$saved_LDFLAGS"
5131 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
5134 #----------------------------------------------------------------------------
5135 # Other library checks
5136 #----------------------------------------------------------------------------
5137 # There now follow some tests for Boost, and OpenMP.  These
5138 # tests are present because Drd has some regression tests that use
5139 # these packages.  All regression test programs all compiled only
5140 # for the primary target.  And so it is important that the configure
5141 # checks that follow, use the correct -m32 or -m64 flag for the
5142 # primary target (called $mflag_primary).  Otherwise, we can end up
5143 # in a situation (eg) where, on amd64-linux, the test for Boost checks
5144 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
5145 # only build (meaning, the primary target is x86-linux), the build
5146 # of the regtest programs that use Boost fails, because they are 
5147 # build as 32-bit (IN THIS EXAMPLE).
5149 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
5150 # NEEDED BY THE REGRESSION TEST PROGRAMS.
5153 # Check whether the boost library 1.35 or later has been installed.
5154 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
5156 AC_MSG_CHECKING([for boost])
5158 AC_LANG(C++)
5159 safe_CXXFLAGS=$CXXFLAGS
5160 CXXFLAGS="$mflag_primary"
5161 safe_LIBS="$LIBS"
5162 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
5164 AC_LINK_IFELSE([AC_LANG_SOURCE([
5165 #include <boost/thread.hpp>
5166 static void thread_func(void)
5167 { }
5168 int main(int argc, char** argv)
5170   boost::thread t(thread_func);
5171   return 0;
5173 ])],
5175 ac_have_boost_1_35=yes
5176 AC_SUBST([BOOST_CFLAGS], [])
5177 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
5178 AC_MSG_RESULT([yes])
5179 ], [
5180 ac_have_boost_1_35=no
5181 AC_MSG_RESULT([no])
5184 LIBS="$safe_LIBS"
5185 CXXFLAGS=$safe_CXXFLAGS
5186 AC_LANG(C)
5188 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
5191 # does this compiler support -fopenmp, does it have the include file
5192 # <omp.h> and does it have libgomp ?
5194 AC_MSG_CHECKING([for OpenMP])
5196 safe_CFLAGS=$CFLAGS
5197 CFLAGS="-fopenmp $mflag_primary -Werror"
5199 AC_LINK_IFELSE([AC_LANG_SOURCE([
5200 #include <omp.h> 
5201 int main(int argc, char** argv)
5203   omp_set_dynamic(0);
5204   return 0;
5206 ])],
5208 ac_have_openmp=yes
5209 AC_MSG_RESULT([yes])
5210 ], [
5211 ac_have_openmp=no
5212 AC_MSG_RESULT([no])
5214 CFLAGS=$safe_CFLAGS
5216 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5219 # Check for __builtin_popcount
5220 AC_MSG_CHECKING([for __builtin_popcount()])
5221 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5222 ]], [[
5223   __builtin_popcount(2);
5224   return 0;
5225 ]])], [
5226 AC_MSG_RESULT([yes])
5227 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5228           [Define to 1 if compiler provides __builtin_popcount().])
5229 ], [
5230 AC_MSG_RESULT([no])
5233 # Check for __builtin_clz
5234 AC_MSG_CHECKING([for __builtin_clz()])
5235 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5236 ]], [[
5237   __builtin_clz(2);
5238   return 0;
5239 ]])], [
5240 AC_MSG_RESULT([yes])
5241 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5242           [Define to 1 if compiler provides __builtin_clz().])
5243 ], [
5244 AC_MSG_RESULT([no])
5247 # Check for __builtin_ctz
5248 AC_MSG_CHECKING([for __builtin_ctz()])
5249 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5250 ]], [[
5251   __builtin_ctz(2);
5252   return 0;
5253 ]])], [
5254 AC_MSG_RESULT([yes])
5255 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5256           [Define to 1 if compiler provides __builtin_ctz().])
5257 ], [
5258 AC_MSG_RESULT([no])
5261 # does this compiler have built-in functions for atomic memory access for the
5262 # primary target ?
5263 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5265 safe_CFLAGS=$CFLAGS
5266 CFLAGS="$mflag_primary"
5268 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5269   int variable = 1;
5270   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5271           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5272 ]])], [
5273   ac_have_builtin_atomic_primary=yes
5274   AC_MSG_RESULT([yes])
5275   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])
5276 ], [
5277   ac_have_builtin_atomic_primary=no
5278   AC_MSG_RESULT([no])
5281 CFLAGS=$safe_CFLAGS
5283 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5284                [test x$ac_have_builtin_atomic_primary = xyes])
5287 # does this compiler have built-in functions for atomic memory access for the
5288 # secondary target ?
5290 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5292 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5294 safe_CFLAGS=$CFLAGS
5295 CFLAGS="$mflag_secondary"
5297 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5298   int variable = 1;
5299   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5300 ]])], [
5301   ac_have_builtin_atomic_secondary=yes
5302   AC_MSG_RESULT([yes])
5303 ], [
5304   ac_have_builtin_atomic_secondary=no
5305   AC_MSG_RESULT([no])
5308 CFLAGS=$safe_CFLAGS
5312 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5313                [test x$ac_have_builtin_atomic_secondary = xyes])
5315 # does this compiler have built-in functions for atomic memory access on
5316 # 64-bit integers for all targets ?
5318 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5320 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5321   #include <stdint.h>
5322 ]], [[
5323   uint64_t variable = 1;
5324   return __sync_add_and_fetch(&variable, 1)
5325 ]])], [
5326   ac_have_builtin_atomic64_primary=yes
5327 ], [
5328   ac_have_builtin_atomic64_primary=no
5331 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5333 safe_CFLAGS=$CFLAGS
5334 CFLAGS="$mflag_secondary"
5336 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5337   #include <stdint.h>
5338 ]], [[
5339   uint64_t variable = 1;
5340   return __sync_add_and_fetch(&variable, 1)
5341 ]])], [
5342   ac_have_builtin_atomic64_secondary=yes
5343 ], [
5344   ac_have_builtin_atomic64_secondary=no
5347 CFLAGS=$safe_CFLAGS
5351 if test x$ac_have_builtin_atomic64_primary = xyes && \
5352    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5353      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5354   AC_MSG_RESULT([yes])
5355   ac_have_builtin_atomic64=yes
5356 else
5357   AC_MSG_RESULT([no])
5358   ac_have_builtin_atomic64=no
5361 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5362                [test x$ac_have_builtin_atomic64 = xyes])
5364                
5365 AC_MSG_CHECKING([if platform has openat2 syscall])
5367 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5368   #include <sys/syscall.h>
5369 ]], [[
5370   return __NR_openat2
5371 ]])], [
5372   ac_have_openat2=yes
5373 ], [
5374   ac_have_openat2=no
5377 AM_CONDITIONAL([HAVE_OPENAT2],
5378                [test x$ac_have_openat2 = xyes])
5380 # does g++ have built-in functions for atomic memory access ?
5381 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5383 safe_CXXFLAGS=$CXXFLAGS
5384 CXXFLAGS="$mflag_primary"
5386 AC_LANG_PUSH(C++)
5387 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5388   int variable = 1;
5389   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5390           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5391 ]])], [
5392   ac_have_builtin_atomic_cxx=yes
5393   AC_MSG_RESULT([yes])
5394   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5395 ], [
5396   ac_have_builtin_atomic_cxx=no
5397   AC_MSG_RESULT([no])
5399 AC_LANG_POP(C++)
5401 CXXFLAGS=$safe_CXXFLAGS
5403 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5406 if test x$ac_have_usable_linux_futex_h = xyes \
5407         -a x$ac_have_builtin_atomic_primary = xyes; then
5408   ac_enable_linux_ticket_lock_primary=yes
5410 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5411                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5413 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5414         -a x$ac_have_usable_linux_futex_h = xyes \
5415         -a x$ac_have_builtin_atomic_secondary = xyes; then
5416   ac_enable_linux_ticket_lock_secondary=yes
5418 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5419                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5422 # does libstdc++ support annotating shared pointers ?
5423 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5425 safe_CXXFLAGS=$CXXFLAGS
5426 CXXFLAGS="-std=c++0x"
5428 AC_LANG_PUSH(C++)
5429 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5430   #include <memory>
5431 ]], [[
5432   std::shared_ptr<int> p
5433 ]])], [
5434   ac_have_shared_ptr=yes
5435 ], [
5436   ac_have_shared_ptr=no
5438 if test x$ac_have_shared_ptr = xyes; then
5439   # If compilation of the program below fails because of a syntax error
5440   # triggered by substituting one of the annotation macros then that
5441   # means that libstdc++ supports these macros.
5442   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5443     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5444     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5445     #include <memory>
5446   ]], [[
5447     std::shared_ptr<int> p
5448   ]])], [
5449     ac_have_shared_pointer_annotation=no
5450     AC_MSG_RESULT([no])
5451   ], [
5452     ac_have_shared_pointer_annotation=yes
5453     AC_MSG_RESULT([yes])
5454     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5455               [Define to 1 if libstd++ supports annotating shared pointers])
5456   ])
5457 else
5458   ac_have_shared_pointer_annotation=no
5459   AC_MSG_RESULT([no])
5461 AC_LANG_POP(C++)
5463 CXXFLAGS=$safe_CXXFLAGS
5465 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5466                [test x$ac_have_shared_pointer_annotation = xyes])
5468 # checking for GNU libc C17 aligned_alloc
5469 # just check glibc version rather than trying to muck around
5470 # checking the runtime behaviour or seeing if it is a weak alias
5471 AC_MSG_CHECKING([for AT_GNU_LIBC_C17_ALIGNED_ALLOC])
5472 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5473 #include <features.h>
5474 ]], [[
5475 #if !defined(__GLIBC__) || __GLIBC__ != 2 || !defined(__GLIBC_MINOR__) || __GLIBC_MINOR__ < 38
5476 #error "not GNU libc 2.38 or later"
5477 #endif
5478 ]])], [
5479     AC_MSG_RESULT([yes])
5480     AC_DEFINE([HAVE_GNU_LIBC_C17_ALIGNED_ALLOC], 1,
5481               [Define to 1 if you have GNU libc C17 aligned_alloc.])
5483 ], [
5484     AC_MSG_RESULT([no])
5487 # Check for C11 thrd_create()
5488 AC_MSG_CHECKING([for thrd_create()])
5489 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
5490 #include <threads.h>
5491 int thrd_entry(void *arg) { return 0; }
5492 ], [[thrd_t thr; return thrd_create(&thr, thrd_entry, NULL);]])],
5494 ac_cxx_have_thrd_create=yes
5495 AC_MSG_RESULT([yes])
5496 ], [
5497 ac_cxx_have_thrd_create=no
5498 AC_MSG_RESULT([no])
5501 AM_CONDITIONAL(HAVE_THRD_CREATE, test x$ac_cxx_have_thrd_create = xyes)
5505 #----------------------------------------------------------------------------
5506 # Ok.  We're done checking.
5507 #----------------------------------------------------------------------------
5509 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5510 AC_CONFIG_FILES([
5511    Makefile 
5512    VEX/Makefile:Makefile.vex.in
5513    valgrind.spec
5514    valgrind.pc
5515    glibc-2.X.supp
5516    glibc-2.X-helgrind.supp
5517    glibc-2.X-drd.supp
5518    include/valgrind.h
5519    docs/Makefile 
5520    docs/xml/vg-entities.xml
5521    tests/Makefile 
5522    tests/vg_regtest 
5523    perf/Makefile 
5524    perf/vg_perf
5525    gdbserver_tests/Makefile
5526    gdbserver_tests/solaris/Makefile
5527    include/Makefile 
5528    auxprogs/Makefile
5529    mpi/Makefile
5530    coregrind/Makefile 
5531    memcheck/Makefile
5532    memcheck/tests/Makefile
5533    memcheck/tests/common/Makefile
5534    memcheck/tests/amd64/Makefile
5535    memcheck/tests/x86/Makefile
5536    memcheck/tests/linux/Makefile
5537    memcheck/tests/linux/debuginfod-check.vgtest
5538    memcheck/tests/darwin/Makefile
5539    memcheck/tests/solaris/Makefile
5540    memcheck/tests/freebsd/Makefile
5541    memcheck/tests/amd64-linux/Makefile
5542    memcheck/tests/arm64-linux/Makefile
5543    memcheck/tests/x86-linux/Makefile
5544    memcheck/tests/amd64-solaris/Makefile
5545    memcheck/tests/x86-solaris/Makefile
5546    memcheck/tests/amd64-freebsd/Makefile
5547    memcheck/tests/x86-freebsd/Makefile
5548    memcheck/tests/ppc32/Makefile
5549    memcheck/tests/ppc64/Makefile
5550    memcheck/tests/s390x/Makefile
5551    memcheck/tests/mips32/Makefile
5552    memcheck/tests/mips64/Makefile
5553    memcheck/tests/vbit-test/Makefile
5554    cachegrind/Makefile
5555    cachegrind/tests/Makefile
5556    cachegrind/tests/x86/Makefile
5557    cachegrind/cg_annotate
5558    cachegrind/cg_diff
5559    cachegrind/cg_merge
5560    callgrind/Makefile
5561    callgrind/callgrind_annotate
5562    callgrind/callgrind_control
5563    callgrind/tests/Makefile
5564    helgrind/Makefile
5565    helgrind/tests/Makefile
5566    drd/Makefile
5567    drd/scripts/download-and-build-splash2
5568    drd/tests/Makefile
5569    massif/Makefile
5570    massif/tests/Makefile
5571    massif/ms_print
5572    dhat/Makefile
5573    dhat/tests/Makefile
5574    lackey/Makefile
5575    lackey/tests/Makefile
5576    none/Makefile
5577    none/tests/Makefile
5578    none/tests/scripts/Makefile
5579    none/tests/amd64/Makefile
5580    none/tests/ppc32/Makefile
5581    none/tests/ppc64/Makefile
5582    none/tests/x86/Makefile
5583    none/tests/arm/Makefile
5584    none/tests/arm64/Makefile
5585    none/tests/s390x/Makefile
5586    none/tests/mips32/Makefile
5587    none/tests/mips64/Makefile
5588    none/tests/nanomips/Makefile
5589    none/tests/linux/Makefile
5590    none/tests/darwin/Makefile
5591    none/tests/solaris/Makefile
5592    none/tests/freebsd/Makefile
5593    none/tests/amd64-linux/Makefile
5594    none/tests/x86-linux/Makefile
5595    none/tests/amd64-darwin/Makefile
5596    none/tests/x86-darwin/Makefile
5597    none/tests/amd64-solaris/Makefile
5598    none/tests/x86-solaris/Makefile
5599    none/tests/x86-freebsd/Makefile
5600    exp-bbv/Makefile
5601    exp-bbv/tests/Makefile
5602    exp-bbv/tests/x86/Makefile
5603    exp-bbv/tests/x86-linux/Makefile
5604    exp-bbv/tests/amd64-linux/Makefile
5605    exp-bbv/tests/ppc32-linux/Makefile
5606    exp-bbv/tests/arm-linux/Makefile
5607    shared/Makefile
5608    solaris/Makefile
5610 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5611                 [chmod +x coregrind/link_tool_exe_linux])
5612 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5613                 [chmod +x coregrind/link_tool_exe_freebsd])
5614 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5615                 [chmod +x coregrind/link_tool_exe_darwin])
5616 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5617                 [chmod +x coregrind/link_tool_exe_solaris])
5618 AC_CONFIG_FILES([tests/filter_stderr_basic],
5619                 [chmod +x tests/filter_stderr_basic])
5620 AC_CONFIG_FILES([tests/filter_discards],
5621                 [chmod +x tests/filter_discards])
5622 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5623                 [chmod +x memcheck/tests/filter_stderr])
5624 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5625                 [chmod +x memcheck/tests/filter_dw4])
5626 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5627                 [chmod +x memcheck/tests/filter_overlaperror])
5628 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5629                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5630 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5631                 [chmod +x gdbserver_tests/filter_gdb])
5632 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5633                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5634 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5635                 [chmod +x gdbserver_tests/filter_stderr])
5636 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5637                 [chmod +x gdbserver_tests/filter_vgdb])
5638 AC_CONFIG_FILES([drd/tests/filter_stderr],
5639                 [chmod +x drd/tests/filter_stderr])
5640 AC_CONFIG_FILES([drd/tests/filter_error_count],
5641                 [chmod +x drd/tests/filter_error_count])
5642 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5643                 [chmod +x drd/tests/filter_error_summary])
5644 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5645                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5646 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5647                 [chmod +x drd/tests/filter_thread_no])
5648 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5649                 [chmod +x drd/tests/filter_xml_and_thread_no])
5650 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5651                 [chmod +x helgrind/tests/filter_stderr])
5652 AC_OUTPUT
5654 cat<<EOF
5656                     Version: ${VERSION}
5657          Maximum build arch: ${ARCH_MAX}
5658          Primary build arch: ${VGCONF_ARCH_PRI}
5659        Secondary build arch: ${VGCONF_ARCH_SEC}
5660                    Build OS: ${VGCONF_OS}
5661      Link Time Optimisation: ${vg_cv_lto}
5662        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5663      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5664            Platform variant: ${VGCONF_PLATVARIANT}
5665       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5666          Default supp files: ${DEFAULT_SUPP}