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