Fix typos in NEWS and valgrind-monitor-def.py
[valgrind.git] / configure.ac
blobd1af9de0d3cbb06d041f40046aca22dd12559222
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], [21])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [RC2])
21 m4_define([v_rel_date], ["21 Apr 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            esac
448            ;;
449         14.*)
450            AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
451            AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
452            freebsd_vers=$freebsd_14
453            ;;
454         *)
455            AC_MSG_RESULT([unsupported (${kernel})])
456            AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x])
457            ;;
458         esac
460         DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
461         ;;
463      *darwin*)
464         AC_MSG_RESULT([ok (${host_os})])
465         VGCONF_OS="darwin"
466         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
467         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
468         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
469         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
470         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
471         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
472         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
473         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
474         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
476         AC_MSG_CHECKING([for the kernel version])
477         kernel=`uname -r`
479         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
480         # has only one relevant version, the OS version. The `uname` check
481         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
482         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
483         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
484         # and we don't know of an macros similar to __GLIBC__ to get that info.
485         #
486         # XXX: `uname -r` won't do the right thing for cross-compiles, but
487         # that's not a problem yet.
488         #
489         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
490         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
491         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
492         # time support for 10.5 (the 9.* pattern just below), I'll leave it
493         # in for now, just in case anybody wants to give it a try.  But I'm
494         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
495         case "${kernel}" in
496              9.*)
497                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
498                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
499                   DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
500                   DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
501                   ;;
502              10.*)
503                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
504                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
505                   DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
506                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
507                   ;;
508              11.*)
509                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
510                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
511                   DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
512                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
513                   ;;
514              12.*)
515                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
516                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
517                   DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
518                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
519                   ;;
520              13.*)
521                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
522                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
523                   DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
524                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
525                   ;;
526              14.*)
527                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
528                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
529                   DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
530                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
531                   ;;
532              15.*)
533                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
534                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
535                   DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
536                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
537                   ;;
538              16.*)
539                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
540                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
541                   DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
542                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
543                   ;;
544              17.*)
545                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
546                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
547                   DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
548                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
549                   ;;
550              *) 
551                   AC_MSG_RESULT([unsupported (${kernel})])
552                   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)])
553                   ;;
554         esac
555         ;;
557      solaris2.11*)
558         AC_MSG_RESULT([ok (${host_os})])
559         VGCONF_OS="solaris"
561         uname_v=$( uname -v )
562         case "$uname_v" in
563              11.4.*)
564                  DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
565                  ;;
566              *)
567                  DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
568                  ;;
569         esac
570         ;;
572      solaris2.12*)
573         AC_MSG_RESULT([ok (${host_os})])
574         VGCONF_OS="solaris"
575         DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
576         ;;
578      *) 
579         AC_MSG_RESULT([no (${host_os})])
580         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
581         ;;
582 esac
584 #----------------------------------------------------------------------------
586 # If we are building on a 64 bit platform test to see if the system
587 # supports building 32 bit programs and disable 32 bit support if it
588 # does not support building 32 bit programs
590 case "$ARCH_MAX-$VGCONF_OS" in
591      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
592         AC_MSG_CHECKING([for 32 bit build support])
593         safe_CFLAGS=$CFLAGS
594         CFLAGS="-m32"
595         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
596           return 0;
597         ]])], [
598         AC_MSG_RESULT([yes])
599         ], [
600         vg_cv_only64bit="yes"
601         AC_MSG_RESULT([no])
602         ])
603         CFLAGS=$safe_CFLAGS;;
604     mips64-linux)
605         AC_MSG_CHECKING([for 32 bit build support])
606         safe_CFLAGS=$CFLAGS
607         CFLAGS="$CFLAGS -mips32 -mabi=32"
608         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
609           #include <sys/prctl.h>
610         ]], [[]])], [
611         AC_MSG_RESULT([yes])
612         ], [
613         vg_cv_only64bit="yes"
614         AC_MSG_RESULT([no])
615         ])
616         CFLAGS=$safe_CFLAGS;;
617 esac
619 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
620    AC_MSG_ERROR(
621       [--enable-only32bit was specified but system does not support 32 bit builds])
624 #----------------------------------------------------------------------------
626 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
627 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
628 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
629 # above) will be "amd64" since that reflects the most that this cpu can do,
630 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
631 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
632 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
633 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
634 AC_SUBST(VGCONF_ARCH_PRI)
636 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
637 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
638 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
639 # It is empty if there is no secondary target.
640 AC_SUBST(VGCONF_ARCH_SEC)
642 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
643 # The entire system, including regression and performance tests, will be
644 # built for this target.  The "_CAPS" indicates that the name is in capital
645 # letters, and it also uses '_' rather than '-' as a separator, because it's
646 # used to create various Makefile variables, which are all in caps by
647 # convention and cannot contain '-' characters.  This is in contrast to
648 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
649 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
651 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
652 # Valgrind and tools will also be built for this target, but not the
653 # regression or performance tests.
655 # By default, the primary arch is the same as the "max" arch, as commented
656 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
657 # the big case statement just below here, in the case where we're building
658 # on a 64 bit machine but have been requested only to do a 32 bit build.
659 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
661 AC_MSG_CHECKING([for a supported CPU/OS combination])
663 # NB.  The load address for a given platform may be specified in more 
664 # than one place, in some cases, depending on whether we're doing a biarch,
665 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
666 # Be careful to give consistent values in all subcases.  Also, all four
667 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
668 # even if it is to "0xUNSET".
670 case "$ARCH_MAX-$VGCONF_OS" in
671      x86-linux)
672         VGCONF_ARCH_PRI="x86"
673         VGCONF_ARCH_SEC=""
674         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
675         VGCONF_PLATFORM_SEC_CAPS=""
676         valt_load_address_pri_norml="0x58000000"
677         valt_load_address_pri_inner="0x38000000"
678         valt_load_address_sec_norml="0xUNSET"
679         valt_load_address_sec_inner="0xUNSET"
680         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
681         ;;
682      amd64-linux)
683         valt_load_address_sec_norml="0xUNSET"
684         valt_load_address_sec_inner="0xUNSET"
685         if test x$vg_cv_only64bit = xyes; then
686            VGCONF_ARCH_PRI="amd64"
687            VGCONF_ARCH_SEC=""
688            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
689            VGCONF_PLATFORM_SEC_CAPS=""
690            valt_load_address_pri_norml="0x58000000"
691            valt_load_address_pri_inner="0x38000000"
692         elif test x$vg_cv_only32bit = xyes; then
693            VGCONF_ARCH_PRI="x86"
694            VGCONF_ARCH_SEC=""
695            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
696            VGCONF_PLATFORM_SEC_CAPS=""
697            valt_load_address_pri_norml="0x58000000"
698            valt_load_address_pri_inner="0x38000000"
699         else
700            VGCONF_ARCH_PRI="amd64"
701            VGCONF_ARCH_SEC="x86"
702            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
703            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
704            valt_load_address_pri_norml="0x58000000"
705            valt_load_address_pri_inner="0x38000000"
706            valt_load_address_sec_norml="0x58000000"
707            valt_load_address_sec_inner="0x38000000"
708         fi
709         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
710         ;;
711      ppc32-linux)
712         VGCONF_ARCH_PRI="ppc32"
713         VGCONF_ARCH_SEC=""
714         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
715         VGCONF_PLATFORM_SEC_CAPS=""
716         valt_load_address_pri_norml="0x58000000"
717         valt_load_address_pri_inner="0x38000000"
718         valt_load_address_sec_norml="0xUNSET"
719         valt_load_address_sec_inner="0xUNSET"
720         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
721         ;;
722      ppc64be-linux)
723         valt_load_address_sec_norml="0xUNSET"
724         valt_load_address_sec_inner="0xUNSET"
725         if test x$vg_cv_only64bit = xyes; then
726            VGCONF_ARCH_PRI="ppc64be"
727            VGCONF_ARCH_SEC=""
728            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
729            VGCONF_PLATFORM_SEC_CAPS=""
730            valt_load_address_pri_norml="0x58000000"
731            valt_load_address_pri_inner="0x38000000"
732         elif test x$vg_cv_only32bit = xyes; then
733            VGCONF_ARCH_PRI="ppc32"
734            VGCONF_ARCH_SEC=""
735            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
736            VGCONF_PLATFORM_SEC_CAPS=""
737            valt_load_address_pri_norml="0x58000000"
738            valt_load_address_pri_inner="0x38000000"
739         else
740            VGCONF_ARCH_PRI="ppc64be"
741            VGCONF_ARCH_SEC="ppc32"
742            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
743            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
744            valt_load_address_pri_norml="0x58000000"
745            valt_load_address_pri_inner="0x38000000"
746            valt_load_address_sec_norml="0x58000000"
747            valt_load_address_sec_inner="0x38000000"
748         fi
749         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
750         ;;
751      ppc64le-linux)
752         # Little Endian is only supported on PPC64
753         valt_load_address_sec_norml="0xUNSET"
754         valt_load_address_sec_inner="0xUNSET"
755         VGCONF_ARCH_PRI="ppc64le"
756         VGCONF_ARCH_SEC=""
757         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
758         VGCONF_PLATFORM_SEC_CAPS=""
759         valt_load_address_pri_norml="0x58000000"
760         valt_load_address_pri_inner="0x38000000"
761         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
762        ;;
763      x86-freebsd)
764         VGCONF_ARCH_PRI="x86"
765         VGCONF_ARCH_SEC=""
766         VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
767         VGCONF_PLATFORM_SEC_CAPS=""
768         valt_load_address_pri_norml="0x38000000"
769         valt_load_address_pri_inner="0x28000000"
770         valt_load_address_sec_norml="0xUNSET"
771         valt_load_address_sec_inner="0xUNSET"
772         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
773         ;;
774      amd64-freebsd)
775         if test x$vg_cv_only64bit = xyes; then
776            VGCONF_ARCH_PRI="amd64"
777            VGCONF_ARCH_SEC=""
778            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
779            VGCONF_PLATFORM_SEC_CAPS=""
780         elif test x$vg_cv_only32bit = xyes; then
781            VGCONF_ARCH_PRI="x86"
782            VGCONF_ARCH_SEC=""
783            VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
784            VGCONF_PLATFORM_SEC_CAPS=""
785         else
786            VGCONF_ARCH_PRI="amd64"
787            VGCONF_ARCH_SEC="x86"
788            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
789            VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
790         fi
791         # These work with either base clang or ports installed gcc
792         # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
793         if test x$is_clang = xclang ; then
794            FLAG_32ON64="-B/usr/lib32"
795         else
796            GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
797            FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
798         fi
799         valt_load_address_pri_norml="0x38000000"
800         valt_load_address_pri_inner="0x28000000"
801         valt_load_address_sec_norml="0x38000000"
802         valt_load_address_sec_inner="0x28000000"
803         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
804         ;;
805      # Darwin gets identified as 32-bit even when it supports 64-bit.
806      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
807      # all Macs support both 32-bit and 64-bit, so we just build both.  If
808      # someone has a really old 32-bit only machine they can (hopefully?)
809      # build with --enable-only32bit.  See bug 243362.
810      x86-darwin|amd64-darwin)
811         ARCH_MAX="amd64"
812         valt_load_address_sec_norml="0xUNSET"
813         valt_load_address_sec_inner="0xUNSET"
814         if test x$vg_cv_only64bit = xyes; then
815            VGCONF_ARCH_PRI="amd64"
816            VGCONF_ARCH_SEC=""
817            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
818            VGCONF_PLATFORM_SEC_CAPS=""
819            valt_load_address_pri_norml="0x158000000"
820            valt_load_address_pri_inner="0x138000000"
821         elif test x$vg_cv_only32bit = xyes; then
822            VGCONF_ARCH_PRI="x86"
823            VGCONF_ARCH_SEC=""
824            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
825            VGCONF_PLATFORM_SEC_CAPS=""
826            VGCONF_ARCH_PRI_CAPS="x86"
827            valt_load_address_pri_norml="0x58000000"
828            valt_load_address_pri_inner="0x38000000"
829         else
830            VGCONF_ARCH_PRI="amd64"
831            VGCONF_ARCH_SEC="x86"
832            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
833            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
834            valt_load_address_pri_norml="0x158000000"
835            valt_load_address_pri_inner="0x138000000"
836            valt_load_address_sec_norml="0x58000000"
837            valt_load_address_sec_inner="0x38000000"
838         fi
839         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
840         ;;
841      arm-linux) 
842         VGCONF_ARCH_PRI="arm"
843         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
844         VGCONF_PLATFORM_SEC_CAPS=""
845         valt_load_address_pri_norml="0x58000000"
846         valt_load_address_pri_inner="0x38000000"
847         valt_load_address_sec_norml="0xUNSET"
848         valt_load_address_sec_inner="0xUNSET"
849         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
850         ;;
851      arm64-linux)
852         valt_load_address_sec_norml="0xUNSET"
853         valt_load_address_sec_inner="0xUNSET"
854         if test x$vg_cv_only64bit = xyes; then
855            VGCONF_ARCH_PRI="arm64"
856            VGCONF_ARCH_SEC=""
857            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
858            VGCONF_PLATFORM_SEC_CAPS=""
859            valt_load_address_pri_norml="0x58000000"
860            valt_load_address_pri_inner="0x38000000"
861         elif test x$vg_cv_only32bit = xyes; then
862            VGCONF_ARCH_PRI="arm"
863            VGCONF_ARCH_SEC=""
864            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
865            VGCONF_PLATFORM_SEC_CAPS=""
866            valt_load_address_pri_norml="0x58000000"
867            valt_load_address_pri_inner="0x38000000"
868         else
869            VGCONF_ARCH_PRI="arm64"
870            VGCONF_ARCH_SEC="arm"
871            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
872            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
873            valt_load_address_pri_norml="0x58000000"
874            valt_load_address_pri_inner="0x38000000"
875            valt_load_address_sec_norml="0x58000000"
876            valt_load_address_sec_inner="0x38000000"
877         fi
878         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
879         ;;
880      s390x-linux)
881         VGCONF_ARCH_PRI="s390x"
882         VGCONF_ARCH_SEC=""
883         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
884         VGCONF_PLATFORM_SEC_CAPS=""
885         # To improve branch prediction hit rate we want to have
886         # the generated code close to valgrind (host) code
887         valt_load_address_pri_norml="0x800000000"
888         valt_load_address_pri_inner="0x810000000"
889         valt_load_address_sec_norml="0xUNSET"
890         valt_load_address_sec_inner="0xUNSET"
891         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
892         ;;
893      mips32-linux) 
894         VGCONF_ARCH_PRI="mips32"
895         VGCONF_ARCH_SEC=""
896         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
897         VGCONF_PLATFORM_SEC_CAPS=""
898         valt_load_address_pri_norml="0x58000000"
899         valt_load_address_pri_inner="0x38000000"
900         valt_load_address_sec_norml="0xUNSET"
901         valt_load_address_sec_inner="0xUNSET"
902         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
903         ;;
904      mips64-linux)
905         valt_load_address_sec_norml="0xUNSET"
906         valt_load_address_sec_inner="0xUNSET"
907         if test x$vg_cv_only64bit = xyes; then
908             VGCONF_ARCH_PRI="mips64"
909             VGCONF_PLATFORM_SEC_CAPS=""
910             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
911             VGCONF_PLATFORM_SEC_CAPS=""
912             valt_load_address_pri_norml="0x58000000"
913             valt_load_address_pri_inner="0x38000000"
914         elif test x$vg_cv_only32bit = xyes; then
915             VGCONF_ARCH_PRI="mips32"
916             VGCONF_ARCH_SEC=""
917             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
918             VGCONF_PLATFORM_SEC_CAPS=""
919             valt_load_address_pri_norml="0x58000000"
920             valt_load_address_pri_inner="0x38000000"
921         else
922             VGCONF_ARCH_PRI="mips64"
923             VGCONF_ARCH_SEC="mips32"
924             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
925             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
926             valt_load_address_pri_norml="0x58000000"
927             valt_load_address_pri_inner="0x38000000"
928             valt_load_address_sec_norml="0x58000000"
929             valt_load_address_sec_inner="0x38000000"
930         fi
931         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
932         ;;
933      nanomips-linux)
934         VGCONF_ARCH_PRI="nanomips"
935         VGCONF_ARCH_SEC=""
936         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
937         VGCONF_PLATFORM_SEC_CAPS=""
938         valt_load_address_pri_norml="0x58000000"
939         valt_load_address_pri_inner="0x38000000"
940         valt_load_address_sec_norml="0xUNSET"
941         valt_load_address_sec_inner="0xUNSET"
942         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
943         ;;
944      x86-solaris)
945         VGCONF_ARCH_PRI="x86"
946         VGCONF_ARCH_SEC=""
947         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
948         VGCONF_PLATFORM_SEC_CAPS=""
949         valt_load_address_pri_norml="0x58000000"
950         valt_load_address_pri_inner="0x38000000"
951         valt_load_address_sec_norml="0xUNSET"
952         valt_load_address_sec_inner="0xUNSET"
953         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
954         ;;
955      amd64-solaris)
956         valt_load_address_sec_norml="0xUNSET"
957         valt_load_address_sec_inner="0xUNSET"
958         if test x$vg_cv_only64bit = xyes; then
959            VGCONF_ARCH_PRI="amd64"
960            VGCONF_ARCH_SEC=""
961            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
962            VGCONF_PLATFORM_SEC_CAPS=""
963            valt_load_address_pri_norml="0x58000000"
964            valt_load_address_pri_inner="0x38000000"
965         elif test x$vg_cv_only32bit = xyes; then
966            VGCONF_ARCH_PRI="x86"
967            VGCONF_ARCH_SEC=""
968            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
969            VGCONF_PLATFORM_SEC_CAPS=""
970            valt_load_address_pri_norml="0x58000000"
971            valt_load_address_pri_inner="0x38000000"
972         else
973            VGCONF_ARCH_PRI="amd64"
974            VGCONF_ARCH_SEC="x86"
975            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
976            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
977            valt_load_address_pri_norml="0x58000000"
978            valt_load_address_pri_inner="0x38000000"
979            valt_load_address_sec_norml="0x58000000"
980            valt_load_address_sec_inner="0x38000000"
981         fi
982         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
983         ;;
984     *)
985         VGCONF_ARCH_PRI="unknown"
986         VGCONF_ARCH_SEC="unknown"
987         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
988         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
989         valt_load_address_pri_norml="0xUNSET"
990         valt_load_address_pri_inner="0xUNSET"
991         valt_load_address_sec_norml="0xUNSET"
992         valt_load_address_sec_inner="0xUNSET"
993         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
994         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
995         ;;
996 esac
998 #----------------------------------------------------------------------------
1000 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
1001 # defined.
1002 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
1003                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1004                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1005                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1006                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1007                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1008                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1009                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1010                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1011 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
1012                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1013                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1014                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1015                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1016 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
1017                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1018                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1019 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
1020                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1021                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1022 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
1023                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1024                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1025 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
1026                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1027 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1028                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1029 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1030                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1031                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1032 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1033                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
1034 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1035                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1037 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
1038 # become defined.
1039 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
1040                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1041                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1042 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
1043                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1044 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
1045                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1046                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1047 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1048                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1049 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1050                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1051 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1052                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1053                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1054 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1055                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1056 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1057                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1058                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1059 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1060                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1061                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1062 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1063                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1064 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1065                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1066 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1067                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1068                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1069 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1070                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1071 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1072                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1073                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1074 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1075                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1076 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1077                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1078                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1079 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1080                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1083 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1084 # Relies on the assumption that the primary and secondary targets are 
1085 # for the same OS, so therefore only necessary to test the primary.
1086 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1087                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1088                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1089                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1090                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1091                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1092                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1093                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1094                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1095                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1096                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1097                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1098 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1099                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1100                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1101 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1102                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1103                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1104 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1105                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1106                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1107 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1108                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1109                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1110                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1111                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1114 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1115 # there is a secondary target.
1116 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1117                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1119 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1120 dnl fallback definition
1121 dnl The macro is courtesy of Dave Hart:
1122 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1123 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1124 if test -z "$$1_TRUE"; then :
1125   m4_n([$2])[]dnl
1126 m4_ifval([$3],
1127 [else
1128   $3
1129 ])dnl
1130 fi[]dnl
1131 ])])
1133 #----------------------------------------------------------------------------
1134 # Inner Valgrind?
1135 #----------------------------------------------------------------------------
1137 # Check if this should be built as an inner Valgrind, to be run within
1138 # another Valgrind.  Choose the load address accordingly.
1139 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1140 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1141 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1142    [AC_ARG_ENABLE(inner, 
1143       [  --enable-inner          enables self-hosting],
1144       [vg_cv_inner=$enableval],
1145       [vg_cv_inner=no])])
1146 if test "$vg_cv_inner" = yes; then
1147     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1148     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1149     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1150 else
1151     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1152     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1155 #----------------------------------------------------------------------------
1156 # Undefined behaviour sanitiser
1157 #----------------------------------------------------------------------------
1158 # Check whether we should build with the undefined beahviour sanitiser.
1160 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1161    [AC_ARG_ENABLE(ubsan, 
1162       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1163       [vg_cv_ubsan=$enableval],
1164       [vg_cv_ubsan=no])])
1166 #----------------------------------------------------------------------------
1167 # Extra fine-tuning of installation directories
1168 #----------------------------------------------------------------------------
1169 AC_ARG_WITH(tmpdir,
1170    [  --with-tmpdir=PATH      Specify path for temporary files],
1171    tmpdir="$withval",
1172    tmpdir="/tmp")
1173 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1174 AC_SUBST(VG_TMPDIR, [$tmpdir])
1176 #----------------------------------------------------------------------------
1177 # Detect xcode path
1178 #----------------------------------------------------------------------------
1179 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1180 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1181 AC_MSG_CHECKING([for xcode sdk include path])
1182 AC_ARG_WITH(xcodedir,
1183    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1184    [xcodedir="$withval"],
1185    [
1186       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1187          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1188          if test -z "$xcrundir"; then
1189             xcodedir="/usr/include"
1190          else
1191             xcodedir="$xcrundir/usr/include"
1192          fi
1193       else
1194          xcodedir="/usr/include"
1195       fi
1196    ])
1197 AC_MSG_RESULT([$xcodedir])
1198 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1199 AC_SUBST(XCODE_DIR, [$xcodedir])])
1201 #----------------------------------------------------------------------------
1202 # Libc and suppressions
1203 #----------------------------------------------------------------------------
1204 # This variable will collect the suppression files to be used.
1205 AC_SUBST(DEFAULT_SUPP)
1207 AC_CHECK_HEADER([features.h])
1209 if test x$ac_cv_header_features_h = xyes; then
1210   AC_DEFINE([HAVE_HEADER_FEATURES_H], 1,
1211           [Define to 1 if you have the `features.h' header.])
1212   rm -f conftest.$ac_ext
1213   cat <<_ACEOF >conftest.$ac_ext
1214 #include <features.h>
1215 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1216 glibc version is: __GLIBC__ __GLIBC_MINOR__
1217 #endif
1218 _ACEOF
1219   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1222 # not really a version check
1223 AC_EGREP_CPP([DARWIN_LIBC], [
1224 #include <sys/cdefs.h>
1225 #if defined(__DARWIN_VERS_1050)
1226   DARWIN_LIBC
1227 #endif
1229 GLIBC_VERSION="darwin")
1231 AC_EGREP_CPP([FREEBSD_LIBC], [
1232 #include <sys/cdefs.h>
1233 #if defined(__FreeBSD__)
1234   FREEBSD_LIBC
1235 #endif
1237 GLIBC_VERSION="freebsd")
1239 # not really a version check
1240 AC_EGREP_CPP([BIONIC_LIBC], [
1241 #if defined(__ANDROID__)
1242   BIONIC_LIBC
1243 #endif
1245 GLIBC_VERSION="bionic")
1247 # there is only one version of libc on Solaris
1248 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1249      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1250     GLIBC_VERSION="solaris"
1253 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1254 # in this case.
1255 if test x$GLIBC_VERSION = x; then
1256     if $CC -dumpmachine | grep -q musl; then
1257         GLIBC_VERSION=musl
1258     fi
1261 # If this is glibc then figure out the generic (in file) libc.so and
1262 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1263 # was a separate library, afterwards it was merged into libc.so and
1264 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1265 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1266 case ${GLIBC_VERSION} in
1268   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1269   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1270   [
1271     AC_MSG_RESULT([no])
1272     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1273     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1274   ], [
1275     AC_MSG_RESULT([yes])
1276     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1277     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1278   ])
1279   ;;
1281   AC_MSG_CHECKING([not glibc...])
1282   AC_MSG_RESULT([${GLIBC_VERSION}])
1283   ;;
1284 esac
1286 AC_MSG_CHECKING([the glibc version])
1288 case "${GLIBC_VERSION}" in
1289      2.2)
1290         AC_MSG_RESULT(${GLIBC_VERSION} family)
1291         DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1292         DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1293         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1294         ;;
1295      2.[[3-6]])
1296         AC_MSG_RESULT(${GLIBC_VERSION} family)
1297         DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1298         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1299         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1300         ;;
1301      2.[[7-9]])
1302         AC_MSG_RESULT(${GLIBC_VERSION} family)
1303         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1304         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1305         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1306         ;;
1307      2.10|2.11)
1308         AC_MSG_RESULT(${GLIBC_VERSION} family)
1309         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1310                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1311         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1312         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1313         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1314         ;;
1315      2.*)
1316         AC_MSG_RESULT(${GLIBC_VERSION} family)
1317         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1318                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1319         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1320                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1321         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1322         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1323         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1324         ;;
1325      darwin)
1326         AC_MSG_RESULT(Darwin)
1327         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1328         # DEFAULT_SUPP set by kernel version check above.
1329         ;;
1330      freebsd)
1331         AC_MSG_RESULT(FreeBSD)
1332         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1333         # DEFAULT_SUPP set by kernel version check above.
1334         ;;
1335      bionic)
1336         AC_MSG_RESULT(Bionic)
1337         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1338         DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1339         ;;
1340      solaris)
1341         AC_MSG_RESULT(Solaris)
1342         # DEFAULT_SUPP set in host_os switch-case above.
1343         # No other suppression file is used.
1344         ;;
1345      musl)
1346         AC_MSG_RESULT(Musl)
1347         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1348         DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1349         ;;
1350      2.0|2.1|*)
1351         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1352         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1353         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1354         ;;
1355 esac
1357 AC_SUBST(GLIBC_VERSION)
1358 AC_SUBST(GLIBC_LIBC_PATH)
1359 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1362 if test "$VGCONF_OS" != "solaris"; then
1363     # Add default suppressions for the X client libraries.  Make no
1364     # attempt to detect whether such libraries are installed on the
1365     # build machine (or even if any X facilities are present); just
1366     # add the suppressions antidisirregardless.
1367     DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1368     DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1372 #----------------------------------------------------------------------------
1373 # Platform variants?
1374 #----------------------------------------------------------------------------
1376 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1377 # But there are times where we need a bit more control.  The motivating
1378 # and currently only case is Android: this is almost identical to
1379 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1380 # platform variant tags, which get passed in the compile as
1381 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1383 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1384 # it is "android" instead.
1386 # Consequently (eg), plain arm-linux would build with
1388 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1390 # whilst an Android build would have
1392 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1394 # Same for x86. The setup of the platform variant is pushed relatively far
1395 # down this file in order that we can inspect any of the variables set above.
1397 # In the normal case ..
1398 VGCONF_PLATVARIANT="vanilla"
1400 # Android ?
1401 if test "$GLIBC_VERSION" = "bionic";
1402 then
1403    VGCONF_PLATVARIANT="android"
1406 AC_SUBST(VGCONF_PLATVARIANT)
1409 # FIXME: do we also want to define automake variables
1410 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1411 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1412 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1413 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1414 # that's what we'd need to do to use this, since what we'd want to write
1415 # is something like
1417 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1419 # Hmm.  Can't think of a nice clean solution to this.
1421 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1422                test x$VGCONF_PLATVARIANT = xvanilla)
1423 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1424                test x$VGCONF_PLATVARIANT = xandroid)
1427 #----------------------------------------------------------------------------
1428 # Checking for various library functions and other definitions
1429 #----------------------------------------------------------------------------
1431 # Check for AT_FDCWD
1433 AC_MSG_CHECKING([for AT_FDCWD])
1434 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1435 #define _GNU_SOURCE
1436 #include <fcntl.h>
1437 #include <unistd.h>
1438 ]], [[
1439   int a = AT_FDCWD;
1440 ]])], [
1441 ac_have_at_fdcwd=yes
1442 AC_MSG_RESULT([yes])
1443 ], [
1444 ac_have_at_fdcwd=no
1445 AC_MSG_RESULT([no])
1448 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1450 # Check for stpncpy function definition in string.h
1451 # This explicitly checks with _GNU_SOURCE defined since that is also
1452 # used in the test case (some systems might define it without anyway
1453 # since stpncpy is part of The Open Group Base Specifications Issue 7
1454 # IEEE Std 1003.1-2008.
1455 AC_MSG_CHECKING([for stpncpy])
1456 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1457 #define _GNU_SOURCE
1458 #include <string.h>
1459 ]], [[
1460   char *d;
1461   char *s;
1462   size_t n = 0;
1463   char *r = stpncpy(d, s, n);
1464 ]])], [
1465 ac_have_gnu_stpncpy=yes
1466 AC_MSG_RESULT([yes])
1467 ], [
1468 ac_have_gnu_stpncpy=no
1469 AC_MSG_RESULT([no])
1472 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1474 # Check for PTRACE_GETREGS
1476 AC_MSG_CHECKING([for PTRACE_GETREGS])
1477 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1478 #include <stdlib.h>
1479 #include <stddef.h>
1480 #include <sys/ptrace.h>
1481 #include <sys/user.h>
1482 ]], [[
1483   void *p;
1484   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1485 ]])], [
1486 AC_MSG_RESULT([yes])
1487 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1488           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1489 ], [
1490 AC_MSG_RESULT([no])
1494 # Check for CLOCK_MONOTONIC
1496 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1498 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1499 #include <time.h>
1500 ]], [[
1501   struct timespec t;
1502   clock_gettime(CLOCK_MONOTONIC, &t);
1503   return 0;
1504 ]])], [
1505 AC_MSG_RESULT([yes])
1506 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1507           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1508 ], [
1509 AC_MSG_RESULT([no])
1513 # Check for ELF32/64_CHDR
1515 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1518 # Check for PTHREAD_RWLOCK_T
1520 AC_MSG_CHECKING([for pthread_rwlock_t])
1522 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1523 #define _GNU_SOURCE
1524 #include <pthread.h>
1525 ]], [[
1526   pthread_rwlock_t rwl;
1527 ]])], [
1528 AC_MSG_RESULT([yes])
1529 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1530           [Define to 1 if you have the `pthread_rwlock_t' type.])
1531 ], [
1532 AC_MSG_RESULT([no])
1535 # Check for CLOCKID_T
1537 AC_MSG_CHECKING([for clockid_t])
1539 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1540 #include <time.h>
1541 ]], [[
1542   clockid_t c;
1543 ]])], [
1544 AC_MSG_RESULT([yes])
1545 AC_DEFINE([HAVE_CLOCKID_T], 1,
1546           [Define to 1 if you have the `clockid_t' type.])
1547 ], [
1548 AC_MSG_RESULT([no])
1551 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1553 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1555 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1556 #define _GNU_SOURCE
1557 #include <pthread.h>
1558 ]], [[
1559   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1560 ]])], [
1561 AC_MSG_RESULT([yes])
1562 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1563           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1564 ], [
1565 AC_MSG_RESULT([no])
1569 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1571 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1573 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1574 #define _GNU_SOURCE
1575 #include <pthread.h>
1576 ]], [[
1577   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1578 ]])], [
1579 AC_MSG_RESULT([yes])
1580 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1581           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1582 ], [
1583 AC_MSG_RESULT([no])
1587 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1589 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1591 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1592 #define _GNU_SOURCE
1593 #include <pthread.h>
1594 ]], [[
1595   return (PTHREAD_MUTEX_RECURSIVE_NP);
1596 ]])], [
1597 AC_MSG_RESULT([yes])
1598 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1599           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1600 ], [
1601 AC_MSG_RESULT([no])
1605 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1607 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1609 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1610 #define _GNU_SOURCE
1611 #include <pthread.h>
1612 ]], [[
1613   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1614   return 0;
1615 ]])], [
1616 AC_MSG_RESULT([yes])
1617 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1618           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1619 ], [
1620 AC_MSG_RESULT([no])
1624 # Check whether pthread_mutex_t has a member called __m_kind.
1626 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1627                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1628                            1,                                   
1629                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1630                 ],
1631                 [],
1632                 [#include <pthread.h>])
1635 # Check whether pthread_mutex_t has a member called __data.__kind.
1637 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1638                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1639                           1,
1640                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1641                 ],
1642                 [],
1643                 [#include <pthread.h>])
1645 # Convenience function.  Set flags based on the existing HWCAP entries.
1646 # The AT_HWCAP entries are generated by glibc, and are based on
1647 # functions supported by the hardware/system/libc.
1648 # Subsequent support for whether the capability will actually be utilized
1649 # will also be checked against the compiler capabilities.
1650 # called as
1651 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1652 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1653   AUXV_CHECK_FOR=$1
1654   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1655   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1656   then
1657     AC_MSG_RESULT([yes])
1658     AC_SUBST([$2],[yes])
1659   else
1660     AC_MSG_RESULT([no])
1661     AC_SUBST([$2],[])
1662   fi
1665 # gather hardware capabilities. (hardware/kernel/libc)
1666 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1667 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1668 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1669 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1670 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1671 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1672 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1673 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1674 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1675 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1677 # ISA Levels
1678 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1679 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1680 # compiler support for isa 2.07 level instructions
1681 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1682 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1683 ]], [[
1684   __asm__ __volatile__("mtvsrd 1,2 ");
1685 ]])], [
1686 ac_asm_have_isa_2_07=yes
1687 AC_MSG_RESULT([yes])
1688 ], [
1689 ac_asm_have_isa_2_07=no
1690 AC_MSG_RESULT([no])
1692 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1693                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1695 # altivec (vsx) support.
1696 # does this compiler support -maltivec and does it have the include file
1697 # <altivec.h> ?
1698 AC_MSG_CHECKING([for Altivec support in the compiler ])
1699 safe_CFLAGS=$CFLAGS
1700 CFLAGS="-maltivec -Werror"
1701 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1702 #include <altivec.h>
1703 ]], [[
1704   vector unsigned int v;
1705 ]])], [
1706 ac_have_altivec=yes
1707 AC_MSG_RESULT([yes])
1708 ], [
1709 ac_have_altivec=no
1710 AC_MSG_RESULT([no])
1712 CFLAGS=$safe_CFLAGS
1713 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1714                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1716 # Check that both: the compiler supports -mvsx and that the assembler
1717 # understands VSX instructions.  If either of those doesn't work,
1718 # conclude that we can't do VSX.
1719 AC_MSG_CHECKING([for VSX compiler flag support])
1720 safe_CFLAGS=$CFLAGS
1721 CFLAGS="-mvsx -Werror"
1722 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1723 ]], [[
1724 ]])], [
1725 ac_compiler_supports_vsx_flag=yes
1726 AC_MSG_RESULT([yes])
1727 ], [
1728 ac_compiler_supports_vsx_flag=no
1729 AC_MSG_RESULT([no])
1731 CFLAGS=$safe_CFLAGS
1733 AC_MSG_CHECKING([for VSX support in the assembler ])
1734 safe_CFLAGS=$CFLAGS
1735 CFLAGS="-mvsx -Werror"
1736 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1737 #include <altivec.h>
1738 ]], [[
1739   vector unsigned int v;
1740   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1741 ]])], [
1742 ac_compiler_supports_vsx=yes
1743 AC_MSG_RESULT([yes])
1744 ], [
1745 ac_compiler_supports_vsx=no
1746 AC_MSG_RESULT([no])
1748 CFLAGS=$safe_CFLAGS
1749 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1750                              -a x$ac_compiler_supports_vsx = xyes \
1751                              -a x$HWCAP_HAS_VSX = xyes ])
1753 # DFP (Decimal Float)
1754 # The initial DFP support was added in Power 6.  The dcffix instruction
1755 # support was added in Power 7.
1756 AC_MSG_CHECKING([that assembler knows DFP])
1757 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1758 ]], [[
1759   #ifdef __s390__
1760   __asm__ __volatile__("adtr 1, 2, 3")
1761   #else
1762 __asm__ __volatile__(".machine power7;\n" \
1763   "dadd 1, 2, 3;\n" \
1764   "dcffix 1, 2");
1765   #endif
1766 ]])], [
1767 ac_asm_have_dfp=yes
1768 AC_MSG_RESULT([yes])
1769 ], [
1770 ac_asm_have_dfp=no
1771 AC_MSG_RESULT([no])
1773 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1774 safe_CFLAGS=$CFLAGS
1775 CFLAGS="-mhard-dfp -Werror"
1777 # The dcffix instruction is Power 7
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_compiler_have_dfp=yes
1789 AC_MSG_RESULT([yes])
1790 ], [
1791 ac_compiler_have_dfp=no
1792 AC_MSG_RESULT([no])
1794 CFLAGS=$safe_CFLAGS
1795 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1796                           -a x$ac_compiler_have_dfp = xyes \
1797                           -a x$HWCAP_HAS_DFP = xyes )
1799 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1800 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1801 ]], [[
1802   _Decimal64 x = 0.0DD;
1803 ]])], [
1804 ac_compiler_have_dfp_type=yes
1805 AC_MSG_RESULT([yes])
1806 ], [
1807 ac_compiler_have_dfp_type=no
1808 AC_MSG_RESULT([no])
1810 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1811                                   -a x$HWCAP_HAS_DFP = xyes )
1814 # HTM (Hardware Transactional Memory)
1815 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1816 safe_CFLAGS=$CFLAGS
1817 CFLAGS="-mhtm -Werror"
1818 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1819 ]], [[
1820   return 0;
1821 ]])], [
1822 AC_MSG_RESULT([yes])
1823 ac_compiler_supports_htm=yes
1824 ], [
1825 AC_MSG_RESULT([no])
1826 ac_compiler_supports_htm=no
1828 CFLAGS=$safe_CFLAGS
1830 AC_MSG_CHECKING([if compiler can find the htm builtins])
1831 safe_CFLAGS=$CFLAGS
1832 CFLAGS="-mhtm -Werror"
1833  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1834  ]], [[
1835    if (__builtin_tbegin (0))
1836       __builtin_tend (0);
1837  ]])], [
1838  AC_MSG_RESULT([yes])
1839 ac_compiler_sees_htm_builtins=yes
1840  ], [
1841  AC_MSG_RESULT([no])
1842 ac_compiler_sees_htm_builtins=no
1843  ])
1844 CFLAGS=$safe_CFLAGS
1846 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1847                                -a x$ac_compiler_sees_htm_builtins = xyes \
1848                                -a x$HWCAP_HAS_HTM = xyes )
1850 # isa 3.0 checking. (actually 3.0 or newer)
1851 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1854 ]], [[
1855 __asm__ __volatile__ (".machine power9;\n" \
1856         "cnttzw   1,3; \n" );
1857 ]])], [
1858 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1859 # cpabort support
1860 safe_CFLAGS=$CFLAGS
1861 CFLAGS="-DHAS_ISA_3_00"
1862 ac_asm_have_isa_3_00=yes
1863 AC_MSG_RESULT([yes])
1864 ], [
1865 ac_asm_have_isa_3_00=no
1866 AC_MSG_RESULT([no])
1868 CFLAGS=$safe_CFLAGS
1870 # xscvhpdp checking
1871 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1873 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1874 ]], [[
1875 __asm__ __volatile__ (".machine power9;\n" \
1876         "xscvhpdp 1,2;\n" );
1877 ]])], [
1878 ac_asm_have_xscvhpdp=yes
1879 AC_MSG_RESULT([yes])
1880 ], [
1881 ac_asm_have_xscvhpdp=no
1882 AC_MSG_RESULT([no])
1885 # darn instruction checking
1886 AC_MSG_CHECKING([that assembler knows darn instruction ])
1888 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1889 ]], [[
1890   __asm__ __volatile__(".machine power9; darn 1,0 ");
1891 ]])], [
1892 ac_asm_have_darn_inst=yes
1893 AC_MSG_RESULT([yes])
1894 ], [
1895 ac_asm_have_darn_inst=no
1896 AC_MSG_RESULT([no])
1899 # isa 3.01 checking
1900 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1901 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1902 ]], [[
1903 __asm__ __volatile__ (".machine power10;\n" \
1904         "brh 1,2;\n ");
1905 ]])], [
1906 ac_asm_have_isa_3_1=yes
1907 AC_MSG_RESULT([yes])
1908 ], [
1909 ac_asm_have_isa_3_1=no
1910 AC_MSG_RESULT([no])
1914 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1915                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1917 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1918 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1920 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1921                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1923 # Check for pthread_create@GLIBC2.0
1924 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1926 safe_CFLAGS=$CFLAGS
1927 CFLAGS="-lpthread -Werror"
1928 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1929 extern int pthread_create_glibc_2_0(void*, const void*,
1930                                     void *(*)(void*), void*);
1931 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1932 ]], [[
1933 #ifdef __powerpc__
1935  * Apparently on PowerPC linking this program succeeds and generates an
1936  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1937  */
1938 #error This test does not work properly on PowerPC.
1939 #else
1940   pthread_create_glibc_2_0(0, 0, 0, 0);
1941 #endif
1942   return 0;
1943 ]])], [
1944 ac_have_pthread_create_glibc_2_0=yes
1945 AC_MSG_RESULT([yes])
1946 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1947           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1948 ], [
1949 ac_have_pthread_create_glibc_2_0=no
1950 AC_MSG_RESULT([no])
1952 CFLAGS=$safe_CFLAGS
1954 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1955                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1958 # Check for dlinfo RTLD_DI_TLS_MODID
1959 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1961 safe_LIBS="$LIBS"
1962 LIBS="-ldl"
1963 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1964 #ifndef _GNU_SOURCE
1965 #define _GNU_SOURCE
1966 #endif
1967 #include <link.h>
1968 #include <dlfcn.h>
1969 ]], [[
1970   size_t sizes[10000];
1971   size_t modid_offset;
1972   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1973   return 0;
1974 ]])], [
1975 ac_have_dlinfo_rtld_di_tls_modid=yes
1976 AC_MSG_RESULT([yes])
1977 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1978           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1979 ], [
1980 ac_have_dlinfo_rtld_di_tls_modid=no
1981 AC_MSG_RESULT([no])
1983 LIBS=$safe_LIBS
1985 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1986                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1989 # Check for eventfd_t, eventfd() and eventfd_read()
1990 AC_MSG_CHECKING([for eventfd()])
1992 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1993 #include <sys/eventfd.h>
1994 ]], [[
1995   eventfd_t ev;
1996   int fd;
1998   fd = eventfd(5, 0);
1999   eventfd_read(fd, &ev);
2000   return 0;
2001 ]])], [
2002 AC_MSG_RESULT([yes])
2003 AC_DEFINE([HAVE_EVENTFD], 1,
2004           [Define to 1 if you have the `eventfd' function.])
2005 AC_DEFINE([HAVE_EVENTFD_READ], 1,
2006           [Define to 1 if you have the `eventfd_read' function.])
2007 ], [
2008 AC_MSG_RESULT([no])
2011 # Check whether compiler can process #include <thread> without errors
2012 # clang 3.3 cannot process <thread> from e.g.
2013 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
2015 AC_MSG_CHECKING([that C++ compiler can compile C++17 code])
2016 AC_LANG(C++)
2017 safe_CXXFLAGS=$CXXFLAGS
2018 CXXFLAGS=-std=c++17
2020 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2021 int x;
2022 ])],
2024 ac_have_cxx_17=yes
2025 AC_MSG_RESULT([yes])
2026 ], [
2027 ac_have_cxx_17=no
2028 AC_MSG_RESULT([no])
2030 CXXFLAGS=$safe_CXXFLAGS
2031 AC_LANG(C)
2033 AM_CONDITIONAL(HAVE_CXX17, test x$ac_have_cxx_17 = xyes)
2035 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
2036 AC_LANG(C++)
2037 safe_CXXFLAGS=$CXXFLAGS
2038 CXXFLAGS=-std=c++0x
2040 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2041 #include <thread> 
2042 ])],
2044 ac_cxx_can_include_thread_header=yes
2045 AC_MSG_RESULT([yes])
2046 ], [
2047 ac_cxx_can_include_thread_header=no
2048 AC_MSG_RESULT([no])
2050 CXXFLAGS=$safe_CXXFLAGS
2051 AC_LANG(C)
2053 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2055 # Check whether compiler can process #include <condition_variable> without errors
2057 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2058 AC_LANG(C++)
2059 safe_CXXFLAGS=$CXXFLAGS
2060 CXXFLAGS=-std=c++0x
2062 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2063 #include <condition_variable> 
2064 ])],
2066 ac_cxx_can_include_condition_variable_header=yes
2067 AC_MSG_RESULT([yes])
2068 ], [
2069 ac_cxx_can_include_condition_variable_header=no
2070 AC_MSG_RESULT([no])
2072 CXXFLAGS=$safe_CXXFLAGS
2073 AC_LANG(C)
2075 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2077 # check for std::shared_timed_mutex, this is a C++ 14 feature
2079 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2080 AC_LANG(C++)
2081 safe_CXXFLAGS=$CXXFLAGS
2082 CXXFLAGS="-std=c++1y -pthread"
2084 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2085 #include <shared_mutex>
2086 std::shared_timed_mutex test_mutex;
2087 ])],
2089 ac_cxx_can_use_shared_timed_mutex=yes
2090 AC_MSG_RESULT([yes])
2091 ], [
2092 ac_cxx_can_use_shared_timed_mutex=no
2093 AC_MSG_RESULT([no])
2095 CXXFLAGS=$safe_CXXFLAGS
2096 AC_LANG(C)
2098 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2100 # check for std::shared_mutex, this is a C++ 11 feature
2102 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2103 AC_LANG(C++)
2104 safe_CXXFLAGS=$CXXFLAGS
2105 CXXFLAGS="-std=c++0x -pthread"
2107 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2108 #include <mutex>
2109 std::timed_mutex test_mutex;
2110 ])],
2112 ac_cxx_can_use_timed_mutex=yes
2113 AC_MSG_RESULT([yes])
2114 ], [
2115 ac_cxx_can_use_timed_mutex=no
2116 AC_MSG_RESULT([no])
2118 CXXFLAGS=$safe_CXXFLAGS
2119 AC_LANG(C)
2121 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2123 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2124 # of the user_regs_struct from sys/user.h. They are structurally the same
2125 # but we get either one or the other.
2127 AC_CHECK_TYPE([struct user_regs_struct],
2128               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2129               [[#include <sys/ptrace.h>]
2130                [#include <sys/time.h>]
2131                [#include <sys/user.h>]])
2132 if test "$sys_user_has_user_regs" = "yes"; then
2133   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2134             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2137 AC_MSG_CHECKING([for __NR_membarrier])
2138 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2139 #include <linux/unistd.h>
2140 ]], [[
2141 return __NR_membarrier
2142 ]])], [
2143 ac_have_nr_membarrier=yes
2144 AC_MSG_RESULT([yes])
2145 ], [
2146 ac_have_nr_membarrier=no
2147 AC_MSG_RESULT([no])
2150 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2152 #----------------------------------------------------------------------------
2153 # Checking for supported compiler flags.
2154 #----------------------------------------------------------------------------
2156 case "${host_cpu}" in
2157     mips*)
2158         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2159         if test -z "$ARCH"; then
2160           # does this compiler support -march=mips32 (mips32 default) ?
2161           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2163           safe_CFLAGS=$CFLAGS
2164           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2166           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2167             return 0;
2168           ]])], [
2169           FLAG_M32="-mips32 -mabi=32"
2170           AC_MSG_RESULT([yes])
2171           ], [
2172           FLAG_M32=""
2173           AC_MSG_RESULT([no])
2174           ])
2175           CFLAGS=$safe_CFLAGS
2177           AC_SUBST(FLAG_M32)
2180           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2181           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2183           safe_CFLAGS=$CFLAGS
2184           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2186           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2187             return 0;
2188           ]])], [
2189           FLAG_M64="-march=mips64r2 -mabi=64"
2190           AC_MSG_RESULT([yes])
2191           ], [
2192           FLAG_M64=""
2193           AC_MSG_RESULT([no])
2194           ])
2195           CFLAGS=$safe_CFLAGS
2197           AC_SUBST(FLAG_M64)
2198         fi
2199         ;;
2200     nanomips*)
2201         ;;
2202     *)
2203         # does this compiler support -m32 ?
2204         AC_MSG_CHECKING([if gcc accepts -m32])
2206         safe_CFLAGS=$CFLAGS
2207         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2209         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2210           return 0;
2211         ]])], [
2212         FLAG_M32="${FLAG_32ON64} -m32"
2213         AC_MSG_RESULT([yes])
2214         ], [
2215         FLAG_M32=""
2216         AC_MSG_RESULT([no])
2217         ])
2218         CFLAGS=$safe_CFLAGS
2220         AC_SUBST(FLAG_M32)
2223         # does this compiler support -m64 ?
2224         AC_MSG_CHECKING([if gcc accepts -m64])
2226         safe_CFLAGS=$CFLAGS
2227         CFLAGS="-m64 -Werror"
2229         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2230           return 0;
2231         ]])], [
2232         FLAG_M64="-m64"
2233         AC_MSG_RESULT([yes])
2234         ], [
2235         FLAG_M64=""
2236         AC_MSG_RESULT([no])
2237         ])
2238         CFLAGS=$safe_CFLAGS
2240         AC_SUBST(FLAG_M64)
2241         ;;
2242 esac
2245 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2246 if test -z "$ARCH"; then
2247   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2248   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2250   safe_CFLAGS=$CFLAGS
2251   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2253   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2254     return 0;
2255   ]])], [
2256   FLAG_OCTEON="-march=octeon"
2257   AC_MSG_RESULT([yes])
2258   ], [
2259   FLAG_OCTEON=""
2260   AC_MSG_RESULT([no])
2261   ])
2262   CFLAGS=$safe_CFLAGS
2264   AC_SUBST(FLAG_OCTEON)
2267   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2268   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2270   safe_CFLAGS=$CFLAGS
2271   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2273   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2274     return 0;
2275   ]])], [
2276   FLAG_OCTEON2="-march=octeon2"
2277   AC_MSG_RESULT([yes])
2278   ], [
2279   FLAG_OCTEON2=""
2280   AC_MSG_RESULT([no])
2281   ])
2282   CFLAGS=$safe_CFLAGS
2284   AC_SUBST(FLAG_OCTEON2)
2288 # does this compiler support -mmsa (MIPS MSA ASE) ?
2289 AC_MSG_CHECKING([if gcc accepts -mmsa])
2291 safe_CFLAGS=$CFLAGS
2292 CFLAGS="$CFLAGS -mmsa -Werror"
2294 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2295     return 0;
2296 ]])], [
2297 FLAG_MSA="-mmsa"
2298 AC_MSG_RESULT([yes])
2299 ], [
2300 FLAG_MSA=""
2301 AC_MSG_RESULT([no])
2303 CFLAGS=$safe_CFLAGS
2305 AC_SUBST(FLAG_MSA)
2307 # Are we compiling for the MIPS64 n32 ABI?
2308 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2309 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2310 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2311 #error NO
2312 #endif
2313 ]])], [
2314 VGCONF_ABI=N32
2315 FLAG_M64="-march=mips64r2 -mabi=n32"
2316 AC_MSG_RESULT([yes])
2317 ], [
2318 AC_MSG_RESULT([no])
2321 # Are we compiling for the MIPS64 n64 ABI?
2322 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2323 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2324 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2325 #error NO
2326 #endif
2327 ]])], [
2328 VGCONF_ABI=64
2329 AC_MSG_RESULT([yes])
2330 ], [
2331 AC_MSG_RESULT([no])
2334 # We enter the code block below in the following case:
2335 # Target architecture is set to mips64, the desired abi
2336 # was not specified and the compiler's default abi setting
2337 # is neither n32 nor n64.
2338 # Probe for and set the abi to either n64 or n32, in that order,
2339 # which is required for a mips64 build of valgrind.
2340 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2341   safe_CFLAGS=$CFLAGS
2342   CFLAGS="$CFLAGS -mabi=64 -Werror"
2343   AC_MSG_CHECKING([if gcc is n64 capable])
2344   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2345       return 0;
2346   ]])], [
2347   VGCONF_ABI=64
2348   AC_MSG_RESULT([yes])
2349   ], [
2350   AC_MSG_RESULT([no])
2351   ])
2352   CFLAGS=$safe_CFLAGS
2354   if test "x$VGCONF_ABI" = "x"; then
2355     safe_CFLAGS=$CFLAGS
2356     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2357     AC_MSG_CHECKING([if gcc is n32 capable])
2358     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2359         return 0;
2360     ]])], [
2361     VGCONF_ABI=N32
2362     FLAG_M64="-march=mips64r2 -mabi=n32"
2363     AC_MSG_RESULT([yes])
2364     ], [
2365     AC_MSG_RESULT([no])
2366     ])
2367     CFLAGS=$safe_CFLAGS
2368   fi
2371 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2372                [test x$VGCONF_ABI != x])
2373 AC_SUBST(VGCONF_ABI)
2376 # does this compiler support -mmmx ?
2377 AC_MSG_CHECKING([if gcc accepts -mmmx])
2379 safe_CFLAGS=$CFLAGS
2380 CFLAGS="-mmmx -Werror"
2382 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2383   return 0;
2384 ]])], [
2385 FLAG_MMMX="-mmmx"
2386 AC_MSG_RESULT([yes])
2387 ], [
2388 FLAG_MMMX=""
2389 AC_MSG_RESULT([no])
2391 CFLAGS=$safe_CFLAGS
2393 AC_SUBST(FLAG_MMMX)
2396 # does this compiler support -msse ?
2397 AC_MSG_CHECKING([if gcc accepts -msse])
2399 safe_CFLAGS=$CFLAGS
2400 CFLAGS="-msse -Werror"
2402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2403   return 0;
2404 ]])], [
2405 FLAG_MSSE="-msse"
2406 AC_MSG_RESULT([yes])
2407 ], [
2408 FLAG_MSSE=""
2409 AC_MSG_RESULT([no])
2411 CFLAGS=$safe_CFLAGS
2413 AC_SUBST(FLAG_MSSE)
2416 # does this compiler support -mpreferred-stack-boundary=2 when
2417 # generating code for a 32-bit target?  Note that we only care about
2418 # this when generating code for (32-bit) x86, so if the compiler
2419 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2420 # the Memcheck and other helper functions, that is a bit slower than
2421 # it could be, on x86; and no difference at all on any other platform.
2422 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2424 safe_CFLAGS=$CFLAGS
2425 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2427 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2428   return 0;
2429 ]])], [
2430 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2431 AC_MSG_RESULT([yes])
2432 ], [
2433 PREFERRED_STACK_BOUNDARY_2=""
2434 AC_MSG_RESULT([no])
2436 CFLAGS=$safe_CFLAGS
2438 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2441 # does this compiler support -mlong-double-128 ?
2442 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2443 safe_CFLAGS=$CFLAGS
2444 CFLAGS="-mlong-double-128 -Werror"
2445 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2446   return 0;
2447 ]])], [
2448 ac_compiler_supports_mlong_double_128=yes
2449 AC_MSG_RESULT([yes])
2450 ], [
2451 ac_compiler_supports_mlong_double_128=no
2452 AC_MSG_RESULT([no])
2454 CFLAGS=$safe_CFLAGS
2455 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2456 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2457 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2459 # does this toolchain support lto ?
2460 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2461 # are not defined
2462 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2463 # a lot slower, and so not appropriate for Valgrind developments.
2464 # --enable-lto=yes should be used by distro packagers.
2465 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2466    [AC_ARG_ENABLE(lto,
2467       [  --enable-lto          enables building with link time optimisation],
2468       [vg_cv_lto=$enableval],
2469       [vg_cv_lto=no])])
2471 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2472 AC_MSG_CHECKING([if toolchain accepts lto])
2473 safe_CFLAGS=$CFLAGS
2474 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2475 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2476 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2477 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2479 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2480   extern void somefun(void);
2481   somefun();
2482   return 0;
2483 ]])], [
2484 LTO_CFLAGS=$TEST_LTO_CFLAGS
2485 AC_MSG_RESULT([yes])
2486 ], [
2487 LTO_CFLAGS=""
2488 AC_MSG_RESULT([no])
2490 CFLAGS=$safe_CFLAGS
2493 AC_SUBST(LTO_CFLAGS)
2495 # if we could not compile with lto args, or lto was disabled,
2496 # then set LTO_AR/LTO_RANLIB to the non lto values
2497 # define in config.h ENABLE_LTO (not needed by the code currently, but
2498 # this guarantees we recompile everything if we re-configure and rebuild
2499 # in a build dir previously build with another value of --enable-lto
2500 if test "x${LTO_CFLAGS}" = "x"; then
2501    LTO_AR=${AR}
2502    LTO_RANLIB=${RANLIB}
2503    vg_cv_lto=no
2504 else
2505    vg_cv_lto=yes
2506    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2509 # Convenience function to check whether GCC supports a particular
2510 # warning option. Takes two arguments,
2511 # first the warning flag name to check (without -W), then the
2512 # substitution name to set with -Wno-warning-flag if the flag exists,
2513 # or the empty string if the compiler doesn't accept the flag. Note
2514 # that checking is done against the warning flag itself, but the
2515 # substitution is then done to cancel the warning flag.
2516 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2517   AC_MSG_CHECKING([if gcc accepts -W$1])
2518   safe_CFLAGS=$CFLAGS
2519   CFLAGS="-W$1 -Werror"
2520   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2521   AC_SUBST([$2], [-Wno-$1])
2522   AC_MSG_RESULT([yes])], [
2523   AC_SUBST([$2], [])
2524   AC_MSG_RESULT([no])])
2525   CFLAGS=$safe_CFLAGS
2528 # A variation of the above for arguments that
2529 # take a value
2530 AC_DEFUN([AC_GCC_WARNING_SUBST_NO_VAL],[
2531   AC_MSG_CHECKING([if gcc accepts -W$1=$2])
2532   safe_CFLAGS=$CFLAGS
2533   CFLAGS="-W$1=$2 -Werror"
2534   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2535   AC_SUBST([$3], [-Wno-$1])
2536   AC_MSG_RESULT([yes])], [
2537   AC_SUBST([$3], [])
2538   AC_MSG_RESULT([no])])
2539   CFLAGS=$safe_CFLAGS
2542 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2543 # -W$1  (instead of -Wno-$1).
2544 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2545   AC_MSG_CHECKING([if gcc accepts -W$1])
2546   safe_CFLAGS=$CFLAGS
2547   CFLAGS="-W$1 -Werror"
2548   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2549   AC_SUBST([$2], [-W$1])
2550   AC_MSG_RESULT([yes])], [
2551   AC_SUBST([$2], [])
2552   AC_MSG_RESULT([no])])
2553   CFLAGS=$safe_CFLAGS
2556 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2557 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2558 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2559 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2560 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2561 AC_GCC_WARNING_SUBST_NO([maybe-uninitialized], [FLAG_W_NO_MAYBE_UNINITIALIZED])
2562 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2563 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2564 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2565 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2566 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2567 AC_GCC_WARNING_SUBST_NO([unused-but-set-variable], [FLAG_W_NO_UNUSED_BUT_SET_VARIABLE])
2568 AC_GCC_WARNING_SUBST_NO([non-power-of-two-alignment], [FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT])
2569 AC_GCC_WARNING_SUBST_NO([sign-compare], [FLAG_W_NO_SIGN_COMPARE])
2570 AC_GCC_WARNING_SUBST_NO([stringop-overflow], [FLAG_W_NO_STRINGOP_OVERFLOW])
2571 AC_GCC_WARNING_SUBST_NO([stringop-overread], [FLAG_W_NO_STRINGOP_OVERREAD])
2572 AC_GCC_WARNING_SUBST_NO([stringop-truncation], [FLAG_W_NO_STRINGOP_TRUNCATION])
2573 AC_GCC_WARNING_SUBST_NO([format-overflow], [FLAG_W_NO_FORMAT_OVERFLOW])
2574 AC_GCC_WARNING_SUBST_NO([use-after-free], [FLAG_W_NO_USE_AFTER_FREE])
2575 AC_GCC_WARNING_SUBST_NO([free-nonheap-object], [FLAG_W_NO_FREE_NONHEAP_OBJECT])
2576 AC_GCC_WARNING_SUBST_NO([fortify-source], [FLAG_W_NO_FORTIFY_SOURCE])
2577 AC_GCC_WARNING_SUBST_NO([builtin-memcpy-chk-size], [FLAG_W_NO_BUILTIN_MEMCPY_CHK_SIZE])
2578 AC_GCC_WARNING_SUBST_NO([incompatible-pointer-types-discards-qualifiers], [FLAG_W_NO_INCOMPATIBLE_POINTER_TYPES_DISCARDS_QUALIFIERS])
2579 AC_GCC_WARNING_SUBST_NO([suspicious-bzero], [FLAG_W_NO_SUSPICIOUS_BZERO])
2581 AC_GCC_WARNING_SUBST_NO_VAL([alloc-size-larger-than], [1677216], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN])
2583 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2584 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2585 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2586 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2587 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2588 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2589 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2590 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2591 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2592 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2593 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2595 # Does this compiler support -Wformat-security ?
2596 # Special handling is needed, because certain GCC versions require -Wformat
2597 # being present if -Wformat-security is given. Otherwise a warning is issued.
2598 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2599 # And with that the warning will be turned into an error with the result
2600 # that -Wformat-security is believed to be unsupported when in fact it is.
2601 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2602 safe_CFLAGS=$CFLAGS
2603 CFLAGS="-Wformat -Wformat-security -Werror"
2604 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2605 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2606 AC_MSG_RESULT([yes])], [
2607 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2608 AC_MSG_RESULT([no])])
2609 CFLAGS=$safe_CFLAGS
2611 # does this compiler support -Wextra or the older -W ?
2613 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2615 safe_CFLAGS=$CFLAGS
2616 CFLAGS="-Wextra -Werror"
2618 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2619   return 0;
2620 ]])], [
2621 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2622 AC_MSG_RESULT([-Wextra])
2623 ], [
2624   CFLAGS="-W -Werror"
2625   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2626     return 0;
2627   ]])], [
2628   AC_SUBST([FLAG_W_EXTRA], [-W])
2629   AC_MSG_RESULT([-W])
2630   ], [
2631   AC_SUBST([FLAG_W_EXTRA], [])
2632   AC_MSG_RESULT([not supported])
2633   ])
2635 CFLAGS=$safe_CFLAGS
2637 # On ARM we do not want to pass -Wcast-align as that produces loads
2638 # of warnings. GCC is just being conservative. See here:
2639 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2640 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2641   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2642 else
2643   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2646 # does this compiler support -faligned-new ?
2647 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2649 safe_CXXFLAGS=$CXXFLAGS
2650 CXXFLAGS="-faligned-new -Werror"
2652 AC_LANG(C++)
2653 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2654   return 0;
2655 ]])], [
2656 FLAG_FALIGNED_NEW="-faligned-new"
2657 AC_MSG_RESULT([yes])
2658 ], [
2659 FLAG_FALIGNED_NEW=""
2660 AC_MSG_RESULT([no])
2662 CXXFLAGS=$safe_CXXFLAGS
2663 AC_LANG(C)
2665 AC_SUBST(FLAG_FALIGNED_NEW)
2667 # does this compiler support -fsized-deallocation ?
2668 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2670 safe_CXXFLAGS=$CXXFLAGS
2671 CXXFLAGS="-fsized-deallocation -Werror"
2673 AC_LANG(C++)
2674 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2675   return 0;
2676 ]])], [
2677 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2678 ac_have_sized_deallocation=yes
2679 AC_MSG_RESULT([yes])
2680 ], [
2681 FLAG_FSIZED_DEALLOCATION=""
2682 ac_have_sized_deallocation=no
2683 AC_MSG_RESULT([no])
2685 CXXFLAGS=$safe_CXXFLAGS
2686 AC_LANG(C)
2688 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2689 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2691 # does this compiler support C++17 aligned new/delete?
2692 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2694 safe_CXXFLAGS=$CXXFLAGS
2695 CXXFLAGS="-std=c++17"
2697 AC_LANG(C++)
2698 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2699 #include <cstdlib>
2700 #include <new>
2701 ]], [[
2702   operator delete(nullptr, std::align_val_t(64U));
2703 ]])], [
2704 ac_have_aligned_cxx_alloc=yes
2705 AC_MSG_RESULT([yes])
2706 ], [
2707 ac_have_aligned_cxx_alloc=no
2708 AC_MSG_RESULT([no])
2710 CXXFLAGS=$safe_CXXFLAGS
2711 AC_LANG(C)
2713 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2715 # does this compiler support -fno-stack-protector ?
2716 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2718 safe_CFLAGS=$CFLAGS
2719 CFLAGS="-fno-stack-protector -Werror"
2721 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2722   return 0;
2723 ]])], [
2724 no_stack_protector=yes
2725 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2726 AC_MSG_RESULT([yes])
2727 ], [
2728 no_stack_protector=no
2729 FLAG_FNO_STACK_PROTECTOR=""
2730 AC_MSG_RESULT([no])
2732 CFLAGS=$safe_CFLAGS
2734 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2736 # does this compiler support -finline-functions ?
2737 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2739 safe_CFLAGS=$CFLAGS
2740 CFLAGS="-finline-functions -Werror"
2742 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2743   return 0;
2744 ]])], [
2745 inline_functions=yes
2746 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2747 AC_MSG_RESULT([yes])
2748 ], [
2749 inline_functions=no
2750 FLAG_FINLINE_FUNCTIONS=""
2751 AC_MSG_RESULT([no])
2753 CFLAGS=$safe_CFLAGS
2755 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2757 # Does GCC support disabling Identical Code Folding?
2758 # We want to disabled Identical Code Folding for the
2759 # tools preload shared objects to get better backraces.
2760 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2761 # "The optimization reduces code size and may disturb
2762 #  unwind stacks by replacing a function by equivalent
2763 #  one with a different name."
2764 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2766 safe_CFLAGS=$CFLAGS
2767 CFLAGS="-fno-ipa-icf -Werror"
2769 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2770   return 0;
2771 ]])], [
2772 no_ipa_icf=yes
2773 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2774 AC_MSG_RESULT([yes])
2775 ], [
2776 no_ipa_icf=no
2777 FLAG_FNO_IPA_ICF=""
2778 AC_MSG_RESULT([no])
2780 CFLAGS=$safe_CFLAGS
2782 AC_SUBST(FLAG_FNO_IPA_ICF)
2785 # Does this compiler support -fsanitize=undefined. This is true for
2786 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2787 # also checks for alignment violations on memory accesses which the valgrind
2788 # code base is sprinkled (if not littered) with. As those alignment issues
2789 # don't pose a problem we want to suppress warnings about them.
2790 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2791 # GCCs do not support that.
2793 # Only checked for if --enable-ubsan was given.
2794 if test "x${vg_cv_ubsan}" = "xyes"; then
2795 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2796 safe_CFLAGS=$CFLAGS
2797 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2798 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2799   return 0;
2800 ]])], [
2801 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2802 LIB_UBSAN="-static-libubsan"
2803 AC_MSG_RESULT([yes])
2804 ], [
2805 CFLAGS="-fsanitize=undefined -Werror"
2806 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2807   return 0;
2808 ]])], [
2809 FLAG_FSANITIZE="-fsanitize=undefined"
2810 LIB_UBSAN="-static-libubsan"
2811 AC_MSG_RESULT([yes])
2812 ], [
2813 FLAG_FSANITIZE=""
2814 LIB_UBSAN=""
2815 AC_MSG_RESULT([no])
2818 CFLAGS=$safe_CFLAGS
2819 AC_SUBST(FLAG_FSANITIZE)
2820 AC_SUBST(LIB_UBSAN)
2822 # does this compiler support --param inline-unit-growth=... ?
2824 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2826 safe_CFLAGS=$CFLAGS
2827 CFLAGS="--param inline-unit-growth=900 -Werror"
2829 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2830   return 0;
2831 ]])], [
2832 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2833          ["--param inline-unit-growth=900"])
2834 AC_MSG_RESULT([yes])
2835 ], [
2836 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2837 AC_MSG_RESULT([no])
2839 CFLAGS=$safe_CFLAGS
2842 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2844 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2846 safe_CFLAGS=$CFLAGS
2847 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2849 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2850   return 0;
2851 ]])], [
2852 ac_have_dwarf4=yes
2853 AC_MSG_RESULT([yes])
2854 ], [
2855 ac_have_dwarf4=no
2856 AC_MSG_RESULT([no])
2858 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2859 CFLAGS=$safe_CFLAGS
2862 # does this compiler support -g -gz=zlib ?
2864 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2866 safe_CFLAGS=$CFLAGS
2867 CFLAGS="-g -gz=zlib"
2869 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2870   return 0;
2871 ]])], [
2872 ac_have_gz_zlib=yes
2873 AC_MSG_RESULT([yes])
2874 ], [
2875 ac_have_gz_zlib=no
2876 AC_MSG_RESULT([no])
2878 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2879 CFLAGS=$safe_CFLAGS
2882 # does this compiler support -g -gz=zlib-gnu ?
2884 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2886 safe_CFLAGS=$CFLAGS
2887 CFLAGS="-g -gz=zlib-gnu"
2889 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2890   return 0;
2891 ]])], [
2892 ac_have_gz_zlib_gnu=yes
2893 AC_MSG_RESULT([yes])
2894 ], [
2895 ac_have_gz_zlib_gnu=no
2896 AC_MSG_RESULT([no])
2898 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2899 CFLAGS=$safe_CFLAGS
2902 # does this compiler support nested functions ?
2904 AC_MSG_CHECKING([if gcc accepts nested functions])
2906 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2907   int foo() { return 1; }
2908   return foo();
2909 ]])], [
2910 ac_have_nested_functions=yes
2911 AC_MSG_RESULT([yes])
2912 ], [
2913 ac_have_nested_functions=no
2914 AC_MSG_RESULT([no])
2916 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2919 # does this compiler support the 'p' constraint in ASM statements ?
2921 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2923 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2924    char *p;
2925    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2926 ]])], [
2927 ac_have_asm_constraint_p=yes
2928 AC_MSG_RESULT([yes])
2929 ], [
2930 ac_have_asm_constraint_p=no
2931 AC_MSG_RESULT([no])
2933 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2936 # Does this compiler and linker support -pie?
2937 # Some compilers actually do not support -pie and report its usage
2938 # as an error. We need to check if it is safe to use it first.
2940 AC_MSG_CHECKING([if gcc accepts -pie])
2942 safe_CFLAGS=$CFLAGS
2943 CFLAGS="-pie"
2945 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2946   return 0;
2947 ]])], [
2948 AC_SUBST([FLAG_PIE], ["-pie"])
2949 AC_MSG_RESULT([yes])
2950 ], [
2951 AC_SUBST([FLAG_PIE], [""])
2952 AC_MSG_RESULT([no])
2954 CFLAGS=$safe_CFLAGS
2956 AC_MSG_CHECKING([if gcc accepts -ansi])
2958 safe_CFLAGS=$CFLAGS
2959 CFLAGS="-ansi"
2961 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2962    return 0;
2963 ]])], [
2964 ac_have_ansi=yes
2965 AC_MSG_RESULT([yes])
2966 ], [
2967 ac_have_ansi=no
2968 AC_MSG_RESULT([no])
2970 AM_CONDITIONAL([HAVE_ANSI], [test x$ac_have_ansi = xyes])
2972 CFLAGS=$safe_CFLAGS
2975 # Does this compiler support -no-pie?
2976 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2977 # default. However this gets in the way with some tests, we use -no-pie
2978 # for these.
2980 AC_MSG_CHECKING([if gcc accepts -no-pie])
2982 safe_CFLAGS=$CFLAGS
2983 CFLAGS="-no-pie -Werror"
2985 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2986   return 0;
2987 ]])], [
2988 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2989 AC_MSG_RESULT([yes])
2990 ], [
2991 AC_SUBST([FLAG_NO_PIE], [""])
2992 AC_MSG_RESULT([no])
2994 CFLAGS=$safe_CFLAGS
2997 # We want to use use the -Ttext-segment option to the linker.
2998 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2999 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
3000 # semantics are NOT what we want (GNU gold -Ttext is fine).
3002 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
3003 # will reside. -Ttext aligns just the .text section start (but not any
3004 # other section).
3006 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
3007 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
3008 # The --image-base option (since version 6.0?) provides the semantics needed.
3009 # -Ttext-segment generates an error, but -Ttext now more closely
3010 # follows the GNU (bfd) ld's -Ttext.
3012 # So test first for --image-base support, and if that fails then
3013 # for -Ttext-segment which is supported by all bfd ld versions
3014 # and use that if it exists. If it doesn't exist it must be an older
3015 # version of gold and we can fall back to using -Ttext which has the
3016 # right semantics.
3018 safe_CFLAGS=$CFLAGS
3019 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
3021 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
3023 AC_LINK_IFELSE(
3024 [AC_LANG_SOURCE([int _start () { return 0; }])],
3026   linker_using_t_text="no"
3027   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
3028   AC_MSG_RESULT([yes])
3029 ], [
3030   AC_MSG_RESULT([no])
3032   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
3034   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
3036   AC_LINK_IFELSE(
3037   [AC_LANG_SOURCE([int _start () { return 0; }])],
3038   [
3039     linker_using_t_text="no"
3040     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
3041     AC_MSG_RESULT([yes])
3042   ], [
3043     linker_using_t_text="yes"
3044     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
3045     AC_MSG_RESULT([no])
3046   ])
3049 CFLAGS=$safe_CFLAGS
3051 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
3052 # have to strip any build-id ELF NOTEs from the statically linked tools.
3053 # Otherwise the build-id NOTE might end up at the default load address.
3054 # (Pedantically if the linker is gold then -Ttext is fine, but newer
3055 # gold versions also support -Ttext-segment. So just assume that unless
3056 # we can use -Ttext-segment we need to strip the build-id NOTEs.
3057 if test "x${linker_using_t_text}" = "xyes"; then
3058 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
3059 # does the linker support -Wl,--build-id=none ?  Note, it's
3060 # important that we test indirectly via whichever C compiler
3061 # is selected, rather than testing /usr/bin/ld or whatever
3062 # directly.
3063 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
3064 safe_CFLAGS=$CFLAGS
3065 CFLAGS="-Wl,--build-id=none -Werror"
3067 AC_LINK_IFELSE(
3068 [AC_LANG_PROGRAM([ ], [return 0;])],
3070   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
3071   AC_MSG_RESULT([yes])
3072 ], [
3073   AC_SUBST([FLAG_NO_BUILD_ID], [""])
3074   AC_MSG_RESULT([no])
3076 else
3077 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
3078 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3080 CFLAGS=$safe_CFLAGS
3082 # does the ppc assembler support "mtocrf" et al?
3083 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
3085 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3086 __asm__ __volatile__("mtocrf 4,0");
3087 __asm__ __volatile__("mfocrf 0,4");
3088 ]])], [
3089 ac_have_as_ppc_mftocrf=yes
3090 AC_MSG_RESULT([yes])
3091 ], [
3092 ac_have_as_ppc_mftocrf=no
3093 AC_MSG_RESULT([no])
3095 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3096   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3100 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3101 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3103 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3104   do { typedef struct {
3105       double hi;
3106       double lo;
3107      } dbl_pair_t;
3108      dbl_pair_t dbl_pair[3];
3109      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3110    } while (0)
3111 ]])], [
3112 ac_have_as_ppc_fpPO=yes
3113 AC_MSG_RESULT([yes])
3114 ], [
3115 ac_have_as_ppc_fpPO=no
3116 AC_MSG_RESULT([no])
3118 if test x$ac_have_as_ppc_fpPO = xyes ; then
3119   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3123 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3124 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3126 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3127 void* p;
3128 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3129 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3130 ]])], [
3131 ac_have_as_amd64_fxsave64=yes
3132 AC_MSG_RESULT([yes])
3133 ], [
3134 ac_have_as_amd64_fxsave64=no
3135 AC_MSG_RESULT([no])
3137 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3138   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3141 # does the x86/amd64 assembler understand SSE3 instructions?
3142 # Note, this doesn't generate a C-level symbol.  It generates a
3143 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3144 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3147   do { long long int x; 
3148      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
3149   while (0)
3150 ]])], [
3151 ac_have_as_sse3=yes
3152 AC_MSG_RESULT([yes])
3153 ], [
3154 ac_have_as_sse3=no
3155 AC_MSG_RESULT([no])
3158 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3161 # Ditto for SSSE3 instructions (note extra S)
3162 # Note, this doesn't generate a C-level symbol.  It generates a
3163 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3164 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3166 save_CFLAGS="$CFLAGS"
3167 CFLAGS="$CFLAGS -msse -Werror"
3168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3169   do { long long int x; 
3170    __asm__ __volatile__(
3171       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3172   while (0)
3173 ]])], [
3174 ac_have_as_ssse3=yes
3175 AC_MSG_RESULT([yes])
3176 ], [
3177 ac_have_as_ssse3=no
3178 AC_MSG_RESULT([no])
3180 CFLAGS="$save_CFLAGS"
3182 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3185 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3186 # Note, this doesn't generate a C-level symbol.  It generates a
3187 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3188 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3189 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3190   do {
3191    __asm__ __volatile__(
3192       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3193   while (0)
3194 ]])], [
3195 ac_have_as_pclmulqdq=yes
3196 AC_MSG_RESULT([yes])
3197 ], [
3198 ac_have_as_pclmulqdq=no
3199 AC_MSG_RESULT([no])
3202 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3205 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3206 # Note, this doesn't generate a C-level symbol.  It generates a
3207 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3208 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3209 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3210   do {
3211       /*
3212        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3213        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3214        * xmm2 should be used.
3215        */
3216    __asm__ __volatile__(
3217       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3218   } while (0)
3219 ]])], [
3220 ac_have_as_vpclmulqdq=yes
3221 AC_MSG_RESULT([yes])
3222 ], [
3223 ac_have_as_vpclmulqdq=no
3224 AC_MSG_RESULT([no])
3227 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3230 # does the x86/amd64 assembler understand FMA4 instructions?
3231 # Note, this doesn't generate a C-level symbol.  It generates a
3232 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3233 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3234 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3235   do {
3236    __asm__ __volatile__(
3237       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3238   } while (0)
3239 ]])], [
3240 ac_have_as_vfmaddpd=yes
3241 AC_MSG_RESULT([yes])
3242 ], [
3243 ac_have_as_vfmaddpd=no
3244 AC_MSG_RESULT([no])
3247 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3250 # does the x86/amd64 assembler understand the LZCNT instruction?
3251 # Note, this doesn't generate a C-level symbol.  It generates a
3252 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3253 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3255 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3256   do {           
3257       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3258   } while (0)
3259 ]])], [
3260   ac_have_as_lzcnt=yes
3261   AC_MSG_RESULT([yes])
3262 ], [
3263   ac_have_as_lzcnt=no
3264   AC_MSG_RESULT([no])
3267 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3270 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3271 # Note, this doesn't generate a C-level symbol.  It generates a
3272 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3273 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3275 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3276   do {           
3277       __asm__ __volatile__("1:  loopnel 1b\n");
3278   } while (0)
3279 ]])], [
3280   ac_have_as_loopnel=yes
3281   AC_MSG_RESULT([yes])
3282 ], [
3283   ac_have_as_loopnel=no
3284   AC_MSG_RESULT([no])
3287 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3290 # does the x86/amd64 assembler understand ADDR32 ?
3291 # Note, this doesn't generate a C-level symbol.  It generates a
3292 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3293 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3295 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3296   do {           
3297       asm volatile ("addr32 rep movsb");
3298   } while (0)
3299 ]])], [
3300   ac_have_as_addr32=yes
3301   AC_MSG_RESULT([yes])
3302 ], [
3303   ac_have_as_addr32=no
3304   AC_MSG_RESULT([no])
3307 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3310 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3311 # Note, this doesn't generate a C-level symbol.  It generates a
3312 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3313 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3316   do { long long int x; 
3317    __asm__ __volatile__(
3318       "crc32q %%r15,%%r15" : : : "r15" );
3319    __asm__ __volatile__(
3320       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3321    __asm__ __volatile__(
3322       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3323   while (0)
3324 ]])], [
3325 ac_have_as_sse42=yes
3326 AC_MSG_RESULT([yes])
3327 ], [
3328 ac_have_as_sse42=no
3329 AC_MSG_RESULT([no])
3332 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3335 # does the x86/amd64 assembler understand AVX instructions?
3336 # Note, this doesn't generate a C-level symbol.  It generates a
3337 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3338 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3340 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3341   do { long long int x; 
3342    __asm__ __volatile__(
3343       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3344    __asm__ __volatile__(
3345       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3346   while (0)
3347 ]])], [
3348 ac_have_as_avx=yes
3349 AC_MSG_RESULT([yes])
3350 ], [
3351 ac_have_as_avx=no
3352 AC_MSG_RESULT([no])
3355 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3358 # does the x86/amd64 assembler understand AVX2 instructions?
3359 # Note, this doesn't generate a C-level symbol.  It generates a
3360 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3361 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3363 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3364   do { long long int x; 
3365    __asm__ __volatile__(
3366       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3367    __asm__ __volatile__(
3368       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3369   while (0)
3370 ]])], [
3371 ac_have_as_avx2=yes
3372 AC_MSG_RESULT([yes])
3373 ], [
3374 ac_have_as_avx2=no
3375 AC_MSG_RESULT([no])
3378 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3381 # does the x86/amd64 assembler understand TSX instructions and
3382 # the XACQUIRE/XRELEASE prefixes?
3383 # Note, this doesn't generate a C-level symbol.  It generates a
3384 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3385 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3387 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3388   do {
3389    __asm__ __volatile__(
3390       "       xbegin Lfoo  \n\t"
3391       "Lfoo:  xend         \n\t"
3392       "       xacquire lock incq 0(%rsp)     \n\t"
3393       "       xrelease lock incq 0(%rsp)     \n"
3394    );
3395   } while (0)
3396 ]])], [
3397 ac_have_as_tsx=yes
3398 AC_MSG_RESULT([yes])
3399 ], [
3400 ac_have_as_tsx=no
3401 AC_MSG_RESULT([no])
3404 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3407 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3408 # Note, this doesn't generate a C-level symbol.  It generates a
3409 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3410 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3412 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3413   do { unsigned int h, l;
3414    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3415    __asm__ __volatile__(
3416       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3417    __asm__ __volatile__(
3418       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3419   while (0)
3420 ]])], [
3421 ac_have_as_bmi=yes
3422 AC_MSG_RESULT([yes])
3423 ], [
3424 ac_have_as_bmi=no
3425 AC_MSG_RESULT([no])
3428 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3431 # does the x86/amd64 assembler understand FMA instructions?
3432 # Note, this doesn't generate a C-level symbol.  It generates a
3433 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3434 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3436 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3437   do { unsigned int h, l;
3438    __asm__ __volatile__(
3439       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3440    __asm__ __volatile__(
3441       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3442    __asm__ __volatile__(
3443       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3444   while (0)
3445 ]])], [
3446 ac_have_as_fma=yes
3447 AC_MSG_RESULT([yes])
3448 ], [
3449 ac_have_as_fma=no
3450 AC_MSG_RESULT([no])
3453 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3456 # does the amd64 assembler understand MPX instructions?
3457 # Note, this doesn't generate a C-level symbol.  It generates a
3458 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3459 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3462   do {
3463     asm ("bndmov %bnd0,(%rsp)");
3464     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3465     asm ("bnd call foo\n"
3466          "bnd jmp  end\n"
3467          "foo: bnd ret\n"
3468          "end: nop");
3469   } while (0)
3470 ]])], [
3471 ac_have_as_mpx=yes
3472 AC_MSG_RESULT([yes])
3473 ], [
3474 ac_have_as_mpx=no
3475 AC_MSG_RESULT([no])
3478 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3481 # does the amd64 assembler understand ADX instructions?
3482 # Note, this doesn't generate a C-level symbol.  It generates a
3483 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3484 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3486 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3487   do {
3488     asm ("adcxq %r14,%r8");
3489   } while (0)
3490 ]])], [
3491 ac_have_as_adx=yes
3492 AC_MSG_RESULT([yes])
3493 ], [
3494 ac_have_as_adx=no
3495 AC_MSG_RESULT([no])
3498 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3501 # does the amd64 assembler understand the RDRAND instruction?
3502 # Note, this doesn't generate a C-level symbol.  It generates a
3503 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3504 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3506 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3507   do {
3508     asm ("rdrand %r14");
3509     asm ("rdrand %r14d");
3510     asm ("rdrand %r14w");
3511   } while (0)
3512 ]])], [
3513 ac_have_as_rdrand=yes
3514 AC_MSG_RESULT([yes])
3515 ], [
3516 ac_have_as_rdrand=no
3517 AC_MSG_RESULT([no])
3520 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3522 # does the amd64 assembler understand the RDSEED instruction?
3523 # Note, this doesn't generate a C-level symbol.  It generates a
3524 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3525 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3527 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3528   do {
3529     asm ("rdseed %r14");
3530     asm ("rdseed %r14d");
3531     asm ("rdseed %r14w");
3532   } while (0)
3533 ]])], [
3534 ac_have_as_rdseed=yes
3535 AC_MSG_RESULT([yes])
3536 ], [
3537 ac_have_as_rdseed=no
3538 AC_MSG_RESULT([no])
3541 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3543 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3544 # VCVTPS2PH) ?
3545 # Note, this doesn't generate a C-level symbol.  It generates a
3546 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3547 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3549 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3550   do {
3551     asm ("vcvtph2ps %xmm5, %ymm10");
3552     // If we put the dollar sign and zero together, the shell processing
3553     // this configure.ac script substitutes the command name in.  Sigh.
3554     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3555   } while (0)
3556 ]])], [
3557 ac_have_as_f16c=yes
3558 AC_MSG_RESULT([yes])
3559 ], [
3560 ac_have_as_f16c=no
3561 AC_MSG_RESULT([no])
3564 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3567 # does the x86/amd64 assembler understand MOVBE?
3568 # Note, this doesn't generate a C-level symbol.  It generates a
3569 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3570 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3572 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3573   do { long long int x; 
3574    __asm__ __volatile__(
3575       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3576   while (0)
3577 ]])], [
3578 ac_have_as_movbe=yes
3579 AC_MSG_RESULT([yes])
3580 ], [
3581 ac_have_as_movbe=no
3582 AC_MSG_RESULT([no])
3585 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3588 # Does the C compiler support the "ifunc" attribute
3589 # Note, this doesn't generate a C-level symbol.  It generates a
3590 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3591 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3593 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3594 static void mytest(void) {}
3596 static void (*resolve_test(void))(void)
3598     return (void (*)(void))&mytest;
3601 void test(void) __attribute__((ifunc("resolve_test")));
3603 int main()
3605     test();
3606     return 0;
3608 ]])], [
3609 ac_have_ifunc_attr=yes
3610 AC_MSG_RESULT([yes])
3611 ], [
3612 ac_have_ifunc_attr=no
3613 AC_MSG_RESULT([no])
3616 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3618 # Does the C compiler support the armv8 crc feature flag
3619 # Note, this doesn't generate a C-level symbol.  It generates a
3620 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3621 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3623 save_CFLAGS="$CFLAGS"
3624 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3625 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3626 int main()
3628     return 0;
3630 ]])], [
3631 ac_have_armv8_crc_feature=yes
3632 AC_MSG_RESULT([yes])
3633 ], [
3634 ac_have_armv8_crc_feature=no
3635 AC_MSG_RESULT([no])
3637 CFLAGS="$save_CFLAGS"
3639 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3642 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3643 # Note, this doesn't generate a C-level symbol.  It generates a
3644 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3645 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3647 save_CFLAGS="$CFLAGS"
3648 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3649 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3650 int main()
3652     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3653     return 0;
3655 ]])], [
3656 ac_have_armv81_feature=yes
3657 AC_MSG_RESULT([yes])
3658 ], [
3659 ac_have_armv81_feature=no
3660 AC_MSG_RESULT([no])
3662 CFLAGS="$save_CFLAGS"
3664 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3667 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3668 # Note, this doesn't generate a C-level symbol.  It generates a
3669 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3670 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3672 save_CFLAGS="$CFLAGS"
3673 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3674 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3675 int main()
3677     __asm__ __volatile__("faddp h0, v1.2h");
3678     return 0;
3680 ]])], [
3681 ac_have_armv82_feature=yes
3682 AC_MSG_RESULT([yes])
3683 ], [
3684 ac_have_armv82_feature=no
3685 AC_MSG_RESULT([no])
3687 CFLAGS="$save_CFLAGS"
3689 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3692 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3693 # when building the tool executables.  I think we should get rid of it.
3695 # Check for TLS support in the compiler and linker
3696 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3697                                 [[return foo;]])],
3698                                [vg_cv_linktime_tls=yes],
3699                                [vg_cv_linktime_tls=no])
3700 # Native compilation: check whether running a program using TLS succeeds.
3701 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3702 # succeeds but running programs using TLS fails.
3703 # Cross-compiling: check whether linking a program using TLS succeeds.
3704 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3705                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3706                 [vg_cv_tls=$enableval],
3707                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3708                                                 [[return foo;]])],
3709                                [vg_cv_tls=yes],
3710                                [vg_cv_tls=no],
3711                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3713 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3714 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3718 #----------------------------------------------------------------------------
3719 # Solaris-specific checks.
3720 #----------------------------------------------------------------------------
3722 if test "$VGCONF_OS" = "solaris" ; then
3723 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3725 # Solaris-specific check determining if the Sun Studio Assembler is used to
3726 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3727 # cmovl.l instruction, if yes then it's Sun Assembler.
3729 # C-level symbol: none
3730 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3732 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3733 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3734 ]], [[
3735   __asm__ __volatile__("cmovl.l %edx, %eax");
3736 ]])], [
3737 solaris_have_sun_studio_as=yes
3738 AC_MSG_RESULT([yes])
3739 ], [
3740 solaris_have_sun_studio_as=no
3741 AC_MSG_RESULT([no])
3743 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3745 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3746 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3747 # See solaris/vgpreload-solaris.mapfile for details.
3748 # gcc on older Solaris instructs linker to include these symbols,
3749 # gcc on illumos and newer Solaris does not.
3751 # C-level symbol: none
3752 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3754 save_CFLAGS="$CFLAGS"
3755 CFLAGS="$CFLAGS -std=gnu99"
3756 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3757 temp_dir=$( /usr/bin/mktemp -d )
3758 cat <<_ACEOF >${temp_dir}/mylib.c
3759 #include <stdio.h>
3760 int myfunc(void) { printf("LaPutyka\n"); }
3761 _ACEOF
3762 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3763 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3764 if test "x${xpg_present}" = "x" ; then
3765     solaris_xpg_symbols_present=no
3766     AC_MSG_RESULT([no])
3767 else
3768     solaris_xpg_symbols_present=yes
3769     AC_MSG_RESULT([yes])
3771 rm -rf ${temp_dir}
3772 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3773 CFLAGS="$save_CFLAGS"
3776 # Solaris-specific check determining if gcc enables largefile support by
3777 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3778 # variable with gcc flags which disable it.
3780 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3781 save_CFLAGS="$CFLAGS"
3782 CFLAGS="$CFLAGS -m32"
3783 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3784   return _LARGEFILE_SOURCE;
3785 ]])], [
3786 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3787 AC_MSG_RESULT([yes])
3788 ], [
3789 SOLARIS_UNDEF_LARGESOURCE=""
3790 AC_MSG_RESULT([no])
3792 CFLAGS=$safe_CFLAGS
3793 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3796 # Solaris-specific check determining if /proc/self/cmdline
3797 # or /proc/<pid>/cmdline is supported.
3799 # C-level symbol: SOLARIS_PROC_CMDLINE
3800 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3802 AC_CHECK_FILE([/proc/self/cmdline],
3804 solaris_proc_cmdline=yes
3805 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3806           [Define to 1 if you have /proc/self/cmdline.])
3807 ], [
3808 solaris_proc_cmdline=no
3810 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3813 # Solaris-specific check determining default platform for the Valgrind launcher.
3814 # Used in case the launcher cannot select platform by looking at the client
3815 # image (for example because the executable is a shell script).
3817 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3818 # Automake-level symbol: none
3820 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3821 # Get the ELF class of /bin/sh first.
3822 if ! test -f /bin/sh; then
3823   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3825 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3826 case "$elf_class" in
3827   64)
3828     default_arch="$VGCONF_ARCH_PRI";
3829     ;;
3830   32)
3831     if test "x$VGCONF_ARCH_SEC" != "x"; then
3832       default_arch="$VGCONF_ARCH_SEC"
3833     else
3834       default_arch="$VGCONF_ARCH_PRI";
3835     fi
3836     ;;
3837   *)
3838     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3839     ;;
3840 esac
3841 default_platform="$default_arch-$VGCONF_OS"
3842 AC_MSG_RESULT([$default_platform])
3843 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3844                    [Default platform for Valgrind launcher.])
3847 # Solaris-specific check determining if the old syscalls are available.
3849 # C-level symbol: SOLARIS_OLD_SYSCALLS
3850 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3852 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3854 #include <sys/syscall.h>
3855 ]], [[
3856   return !SYS_open;
3857 ]])], [
3858 solaris_old_syscalls=yes
3859 AC_MSG_RESULT([yes])
3860 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3861           [Define to 1 if you have the old Solaris syscalls.])
3862 ], [
3863 solaris_old_syscalls=no
3864 AC_MSG_RESULT([no])
3866 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3869 # Solaris-specific check determining if the new accept() syscall is available.
3871 # Old syscall:
3872 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3873 #            int version);
3875 # New syscall (available on illumos):
3876 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3877 #            int version, int flags);
3879 # If the old syscall is present then the following syscall will fail with
3880 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3881 # available then it will fail with EINVAL (because the flags parameter is
3882 # invalid).
3884 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3885 # Automake-level symbol: none
3887 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3888 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3889 #include <sys/syscall.h>
3890 #include <errno.h>
3891 ]], [[
3892   errno = 0;
3893   syscall(SYS_accept, 0, 0, 0, 0, -1);
3894   return !(errno == EINVAL);
3895 ]])], [
3896 AC_MSG_RESULT([yes])
3897 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3898           [Define to 1 if you have the new `accept' syscall.])
3899 ], [
3900 AC_MSG_RESULT([no])
3904 # Solaris-specific check determining if the new illumos pipe() syscall is
3905 # available.
3907 # Old syscall:
3908 # longlong_t pipe();
3910 # New syscall (available on illumos):
3911 # int pipe(intptr_t arg, int flags);
3913 # If the old syscall is present then the following call will succeed, if the
3914 # new syscall is available then it will fail with EFAULT (because address 0
3915 # cannot be accessed).
3917 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3918 # Automake-level symbol: none
3920 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3921 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3922 #include <sys/syscall.h>
3923 #include <errno.h>
3924 ]], [[
3925   errno = 0;
3926   syscall(SYS_pipe, 0, 0);
3927   return !(errno == EFAULT);
3928 ]])], [
3929 AC_MSG_RESULT([yes])
3930 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3931           [Define to 1 if you have the new `pipe' syscall.])
3932 ], [
3933 AC_MSG_RESULT([no])
3937 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3938 # available.
3940 # Old syscall:
3941 # int lwp_kill(id_t lwpid, int sig);
3943 # New syscall (available on Solaris 11):
3944 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3945 #                  int si_code, timespec_t *timeout);
3947 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3948 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3950 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3951 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3952 #include <sys/syscall.h> 
3953 ]], [[
3954   return !SYS_lwp_sigqueue;
3955 ]])], [
3956 solaris_lwp_sigqueue_syscall=yes
3957 AC_MSG_RESULT([yes])
3958 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3959           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3960 ], [
3961 solaris_lwp_sigqueue_syscall=no
3962 AC_MSG_RESULT([no])
3964 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3967 # Solaris-specific check determining if the lwp_sigqueue() syscall
3968 # takes both pid and thread id arguments or just thread id.
3970 # Old syscall (available up to Solaris 11.3):
3971 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3972 #                  int si_code, timespec_t *timeout);
3974 # New syscall (available since Solaris 11.4):
3975 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3976 #                  int si_code, timespec_t *timeout);
3978 # If the old syscall is present then the following syscall will fail with
3979 # EINVAL (because signal is out of range); if the new syscall is available
3980 # then it will fail with ESRCH (because it would not find such thread in the
3981 # current process).
3983 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3984 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3986 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3987 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3988 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3989 #include <sys/syscall.h>
3990 #include <errno.h>
3991 ]], [[
3992   errno = 0;
3993   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3994   return !(errno == ESRCH);
3995 ]])], [
3996 solaris_lwp_sigqueue_syscall_takes_pid=yes
3997 AC_MSG_RESULT([yes])
3998 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3999           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
4000 ], [
4001 solaris_lwp_sigqueue_syscall_takes_pid=no
4002 AC_MSG_RESULT([no])
4004 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
4005                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
4007 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
4011 # Solaris-specific check determining if the new lwp_name() syscall is
4012 # available.
4014 # New syscall (available on Solaris 11):
4015 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
4017 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
4018 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
4020 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
4021 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4022 #include <sys/syscall.h>
4023 ]], [[
4024   return !SYS_lwp_name;
4025 ]])], [
4026 solaris_lwp_name_syscall=yes
4027 AC_MSG_RESULT([yes])
4028 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
4029           [Define to 1 if you have the new `lwp_name' syscall.])
4030 ], [
4031 solaris_lwp_name_syscall=no
4032 AC_MSG_RESULT([no])
4034 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
4037 # Solaris-specific check determining if the new getrandom() syscall is
4038 # available.
4040 # New syscall (available on Solaris 11):
4041 # int getrandom(void *buf, size_t buflen, uint_t flags);
4043 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
4044 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
4046 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
4047 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4048 #include <sys/syscall.h>
4049 ]], [[
4050   return !SYS_getrandom;
4051 ]])], [
4052 solaris_getrandom_syscall=yes
4053 AC_MSG_RESULT([yes])
4054 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
4055           [Define to 1 if you have the new `getrandom' syscall.])
4056 ], [
4057 solaris_getrandom_syscall=no
4058 AC_MSG_RESULT([no])
4060 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
4063 # Solaris-specific check determining if the new zone() syscall subcodes
4064 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
4065 # were added in Solaris 11 but are missing on illumos.
4067 # C-level symbol: SOLARIS_ZONE_DEFUNCT
4068 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
4070 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
4071 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4072 #include <sys/zone.h>
4073 ]], [[
4074   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
4075 ]])], [
4076 solaris_zone_defunct=yes
4077 AC_MSG_RESULT([yes])
4078 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
4079           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
4080 ], [
4081 solaris_zone_defunct=no
4082 AC_MSG_RESULT([no])
4084 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
4087 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4088 # for auditon(2) subcode of the auditsys() syscall are available.
4089 # These commands are available in Solaris 11 and illumos but were removed
4090 # in Solaris 11.4.
4092 # C-level symbol: SOLARIS_AUDITON_STAT
4093 # Automake-level symbol: SOLARIS_AUDITON_STAT
4095 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4096 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4097 #include <bsm/audit.h>
4098 ]], [[
4099   return !(A_GETSTAT && A_SETSTAT);
4100 ]])], [
4101 solaris_auditon_stat=yes
4102 AC_MSG_RESULT([yes])
4103 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4104           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4105 ], [
4106 solaris_auditon_stat=no
4107 AC_MSG_RESULT([no])
4109 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4112 # Solaris-specific check determining if the new shmsys() syscall subcodes
4113 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4114 # These subcodes were added in Solaris 11 but are missing on illumos.
4116 # C-level symbol: SOLARIS_SHM_NEW
4117 # Automake-level symbol: SOLARIS_SHM_NEW
4119 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4120 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4121 #include <sys/ipc_impl.h>
4122 #include <sys/shm.h>
4123 #include <sys/shm_impl.h>
4124 ]], [[
4125   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4126 ]])], [
4127 solaris_shm_new=yes
4128 AC_MSG_RESULT([yes])
4129 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4130           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4131 ], [
4132 solaris_shm_new=no
4133 AC_MSG_RESULT([no])
4135 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4138 # Solaris-specific check determining if prxregset_t is available.  Illumos
4139 # currently does not define it on the x86 platform.
4141 # C-level symbol: SOLARIS_PRXREGSET_T
4142 # Automake-level symbol: SOLARIS_PRXREGSET_T
4144 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4145 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4146 #include <sys/procfs_isa.h>
4147 ]], [[
4148   return !sizeof(prxregset_t);
4149 ]])], [
4150 solaris_prxregset_t=yes
4151 AC_MSG_RESULT([yes])
4152 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4153           [Define to 1 if you have the `prxregset_t' type.])
4154 ], [
4155 solaris_prxregset_t=no
4156 AC_MSG_RESULT([no])
4158 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4161 # Solaris-specific check determining if the new frealpathat() syscall is
4162 # available.
4164 # New syscall (available on Solaris 11.1):
4165 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4167 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4168 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4170 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4171 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4172 #include <sys/syscall.h>
4173 ]], [[
4174   return !SYS_frealpathat;
4175 ]])], [
4176 solaris_frealpathat_syscall=yes
4177 AC_MSG_RESULT([yes])
4178 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4179           [Define to 1 if you have the new `frealpathat' syscall.])
4180 ], [
4181 solaris_frealpathat_syscall=no
4182 AC_MSG_RESULT([no])
4184 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4187 # Solaris-specific check determining if the new uuidsys() syscall is
4188 # available.
4190 # New syscall (available on newer Solaris):
4191 # int uuidsys(struct uuid *uuid);
4193 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4194 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4196 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4197 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4198 #include <sys/syscall.h>
4199 ]], [[
4200   return !SYS_uuidsys;
4201 ]])], [
4202 solaris_uuidsys_syscall=yes
4203 AC_MSG_RESULT([yes])
4204 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4205           [Define to 1 if you have the new `uuidsys' syscall.])
4206 ], [
4207 solaris_uuidsys_syscall=no
4208 AC_MSG_RESULT([no])
4210 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4213 # Solaris-specific check determining if the new labelsys() syscall subcode
4214 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4215 # missing on illumos.
4217 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4218 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4220 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4221 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4222 #include <sys/tsol/tndb.h>
4223 ]], [[
4224   return !TNDB_GET_TNIP;
4225 ]])], [
4226 solaris_tndb_get_tnip=yes
4227 AC_MSG_RESULT([yes])
4228 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4229           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4230 ], [
4231 solaris_tndb_get_tnip=no
4232 AC_MSG_RESULT([no])
4234 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4237 # Solaris-specific check determining if the new labelsys() syscall opcodes
4238 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4239 # added in Solaris 11 but are missing on illumos.
4241 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4242 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4244 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4245 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4246 #include <sys/tsol/tsyscall.h>
4247 ]], [[
4248   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4249 ]])], [
4250 solaris_tsol_clearance=yes
4251 AC_MSG_RESULT([yes])
4252 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4253           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4254 ], [
4255 solaris_tsol_clearance=no
4256 AC_MSG_RESULT([no])
4258 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4261 # Solaris-specific check determining if the new pset() syscall subcode
4262 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4263 # is missing on illumos and Solaris 11.3.
4265 # C-level symbol: SOLARIS_PSET_GET_NAME
4266 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4268 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4269 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4270 #include <sys/pset.h>
4271 ]], [[
4272   return !(PSET_GET_NAME);
4273 ]])], [
4274 solaris_pset_get_name=yes
4275 AC_MSG_RESULT([yes])
4276 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4277           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4278 ], [
4279 solaris_pset_get_name=no
4280 AC_MSG_RESULT([no])
4282 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4285 # Solaris-specific check determining if the utimesys() syscall is
4286 # available (on illumos and older Solaris).
4288 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4289 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4291 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4292 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4293 #include <sys/syscall.h>
4294 ]], [[
4295   return !SYS_utimesys;
4296 ]])], [
4297 solaris_utimesys_syscall=yes
4298 AC_MSG_RESULT([yes])
4299 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4300           [Define to 1 if you have the `utimesys' syscall.])
4301 ], [
4302 solaris_utimesys_syscall=no
4303 AC_MSG_RESULT([no])
4305 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4308 # Solaris-specific check determining if the utimensat() syscall is
4309 # available (on newer Solaris).
4311 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4312 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4314 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4316 #include <sys/syscall.h>
4317 ]], [[
4318   return !SYS_utimensat;
4319 ]])], [
4320 solaris_utimensat_syscall=yes
4321 AC_MSG_RESULT([yes])
4322 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4323           [Define to 1 if you have the `utimensat' syscall.])
4324 ], [
4325 solaris_utimensat_syscall=no
4326 AC_MSG_RESULT([no])
4328 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4331 # Solaris-specific check determining if the spawn() syscall is available
4332 # (on newer Solaris).
4334 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4335 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4337 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4338 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4339 #include <sys/syscall.h>
4340 ]], [[
4341   return !SYS_spawn;
4342 ]])], [
4343 solaris_spawn_syscall=yes
4344 AC_MSG_RESULT([yes])
4345 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4346           [Define to 1 if you have the `spawn' syscall.])
4347 ], [
4348 solaris_spawn_syscall=no
4349 AC_MSG_RESULT([no])
4351 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4354 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4355 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4357 # C-level symbol: SOLARIS_MODCTL_MODNVL
4358 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4360 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4361 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4362 #include <sys/modctl.h>
4363 ]], [[
4364   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4365 ]])], [
4366 solaris_modctl_modnvl=yes
4367 AC_MSG_RESULT([yes])
4368 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4369           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4370 ], [
4371 solaris_modctl_modnvl=no
4372 AC_MSG_RESULT([no])
4374 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4377 # Solaris-specific check determining whether nscd (name switch cache daemon)
4378 # attaches its door at /system/volatile/name_service_door (Solaris)
4379 # or at /var/run/name_service_door (illumos).
4381 # Note that /var/run is a symlink to /system/volatile on Solaris
4382 # but not vice versa on illumos.
4384 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4385 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4387 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4388 if test -e /system/volatile/name_service_door; then
4389     solaris_nscd_door_system_volatile=yes
4390     AC_MSG_RESULT([/system/volatile/name_service_door])
4391     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4392               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4393 else
4394     solaris_nscd_door_system_volatile=no
4395     AC_MSG_RESULT([/var/run/name_service_door])
4397 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4400 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4402 # New fasttrap (available on Solaris 11):
4403 # hrt_t *gethrt(void);
4405 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4406 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4408 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4409 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4410 #include <sys/trap.h>
4411 ]], [[
4412   return !T_GETHRT;
4413 ]])], [
4414 solaris_gethrt_fasttrap=yes
4415 AC_MSG_RESULT([yes])
4416 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4417           [Define to 1 if you have the new `gethrt' fasttrap.])
4418 ], [
4419 solaris_gethrt_fasttrap=no
4420 AC_MSG_RESULT([no])
4422 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4425 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4426 # is available.
4428 # New fasttrap (available on Solaris 11):
4429 # zonehrtoffset_t *get_zone_offset(void);
4431 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4432 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4434 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4435 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4436 #include <sys/trap.h>
4437 ]], [[
4438   return !T_GETZONEOFFSET;
4439 ]])], [
4440 solaris_getzoneoffset_fasttrap=yes
4441 AC_MSG_RESULT([yes])
4442 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4443           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4444 ], [
4445 solaris_getzoneoffset_fasttrap=no
4446 AC_MSG_RESULT([no])
4448 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4451 # Solaris-specific check determining if the execve() syscall
4452 # takes fourth argument (flags) or not.
4454 # Old syscall (available on illumos):
4455 # int execve(const char *fname, const char **argv, const char **envp);
4457 # New syscall (available on Solaris):
4458 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4460 # If the new syscall is present then it will fail with EINVAL (because flags
4461 # are invalid); if the old syscall is available then it will fail with ENOENT
4462 # (because the file could not be found).
4464 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4465 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4467 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4468 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4469 #include <sys/syscall.h>
4470 #include <errno.h>
4471 ]], [[
4472   errno = 0;
4473   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4474   return !(errno == EINVAL);
4475 ]])], [
4476 solaris_execve_syscall_takes_flags=yes
4477 AC_MSG_RESULT([yes])
4478 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4479           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4480 ], [
4481 solaris_execve_syscall_takes_flags=no
4482 AC_MSG_RESULT([no])
4484 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4485                test x$solaris_execve_syscall_takes_flags = xyes)
4488 # Solaris-specific check determining version of the repository cache protocol.
4489 # Every Solaris version uses a different one, ranging from 21 to current 25.
4490 # The check is very ugly, though.
4492 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4493 # Automake-level symbol: none
4495 AC_PATH_PROG(DIS_PATH, dis, false)
4496 if test "x$DIS_PATH" = "xfalse"; then
4497   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4499 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4500   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4501   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4504 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4505 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4506   libscf=/usr/lib/64/libscf.so.1
4507 else
4508   libscf=/usr/lib/libscf.so.1
4510 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q -E '0x(4d01)?526570'; then
4511   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4512   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4514 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | perl -pe '($_) = /0x(?:4d01)?526570(\d{2}),/' )
4515 if test -z "$hex"; then
4516   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4517   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4519 version=$( printf "%d\n" 0x$hex )
4520 AC_MSG_RESULT([$version])
4521 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4522                    [Version number of the repository door cache protocol.])
4525 # Solaris-specific check determining if "sysstat" segment reservation type
4526 # is available.
4528 # New "sysstat" segment reservation (available on Solaris 11.4):
4529 # - program header type:    PT_SUNW_SYSSTAT
4530 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4532 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4533 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4535 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4536 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4537 #include <sys/auxv.h>
4538 ]], [[
4539   return !AT_SUN_SYSSTAT_ADDR;
4540 ]])], [
4541 solaris_reserve_sysstat_addr=yes
4542 AC_MSG_RESULT([yes])
4543 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4544           [Define to 1 if you have the new `sysstat' segment reservation.])
4545 ], [
4546 solaris_reserve_sysstat_addr=no
4547 AC_MSG_RESULT([no])
4549 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4552 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4553 # is available.
4555 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4556 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4557 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4559 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4560 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4562 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4563 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4564 #include <sys/auxv.h>
4565 ]], [[
4566   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4567 ]])], [
4568 solaris_reserve_sysstat_zone_addr=yes
4569 AC_MSG_RESULT([yes])
4570 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4571           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4572 ], [
4573 solaris_reserve_sysstat_zone_addr=no
4574 AC_MSG_RESULT([no])
4576 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4579 # Solaris-specific check determining if the system_stats() syscall is available
4580 # (on newer Solaris).
4582 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4583 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4585 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4586 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4587 #include <sys/syscall.h>
4588 ]], [[
4589   return !SYS_system_stats;
4590 ]])], [
4591 solaris_system_stats_syscall=yes
4592 AC_MSG_RESULT([yes])
4593 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4594           [Define to 1 if you have the `system_stats' syscall.])
4595 ], [
4596 solaris_system_stats_syscall=no
4597 AC_MSG_RESULT([no])
4599 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4602 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4603 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4605 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4606 # Automake-level symbol: none
4608 AC_CHECK_TYPE([struct _fpchip_state],
4609               [solaris_fpchip_state_takes_underscore=yes],
4610               [solaris_fpchip_state_takes_underscore=no],
4611               [[#include <sys/regset.h>]])
4612 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4613   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4614             [Define to 1 if fpregset_t defines struct _fpchip_state])
4618 # Solaris-specific check determining if schedctl page shared between kernel
4619 # and userspace program is executable (illumos, older Solaris) or not (newer
4620 # Solaris).
4622 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4623 # Automake-level symbol: none
4625 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4626 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4627 #include <assert.h>
4628 #include <fcntl.h>
4629 #include <procfs.h>
4630 #include <schedctl.h>
4631 #include <stdio.h>
4632 #include <unistd.h>
4633 ]], [[
4634     schedctl_t *scp = schedctl_init();
4635     if (scp == NULL)
4636         return 1;
4638     int fd = open("/proc/self/map", O_RDONLY);
4639     assert(fd >= 0);
4641     prmap_t map;
4642     ssize_t rd;
4643     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4644         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4645             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4646                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4647             return (map.pr_mflags & MA_EXEC);
4648         }
4649     }
4651     return 1;
4652 ]])], [
4653 solaris_schedctl_page_exec=no
4654 AC_MSG_RESULT([no])
4655 ], [
4656 solaris_schedctl_page_exec=yes
4657 AC_MSG_RESULT([yes])
4658 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4659           [Define to 1 if you have the schedctl page executable.])
4663 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4664 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4665 # an initial thread pointer for libc (newer Solaris).
4667 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4668 # Automake-level symbol: none
4670 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4671 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4672 #include <sys/fasttrap_isa.h>
4673 ]], [[
4674     return !FT_SCRATCHSIZE;
4675 ]])], [
4676 solaris_pt_sunwdtrace_thrp=yes
4677 AC_MSG_RESULT([yes])
4678 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4679           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4680 ], [
4681 solaris_pt_sunwdtrace_thrp=no
4682 AC_MSG_RESULT([no])
4685 else
4686 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4687 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4688 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4689 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4690 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4691 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4692 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4693 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4694 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4695 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4696 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4697 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4698 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4699 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4700 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4701 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4702 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4703 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4704 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4705 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4706 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4707 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4708 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4709 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4710 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4711 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4712 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4713 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4714 fi # test "$VGCONF_OS" = "solaris"
4716 #----------------------------------------------------------------------------
4717 # FreeBSD-specific checks.
4718 #----------------------------------------------------------------------------
4720 # Rather than having a large number of feature test as above with Solaris
4721 # these tests are per-version. This may not be entirely relialable for
4722 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4723 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4725 if test "$VGCONF_OS" = "freebsd" ; then
4727 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4729 else
4731 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4733 fi # test "$VGCONF_OS" = "freebsd"
4736 #----------------------------------------------------------------------------
4737 # Checks for C header files.
4738 #----------------------------------------------------------------------------
4740 AC_CHECK_HEADERS([       \
4741         asm/unistd.h     \
4742         endian.h         \
4743         mqueue.h         \
4744         sys/endian.h     \
4745         sys/epoll.h      \
4746         sys/eventfd.h    \
4747         sys/klog.h       \
4748         sys/poll.h       \
4749         sys/prctl.h      \
4750         sys/signal.h     \
4751         sys/signalfd.h   \
4752         sys/syscall.h    \
4753         sys/sysnvl.h     \
4754         sys/time.h       \
4755         sys/types.h      \
4756         ])
4758 # Verify whether the <linux/futex.h> header is usable.
4759 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4761 save_CFLAGS="$CFLAGS"
4762 CFLAGS="$CFLAGS -D__user="
4763 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4764 #include <linux/futex.h>
4765 ]], [[
4766   return FUTEX_WAIT;
4767 ]])], [
4768 ac_have_usable_linux_futex_h=yes
4769 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4770           [Define to 1 if you have a usable <linux/futex.h> header file.])
4771 AC_MSG_RESULT([yes])
4772 ], [
4773 ac_have_usable_linux_futex_h=no
4774 AC_MSG_RESULT([no])
4776 CFLAGS="$save_CFLAGS"
4779 #----------------------------------------------------------------------------
4780 # Checks for typedefs, structures, and compiler characteristics.
4781 #----------------------------------------------------------------------------
4782 AC_TYPE_UID_T
4783 AC_TYPE_OFF_T
4784 AC_TYPE_SIZE_T
4785 AC_CHECK_HEADERS_ONCE([sys/time.h])
4787 AC_CHECK_TYPE([struct statx], [
4788   AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4789             [Define to 1 if <sys/stat.h> declares struct statx.])
4790 ], [], [
4791   #define _GNU_SOURCE
4792   #include <sys/stat.h>
4796 #----------------------------------------------------------------------------
4797 # Checks for library functions.
4798 #----------------------------------------------------------------------------
4799 AC_FUNC_MEMCMP
4800 AC_FUNC_MMAP
4802 AC_CHECK_LIB([pthread], [pthread_create])
4803 AC_CHECK_LIB([rt], [clock_gettime])
4805 AC_CHECK_FUNCS([     \
4806         aligned_alloc \
4807         clock_gettime\
4808         copy_file_range \
4809         epoll_create \
4810         epoll_pwait  \
4811         klogctl      \
4812         mallinfo     \
4813         memchr       \
4814         memfd_create \
4815         memset       \
4816         mkdir        \
4817         mremap       \
4818         pipe2        \
4819         ppoll        \
4820         preadv       \
4821         preadv2      \
4822         process_vm_readv  \
4823         process_vm_writev \
4824         pthread_barrier_init       \
4825         pthread_condattr_setclock  \
4826         pthread_mutex_timedlock    \
4827         pthread_rwlock_timedrdlock \
4828         pthread_rwlock_timedwrlock \
4829         pthread_setname_np         \
4830         pthread_spin_lock          \
4831         pthread_yield              \
4832         pwritev      \
4833         pwritev2     \
4834         rawmemchr    \
4835         readlinkat   \
4836         semtimedop   \
4837         setcontext   \
4838         signalfd     \
4839         sigwaitinfo  \
4840         strchr       \
4841         strdup       \
4842         strpbrk      \
4843         strrchr      \
4844         strstr       \
4845         swapcontext  \
4846         syscall      \
4847         utimensat    \
4848         mempcpy      \
4849         stpncpy      \
4850         strchrnul    \
4851         memrchr      \
4852         strndup      \
4853         ])
4855 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4856 # libraries with any shared object and/or executable. This is NOT what we
4857 # want for e.g. vgpreload_core-x86-linux.so
4858 LIBS=""
4860 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4861                [test x$ac_cv_func_pthread_barrier_init = xyes])
4862 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4863                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4864 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4865                [test x$ac_cv_func_pthread_spin_lock = xyes])
4866 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4867                [test x$ac_cv_func_pthread_setname_np = xyes])
4868 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4869                [test x$ac_cv_func_copy_file_range = xyes])
4870 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4871                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4872 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4873                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4874 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4875 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4876 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4877                [test x$ac_cv_func_memfd_create = xyes])
4879 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4880      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4881      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4882   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4883             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4886 #----------------------------------------------------------------------------
4887 # MPI checks
4888 #----------------------------------------------------------------------------
4889 # Do we have a useable MPI setup on the primary and/or secondary targets?
4890 # On Linux, by default, assumes mpicc and -m32/-m64
4891 # Note: this is a kludge in that it assumes the specified mpicc 
4892 # understands -m32/-m64 regardless of what is specified using
4893 # --with-mpicc=.
4894 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4895              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4897 mflag_primary=
4898 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4899      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4900      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4901      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4902      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4903      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4904      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4905   mflag_primary=$FLAG_M32
4906 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4907        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4908        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4909        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4910        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4911        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4912   mflag_primary=$FLAG_M64
4913 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4914   mflag_primary="$FLAG_M32 -arch i386"
4915 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4916   mflag_primary="$FLAG_M64 -arch x86_64"
4919 mflag_secondary=
4920 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4921      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4922      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4923      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4924      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4925   mflag_secondary=$FLAG_M32
4926 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4927   mflag_secondary="$FLAG_M32 -arch i386"
4931 AC_ARG_WITH(mpicc,
4932    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4933    MPI_CC=$withval
4935 AC_SUBST(MPI_CC)
4937 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4938 ## use these values in the check for a functioning mpicc.
4940 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4941 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4942 AM_COND_IF([VGCONF_OS_IS_LINUX],
4943            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4944             LDFLAGS_MPI="-fpic -shared"])
4945 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
4946            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4947             LDFLAGS_MPI="-fpic -shared"])
4948 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4949            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4950             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4951 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4952            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4953             LDFLAGS_MPI="-fpic -shared"])
4955 AC_SUBST([CFLAGS_MPI])
4956 AC_SUBST([LDFLAGS_MPI])
4959 ## See if MPI_CC works for the primary target
4961 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4962 saved_CC=$CC
4963 saved_CFLAGS=$CFLAGS
4964 CC=$MPI_CC
4965 CFLAGS="$CFLAGS_MPI $mflag_primary"
4966 saved_LDFLAGS="$LDFLAGS"
4967 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4968 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4969 #include <mpi.h>
4970 #include <stdio.h>
4971 ]], [[
4972   int ni, na, nd, comb;
4973   int r = MPI_Init(NULL,NULL);
4974   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4975   r |= MPI_Finalize();
4976   return r; 
4977 ]])], [
4978 ac_have_mpi2_pri=yes
4979 AC_MSG_RESULT([yes, $MPI_CC])
4980 ], [
4981 ac_have_mpi2_pri=no
4982 AC_MSG_RESULT([no])
4984 CC=$saved_CC
4985 CFLAGS=$saved_CFLAGS
4986 LDFLAGS="$saved_LDFLAGS"
4987 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4989 ## See if MPI_CC works for the secondary target.  Complication: what if
4990 ## there is no secondary target?  We need this to then fail.
4991 ## Kludge this by making MPI_CC something which will surely fail in
4992 ## such a case.
4994 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4995 saved_CC=$CC
4996 saved_CFLAGS=$CFLAGS
4997 saved_LDFLAGS="$LDFLAGS"
4998 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4999 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
5000   CC="$MPI_CC this will surely fail"
5001 else
5002   CC=$MPI_CC
5004 CFLAGS="$CFLAGS_MPI $mflag_secondary"
5005 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5006 #include <mpi.h>
5007 #include <stdio.h>
5008 ]], [[
5009   int ni, na, nd, comb;
5010   int r = MPI_Init(NULL,NULL);
5011   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5012   r |= MPI_Finalize();
5013   return r; 
5014 ]])], [
5015 ac_have_mpi2_sec=yes
5016 AC_MSG_RESULT([yes, $MPI_CC])
5017 ], [
5018 ac_have_mpi2_sec=no
5019 AC_MSG_RESULT([no])
5021 CC=$saved_CC
5022 CFLAGS=$saved_CFLAGS
5023 LDFLAGS="$saved_LDFLAGS"
5024 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
5027 #----------------------------------------------------------------------------
5028 # Other library checks
5029 #----------------------------------------------------------------------------
5030 # There now follow some tests for Boost, and OpenMP.  These
5031 # tests are present because Drd has some regression tests that use
5032 # these packages.  All regression test programs all compiled only
5033 # for the primary target.  And so it is important that the configure
5034 # checks that follow, use the correct -m32 or -m64 flag for the
5035 # primary target (called $mflag_primary).  Otherwise, we can end up
5036 # in a situation (eg) where, on amd64-linux, the test for Boost checks
5037 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
5038 # only build (meaning, the primary target is x86-linux), the build
5039 # of the regtest programs that use Boost fails, because they are 
5040 # build as 32-bit (IN THIS EXAMPLE).
5042 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
5043 # NEEDED BY THE REGRESSION TEST PROGRAMS.
5046 # Check whether the boost library 1.35 or later has been installed.
5047 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
5049 AC_MSG_CHECKING([for boost])
5051 AC_LANG(C++)
5052 safe_CXXFLAGS=$CXXFLAGS
5053 CXXFLAGS="$mflag_primary"
5054 safe_LIBS="$LIBS"
5055 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
5057 AC_LINK_IFELSE([AC_LANG_SOURCE([
5058 #include <boost/thread.hpp>
5059 static void thread_func(void)
5060 { }
5061 int main(int argc, char** argv)
5063   boost::thread t(thread_func);
5064   return 0;
5066 ])],
5068 ac_have_boost_1_35=yes
5069 AC_SUBST([BOOST_CFLAGS], [])
5070 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
5071 AC_MSG_RESULT([yes])
5072 ], [
5073 ac_have_boost_1_35=no
5074 AC_MSG_RESULT([no])
5077 LIBS="$safe_LIBS"
5078 CXXFLAGS=$safe_CXXFLAGS
5079 AC_LANG(C)
5081 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
5084 # does this compiler support -fopenmp, does it have the include file
5085 # <omp.h> and does it have libgomp ?
5087 AC_MSG_CHECKING([for OpenMP])
5089 safe_CFLAGS=$CFLAGS
5090 CFLAGS="-fopenmp $mflag_primary -Werror"
5092 AC_LINK_IFELSE([AC_LANG_SOURCE([
5093 #include <omp.h> 
5094 int main(int argc, char** argv)
5096   omp_set_dynamic(0);
5097   return 0;
5099 ])],
5101 ac_have_openmp=yes
5102 AC_MSG_RESULT([yes])
5103 ], [
5104 ac_have_openmp=no
5105 AC_MSG_RESULT([no])
5107 CFLAGS=$safe_CFLAGS
5109 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5112 # Check for __builtin_popcount
5113 AC_MSG_CHECKING([for __builtin_popcount()])
5114 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5115 ]], [[
5116   __builtin_popcount(2);
5117   return 0;
5118 ]])], [
5119 AC_MSG_RESULT([yes])
5120 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5121           [Define to 1 if compiler provides __builtin_popcount().])
5122 ], [
5123 AC_MSG_RESULT([no])
5126 # Check for __builtin_clz
5127 AC_MSG_CHECKING([for __builtin_clz()])
5128 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5129 ]], [[
5130   __builtin_clz(2);
5131   return 0;
5132 ]])], [
5133 AC_MSG_RESULT([yes])
5134 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5135           [Define to 1 if compiler provides __builtin_clz().])
5136 ], [
5137 AC_MSG_RESULT([no])
5140 # Check for __builtin_ctz
5141 AC_MSG_CHECKING([for __builtin_ctz()])
5142 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5143 ]], [[
5144   __builtin_ctz(2);
5145   return 0;
5146 ]])], [
5147 AC_MSG_RESULT([yes])
5148 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5149           [Define to 1 if compiler provides __builtin_ctz().])
5150 ], [
5151 AC_MSG_RESULT([no])
5154 # does this compiler have built-in functions for atomic memory access for the
5155 # primary target ?
5156 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5158 safe_CFLAGS=$CFLAGS
5159 CFLAGS="$mflag_primary"
5161 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5162   int variable = 1;
5163   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5164           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5165 ]])], [
5166   ac_have_builtin_atomic_primary=yes
5167   AC_MSG_RESULT([yes])
5168   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])
5169 ], [
5170   ac_have_builtin_atomic_primary=no
5171   AC_MSG_RESULT([no])
5174 CFLAGS=$safe_CFLAGS
5176 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5177                [test x$ac_have_builtin_atomic_primary = xyes])
5180 # does this compiler have built-in functions for atomic memory access for the
5181 # secondary target ?
5183 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5185 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5187 safe_CFLAGS=$CFLAGS
5188 CFLAGS="$mflag_secondary"
5190 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5191   int variable = 1;
5192   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5193 ]])], [
5194   ac_have_builtin_atomic_secondary=yes
5195   AC_MSG_RESULT([yes])
5196 ], [
5197   ac_have_builtin_atomic_secondary=no
5198   AC_MSG_RESULT([no])
5201 CFLAGS=$safe_CFLAGS
5205 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5206                [test x$ac_have_builtin_atomic_secondary = xyes])
5208 # does this compiler have built-in functions for atomic memory access on
5209 # 64-bit integers for all targets ?
5211 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5213 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5214   #include <stdint.h>
5215 ]], [[
5216   uint64_t variable = 1;
5217   return __sync_add_and_fetch(&variable, 1)
5218 ]])], [
5219   ac_have_builtin_atomic64_primary=yes
5220 ], [
5221   ac_have_builtin_atomic64_primary=no
5224 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5226 safe_CFLAGS=$CFLAGS
5227 CFLAGS="$mflag_secondary"
5229 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5230   #include <stdint.h>
5231 ]], [[
5232   uint64_t variable = 1;
5233   return __sync_add_and_fetch(&variable, 1)
5234 ]])], [
5235   ac_have_builtin_atomic64_secondary=yes
5236 ], [
5237   ac_have_builtin_atomic64_secondary=no
5240 CFLAGS=$safe_CFLAGS
5244 if test x$ac_have_builtin_atomic64_primary = xyes && \
5245    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5246      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5247   AC_MSG_RESULT([yes])
5248   ac_have_builtin_atomic64=yes
5249 else
5250   AC_MSG_RESULT([no])
5251   ac_have_builtin_atomic64=no
5254 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5255                [test x$ac_have_builtin_atomic64 = xyes])
5257                
5258 AC_MSG_CHECKING([if platform has openat2 syscall])
5260 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5261   #include <sys/syscall.h>
5262 ]], [[
5263   return __NR_openat2
5264 ]])], [
5265   ac_have_openat2=yes
5266 ], [
5267   ac_have_openat2=no
5270 AM_CONDITIONAL([HAVE_OPENAT2],
5271                [test x$ac_have_openat2 = xyes])
5273 # does g++ have built-in functions for atomic memory access ?
5274 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5276 safe_CXXFLAGS=$CXXFLAGS
5277 CXXFLAGS="$mflag_primary"
5279 AC_LANG_PUSH(C++)
5280 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5281   int variable = 1;
5282   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5283           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5284 ]])], [
5285   ac_have_builtin_atomic_cxx=yes
5286   AC_MSG_RESULT([yes])
5287   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5288 ], [
5289   ac_have_builtin_atomic_cxx=no
5290   AC_MSG_RESULT([no])
5292 AC_LANG_POP(C++)
5294 CXXFLAGS=$safe_CXXFLAGS
5296 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5299 if test x$ac_have_usable_linux_futex_h = xyes \
5300         -a x$ac_have_builtin_atomic_primary = xyes; then
5301   ac_enable_linux_ticket_lock_primary=yes
5303 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5304                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5306 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5307         -a x$ac_have_usable_linux_futex_h = xyes \
5308         -a x$ac_have_builtin_atomic_secondary = xyes; then
5309   ac_enable_linux_ticket_lock_secondary=yes
5311 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5312                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5315 # does libstdc++ support annotating shared pointers ?
5316 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5318 safe_CXXFLAGS=$CXXFLAGS
5319 CXXFLAGS="-std=c++0x"
5321 AC_LANG_PUSH(C++)
5322 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5323   #include <memory>
5324 ]], [[
5325   std::shared_ptr<int> p
5326 ]])], [
5327   ac_have_shared_ptr=yes
5328 ], [
5329   ac_have_shared_ptr=no
5331 if test x$ac_have_shared_ptr = xyes; then
5332   # If compilation of the program below fails because of a syntax error
5333   # triggered by substituting one of the annotation macros then that
5334   # means that libstdc++ supports these macros.
5335   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5336     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5337     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5338     #include <memory>
5339   ]], [[
5340     std::shared_ptr<int> p
5341   ]])], [
5342     ac_have_shared_pointer_annotation=no
5343     AC_MSG_RESULT([no])
5344   ], [
5345     ac_have_shared_pointer_annotation=yes
5346     AC_MSG_RESULT([yes])
5347     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5348               [Define to 1 if libstd++ supports annotating shared pointers])
5349   ])
5350 else
5351   ac_have_shared_pointer_annotation=no
5352   AC_MSG_RESULT([no])
5354 AC_LANG_POP(C++)
5356 CXXFLAGS=$safe_CXXFLAGS
5358 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5359                [test x$ac_have_shared_pointer_annotation = xyes])
5362 #----------------------------------------------------------------------------
5363 # Ok.  We're done checking.
5364 #----------------------------------------------------------------------------
5366 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5367 AC_CONFIG_FILES([
5368    Makefile 
5369    VEX/Makefile:Makefile.vex.in
5370    valgrind.spec
5371    valgrind.pc
5372    glibc-2.X.supp
5373    glibc-2.X-helgrind.supp
5374    glibc-2.X-drd.supp
5375    include/valgrind.h
5376    docs/Makefile 
5377    docs/xml/vg-entities.xml
5378    tests/Makefile 
5379    tests/vg_regtest 
5380    perf/Makefile 
5381    perf/vg_perf
5382    gdbserver_tests/Makefile
5383    gdbserver_tests/solaris/Makefile
5384    include/Makefile 
5385    auxprogs/Makefile
5386    mpi/Makefile
5387    coregrind/Makefile 
5388    memcheck/Makefile
5389    memcheck/tests/Makefile
5390    memcheck/tests/common/Makefile
5391    memcheck/tests/amd64/Makefile
5392    memcheck/tests/x86/Makefile
5393    memcheck/tests/linux/Makefile
5394    memcheck/tests/linux/debuginfod-check.vgtest
5395    memcheck/tests/darwin/Makefile
5396    memcheck/tests/solaris/Makefile
5397    memcheck/tests/freebsd/Makefile
5398    memcheck/tests/amd64-linux/Makefile
5399    memcheck/tests/arm64-linux/Makefile
5400    memcheck/tests/x86-linux/Makefile
5401    memcheck/tests/amd64-solaris/Makefile
5402    memcheck/tests/x86-solaris/Makefile
5403    memcheck/tests/amd64-freebsd/Makefile
5404    memcheck/tests/x86-freebsd/Makefile
5405    memcheck/tests/ppc32/Makefile
5406    memcheck/tests/ppc64/Makefile
5407    memcheck/tests/s390x/Makefile
5408    memcheck/tests/mips32/Makefile
5409    memcheck/tests/mips64/Makefile
5410    memcheck/tests/vbit-test/Makefile
5411    cachegrind/Makefile
5412    cachegrind/tests/Makefile
5413    cachegrind/tests/x86/Makefile
5414    cachegrind/cg_annotate
5415    cachegrind/cg_diff
5416    cachegrind/cg_merge
5417    callgrind/Makefile
5418    callgrind/callgrind_annotate
5419    callgrind/callgrind_control
5420    callgrind/tests/Makefile
5421    helgrind/Makefile
5422    helgrind/tests/Makefile
5423    drd/Makefile
5424    drd/scripts/download-and-build-splash2
5425    drd/tests/Makefile
5426    massif/Makefile
5427    massif/tests/Makefile
5428    massif/ms_print
5429    dhat/Makefile
5430    dhat/tests/Makefile
5431    lackey/Makefile
5432    lackey/tests/Makefile
5433    none/Makefile
5434    none/tests/Makefile
5435    none/tests/scripts/Makefile
5436    none/tests/amd64/Makefile
5437    none/tests/ppc32/Makefile
5438    none/tests/ppc64/Makefile
5439    none/tests/x86/Makefile
5440    none/tests/arm/Makefile
5441    none/tests/arm64/Makefile
5442    none/tests/s390x/Makefile
5443    none/tests/mips32/Makefile
5444    none/tests/mips64/Makefile
5445    none/tests/nanomips/Makefile
5446    none/tests/linux/Makefile
5447    none/tests/darwin/Makefile
5448    none/tests/solaris/Makefile
5449    none/tests/freebsd/Makefile
5450    none/tests/amd64-linux/Makefile
5451    none/tests/x86-linux/Makefile
5452    none/tests/amd64-darwin/Makefile
5453    none/tests/x86-darwin/Makefile
5454    none/tests/amd64-solaris/Makefile
5455    none/tests/x86-solaris/Makefile
5456    none/tests/x86-freebsd/Makefile
5457    exp-bbv/Makefile
5458    exp-bbv/tests/Makefile
5459    exp-bbv/tests/x86/Makefile
5460    exp-bbv/tests/x86-linux/Makefile
5461    exp-bbv/tests/amd64-linux/Makefile
5462    exp-bbv/tests/ppc32-linux/Makefile
5463    exp-bbv/tests/arm-linux/Makefile
5464    shared/Makefile
5465    solaris/Makefile
5467 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5468                 [chmod +x coregrind/link_tool_exe_linux])
5469 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5470                 [chmod +x coregrind/link_tool_exe_freebsd])
5471 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5472                 [chmod +x coregrind/link_tool_exe_darwin])
5473 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5474                 [chmod +x coregrind/link_tool_exe_solaris])
5475 AC_CONFIG_FILES([tests/filter_stderr_basic],
5476                 [chmod +x tests/filter_stderr_basic])
5477 AC_CONFIG_FILES([tests/filter_discards],
5478                 [chmod +x tests/filter_discards])
5479 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5480                 [chmod +x memcheck/tests/filter_stderr])
5481 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5482                 [chmod +x memcheck/tests/filter_dw4])
5483 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5484                 [chmod +x memcheck/tests/filter_overlaperror])
5485 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5486                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5487 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5488                 [chmod +x gdbserver_tests/filter_gdb])
5489 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5490                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5491 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5492                 [chmod +x gdbserver_tests/filter_stderr])
5493 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5494                 [chmod +x gdbserver_tests/filter_vgdb])
5495 AC_CONFIG_FILES([drd/tests/filter_stderr],
5496                 [chmod +x drd/tests/filter_stderr])
5497 AC_CONFIG_FILES([drd/tests/filter_error_count],
5498                 [chmod +x drd/tests/filter_error_count])
5499 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5500                 [chmod +x drd/tests/filter_error_summary])
5501 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5502                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5503 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5504                 [chmod +x drd/tests/filter_thread_no])
5505 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5506                 [chmod +x drd/tests/filter_xml_and_thread_no])
5507 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5508                 [chmod +x helgrind/tests/filter_stderr])
5509 AC_OUTPUT
5511 cat<<EOF
5513                     Version: ${VERSION}
5514          Maximum build arch: ${ARCH_MAX}
5515          Primary build arch: ${VGCONF_ARCH_PRI}
5516        Secondary build arch: ${VGCONF_ARCH_SEC}
5517                    Build OS: ${VGCONF_OS}
5518      Link Time Optimisation: ${vg_cv_lto}
5519        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5520      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5521            Platform variant: ${VGCONF_PLATVARIANT}
5522       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5523          Default supp files: ${DEFAULT_SUPP}