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