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 #----------------------------------------------------------------------------
53 m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
54 # Make sure we can compile in C99 mode.
55 if test "$ac_cv_prog_cc_c99" = "no"; then
56 AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
60 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
61 # autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
62 # base (eg. most likely as Darwin-specific tests) we'll need one of the
64 # - put AC_PROG_OBJC in a Darwin-specific part of this file
65 # - Use AC_PROG_OBJC here and up the minimum autoconf version
66 # - Use the following, which is apparently equivalent:
67 # m4_ifdef([AC_PROG_OBJC],
69 # [AC_CHECK_TOOL([OBJC], [gcc])
71 # AC_SUBST([OBJCFLAGS])
74 # Set LTO_RANLIB variable to an lto enabled ranlib
75 if test "x$LTO_RANLIB" = "x"; then
76 AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
78 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
80 # provide a very basic definition for AC_PROG_SED if it's not provided by
81 # autoconf (as e.g. in autoconf 2.59).
82 m4_ifndef([AC_PROG_SED],
83 [AC_DEFUN([AC_PROG_SED],
85 AC_CHECK_PROGS([SED],[gsed sed])])])
88 # If no AR variable was specified, look up the name of the archiver. Otherwise
89 # do not touch the AR variable.
90 if test "x$AR" = "x"; then
91 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
93 AC_ARG_VAR([AR],[Archiver command])
95 # same for LTO_AR variable for lto enabled archiver
96 if test "x$LTO_AR" = "x"; then
97 AC_PATH_PROGS([LTO_AR], [gcc-ar])
99 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
102 # Check for the compiler support
103 if test "${GCC}" != "yes" ; then
104 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
107 # figure out where perl lives
108 AC_PATH_PROG(PERL, perl)
110 # figure out where gdb lives
111 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
112 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
114 # some older automake's don't have it so try something on our own
115 ifdef([AM_PROG_AS],[AM_PROG_AS],
125 # Check if 'diff' supports -u (universal diffs) and use it if possible.
127 AC_MSG_CHECKING([for diff -u])
130 # Comparing two identical files results in 0.
131 tmpfile="tmp-xxx-yyy-zzz"
133 if diff -u $tmpfile $tmpfile ; then
142 # We don't want gcc < 3.0
143 AC_MSG_CHECKING([for a supported version of gcc])
145 # Obtain the compiler version.
147 # A few examples of how the ${CC} --version output looks like:
149 # ######## gcc variants ########
150 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
151 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
152 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
153 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
154 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
155 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
156 # 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)
158 # ######## clang variants ########
159 # Clang: clang version 2.9 (tags/RELEASE_29/final)
160 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
161 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
163 # ######## Apple LLVM variants ########
164 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
165 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
168 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
171 gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
172 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
175 # Don't use -dumpversion with clang: it will always produce "4.2.1".
176 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
177 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ;
180 gcc_version=`${CC} -dumpversion 2>/dev/null`
183 gcc_version=`${CC} -dumpversion 2>/dev/null`
184 if test "x$gcc_version" = x; then
185 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
189 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
190 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
192 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
193 # statements have to be quoted.
194 case "${is_clang}-${gcc_version}" in
195 applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
196 AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
198 icc-1[[3-9]].*|icc-202[[0-9]].*)
199 AC_MSG_RESULT([ok (ICC version ${gcc_version})])
201 notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
202 AC_MSG_RESULT([ok (${gcc_version})])
204 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
205 AC_MSG_RESULT([ok (clang-${gcc_version})])
208 AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
209 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
213 #----------------------------------------------------------------------------
214 # Arch/OS/platform tests.
215 #----------------------------------------------------------------------------
216 # We create a number of arch/OS/platform-related variables. We prefix them
217 # all with "VGCONF_" which indicates that they are defined at
218 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
219 # variables used when compiling C files.
223 AC_MSG_CHECKING([for a supported CPU])
225 # ARCH_MAX reflects the most that this CPU can do: for example if it
226 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
227 # Ditto for amd64. It is used for more configuration below, but is not used
230 # Power PC returns powerpc for Big Endian. This was not changed when Little
231 # Endian support was added to the 64-bit architecture. The 64-bit Little
232 # Endian systems explicitly state le in the host_cpu. For clarity in the
233 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
234 # the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
235 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
236 # Endianness. The name PPC64 or ppc64 to 64-bit systems of either Endianness.
237 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
238 # Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
241 case "${host_cpu}" in
243 AC_MSG_RESULT([ok (${host_cpu})])
248 AC_MSG_RESULT([ok (${host_cpu})])
253 # this only referrs to 64-bit Big Endian
254 AC_MSG_RESULT([ok (${host_cpu})])
259 # this only referrs to 64-bit Little Endian
260 AC_MSG_RESULT([ok (${host_cpu})])
265 # On Linux this means only a 32-bit capable CPU.
266 AC_MSG_RESULT([ok (${host_cpu})])
271 AC_MSG_RESULT([ok (${host_cpu})])
276 AC_MSG_RESULT([ok (${host_cpu})])
281 AC_MSG_RESULT([ok (${host_cpu})])
286 AC_MSG_RESULT([ok (${host_cpu})])
291 AC_MSG_RESULT([ok (${host_cpu})])
296 AC_MSG_RESULT([ok (${host_cpu})])
301 AC_MSG_RESULT([ok (${host_cpu})])
306 AC_MSG_RESULT([ok (${host_cpu})])
310 AC_MSG_RESULT([ok (${host_cpu})])
315 AC_MSG_RESULT([no (${host_cpu})])
316 AC_MSG_ERROR([Unsupported host architecture. Sorry])
320 #----------------------------------------------------------------------------
322 # Sometimes it's convenient to subvert the bi-arch build system and
323 # just have a single build even though the underlying platform is
324 # capable of both. Hence handle --enable-only64bit and
325 # --enable-only32bit. Complain if both are issued :-)
326 # [Actually, if either of these options are used, I think both get built,
327 # but only one gets installed. So if you use an in-place build, both can be
330 # Check if a 64-bit only build has been requested
331 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
332 [AC_ARG_ENABLE(only64bit,
333 [ --enable-only64bit do a 64-bit only build],
334 [vg_cv_only64bit=$enableval],
335 [vg_cv_only64bit=no])])
337 # Check if a 32-bit only build has been requested
338 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
339 [AC_ARG_ENABLE(only32bit,
340 [ --enable-only32bit do a 32-bit only build],
341 [vg_cv_only32bit=$enableval],
342 [vg_cv_only32bit=no])])
345 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
347 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
350 #----------------------------------------------------------------------------
352 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
353 # compilation of many C files via -VGO_$(VGCONF_OS) and
354 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
355 AC_MSG_CHECKING([for a supported OS])
362 AC_MSG_RESULT([ok (${host_os})])
365 # Ok, this is linux. Check the kernel version
366 AC_MSG_CHECKING([for the kernel version])
371 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*)
372 AC_MSG_RESULT([unsupported (${kernel})])
373 AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
377 AC_MSG_RESULT([2.6 or later (${kernel})])
384 AC_MSG_RESULT([ok (${host_os})])
386 AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
388 AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
390 AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
392 AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
394 AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
396 AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1+])
398 AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
401 AC_MSG_CHECKING([for the kernel version])
406 AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
407 AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
408 freebsd_vers=$freebsd_10
411 AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
412 AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
413 freebsd_vers=$freebsd_11
418 AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
419 AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
420 freebsd_vers=$freebsd_12
423 AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
424 AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
425 freebsd_vers=$freebsd_12_2
432 AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
433 AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
434 freebsd_vers=$freebsd_13_0
437 AC_MSG_RESULT([FreeBSD 13.1+ (${kernel})])
438 AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
439 freebsd_vers=$freebsd_13_1
444 AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
445 AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
446 freebsd_vers=$freebsd_14
449 AC_MSG_RESULT([unsupported (${kernel})])
450 AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x])
454 DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
458 AC_MSG_RESULT([ok (${host_os})])
460 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
461 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
462 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
463 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
464 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
465 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
466 AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
467 AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
468 AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
470 AC_MSG_CHECKING([for the kernel version])
473 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
474 # has only one relevant version, the OS version. The `uname` check
475 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
476 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
477 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
478 # and we don't know of an macros similar to __GLIBC__ to get that info.
480 # XXX: `uname -r` won't do the right thing for cross-compiles, but
481 # that's not a problem yet.
483 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
484 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
485 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
486 # time support for 10.5 (the 9.* pattern just below), I'll leave it
487 # in for now, just in case anybody wants to give it a try. But I'm
488 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
491 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
492 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
493 DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
494 DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
497 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
498 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
499 DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
500 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
503 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
504 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
505 DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
506 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
509 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
510 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
511 DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
512 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
515 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
516 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
517 DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
518 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
521 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
522 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
523 DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
524 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
527 AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
528 AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
529 DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
530 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
533 AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
534 AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
535 DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
536 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
539 AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
540 AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
541 DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
542 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
545 AC_MSG_RESULT([unsupported (${kernel})])
546 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)])
552 AC_MSG_RESULT([ok (${host_os})])
555 uname_v=$( uname -v )
558 DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
561 DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
567 AC_MSG_RESULT([ok (${host_os})])
569 DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
573 AC_MSG_RESULT([no (${host_os})])
574 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
578 #----------------------------------------------------------------------------
580 # If we are building on a 64 bit platform test to see if the system
581 # supports building 32 bit programs and disable 32 bit support if it
582 # does not support building 32 bit programs
584 case "$ARCH_MAX-$VGCONF_OS" in
585 amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
586 AC_MSG_CHECKING([for 32 bit build support])
589 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
594 vg_cv_only64bit="yes"
597 CFLAGS=$safe_CFLAGS;;
599 AC_MSG_CHECKING([for 32 bit build support])
601 CFLAGS="$CFLAGS -mips32 -mabi=32"
602 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
603 #include <sys/prctl.h>
607 vg_cv_only64bit="yes"
610 CFLAGS=$safe_CFLAGS;;
613 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
615 [--enable-only32bit was specified but system does not support 32 bit builds])
618 #----------------------------------------------------------------------------
620 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
621 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
622 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
623 # above) will be "amd64" since that reflects the most that this cpu can do,
624 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
625 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
626 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
627 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
628 AC_SUBST(VGCONF_ARCH_PRI)
630 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
631 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
632 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
633 # It is empty if there is no secondary target.
634 AC_SUBST(VGCONF_ARCH_SEC)
636 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
637 # The entire system, including regression and performance tests, will be
638 # built for this target. The "_CAPS" indicates that the name is in capital
639 # letters, and it also uses '_' rather than '-' as a separator, because it's
640 # used to create various Makefile variables, which are all in caps by
641 # convention and cannot contain '-' characters. This is in contrast to
642 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
643 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
645 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
646 # Valgrind and tools will also be built for this target, but not the
647 # regression or performance tests.
649 # By default, the primary arch is the same as the "max" arch, as commented
650 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
651 # the big case statement just below here, in the case where we're building
652 # on a 64 bit machine but have been requested only to do a 32 bit build.
653 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
655 AC_MSG_CHECKING([for a supported CPU/OS combination])
657 # NB. The load address for a given platform may be specified in more
658 # than one place, in some cases, depending on whether we're doing a biarch,
659 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
660 # Be careful to give consistent values in all subcases. Also, all four
661 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
662 # even if it is to "0xUNSET".
664 case "$ARCH_MAX-$VGCONF_OS" in
666 VGCONF_ARCH_PRI="x86"
668 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
669 VGCONF_PLATFORM_SEC_CAPS=""
670 valt_load_address_pri_norml="0x58000000"
671 valt_load_address_pri_inner="0x38000000"
672 valt_load_address_sec_norml="0xUNSET"
673 valt_load_address_sec_inner="0xUNSET"
674 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
677 valt_load_address_sec_norml="0xUNSET"
678 valt_load_address_sec_inner="0xUNSET"
679 if test x$vg_cv_only64bit = xyes; then
680 VGCONF_ARCH_PRI="amd64"
682 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
683 VGCONF_PLATFORM_SEC_CAPS=""
684 valt_load_address_pri_norml="0x58000000"
685 valt_load_address_pri_inner="0x38000000"
686 elif test x$vg_cv_only32bit = xyes; then
687 VGCONF_ARCH_PRI="x86"
689 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
690 VGCONF_PLATFORM_SEC_CAPS=""
691 valt_load_address_pri_norml="0x58000000"
692 valt_load_address_pri_inner="0x38000000"
694 VGCONF_ARCH_PRI="amd64"
695 VGCONF_ARCH_SEC="x86"
696 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
697 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
698 valt_load_address_pri_norml="0x58000000"
699 valt_load_address_pri_inner="0x38000000"
700 valt_load_address_sec_norml="0x58000000"
701 valt_load_address_sec_inner="0x38000000"
703 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
706 VGCONF_ARCH_PRI="ppc32"
708 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
709 VGCONF_PLATFORM_SEC_CAPS=""
710 valt_load_address_pri_norml="0x58000000"
711 valt_load_address_pri_inner="0x38000000"
712 valt_load_address_sec_norml="0xUNSET"
713 valt_load_address_sec_inner="0xUNSET"
714 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
717 valt_load_address_sec_norml="0xUNSET"
718 valt_load_address_sec_inner="0xUNSET"
719 if test x$vg_cv_only64bit = xyes; then
720 VGCONF_ARCH_PRI="ppc64be"
722 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
723 VGCONF_PLATFORM_SEC_CAPS=""
724 valt_load_address_pri_norml="0x58000000"
725 valt_load_address_pri_inner="0x38000000"
726 elif test x$vg_cv_only32bit = xyes; then
727 VGCONF_ARCH_PRI="ppc32"
729 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
730 VGCONF_PLATFORM_SEC_CAPS=""
731 valt_load_address_pri_norml="0x58000000"
732 valt_load_address_pri_inner="0x38000000"
734 VGCONF_ARCH_PRI="ppc64be"
735 VGCONF_ARCH_SEC="ppc32"
736 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
737 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
738 valt_load_address_pri_norml="0x58000000"
739 valt_load_address_pri_inner="0x38000000"
740 valt_load_address_sec_norml="0x58000000"
741 valt_load_address_sec_inner="0x38000000"
743 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
746 # Little Endian is only supported on PPC64
747 valt_load_address_sec_norml="0xUNSET"
748 valt_load_address_sec_inner="0xUNSET"
749 VGCONF_ARCH_PRI="ppc64le"
751 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
752 VGCONF_PLATFORM_SEC_CAPS=""
753 valt_load_address_pri_norml="0x58000000"
754 valt_load_address_pri_inner="0x38000000"
755 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
758 VGCONF_ARCH_PRI="x86"
760 VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
761 VGCONF_PLATFORM_SEC_CAPS=""
762 valt_load_address_pri_norml="0x38000000"
763 valt_load_address_pri_inner="0x28000000"
764 valt_load_address_sec_norml="0xUNSET"
765 valt_load_address_sec_inner="0xUNSET"
766 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
769 if test x$vg_cv_only64bit = xyes; then
770 VGCONF_ARCH_PRI="amd64"
772 VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
773 VGCONF_PLATFORM_SEC_CAPS=""
774 elif test x$vg_cv_only32bit = xyes; then
775 VGCONF_ARCH_PRI="x86"
777 VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
778 VGCONF_PLATFORM_SEC_CAPS=""
780 VGCONF_ARCH_PRI="amd64"
781 VGCONF_ARCH_SEC="x86"
782 VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
783 VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
785 # These work with either base clang or ports installed gcc
786 # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
787 if test x$is_clang = xclang ; then
788 FLAG_32ON64="-B/usr/lib32"
790 GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
791 FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
793 valt_load_address_pri_norml="0x38000000"
794 valt_load_address_pri_inner="0x28000000"
795 valt_load_address_sec_norml="0x38000000"
796 valt_load_address_sec_inner="0x28000000"
797 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
799 # Darwin gets identified as 32-bit even when it supports 64-bit.
800 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
801 # all Macs support both 32-bit and 64-bit, so we just build both. If
802 # someone has a really old 32-bit only machine they can (hopefully?)
803 # build with --enable-only32bit. See bug 243362.
804 x86-darwin|amd64-darwin)
806 valt_load_address_sec_norml="0xUNSET"
807 valt_load_address_sec_inner="0xUNSET"
808 if test x$vg_cv_only64bit = xyes; then
809 VGCONF_ARCH_PRI="amd64"
811 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
812 VGCONF_PLATFORM_SEC_CAPS=""
813 valt_load_address_pri_norml="0x158000000"
814 valt_load_address_pri_inner="0x138000000"
815 elif test x$vg_cv_only32bit = xyes; then
816 VGCONF_ARCH_PRI="x86"
818 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
819 VGCONF_PLATFORM_SEC_CAPS=""
820 VGCONF_ARCH_PRI_CAPS="x86"
821 valt_load_address_pri_norml="0x58000000"
822 valt_load_address_pri_inner="0x38000000"
824 VGCONF_ARCH_PRI="amd64"
825 VGCONF_ARCH_SEC="x86"
826 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
827 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
828 valt_load_address_pri_norml="0x158000000"
829 valt_load_address_pri_inner="0x138000000"
830 valt_load_address_sec_norml="0x58000000"
831 valt_load_address_sec_inner="0x38000000"
833 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
836 VGCONF_ARCH_PRI="arm"
837 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
838 VGCONF_PLATFORM_SEC_CAPS=""
839 valt_load_address_pri_norml="0x58000000"
840 valt_load_address_pri_inner="0x38000000"
841 valt_load_address_sec_norml="0xUNSET"
842 valt_load_address_sec_inner="0xUNSET"
843 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
846 valt_load_address_sec_norml="0xUNSET"
847 valt_load_address_sec_inner="0xUNSET"
848 if test x$vg_cv_only64bit = xyes; then
849 VGCONF_ARCH_PRI="arm64"
851 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
852 VGCONF_PLATFORM_SEC_CAPS=""
853 valt_load_address_pri_norml="0x58000000"
854 valt_load_address_pri_inner="0x38000000"
855 elif test x$vg_cv_only32bit = xyes; then
856 VGCONF_ARCH_PRI="arm"
858 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
859 VGCONF_PLATFORM_SEC_CAPS=""
860 valt_load_address_pri_norml="0x58000000"
861 valt_load_address_pri_inner="0x38000000"
863 VGCONF_ARCH_PRI="arm64"
864 VGCONF_ARCH_SEC="arm"
865 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
866 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
867 valt_load_address_pri_norml="0x58000000"
868 valt_load_address_pri_inner="0x38000000"
869 valt_load_address_sec_norml="0x58000000"
870 valt_load_address_sec_inner="0x38000000"
872 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
875 VGCONF_ARCH_PRI="s390x"
877 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
878 VGCONF_PLATFORM_SEC_CAPS=""
879 # To improve branch prediction hit rate we want to have
880 # the generated code close to valgrind (host) code
881 valt_load_address_pri_norml="0x800000000"
882 valt_load_address_pri_inner="0x810000000"
883 valt_load_address_sec_norml="0xUNSET"
884 valt_load_address_sec_inner="0xUNSET"
885 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
888 VGCONF_ARCH_PRI="mips32"
890 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
891 VGCONF_PLATFORM_SEC_CAPS=""
892 valt_load_address_pri_norml="0x58000000"
893 valt_load_address_pri_inner="0x38000000"
894 valt_load_address_sec_norml="0xUNSET"
895 valt_load_address_sec_inner="0xUNSET"
896 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
899 valt_load_address_sec_norml="0xUNSET"
900 valt_load_address_sec_inner="0xUNSET"
901 if test x$vg_cv_only64bit = xyes; then
902 VGCONF_ARCH_PRI="mips64"
903 VGCONF_PLATFORM_SEC_CAPS=""
904 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
905 VGCONF_PLATFORM_SEC_CAPS=""
906 valt_load_address_pri_norml="0x58000000"
907 valt_load_address_pri_inner="0x38000000"
908 elif test x$vg_cv_only32bit = xyes; then
909 VGCONF_ARCH_PRI="mips32"
911 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
912 VGCONF_PLATFORM_SEC_CAPS=""
913 valt_load_address_pri_norml="0x58000000"
914 valt_load_address_pri_inner="0x38000000"
916 VGCONF_ARCH_PRI="mips64"
917 VGCONF_ARCH_SEC="mips32"
918 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
919 VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
920 valt_load_address_pri_norml="0x58000000"
921 valt_load_address_pri_inner="0x38000000"
922 valt_load_address_sec_norml="0x58000000"
923 valt_load_address_sec_inner="0x38000000"
925 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
928 VGCONF_ARCH_PRI="nanomips"
930 VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
931 VGCONF_PLATFORM_SEC_CAPS=""
932 valt_load_address_pri_norml="0x58000000"
933 valt_load_address_pri_inner="0x38000000"
934 valt_load_address_sec_norml="0xUNSET"
935 valt_load_address_sec_inner="0xUNSET"
936 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
939 VGCONF_ARCH_PRI="x86"
941 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
942 VGCONF_PLATFORM_SEC_CAPS=""
943 valt_load_address_pri_norml="0x58000000"
944 valt_load_address_pri_inner="0x38000000"
945 valt_load_address_sec_norml="0xUNSET"
946 valt_load_address_sec_inner="0xUNSET"
947 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
950 valt_load_address_sec_norml="0xUNSET"
951 valt_load_address_sec_inner="0xUNSET"
952 if test x$vg_cv_only64bit = xyes; then
953 VGCONF_ARCH_PRI="amd64"
955 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
956 VGCONF_PLATFORM_SEC_CAPS=""
957 valt_load_address_pri_norml="0x58000000"
958 valt_load_address_pri_inner="0x38000000"
959 elif test x$vg_cv_only32bit = xyes; then
960 VGCONF_ARCH_PRI="x86"
962 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
963 VGCONF_PLATFORM_SEC_CAPS=""
964 valt_load_address_pri_norml="0x58000000"
965 valt_load_address_pri_inner="0x38000000"
967 VGCONF_ARCH_PRI="amd64"
968 VGCONF_ARCH_SEC="x86"
969 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
970 VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
971 valt_load_address_pri_norml="0x58000000"
972 valt_load_address_pri_inner="0x38000000"
973 valt_load_address_sec_norml="0x58000000"
974 valt_load_address_sec_inner="0x38000000"
976 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
979 VGCONF_ARCH_PRI="unknown"
980 VGCONF_ARCH_SEC="unknown"
981 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
982 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
983 valt_load_address_pri_norml="0xUNSET"
984 valt_load_address_pri_inner="0xUNSET"
985 valt_load_address_sec_norml="0xUNSET"
986 valt_load_address_sec_inner="0xUNSET"
987 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
988 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
992 #----------------------------------------------------------------------------
994 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
996 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
997 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
998 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
999 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1000 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1001 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1002 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1003 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1004 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1005 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
1006 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1007 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1008 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1009 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1010 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
1011 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1012 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1013 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
1014 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1015 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1016 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
1017 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1018 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1019 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
1020 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1021 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1022 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1023 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1024 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1025 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1026 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1027 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
1028 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1029 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1031 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
1033 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
1034 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1035 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1036 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
1037 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1038 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
1039 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1040 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1041 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1042 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1043 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1044 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1045 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
1046 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1047 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1048 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
1049 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1050 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1051 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1052 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1053 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1054 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1055 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1056 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1057 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1058 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1059 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1060 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1061 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1062 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1063 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD,
1064 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1065 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1066 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1067 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1068 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
1069 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1070 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1071 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1072 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1073 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1074 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1077 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
1078 # Relies on the assumption that the primary and secondary targets are
1079 # for the same OS, so therefore only necessary to test the primary.
1080 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1081 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1082 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1083 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1084 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1085 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1086 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1087 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1088 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1089 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1090 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1091 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1092 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1093 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1094 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1095 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1096 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1097 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1098 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1099 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1100 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1101 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1102 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1103 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1104 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1105 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1108 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1109 # there is a secondary target.
1110 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1111 test x$VGCONF_PLATFORM_SEC_CAPS != x)
1113 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1114 dnl fallback definition
1115 dnl The macro is courtesy of Dave Hart:
1116 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1117 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1118 if test -z "$$1_TRUE"; then :
1127 #----------------------------------------------------------------------------
1129 #----------------------------------------------------------------------------
1131 # Check if this should be built as an inner Valgrind, to be run within
1132 # another Valgrind. Choose the load address accordingly.
1133 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1134 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1135 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1136 [AC_ARG_ENABLE(inner,
1137 [ --enable-inner enables self-hosting],
1138 [vg_cv_inner=$enableval],
1140 if test "$vg_cv_inner" = yes; then
1141 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1142 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1143 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1145 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1146 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1149 #----------------------------------------------------------------------------
1150 # Undefined behaviour sanitiser
1151 #----------------------------------------------------------------------------
1152 # Check whether we should build with the undefined beahviour sanitiser.
1154 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1155 [AC_ARG_ENABLE(ubsan,
1156 [ --enable-ubsan enables the undefined behaviour sanitiser],
1157 [vg_cv_ubsan=$enableval],
1160 #----------------------------------------------------------------------------
1161 # Extra fine-tuning of installation directories
1162 #----------------------------------------------------------------------------
1164 [ --with-tmpdir=PATH Specify path for temporary files],
1167 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1168 AC_SUBST(VG_TMPDIR, [$tmpdir])
1170 #----------------------------------------------------------------------------
1172 #----------------------------------------------------------------------------
1173 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1174 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1175 AC_MSG_CHECKING([for xcode sdk include path])
1176 AC_ARG_WITH(xcodedir,
1177 [ --with-xcode-path=PATH Specify path for xcode sdk includes],
1178 [xcodedir="$withval"],
1180 if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1181 xcrundir=`xcrun --sdk macosx --show-sdk-path`
1182 if test -z "$xcrundir"; then
1183 xcodedir="/usr/include"
1185 xcodedir="$xcrundir/usr/include"
1188 xcodedir="/usr/include"
1191 AC_MSG_RESULT([$xcodedir])
1192 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1193 AC_SUBST(XCODE_DIR, [$xcodedir])])
1195 #----------------------------------------------------------------------------
1196 # Libc and suppressions
1197 #----------------------------------------------------------------------------
1198 # This variable will collect the suppression files to be used.
1199 AC_SUBST(DEFAULT_SUPP)
1201 AC_CHECK_HEADER([features.h])
1203 if test x$ac_cv_header_features_h = xyes; then
1204 AC_DEFINE([HAVE_HEADER_FEATURES_H], 1,
1205 [Define to 1 if you have the `features.h' header.])
1206 rm -f conftest.$ac_ext
1207 cat <<_ACEOF >conftest.$ac_ext
1208 #include <features.h>
1209 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1210 glibc version is: __GLIBC__ __GLIBC_MINOR__
1213 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1216 # not really a version check
1217 AC_EGREP_CPP([DARWIN_LIBC], [
1218 #include <sys/cdefs.h>
1219 #if defined(__DARWIN_VERS_1050)
1223 GLIBC_VERSION="darwin")
1225 AC_EGREP_CPP([FREEBSD_LIBC], [
1226 #include <sys/cdefs.h>
1227 #if defined(__FreeBSD__)
1231 GLIBC_VERSION="freebsd")
1233 # not really a version check
1234 AC_EGREP_CPP([BIONIC_LIBC], [
1235 #if defined(__ANDROID__)
1239 GLIBC_VERSION="bionic")
1241 # there is only one version of libc on Solaris
1242 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1243 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1244 GLIBC_VERSION="solaris"
1247 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1249 if test x$GLIBC_VERSION = x; then
1250 if $CC -dumpmachine | grep -q musl; then
1255 # If this is glibc then figure out the generic (in file) libc.so and
1256 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1257 # was a separate library, afterwards it was merged into libc.so and
1258 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1259 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1260 case ${GLIBC_VERSION} in
1262 AC_MSG_CHECKING([whether pthread_create needs libpthread])
1263 AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1266 GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1267 GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1269 AC_MSG_RESULT([yes])
1270 GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1271 GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1275 AC_MSG_CHECKING([not glibc...])
1276 AC_MSG_RESULT([${GLIBC_VERSION}])
1280 AC_MSG_CHECKING([the glibc version])
1282 case "${GLIBC_VERSION}" in
1284 AC_MSG_RESULT(${GLIBC_VERSION} family)
1285 DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1286 DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1287 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1290 AC_MSG_RESULT(${GLIBC_VERSION} family)
1291 DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1292 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1293 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1296 AC_MSG_RESULT(${GLIBC_VERSION} family)
1297 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1298 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1299 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1302 AC_MSG_RESULT(${GLIBC_VERSION} family)
1303 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1304 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1305 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1306 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1307 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1310 AC_MSG_RESULT(${GLIBC_VERSION} family)
1311 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1312 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1313 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1314 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1315 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1316 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1317 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1320 AC_MSG_RESULT(Darwin)
1321 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1322 # DEFAULT_SUPP set by kernel version check above.
1325 AC_MSG_RESULT(FreeBSD)
1326 AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1327 # DEFAULT_SUPP set by kernel version check above.
1330 AC_MSG_RESULT(Bionic)
1331 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1332 DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1335 AC_MSG_RESULT(Solaris)
1336 # DEFAULT_SUPP set in host_os switch-case above.
1337 # No other suppression file is used.
1341 AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1342 DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1345 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1346 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1347 AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1351 AC_SUBST(GLIBC_VERSION)
1352 AC_SUBST(GLIBC_LIBC_PATH)
1353 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1356 if test "$VGCONF_OS" != "solaris"; then
1357 # Add default suppressions for the X client libraries. Make no
1358 # attempt to detect whether such libraries are installed on the
1359 # build machine (or even if any X facilities are present); just
1360 # add the suppressions antidisirregardless.
1361 DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1362 DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1366 #----------------------------------------------------------------------------
1367 # Platform variants?
1368 #----------------------------------------------------------------------------
1370 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1371 # But there are times where we need a bit more control. The motivating
1372 # and currently only case is Android: this is almost identical to
1373 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1374 # platform variant tags, which get passed in the compile as
1375 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1377 # In almost all cases, the <variant> bit is "vanilla". But for Android
1378 # it is "android" instead.
1380 # Consequently (eg), plain arm-linux would build with
1382 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1384 # whilst an Android build would have
1386 # -DVGP_arm_linux -DVGPV_arm_linux_android
1388 # Same for x86. The setup of the platform variant is pushed relatively far
1389 # down this file in order that we can inspect any of the variables set above.
1391 # In the normal case ..
1392 VGCONF_PLATVARIANT="vanilla"
1395 if test "$GLIBC_VERSION" = "bionic";
1397 VGCONF_PLATVARIANT="android"
1400 AC_SUBST(VGCONF_PLATVARIANT)
1403 # FIXME: do we also want to define automake variables
1404 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1405 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1406 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1407 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1408 # that's what we'd need to do to use this, since what we'd want to write
1411 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1413 # Hmm. Can't think of a nice clean solution to this.
1415 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1416 test x$VGCONF_PLATVARIANT = xvanilla)
1417 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1418 test x$VGCONF_PLATVARIANT = xandroid)
1421 #----------------------------------------------------------------------------
1422 # Checking for various library functions and other definitions
1423 #----------------------------------------------------------------------------
1425 # Check for AT_FDCWD
1427 AC_MSG_CHECKING([for AT_FDCWD])
1428 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1435 ac_have_at_fdcwd=yes
1436 AC_MSG_RESULT([yes])
1442 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1444 # Check for stpncpy function definition in string.h
1445 # This explicitly checks with _GNU_SOURCE defined since that is also
1446 # used in the test case (some systems might define it without anyway
1447 # since stpncpy is part of The Open Group Base Specifications Issue 7
1448 # IEEE Std 1003.1-2008.
1449 AC_MSG_CHECKING([for stpncpy])
1450 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1457 char *r = stpncpy(d, s, n);
1459 ac_have_gnu_stpncpy=yes
1460 AC_MSG_RESULT([yes])
1462 ac_have_gnu_stpncpy=no
1466 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1468 # Check for PTRACE_GETREGS
1470 AC_MSG_CHECKING([for PTRACE_GETREGS])
1471 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1474 #include <sys/ptrace.h>
1475 #include <sys/user.h>
1478 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1480 AC_MSG_RESULT([yes])
1481 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1482 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1488 # Check for CLOCK_MONOTONIC
1490 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1492 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1496 clock_gettime(CLOCK_MONOTONIC, &t);
1499 AC_MSG_RESULT([yes])
1500 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1501 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1507 # Check for ELF32/64_CHDR
1509 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1512 # Check for PTHREAD_RWLOCK_T
1514 AC_MSG_CHECKING([for pthread_rwlock_t])
1516 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1518 #include <pthread.h>
1520 pthread_rwlock_t rwl;
1522 AC_MSG_RESULT([yes])
1523 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1524 [Define to 1 if you have the `pthread_rwlock_t' type.])
1529 # Check for CLOCKID_T
1531 AC_MSG_CHECKING([for clockid_t])
1533 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1538 AC_MSG_RESULT([yes])
1539 AC_DEFINE([HAVE_CLOCKID_T], 1,
1540 [Define to 1 if you have the `clockid_t' type.])
1545 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1547 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1549 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1551 #include <pthread.h>
1553 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1555 AC_MSG_RESULT([yes])
1556 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1557 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1563 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1565 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1567 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1569 #include <pthread.h>
1571 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1573 AC_MSG_RESULT([yes])
1574 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1575 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1581 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1583 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1587 #include <pthread.h>
1589 return (PTHREAD_MUTEX_RECURSIVE_NP);
1591 AC_MSG_RESULT([yes])
1592 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1593 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1599 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1601 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1603 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1605 #include <pthread.h>
1607 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1610 AC_MSG_RESULT([yes])
1611 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1612 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1618 # Check whether pthread_mutex_t has a member called __m_kind.
1620 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1621 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1623 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1626 [#include <pthread.h>])
1629 # Check whether pthread_mutex_t has a member called __data.__kind.
1631 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1632 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1634 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1637 [#include <pthread.h>])
1639 # Convenience function. Set flags based on the existing HWCAP entries.
1640 # The AT_HWCAP entries are generated by glibc, and are based on
1641 # functions supported by the hardware/system/libc.
1642 # Subsequent support for whether the capability will actually be utilized
1643 # will also be checked against the compiler capabilities.
1645 # AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1646 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1648 AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1649 if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1651 AC_MSG_RESULT([yes])
1652 AC_SUBST([$2],[yes])
1659 # gather hardware capabilities. (hardware/kernel/libc)
1660 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1661 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1662 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1663 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1664 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1665 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1666 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1667 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1668 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1669 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1672 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1673 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1674 # compiler support for isa 2.07 level instructions
1675 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1676 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1678 __asm__ __volatile__("mtvsrd 1,2 ");
1680 ac_asm_have_isa_2_07=yes
1681 AC_MSG_RESULT([yes])
1683 ac_asm_have_isa_2_07=no
1686 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1687 -a x$HWCAP_HAS_ISA_2_07 = xyes])
1689 # altivec (vsx) support.
1690 # does this compiler support -maltivec and does it have the include file
1692 AC_MSG_CHECKING([for Altivec support in the compiler ])
1694 CFLAGS="-maltivec -Werror"
1695 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1696 #include <altivec.h>
1698 vector unsigned int v;
1701 AC_MSG_RESULT([yes])
1707 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1708 -a x$HWCAP_HAS_ALTIVEC = xyes])
1710 # Check that both: the compiler supports -mvsx and that the assembler
1711 # understands VSX instructions. If either of those doesn't work,
1712 # conclude that we can't do VSX.
1713 AC_MSG_CHECKING([for VSX compiler flag support])
1715 CFLAGS="-mvsx -Werror"
1716 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1719 ac_compiler_supports_vsx_flag=yes
1720 AC_MSG_RESULT([yes])
1722 ac_compiler_supports_vsx_flag=no
1727 AC_MSG_CHECKING([for VSX support in the assembler ])
1729 CFLAGS="-mvsx -Werror"
1730 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1731 #include <altivec.h>
1733 vector unsigned int v;
1734 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1736 ac_compiler_supports_vsx=yes
1737 AC_MSG_RESULT([yes])
1739 ac_compiler_supports_vsx=no
1743 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1744 -a x$ac_compiler_supports_vsx = xyes \
1745 -a x$HWCAP_HAS_VSX = xyes ])
1747 # DFP (Decimal Float)
1748 # The initial DFP support was added in Power 6. The dcffix instruction
1749 # support was added in Power 7.
1750 AC_MSG_CHECKING([that assembler knows DFP])
1751 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1754 __asm__ __volatile__("adtr 1, 2, 3")
1756 __asm__ __volatile__(".machine power7;\n" \
1762 AC_MSG_RESULT([yes])
1767 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1769 CFLAGS="-mhard-dfp -Werror"
1771 # The dcffix instruction is Power 7
1772 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1775 __asm__ __volatile__("adtr 1, 2, 3")
1777 __asm__ __volatile__(".machine power7;\n" \
1782 ac_compiler_have_dfp=yes
1783 AC_MSG_RESULT([yes])
1785 ac_compiler_have_dfp=no
1789 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1790 -a x$ac_compiler_have_dfp = xyes \
1791 -a x$HWCAP_HAS_DFP = xyes )
1793 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1794 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1796 _Decimal64 x = 0.0DD;
1798 ac_compiler_have_dfp_type=yes
1799 AC_MSG_RESULT([yes])
1801 ac_compiler_have_dfp_type=no
1804 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1805 -a x$HWCAP_HAS_DFP = xyes )
1808 # HTM (Hardware Transactional Memory)
1809 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1811 CFLAGS="-mhtm -Werror"
1812 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1816 AC_MSG_RESULT([yes])
1817 ac_compiler_supports_htm=yes
1820 ac_compiler_supports_htm=no
1824 AC_MSG_CHECKING([if compiler can find the htm builtins])
1826 CFLAGS="-mhtm -Werror"
1827 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1829 if (__builtin_tbegin (0))
1832 AC_MSG_RESULT([yes])
1833 ac_compiler_sees_htm_builtins=yes
1836 ac_compiler_sees_htm_builtins=no
1840 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1841 -a x$ac_compiler_sees_htm_builtins = xyes \
1842 -a x$HWCAP_HAS_HTM = xyes )
1844 # isa 3.0 checking. (actually 3.0 or newer)
1845 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1847 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1849 __asm__ __volatile__ (".machine power9;\n" \
1852 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1855 CFLAGS="-DHAS_ISA_3_00"
1856 ac_asm_have_isa_3_00=yes
1857 AC_MSG_RESULT([yes])
1859 ac_asm_have_isa_3_00=no
1865 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1867 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1869 __asm__ __volatile__ (".machine power9;\n" \
1870 "xscvhpdp 1,2;\n" );
1872 ac_asm_have_xscvhpdp=yes
1873 AC_MSG_RESULT([yes])
1875 ac_asm_have_xscvhpdp=no
1879 # darn instruction checking
1880 AC_MSG_CHECKING([that assembler knows darn instruction ])
1882 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1884 __asm__ __volatile__(".machine power9; darn 1,0 ");
1886 ac_asm_have_darn_inst=yes
1887 AC_MSG_RESULT([yes])
1889 ac_asm_have_darn_inst=no
1894 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1895 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1897 __asm__ __volatile__ (".machine power10;\n" \
1900 ac_asm_have_isa_3_1=yes
1901 AC_MSG_RESULT([yes])
1903 ac_asm_have_isa_3_1=no
1908 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1909 -a x$HWCAP_HAS_ISA_3_00 = xyes])
1911 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1912 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1914 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1915 -a x$HWCAP_HAS_ISA_3_1 = xyes])
1917 # Check for pthread_create@GLIBC2.0
1918 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1921 CFLAGS="-lpthread -Werror"
1922 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1923 extern int pthread_create_glibc_2_0(void*, const void*,
1924 void *(*)(void*), void*);
1925 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1929 * Apparently on PowerPC linking this program succeeds and generates an
1930 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1932 #error This test does not work properly on PowerPC.
1934 pthread_create_glibc_2_0(0, 0, 0, 0);
1938 ac_have_pthread_create_glibc_2_0=yes
1939 AC_MSG_RESULT([yes])
1940 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1941 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1943 ac_have_pthread_create_glibc_2_0=no
1948 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1949 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1952 # Check for dlinfo RTLD_DI_TLS_MODID
1953 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1957 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1964 size_t sizes[10000];
1965 size_t modid_offset;
1966 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1969 ac_have_dlinfo_rtld_di_tls_modid=yes
1970 AC_MSG_RESULT([yes])
1971 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1972 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1974 ac_have_dlinfo_rtld_di_tls_modid=no
1979 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1980 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1983 # Check for eventfd_t, eventfd() and eventfd_read()
1984 AC_MSG_CHECKING([for eventfd()])
1986 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1987 #include <sys/eventfd.h>
1993 eventfd_read(fd, &ev);
1996 AC_MSG_RESULT([yes])
1997 AC_DEFINE([HAVE_EVENTFD], 1,
1998 [Define to 1 if you have the `eventfd' function.])
1999 AC_DEFINE([HAVE_EVENTFD_READ], 1,
2000 [Define to 1 if you have the `eventfd_read' function.])
2005 # Check whether compiler can process #include <thread> without errors
2006 # clang 3.3 cannot process <thread> from e.g.
2007 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
2009 AC_MSG_CHECKING([that C++ compiler can compile C++17 code])
2011 safe_CXXFLAGS=$CXXFLAGS
2014 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2019 AC_MSG_RESULT([yes])
2024 CXXFLAGS=$safe_CXXFLAGS
2027 AM_CONDITIONAL(HAVE_CXX17, test x$ac_have_cxx_17 = xyes)
2029 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
2031 safe_CXXFLAGS=$CXXFLAGS
2034 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2038 ac_cxx_can_include_thread_header=yes
2039 AC_MSG_RESULT([yes])
2041 ac_cxx_can_include_thread_header=no
2044 CXXFLAGS=$safe_CXXFLAGS
2047 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2049 # Check whether compiler can process #include <condition_variable> without errors
2051 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2053 safe_CXXFLAGS=$CXXFLAGS
2056 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2057 #include <condition_variable>
2060 ac_cxx_can_include_condition_variable_header=yes
2061 AC_MSG_RESULT([yes])
2063 ac_cxx_can_include_condition_variable_header=no
2066 CXXFLAGS=$safe_CXXFLAGS
2069 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2071 # check for std::shared_timed_mutex, this is a C++ 14 feature
2073 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2075 safe_CXXFLAGS=$CXXFLAGS
2076 CXXFLAGS="-std=c++1y -pthread"
2078 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2079 #include <shared_mutex>
2080 std::shared_timed_mutex test_mutex;
2083 ac_cxx_can_use_shared_timed_mutex=yes
2084 AC_MSG_RESULT([yes])
2086 ac_cxx_can_use_shared_timed_mutex=no
2089 CXXFLAGS=$safe_CXXFLAGS
2092 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2094 # check for std::shared_mutex, this is a C++ 11 feature
2096 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2098 safe_CXXFLAGS=$CXXFLAGS
2099 CXXFLAGS="-std=c++0x -pthread"
2101 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2103 std::timed_mutex test_mutex;
2106 ac_cxx_can_use_timed_mutex=yes
2107 AC_MSG_RESULT([yes])
2109 ac_cxx_can_use_timed_mutex=no
2112 CXXFLAGS=$safe_CXXFLAGS
2115 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2117 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2118 # of the user_regs_struct from sys/user.h. They are structurally the same
2119 # but we get either one or the other.
2121 AC_CHECK_TYPE([struct user_regs_struct],
2122 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2123 [[#include <sys/ptrace.h>]
2124 [#include <sys/time.h>]
2125 [#include <sys/user.h>]])
2126 if test "$sys_user_has_user_regs" = "yes"; then
2127 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2128 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2131 AC_MSG_CHECKING([for __NR_membarrier])
2132 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2133 #include <linux/unistd.h>
2135 return __NR_membarrier
2137 ac_have_nr_membarrier=yes
2138 AC_MSG_RESULT([yes])
2140 ac_have_nr_membarrier=no
2144 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2146 #----------------------------------------------------------------------------
2147 # Checking for supported compiler flags.
2148 #----------------------------------------------------------------------------
2150 case "${host_cpu}" in
2152 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2153 if test -z "$ARCH"; then
2154 # does this compiler support -march=mips32 (mips32 default) ?
2155 AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2158 CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2160 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2163 FLAG_M32="-mips32 -mabi=32"
2164 AC_MSG_RESULT([yes])
2174 # does this compiler support -march=mips64r2 (mips64r2 default) ?
2175 AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2178 CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2180 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2183 FLAG_M64="-march=mips64r2 -mabi=64"
2184 AC_MSG_RESULT([yes])
2197 # does this compiler support -m32 ?
2198 AC_MSG_CHECKING([if gcc accepts -m32])
2201 CFLAGS="${FLAG_32ON64} -m32 -Werror"
2203 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2206 FLAG_M32="${FLAG_32ON64} -m32"
2207 AC_MSG_RESULT([yes])
2217 # does this compiler support -m64 ?
2218 AC_MSG_CHECKING([if gcc accepts -m64])
2221 CFLAGS="-m64 -Werror"
2223 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2227 AC_MSG_RESULT([yes])
2239 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2240 if test -z "$ARCH"; then
2241 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2242 AC_MSG_CHECKING([if gcc accepts -march=octeon])
2245 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2247 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2250 FLAG_OCTEON="-march=octeon"
2251 AC_MSG_RESULT([yes])
2258 AC_SUBST(FLAG_OCTEON)
2261 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2262 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2265 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2267 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2270 FLAG_OCTEON2="-march=octeon2"
2271 AC_MSG_RESULT([yes])
2278 AC_SUBST(FLAG_OCTEON2)
2282 # does this compiler support -mmsa (MIPS MSA ASE) ?
2283 AC_MSG_CHECKING([if gcc accepts -mmsa])
2286 CFLAGS="$CFLAGS -mmsa -Werror"
2288 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2292 AC_MSG_RESULT([yes])
2301 # Are we compiling for the MIPS64 n32 ABI?
2302 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2303 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2304 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2309 FLAG_M64="-march=mips64r2 -mabi=n32"
2310 AC_MSG_RESULT([yes])
2315 # Are we compiling for the MIPS64 n64 ABI?
2316 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2317 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2318 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2323 AC_MSG_RESULT([yes])
2328 # We enter the code block below in the following case:
2329 # Target architecture is set to mips64, the desired abi
2330 # was not specified and the compiler's default abi setting
2331 # is neither n32 nor n64.
2332 # Probe for and set the abi to either n64 or n32, in that order,
2333 # which is required for a mips64 build of valgrind.
2334 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2336 CFLAGS="$CFLAGS -mabi=64 -Werror"
2337 AC_MSG_CHECKING([if gcc is n64 capable])
2338 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2342 AC_MSG_RESULT([yes])
2348 if test "x$VGCONF_ABI" = "x"; then
2350 CFLAGS="$CFLAGS -mabi=n32 -Werror"
2351 AC_MSG_CHECKING([if gcc is n32 capable])
2352 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2356 FLAG_M64="-march=mips64r2 -mabi=n32"
2357 AC_MSG_RESULT([yes])
2365 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2366 [test x$VGCONF_ABI != x])
2367 AC_SUBST(VGCONF_ABI)
2370 # does this compiler support -mmmx ?
2371 AC_MSG_CHECKING([if gcc accepts -mmmx])
2374 CFLAGS="-mmmx -Werror"
2376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2380 AC_MSG_RESULT([yes])
2390 # does this compiler support -msse ?
2391 AC_MSG_CHECKING([if gcc accepts -msse])
2394 CFLAGS="-msse -Werror"
2396 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2400 AC_MSG_RESULT([yes])
2410 # does this compiler support -mpreferred-stack-boundary=2 when
2411 # generating code for a 32-bit target? Note that we only care about
2412 # this when generating code for (32-bit) x86, so if the compiler
2413 # doesn't recognise -m32 it's no big deal. We'll just get code for
2414 # the Memcheck and other helper functions, that is a bit slower than
2415 # it could be, on x86; and no difference at all on any other platform.
2416 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2419 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2421 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2424 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2425 AC_MSG_RESULT([yes])
2427 PREFERRED_STACK_BOUNDARY_2=""
2432 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2435 # does this compiler support -mlong-double-128 ?
2436 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2438 CFLAGS="-mlong-double-128 -Werror"
2439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2442 ac_compiler_supports_mlong_double_128=yes
2443 AC_MSG_RESULT([yes])
2445 ac_compiler_supports_mlong_double_128=no
2449 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2450 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2451 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2453 # does this toolchain support lto ?
2454 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2456 # If not enable-lto=* arg is provided, default to no, as lto builds are
2457 # a lot slower, and so not appropriate for Valgrind developments.
2458 # --enable-lto=yes should be used by distro packagers.
2459 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2461 [ --enable-lto enables building with link time optimisation],
2462 [vg_cv_lto=$enableval],
2465 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2466 AC_MSG_CHECKING([if toolchain accepts lto])
2468 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2469 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2470 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2471 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2473 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2474 extern void somefun(void);
2478 LTO_CFLAGS=$TEST_LTO_CFLAGS
2479 AC_MSG_RESULT([yes])
2487 AC_SUBST(LTO_CFLAGS)
2489 # if we could not compile with lto args, or lto was disabled,
2490 # then set LTO_AR/LTO_RANLIB to the non lto values
2491 # define in config.h ENABLE_LTO (not needed by the code currently, but
2492 # this guarantees we recompile everything if we re-configure and rebuild
2493 # in a build dir previously build with another value of --enable-lto
2494 if test "x${LTO_CFLAGS}" = "x"; then
2496 LTO_RANLIB=${RANLIB}
2500 AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2503 # Convenience function to check whether GCC supports a particular
2504 # warning option. Takes two arguments,
2505 # first the warning flag name to check (without -W), then the
2506 # substitution name to set with -Wno-warning-flag if the flag exists,
2507 # or the empty string if the compiler doesn't accept the flag. Note
2508 # that checking is done against the warning flag itself, but the
2509 # substitution is then done to cancel the warning flag.
2510 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2511 AC_MSG_CHECKING([if gcc accepts -W$1])
2513 CFLAGS="-W$1 -Werror"
2514 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2515 AC_SUBST([$2], [-Wno-$1])
2516 AC_MSG_RESULT([yes])], [
2518 AC_MSG_RESULT([no])])
2522 # A variation of the above for arguments that
2524 AC_DEFUN([AC_GCC_WARNING_SUBST_NO_VAL],[
2525 AC_MSG_CHECKING([if gcc accepts -W$1=$2])
2527 CFLAGS="-W$1=$2 -Werror"
2528 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2529 AC_SUBST([$3], [-Wno-$1])
2530 AC_MSG_RESULT([yes])], [
2532 AC_MSG_RESULT([no])])
2536 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2537 # -W$1 (instead of -Wno-$1).
2538 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2539 AC_MSG_CHECKING([if gcc accepts -W$1])
2541 CFLAGS="-W$1 -Werror"
2542 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2543 AC_SUBST([$2], [-W$1])
2544 AC_MSG_RESULT([yes])], [
2546 AC_MSG_RESULT([no])])
2550 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2551 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2552 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2553 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2554 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2555 AC_GCC_WARNING_SUBST_NO([maybe-uninitialized], [FLAG_W_NO_MAYBE_UNINITIALIZED])
2556 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2557 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2558 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2559 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2560 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2561 AC_GCC_WARNING_SUBST_NO([unused-but-set-variable], [FLAG_W_NO_UNUSED_BUT_SET_VARIABLE])
2562 AC_GCC_WARNING_SUBST_NO([non-power-of-two-alignment], [FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT])
2563 AC_GCC_WARNING_SUBST_NO([sign-compare], [FLAG_W_NO_SIGN_COMPARE])
2564 AC_GCC_WARNING_SUBST_NO([stringop-overflow], [FLAG_W_NO_STRINGOP_OVERFLOW])
2565 AC_GCC_WARNING_SUBST_NO([stringop-overread], [FLAG_W_NO_STRINGOP_OVERREAD])
2566 AC_GCC_WARNING_SUBST_NO([stringop-truncation], [FLAG_W_NO_STRINGOP_TRUNCATION])
2567 AC_GCC_WARNING_SUBST_NO([format-overflow], [FLAG_W_NO_FORMAT_OVERFLOW])
2568 AC_GCC_WARNING_SUBST_NO([use-after-free], [FLAG_W_NO_USE_AFTER_FREE])
2569 AC_GCC_WARNING_SUBST_NO([free-nonheap-object], [FLAG_W_NO_FREE_NONHEAP_OBJECT])
2571 AC_GCC_WARNING_SUBST_NO_VAL([alloc-size-larger-than], [1677216], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN])
2573 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2574 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2575 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2576 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2577 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2578 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2579 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2580 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2581 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2582 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2583 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2585 # Does this compiler support -Wformat-security ?
2586 # Special handling is needed, because certain GCC versions require -Wformat
2587 # being present if -Wformat-security is given. Otherwise a warning is issued.
2588 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2589 # And with that the warning will be turned into an error with the result
2590 # that -Wformat-security is believed to be unsupported when in fact it is.
2591 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2593 CFLAGS="-Wformat -Wformat-security -Werror"
2594 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2595 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2596 AC_MSG_RESULT([yes])], [
2597 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2598 AC_MSG_RESULT([no])])
2601 # does this compiler support -Wextra or the older -W ?
2603 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2606 CFLAGS="-Wextra -Werror"
2608 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2611 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2612 AC_MSG_RESULT([-Wextra])
2615 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2618 AC_SUBST([FLAG_W_EXTRA], [-W])
2621 AC_SUBST([FLAG_W_EXTRA], [])
2622 AC_MSG_RESULT([not supported])
2627 # On ARM we do not want to pass -Wcast-align as that produces loads
2628 # of warnings. GCC is just being conservative. See here:
2629 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2630 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2631 AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2633 AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2636 # does this compiler support -faligned-new ?
2637 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2639 safe_CXXFLAGS=$CXXFLAGS
2640 CXXFLAGS="-faligned-new -Werror"
2643 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2646 FLAG_FALIGNED_NEW="-faligned-new"
2647 AC_MSG_RESULT([yes])
2649 FLAG_FALIGNED_NEW=""
2652 CXXFLAGS=$safe_CXXFLAGS
2655 AC_SUBST(FLAG_FALIGNED_NEW)
2657 # does this compiler support -fsized-deallocation ?
2658 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2660 safe_CXXFLAGS=$CXXFLAGS
2661 CXXFLAGS="-fsized-deallocation -Werror"
2664 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2667 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2668 ac_have_sized_deallocation=yes
2669 AC_MSG_RESULT([yes])
2671 FLAG_FSIZED_DEALLOCATION=""
2672 ac_have_sized_deallocation=no
2675 CXXFLAGS=$safe_CXXFLAGS
2678 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2679 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2681 # does this compiler support C++17 aligned new/delete?
2682 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2684 safe_CXXFLAGS=$CXXFLAGS
2685 CXXFLAGS="-std=c++17"
2688 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2692 operator delete(nullptr, std::align_val_t(64U));
2694 ac_have_aligned_cxx_alloc=yes
2695 AC_MSG_RESULT([yes])
2697 ac_have_aligned_cxx_alloc=no
2700 CXXFLAGS=$safe_CXXFLAGS
2703 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2705 # does this compiler support -fno-stack-protector ?
2706 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2709 CFLAGS="-fno-stack-protector -Werror"
2711 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2714 no_stack_protector=yes
2715 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2716 AC_MSG_RESULT([yes])
2718 no_stack_protector=no
2719 FLAG_FNO_STACK_PROTECTOR=""
2724 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2726 # does this compiler support -finline-functions ?
2727 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2730 CFLAGS="-finline-functions -Werror"
2732 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2735 inline_functions=yes
2736 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2737 AC_MSG_RESULT([yes])
2740 FLAG_FINLINE_FUNCTIONS=""
2745 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2747 # Does GCC support disabling Identical Code Folding?
2748 # We want to disabled Identical Code Folding for the
2749 # tools preload shared objects to get better backraces.
2750 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2751 # "The optimization reduces code size and may disturb
2752 # unwind stacks by replacing a function by equivalent
2753 # one with a different name."
2754 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2757 CFLAGS="-fno-ipa-icf -Werror"
2759 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2763 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2764 AC_MSG_RESULT([yes])
2772 AC_SUBST(FLAG_FNO_IPA_ICF)
2775 # Does this compiler support -fsanitize=undefined. This is true for
2776 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2777 # also checks for alignment violations on memory accesses which the valgrind
2778 # code base is sprinkled (if not littered) with. As those alignment issues
2779 # don't pose a problem we want to suppress warnings about them.
2780 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2781 # GCCs do not support that.
2783 # Only checked for if --enable-ubsan was given.
2784 if test "x${vg_cv_ubsan}" = "xyes"; then
2785 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2787 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2788 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2791 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2792 LIB_UBSAN="-static-libubsan"
2793 AC_MSG_RESULT([yes])
2795 CFLAGS="-fsanitize=undefined -Werror"
2796 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2799 FLAG_FSANITIZE="-fsanitize=undefined"
2800 LIB_UBSAN="-static-libubsan"
2801 AC_MSG_RESULT([yes])
2809 AC_SUBST(FLAG_FSANITIZE)
2812 # does this compiler support --param inline-unit-growth=... ?
2814 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2817 CFLAGS="--param inline-unit-growth=900 -Werror"
2819 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2822 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2823 ["--param inline-unit-growth=900"])
2824 AC_MSG_RESULT([yes])
2826 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2832 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2834 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2837 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2839 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2843 AC_MSG_RESULT([yes])
2848 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2852 # does this compiler support -g -gz=zlib ?
2854 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2857 CFLAGS="-g -gz=zlib"
2859 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2863 AC_MSG_RESULT([yes])
2868 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2872 # does this compiler support -g -gz=zlib-gnu ?
2874 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2877 CFLAGS="-g -gz=zlib-gnu"
2879 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2882 ac_have_gz_zlib_gnu=yes
2883 AC_MSG_RESULT([yes])
2885 ac_have_gz_zlib_gnu=no
2888 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2892 # does this compiler support nested functions ?
2894 AC_MSG_CHECKING([if gcc accepts nested functions])
2896 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2897 int foo() { return 1; }
2900 ac_have_nested_functions=yes
2901 AC_MSG_RESULT([yes])
2903 ac_have_nested_functions=no
2906 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2909 # does this compiler support the 'p' constraint in ASM statements ?
2911 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2913 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2915 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2917 ac_have_asm_constraint_p=yes
2918 AC_MSG_RESULT([yes])
2920 ac_have_asm_constraint_p=no
2923 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2926 # Does this compiler and linker support -pie?
2927 # Some compilers actually do not support -pie and report its usage
2928 # as an error. We need to check if it is safe to use it first.
2930 AC_MSG_CHECKING([if gcc accepts -pie])
2935 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2938 AC_SUBST([FLAG_PIE], ["-pie"])
2939 AC_MSG_RESULT([yes])
2941 AC_SUBST([FLAG_PIE], [""])
2946 AC_MSG_CHECKING([if gcc accepts -ansi])
2951 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2955 AC_MSG_RESULT([yes])
2960 AM_CONDITIONAL([HAVE_ANSI], [test x$ac_have_ansi = xyes])
2965 # Does this compiler support -no-pie?
2966 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2967 # default. However this gets in the way with some tests, we use -no-pie
2970 AC_MSG_CHECKING([if gcc accepts -no-pie])
2973 CFLAGS="-no-pie -Werror"
2975 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2978 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2979 AC_MSG_RESULT([yes])
2981 AC_SUBST([FLAG_NO_PIE], [""])
2987 # We want to use use the -Ttext-segment option to the linker.
2988 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2989 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2990 # semantics are NOT what we want (GNU gold -Ttext is fine).
2992 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2993 # will reside. -Ttext aligns just the .text section start (but not any
2996 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
2997 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
2998 # The --image-base option (since version 6.0?) provides the semantics needed.
2999 # -Ttext-segment generates an error, but -Ttext now more closely
3000 # follows the GNU (bfd) ld's -Ttext.
3002 # So test first for --image-base support, and if that fails then
3003 # for -Ttext-segment which is supported by all bfd ld versions
3004 # and use that if it exists. If it doesn't exist it must be an older
3005 # version of gold and we can fall back to using -Ttext which has the
3009 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
3011 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
3014 [AC_LANG_SOURCE([int _start () { return 0; }])],
3016 linker_using_t_text="no"
3017 AC_SUBST([FLAG_T_TEXT], ["--image-base"])
3018 AC_MSG_RESULT([yes])
3022 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
3024 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
3027 [AC_LANG_SOURCE([int _start () { return 0; }])],
3029 linker_using_t_text="no"
3030 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
3031 AC_MSG_RESULT([yes])
3033 linker_using_t_text="yes"
3034 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
3041 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
3042 # have to strip any build-id ELF NOTEs from the statically linked tools.
3043 # Otherwise the build-id NOTE might end up at the default load address.
3044 # (Pedantically if the linker is gold then -Ttext is fine, but newer
3045 # gold versions also support -Ttext-segment. So just assume that unless
3046 # we can use -Ttext-segment we need to strip the build-id NOTEs.
3047 if test "x${linker_using_t_text}" = "xyes"; then
3048 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
3049 # does the linker support -Wl,--build-id=none ? Note, it's
3050 # important that we test indirectly via whichever C compiler
3051 # is selected, rather than testing /usr/bin/ld or whatever
3053 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
3055 CFLAGS="-Wl,--build-id=none -Werror"
3058 [AC_LANG_PROGRAM([ ], [return 0;])],
3060 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
3061 AC_MSG_RESULT([yes])
3063 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3067 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
3068 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3072 # does the ppc assembler support "mtocrf" et al?
3073 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
3075 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3076 __asm__ __volatile__("mtocrf 4,0");
3077 __asm__ __volatile__("mfocrf 0,4");
3079 ac_have_as_ppc_mftocrf=yes
3080 AC_MSG_RESULT([yes])
3082 ac_have_as_ppc_mftocrf=no
3085 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3086 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3090 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3091 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3093 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3094 do { typedef struct {
3098 dbl_pair_t dbl_pair[3];
3099 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3102 ac_have_as_ppc_fpPO=yes
3103 AC_MSG_RESULT([yes])
3105 ac_have_as_ppc_fpPO=no
3108 if test x$ac_have_as_ppc_fpPO = xyes ; then
3109 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3113 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3114 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3116 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3118 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3119 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3121 ac_have_as_amd64_fxsave64=yes
3122 AC_MSG_RESULT([yes])
3124 ac_have_as_amd64_fxsave64=no
3127 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3128 AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3131 # does the x86/amd64 assembler understand SSE3 instructions?
3132 # Note, this doesn't generate a C-level symbol. It generates a
3133 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3134 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3136 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3137 do { long long int x;
3138 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
3142 AC_MSG_RESULT([yes])
3148 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3151 # Ditto for SSSE3 instructions (note extra S)
3152 # Note, this doesn't generate a C-level symbol. It generates a
3153 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3154 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3156 save_CFLAGS="$CFLAGS"
3157 CFLAGS="$CFLAGS -msse -Werror"
3158 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3159 do { long long int x;
3160 __asm__ __volatile__(
3161 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3164 ac_have_as_ssse3=yes
3165 AC_MSG_RESULT([yes])
3170 CFLAGS="$save_CFLAGS"
3172 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3175 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3176 # Note, this doesn't generate a C-level symbol. It generates a
3177 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3178 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3179 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3181 __asm__ __volatile__(
3182 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3185 ac_have_as_pclmulqdq=yes
3186 AC_MSG_RESULT([yes])
3188 ac_have_as_pclmulqdq=no
3192 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3195 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3196 # Note, this doesn't generate a C-level symbol. It generates a
3197 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3198 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3199 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3202 * Carry-less multiplication of xmm1 with xmm2 and store the result in
3203 * xmm3. The immediate is used to determine which quadwords of xmm1 and
3204 * xmm2 should be used.
3206 __asm__ __volatile__(
3207 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3210 ac_have_as_vpclmulqdq=yes
3211 AC_MSG_RESULT([yes])
3213 ac_have_as_vpclmulqdq=no
3217 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3220 # does the x86/amd64 assembler understand FMA4 instructions?
3221 # Note, this doesn't generate a C-level symbol. It generates a
3222 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3223 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3224 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3226 __asm__ __volatile__(
3227 "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3230 ac_have_as_vfmaddpd=yes
3231 AC_MSG_RESULT([yes])
3233 ac_have_as_vfmaddpd=no
3237 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3240 # does the x86/amd64 assembler understand the LZCNT instruction?
3241 # Note, this doesn't generate a C-level symbol. It generates a
3242 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3243 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3245 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3247 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3250 ac_have_as_lzcnt=yes
3251 AC_MSG_RESULT([yes])
3257 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3260 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3261 # Note, this doesn't generate a C-level symbol. It generates a
3262 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3263 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3265 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3267 __asm__ __volatile__("1: loopnel 1b\n");
3270 ac_have_as_loopnel=yes
3271 AC_MSG_RESULT([yes])
3273 ac_have_as_loopnel=no
3277 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3280 # does the x86/amd64 assembler understand ADDR32 ?
3281 # Note, this doesn't generate a C-level symbol. It generates a
3282 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3283 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3287 asm volatile ("addr32 rep movsb");
3290 ac_have_as_addr32=yes
3291 AC_MSG_RESULT([yes])
3293 ac_have_as_addr32=no
3297 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3300 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3301 # Note, this doesn't generate a C-level symbol. It generates a
3302 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3303 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3305 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3306 do { long long int x;
3307 __asm__ __volatile__(
3308 "crc32q %%r15,%%r15" : : : "r15" );
3309 __asm__ __volatile__(
3310 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
3311 __asm__ __volatile__(
3312 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3315 ac_have_as_sse42=yes
3316 AC_MSG_RESULT([yes])
3322 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3325 # does the x86/amd64 assembler understand AVX instructions?
3326 # Note, this doesn't generate a C-level symbol. It generates a
3327 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3328 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3330 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3331 do { long long int x;
3332 __asm__ __volatile__(
3333 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3334 __asm__ __volatile__(
3335 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3339 AC_MSG_RESULT([yes])
3345 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3348 # does the x86/amd64 assembler understand AVX2 instructions?
3349 # Note, this doesn't generate a C-level symbol. It generates a
3350 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3351 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3354 do { long long int x;
3355 __asm__ __volatile__(
3356 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3357 __asm__ __volatile__(
3358 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3362 AC_MSG_RESULT([yes])
3368 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3371 # does the x86/amd64 assembler understand TSX instructions and
3372 # the XACQUIRE/XRELEASE prefixes?
3373 # Note, this doesn't generate a C-level symbol. It generates a
3374 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3375 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3377 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3379 __asm__ __volatile__(
3382 " xacquire lock incq 0(%rsp) \n\t"
3383 " xrelease lock incq 0(%rsp) \n"
3388 AC_MSG_RESULT([yes])
3394 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3397 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3398 # Note, this doesn't generate a C-level symbol. It generates a
3399 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3400 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3403 do { unsigned int h, l;
3404 __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3405 __asm__ __volatile__(
3406 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3407 __asm__ __volatile__(
3408 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3412 AC_MSG_RESULT([yes])
3418 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3421 # does the x86/amd64 assembler understand FMA instructions?
3422 # Note, this doesn't generate a C-level symbol. It generates a
3423 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3424 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3426 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3427 do { unsigned int h, l;
3428 __asm__ __volatile__(
3429 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3430 __asm__ __volatile__(
3431 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3432 __asm__ __volatile__(
3433 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3437 AC_MSG_RESULT([yes])
3443 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3446 # does the amd64 assembler understand MPX instructions?
3447 # Note, this doesn't generate a C-level symbol. It generates a
3448 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3449 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3451 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3453 asm ("bndmov %bnd0,(%rsp)");
3454 asm ("bndldx 3(%rbx,%rdx), %bnd2");
3455 asm ("bnd call foo\n"
3462 AC_MSG_RESULT([yes])
3468 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3471 # does the amd64 assembler understand ADX instructions?
3472 # Note, this doesn't generate a C-level symbol. It generates a
3473 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3474 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3476 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3478 asm ("adcxq %r14,%r8");
3482 AC_MSG_RESULT([yes])
3488 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3491 # does the amd64 assembler understand the RDRAND instruction?
3492 # Note, this doesn't generate a C-level symbol. It generates a
3493 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3494 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3496 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3498 asm ("rdrand %r14");
3499 asm ("rdrand %r14d");
3500 asm ("rdrand %r14w");
3503 ac_have_as_rdrand=yes
3504 AC_MSG_RESULT([yes])
3506 ac_have_as_rdrand=no
3510 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3512 # does the amd64 assembler understand the RDSEED instruction?
3513 # Note, this doesn't generate a C-level symbol. It generates a
3514 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3515 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3517 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3519 asm ("rdseed %r14");
3520 asm ("rdseed %r14d");
3521 asm ("rdseed %r14w");
3524 ac_have_as_rdseed=yes
3525 AC_MSG_RESULT([yes])
3527 ac_have_as_rdseed=no
3531 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3533 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3535 # Note, this doesn't generate a C-level symbol. It generates a
3536 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3537 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3539 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3541 asm ("vcvtph2ps %xmm5, %ymm10");
3542 // If we put the dollar sign and zero together, the shell processing
3543 // this configure.ac script substitutes the command name in. Sigh.
3544 asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3548 AC_MSG_RESULT([yes])
3554 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3557 # does the x86/amd64 assembler understand MOVBE?
3558 # Note, this doesn't generate a C-level symbol. It generates a
3559 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3560 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3563 do { long long int x;
3564 __asm__ __volatile__(
3565 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3568 ac_have_as_movbe=yes
3569 AC_MSG_RESULT([yes])
3575 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3578 # Does the C compiler support the "ifunc" attribute
3579 # Note, this doesn't generate a C-level symbol. It generates a
3580 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3581 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3583 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3584 static void mytest(void) {}
3586 static void (*resolve_test(void))(void)
3588 return (void (*)(void))&mytest;
3591 void test(void) __attribute__((ifunc("resolve_test")));
3599 ac_have_ifunc_attr=yes
3600 AC_MSG_RESULT([yes])
3602 ac_have_ifunc_attr=no
3606 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3608 # Does the C compiler support the armv8 crc feature flag
3609 # Note, this doesn't generate a C-level symbol. It generates a
3610 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3611 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3613 save_CFLAGS="$CFLAGS"
3614 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3615 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3621 ac_have_armv8_crc_feature=yes
3622 AC_MSG_RESULT([yes])
3624 ac_have_armv8_crc_feature=no
3627 CFLAGS="$save_CFLAGS"
3629 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3632 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3633 # Note, this doesn't generate a C-level symbol. It generates a
3634 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3635 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3637 save_CFLAGS="$CFLAGS"
3638 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3639 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3642 __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3646 ac_have_armv81_feature=yes
3647 AC_MSG_RESULT([yes])
3649 ac_have_armv81_feature=no
3652 CFLAGS="$save_CFLAGS"
3654 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3657 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3658 # Note, this doesn't generate a C-level symbol. It generates a
3659 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3660 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3662 save_CFLAGS="$CFLAGS"
3663 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3664 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3667 __asm__ __volatile__("faddp h0, v1.2h");
3671 ac_have_armv82_feature=yes
3672 AC_MSG_RESULT([yes])
3674 ac_have_armv82_feature=no
3677 CFLAGS="$save_CFLAGS"
3679 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3682 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
3683 # when building the tool executables. I think we should get rid of it.
3685 # Check for TLS support in the compiler and linker
3686 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3688 [vg_cv_linktime_tls=yes],
3689 [vg_cv_linktime_tls=no])
3690 # Native compilation: check whether running a program using TLS succeeds.
3691 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3692 # succeeds but running programs using TLS fails.
3693 # Cross-compiling: check whether linking a program using TLS succeeds.
3694 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3695 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
3696 [vg_cv_tls=$enableval],
3697 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3701 [vg_cv_tls=$vg_cv_linktime_tls])])])
3703 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3704 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3708 #----------------------------------------------------------------------------
3709 # Solaris-specific checks.
3710 #----------------------------------------------------------------------------
3712 if test "$VGCONF_OS" = "solaris" ; then
3713 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3715 # Solaris-specific check determining if the Sun Studio Assembler is used to
3716 # build Valgrind. The test checks if the x86/amd64 assembler understands the
3717 # cmovl.l instruction, if yes then it's Sun Assembler.
3719 # C-level symbol: none
3720 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3722 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3723 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3725 __asm__ __volatile__("cmovl.l %edx, %eax");
3727 solaris_have_sun_studio_as=yes
3728 AC_MSG_RESULT([yes])
3730 solaris_have_sun_studio_as=no
3733 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3735 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3736 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3737 # See solaris/vgpreload-solaris.mapfile for details.
3738 # gcc on older Solaris instructs linker to include these symbols,
3739 # gcc on illumos and newer Solaris does not.
3741 # C-level symbol: none
3742 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3744 save_CFLAGS="$CFLAGS"
3745 CFLAGS="$CFLAGS -std=gnu99"
3746 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3747 temp_dir=$( /usr/bin/mktemp -d )
3748 cat <<_ACEOF >${temp_dir}/mylib.c
3750 int myfunc(void) { printf("LaPutyka\n"); }
3752 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3753 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3754 if test "x${xpg_present}" = "x" ; then
3755 solaris_xpg_symbols_present=no
3758 solaris_xpg_symbols_present=yes
3759 AC_MSG_RESULT([yes])
3762 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3763 CFLAGS="$save_CFLAGS"
3766 # Solaris-specific check determining if gcc enables largefile support by
3767 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3768 # variable with gcc flags which disable it.
3770 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3771 save_CFLAGS="$CFLAGS"
3772 CFLAGS="$CFLAGS -m32"
3773 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3774 return _LARGEFILE_SOURCE;
3776 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3777 AC_MSG_RESULT([yes])
3779 SOLARIS_UNDEF_LARGESOURCE=""
3783 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3786 # Solaris-specific check determining if /proc/self/cmdline
3787 # or /proc/<pid>/cmdline is supported.
3789 # C-level symbol: SOLARIS_PROC_CMDLINE
3790 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3792 AC_CHECK_FILE([/proc/self/cmdline],
3794 solaris_proc_cmdline=yes
3795 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3796 [Define to 1 if you have /proc/self/cmdline.])
3798 solaris_proc_cmdline=no
3800 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3803 # Solaris-specific check determining default platform for the Valgrind launcher.
3804 # Used in case the launcher cannot select platform by looking at the client
3805 # image (for example because the executable is a shell script).
3807 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3808 # Automake-level symbol: none
3810 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3811 # Get the ELF class of /bin/sh first.
3812 if ! test -f /bin/sh; then
3813 AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3815 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3816 case "$elf_class" in
3818 default_arch="$VGCONF_ARCH_PRI";
3821 if test "x$VGCONF_ARCH_SEC" != "x"; then
3822 default_arch="$VGCONF_ARCH_SEC"
3824 default_arch="$VGCONF_ARCH_PRI";
3828 AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3831 default_platform="$default_arch-$VGCONF_OS"
3832 AC_MSG_RESULT([$default_platform])
3833 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3834 [Default platform for Valgrind launcher.])
3837 # Solaris-specific check determining if the old syscalls are available.
3839 # C-level symbol: SOLARIS_OLD_SYSCALLS
3840 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3842 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3843 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3844 #include <sys/syscall.h>
3848 solaris_old_syscalls=yes
3849 AC_MSG_RESULT([yes])
3850 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3851 [Define to 1 if you have the old Solaris syscalls.])
3853 solaris_old_syscalls=no
3856 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3859 # Solaris-specific check determining if the new accept() syscall is available.
3862 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3865 # New syscall (available on illumos):
3866 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3867 # int version, int flags);
3869 # If the old syscall is present then the following syscall will fail with
3870 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3871 # available then it will fail with EINVAL (because the flags parameter is
3874 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3875 # Automake-level symbol: none
3877 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3878 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3879 #include <sys/syscall.h>
3883 syscall(SYS_accept, 0, 0, 0, 0, -1);
3884 return !(errno == EINVAL);
3886 AC_MSG_RESULT([yes])
3887 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3888 [Define to 1 if you have the new `accept' syscall.])
3894 # Solaris-specific check determining if the new illumos pipe() syscall is
3898 # longlong_t pipe();
3900 # New syscall (available on illumos):
3901 # int pipe(intptr_t arg, int flags);
3903 # If the old syscall is present then the following call will succeed, if the
3904 # new syscall is available then it will fail with EFAULT (because address 0
3905 # cannot be accessed).
3907 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3908 # Automake-level symbol: none
3910 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3911 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3912 #include <sys/syscall.h>
3916 syscall(SYS_pipe, 0, 0);
3917 return !(errno == EFAULT);
3919 AC_MSG_RESULT([yes])
3920 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3921 [Define to 1 if you have the new `pipe' syscall.])
3927 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3931 # int lwp_kill(id_t lwpid, int sig);
3933 # New syscall (available on Solaris 11):
3934 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3935 # int si_code, timespec_t *timeout);
3937 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3938 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3940 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3941 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3942 #include <sys/syscall.h>
3944 return !SYS_lwp_sigqueue;
3946 solaris_lwp_sigqueue_syscall=yes
3947 AC_MSG_RESULT([yes])
3948 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3949 [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3951 solaris_lwp_sigqueue_syscall=no
3954 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3957 # Solaris-specific check determining if the lwp_sigqueue() syscall
3958 # takes both pid and thread id arguments or just thread id.
3960 # Old syscall (available up to Solaris 11.3):
3961 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3962 # int si_code, timespec_t *timeout);
3964 # New syscall (available since Solaris 11.4):
3965 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3966 # int si_code, timespec_t *timeout);
3968 # If the old syscall is present then the following syscall will fail with
3969 # EINVAL (because signal is out of range); if the new syscall is available
3970 # then it will fail with ESRCH (because it would not find such thread in the
3973 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3974 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3976 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3977 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3978 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3979 #include <sys/syscall.h>
3983 syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3984 return !(errno == ESRCH);
3986 solaris_lwp_sigqueue_syscall_takes_pid=yes
3987 AC_MSG_RESULT([yes])
3988 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3989 [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3991 solaris_lwp_sigqueue_syscall_takes_pid=no
3994 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3995 test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3997 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
4001 # Solaris-specific check determining if the new lwp_name() syscall is
4004 # New syscall (available on Solaris 11):
4005 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
4007 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
4008 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
4010 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
4011 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4012 #include <sys/syscall.h>
4014 return !SYS_lwp_name;
4016 solaris_lwp_name_syscall=yes
4017 AC_MSG_RESULT([yes])
4018 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
4019 [Define to 1 if you have the new `lwp_name' syscall.])
4021 solaris_lwp_name_syscall=no
4024 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
4027 # Solaris-specific check determining if the new getrandom() syscall is
4030 # New syscall (available on Solaris 11):
4031 # int getrandom(void *buf, size_t buflen, uint_t flags);
4033 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
4034 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
4036 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
4037 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4038 #include <sys/syscall.h>
4040 return !SYS_getrandom;
4042 solaris_getrandom_syscall=yes
4043 AC_MSG_RESULT([yes])
4044 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
4045 [Define to 1 if you have the new `getrandom' syscall.])
4047 solaris_getrandom_syscall=no
4050 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
4053 # Solaris-specific check determining if the new zone() syscall subcodes
4054 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available. These subcodes
4055 # were added in Solaris 11 but are missing on illumos.
4057 # C-level symbol: SOLARIS_ZONE_DEFUNCT
4058 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
4060 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
4061 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4062 #include <sys/zone.h>
4064 return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
4066 solaris_zone_defunct=yes
4067 AC_MSG_RESULT([yes])
4068 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
4069 [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
4071 solaris_zone_defunct=no
4074 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
4077 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4078 # for auditon(2) subcode of the auditsys() syscall are available.
4079 # These commands are available in Solaris 11 and illumos but were removed
4082 # C-level symbol: SOLARIS_AUDITON_STAT
4083 # Automake-level symbol: SOLARIS_AUDITON_STAT
4085 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4086 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4087 #include <bsm/audit.h>
4089 return !(A_GETSTAT && A_SETSTAT);
4091 solaris_auditon_stat=yes
4092 AC_MSG_RESULT([yes])
4093 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4094 [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4096 solaris_auditon_stat=no
4099 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4102 # Solaris-specific check determining if the new shmsys() syscall subcodes
4103 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4104 # These subcodes were added in Solaris 11 but are missing on illumos.
4106 # C-level symbol: SOLARIS_SHM_NEW
4107 # Automake-level symbol: SOLARIS_SHM_NEW
4109 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4110 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4111 #include <sys/ipc_impl.h>
4112 #include <sys/shm.h>
4113 #include <sys/shm_impl.h>
4115 return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4118 AC_MSG_RESULT([yes])
4119 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4120 [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4125 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4128 # Solaris-specific check determining if prxregset_t is available. Illumos
4129 # currently does not define it on the x86 platform.
4131 # C-level symbol: SOLARIS_PRXREGSET_T
4132 # Automake-level symbol: SOLARIS_PRXREGSET_T
4134 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4135 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4136 #include <sys/procfs_isa.h>
4138 return !sizeof(prxregset_t);
4140 solaris_prxregset_t=yes
4141 AC_MSG_RESULT([yes])
4142 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4143 [Define to 1 if you have the `prxregset_t' type.])
4145 solaris_prxregset_t=no
4148 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4151 # Solaris-specific check determining if the new frealpathat() syscall is
4154 # New syscall (available on Solaris 11.1):
4155 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4157 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4158 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4160 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4161 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4162 #include <sys/syscall.h>
4164 return !SYS_frealpathat;
4166 solaris_frealpathat_syscall=yes
4167 AC_MSG_RESULT([yes])
4168 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4169 [Define to 1 if you have the new `frealpathat' syscall.])
4171 solaris_frealpathat_syscall=no
4174 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4177 # Solaris-specific check determining if the new uuidsys() syscall is
4180 # New syscall (available on newer Solaris):
4181 # int uuidsys(struct uuid *uuid);
4183 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4184 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4186 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4187 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4188 #include <sys/syscall.h>
4190 return !SYS_uuidsys;
4192 solaris_uuidsys_syscall=yes
4193 AC_MSG_RESULT([yes])
4194 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4195 [Define to 1 if you have the new `uuidsys' syscall.])
4197 solaris_uuidsys_syscall=no
4200 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4203 # Solaris-specific check determining if the new labelsys() syscall subcode
4204 # TNDB_GET_TNIP is available. This subcode was added in Solaris 11 but is
4205 # missing on illumos.
4207 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4208 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4210 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4211 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4212 #include <sys/tsol/tndb.h>
4214 return !TNDB_GET_TNIP;
4216 solaris_tndb_get_tnip=yes
4217 AC_MSG_RESULT([yes])
4218 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4219 [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4221 solaris_tndb_get_tnip=no
4224 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4227 # Solaris-specific check determining if the new labelsys() syscall opcodes
4228 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4229 # added in Solaris 11 but are missing on illumos.
4231 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4232 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4234 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4235 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4236 #include <sys/tsol/tsyscall.h>
4238 return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4240 solaris_tsol_clearance=yes
4241 AC_MSG_RESULT([yes])
4242 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4243 [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4245 solaris_tsol_clearance=no
4248 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4251 # Solaris-specific check determining if the new pset() syscall subcode
4252 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4253 # is missing on illumos and Solaris 11.3.
4255 # C-level symbol: SOLARIS_PSET_GET_NAME
4256 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4258 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4259 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4260 #include <sys/pset.h>
4262 return !(PSET_GET_NAME);
4264 solaris_pset_get_name=yes
4265 AC_MSG_RESULT([yes])
4266 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4267 [Define to 1 if you have the `PSET_GET_NAME' constants.])
4269 solaris_pset_get_name=no
4272 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4275 # Solaris-specific check determining if the utimesys() syscall is
4276 # available (on illumos and older Solaris).
4278 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4279 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4281 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4282 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4283 #include <sys/syscall.h>
4285 return !SYS_utimesys;
4287 solaris_utimesys_syscall=yes
4288 AC_MSG_RESULT([yes])
4289 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4290 [Define to 1 if you have the `utimesys' syscall.])
4292 solaris_utimesys_syscall=no
4295 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4298 # Solaris-specific check determining if the utimensat() syscall is
4299 # available (on newer Solaris).
4301 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4302 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4304 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4305 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4306 #include <sys/syscall.h>
4308 return !SYS_utimensat;
4310 solaris_utimensat_syscall=yes
4311 AC_MSG_RESULT([yes])
4312 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4313 [Define to 1 if you have the `utimensat' syscall.])
4315 solaris_utimensat_syscall=no
4318 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4321 # Solaris-specific check determining if the spawn() syscall is available
4322 # (on newer Solaris).
4324 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4325 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4327 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4328 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4329 #include <sys/syscall.h>
4333 solaris_spawn_syscall=yes
4334 AC_MSG_RESULT([yes])
4335 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4336 [Define to 1 if you have the `spawn' syscall.])
4338 solaris_spawn_syscall=no
4341 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4344 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4345 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4347 # C-level symbol: SOLARIS_MODCTL_MODNVL
4348 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4350 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4351 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4352 #include <sys/modctl.h>
4354 return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4356 solaris_modctl_modnvl=yes
4357 AC_MSG_RESULT([yes])
4358 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4359 [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4361 solaris_modctl_modnvl=no
4364 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4367 # Solaris-specific check determining whether nscd (name switch cache daemon)
4368 # attaches its door at /system/volatile/name_service_door (Solaris)
4369 # or at /var/run/name_service_door (illumos).
4371 # Note that /var/run is a symlink to /system/volatile on Solaris
4372 # but not vice versa on illumos.
4374 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4375 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4377 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4378 if test -e /system/volatile/name_service_door; then
4379 solaris_nscd_door_system_volatile=yes
4380 AC_MSG_RESULT([/system/volatile/name_service_door])
4381 AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4382 [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4384 solaris_nscd_door_system_volatile=no
4385 AC_MSG_RESULT([/var/run/name_service_door])
4387 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4390 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4392 # New fasttrap (available on Solaris 11):
4393 # hrt_t *gethrt(void);
4395 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4396 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4398 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4399 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4400 #include <sys/trap.h>
4404 solaris_gethrt_fasttrap=yes
4405 AC_MSG_RESULT([yes])
4406 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4407 [Define to 1 if you have the new `gethrt' fasttrap.])
4409 solaris_gethrt_fasttrap=no
4412 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4415 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4418 # New fasttrap (available on Solaris 11):
4419 # zonehrtoffset_t *get_zone_offset(void);
4421 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4422 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4424 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4425 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4426 #include <sys/trap.h>
4428 return !T_GETZONEOFFSET;
4430 solaris_getzoneoffset_fasttrap=yes
4431 AC_MSG_RESULT([yes])
4432 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4433 [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4435 solaris_getzoneoffset_fasttrap=no
4438 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4441 # Solaris-specific check determining if the execve() syscall
4442 # takes fourth argument (flags) or not.
4444 # Old syscall (available on illumos):
4445 # int execve(const char *fname, const char **argv, const char **envp);
4447 # New syscall (available on Solaris):
4448 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4450 # If the new syscall is present then it will fail with EINVAL (because flags
4451 # are invalid); if the old syscall is available then it will fail with ENOENT
4452 # (because the file could not be found).
4454 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4455 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4457 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4458 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4459 #include <sys/syscall.h>
4463 syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4464 return !(errno == EINVAL);
4466 solaris_execve_syscall_takes_flags=yes
4467 AC_MSG_RESULT([yes])
4468 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4469 [Define to 1 if you have the new `execve' syscall which accepts flags.])
4471 solaris_execve_syscall_takes_flags=no
4474 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4475 test x$solaris_execve_syscall_takes_flags = xyes)
4478 # Solaris-specific check determining version of the repository cache protocol.
4479 # Every Solaris version uses a different one, ranging from 21 to current 25.
4480 # The check is very ugly, though.
4482 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4483 # Automake-level symbol: none
4485 AC_PATH_PROG(DIS_PATH, dis, false)
4486 if test "x$DIS_PATH" = "xfalse"; then
4487 AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4489 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4490 AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4491 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4494 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4495 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4496 libscf=/usr/lib/64/libscf.so.1
4498 libscf=/usr/lib/libscf.so.1
4500 if ! $DIS_PATH -F scf_handle_bind $libscf | grep -q 0x526570; then
4501 AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4502 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4504 hex=$( $DIS_PATH -F scf_handle_bind $libscf | sed -n 's/.*0x526570\(..\).*/\1/p' )
4505 if test -z "$hex"; then
4506 AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4507 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4509 version=$( printf "%d\n" 0x$hex )
4510 AC_MSG_RESULT([$version])
4511 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4512 [Version number of the repository door cache protocol.])
4515 # Solaris-specific check determining if "sysstat" segment reservation type
4518 # New "sysstat" segment reservation (available on Solaris 11.4):
4519 # - program header type: PT_SUNW_SYSSTAT
4520 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4522 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4523 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4525 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4527 #include <sys/auxv.h>
4529 return !AT_SUN_SYSSTAT_ADDR;
4531 solaris_reserve_sysstat_addr=yes
4532 AC_MSG_RESULT([yes])
4533 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4534 [Define to 1 if you have the new `sysstat' segment reservation.])
4536 solaris_reserve_sysstat_addr=no
4539 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4542 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4545 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4546 # - program header type: PT_SUNW_SYSSTAT_ZONE
4547 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4549 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4550 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4552 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4553 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4554 #include <sys/auxv.h>
4556 return !AT_SUN_SYSSTAT_ZONE_ADDR;
4558 solaris_reserve_sysstat_zone_addr=yes
4559 AC_MSG_RESULT([yes])
4560 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4561 [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4563 solaris_reserve_sysstat_zone_addr=no
4566 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4569 # Solaris-specific check determining if the system_stats() syscall is available
4570 # (on newer Solaris).
4572 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4573 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4575 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4576 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4577 #include <sys/syscall.h>
4579 return !SYS_system_stats;
4581 solaris_system_stats_syscall=yes
4582 AC_MSG_RESULT([yes])
4583 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4584 [Define to 1 if you have the `system_stats' syscall.])
4586 solaris_system_stats_syscall=no
4589 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4592 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4593 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4595 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4596 # Automake-level symbol: none
4598 AC_CHECK_TYPE([struct _fpchip_state],
4599 [solaris_fpchip_state_takes_underscore=yes],
4600 [solaris_fpchip_state_takes_underscore=no],
4601 [[#include <sys/regset.h>]])
4602 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4603 AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4604 [Define to 1 if fpregset_t defines struct _fpchip_state])
4608 # Solaris-specific check determining if schedctl page shared between kernel
4609 # and userspace program is executable (illumos, older Solaris) or not (newer
4612 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4613 # Automake-level symbol: none
4615 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4616 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4620 #include <schedctl.h>
4624 schedctl_t *scp = schedctl_init();
4628 int fd = open("/proc/self/map", O_RDONLY);
4633 while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4634 if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4635 fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4636 (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4637 return (map.pr_mflags & MA_EXEC);
4643 solaris_schedctl_page_exec=no
4646 solaris_schedctl_page_exec=yes
4647 AC_MSG_RESULT([yes])
4648 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4649 [Define to 1 if you have the schedctl page executable.])
4653 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4654 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4655 # an initial thread pointer for libc (newer Solaris).
4657 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4658 # Automake-level symbol: none
4660 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4661 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4662 #include <sys/fasttrap_isa.h>
4664 return !FT_SCRATCHSIZE;
4666 solaris_pt_sunwdtrace_thrp=yes
4667 AC_MSG_RESULT([yes])
4668 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4669 [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4671 solaris_pt_sunwdtrace_thrp=no
4676 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4677 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4678 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4679 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4680 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4681 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4682 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4683 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4684 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4685 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4686 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4687 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4688 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4689 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4690 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4691 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4692 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4693 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4694 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4695 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4696 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4697 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4698 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4699 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4700 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4701 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4702 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4703 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4704 fi # test "$VGCONF_OS" = "solaris"
4706 #----------------------------------------------------------------------------
4707 # FreeBSD-specific checks.
4708 #----------------------------------------------------------------------------
4710 # Rather than having a large number of feature test as above with Solaris
4711 # these tests are per-version. This may not be entirely relialable for
4712 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4713 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4715 if test "$VGCONF_OS" = "freebsd" ; then
4717 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4721 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4723 fi # test "$VGCONF_OS" = "freebsd"
4726 #----------------------------------------------------------------------------
4727 # Checks for C header files.
4728 #----------------------------------------------------------------------------
4730 AC_CHECK_HEADERS([ \
4748 # Verify whether the <linux/futex.h> header is usable.
4749 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4751 save_CFLAGS="$CFLAGS"
4752 CFLAGS="$CFLAGS -D__user="
4753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4754 #include <linux/futex.h>
4758 ac_have_usable_linux_futex_h=yes
4759 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4760 [Define to 1 if you have a usable <linux/futex.h> header file.])
4761 AC_MSG_RESULT([yes])
4763 ac_have_usable_linux_futex_h=no
4766 CFLAGS="$save_CFLAGS"
4769 #----------------------------------------------------------------------------
4770 # Checks for typedefs, structures, and compiler characteristics.
4771 #----------------------------------------------------------------------------
4775 AC_CHECK_HEADERS_ONCE([sys/time.h])
4777 AC_CHECK_TYPE([struct statx], [
4778 AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4779 [Define to 1 if <sys/stat.h> declares struct statx.])
4782 #include <sys/stat.h>
4786 #----------------------------------------------------------------------------
4787 # Checks for library functions.
4788 #----------------------------------------------------------------------------
4792 AC_CHECK_LIB([pthread], [pthread_create])
4793 AC_CHECK_LIB([rt], [clock_gettime])
4812 pthread_barrier_init \
4813 pthread_condattr_setclock \
4814 pthread_mutex_timedlock \
4815 pthread_rwlock_timedrdlock \
4816 pthread_rwlock_timedwrlock \
4817 pthread_setname_np \
4843 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4844 # libraries with any shared object and/or executable. This is NOT what we
4845 # want for e.g. vgpreload_core-x86-linux.so
4848 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4849 [test x$ac_cv_func_pthread_barrier_init = xyes])
4850 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4851 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4852 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4853 [test x$ac_cv_func_pthread_spin_lock = xyes])
4854 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4855 [test x$ac_cv_func_pthread_setname_np = xyes])
4856 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4857 [test x$ac_cv_func_copy_file_range = xyes])
4858 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4859 [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4860 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4861 [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4862 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4863 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4864 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4865 [test x$ac_cv_func_memfd_create = xyes])
4867 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4868 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4869 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4870 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4871 [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4874 #----------------------------------------------------------------------------
4876 #----------------------------------------------------------------------------
4877 # Do we have a useable MPI setup on the primary and/or secondary targets?
4878 # On Linux, by default, assumes mpicc and -m32/-m64
4879 # Note: this is a kludge in that it assumes the specified mpicc
4880 # understands -m32/-m64 regardless of what is specified using
4882 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4883 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4886 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4887 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4888 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4889 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4890 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4891 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4892 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4893 mflag_primary=$FLAG_M32
4894 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4895 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4896 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4897 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4898 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4899 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4900 mflag_primary=$FLAG_M64
4901 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4902 mflag_primary="$FLAG_M32 -arch i386"
4903 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4904 mflag_primary="$FLAG_M64 -arch x86_64"
4908 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4909 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4910 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4911 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4912 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4913 mflag_secondary=$FLAG_M32
4914 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4915 mflag_secondary="$FLAG_M32 -arch i386"
4920 [ --with-mpicc= Specify name of MPI2-ised C compiler],
4925 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4926 ## use these values in the check for a functioning mpicc.
4928 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4929 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4930 AM_COND_IF([VGCONF_OS_IS_LINUX],
4931 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4932 LDFLAGS_MPI="-fpic -shared"])
4933 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
4934 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4935 LDFLAGS_MPI="-fpic -shared"])
4936 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4937 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4938 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4939 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4940 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4941 LDFLAGS_MPI="-fpic -shared"])
4943 AC_SUBST([CFLAGS_MPI])
4944 AC_SUBST([LDFLAGS_MPI])
4947 ## See if MPI_CC works for the primary target
4949 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4951 saved_CFLAGS=$CFLAGS
4953 CFLAGS="$CFLAGS_MPI $mflag_primary"
4954 saved_LDFLAGS="$LDFLAGS"
4955 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4956 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4960 int ni, na, nd, comb;
4961 int r = MPI_Init(NULL,NULL);
4962 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4963 r |= MPI_Finalize();
4966 ac_have_mpi2_pri=yes
4967 AC_MSG_RESULT([yes, $MPI_CC])
4973 CFLAGS=$saved_CFLAGS
4974 LDFLAGS="$saved_LDFLAGS"
4975 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4977 ## See if MPI_CC works for the secondary target. Complication: what if
4978 ## there is no secondary target? We need this to then fail.
4979 ## Kludge this by making MPI_CC something which will surely fail in
4982 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4984 saved_CFLAGS=$CFLAGS
4985 saved_LDFLAGS="$LDFLAGS"
4986 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4987 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4988 CC="$MPI_CC this will surely fail"
4992 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4993 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4997 int ni, na, nd, comb;
4998 int r = MPI_Init(NULL,NULL);
4999 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5000 r |= MPI_Finalize();
5003 ac_have_mpi2_sec=yes
5004 AC_MSG_RESULT([yes, $MPI_CC])
5010 CFLAGS=$saved_CFLAGS
5011 LDFLAGS="$saved_LDFLAGS"
5012 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
5015 #----------------------------------------------------------------------------
5016 # Other library checks
5017 #----------------------------------------------------------------------------
5018 # There now follow some tests for Boost, and OpenMP. These
5019 # tests are present because Drd has some regression tests that use
5020 # these packages. All regression test programs all compiled only
5021 # for the primary target. And so it is important that the configure
5022 # checks that follow, use the correct -m32 or -m64 flag for the
5023 # primary target (called $mflag_primary). Otherwise, we can end up
5024 # in a situation (eg) where, on amd64-linux, the test for Boost checks
5025 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
5026 # only build (meaning, the primary target is x86-linux), the build
5027 # of the regtest programs that use Boost fails, because they are
5028 # build as 32-bit (IN THIS EXAMPLE).
5030 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
5031 # NEEDED BY THE REGRESSION TEST PROGRAMS.
5034 # Check whether the boost library 1.35 or later has been installed.
5035 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
5037 AC_MSG_CHECKING([for boost])
5040 safe_CXXFLAGS=$CXXFLAGS
5041 CXXFLAGS="$mflag_primary"
5043 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
5045 AC_LINK_IFELSE([AC_LANG_SOURCE([
5046 #include <boost/thread.hpp>
5047 static void thread_func(void)
5049 int main(int argc, char** argv)
5051 boost::thread t(thread_func);
5056 ac_have_boost_1_35=yes
5057 AC_SUBST([BOOST_CFLAGS], [])
5058 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
5059 AC_MSG_RESULT([yes])
5061 ac_have_boost_1_35=no
5066 CXXFLAGS=$safe_CXXFLAGS
5069 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
5072 # does this compiler support -fopenmp, does it have the include file
5073 # <omp.h> and does it have libgomp ?
5075 AC_MSG_CHECKING([for OpenMP])
5078 CFLAGS="-fopenmp $mflag_primary -Werror"
5080 AC_LINK_IFELSE([AC_LANG_SOURCE([
5082 int main(int argc, char** argv)
5090 AC_MSG_RESULT([yes])
5097 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5100 # Check for __builtin_popcount
5101 AC_MSG_CHECKING([for __builtin_popcount()])
5102 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5104 __builtin_popcount(2);
5107 AC_MSG_RESULT([yes])
5108 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5109 [Define to 1 if compiler provides __builtin_popcount().])
5114 # Check for __builtin_clz
5115 AC_MSG_CHECKING([for __builtin_clz()])
5116 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5121 AC_MSG_RESULT([yes])
5122 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5123 [Define to 1 if compiler provides __builtin_clz().])
5128 # Check for __builtin_ctz
5129 AC_MSG_CHECKING([for __builtin_ctz()])
5130 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5135 AC_MSG_RESULT([yes])
5136 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5137 [Define to 1 if compiler provides __builtin_ctz().])
5142 # does this compiler have built-in functions for atomic memory access for the
5144 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5147 CFLAGS="$mflag_primary"
5149 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5151 return (__sync_bool_compare_and_swap(&variable, 1, 2)
5152 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5154 ac_have_builtin_atomic_primary=yes
5155 AC_MSG_RESULT([yes])
5156 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])
5158 ac_have_builtin_atomic_primary=no
5164 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5165 [test x$ac_have_builtin_atomic_primary = xyes])
5168 # does this compiler have built-in functions for atomic memory access for the
5169 # secondary target ?
5171 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5173 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5176 CFLAGS="$mflag_secondary"
5178 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5180 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5182 ac_have_builtin_atomic_secondary=yes
5183 AC_MSG_RESULT([yes])
5185 ac_have_builtin_atomic_secondary=no
5193 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5194 [test x$ac_have_builtin_atomic_secondary = xyes])
5196 # does this compiler have built-in functions for atomic memory access on
5197 # 64-bit integers for all targets ?
5199 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5201 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5204 uint64_t variable = 1;
5205 return __sync_add_and_fetch(&variable, 1)
5207 ac_have_builtin_atomic64_primary=yes
5209 ac_have_builtin_atomic64_primary=no
5212 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5215 CFLAGS="$mflag_secondary"
5217 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5220 uint64_t variable = 1;
5221 return __sync_add_and_fetch(&variable, 1)
5223 ac_have_builtin_atomic64_secondary=yes
5225 ac_have_builtin_atomic64_secondary=no
5232 if test x$ac_have_builtin_atomic64_primary = xyes && \
5233 test x$VGCONF_PLATFORM_SEC_CAPS = x \
5234 -o x$ac_have_builtin_atomic64_secondary = xyes; then
5235 AC_MSG_RESULT([yes])
5236 ac_have_builtin_atomic64=yes
5239 ac_have_builtin_atomic64=no
5242 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5243 [test x$ac_have_builtin_atomic64 = xyes])
5246 AC_MSG_CHECKING([if platform has openat2 syscall])
5248 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5249 #include <sys/syscall.h>
5258 AM_CONDITIONAL([HAVE_OPENAT2],
5259 [test x$ac_have_openat2 = xyes])
5261 # does g++ have built-in functions for atomic memory access ?
5262 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5264 safe_CXXFLAGS=$CXXFLAGS
5265 CXXFLAGS="$mflag_primary"
5268 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5270 return (__sync_bool_compare_and_swap(&variable, 1, 2)
5271 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5273 ac_have_builtin_atomic_cxx=yes
5274 AC_MSG_RESULT([yes])
5275 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5277 ac_have_builtin_atomic_cxx=no
5282 CXXFLAGS=$safe_CXXFLAGS
5284 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5287 if test x$ac_have_usable_linux_futex_h = xyes \
5288 -a x$ac_have_builtin_atomic_primary = xyes; then
5289 ac_enable_linux_ticket_lock_primary=yes
5291 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5292 [test x$ac_enable_linux_ticket_lock_primary = xyes])
5294 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5295 -a x$ac_have_usable_linux_futex_h = xyes \
5296 -a x$ac_have_builtin_atomic_secondary = xyes; then
5297 ac_enable_linux_ticket_lock_secondary=yes
5299 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5300 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5303 # does libstdc++ support annotating shared pointers ?
5304 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5306 safe_CXXFLAGS=$CXXFLAGS
5307 CXXFLAGS="-std=c++0x"
5310 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5313 std::shared_ptr<int> p
5315 ac_have_shared_ptr=yes
5317 ac_have_shared_ptr=no
5319 if test x$ac_have_shared_ptr = xyes; then
5320 # If compilation of the program below fails because of a syntax error
5321 # triggered by substituting one of the annotation macros then that
5322 # means that libstdc++ supports these macros.
5323 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5324 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5325 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5328 std::shared_ptr<int> p
5330 ac_have_shared_pointer_annotation=no
5333 ac_have_shared_pointer_annotation=yes
5334 AC_MSG_RESULT([yes])
5335 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5336 [Define to 1 if libstd++ supports annotating shared pointers])
5339 ac_have_shared_pointer_annotation=no
5344 CXXFLAGS=$safe_CXXFLAGS
5346 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5347 [test x$ac_have_shared_pointer_annotation = xyes])
5350 #----------------------------------------------------------------------------
5351 # Ok. We're done checking.
5352 #----------------------------------------------------------------------------
5354 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5357 VEX/Makefile:Makefile.vex.in
5361 glibc-2.X-helgrind.supp
5365 docs/xml/vg-entities.xml
5370 gdbserver_tests/Makefile
5371 gdbserver_tests/solaris/Makefile
5377 memcheck/tests/Makefile
5378 memcheck/tests/common/Makefile
5379 memcheck/tests/amd64/Makefile
5380 memcheck/tests/x86/Makefile
5381 memcheck/tests/linux/Makefile
5382 memcheck/tests/linux/debuginfod-check.vgtest
5383 memcheck/tests/darwin/Makefile
5384 memcheck/tests/solaris/Makefile
5385 memcheck/tests/freebsd/Makefile
5386 memcheck/tests/amd64-linux/Makefile
5387 memcheck/tests/arm64-linux/Makefile
5388 memcheck/tests/x86-linux/Makefile
5389 memcheck/tests/amd64-solaris/Makefile
5390 memcheck/tests/x86-solaris/Makefile
5391 memcheck/tests/amd64-freebsd/Makefile
5392 memcheck/tests/x86-freebsd/Makefile
5393 memcheck/tests/ppc32/Makefile
5394 memcheck/tests/ppc64/Makefile
5395 memcheck/tests/s390x/Makefile
5396 memcheck/tests/mips32/Makefile
5397 memcheck/tests/mips64/Makefile
5398 memcheck/tests/vbit-test/Makefile
5400 cachegrind/tests/Makefile
5401 cachegrind/tests/x86/Makefile
5402 cachegrind/cg_annotate
5405 callgrind/callgrind_annotate
5406 callgrind/callgrind_control
5407 callgrind/tests/Makefile
5409 helgrind/tests/Makefile
5411 drd/scripts/download-and-build-splash2
5414 massif/tests/Makefile
5419 lackey/tests/Makefile
5422 none/tests/scripts/Makefile
5423 none/tests/amd64/Makefile
5424 none/tests/ppc32/Makefile
5425 none/tests/ppc64/Makefile
5426 none/tests/x86/Makefile
5427 none/tests/arm/Makefile
5428 none/tests/arm64/Makefile
5429 none/tests/s390x/Makefile
5430 none/tests/mips32/Makefile
5431 none/tests/mips64/Makefile
5432 none/tests/nanomips/Makefile
5433 none/tests/linux/Makefile
5434 none/tests/darwin/Makefile
5435 none/tests/solaris/Makefile
5436 none/tests/freebsd/Makefile
5437 none/tests/amd64-linux/Makefile
5438 none/tests/x86-linux/Makefile
5439 none/tests/amd64-darwin/Makefile
5440 none/tests/x86-darwin/Makefile
5441 none/tests/amd64-solaris/Makefile
5442 none/tests/x86-solaris/Makefile
5443 none/tests/x86-freebsd/Makefile
5445 exp-bbv/tests/Makefile
5446 exp-bbv/tests/x86/Makefile
5447 exp-bbv/tests/x86-linux/Makefile
5448 exp-bbv/tests/amd64-linux/Makefile
5449 exp-bbv/tests/ppc32-linux/Makefile
5450 exp-bbv/tests/arm-linux/Makefile
5454 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5455 [chmod +x coregrind/link_tool_exe_linux])
5456 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5457 [chmod +x coregrind/link_tool_exe_freebsd])
5458 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5459 [chmod +x coregrind/link_tool_exe_darwin])
5460 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5461 [chmod +x coregrind/link_tool_exe_solaris])
5462 AC_CONFIG_FILES([tests/filter_stderr_basic],
5463 [chmod +x tests/filter_stderr_basic])
5464 AC_CONFIG_FILES([tests/filter_discards],
5465 [chmod +x tests/filter_discards])
5466 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5467 [chmod +x memcheck/tests/filter_stderr])
5468 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5469 [chmod +x memcheck/tests/filter_dw4])
5470 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5471 [chmod +x memcheck/tests/filter_overlaperror])
5472 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5473 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5474 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5475 [chmod +x gdbserver_tests/filter_gdb])
5476 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5477 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5478 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5479 [chmod +x gdbserver_tests/filter_stderr])
5480 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5481 [chmod +x gdbserver_tests/filter_vgdb])
5482 AC_CONFIG_FILES([drd/tests/filter_stderr],
5483 [chmod +x drd/tests/filter_stderr])
5484 AC_CONFIG_FILES([drd/tests/filter_error_count],
5485 [chmod +x drd/tests/filter_error_count])
5486 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5487 [chmod +x drd/tests/filter_error_summary])
5488 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5489 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5490 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5491 [chmod +x drd/tests/filter_thread_no])
5492 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5493 [chmod +x drd/tests/filter_xml_and_thread_no])
5494 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5495 [chmod +x helgrind/tests/filter_stderr])
5501 Maximum build arch: ${ARCH_MAX}
5502 Primary build arch: ${VGCONF_ARCH_PRI}
5503 Secondary build arch: ${VGCONF_ARCH_SEC}
5504 Build OS: ${VGCONF_OS}
5505 Link Time Optimisation: ${vg_cv_lto}
5506 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5507 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5508 Platform variant: ${VGCONF_PLATVARIANT}
5509 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5510 Default supp files: ${DEFAULT_SUPP}