2 ##------------------------------------------------------------##
4 # The multiple-architecture stuff in this file is pretty
5 # cryptic. Read docs/internals/multiple-architectures.txt
6 # for at least a partial explanation of what is going on.
8 ##------------------------------------------------------------##
10 # Process this file with autoconf to produce a configure script.
12 # Define major, minor, micro and suffix here once, then reuse them
13 # for version number in valgrind.h and vg-entities (documentation).
14 # suffix must be empty for a release, otherwise it is GIT or RC1, etc.
15 # Also set the (expected/last) release date here.
16 # Do not forget to rerun ./autogen.sh
17 m4_define([v_major_ver], [3])
18 m4_define([v_minor_ver], [21])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [GIT])
21 m4_define([v_rel_date], ["?? Apr 2023"])
22 m4_define([v_version],
23 m4_if(v_suffix_ver, [],
24 [v_major_ver.v_minor_ver.v_micro_ver],
25 [v_major_ver.v_minor_ver.v_micro_ver.v_suffix_ver]))
26 AC_INIT([Valgrind],[v_version],[valgrind-users@lists.sourceforge.net])
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])
41 #----------------------------------------------------------------------------
42 # Do NOT modify these flags here. Except in feature tests in which case
43 # the original values must be properly restored.
44 #----------------------------------------------------------------------------
48 #----------------------------------------------------------------------------
49 # Checks for various programs.
50 #----------------------------------------------------------------------------
57 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
58 # autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
59 # base (eg. most likely as Darwin-specific tests) we'll need one of the
61 # - put AC_PROG_OBJC in a Darwin-specific part of this file
62 # - Use AC_PROG_OBJC here and up the minimum autoconf version
63 # - Use the following, which is apparently equivalent:
64 # m4_ifdef([AC_PROG_OBJC],
66 # [AC_CHECK_TOOL([OBJC], [gcc])
68 # AC_SUBST([OBJCFLAGS])
71 # Set LTO_RANLIB variable to an lto enabled ranlib
72 if test "x$LTO_RANLIB" = "x"; then
73 AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
75 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
77 # provide a very basic definition for AC_PROG_SED if it's not provided by
78 # autoconf (as e.g. in autoconf 2.59).
79 m4_ifndef([AC_PROG_SED],
80 [AC_DEFUN([AC_PROG_SED],
82 AC_CHECK_PROGS([SED],[gsed sed])])])
85 # If no AR variable was specified, look up the name of the archiver. Otherwise
86 # do not touch the AR variable.
87 if test "x$AR" = "x"; then
88 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
90 AC_ARG_VAR([AR],[Archiver command])
92 # same for LTO_AR variable for lto enabled archiver
93 if test "x$LTO_AR" = "x"; then
94 AC_PATH_PROGS([LTO_AR], [gcc-ar])
96 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
99 # Check for the compiler support
100 if test "${GCC}" != "yes" ; then
101 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
104 # figure out where perl lives
105 AC_PATH_PROG(PERL, perl)
107 # figure out where gdb lives
108 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
109 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
111 # some older automake's don't have it so try something on our own
112 ifdef([AM_PROG_AS],[AM_PROG_AS],
122 # Check if 'diff' supports -u (universal diffs) and use it if possible.
124 AC_MSG_CHECKING([for diff -u])
127 # Comparing two identical files results in 0.
128 tmpfile="tmp-xxx-yyy-zzz"
130 if diff -u $tmpfile $tmpfile ; then
139 # Make sure we can compile in C99 mode.
141 if test "$ac_cv_prog_cc_c99" = "no"; then
142 AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
145 # We don't want gcc < 3.0
146 AC_MSG_CHECKING([for a supported version of gcc])
148 # Obtain the compiler version.
150 # A few examples of how the ${CC} --version output looks like:
152 # ######## gcc variants ########
153 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
154 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
155 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
156 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
157 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
158 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
159 # 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)
161 # ######## clang variants ########
162 # Clang: clang version 2.9 (tags/RELEASE_29/final)
163 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
164 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
166 # ######## Apple LLVM variants ########
167 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
168 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
171 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
174 gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
175 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
178 # Don't use -dumpversion with clang: it will always produce "4.2.1".
179 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
180 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ;
183 gcc_version=`${CC} -dumpversion 2>/dev/null`
186 gcc_version=`${CC} -dumpversion 2>/dev/null`
187 if test "x$gcc_version" = x; then
188 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
192 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
193 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
195 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
196 # statements have to be quoted.
197 case "${is_clang}-${gcc_version}" in
198 applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
199 AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
201 icc-1[[3-9]].*|icc-202[[0-9]].*)
202 AC_MSG_RESULT([ok (ICC version ${gcc_version})])
204 notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
205 AC_MSG_RESULT([ok (${gcc_version})])
207 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
208 AC_MSG_RESULT([ok (clang-${gcc_version})])
211 AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
212 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
216 #----------------------------------------------------------------------------
217 # Arch/OS/platform tests.
218 #----------------------------------------------------------------------------
219 # We create a number of arch/OS/platform-related variables. We prefix them
220 # all with "VGCONF_" which indicates that they are defined at
221 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
222 # variables used when compiling C files.
226 AC_MSG_CHECKING([for a supported CPU])
228 # ARCH_MAX reflects the most that this CPU can do: for example if it
229 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
230 # Ditto for amd64. It is used for more configuration below, but is not used
233 # Power PC returns powerpc for Big Endian. This was not changed when Little
234 # Endian support was added to the 64-bit architecture. The 64-bit Little
235 # Endian systems explicitly state le in the host_cpu. For clarity in the
236 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
237 # the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
238 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
239 # Endianness. The name PPC64 or ppc64 to 64-bit systems of either Endianness.
240 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
241 # Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
244 case "${host_cpu}" in
246 AC_MSG_RESULT([ok (${host_cpu})])
251 AC_MSG_RESULT([ok (${host_cpu})])
256 # this only referrs to 64-bit Big Endian
257 AC_MSG_RESULT([ok (${host_cpu})])
262 # this only referrs to 64-bit Little Endian
263 AC_MSG_RESULT([ok (${host_cpu})])
268 # On Linux this means only a 32-bit capable CPU.
269 AC_MSG_RESULT([ok (${host_cpu})])
274 AC_MSG_RESULT([ok (${host_cpu})])
279 AC_MSG_RESULT([ok (${host_cpu})])
284 AC_MSG_RESULT([ok (${host_cpu})])
289 AC_MSG_RESULT([ok (${host_cpu})])
294 AC_MSG_RESULT([ok (${host_cpu})])
299 AC_MSG_RESULT([ok (${host_cpu})])
304 AC_MSG_RESULT([ok (${host_cpu})])
309 AC_MSG_RESULT([ok (${host_cpu})])
313 AC_MSG_RESULT([ok (${host_cpu})])
318 AC_MSG_RESULT([no (${host_cpu})])
319 AC_MSG_ERROR([Unsupported host architecture. Sorry])
323 #----------------------------------------------------------------------------
325 # Sometimes it's convenient to subvert the bi-arch build system and
326 # just have a single build even though the underlying platform is
327 # capable of both. Hence handle --enable-only64bit and
328 # --enable-only32bit. Complain if both are issued :-)
329 # [Actually, if either of these options are used, I think both get built,
330 # but only one gets installed. So if you use an in-place build, both can be
333 # Check if a 64-bit only build has been requested
334 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
335 [AC_ARG_ENABLE(only64bit,
336 [ --enable-only64bit do a 64-bit only build],
337 [vg_cv_only64bit=$enableval],
338 [vg_cv_only64bit=no])])
340 # Check if a 32-bit only build has been requested
341 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
342 [AC_ARG_ENABLE(only32bit,
343 [ --enable-only32bit do a 32-bit only build],
344 [vg_cv_only32bit=$enableval],
345 [vg_cv_only32bit=no])])
348 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
350 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
353 #----------------------------------------------------------------------------
355 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
356 # compilation of many C files via -VGO_$(VGCONF_OS) and
357 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
358 AC_MSG_CHECKING([for a supported OS])
365 AC_MSG_RESULT([ok (${host_os})])
368 # Ok, this is linux. Check the kernel version
369 AC_MSG_CHECKING([for the kernel version])
374 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*)
375 AC_MSG_RESULT([unsupported (${kernel})])
376 AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
380 AC_MSG_RESULT([2.6 or later (${kernel})])
387 AC_MSG_RESULT([ok (${host_os})])
389 AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
391 AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
393 AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
395 AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
397 AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
399 AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1+])
401 AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
404 AC_MSG_CHECKING([for the kernel version])
409 AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
410 AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
411 freebsd_vers=$freebsd_10
414 AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
415 AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
416 freebsd_vers=$freebsd_11
421 AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
422 AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
423 freebsd_vers=$freebsd_12
426 AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
427 AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
428 freebsd_vers=$freebsd_12_2
435 AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
436 AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
437 freebsd_vers=$freebsd_13_0
440 AC_MSG_RESULT([FreeBSD 13.1+ (${kernel})])
441 AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
442 freebsd_vers=$freebsd_13_1
447 AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
448 AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
449 freebsd_vers=$freebsd_14
452 AC_MSG_RESULT([unsupported (${kernel})])
453 AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x])
457 DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
461 AC_MSG_RESULT([ok (${host_os})])
463 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
464 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
465 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
466 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
467 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
468 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
469 AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
470 AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
471 AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
473 AC_MSG_CHECKING([for the kernel version])
476 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
477 # has only one relevant version, the OS version. The `uname` check
478 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
479 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
480 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
481 # and we don't know of an macros similar to __GLIBC__ to get that info.
483 # XXX: `uname -r` won't do the right thing for cross-compiles, but
484 # that's not a problem yet.
486 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
487 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
488 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
489 # time support for 10.5 (the 9.* pattern just below), I'll leave it
490 # in for now, just in case anybody wants to give it a try. But I'm
491 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
494 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
495 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
496 DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
497 DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
500 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
501 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
502 DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
503 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
506 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
507 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
508 DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
509 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
512 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
513 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
514 DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
515 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
518 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
519 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
520 DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
521 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
524 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
525 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
526 DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
527 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
530 AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
531 AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
532 DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
533 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
536 AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
537 AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
538 DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
539 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
542 AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
543 AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
544 DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
545 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
548 AC_MSG_RESULT([unsupported (${kernel})])
549 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)])
555 AC_MSG_RESULT([ok (${host_os})])
558 uname_v=$( uname -v )
561 DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
564 DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
570 AC_MSG_RESULT([ok (${host_os})])
572 DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
576 AC_MSG_RESULT([no (${host_os})])
577 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
581 #----------------------------------------------------------------------------
583 # If we are building on a 64 bit platform test to see if the system
584 # supports building 32 bit programs and disable 32 bit support if it
585 # does not support building 32 bit programs
587 case "$ARCH_MAX-$VGCONF_OS" in
588 amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
589 AC_MSG_CHECKING([for 32 bit build support])
592 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
597 vg_cv_only64bit="yes"
600 CFLAGS=$safe_CFLAGS;;
602 AC_MSG_CHECKING([for 32 bit build support])
604 CFLAGS="$CFLAGS -mips32 -mabi=32"
605 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
606 #include <sys/prctl.h>
610 vg_cv_only64bit="yes"
613 CFLAGS=$safe_CFLAGS;;
616 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
618 [--enable-only32bit was specified but system does not support 32 bit builds])
621 #----------------------------------------------------------------------------
623 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
624 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
625 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
626 # above) will be "amd64" since that reflects the most that this cpu can do,
627 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
628 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
629 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
630 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
631 AC_SUBST(VGCONF_ARCH_PRI)
633 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
634 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
635 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
636 # It is empty if there is no secondary target.
637 AC_SUBST(VGCONF_ARCH_SEC)
639 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
640 # The entire system, including regression and performance tests, will be
641 # built for this target. The "_CAPS" indicates that the name is in capital
642 # letters, and it also uses '_' rather than '-' as a separator, because it's
643 # used to create various Makefile variables, which are all in caps by
644 # convention and cannot contain '-' characters. This is in contrast to
645 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
646 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
648 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
649 # Valgrind and tools will also be built for this target, but not the
650 # regression or performance tests.
652 # By default, the primary arch is the same as the "max" arch, as commented
653 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
654 # the big case statement just below here, in the case where we're building
655 # on a 64 bit machine but have been requested only to do a 32 bit build.
656 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
658 AC_MSG_CHECKING([for a supported CPU/OS combination])
660 # NB. The load address for a given platform may be specified in more
661 # than one place, in some cases, depending on whether we're doing a biarch,
662 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
663 # Be careful to give consistent values in all subcases. Also, all four
664 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
665 # even if it is to "0xUNSET".
667 case "$ARCH_MAX-$VGCONF_OS" in
669 VGCONF_ARCH_PRI="x86"
671 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
672 VGCONF_PLATFORM_SEC_CAPS=""
673 valt_load_address_pri_norml="0x58000000"
674 valt_load_address_pri_inner="0x38000000"
675 valt_load_address_sec_norml="0xUNSET"
676 valt_load_address_sec_inner="0xUNSET"
677 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
680 valt_load_address_sec_norml="0xUNSET"
681 valt_load_address_sec_inner="0xUNSET"
682 if test x$vg_cv_only64bit = xyes; then
683 VGCONF_ARCH_PRI="amd64"
685 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
686 VGCONF_PLATFORM_SEC_CAPS=""
687 valt_load_address_pri_norml="0x58000000"
688 valt_load_address_pri_inner="0x38000000"
689 elif test x$vg_cv_only32bit = xyes; then
690 VGCONF_ARCH_PRI="x86"
692 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
693 VGCONF_PLATFORM_SEC_CAPS=""
694 valt_load_address_pri_norml="0x58000000"
695 valt_load_address_pri_inner="0x38000000"
697 VGCONF_ARCH_PRI="amd64"
698 VGCONF_ARCH_SEC="x86"
699 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
700 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
701 valt_load_address_pri_norml="0x58000000"
702 valt_load_address_pri_inner="0x38000000"
703 valt_load_address_sec_norml="0x58000000"
704 valt_load_address_sec_inner="0x38000000"
706 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
709 VGCONF_ARCH_PRI="ppc32"
711 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
712 VGCONF_PLATFORM_SEC_CAPS=""
713 valt_load_address_pri_norml="0x58000000"
714 valt_load_address_pri_inner="0x38000000"
715 valt_load_address_sec_norml="0xUNSET"
716 valt_load_address_sec_inner="0xUNSET"
717 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
720 valt_load_address_sec_norml="0xUNSET"
721 valt_load_address_sec_inner="0xUNSET"
722 if test x$vg_cv_only64bit = xyes; then
723 VGCONF_ARCH_PRI="ppc64be"
725 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
726 VGCONF_PLATFORM_SEC_CAPS=""
727 valt_load_address_pri_norml="0x58000000"
728 valt_load_address_pri_inner="0x38000000"
729 elif test x$vg_cv_only32bit = xyes; then
730 VGCONF_ARCH_PRI="ppc32"
732 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
733 VGCONF_PLATFORM_SEC_CAPS=""
734 valt_load_address_pri_norml="0x58000000"
735 valt_load_address_pri_inner="0x38000000"
737 VGCONF_ARCH_PRI="ppc64be"
738 VGCONF_ARCH_SEC="ppc32"
739 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
740 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
741 valt_load_address_pri_norml="0x58000000"
742 valt_load_address_pri_inner="0x38000000"
743 valt_load_address_sec_norml="0x58000000"
744 valt_load_address_sec_inner="0x38000000"
746 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
749 # Little Endian is only supported on PPC64
750 valt_load_address_sec_norml="0xUNSET"
751 valt_load_address_sec_inner="0xUNSET"
752 VGCONF_ARCH_PRI="ppc64le"
754 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
755 VGCONF_PLATFORM_SEC_CAPS=""
756 valt_load_address_pri_norml="0x58000000"
757 valt_load_address_pri_inner="0x38000000"
758 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
761 VGCONF_ARCH_PRI="x86"
763 VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
764 VGCONF_PLATFORM_SEC_CAPS=""
765 valt_load_address_pri_norml="0x38000000"
766 valt_load_address_pri_inner="0x28000000"
767 valt_load_address_sec_norml="0xUNSET"
768 valt_load_address_sec_inner="0xUNSET"
769 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
772 if test x$vg_cv_only64bit = xyes; then
773 VGCONF_ARCH_PRI="amd64"
775 VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
776 VGCONF_PLATFORM_SEC_CAPS=""
777 elif test x$vg_cv_only32bit = xyes; then
778 VGCONF_ARCH_PRI="x86"
780 VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
781 VGCONF_PLATFORM_SEC_CAPS=""
783 VGCONF_ARCH_PRI="amd64"
784 VGCONF_ARCH_SEC="x86"
785 VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
786 VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
788 # These work with either base clang or ports installed gcc
789 # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
790 if test x$is_clang = xclang ; then
791 FLAG_32ON64="-B/usr/lib32"
793 GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
794 FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
796 valt_load_address_pri_norml="0x38000000"
797 valt_load_address_pri_inner="0x28000000"
798 valt_load_address_sec_norml="0x38000000"
799 valt_load_address_sec_inner="0x28000000"
800 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
802 # Darwin gets identified as 32-bit even when it supports 64-bit.
803 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
804 # all Macs support both 32-bit and 64-bit, so we just build both. If
805 # someone has a really old 32-bit only machine they can (hopefully?)
806 # build with --enable-only32bit. See bug 243362.
807 x86-darwin|amd64-darwin)
809 valt_load_address_sec_norml="0xUNSET"
810 valt_load_address_sec_inner="0xUNSET"
811 if test x$vg_cv_only64bit = xyes; then
812 VGCONF_ARCH_PRI="amd64"
814 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
815 VGCONF_PLATFORM_SEC_CAPS=""
816 valt_load_address_pri_norml="0x158000000"
817 valt_load_address_pri_inner="0x138000000"
818 elif test x$vg_cv_only32bit = xyes; then
819 VGCONF_ARCH_PRI="x86"
821 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
822 VGCONF_PLATFORM_SEC_CAPS=""
823 VGCONF_ARCH_PRI_CAPS="x86"
824 valt_load_address_pri_norml="0x58000000"
825 valt_load_address_pri_inner="0x38000000"
827 VGCONF_ARCH_PRI="amd64"
828 VGCONF_ARCH_SEC="x86"
829 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
830 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
831 valt_load_address_pri_norml="0x158000000"
832 valt_load_address_pri_inner="0x138000000"
833 valt_load_address_sec_norml="0x58000000"
834 valt_load_address_sec_inner="0x38000000"
836 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
839 VGCONF_ARCH_PRI="arm"
840 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
841 VGCONF_PLATFORM_SEC_CAPS=""
842 valt_load_address_pri_norml="0x58000000"
843 valt_load_address_pri_inner="0x38000000"
844 valt_load_address_sec_norml="0xUNSET"
845 valt_load_address_sec_inner="0xUNSET"
846 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
849 valt_load_address_sec_norml="0xUNSET"
850 valt_load_address_sec_inner="0xUNSET"
851 if test x$vg_cv_only64bit = xyes; then
852 VGCONF_ARCH_PRI="arm64"
854 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
855 VGCONF_PLATFORM_SEC_CAPS=""
856 valt_load_address_pri_norml="0x58000000"
857 valt_load_address_pri_inner="0x38000000"
858 elif test x$vg_cv_only32bit = xyes; then
859 VGCONF_ARCH_PRI="arm"
861 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
862 VGCONF_PLATFORM_SEC_CAPS=""
863 valt_load_address_pri_norml="0x58000000"
864 valt_load_address_pri_inner="0x38000000"
866 VGCONF_ARCH_PRI="arm64"
867 VGCONF_ARCH_SEC="arm"
868 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
869 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
870 valt_load_address_pri_norml="0x58000000"
871 valt_load_address_pri_inner="0x38000000"
872 valt_load_address_sec_norml="0x58000000"
873 valt_load_address_sec_inner="0x38000000"
875 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
878 VGCONF_ARCH_PRI="s390x"
880 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
881 VGCONF_PLATFORM_SEC_CAPS=""
882 # To improve branch prediction hit rate we want to have
883 # the generated code close to valgrind (host) code
884 valt_load_address_pri_norml="0x800000000"
885 valt_load_address_pri_inner="0x810000000"
886 valt_load_address_sec_norml="0xUNSET"
887 valt_load_address_sec_inner="0xUNSET"
888 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
891 VGCONF_ARCH_PRI="mips32"
893 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
894 VGCONF_PLATFORM_SEC_CAPS=""
895 valt_load_address_pri_norml="0x58000000"
896 valt_load_address_pri_inner="0x38000000"
897 valt_load_address_sec_norml="0xUNSET"
898 valt_load_address_sec_inner="0xUNSET"
899 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
902 valt_load_address_sec_norml="0xUNSET"
903 valt_load_address_sec_inner="0xUNSET"
904 if test x$vg_cv_only64bit = xyes; then
905 VGCONF_ARCH_PRI="mips64"
906 VGCONF_PLATFORM_SEC_CAPS=""
907 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
908 VGCONF_PLATFORM_SEC_CAPS=""
909 valt_load_address_pri_norml="0x58000000"
910 valt_load_address_pri_inner="0x38000000"
911 elif test x$vg_cv_only32bit = xyes; then
912 VGCONF_ARCH_PRI="mips32"
914 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
915 VGCONF_PLATFORM_SEC_CAPS=""
916 valt_load_address_pri_norml="0x58000000"
917 valt_load_address_pri_inner="0x38000000"
919 VGCONF_ARCH_PRI="mips64"
920 VGCONF_ARCH_SEC="mips32"
921 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
922 VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
923 valt_load_address_pri_norml="0x58000000"
924 valt_load_address_pri_inner="0x38000000"
925 valt_load_address_sec_norml="0x58000000"
926 valt_load_address_sec_inner="0x38000000"
928 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
931 VGCONF_ARCH_PRI="nanomips"
933 VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
934 VGCONF_PLATFORM_SEC_CAPS=""
935 valt_load_address_pri_norml="0x58000000"
936 valt_load_address_pri_inner="0x38000000"
937 valt_load_address_sec_norml="0xUNSET"
938 valt_load_address_sec_inner="0xUNSET"
939 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
942 VGCONF_ARCH_PRI="x86"
944 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
945 VGCONF_PLATFORM_SEC_CAPS=""
946 valt_load_address_pri_norml="0x58000000"
947 valt_load_address_pri_inner="0x38000000"
948 valt_load_address_sec_norml="0xUNSET"
949 valt_load_address_sec_inner="0xUNSET"
950 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
953 valt_load_address_sec_norml="0xUNSET"
954 valt_load_address_sec_inner="0xUNSET"
955 if test x$vg_cv_only64bit = xyes; then
956 VGCONF_ARCH_PRI="amd64"
958 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
959 VGCONF_PLATFORM_SEC_CAPS=""
960 valt_load_address_pri_norml="0x58000000"
961 valt_load_address_pri_inner="0x38000000"
962 elif test x$vg_cv_only32bit = xyes; then
963 VGCONF_ARCH_PRI="x86"
965 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
966 VGCONF_PLATFORM_SEC_CAPS=""
967 valt_load_address_pri_norml="0x58000000"
968 valt_load_address_pri_inner="0x38000000"
970 VGCONF_ARCH_PRI="amd64"
971 VGCONF_ARCH_SEC="x86"
972 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
973 VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
974 valt_load_address_pri_norml="0x58000000"
975 valt_load_address_pri_inner="0x38000000"
976 valt_load_address_sec_norml="0x58000000"
977 valt_load_address_sec_inner="0x38000000"
979 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
982 VGCONF_ARCH_PRI="unknown"
983 VGCONF_ARCH_SEC="unknown"
984 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
985 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
986 valt_load_address_pri_norml="0xUNSET"
987 valt_load_address_pri_inner="0xUNSET"
988 valt_load_address_sec_norml="0xUNSET"
989 valt_load_address_sec_inner="0xUNSET"
990 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
991 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
995 #----------------------------------------------------------------------------
997 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
999 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
1000 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1001 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1002 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1003 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1004 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1005 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1006 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1007 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1008 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
1009 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1010 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1011 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1012 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1013 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
1014 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1015 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1016 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
1017 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1018 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1019 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
1020 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1021 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1022 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
1023 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1024 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1025 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1026 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1027 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1028 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1029 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1030 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
1031 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1032 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1034 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
1036 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
1037 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1038 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1039 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
1040 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1041 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
1042 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1043 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1044 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1045 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1046 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1047 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1048 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
1049 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1050 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1051 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
1052 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1053 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1054 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1055 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1056 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1057 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1058 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1059 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1060 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1061 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1062 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1063 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1064 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1065 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1066 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD,
1067 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1068 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1069 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1070 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1071 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
1072 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1073 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1074 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1075 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1076 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1077 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1080 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
1081 # Relies on the assumption that the primary and secondary targets are
1082 # for the same OS, so therefore only necessary to test the primary.
1083 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1084 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1085 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1086 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1087 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1088 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1089 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1090 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1091 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1092 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1093 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1094 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1095 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1096 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1097 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1098 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1099 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1100 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1101 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1102 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1103 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1104 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1105 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1106 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1107 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1108 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1111 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1112 # there is a secondary target.
1113 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1114 test x$VGCONF_PLATFORM_SEC_CAPS != x)
1116 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1117 dnl fallback definition
1118 dnl The macro is courtesy of Dave Hart:
1119 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1120 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1121 if test -z "$$1_TRUE"; then :
1130 #----------------------------------------------------------------------------
1132 #----------------------------------------------------------------------------
1134 # Check if this should be built as an inner Valgrind, to be run within
1135 # another Valgrind. Choose the load address accordingly.
1136 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1137 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1138 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1139 [AC_ARG_ENABLE(inner,
1140 [ --enable-inner enables self-hosting],
1141 [vg_cv_inner=$enableval],
1143 if test "$vg_cv_inner" = yes; then
1144 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1145 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1146 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1148 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1149 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1152 #----------------------------------------------------------------------------
1153 # Undefined behaviour sanitiser
1154 #----------------------------------------------------------------------------
1155 # Check whether we should build with the undefined beahviour sanitiser.
1157 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1158 [AC_ARG_ENABLE(ubsan,
1159 [ --enable-ubsan enables the undefined behaviour sanitiser],
1160 [vg_cv_ubsan=$enableval],
1163 #----------------------------------------------------------------------------
1164 # Extra fine-tuning of installation directories
1165 #----------------------------------------------------------------------------
1167 [ --with-tmpdir=PATH Specify path for temporary files],
1170 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1171 AC_SUBST(VG_TMPDIR, [$tmpdir])
1173 #----------------------------------------------------------------------------
1175 #----------------------------------------------------------------------------
1176 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1177 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1178 AC_MSG_CHECKING([for xcode sdk include path])
1179 AC_ARG_WITH(xcodedir,
1180 [ --with-xcode-path=PATH Specify path for xcode sdk includes],
1181 [xcodedir="$withval"],
1183 if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1184 xcrundir=`xcrun --sdk macosx --show-sdk-path`
1185 if test -z "$xcrundir"; then
1186 xcodedir="/usr/include"
1188 xcodedir="$xcrundir/usr/include"
1191 xcodedir="/usr/include"
1194 AC_MSG_RESULT([$xcodedir])
1195 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1196 AC_SUBST(XCODE_DIR, [$xcodedir])])
1198 #----------------------------------------------------------------------------
1199 # Libc and suppressions
1200 #----------------------------------------------------------------------------
1201 # This variable will collect the suppression files to be used.
1202 AC_SUBST(DEFAULT_SUPP)
1204 AC_CHECK_HEADER([features.h])
1206 if test x$ac_cv_header_features_h = xyes; then
1207 AC_DEFINE([HAVE_HEADER_FEATURES_H], 1,
1208 [Define to 1 if you have the `features.h' header.])
1209 rm -f conftest.$ac_ext
1210 cat <<_ACEOF >conftest.$ac_ext
1211 #include <features.h>
1212 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1213 glibc version is: __GLIBC__ __GLIBC_MINOR__
1216 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1219 # not really a version check
1220 AC_EGREP_CPP([DARWIN_LIBC], [
1221 #include <sys/cdefs.h>
1222 #if defined(__DARWIN_VERS_1050)
1226 GLIBC_VERSION="darwin")
1228 AC_EGREP_CPP([FREEBSD_LIBC], [
1229 #include <sys/cdefs.h>
1230 #if defined(__FreeBSD__)
1234 GLIBC_VERSION="freebsd")
1236 # not really a version check
1237 AC_EGREP_CPP([BIONIC_LIBC], [
1238 #if defined(__ANDROID__)
1242 GLIBC_VERSION="bionic")
1244 # there is only one version of libc on Solaris
1245 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1246 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1247 GLIBC_VERSION="solaris"
1250 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1252 if test x$GLIBC_VERSION = x; then
1253 if $CC -dumpmachine | grep -q musl; then
1258 # If this is glibc then figure out the generic (in file) libc.so and
1259 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1260 # was a separate library, afterwards it was merged into libc.so and
1261 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1262 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1263 case ${GLIBC_VERSION} in
1265 AC_MSG_CHECKING([whether pthread_create needs libpthread])
1266 AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1269 GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1270 GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1272 AC_MSG_RESULT([yes])
1273 GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1274 GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1278 AC_MSG_CHECKING([not glibc...])
1279 AC_MSG_RESULT([${GLIBC_VERSION}])
1283 AC_MSG_CHECKING([the glibc version])
1285 case "${GLIBC_VERSION}" in
1287 AC_MSG_RESULT(${GLIBC_VERSION} family)
1288 DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1289 DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1290 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1293 AC_MSG_RESULT(${GLIBC_VERSION} family)
1294 DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1295 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1296 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1299 AC_MSG_RESULT(${GLIBC_VERSION} family)
1300 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1301 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1302 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1305 AC_MSG_RESULT(${GLIBC_VERSION} family)
1306 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1307 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1308 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1309 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1310 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1313 AC_MSG_RESULT(${GLIBC_VERSION} family)
1314 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1315 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1316 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1317 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1318 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1319 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1320 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1323 AC_MSG_RESULT(Darwin)
1324 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1325 # DEFAULT_SUPP set by kernel version check above.
1328 AC_MSG_RESULT(FreeBSD)
1329 AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1330 # DEFAULT_SUPP set by kernel version check above.
1333 AC_MSG_RESULT(Bionic)
1334 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1335 DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1338 AC_MSG_RESULT(Solaris)
1339 # DEFAULT_SUPP set in host_os switch-case above.
1340 # No other suppression file is used.
1344 AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1345 DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1348 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1349 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1350 AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1354 AC_SUBST(GLIBC_VERSION)
1355 AC_SUBST(GLIBC_LIBC_PATH)
1356 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1359 if test "$VGCONF_OS" != "solaris"; then
1360 # Add default suppressions for the X client libraries. Make no
1361 # attempt to detect whether such libraries are installed on the
1362 # build machine (or even if any X facilities are present); just
1363 # add the suppressions antidisirregardless.
1364 DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1365 DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1369 #----------------------------------------------------------------------------
1370 # Platform variants?
1371 #----------------------------------------------------------------------------
1373 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1374 # But there are times where we need a bit more control. The motivating
1375 # and currently only case is Android: this is almost identical to
1376 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1377 # platform variant tags, which get passed in the compile as
1378 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1380 # In almost all cases, the <variant> bit is "vanilla". But for Android
1381 # it is "android" instead.
1383 # Consequently (eg), plain arm-linux would build with
1385 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1387 # whilst an Android build would have
1389 # -DVGP_arm_linux -DVGPV_arm_linux_android
1391 # Same for x86. The setup of the platform variant is pushed relatively far
1392 # down this file in order that we can inspect any of the variables set above.
1394 # In the normal case ..
1395 VGCONF_PLATVARIANT="vanilla"
1398 if test "$GLIBC_VERSION" = "bionic";
1400 VGCONF_PLATVARIANT="android"
1403 AC_SUBST(VGCONF_PLATVARIANT)
1406 # FIXME: do we also want to define automake variables
1407 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1408 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1409 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1410 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1411 # that's what we'd need to do to use this, since what we'd want to write
1414 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1416 # Hmm. Can't think of a nice clean solution to this.
1418 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1419 test x$VGCONF_PLATVARIANT = xvanilla)
1420 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1421 test x$VGCONF_PLATVARIANT = xandroid)
1424 #----------------------------------------------------------------------------
1425 # Checking for various library functions and other definitions
1426 #----------------------------------------------------------------------------
1428 # Check for AT_FDCWD
1430 AC_MSG_CHECKING([for AT_FDCWD])
1431 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1438 ac_have_at_fdcwd=yes
1439 AC_MSG_RESULT([yes])
1445 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1447 # Check for stpncpy function definition in string.h
1448 # This explicitly checks with _GNU_SOURCE defined since that is also
1449 # used in the test case (some systems might define it without anyway
1450 # since stpncpy is part of The Open Group Base Specifications Issue 7
1451 # IEEE Std 1003.1-2008.
1452 AC_MSG_CHECKING([for stpncpy])
1453 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1460 char *r = stpncpy(d, s, n);
1462 ac_have_gnu_stpncpy=yes
1463 AC_MSG_RESULT([yes])
1465 ac_have_gnu_stpncpy=no
1469 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1471 # Check for PTRACE_GETREGS
1473 AC_MSG_CHECKING([for PTRACE_GETREGS])
1474 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1477 #include <sys/ptrace.h>
1478 #include <sys/user.h>
1481 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1483 AC_MSG_RESULT([yes])
1484 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1485 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1491 # Check for CLOCK_MONOTONIC
1493 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1495 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1499 clock_gettime(CLOCK_MONOTONIC, &t);
1502 AC_MSG_RESULT([yes])
1503 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1504 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1510 # Check for ELF32/64_CHDR
1512 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1515 # Check for PTHREAD_RWLOCK_T
1517 AC_MSG_CHECKING([for pthread_rwlock_t])
1519 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1521 #include <pthread.h>
1523 pthread_rwlock_t rwl;
1525 AC_MSG_RESULT([yes])
1526 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1527 [Define to 1 if you have the `pthread_rwlock_t' type.])
1532 # Check for CLOCKID_T
1534 AC_MSG_CHECKING([for clockid_t])
1536 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1541 AC_MSG_RESULT([yes])
1542 AC_DEFINE([HAVE_CLOCKID_T], 1,
1543 [Define to 1 if you have the `clockid_t' type.])
1548 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1550 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1552 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1554 #include <pthread.h>
1556 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1558 AC_MSG_RESULT([yes])
1559 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1560 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1566 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1568 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1570 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1572 #include <pthread.h>
1574 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1576 AC_MSG_RESULT([yes])
1577 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1578 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1584 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1586 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1588 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1590 #include <pthread.h>
1592 return (PTHREAD_MUTEX_RECURSIVE_NP);
1594 AC_MSG_RESULT([yes])
1595 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1596 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1602 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1604 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1606 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1608 #include <pthread.h>
1610 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1613 AC_MSG_RESULT([yes])
1614 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1615 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1621 # Check whether pthread_mutex_t has a member called __m_kind.
1623 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1624 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1626 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1629 [#include <pthread.h>])
1632 # Check whether pthread_mutex_t has a member called __data.__kind.
1634 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1635 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1637 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1640 [#include <pthread.h>])
1642 # Convenience function. Set flags based on the existing HWCAP entries.
1643 # The AT_HWCAP entries are generated by glibc, and are based on
1644 # functions supported by the hardware/system/libc.
1645 # Subsequent support for whether the capability will actually be utilized
1646 # will also be checked against the compiler capabilities.
1648 # AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1649 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1651 AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1652 if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1654 AC_MSG_RESULT([yes])
1655 AC_SUBST([$2],[yes])
1662 # gather hardware capabilities. (hardware/kernel/libc)
1663 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1664 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1665 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1666 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1667 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1668 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1669 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1670 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1671 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1672 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1675 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1676 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1677 # compiler support for isa 2.07 level instructions
1678 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1679 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1681 __asm__ __volatile__("mtvsrd 1,2 ");
1683 ac_asm_have_isa_2_07=yes
1684 AC_MSG_RESULT([yes])
1686 ac_asm_have_isa_2_07=no
1689 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1690 -a x$HWCAP_HAS_ISA_2_07 = xyes])
1692 # altivec (vsx) support.
1693 # does this compiler support -maltivec and does it have the include file
1695 AC_MSG_CHECKING([for Altivec support in the compiler ])
1697 CFLAGS="-maltivec -Werror"
1698 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1699 #include <altivec.h>
1701 vector unsigned int v;
1704 AC_MSG_RESULT([yes])
1710 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1711 -a x$HWCAP_HAS_ALTIVEC = xyes])
1713 # Check that both: the compiler supports -mvsx and that the assembler
1714 # understands VSX instructions. If either of those doesn't work,
1715 # conclude that we can't do VSX.
1716 AC_MSG_CHECKING([for VSX compiler flag support])
1718 CFLAGS="-mvsx -Werror"
1719 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1722 ac_compiler_supports_vsx_flag=yes
1723 AC_MSG_RESULT([yes])
1725 ac_compiler_supports_vsx_flag=no
1730 AC_MSG_CHECKING([for VSX support in the assembler ])
1732 CFLAGS="-mvsx -Werror"
1733 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1734 #include <altivec.h>
1736 vector unsigned int v;
1737 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1739 ac_compiler_supports_vsx=yes
1740 AC_MSG_RESULT([yes])
1742 ac_compiler_supports_vsx=no
1746 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1747 -a x$ac_compiler_supports_vsx = xyes \
1748 -a x$HWCAP_HAS_VSX = xyes ])
1750 # DFP (Decimal Float)
1751 # The initial DFP support was added in Power 6. The dcffix instruction
1752 # support was added in Power 7.
1753 AC_MSG_CHECKING([that assembler knows DFP])
1754 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1757 __asm__ __volatile__("adtr 1, 2, 3")
1759 __asm__ __volatile__(".machine power7;\n" \
1765 AC_MSG_RESULT([yes])
1770 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1772 CFLAGS="-mhard-dfp -Werror"
1774 # The dcffix instruction is Power 7
1775 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1778 __asm__ __volatile__("adtr 1, 2, 3")
1780 __asm__ __volatile__(".machine power7;\n" \
1785 ac_compiler_have_dfp=yes
1786 AC_MSG_RESULT([yes])
1788 ac_compiler_have_dfp=no
1792 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1793 -a x$ac_compiler_have_dfp = xyes \
1794 -a x$HWCAP_HAS_DFP = xyes )
1796 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1797 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1799 _Decimal64 x = 0.0DD;
1801 ac_compiler_have_dfp_type=yes
1802 AC_MSG_RESULT([yes])
1804 ac_compiler_have_dfp_type=no
1807 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1808 -a x$HWCAP_HAS_DFP = xyes )
1811 # HTM (Hardware Transactional Memory)
1812 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1814 CFLAGS="-mhtm -Werror"
1815 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1819 AC_MSG_RESULT([yes])
1820 ac_compiler_supports_htm=yes
1823 ac_compiler_supports_htm=no
1827 AC_MSG_CHECKING([if compiler can find the htm builtins])
1829 CFLAGS="-mhtm -Werror"
1830 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1832 if (__builtin_tbegin (0))
1835 AC_MSG_RESULT([yes])
1836 ac_compiler_sees_htm_builtins=yes
1839 ac_compiler_sees_htm_builtins=no
1843 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1844 -a x$ac_compiler_sees_htm_builtins = xyes \
1845 -a x$HWCAP_HAS_HTM = xyes )
1847 # isa 3.0 checking. (actually 3.0 or newer)
1848 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1850 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1852 __asm__ __volatile__ (".machine power9;\n" \
1855 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1858 CFLAGS="-DHAS_ISA_3_00"
1859 ac_asm_have_isa_3_00=yes
1860 AC_MSG_RESULT([yes])
1862 ac_asm_have_isa_3_00=no
1868 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1870 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1872 __asm__ __volatile__ (".machine power9;\n" \
1873 "xscvhpdp 1,2;\n" );
1875 ac_asm_have_xscvhpdp=yes
1876 AC_MSG_RESULT([yes])
1878 ac_asm_have_xscvhpdp=no
1882 # darn instruction checking
1883 AC_MSG_CHECKING([that assembler knows darn instruction ])
1885 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1887 __asm__ __volatile__(".machine power9; darn 1,0 ");
1889 ac_asm_have_darn_inst=yes
1890 AC_MSG_RESULT([yes])
1892 ac_asm_have_darn_inst=no
1897 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1898 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1900 __asm__ __volatile__ (".machine power10;\n" \
1903 ac_asm_have_isa_3_1=yes
1904 AC_MSG_RESULT([yes])
1906 ac_asm_have_isa_3_1=no
1911 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1912 -a x$HWCAP_HAS_ISA_3_00 = xyes])
1914 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1915 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1917 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1918 -a x$HWCAP_HAS_ISA_3_1 = xyes])
1920 # Check for pthread_create@GLIBC2.0
1921 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1924 CFLAGS="-lpthread -Werror"
1925 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1926 extern int pthread_create_glibc_2_0(void*, const void*,
1927 void *(*)(void*), void*);
1928 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1932 * Apparently on PowerPC linking this program succeeds and generates an
1933 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1935 #error This test does not work properly on PowerPC.
1937 pthread_create_glibc_2_0(0, 0, 0, 0);
1941 ac_have_pthread_create_glibc_2_0=yes
1942 AC_MSG_RESULT([yes])
1943 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1944 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1946 ac_have_pthread_create_glibc_2_0=no
1951 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1952 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1955 # Check for dlinfo RTLD_DI_TLS_MODID
1956 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1960 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1967 size_t sizes[10000];
1968 size_t modid_offset;
1969 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1972 ac_have_dlinfo_rtld_di_tls_modid=yes
1973 AC_MSG_RESULT([yes])
1974 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1975 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1977 ac_have_dlinfo_rtld_di_tls_modid=no
1982 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1983 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1986 # Check for eventfd_t, eventfd() and eventfd_read()
1987 AC_MSG_CHECKING([for eventfd()])
1989 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1990 #include <sys/eventfd.h>
1996 eventfd_read(fd, &ev);
1999 AC_MSG_RESULT([yes])
2000 AC_DEFINE([HAVE_EVENTFD], 1,
2001 [Define to 1 if you have the `eventfd' function.])
2002 AC_DEFINE([HAVE_EVENTFD_READ], 1,
2003 [Define to 1 if you have the `eventfd_read' function.])
2008 # Check whether compiler can process #include <thread> without errors
2009 # clang 3.3 cannot process <thread> from e.g.
2010 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
2012 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
2014 safe_CXXFLAGS=$CXXFLAGS
2017 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2021 ac_cxx_can_include_thread_header=yes
2022 AC_MSG_RESULT([yes])
2024 ac_cxx_can_include_thread_header=no
2027 CXXFLAGS=$safe_CXXFLAGS
2030 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2032 # Check whether compiler can process #include <condition_variable> without errors
2034 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2036 safe_CXXFLAGS=$CXXFLAGS
2039 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2040 #include <condition_variable>
2043 ac_cxx_can_include_condition_variable_header=yes
2044 AC_MSG_RESULT([yes])
2046 ac_cxx_can_include_condition_variable_header=no
2049 CXXFLAGS=$safe_CXXFLAGS
2052 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2054 # check for std::shared_timed_mutex, this is a C++ 14 feature
2056 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2058 safe_CXXFLAGS=$CXXFLAGS
2059 CXXFLAGS="-std=c++1y -pthread"
2061 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2062 #include <shared_mutex>
2063 std::shared_timed_mutex test_mutex;
2066 ac_cxx_can_use_shared_timed_mutex=yes
2067 AC_MSG_RESULT([yes])
2069 ac_cxx_can_use_shared_timed_mutex=no
2072 CXXFLAGS=$safe_CXXFLAGS
2075 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2077 # check for std::shared_mutex, this is a C++ 11 feature
2079 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2081 safe_CXXFLAGS=$CXXFLAGS
2082 CXXFLAGS="-std=c++0x -pthread"
2084 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2086 std::timed_mutex test_mutex;
2089 ac_cxx_can_use_timed_mutex=yes
2090 AC_MSG_RESULT([yes])
2092 ac_cxx_can_use_timed_mutex=no
2095 CXXFLAGS=$safe_CXXFLAGS
2098 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2100 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2101 # of the user_regs_struct from sys/user.h. They are structurally the same
2102 # but we get either one or the other.
2104 AC_CHECK_TYPE([struct user_regs_struct],
2105 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2106 [[#include <sys/ptrace.h>]
2107 [#include <sys/time.h>]
2108 [#include <sys/user.h>]])
2109 if test "$sys_user_has_user_regs" = "yes"; then
2110 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2111 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2114 AC_MSG_CHECKING([for __NR_membarrier])
2115 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2116 #include <linux/unistd.h>
2118 return __NR_membarrier
2120 ac_have_nr_membarrier=yes
2121 AC_MSG_RESULT([yes])
2123 ac_have_nr_membarrier=no
2127 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2129 #----------------------------------------------------------------------------
2130 # Checking for supported compiler flags.
2131 #----------------------------------------------------------------------------
2133 case "${host_cpu}" in
2135 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2136 if test -z "$ARCH"; then
2137 # does this compiler support -march=mips32 (mips32 default) ?
2138 AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2141 CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2143 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2146 FLAG_M32="-mips32 -mabi=32"
2147 AC_MSG_RESULT([yes])
2157 # does this compiler support -march=mips64r2 (mips64r2 default) ?
2158 AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2161 CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2163 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2166 FLAG_M64="-march=mips64r2 -mabi=64"
2167 AC_MSG_RESULT([yes])
2180 # does this compiler support -m32 ?
2181 AC_MSG_CHECKING([if gcc accepts -m32])
2184 CFLAGS="${FLAG_32ON64} -m32 -Werror"
2186 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2189 FLAG_M32="${FLAG_32ON64} -m32"
2190 AC_MSG_RESULT([yes])
2200 # does this compiler support -m64 ?
2201 AC_MSG_CHECKING([if gcc accepts -m64])
2204 CFLAGS="-m64 -Werror"
2206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2210 AC_MSG_RESULT([yes])
2222 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2223 if test -z "$ARCH"; then
2224 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2225 AC_MSG_CHECKING([if gcc accepts -march=octeon])
2228 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2230 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2233 FLAG_OCTEON="-march=octeon"
2234 AC_MSG_RESULT([yes])
2241 AC_SUBST(FLAG_OCTEON)
2244 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2245 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2248 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2250 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2253 FLAG_OCTEON2="-march=octeon2"
2254 AC_MSG_RESULT([yes])
2261 AC_SUBST(FLAG_OCTEON2)
2265 # does this compiler support -mmsa (MIPS MSA ASE) ?
2266 AC_MSG_CHECKING([if gcc accepts -mmsa])
2269 CFLAGS="$CFLAGS -mmsa -Werror"
2271 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2275 AC_MSG_RESULT([yes])
2284 # Are we compiling for the MIPS64 n32 ABI?
2285 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2286 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2287 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2292 FLAG_M64="-march=mips64r2 -mabi=n32"
2293 AC_MSG_RESULT([yes])
2298 # Are we compiling for the MIPS64 n64 ABI?
2299 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2300 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2301 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2306 AC_MSG_RESULT([yes])
2311 # We enter the code block below in the following case:
2312 # Target architecture is set to mips64, the desired abi
2313 # was not specified and the compiler's default abi setting
2314 # is neither n32 nor n64.
2315 # Probe for and set the abi to either n64 or n32, in that order,
2316 # which is required for a mips64 build of valgrind.
2317 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2319 CFLAGS="$CFLAGS -mabi=64 -Werror"
2320 AC_MSG_CHECKING([if gcc is n64 capable])
2321 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2325 AC_MSG_RESULT([yes])
2331 if test "x$VGCONF_ABI" = "x"; then
2333 CFLAGS="$CFLAGS -mabi=n32 -Werror"
2334 AC_MSG_CHECKING([if gcc is n32 capable])
2335 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2339 FLAG_M64="-march=mips64r2 -mabi=n32"
2340 AC_MSG_RESULT([yes])
2348 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2349 [test x$VGCONF_ABI != x])
2350 AC_SUBST(VGCONF_ABI)
2353 # does this compiler support -mmmx ?
2354 AC_MSG_CHECKING([if gcc accepts -mmmx])
2357 CFLAGS="-mmmx -Werror"
2359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2363 AC_MSG_RESULT([yes])
2373 # does this compiler support -msse ?
2374 AC_MSG_CHECKING([if gcc accepts -msse])
2377 CFLAGS="-msse -Werror"
2379 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2383 AC_MSG_RESULT([yes])
2393 # does this compiler support -mpreferred-stack-boundary=2 when
2394 # generating code for a 32-bit target? Note that we only care about
2395 # this when generating code for (32-bit) x86, so if the compiler
2396 # doesn't recognise -m32 it's no big deal. We'll just get code for
2397 # the Memcheck and other helper functions, that is a bit slower than
2398 # it could be, on x86; and no difference at all on any other platform.
2399 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2402 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2404 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2407 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2408 AC_MSG_RESULT([yes])
2410 PREFERRED_STACK_BOUNDARY_2=""
2415 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2418 # does this compiler support -mlong-double-128 ?
2419 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2421 CFLAGS="-mlong-double-128 -Werror"
2422 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2425 ac_compiler_supports_mlong_double_128=yes
2426 AC_MSG_RESULT([yes])
2428 ac_compiler_supports_mlong_double_128=no
2432 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2433 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2434 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2436 # does this toolchain support lto ?
2437 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2439 # If not enable-lto=* arg is provided, default to no, as lto builds are
2440 # a lot slower, and so not appropriate for Valgrind developments.
2441 # --enable-lto=yes should be used by distro packagers.
2442 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2444 [ --enable-lto enables building with link time optimisation],
2445 [vg_cv_lto=$enableval],
2448 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2449 AC_MSG_CHECKING([if toolchain accepts lto])
2451 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2452 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2453 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2454 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2456 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2457 extern void somefun(void);
2461 LTO_CFLAGS=$TEST_LTO_CFLAGS
2462 AC_MSG_RESULT([yes])
2470 AC_SUBST(LTO_CFLAGS)
2472 # if we could not compile with lto args, or lto was disabled,
2473 # then set LTO_AR/LTO_RANLIB to the non lto values
2474 # define in config.h ENABLE_LTO (not needed by the code currently, but
2475 # this guarantees we recompile everything if we re-configure and rebuild
2476 # in a build dir previously build with another value of --enable-lto
2477 if test "x${LTO_CFLAGS}" = "x"; then
2479 LTO_RANLIB=${RANLIB}
2483 AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2486 # Convenience function to check whether GCC supports a particular
2487 # warning option. Takes two arguments,
2488 # first the warning flag name to check (without -W), then the
2489 # substitution name to set with -Wno-warning-flag if the flag exists,
2490 # or the empty string if the compiler doesn't accept the flag. Note
2491 # that checking is done against the warning flag itself, but the
2492 # substitution is then done to cancel the warning flag.
2493 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2494 AC_MSG_CHECKING([if gcc accepts -W$1])
2496 CFLAGS="-W$1 -Werror"
2497 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2498 AC_SUBST([$2], [-Wno-$1])
2499 AC_MSG_RESULT([yes])], [
2501 AC_MSG_RESULT([no])])
2505 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2506 # -W$1 (instead of -Wno-$1).
2507 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2508 AC_MSG_CHECKING([if gcc accepts -W$1])
2510 CFLAGS="-W$1 -Werror"
2511 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2512 AC_SUBST([$2], [-W$1])
2513 AC_MSG_RESULT([yes])], [
2515 AC_MSG_RESULT([no])])
2519 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2520 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2521 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2522 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2523 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2524 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2525 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2526 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2527 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2528 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2530 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2531 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2532 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2533 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2534 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2535 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2536 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2537 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2538 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2539 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2540 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2542 # Does this compiler support -Wformat-security ?
2543 # Special handling is needed, because certain GCC versions require -Wformat
2544 # being present if -Wformat-security is given. Otherwise a warning is issued.
2545 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2546 # And with that the warning will be turned into an error with the result
2547 # that -Wformat-security is believed to be unsupported when in fact it is.
2548 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2550 CFLAGS="-Wformat -Wformat-security -Werror"
2551 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2552 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2553 AC_MSG_RESULT([yes])], [
2554 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2555 AC_MSG_RESULT([no])])
2558 # does this compiler support -Wextra or the older -W ?
2560 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2563 CFLAGS="-Wextra -Werror"
2565 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2568 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2569 AC_MSG_RESULT([-Wextra])
2572 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2575 AC_SUBST([FLAG_W_EXTRA], [-W])
2578 AC_SUBST([FLAG_W_EXTRA], [])
2579 AC_MSG_RESULT([not supported])
2584 # On ARM we do not want to pass -Wcast-align as that produces loads
2585 # of warnings. GCC is just being conservative. See here:
2586 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2587 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2588 AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2590 AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2593 # does this compiler support -faligned-new ?
2594 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2596 safe_CXXFLAGS=$CXXFLAGS
2597 CXXFLAGS="-faligned-new -Werror"
2600 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2603 FLAG_FALIGNED_NEW="-faligned-new"
2604 AC_MSG_RESULT([yes])
2606 FLAG_FALIGNED_NEW=""
2609 CXXFLAGS=$safe_CXXFLAGS
2612 AC_SUBST(FLAG_FALIGNED_NEW)
2614 # does this compiler support -fsized-deallocation ?
2615 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2617 safe_CXXFLAGS=$CXXFLAGS
2618 CXXFLAGS="-fsized-deallocation -Werror"
2621 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2624 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2625 ac_have_sized_deallocation=yes
2626 AC_MSG_RESULT([yes])
2628 FLAG_FSIZED_DEALLOCATION=""
2629 ac_have_sized_deallocation=no
2632 CXXFLAGS=$safe_CXXFLAGS
2635 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2636 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2638 # does this compiler support C++17 aligned new/delete?
2639 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2641 safe_CXXFLAGS=$CXXFLAGS
2642 CXXFLAGS="-std=c++17"
2645 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2649 operator delete(nullptr, std::align_val_t(64U));
2651 ac_have_aligned_cxx_alloc=yes
2652 AC_MSG_RESULT([yes])
2654 ac_have_aligned_cxx_alloc=no
2657 CXXFLAGS=$safe_CXXFLAGS
2660 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2662 # does this compiler support -fno-stack-protector ?
2663 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2666 CFLAGS="-fno-stack-protector -Werror"
2668 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2671 no_stack_protector=yes
2672 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2673 AC_MSG_RESULT([yes])
2675 no_stack_protector=no
2676 FLAG_FNO_STACK_PROTECTOR=""
2681 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2683 # does this compiler support -finline-functions ?
2684 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2687 CFLAGS="-finline-functions -Werror"
2689 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2692 inline_functions=yes
2693 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2694 AC_MSG_RESULT([yes])
2697 FLAG_FINLINE_FUNCTIONS=""
2702 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2704 # Does GCC support disabling Identical Code Folding?
2705 # We want to disabled Identical Code Folding for the
2706 # tools preload shared objects to get better backraces.
2707 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2708 # "The optimization reduces code size and may disturb
2709 # unwind stacks by replacing a function by equivalent
2710 # one with a different name."
2711 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2714 CFLAGS="-fno-ipa-icf -Werror"
2716 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2720 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2721 AC_MSG_RESULT([yes])
2729 AC_SUBST(FLAG_FNO_IPA_ICF)
2732 # Does this compiler support -fsanitize=undefined. This is true for
2733 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2734 # also checks for alignment violations on memory accesses which the valgrind
2735 # code base is sprinkled (if not littered) with. As those alignment issues
2736 # don't pose a problem we want to suppress warnings about them.
2737 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2738 # GCCs do not support that.
2740 # Only checked for if --enable-ubsan was given.
2741 if test "x${vg_cv_ubsan}" = "xyes"; then
2742 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2744 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2745 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2748 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2749 LIB_UBSAN="-static-libubsan"
2750 AC_MSG_RESULT([yes])
2752 CFLAGS="-fsanitize=undefined -Werror"
2753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2756 FLAG_FSANITIZE="-fsanitize=undefined"
2757 LIB_UBSAN="-static-libubsan"
2758 AC_MSG_RESULT([yes])
2766 AC_SUBST(FLAG_FSANITIZE)
2769 # does this compiler support --param inline-unit-growth=... ?
2771 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2774 CFLAGS="--param inline-unit-growth=900 -Werror"
2776 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2779 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2780 ["--param inline-unit-growth=900"])
2781 AC_MSG_RESULT([yes])
2783 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2789 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2791 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2794 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2796 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2800 AC_MSG_RESULT([yes])
2805 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2809 # does this compiler support -g -gz=zlib ?
2811 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2814 CFLAGS="-g -gz=zlib"
2816 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2820 AC_MSG_RESULT([yes])
2825 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2829 # does this compiler support -g -gz=zlib-gnu ?
2831 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2834 CFLAGS="-g -gz=zlib-gnu"
2836 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2839 ac_have_gz_zlib_gnu=yes
2840 AC_MSG_RESULT([yes])
2842 ac_have_gz_zlib_gnu=no
2845 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2849 # does this compiler support nested functions ?
2851 AC_MSG_CHECKING([if gcc accepts nested functions])
2853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2854 int foo() { return 1; }
2857 ac_have_nested_functions=yes
2858 AC_MSG_RESULT([yes])
2860 ac_have_nested_functions=no
2863 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2866 # does this compiler support the 'p' constraint in ASM statements ?
2868 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2870 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2872 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2874 ac_have_asm_constraint_p=yes
2875 AC_MSG_RESULT([yes])
2877 ac_have_asm_constraint_p=no
2880 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2883 # Does this compiler and linker support -pie?
2884 # Some compilers actually do not support -pie and report its usage
2885 # as an error. We need to check if it is safe to use it first.
2887 AC_MSG_CHECKING([if gcc accepts -pie])
2892 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2895 AC_SUBST([FLAG_PIE], ["-pie"])
2896 AC_MSG_RESULT([yes])
2898 AC_SUBST([FLAG_PIE], [""])
2903 AC_MSG_CHECKING([if gcc accepts -ansi])
2908 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2912 AC_MSG_RESULT([yes])
2917 AM_CONDITIONAL([HAVE_ANSI], [test x$ac_have_ansi = xyes])
2922 # Does this compiler support -no-pie?
2923 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2924 # default. However this gets in the way with some tests, we use -no-pie
2927 AC_MSG_CHECKING([if gcc accepts -no-pie])
2930 CFLAGS="-no-pie -Werror"
2932 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2935 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2936 AC_MSG_RESULT([yes])
2938 AC_SUBST([FLAG_NO_PIE], [""])
2944 # We want to use use the -Ttext-segment option to the linker.
2945 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2946 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2947 # semantics are NOT what we want (GNU gold -Ttext is fine).
2949 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2950 # will reside. -Ttext aligns just the .text section start (but not any
2953 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
2954 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
2955 # The --image-base option (since version 6.0?) provides the semantics needed.
2956 # -Ttext-segment generates an error, but -Ttext now more closely
2957 # follows the GNU (bfd) ld's -Ttext.
2959 # So test first for --image-base support, and if that fails then
2960 # for -Ttext-segment which is supported by all bfd ld versions
2961 # and use that if it exists. If it doesn't exist it must be an older
2962 # version of gold and we can fall back to using -Ttext which has the
2966 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
2968 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
2971 [AC_LANG_SOURCE([int _start () { return 0; }])],
2973 linker_using_t_text="no"
2974 AC_SUBST([FLAG_T_TEXT], ["--image-base"])
2975 AC_MSG_RESULT([yes])
2979 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2981 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2984 [AC_LANG_SOURCE([int _start () { return 0; }])],
2986 linker_using_t_text="no"
2987 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2988 AC_MSG_RESULT([yes])
2990 linker_using_t_text="yes"
2991 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2998 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
2999 # have to strip any build-id ELF NOTEs from the statically linked tools.
3000 # Otherwise the build-id NOTE might end up at the default load address.
3001 # (Pedantically if the linker is gold then -Ttext is fine, but newer
3002 # gold versions also support -Ttext-segment. So just assume that unless
3003 # we can use -Ttext-segment we need to strip the build-id NOTEs.
3004 if test "x${linker_using_t_text}" = "xyes"; then
3005 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
3006 # does the linker support -Wl,--build-id=none ? Note, it's
3007 # important that we test indirectly via whichever C compiler
3008 # is selected, rather than testing /usr/bin/ld or whatever
3010 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
3012 CFLAGS="-Wl,--build-id=none -Werror"
3015 [AC_LANG_PROGRAM([ ], [return 0;])],
3017 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
3018 AC_MSG_RESULT([yes])
3020 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3024 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
3025 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3029 # does the ppc assembler support "mtocrf" et al?
3030 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
3032 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3033 __asm__ __volatile__("mtocrf 4,0");
3034 __asm__ __volatile__("mfocrf 0,4");
3036 ac_have_as_ppc_mftocrf=yes
3037 AC_MSG_RESULT([yes])
3039 ac_have_as_ppc_mftocrf=no
3042 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3043 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3047 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3048 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3050 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3051 do { typedef struct {
3055 dbl_pair_t dbl_pair[3];
3056 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3059 ac_have_as_ppc_fpPO=yes
3060 AC_MSG_RESULT([yes])
3062 ac_have_as_ppc_fpPO=no
3065 if test x$ac_have_as_ppc_fpPO = xyes ; then
3066 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3070 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3071 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3073 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3075 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3076 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3078 ac_have_as_amd64_fxsave64=yes
3079 AC_MSG_RESULT([yes])
3081 ac_have_as_amd64_fxsave64=no
3084 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3085 AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3088 # does the x86/amd64 assembler understand SSE3 instructions?
3089 # Note, this doesn't generate a C-level symbol. It generates a
3090 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3091 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3093 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3094 do { long long int x;
3095 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
3099 AC_MSG_RESULT([yes])
3105 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3108 # Ditto for SSSE3 instructions (note extra S)
3109 # Note, this doesn't generate a C-level symbol. It generates a
3110 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3111 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3113 save_CFLAGS="$CFLAGS"
3114 CFLAGS="$CFLAGS -msse -Werror"
3115 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3116 do { long long int x;
3117 __asm__ __volatile__(
3118 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3121 ac_have_as_ssse3=yes
3122 AC_MSG_RESULT([yes])
3127 CFLAGS="$save_CFLAGS"
3129 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3132 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3133 # Note, this doesn't generate a C-level symbol. It generates a
3134 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3135 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3136 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3138 __asm__ __volatile__(
3139 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3142 ac_have_as_pclmulqdq=yes
3143 AC_MSG_RESULT([yes])
3145 ac_have_as_pclmulqdq=no
3149 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3152 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3153 # Note, this doesn't generate a C-level symbol. It generates a
3154 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3155 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3156 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3159 * Carry-less multiplication of xmm1 with xmm2 and store the result in
3160 * xmm3. The immediate is used to determine which quadwords of xmm1 and
3161 * xmm2 should be used.
3163 __asm__ __volatile__(
3164 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3167 ac_have_as_vpclmulqdq=yes
3168 AC_MSG_RESULT([yes])
3170 ac_have_as_vpclmulqdq=no
3174 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3177 # does the x86/amd64 assembler understand FMA4 instructions?
3178 # Note, this doesn't generate a C-level symbol. It generates a
3179 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3180 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3181 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3183 __asm__ __volatile__(
3184 "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3187 ac_have_as_vfmaddpd=yes
3188 AC_MSG_RESULT([yes])
3190 ac_have_as_vfmaddpd=no
3194 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3197 # does the x86/amd64 assembler understand the LZCNT instruction?
3198 # Note, this doesn't generate a C-level symbol. It generates a
3199 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3200 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3202 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3204 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3207 ac_have_as_lzcnt=yes
3208 AC_MSG_RESULT([yes])
3214 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3217 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3218 # Note, this doesn't generate a C-level symbol. It generates a
3219 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3220 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3222 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3224 __asm__ __volatile__("1: loopnel 1b\n");
3227 ac_have_as_loopnel=yes
3228 AC_MSG_RESULT([yes])
3230 ac_have_as_loopnel=no
3234 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3237 # does the x86/amd64 assembler understand ADDR32 ?
3238 # Note, this doesn't generate a C-level symbol. It generates a
3239 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3240 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3242 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3244 asm volatile ("addr32 rep movsb");
3247 ac_have_as_addr32=yes
3248 AC_MSG_RESULT([yes])
3250 ac_have_as_addr32=no
3254 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3257 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3258 # Note, this doesn't generate a C-level symbol. It generates a
3259 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3260 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3262 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3263 do { long long int x;
3264 __asm__ __volatile__(
3265 "crc32q %%r15,%%r15" : : : "r15" );
3266 __asm__ __volatile__(
3267 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
3268 __asm__ __volatile__(
3269 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3272 ac_have_as_sse42=yes
3273 AC_MSG_RESULT([yes])
3279 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3282 # does the x86/amd64 assembler understand AVX instructions?
3283 # Note, this doesn't generate a C-level symbol. It generates a
3284 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3285 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3287 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3288 do { long long int x;
3289 __asm__ __volatile__(
3290 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3291 __asm__ __volatile__(
3292 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3296 AC_MSG_RESULT([yes])
3302 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3305 # does the x86/amd64 assembler understand AVX2 instructions?
3306 # Note, this doesn't generate a C-level symbol. It generates a
3307 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3308 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3310 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3311 do { long long int x;
3312 __asm__ __volatile__(
3313 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3314 __asm__ __volatile__(
3315 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3319 AC_MSG_RESULT([yes])
3325 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3328 # does the x86/amd64 assembler understand TSX instructions and
3329 # the XACQUIRE/XRELEASE prefixes?
3330 # Note, this doesn't generate a C-level symbol. It generates a
3331 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3332 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3334 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3336 __asm__ __volatile__(
3339 " xacquire lock incq 0(%rsp) \n\t"
3340 " xrelease lock incq 0(%rsp) \n"
3345 AC_MSG_RESULT([yes])
3351 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3354 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3355 # Note, this doesn't generate a C-level symbol. It generates a
3356 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3357 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3360 do { unsigned int h, l;
3361 __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3362 __asm__ __volatile__(
3363 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3364 __asm__ __volatile__(
3365 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3369 AC_MSG_RESULT([yes])
3375 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3378 # does the x86/amd64 assembler understand FMA instructions?
3379 # Note, this doesn't generate a C-level symbol. It generates a
3380 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3381 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3383 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3384 do { unsigned int h, l;
3385 __asm__ __volatile__(
3386 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3387 __asm__ __volatile__(
3388 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3389 __asm__ __volatile__(
3390 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3394 AC_MSG_RESULT([yes])
3400 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3403 # does the amd64 assembler understand MPX instructions?
3404 # Note, this doesn't generate a C-level symbol. It generates a
3405 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3406 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3408 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3410 asm ("bndmov %bnd0,(%rsp)");
3411 asm ("bndldx 3(%rbx,%rdx), %bnd2");
3412 asm ("bnd call foo\n"
3419 AC_MSG_RESULT([yes])
3425 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3428 # does the amd64 assembler understand ADX instructions?
3429 # Note, this doesn't generate a C-level symbol. It generates a
3430 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3431 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3433 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3435 asm ("adcxq %r14,%r8");
3439 AC_MSG_RESULT([yes])
3445 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3448 # does the amd64 assembler understand the RDRAND instruction?
3449 # Note, this doesn't generate a C-level symbol. It generates a
3450 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3451 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3453 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3455 asm ("rdrand %r14");
3456 asm ("rdrand %r14d");
3457 asm ("rdrand %r14w");
3460 ac_have_as_rdrand=yes
3461 AC_MSG_RESULT([yes])
3463 ac_have_as_rdrand=no
3467 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3469 # does the amd64 assembler understand the RDSEED instruction?
3470 # Note, this doesn't generate a C-level symbol. It generates a
3471 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3472 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3474 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3476 asm ("rdseed %r14");
3477 asm ("rdseed %r14d");
3478 asm ("rdseed %r14w");
3481 ac_have_as_rdseed=yes
3482 AC_MSG_RESULT([yes])
3484 ac_have_as_rdseed=no
3488 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3490 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3492 # Note, this doesn't generate a C-level symbol. It generates a
3493 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3494 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3496 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3498 asm ("vcvtph2ps %xmm5, %ymm10");
3499 // If we put the dollar sign and zero together, the shell processing
3500 // this configure.ac script substitutes the command name in. Sigh.
3501 asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3505 AC_MSG_RESULT([yes])
3511 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3514 # does the x86/amd64 assembler understand MOVBE?
3515 # Note, this doesn't generate a C-level symbol. It generates a
3516 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3517 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3519 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3520 do { long long int x;
3521 __asm__ __volatile__(
3522 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3525 ac_have_as_movbe=yes
3526 AC_MSG_RESULT([yes])
3532 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3535 # Does the C compiler support the "ifunc" attribute
3536 # Note, this doesn't generate a C-level symbol. It generates a
3537 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3538 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3540 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3541 static void mytest(void) {}
3543 static void (*resolve_test(void))(void)
3545 return (void (*)(void))&mytest;
3548 void test(void) __attribute__((ifunc("resolve_test")));
3556 ac_have_ifunc_attr=yes
3557 AC_MSG_RESULT([yes])
3559 ac_have_ifunc_attr=no
3563 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3565 # Does the C compiler support the armv8 crc feature flag
3566 # Note, this doesn't generate a C-level symbol. It generates a
3567 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3568 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3570 save_CFLAGS="$CFLAGS"
3571 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3572 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3578 ac_have_armv8_crc_feature=yes
3579 AC_MSG_RESULT([yes])
3581 ac_have_armv8_crc_feature=no
3584 CFLAGS="$save_CFLAGS"
3586 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3589 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3590 # Note, this doesn't generate a C-level symbol. It generates a
3591 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3592 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3594 save_CFLAGS="$CFLAGS"
3595 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3596 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3599 __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3603 ac_have_armv81_feature=yes
3604 AC_MSG_RESULT([yes])
3606 ac_have_armv81_feature=no
3609 CFLAGS="$save_CFLAGS"
3611 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3614 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3615 # Note, this doesn't generate a C-level symbol. It generates a
3616 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3617 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3619 save_CFLAGS="$CFLAGS"
3620 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3621 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3624 __asm__ __volatile__("faddp h0, v1.2h");
3628 ac_have_armv82_feature=yes
3629 AC_MSG_RESULT([yes])
3631 ac_have_armv82_feature=no
3634 CFLAGS="$save_CFLAGS"
3636 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3639 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
3640 # when building the tool executables. I think we should get rid of it.
3642 # Check for TLS support in the compiler and linker
3643 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3645 [vg_cv_linktime_tls=yes],
3646 [vg_cv_linktime_tls=no])
3647 # Native compilation: check whether running a program using TLS succeeds.
3648 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3649 # succeeds but running programs using TLS fails.
3650 # Cross-compiling: check whether linking a program using TLS succeeds.
3651 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3652 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
3653 [vg_cv_tls=$enableval],
3654 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3658 [vg_cv_tls=$vg_cv_linktime_tls])])])
3660 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3661 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3665 #----------------------------------------------------------------------------
3666 # Solaris-specific checks.
3667 #----------------------------------------------------------------------------
3669 if test "$VGCONF_OS" = "solaris" ; then
3670 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3672 # Solaris-specific check determining if the Sun Studio Assembler is used to
3673 # build Valgrind. The test checks if the x86/amd64 assembler understands the
3674 # cmovl.l instruction, if yes then it's Sun Assembler.
3676 # C-level symbol: none
3677 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3679 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3680 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3682 __asm__ __volatile__("cmovl.l %edx, %eax");
3684 solaris_have_sun_studio_as=yes
3685 AC_MSG_RESULT([yes])
3687 solaris_have_sun_studio_as=no
3690 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3692 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3693 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3694 # See solaris/vgpreload-solaris.mapfile for details.
3695 # gcc on older Solaris instructs linker to include these symbols,
3696 # gcc on illumos and newer Solaris does not.
3698 # C-level symbol: none
3699 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3701 save_CFLAGS="$CFLAGS"
3702 CFLAGS="$CFLAGS -std=gnu99"
3703 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3704 temp_dir=$( /usr/bin/mktemp -d )
3705 cat <<_ACEOF >${temp_dir}/mylib.c
3707 int myfunc(void) { printf("LaPutyka\n"); }
3709 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3710 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3711 if test "x${xpg_present}" = "x" ; then
3712 solaris_xpg_symbols_present=no
3715 solaris_xpg_symbols_present=yes
3716 AC_MSG_RESULT([yes])
3719 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3720 CFLAGS="$save_CFLAGS"
3723 # Solaris-specific check determining if gcc enables largefile support by
3724 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3725 # variable with gcc flags which disable it.
3727 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3728 save_CFLAGS="$CFLAGS"
3729 CFLAGS="$CFLAGS -m32"
3730 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3731 return _LARGEFILE_SOURCE;
3733 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3734 AC_MSG_RESULT([yes])
3736 SOLARIS_UNDEF_LARGESOURCE=""
3740 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3743 # Solaris-specific check determining if /proc/self/cmdline
3744 # or /proc/<pid>/cmdline is supported.
3746 # C-level symbol: SOLARIS_PROC_CMDLINE
3747 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3749 AC_CHECK_FILE([/proc/self/cmdline],
3751 solaris_proc_cmdline=yes
3752 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3753 [Define to 1 if you have /proc/self/cmdline.])
3755 solaris_proc_cmdline=no
3757 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3760 # Solaris-specific check determining default platform for the Valgrind launcher.
3761 # Used in case the launcher cannot select platform by looking at the client
3762 # image (for example because the executable is a shell script).
3764 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3765 # Automake-level symbol: none
3767 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3768 # Get the ELF class of /bin/sh first.
3769 if ! test -f /bin/sh; then
3770 AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3772 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3773 case "$elf_class" in
3775 default_arch="$VGCONF_ARCH_PRI";
3778 if test "x$VGCONF_ARCH_SEC" != "x"; then
3779 default_arch="$VGCONF_ARCH_SEC"
3781 default_arch="$VGCONF_ARCH_PRI";
3785 AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3788 default_platform="$default_arch-$VGCONF_OS"
3789 AC_MSG_RESULT([$default_platform])
3790 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3791 [Default platform for Valgrind launcher.])
3794 # Solaris-specific check determining if the old syscalls are available.
3796 # C-level symbol: SOLARIS_OLD_SYSCALLS
3797 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3799 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3800 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3801 #include <sys/syscall.h>
3805 solaris_old_syscalls=yes
3806 AC_MSG_RESULT([yes])
3807 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3808 [Define to 1 if you have the old Solaris syscalls.])
3810 solaris_old_syscalls=no
3813 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3816 # Solaris-specific check determining if the new accept() syscall is available.
3819 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3822 # New syscall (available on illumos):
3823 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3824 # int version, int flags);
3826 # If the old syscall is present then the following syscall will fail with
3827 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3828 # available then it will fail with EINVAL (because the flags parameter is
3831 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3832 # Automake-level symbol: none
3834 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3835 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3836 #include <sys/syscall.h>
3840 syscall(SYS_accept, 0, 0, 0, 0, -1);
3841 return !(errno == EINVAL);
3843 AC_MSG_RESULT([yes])
3844 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3845 [Define to 1 if you have the new `accept' syscall.])
3851 # Solaris-specific check determining if the new illumos pipe() syscall is
3855 # longlong_t pipe();
3857 # New syscall (available on illumos):
3858 # int pipe(intptr_t arg, int flags);
3860 # If the old syscall is present then the following call will succeed, if the
3861 # new syscall is available then it will fail with EFAULT (because address 0
3862 # cannot be accessed).
3864 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3865 # Automake-level symbol: none
3867 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3868 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3869 #include <sys/syscall.h>
3873 syscall(SYS_pipe, 0, 0);
3874 return !(errno == EFAULT);
3876 AC_MSG_RESULT([yes])
3877 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3878 [Define to 1 if you have the new `pipe' syscall.])
3884 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3888 # int lwp_kill(id_t lwpid, int sig);
3890 # New syscall (available on Solaris 11):
3891 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3892 # int si_code, timespec_t *timeout);
3894 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3895 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3897 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3898 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3899 #include <sys/syscall.h>
3901 return !SYS_lwp_sigqueue;
3903 solaris_lwp_sigqueue_syscall=yes
3904 AC_MSG_RESULT([yes])
3905 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3906 [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3908 solaris_lwp_sigqueue_syscall=no
3911 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3914 # Solaris-specific check determining if the lwp_sigqueue() syscall
3915 # takes both pid and thread id arguments or just thread id.
3917 # Old syscall (available up to Solaris 11.3):
3918 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3919 # int si_code, timespec_t *timeout);
3921 # New syscall (available since Solaris 11.4):
3922 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3923 # int si_code, timespec_t *timeout);
3925 # If the old syscall is present then the following syscall will fail with
3926 # EINVAL (because signal is out of range); if the new syscall is available
3927 # then it will fail with ESRCH (because it would not find such thread in the
3930 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3931 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3933 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3934 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3935 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3936 #include <sys/syscall.h>
3940 syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3941 return !(errno == ESRCH);
3943 solaris_lwp_sigqueue_syscall_takes_pid=yes
3944 AC_MSG_RESULT([yes])
3945 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3946 [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3948 solaris_lwp_sigqueue_syscall_takes_pid=no
3951 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3952 test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3954 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3958 # Solaris-specific check determining if the new lwp_name() syscall is
3961 # New syscall (available on Solaris 11):
3962 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3964 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3965 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3967 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3968 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3969 #include <sys/syscall.h>
3971 return !SYS_lwp_name;
3973 solaris_lwp_name_syscall=yes
3974 AC_MSG_RESULT([yes])
3975 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3976 [Define to 1 if you have the new `lwp_name' syscall.])
3978 solaris_lwp_name_syscall=no
3981 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3984 # Solaris-specific check determining if the new getrandom() syscall is
3987 # New syscall (available on Solaris 11):
3988 # int getrandom(void *buf, size_t buflen, uint_t flags);
3990 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3991 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3993 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3994 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3995 #include <sys/syscall.h>
3997 return !SYS_getrandom;
3999 solaris_getrandom_syscall=yes
4000 AC_MSG_RESULT([yes])
4001 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
4002 [Define to 1 if you have the new `getrandom' syscall.])
4004 solaris_getrandom_syscall=no
4007 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
4010 # Solaris-specific check determining if the new zone() syscall subcodes
4011 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available. These subcodes
4012 # were added in Solaris 11 but are missing on illumos.
4014 # C-level symbol: SOLARIS_ZONE_DEFUNCT
4015 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
4017 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
4018 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4019 #include <sys/zone.h>
4021 return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
4023 solaris_zone_defunct=yes
4024 AC_MSG_RESULT([yes])
4025 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
4026 [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
4028 solaris_zone_defunct=no
4031 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
4034 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4035 # for auditon(2) subcode of the auditsys() syscall are available.
4036 # These commands are available in Solaris 11 and illumos but were removed
4039 # C-level symbol: SOLARIS_AUDITON_STAT
4040 # Automake-level symbol: SOLARIS_AUDITON_STAT
4042 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4043 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4044 #include <bsm/audit.h>
4046 return !(A_GETSTAT && A_SETSTAT);
4048 solaris_auditon_stat=yes
4049 AC_MSG_RESULT([yes])
4050 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4051 [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4053 solaris_auditon_stat=no
4056 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4059 # Solaris-specific check determining if the new shmsys() syscall subcodes
4060 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4061 # These subcodes were added in Solaris 11 but are missing on illumos.
4063 # C-level symbol: SOLARIS_SHM_NEW
4064 # Automake-level symbol: SOLARIS_SHM_NEW
4066 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4067 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4068 #include <sys/ipc_impl.h>
4069 #include <sys/shm.h>
4070 #include <sys/shm_impl.h>
4072 return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4075 AC_MSG_RESULT([yes])
4076 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4077 [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4082 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4085 # Solaris-specific check determining if prxregset_t is available. Illumos
4086 # currently does not define it on the x86 platform.
4088 # C-level symbol: SOLARIS_PRXREGSET_T
4089 # Automake-level symbol: SOLARIS_PRXREGSET_T
4091 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4092 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4093 #include <sys/procfs_isa.h>
4095 return !sizeof(prxregset_t);
4097 solaris_prxregset_t=yes
4098 AC_MSG_RESULT([yes])
4099 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4100 [Define to 1 if you have the `prxregset_t' type.])
4102 solaris_prxregset_t=no
4105 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4108 # Solaris-specific check determining if the new frealpathat() syscall is
4111 # New syscall (available on Solaris 11.1):
4112 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4114 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4115 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4117 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4118 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4119 #include <sys/syscall.h>
4121 return !SYS_frealpathat;
4123 solaris_frealpathat_syscall=yes
4124 AC_MSG_RESULT([yes])
4125 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4126 [Define to 1 if you have the new `frealpathat' syscall.])
4128 solaris_frealpathat_syscall=no
4131 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4134 # Solaris-specific check determining if the new uuidsys() syscall is
4137 # New syscall (available on newer Solaris):
4138 # int uuidsys(struct uuid *uuid);
4140 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4141 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4143 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4144 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4145 #include <sys/syscall.h>
4147 return !SYS_uuidsys;
4149 solaris_uuidsys_syscall=yes
4150 AC_MSG_RESULT([yes])
4151 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4152 [Define to 1 if you have the new `uuidsys' syscall.])
4154 solaris_uuidsys_syscall=no
4157 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4160 # Solaris-specific check determining if the new labelsys() syscall subcode
4161 # TNDB_GET_TNIP is available. This subcode was added in Solaris 11 but is
4162 # missing on illumos.
4164 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4165 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4167 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4169 #include <sys/tsol/tndb.h>
4171 return !TNDB_GET_TNIP;
4173 solaris_tndb_get_tnip=yes
4174 AC_MSG_RESULT([yes])
4175 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4176 [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4178 solaris_tndb_get_tnip=no
4181 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4184 # Solaris-specific check determining if the new labelsys() syscall opcodes
4185 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4186 # added in Solaris 11 but are missing on illumos.
4188 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4189 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4191 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4192 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4193 #include <sys/tsol/tsyscall.h>
4195 return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4197 solaris_tsol_clearance=yes
4198 AC_MSG_RESULT([yes])
4199 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4200 [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4202 solaris_tsol_clearance=no
4205 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4208 # Solaris-specific check determining if the new pset() syscall subcode
4209 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4210 # is missing on illumos and Solaris 11.3.
4212 # C-level symbol: SOLARIS_PSET_GET_NAME
4213 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4215 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4216 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4217 #include <sys/pset.h>
4219 return !(PSET_GET_NAME);
4221 solaris_pset_get_name=yes
4222 AC_MSG_RESULT([yes])
4223 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4224 [Define to 1 if you have the `PSET_GET_NAME' constants.])
4226 solaris_pset_get_name=no
4229 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4232 # Solaris-specific check determining if the utimesys() syscall is
4233 # available (on illumos and older Solaris).
4235 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4236 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4238 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4239 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4240 #include <sys/syscall.h>
4242 return !SYS_utimesys;
4244 solaris_utimesys_syscall=yes
4245 AC_MSG_RESULT([yes])
4246 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4247 [Define to 1 if you have the `utimesys' syscall.])
4249 solaris_utimesys_syscall=no
4252 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4255 # Solaris-specific check determining if the utimensat() syscall is
4256 # available (on newer Solaris).
4258 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4259 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4261 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4262 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4263 #include <sys/syscall.h>
4265 return !SYS_utimensat;
4267 solaris_utimensat_syscall=yes
4268 AC_MSG_RESULT([yes])
4269 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4270 [Define to 1 if you have the `utimensat' syscall.])
4272 solaris_utimensat_syscall=no
4275 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4278 # Solaris-specific check determining if the spawn() syscall is available
4279 # (on newer Solaris).
4281 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4282 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4284 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4286 #include <sys/syscall.h>
4290 solaris_spawn_syscall=yes
4291 AC_MSG_RESULT([yes])
4292 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4293 [Define to 1 if you have the `spawn' syscall.])
4295 solaris_spawn_syscall=no
4298 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4301 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4302 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4304 # C-level symbol: SOLARIS_MODCTL_MODNVL
4305 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4307 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4308 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4309 #include <sys/modctl.h>
4311 return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4313 solaris_modctl_modnvl=yes
4314 AC_MSG_RESULT([yes])
4315 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4316 [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4318 solaris_modctl_modnvl=no
4321 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4324 # Solaris-specific check determining whether nscd (name switch cache daemon)
4325 # attaches its door at /system/volatile/name_service_door (Solaris)
4326 # or at /var/run/name_service_door (illumos).
4328 # Note that /var/run is a symlink to /system/volatile on Solaris
4329 # but not vice versa on illumos.
4331 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4332 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4334 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4335 if test -e /system/volatile/name_service_door; then
4336 solaris_nscd_door_system_volatile=yes
4337 AC_MSG_RESULT([/system/volatile/name_service_door])
4338 AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4339 [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4341 solaris_nscd_door_system_volatile=no
4342 AC_MSG_RESULT([/var/run/name_service_door])
4344 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4347 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4349 # New fasttrap (available on Solaris 11):
4350 # hrt_t *gethrt(void);
4352 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4353 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4355 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4356 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4357 #include <sys/trap.h>
4361 solaris_gethrt_fasttrap=yes
4362 AC_MSG_RESULT([yes])
4363 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4364 [Define to 1 if you have the new `gethrt' fasttrap.])
4366 solaris_gethrt_fasttrap=no
4369 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4372 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4375 # New fasttrap (available on Solaris 11):
4376 # zonehrtoffset_t *get_zone_offset(void);
4378 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4379 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4381 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4382 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4383 #include <sys/trap.h>
4385 return !T_GETZONEOFFSET;
4387 solaris_getzoneoffset_fasttrap=yes
4388 AC_MSG_RESULT([yes])
4389 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4390 [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4392 solaris_getzoneoffset_fasttrap=no
4395 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4398 # Solaris-specific check determining if the execve() syscall
4399 # takes fourth argument (flags) or not.
4401 # Old syscall (available on illumos):
4402 # int execve(const char *fname, const char **argv, const char **envp);
4404 # New syscall (available on Solaris):
4405 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4407 # If the new syscall is present then it will fail with EINVAL (because flags
4408 # are invalid); if the old syscall is available then it will fail with ENOENT
4409 # (because the file could not be found).
4411 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4412 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4414 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4415 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4416 #include <sys/syscall.h>
4420 syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4421 return !(errno == EINVAL);
4423 solaris_execve_syscall_takes_flags=yes
4424 AC_MSG_RESULT([yes])
4425 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4426 [Define to 1 if you have the new `execve' syscall which accepts flags.])
4428 solaris_execve_syscall_takes_flags=no
4431 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4432 test x$solaris_execve_syscall_takes_flags = xyes)
4435 # Solaris-specific check determining version of the repository cache protocol.
4436 # Every Solaris version uses a different one, ranging from 21 to current 25.
4437 # The check is very ugly, though.
4439 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4440 # Automake-level symbol: none
4442 AC_PATH_PROG(DIS_PATH, dis, false)
4443 if test "x$DIS_PATH" = "xfalse"; then
4444 AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4446 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4447 AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4448 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4451 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4452 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4453 libscf=/usr/lib/64/libscf.so.1
4455 libscf=/usr/lib/libscf.so.1
4457 if ! $DIS_PATH -F scf_handle_bind $libscf | grep -q 0x526570; then
4458 AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4459 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4461 hex=$( $DIS_PATH -F scf_handle_bind $libscf | sed -n 's/.*0x526570\(..\).*/\1/p' )
4462 if test -z "$hex"; then
4463 AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4464 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4466 version=$( printf "%d\n" 0x$hex )
4467 AC_MSG_RESULT([$version])
4468 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4469 [Version number of the repository door cache protocol.])
4472 # Solaris-specific check determining if "sysstat" segment reservation type
4475 # New "sysstat" segment reservation (available on Solaris 11.4):
4476 # - program header type: PT_SUNW_SYSSTAT
4477 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4479 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4480 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4482 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4483 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4484 #include <sys/auxv.h>
4486 return !AT_SUN_SYSSTAT_ADDR;
4488 solaris_reserve_sysstat_addr=yes
4489 AC_MSG_RESULT([yes])
4490 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4491 [Define to 1 if you have the new `sysstat' segment reservation.])
4493 solaris_reserve_sysstat_addr=no
4496 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4499 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4502 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4503 # - program header type: PT_SUNW_SYSSTAT_ZONE
4504 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4506 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4507 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4509 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4510 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4511 #include <sys/auxv.h>
4513 return !AT_SUN_SYSSTAT_ZONE_ADDR;
4515 solaris_reserve_sysstat_zone_addr=yes
4516 AC_MSG_RESULT([yes])
4517 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4518 [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4520 solaris_reserve_sysstat_zone_addr=no
4523 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4526 # Solaris-specific check determining if the system_stats() syscall is available
4527 # (on newer Solaris).
4529 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4530 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4532 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4533 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4534 #include <sys/syscall.h>
4536 return !SYS_system_stats;
4538 solaris_system_stats_syscall=yes
4539 AC_MSG_RESULT([yes])
4540 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4541 [Define to 1 if you have the `system_stats' syscall.])
4543 solaris_system_stats_syscall=no
4546 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4549 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4550 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4552 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4553 # Automake-level symbol: none
4555 AC_CHECK_TYPE([struct _fpchip_state],
4556 [solaris_fpchip_state_takes_underscore=yes],
4557 [solaris_fpchip_state_takes_underscore=no],
4558 [[#include <sys/regset.h>]])
4559 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4560 AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4561 [Define to 1 if fpregset_t defines struct _fpchip_state])
4565 # Solaris-specific check determining if schedctl page shared between kernel
4566 # and userspace program is executable (illumos, older Solaris) or not (newer
4569 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4570 # Automake-level symbol: none
4572 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4573 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4577 #include <schedctl.h>
4581 schedctl_t *scp = schedctl_init();
4585 int fd = open("/proc/self/map", O_RDONLY);
4590 while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4591 if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4592 fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4593 (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4594 return (map.pr_mflags & MA_EXEC);
4600 solaris_schedctl_page_exec=no
4603 solaris_schedctl_page_exec=yes
4604 AC_MSG_RESULT([yes])
4605 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4606 [Define to 1 if you have the schedctl page executable.])
4610 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4611 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4612 # an initial thread pointer for libc (newer Solaris).
4614 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4615 # Automake-level symbol: none
4617 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4618 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4619 #include <sys/fasttrap_isa.h>
4621 return !FT_SCRATCHSIZE;
4623 solaris_pt_sunwdtrace_thrp=yes
4624 AC_MSG_RESULT([yes])
4625 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4626 [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4628 solaris_pt_sunwdtrace_thrp=no
4633 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4634 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4635 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4636 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4637 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4638 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4639 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4640 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4641 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4642 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4643 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4644 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4645 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4646 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4647 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4648 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4649 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4650 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4651 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4652 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4653 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4654 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4655 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4656 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4657 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4658 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4659 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4660 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4661 fi # test "$VGCONF_OS" = "solaris"
4663 #----------------------------------------------------------------------------
4664 # FreeBSD-specific checks.
4665 #----------------------------------------------------------------------------
4667 # Rather than having a large number of feature test as above with Solaris
4668 # these tests are per-version. This may not be entirely relialable for
4669 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4670 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4672 if test "$VGCONF_OS" = "freebsd" ; then
4674 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4678 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4680 fi # test "$VGCONF_OS" = "freebsd"
4683 #----------------------------------------------------------------------------
4684 # Checks for C header files.
4685 #----------------------------------------------------------------------------
4687 AC_CHECK_HEADERS([ \
4705 # Verify whether the <linux/futex.h> header is usable.
4706 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4708 save_CFLAGS="$CFLAGS"
4709 CFLAGS="$CFLAGS -D__user="
4710 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4711 #include <linux/futex.h>
4715 ac_have_usable_linux_futex_h=yes
4716 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4717 [Define to 1 if you have a usable <linux/futex.h> header file.])
4718 AC_MSG_RESULT([yes])
4720 ac_have_usable_linux_futex_h=no
4723 CFLAGS="$save_CFLAGS"
4726 #----------------------------------------------------------------------------
4727 # Checks for typedefs, structures, and compiler characteristics.
4728 #----------------------------------------------------------------------------
4732 AC_CHECK_HEADERS_ONCE([sys/time.h])
4734 AC_CHECK_TYPE([struct statx], [
4735 AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4736 [Define to 1 if <sys/stat.h> declares struct statx.])
4739 #include <sys/stat.h>
4743 #----------------------------------------------------------------------------
4744 # Checks for library functions.
4745 #----------------------------------------------------------------------------
4749 AC_CHECK_LIB([pthread], [pthread_create])
4750 AC_CHECK_LIB([rt], [clock_gettime])
4769 pthread_barrier_init \
4770 pthread_condattr_setclock \
4771 pthread_mutex_timedlock \
4772 pthread_rwlock_timedrdlock \
4773 pthread_rwlock_timedwrlock \
4774 pthread_setname_np \
4800 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4801 # libraries with any shared object and/or executable. This is NOT what we
4802 # want for e.g. vgpreload_core-x86-linux.so
4805 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4806 [test x$ac_cv_func_pthread_barrier_init = xyes])
4807 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4808 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4809 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4810 [test x$ac_cv_func_pthread_spin_lock = xyes])
4811 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4812 [test x$ac_cv_func_pthread_setname_np = xyes])
4813 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4814 [test x$ac_cv_func_copy_file_range = xyes])
4815 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4816 [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4817 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4818 [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4819 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4820 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4821 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4822 [test x$ac_cv_func_memfd_create = xyes])
4824 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4825 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4826 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4827 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4828 [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4831 #----------------------------------------------------------------------------
4833 #----------------------------------------------------------------------------
4834 # Do we have a useable MPI setup on the primary and/or secondary targets?
4835 # On Linux, by default, assumes mpicc and -m32/-m64
4836 # Note: this is a kludge in that it assumes the specified mpicc
4837 # understands -m32/-m64 regardless of what is specified using
4839 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4840 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4843 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4844 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4845 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4846 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4847 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4848 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4849 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4850 mflag_primary=$FLAG_M32
4851 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4852 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4853 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4854 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4855 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4856 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4857 mflag_primary=$FLAG_M64
4858 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4859 mflag_primary="$FLAG_M32 -arch i386"
4860 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4861 mflag_primary="$FLAG_M64 -arch x86_64"
4865 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4866 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4867 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4868 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4869 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4870 mflag_secondary=$FLAG_M32
4871 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4872 mflag_secondary="$FLAG_M32 -arch i386"
4877 [ --with-mpicc= Specify name of MPI2-ised C compiler],
4882 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4883 ## use these values in the check for a functioning mpicc.
4885 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4886 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4887 AM_COND_IF([VGCONF_OS_IS_LINUX],
4888 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4889 LDFLAGS_MPI="-fpic -shared"])
4890 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
4891 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4892 LDFLAGS_MPI="-fpic -shared"])
4893 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4894 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4895 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4896 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4897 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4898 LDFLAGS_MPI="-fpic -shared"])
4900 AC_SUBST([CFLAGS_MPI])
4901 AC_SUBST([LDFLAGS_MPI])
4904 ## See if MPI_CC works for the primary target
4906 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4908 saved_CFLAGS=$CFLAGS
4910 CFLAGS="$CFLAGS_MPI $mflag_primary"
4911 saved_LDFLAGS="$LDFLAGS"
4912 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4913 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4917 int ni, na, nd, comb;
4918 int r = MPI_Init(NULL,NULL);
4919 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4920 r |= MPI_Finalize();
4923 ac_have_mpi2_pri=yes
4924 AC_MSG_RESULT([yes, $MPI_CC])
4930 CFLAGS=$saved_CFLAGS
4931 LDFLAGS="$saved_LDFLAGS"
4932 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4934 ## See if MPI_CC works for the secondary target. Complication: what if
4935 ## there is no secondary target? We need this to then fail.
4936 ## Kludge this by making MPI_CC something which will surely fail in
4939 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4941 saved_CFLAGS=$CFLAGS
4942 saved_LDFLAGS="$LDFLAGS"
4943 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4944 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4945 CC="$MPI_CC this will surely fail"
4949 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4950 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4954 int ni, na, nd, comb;
4955 int r = MPI_Init(NULL,NULL);
4956 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4957 r |= MPI_Finalize();
4960 ac_have_mpi2_sec=yes
4961 AC_MSG_RESULT([yes, $MPI_CC])
4967 CFLAGS=$saved_CFLAGS
4968 LDFLAGS="$saved_LDFLAGS"
4969 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4972 #----------------------------------------------------------------------------
4973 # Other library checks
4974 #----------------------------------------------------------------------------
4975 # There now follow some tests for Boost, and OpenMP. These
4976 # tests are present because Drd has some regression tests that use
4977 # these packages. All regression test programs all compiled only
4978 # for the primary target. And so it is important that the configure
4979 # checks that follow, use the correct -m32 or -m64 flag for the
4980 # primary target (called $mflag_primary). Otherwise, we can end up
4981 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4982 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4983 # only build (meaning, the primary target is x86-linux), the build
4984 # of the regtest programs that use Boost fails, because they are
4985 # build as 32-bit (IN THIS EXAMPLE).
4987 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4988 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4991 # Check whether the boost library 1.35 or later has been installed.
4992 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4994 AC_MSG_CHECKING([for boost])
4997 safe_CXXFLAGS=$CXXFLAGS
4998 CXXFLAGS="$mflag_primary"
5000 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
5002 AC_LINK_IFELSE([AC_LANG_SOURCE([
5003 #include <boost/thread.hpp>
5004 static void thread_func(void)
5006 int main(int argc, char** argv)
5008 boost::thread t(thread_func);
5013 ac_have_boost_1_35=yes
5014 AC_SUBST([BOOST_CFLAGS], [])
5015 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
5016 AC_MSG_RESULT([yes])
5018 ac_have_boost_1_35=no
5023 CXXFLAGS=$safe_CXXFLAGS
5026 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
5029 # does this compiler support -fopenmp, does it have the include file
5030 # <omp.h> and does it have libgomp ?
5032 AC_MSG_CHECKING([for OpenMP])
5035 CFLAGS="-fopenmp $mflag_primary -Werror"
5037 AC_LINK_IFELSE([AC_LANG_SOURCE([
5039 int main(int argc, char** argv)
5047 AC_MSG_RESULT([yes])
5054 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5057 # Check for __builtin_popcount
5058 AC_MSG_CHECKING([for __builtin_popcount()])
5059 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5061 __builtin_popcount(2);
5064 AC_MSG_RESULT([yes])
5065 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5066 [Define to 1 if compiler provides __builtin_popcount().])
5071 # Check for __builtin_clz
5072 AC_MSG_CHECKING([for __builtin_clz()])
5073 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5078 AC_MSG_RESULT([yes])
5079 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5080 [Define to 1 if compiler provides __builtin_clz().])
5085 # Check for __builtin_ctz
5086 AC_MSG_CHECKING([for __builtin_ctz()])
5087 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5092 AC_MSG_RESULT([yes])
5093 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5094 [Define to 1 if compiler provides __builtin_ctz().])
5099 # does this compiler have built-in functions for atomic memory access for the
5101 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5104 CFLAGS="$mflag_primary"
5106 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5108 return (__sync_bool_compare_and_swap(&variable, 1, 2)
5109 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5111 ac_have_builtin_atomic_primary=yes
5112 AC_MSG_RESULT([yes])
5113 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])
5115 ac_have_builtin_atomic_primary=no
5121 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5122 [test x$ac_have_builtin_atomic_primary = xyes])
5125 # does this compiler have built-in functions for atomic memory access for the
5126 # secondary target ?
5128 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5130 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5133 CFLAGS="$mflag_secondary"
5135 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5137 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5139 ac_have_builtin_atomic_secondary=yes
5140 AC_MSG_RESULT([yes])
5142 ac_have_builtin_atomic_secondary=no
5150 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5151 [test x$ac_have_builtin_atomic_secondary = xyes])
5153 # does this compiler have built-in functions for atomic memory access on
5154 # 64-bit integers for all targets ?
5156 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5158 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5161 uint64_t variable = 1;
5162 return __sync_add_and_fetch(&variable, 1)
5164 ac_have_builtin_atomic64_primary=yes
5166 ac_have_builtin_atomic64_primary=no
5169 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5172 CFLAGS="$mflag_secondary"
5174 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5177 uint64_t variable = 1;
5178 return __sync_add_and_fetch(&variable, 1)
5180 ac_have_builtin_atomic64_secondary=yes
5182 ac_have_builtin_atomic64_secondary=no
5189 if test x$ac_have_builtin_atomic64_primary = xyes && \
5190 test x$VGCONF_PLATFORM_SEC_CAPS = x \
5191 -o x$ac_have_builtin_atomic64_secondary = xyes; then
5192 AC_MSG_RESULT([yes])
5193 ac_have_builtin_atomic64=yes
5196 ac_have_builtin_atomic64=no
5199 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5200 [test x$ac_have_builtin_atomic64 = xyes])
5203 # does g++ have built-in functions for atomic memory access ?
5204 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5206 safe_CXXFLAGS=$CXXFLAGS
5207 CXXFLAGS="$mflag_primary"
5210 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5212 return (__sync_bool_compare_and_swap(&variable, 1, 2)
5213 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5215 ac_have_builtin_atomic_cxx=yes
5216 AC_MSG_RESULT([yes])
5217 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5219 ac_have_builtin_atomic_cxx=no
5224 CXXFLAGS=$safe_CXXFLAGS
5226 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5229 if test x$ac_have_usable_linux_futex_h = xyes \
5230 -a x$ac_have_builtin_atomic_primary = xyes; then
5231 ac_enable_linux_ticket_lock_primary=yes
5233 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5234 [test x$ac_enable_linux_ticket_lock_primary = xyes])
5236 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5237 -a x$ac_have_usable_linux_futex_h = xyes \
5238 -a x$ac_have_builtin_atomic_secondary = xyes; then
5239 ac_enable_linux_ticket_lock_secondary=yes
5241 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5242 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5245 # does libstdc++ support annotating shared pointers ?
5246 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5248 safe_CXXFLAGS=$CXXFLAGS
5249 CXXFLAGS="-std=c++0x"
5252 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5255 std::shared_ptr<int> p
5257 ac_have_shared_ptr=yes
5259 ac_have_shared_ptr=no
5261 if test x$ac_have_shared_ptr = xyes; then
5262 # If compilation of the program below fails because of a syntax error
5263 # triggered by substituting one of the annotation macros then that
5264 # means that libstdc++ supports these macros.
5265 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5266 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5267 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5270 std::shared_ptr<int> p
5272 ac_have_shared_pointer_annotation=no
5275 ac_have_shared_pointer_annotation=yes
5276 AC_MSG_RESULT([yes])
5277 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5278 [Define to 1 if libstd++ supports annotating shared pointers])
5281 ac_have_shared_pointer_annotation=no
5286 CXXFLAGS=$safe_CXXFLAGS
5288 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5289 [test x$ac_have_shared_pointer_annotation = xyes])
5292 #----------------------------------------------------------------------------
5293 # Ok. We're done checking.
5294 #----------------------------------------------------------------------------
5296 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5299 VEX/Makefile:Makefile.vex.in
5303 glibc-2.X-helgrind.supp
5307 docs/xml/vg-entities.xml
5312 gdbserver_tests/Makefile
5313 gdbserver_tests/solaris/Makefile
5319 memcheck/tests/Makefile
5320 memcheck/tests/common/Makefile
5321 memcheck/tests/amd64/Makefile
5322 memcheck/tests/x86/Makefile
5323 memcheck/tests/linux/Makefile
5324 memcheck/tests/linux/debuginfod-check.vgtest
5325 memcheck/tests/darwin/Makefile
5326 memcheck/tests/solaris/Makefile
5327 memcheck/tests/freebsd/Makefile
5328 memcheck/tests/amd64-linux/Makefile
5329 memcheck/tests/arm64-linux/Makefile
5330 memcheck/tests/x86-linux/Makefile
5331 memcheck/tests/amd64-solaris/Makefile
5332 memcheck/tests/x86-solaris/Makefile
5333 memcheck/tests/amd64-freebsd/Makefile
5334 memcheck/tests/x86-freebsd/Makefile
5335 memcheck/tests/ppc32/Makefile
5336 memcheck/tests/ppc64/Makefile
5337 memcheck/tests/s390x/Makefile
5338 memcheck/tests/mips32/Makefile
5339 memcheck/tests/mips64/Makefile
5340 memcheck/tests/vbit-test/Makefile
5342 cachegrind/tests/Makefile
5343 cachegrind/tests/x86/Makefile
5344 cachegrind/cg_annotate
5347 callgrind/callgrind_annotate
5348 callgrind/callgrind_control
5349 callgrind/tests/Makefile
5351 helgrind/tests/Makefile
5353 drd/scripts/download-and-build-splash2
5356 massif/tests/Makefile
5361 lackey/tests/Makefile
5364 none/tests/scripts/Makefile
5365 none/tests/amd64/Makefile
5366 none/tests/ppc32/Makefile
5367 none/tests/ppc64/Makefile
5368 none/tests/x86/Makefile
5369 none/tests/arm/Makefile
5370 none/tests/arm64/Makefile
5371 none/tests/s390x/Makefile
5372 none/tests/mips32/Makefile
5373 none/tests/mips64/Makefile
5374 none/tests/nanomips/Makefile
5375 none/tests/linux/Makefile
5376 none/tests/darwin/Makefile
5377 none/tests/solaris/Makefile
5378 none/tests/freebsd/Makefile
5379 none/tests/amd64-linux/Makefile
5380 none/tests/x86-linux/Makefile
5381 none/tests/amd64-darwin/Makefile
5382 none/tests/x86-darwin/Makefile
5383 none/tests/amd64-solaris/Makefile
5384 none/tests/x86-solaris/Makefile
5385 none/tests/x86-freebsd/Makefile
5387 exp-bbv/tests/Makefile
5388 exp-bbv/tests/x86/Makefile
5389 exp-bbv/tests/x86-linux/Makefile
5390 exp-bbv/tests/amd64-linux/Makefile
5391 exp-bbv/tests/ppc32-linux/Makefile
5392 exp-bbv/tests/arm-linux/Makefile
5396 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5397 [chmod +x coregrind/link_tool_exe_linux])
5398 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5399 [chmod +x coregrind/link_tool_exe_freebsd])
5400 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5401 [chmod +x coregrind/link_tool_exe_darwin])
5402 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5403 [chmod +x coregrind/link_tool_exe_solaris])
5404 AC_CONFIG_FILES([tests/filter_stderr_basic],
5405 [chmod +x tests/filter_stderr_basic])
5406 AC_CONFIG_FILES([tests/filter_discards],
5407 [chmod +x tests/filter_discards])
5408 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5409 [chmod +x memcheck/tests/filter_stderr])
5410 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5411 [chmod +x memcheck/tests/filter_dw4])
5412 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5413 [chmod +x memcheck/tests/filter_overlaperror])
5414 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5415 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5416 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5417 [chmod +x gdbserver_tests/filter_gdb])
5418 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5419 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5420 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5421 [chmod +x gdbserver_tests/filter_stderr])
5422 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5423 [chmod +x gdbserver_tests/filter_vgdb])
5424 AC_CONFIG_FILES([drd/tests/filter_stderr],
5425 [chmod +x drd/tests/filter_stderr])
5426 AC_CONFIG_FILES([drd/tests/filter_error_count],
5427 [chmod +x drd/tests/filter_error_count])
5428 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5429 [chmod +x drd/tests/filter_error_summary])
5430 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5431 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5432 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5433 [chmod +x drd/tests/filter_thread_no])
5434 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5435 [chmod +x drd/tests/filter_xml_and_thread_no])
5436 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5437 [chmod +x helgrind/tests/filter_stderr])
5443 Maximum build arch: ${ARCH_MAX}
5444 Primary build arch: ${VGCONF_ARCH_PRI}
5445 Secondary build arch: ${VGCONF_ARCH_SEC}
5446 Build OS: ${VGCONF_OS}
5447 Link Time Optimisation: ${vg_cv_lto}
5448 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5449 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5450 Platform variant: ${VGCONF_PLATVARIANT}
5451 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5452 Default supp files: ${DEFAULT_SUPP}