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.
11 AC_INIT([Valgrind],[3.16.0.GIT],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
18 #----------------------------------------------------------------------------
19 # Do NOT modify these flags here. Except in feature tests in which case
20 # the original values must be properly restored.
21 #----------------------------------------------------------------------------
25 #----------------------------------------------------------------------------
26 # Checks for various programs.
27 #----------------------------------------------------------------------------
34 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
35 # autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
36 # base (eg. most likely as Darwin-specific tests) we'll need one of the
38 # - put AC_PROG_OBJC in a Darwin-specific part of this file
39 # - Use AC_PROG_OBJC here and up the minimum autoconf version
40 # - Use the following, which is apparently equivalent:
41 # m4_ifdef([AC_PROG_OBJC],
43 # [AC_CHECK_TOOL([OBJC], [gcc])
45 # AC_SUBST([OBJCFLAGS])
48 # Set LTO_RANLIB variable to an lto enabled ranlib
49 if test "x$LTO_RANLIB" = "x"; then
50 AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
52 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
54 # provide a very basic definition for AC_PROG_SED if it's not provided by
55 # autoconf (as e.g. in autoconf 2.59).
56 m4_ifndef([AC_PROG_SED],
57 [AC_DEFUN([AC_PROG_SED],
59 AC_CHECK_PROGS([SED],[gsed sed])])])
62 # If no AR variable was specified, look up the name of the archiver. Otherwise
63 # do not touch the AR variable.
64 if test "x$AR" = "x"; then
65 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
67 AC_ARG_VAR([AR],[Archiver command])
69 # same for LTO_AR variable for lto enabled archiver
70 if test "x$LTO_AR" = "x"; then
71 AC_PATH_PROGS([LTO_AR], [gcc-ar])
73 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
76 # Check for the compiler support
77 if test "${GCC}" != "yes" ; then
78 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
81 # figure out where perl lives
82 AC_PATH_PROG(PERL, perl)
84 # figure out where gdb lives
85 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
86 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
88 # some older automake's don't have it so try something on our own
89 ifdef([AM_PROG_AS],[AM_PROG_AS],
99 # Check if 'diff' supports -u (universal diffs) and use it if possible.
101 AC_MSG_CHECKING([for diff -u])
104 # Comparing two identical files results in 0.
105 tmpfile="tmp-xxx-yyy-zzz"
107 if diff -u $tmpfile $tmpfile ; then
116 # Make sure we can compile in C99 mode.
118 if test "$ac_cv_prog_cc_c99" == "no"; then
119 AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
122 # We don't want gcc < 3.0
123 AC_MSG_CHECKING([for a supported version of gcc])
125 # Obtain the compiler version.
127 # A few examples of how the ${CC} --version output looks like:
129 # ######## gcc variants ########
130 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
131 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
132 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
133 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
134 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
135 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
136 # 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)
138 # ######## clang variants ########
139 # Clang: clang version 2.9 (tags/RELEASE_29/final)
140 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
141 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
143 # ######## Apple LLVM variants ########
144 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
145 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
148 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
151 gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
152 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
155 # Don't use -dumpversion with clang: it will always produce "4.2.1".
156 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
157 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ;
160 gcc_version=`${CC} -dumpversion 2>/dev/null`
163 gcc_version=`${CC} -dumpversion 2>/dev/null`
164 if test "x$gcc_version" = x; then
165 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
169 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
170 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
172 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
173 # statements have to be quoted.
174 case "${is_clang}-${gcc_version}" in
175 applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
176 AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
179 AC_MSG_RESULT([ok (ICC version ${gcc_version})])
181 notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
182 AC_MSG_RESULT([ok (${gcc_version})])
184 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
185 AC_MSG_RESULT([ok (clang-${gcc_version})])
188 AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
189 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
193 #----------------------------------------------------------------------------
194 # Arch/OS/platform tests.
195 #----------------------------------------------------------------------------
196 # We create a number of arch/OS/platform-related variables. We prefix them
197 # all with "VGCONF_" which indicates that they are defined at
198 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
199 # variables used when compiling C files.
203 AC_MSG_CHECKING([for a supported CPU])
205 # ARCH_MAX reflects the most that this CPU can do: for example if it
206 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
207 # Ditto for amd64. It is used for more configuration below, but is not used
210 # Power PC returns powerpc for Big Endian. This was not changed when Little
211 # Endian support was added to the 64-bit architecture. The 64-bit Little
212 # Endian systems explicitly state le in the host_cpu. For clarity in the
213 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
214 # the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
215 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
216 # Endianness. The name PPC64 or ppc64 to 64-bit systems of either Endianness.
217 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
218 # Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
221 case "${host_cpu}" in
223 AC_MSG_RESULT([ok (${host_cpu})])
228 AC_MSG_RESULT([ok (${host_cpu})])
233 # this only referrs to 64-bit Big Endian
234 AC_MSG_RESULT([ok (${host_cpu})])
239 # this only referrs to 64-bit Little Endian
240 AC_MSG_RESULT([ok (${host_cpu})])
245 # On Linux this means only a 32-bit capable CPU.
246 AC_MSG_RESULT([ok (${host_cpu})])
251 AC_MSG_RESULT([ok (${host_cpu})])
256 AC_MSG_RESULT([ok (${host_cpu})])
261 AC_MSG_RESULT([ok (${host_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})])
290 AC_MSG_RESULT([ok (${host_cpu})])
295 AC_MSG_RESULT([no (${host_cpu})])
296 AC_MSG_ERROR([Unsupported host architecture. Sorry])
300 #----------------------------------------------------------------------------
302 # Sometimes it's convenient to subvert the bi-arch build system and
303 # just have a single build even though the underlying platform is
304 # capable of both. Hence handle --enable-only64bit and
305 # --enable-only32bit. Complain if both are issued :-)
306 # [Actually, if either of these options are used, I think both get built,
307 # but only one gets installed. So if you use an in-place build, both can be
310 # Check if a 64-bit only build has been requested
311 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
312 [AC_ARG_ENABLE(only64bit,
313 [ --enable-only64bit do a 64-bit only build],
314 [vg_cv_only64bit=$enableval],
315 [vg_cv_only64bit=no])])
317 # Check if a 32-bit only build has been requested
318 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
319 [AC_ARG_ENABLE(only32bit,
320 [ --enable-only32bit do a 32-bit only build],
321 [vg_cv_only32bit=$enableval],
322 [vg_cv_only32bit=no])])
325 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
327 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
330 #----------------------------------------------------------------------------
332 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
333 # compilation of many C files via -VGO_$(VGCONF_OS) and
334 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
335 AC_MSG_CHECKING([for a supported OS])
342 AC_MSG_RESULT([ok (${host_os})])
345 # Ok, this is linux. Check the kernel version
346 AC_MSG_CHECKING([for the kernel version])
351 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*)
352 AC_MSG_RESULT([unsupported (${kernel})])
353 AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
357 AC_MSG_RESULT([2.6 or later (${kernel})])
364 AC_MSG_RESULT([ok (${host_os})])
366 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
367 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
368 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
369 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
370 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
371 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
372 AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
373 AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
374 AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
376 AC_MSG_CHECKING([for the kernel version])
379 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
380 # has only one relevant version, the OS version. The `uname` check
381 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
382 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
383 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
384 # and we don't know of an macros similar to __GLIBC__ to get that info.
386 # XXX: `uname -r` won't do the right thing for cross-compiles, but
387 # that's not a problem yet.
389 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
390 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
391 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
392 # time support for 10.5 (the 9.* pattern just below), I'll leave it
393 # in for now, just in case anybody wants to give it a try. But I'm
394 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
397 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
398 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
399 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
400 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
403 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
404 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
405 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
406 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
409 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
410 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
411 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
412 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
415 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
416 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
417 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
418 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
421 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
422 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
423 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
424 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
427 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
428 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
429 DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
430 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
433 AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
434 AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
435 DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
436 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
439 AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
440 AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
441 DEFAULT_SUPP="darwin16.supp ${DEFAULT_SUPP}"
442 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
445 AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
446 AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
447 DEFAULT_SUPP="darwin17.supp ${DEFAULT_SUPP}"
448 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
451 AC_MSG_RESULT([unsupported (${kernel})])
452 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)])
458 AC_MSG_RESULT([ok (${host_os})])
461 uname_v=$( uname -v )
464 DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
467 DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
473 AC_MSG_RESULT([ok (${host_os})])
475 DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
479 AC_MSG_RESULT([no (${host_os})])
480 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
484 #----------------------------------------------------------------------------
486 # If we are building on a 64 bit platform test to see if the system
487 # supports building 32 bit programs and disable 32 bit support if it
488 # does not support building 32 bit programs
490 case "$ARCH_MAX-$VGCONF_OS" in
491 amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
492 AC_MSG_CHECKING([for 32 bit build support])
495 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
500 vg_cv_only64bit="yes"
503 CFLAGS=$safe_CFLAGS;;
505 AC_MSG_CHECKING([for 32 bit build support])
507 CFLAGS="$CFLAGS -mips32 -mabi=32"
508 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
509 #include <sys/prctl.h>
513 vg_cv_only64bit="yes"
516 CFLAGS=$safe_CFLAGS;;
519 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
521 [--enable-only32bit was specified but system does not support 32 bit builds])
524 #----------------------------------------------------------------------------
526 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
527 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
528 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
529 # above) will be "amd64" since that reflects the most that this cpu can do,
530 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
531 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
532 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
533 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
534 AC_SUBST(VGCONF_ARCH_PRI)
536 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
537 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
538 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
539 # It is empty if there is no secondary target.
540 AC_SUBST(VGCONF_ARCH_SEC)
542 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
543 # The entire system, including regression and performance tests, will be
544 # built for this target. The "_CAPS" indicates that the name is in capital
545 # letters, and it also uses '_' rather than '-' as a separator, because it's
546 # used to create various Makefile variables, which are all in caps by
547 # convention and cannot contain '-' characters. This is in contrast to
548 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
549 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
551 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
552 # Valgrind and tools will also be built for this target, but not the
553 # regression or performance tests.
555 # By default, the primary arch is the same as the "max" arch, as commented
556 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
557 # the big case statement just below here, in the case where we're building
558 # on a 64 bit machine but have been requested only to do a 32 bit build.
559 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
561 AC_MSG_CHECKING([for a supported CPU/OS combination])
563 # NB. The load address for a given platform may be specified in more
564 # than one place, in some cases, depending on whether we're doing a biarch,
565 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
566 # Be careful to give consistent values in all subcases. Also, all four
567 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
568 # even if it is to "0xUNSET".
570 case "$ARCH_MAX-$VGCONF_OS" in
572 VGCONF_ARCH_PRI="x86"
574 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
575 VGCONF_PLATFORM_SEC_CAPS=""
576 valt_load_address_pri_norml="0x58000000"
577 valt_load_address_pri_inner="0x38000000"
578 valt_load_address_sec_norml="0xUNSET"
579 valt_load_address_sec_inner="0xUNSET"
580 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
583 valt_load_address_sec_norml="0xUNSET"
584 valt_load_address_sec_inner="0xUNSET"
585 if test x$vg_cv_only64bit = xyes; then
586 VGCONF_ARCH_PRI="amd64"
588 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
589 VGCONF_PLATFORM_SEC_CAPS=""
590 valt_load_address_pri_norml="0x58000000"
591 valt_load_address_pri_inner="0x38000000"
592 elif test x$vg_cv_only32bit = xyes; then
593 VGCONF_ARCH_PRI="x86"
595 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
596 VGCONF_PLATFORM_SEC_CAPS=""
597 valt_load_address_pri_norml="0x58000000"
598 valt_load_address_pri_inner="0x38000000"
600 VGCONF_ARCH_PRI="amd64"
601 VGCONF_ARCH_SEC="x86"
602 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
603 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
604 valt_load_address_pri_norml="0x58000000"
605 valt_load_address_pri_inner="0x38000000"
606 valt_load_address_sec_norml="0x58000000"
607 valt_load_address_sec_inner="0x38000000"
609 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
612 VGCONF_ARCH_PRI="ppc32"
614 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
615 VGCONF_PLATFORM_SEC_CAPS=""
616 valt_load_address_pri_norml="0x58000000"
617 valt_load_address_pri_inner="0x38000000"
618 valt_load_address_sec_norml="0xUNSET"
619 valt_load_address_sec_inner="0xUNSET"
620 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
623 valt_load_address_sec_norml="0xUNSET"
624 valt_load_address_sec_inner="0xUNSET"
625 if test x$vg_cv_only64bit = xyes; then
626 VGCONF_ARCH_PRI="ppc64be"
628 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
629 VGCONF_PLATFORM_SEC_CAPS=""
630 valt_load_address_pri_norml="0x58000000"
631 valt_load_address_pri_inner="0x38000000"
632 elif test x$vg_cv_only32bit = xyes; then
633 VGCONF_ARCH_PRI="ppc32"
635 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
636 VGCONF_PLATFORM_SEC_CAPS=""
637 valt_load_address_pri_norml="0x58000000"
638 valt_load_address_pri_inner="0x38000000"
640 VGCONF_ARCH_PRI="ppc64be"
641 VGCONF_ARCH_SEC="ppc32"
642 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
643 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
644 valt_load_address_pri_norml="0x58000000"
645 valt_load_address_pri_inner="0x38000000"
646 valt_load_address_sec_norml="0x58000000"
647 valt_load_address_sec_inner="0x38000000"
649 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
652 # Little Endian is only supported on PPC64
653 valt_load_address_sec_norml="0xUNSET"
654 valt_load_address_sec_inner="0xUNSET"
655 VGCONF_ARCH_PRI="ppc64le"
657 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
658 VGCONF_PLATFORM_SEC_CAPS=""
659 valt_load_address_pri_norml="0x58000000"
660 valt_load_address_pri_inner="0x38000000"
661 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
663 # Darwin gets identified as 32-bit even when it supports 64-bit.
664 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
665 # all Macs support both 32-bit and 64-bit, so we just build both. If
666 # someone has a really old 32-bit only machine they can (hopefully?)
667 # build with --enable-only32bit. See bug 243362.
668 x86-darwin|amd64-darwin)
670 valt_load_address_sec_norml="0xUNSET"
671 valt_load_address_sec_inner="0xUNSET"
672 if test x$vg_cv_only64bit = xyes; then
673 VGCONF_ARCH_PRI="amd64"
675 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
676 VGCONF_PLATFORM_SEC_CAPS=""
677 valt_load_address_pri_norml="0x158000000"
678 valt_load_address_pri_inner="0x138000000"
679 elif test x$vg_cv_only32bit = xyes; then
680 VGCONF_ARCH_PRI="x86"
682 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
683 VGCONF_PLATFORM_SEC_CAPS=""
684 VGCONF_ARCH_PRI_CAPS="x86"
685 valt_load_address_pri_norml="0x58000000"
686 valt_load_address_pri_inner="0x38000000"
688 VGCONF_ARCH_PRI="amd64"
689 VGCONF_ARCH_SEC="x86"
690 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
691 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
692 valt_load_address_pri_norml="0x158000000"
693 valt_load_address_pri_inner="0x138000000"
694 valt_load_address_sec_norml="0x58000000"
695 valt_load_address_sec_inner="0x38000000"
697 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
700 VGCONF_ARCH_PRI="arm"
701 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
702 VGCONF_PLATFORM_SEC_CAPS=""
703 valt_load_address_pri_norml="0x58000000"
704 valt_load_address_pri_inner="0x38000000"
705 valt_load_address_sec_norml="0xUNSET"
706 valt_load_address_sec_inner="0xUNSET"
707 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
710 valt_load_address_sec_norml="0xUNSET"
711 valt_load_address_sec_inner="0xUNSET"
712 if test x$vg_cv_only64bit = xyes; then
713 VGCONF_ARCH_PRI="arm64"
715 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
716 VGCONF_PLATFORM_SEC_CAPS=""
717 valt_load_address_pri_norml="0x58000000"
718 valt_load_address_pri_inner="0x38000000"
719 elif test x$vg_cv_only32bit = xyes; then
720 VGCONF_ARCH_PRI="arm"
722 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
723 VGCONF_PLATFORM_SEC_CAPS=""
724 valt_load_address_pri_norml="0x58000000"
725 valt_load_address_pri_inner="0x38000000"
727 VGCONF_ARCH_PRI="arm64"
728 VGCONF_ARCH_SEC="arm"
729 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
730 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
731 valt_load_address_pri_norml="0x58000000"
732 valt_load_address_pri_inner="0x38000000"
733 valt_load_address_sec_norml="0x58000000"
734 valt_load_address_sec_inner="0x38000000"
736 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
739 VGCONF_ARCH_PRI="s390x"
741 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
742 VGCONF_PLATFORM_SEC_CAPS=""
743 # To improve branch prediction hit rate we want to have
744 # the generated code close to valgrind (host) code
745 valt_load_address_pri_norml="0x800000000"
746 valt_load_address_pri_inner="0x810000000"
747 valt_load_address_sec_norml="0xUNSET"
748 valt_load_address_sec_inner="0xUNSET"
749 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
752 VGCONF_ARCH_PRI="mips32"
754 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
755 VGCONF_PLATFORM_SEC_CAPS=""
756 valt_load_address_pri_norml="0x58000000"
757 valt_load_address_pri_inner="0x38000000"
758 valt_load_address_sec_norml="0xUNSET"
759 valt_load_address_sec_inner="0xUNSET"
760 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
763 valt_load_address_sec_norml="0xUNSET"
764 valt_load_address_sec_inner="0xUNSET"
765 if test x$vg_cv_only64bit = xyes; then
766 VGCONF_ARCH_PRI="mips64"
767 VGCONF_PLATFORM_SEC_CAPS=""
768 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
769 VGCONF_PLATFORM_SEC_CAPS=""
770 valt_load_address_pri_norml="0x58000000"
771 valt_load_address_pri_inner="0x38000000"
772 elif test x$vg_cv_only32bit = xyes; then
773 VGCONF_ARCH_PRI="mips32"
775 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
776 VGCONF_PLATFORM_SEC_CAPS=""
777 valt_load_address_pri_norml="0x58000000"
778 valt_load_address_pri_inner="0x38000000"
780 VGCONF_ARCH_PRI="mips64"
781 VGCONF_ARCH_SEC="mips32"
782 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
783 VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
784 valt_load_address_pri_norml="0x58000000"
785 valt_load_address_pri_inner="0x38000000"
786 valt_load_address_sec_norml="0x58000000"
787 valt_load_address_sec_inner="0x38000000"
789 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
792 VGCONF_ARCH_PRI="nanomips"
794 VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
795 VGCONF_PLATFORM_SEC_CAPS=""
796 valt_load_address_pri_norml="0x58000000"
797 valt_load_address_pri_inner="0x38000000"
798 valt_load_address_sec_norml="0xUNSET"
799 valt_load_address_sec_inner="0xUNSET"
800 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
803 VGCONF_ARCH_PRI="x86"
805 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
806 VGCONF_PLATFORM_SEC_CAPS=""
807 valt_load_address_pri_norml="0x58000000"
808 valt_load_address_pri_inner="0x38000000"
809 valt_load_address_sec_norml="0xUNSET"
810 valt_load_address_sec_inner="0xUNSET"
811 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
814 valt_load_address_sec_norml="0xUNSET"
815 valt_load_address_sec_inner="0xUNSET"
816 if test x$vg_cv_only64bit = xyes; then
817 VGCONF_ARCH_PRI="amd64"
819 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
820 VGCONF_PLATFORM_SEC_CAPS=""
821 valt_load_address_pri_norml="0x58000000"
822 valt_load_address_pri_inner="0x38000000"
823 elif test x$vg_cv_only32bit = xyes; then
824 VGCONF_ARCH_PRI="x86"
826 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
827 VGCONF_PLATFORM_SEC_CAPS=""
828 valt_load_address_pri_norml="0x58000000"
829 valt_load_address_pri_inner="0x38000000"
831 VGCONF_ARCH_PRI="amd64"
832 VGCONF_ARCH_SEC="x86"
833 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
834 VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
835 valt_load_address_pri_norml="0x58000000"
836 valt_load_address_pri_inner="0x38000000"
837 valt_load_address_sec_norml="0x58000000"
838 valt_load_address_sec_inner="0x38000000"
840 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
843 VGCONF_ARCH_PRI="unknown"
844 VGCONF_ARCH_SEC="unknown"
845 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
846 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
847 valt_load_address_pri_norml="0xUNSET"
848 valt_load_address_pri_inner="0xUNSET"
849 valt_load_address_sec_norml="0xUNSET"
850 valt_load_address_sec_inner="0xUNSET"
851 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
852 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
856 #----------------------------------------------------------------------------
858 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
860 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
861 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
862 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
863 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
864 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
865 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
866 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
867 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
868 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
869 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
870 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
871 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
872 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
873 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
874 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
875 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
876 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
877 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
878 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
879 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
880 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
881 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
882 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
883 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
884 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
885 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
886 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
887 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
888 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
889 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
890 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
892 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
894 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
895 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
896 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
897 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
898 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
899 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
900 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
901 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
902 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
903 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
904 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
905 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
906 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
907 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
908 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
909 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
910 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
911 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
912 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
913 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
914 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
915 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
916 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
917 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
918 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
919 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
920 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
921 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
922 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
923 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
924 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
925 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
926 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
927 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
928 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
929 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
930 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
933 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
934 # Relies on the assumption that the primary and secondary targets are
935 # for the same OS, so therefore only necessary to test the primary.
936 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
937 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
938 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
939 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
940 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
941 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
942 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
943 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
944 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
945 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
946 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
947 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
948 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
949 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
950 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
951 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
952 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
953 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
956 # Sometimes, in the Makefile.am files, it's useful to know whether or not
957 # there is a secondary target.
958 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
959 test x$VGCONF_PLATFORM_SEC_CAPS != x)
961 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
962 dnl fallback definition
963 dnl The macro is courtesy of Dave Hart:
964 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
965 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
966 if test -z "$$1_TRUE"; then :
975 #----------------------------------------------------------------------------
977 #----------------------------------------------------------------------------
979 # Check if this should be built as an inner Valgrind, to be run within
980 # another Valgrind. Choose the load address accordingly.
981 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
982 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
983 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
984 [AC_ARG_ENABLE(inner,
985 [ --enable-inner enables self-hosting],
986 [vg_cv_inner=$enableval],
988 if test "$vg_cv_inner" = yes; then
989 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
990 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
991 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
993 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
994 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
997 #----------------------------------------------------------------------------
998 # Undefined behaviour sanitiser
999 #----------------------------------------------------------------------------
1000 # Check whether we should build with the undefined beahviour sanitiser.
1002 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1003 [AC_ARG_ENABLE(ubsan,
1004 [ --enable-ubsan enables the undefined behaviour sanitiser],
1005 [vg_cv_ubsan=$enableval],
1008 #----------------------------------------------------------------------------
1009 # Extra fine-tuning of installation directories
1010 #----------------------------------------------------------------------------
1012 [ --with-tmpdir=PATH Specify path for temporary files],
1015 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1016 AC_SUBST(VG_TMPDIR, [$tmpdir])
1018 #----------------------------------------------------------------------------
1020 #----------------------------------------------------------------------------
1021 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1022 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1023 AC_MSG_CHECKING([for xcode sdk include path])
1024 AC_ARG_WITH(xcodedir,
1025 [ --with-xcode-path=PATH Specify path for xcode sdk includes],
1026 [xcodedir="$withval"],
1028 if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1029 xcrundir=`xcrun --sdk macosx --show-sdk-path`
1030 if test -z "$xcrundir"; then
1031 xcodedir="/usr/include"
1033 xcodedir="$xcrundir/usr/include"
1036 xcodedir="/usr/include"
1039 AC_MSG_RESULT([$xcodedir])
1040 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1041 AC_SUBST(XCODE_DIR, [$xcodedir])])
1043 #----------------------------------------------------------------------------
1044 # Libc and suppressions
1045 #----------------------------------------------------------------------------
1046 # This variable will collect the suppression files to be used.
1047 AC_SUBST(DEFAULT_SUPP)
1049 AC_CHECK_HEADER([features.h])
1051 if test x$ac_cv_header_features_h = xyes; then
1052 rm -f conftest.$ac_ext
1053 cat <<_ACEOF >conftest.$ac_ext
1054 #include <features.h>
1055 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1056 glibc version is: __GLIBC__ __GLIBC_MINOR__
1059 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1062 # not really a version check
1063 AC_EGREP_CPP([DARWIN_LIBC], [
1064 #include <sys/cdefs.h>
1065 #if defined(__DARWIN_VERS_1050)
1069 GLIBC_VERSION="darwin")
1071 # not really a version check
1072 AC_EGREP_CPP([BIONIC_LIBC], [
1073 #if defined(__ANDROID__)
1077 GLIBC_VERSION="bionic")
1079 # there is only one version of libc on Solaris
1080 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1081 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1082 GLIBC_VERSION="solaris"
1085 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1087 if test x$GLIBC_VERSION = x; then
1088 if $CC -dumpmachine | grep -q musl; then
1093 AC_MSG_CHECKING([the glibc version])
1095 case "${GLIBC_VERSION}" in
1097 AC_MSG_RESULT(${GLIBC_VERSION} family)
1098 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1099 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1100 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1103 AC_MSG_RESULT(${GLIBC_VERSION} family)
1104 DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1105 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1106 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1109 AC_MSG_RESULT(${GLIBC_VERSION} family)
1110 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1111 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1112 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1115 AC_MSG_RESULT(${GLIBC_VERSION} family)
1116 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1117 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1118 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1119 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1120 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1123 AC_MSG_RESULT(${GLIBC_VERSION} family)
1124 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1125 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1126 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1127 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1128 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1129 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1130 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1133 AC_MSG_RESULT(Darwin)
1134 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1135 # DEFAULT_SUPP set by kernel version check above.
1138 AC_MSG_RESULT(Bionic)
1139 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1140 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1143 AC_MSG_RESULT(Solaris)
1144 # DEFAULT_SUPP set in host_os switch-case above.
1145 # No other suppression file is used.
1149 AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1150 # no DEFAULT_SUPP file yet for musl libc.
1153 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1154 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1155 AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1159 AC_SUBST(GLIBC_VERSION)
1162 if test "$VGCONF_OS" != "solaris"; then
1163 # Add default suppressions for the X client libraries. Make no
1164 # attempt to detect whether such libraries are installed on the
1165 # build machine (or even if any X facilities are present); just
1166 # add the suppressions antidisirregardless.
1167 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1168 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1172 #----------------------------------------------------------------------------
1173 # Platform variants?
1174 #----------------------------------------------------------------------------
1176 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1177 # But there are times where we need a bit more control. The motivating
1178 # and currently only case is Android: this is almost identical to
1179 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1180 # platform variant tags, which get passed in the compile as
1181 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1183 # In almost all cases, the <variant> bit is "vanilla". But for Android
1184 # it is "android" instead.
1186 # Consequently (eg), plain arm-linux would build with
1188 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1190 # whilst an Android build would have
1192 # -DVGP_arm_linux -DVGPV_arm_linux_android
1194 # Same for x86. The setup of the platform variant is pushed relatively far
1195 # down this file in order that we can inspect any of the variables set above.
1197 # In the normal case ..
1198 VGCONF_PLATVARIANT="vanilla"
1201 if test "$GLIBC_VERSION" = "bionic";
1203 VGCONF_PLATVARIANT="android"
1206 AC_SUBST(VGCONF_PLATVARIANT)
1209 # FIXME: do we also want to define automake variables
1210 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1211 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1212 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1213 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1214 # that's what we'd need to do to use this, since what we'd want to write
1217 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1219 # Hmm. Can't think of a nice clean solution to this.
1221 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1222 test x$VGCONF_PLATVARIANT = xvanilla)
1223 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1224 test x$VGCONF_PLATVARIANT = xandroid)
1227 #----------------------------------------------------------------------------
1228 # Checking for various library functions and other definitions
1229 #----------------------------------------------------------------------------
1231 # Check for AT_FDCWD
1233 AC_MSG_CHECKING([for AT_FDCWD])
1234 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1241 ac_have_at_fdcwd=yes
1242 AC_MSG_RESULT([yes])
1248 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1250 # Check for stpncpy function definition in string.h
1251 # This explicitly checks with _GNU_SOURCE defined since that is also
1252 # used in the test case (some systems might define it without anyway
1253 # since stpncpy is part of The Open Group Base Specifications Issue 7
1254 # IEEE Std 1003.1-2008.
1255 AC_MSG_CHECKING([for stpncpy])
1256 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1263 char *r = stpncpy(d, s, n);
1265 ac_have_gnu_stpncpy=yes
1266 AC_MSG_RESULT([yes])
1268 ac_have_gnu_stpncpy=no
1272 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1274 # Check for PTRACE_GETREGS
1276 AC_MSG_CHECKING([for PTRACE_GETREGS])
1277 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1280 #include <sys/ptrace.h>
1281 #include <sys/user.h>
1284 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1286 AC_MSG_RESULT([yes])
1287 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1288 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1294 # Check for CLOCK_MONOTONIC
1296 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1298 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1302 clock_gettime(CLOCK_MONOTONIC, &t);
1305 AC_MSG_RESULT([yes])
1306 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1307 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1313 # Check for ELF32/64_CHDR
1315 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1318 # Check for PTHREAD_RWLOCK_T
1320 AC_MSG_CHECKING([for pthread_rwlock_t])
1322 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1324 #include <pthread.h>
1326 pthread_rwlock_t rwl;
1328 AC_MSG_RESULT([yes])
1329 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1330 [Define to 1 if you have the `pthread_rwlock_t' type.])
1336 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1338 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1340 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1342 #include <pthread.h>
1344 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1346 AC_MSG_RESULT([yes])
1347 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1348 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1354 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1356 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1358 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1360 #include <pthread.h>
1362 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1364 AC_MSG_RESULT([yes])
1365 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1366 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1372 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1374 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1378 #include <pthread.h>
1380 return (PTHREAD_MUTEX_RECURSIVE_NP);
1382 AC_MSG_RESULT([yes])
1383 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1384 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1390 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1392 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1394 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1396 #include <pthread.h>
1398 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1401 AC_MSG_RESULT([yes])
1402 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1403 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1409 # Check whether pthread_mutex_t has a member called __m_kind.
1411 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1412 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1414 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1417 [#include <pthread.h>])
1420 # Check whether pthread_mutex_t has a member called __data.__kind.
1422 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1423 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1425 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1428 [#include <pthread.h>])
1430 # Convenience function. Set flags based on the existing HWCAP entries.
1431 # The AT_HWCAP entries are generated by glibc, and are based on
1432 # functions supported by the hardware/system/libc.
1433 # Subsequent support for whether the capability will actually be utilized
1434 # will also be checked against the compiler capabilities.
1436 # AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1437 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1439 AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1440 if LD_SHOW_AUXV=1 `which true` | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1442 AC_MSG_RESULT([yes])
1443 AC_SUBST([$2],[yes])
1450 # gather hardware capabilities. (hardware/kernel/libc)
1451 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1452 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1453 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1454 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1455 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1456 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1457 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1458 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1461 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1462 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1463 # compiler support for isa 2.07 level instructions
1464 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1465 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1467 __asm__ __volatile__("mtvsrd 1,2 ");
1469 ac_asm_have_isa_2_07=yes
1470 AC_MSG_RESULT([yes])
1472 ac_asm_have_isa_2_07=no
1475 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1476 -a x$HWCAP_HAS_ISA_2_07 = xyes])
1478 # altivec (vsx) support.
1479 # does this compiler support -maltivec and does it have the include file
1481 AC_MSG_CHECKING([for Altivec support in the compiler ])
1483 CFLAGS="-maltivec -Werror"
1484 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1485 #include <altivec.h>
1487 vector unsigned int v;
1490 AC_MSG_RESULT([yes])
1496 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1497 -a x$HWCAP_HAS_ALTIVEC = xyes])
1499 # Check that both: the compiler supports -mvsx and that the assembler
1500 # understands VSX instructions. If either of those doesn't work,
1501 # conclude that we can't do VSX.
1502 AC_MSG_CHECKING([for VSX compiler flag support])
1504 CFLAGS="-mvsx -Werror"
1505 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1508 ac_compiler_supports_vsx_flag=yes
1509 AC_MSG_RESULT([yes])
1511 ac_compiler_supports_vsx_flag=no
1516 AC_MSG_CHECKING([for VSX support in the assembler ])
1518 CFLAGS="-mvsx -Werror"
1519 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1520 #include <altivec.h>
1522 vector unsigned int v;
1523 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1525 ac_compiler_supports_vsx=yes
1526 AC_MSG_RESULT([yes])
1528 ac_compiler_supports_vsx=no
1532 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1533 -a x$ac_compiler_supports_vsx = xyes \
1534 -a x$HWCAP_HAS_VSX = xyes ])
1536 # DFP (Decimal Float)
1537 AC_MSG_CHECKING([that assembler knows DFP])
1538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1541 __asm__ __volatile__("adtr 1, 2, 3")
1543 __asm__ __volatile__("dadd 1, 2, 3");
1544 __asm__ __volatile__("dcffix 1, 2");
1548 AC_MSG_RESULT([yes])
1553 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1555 CFLAGS="-mhard-dfp -Werror"
1556 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1559 __asm__ __volatile__("adtr 1, 2, 3")
1561 __asm__ __volatile__("dadd 1, 2, 3");
1562 __asm__ __volatile__("dcffix 1, 2");
1565 ac_compiler_have_dfp=yes
1566 AC_MSG_RESULT([yes])
1568 ac_compiler_have_dfp=no
1572 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1573 -a x$ac_compiler_have_dfp = xyes \
1574 -a x$HWCAP_HAS_DFP = xyes )
1576 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1577 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1579 _Decimal64 x = 0.0DD;
1581 ac_compiler_have_dfp_type=yes
1582 AC_MSG_RESULT([yes])
1584 ac_compiler_have_dfp_type=no
1587 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1588 -a x$HWCAP_HAS_DFP = xyes )
1591 # HTM (Hardware Transactional Memory)
1592 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1594 CFLAGS="-mhtm -Werror"
1595 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1599 AC_MSG_RESULT([yes])
1600 ac_compiler_supports_htm=yes
1603 ac_compiler_supports_htm=no
1607 AC_MSG_CHECKING([if compiler can find the htm builtins])
1609 CFLAGS="-mhtm -Werror"
1610 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1612 if (__builtin_tbegin (0))
1615 AC_MSG_RESULT([yes])
1616 ac_compiler_sees_htm_builtins=yes
1619 ac_compiler_sees_htm_builtins=no
1623 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1624 -a x$ac_compiler_sees_htm_builtins = xyes \
1625 -a x$HWCAP_HAS_HTM = xyes )
1628 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1630 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1632 __asm__ __volatile__("cnttzw 1,2 ");
1634 ac_asm_have_isa_3_00=yes
1635 AC_MSG_RESULT([yes])
1637 ac_asm_have_isa_3_00=no
1641 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1642 -a x$HWCAP_HAS_ISA_3_00 = xyes])
1644 # Check for pthread_create@GLIBC2.0
1645 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1648 CFLAGS="-lpthread -Werror"
1649 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1650 extern int pthread_create_glibc_2_0(void*, const void*,
1651 void *(*)(void*), void*);
1652 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1656 * Apparently on PowerPC linking this program succeeds and generates an
1657 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1659 #error This test does not work properly on PowerPC.
1661 pthread_create_glibc_2_0(0, 0, 0, 0);
1665 ac_have_pthread_create_glibc_2_0=yes
1666 AC_MSG_RESULT([yes])
1667 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1668 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1670 ac_have_pthread_create_glibc_2_0=no
1675 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1676 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1679 # Check for dlinfo RTLD_DI_TLS_MODID
1680 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1684 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1691 size_t sizes[10000];
1692 size_t modid_offset;
1693 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1696 ac_have_dlinfo_rtld_di_tls_modid=yes
1697 AC_MSG_RESULT([yes])
1698 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1699 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1701 ac_have_dlinfo_rtld_di_tls_modid=no
1706 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1707 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1710 # Check for eventfd_t, eventfd() and eventfd_read()
1711 AC_MSG_CHECKING([for eventfd()])
1713 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1714 #include <sys/eventfd.h>
1720 eventfd_read(fd, &ev);
1723 AC_MSG_RESULT([yes])
1724 AC_DEFINE([HAVE_EVENTFD], 1,
1725 [Define to 1 if you have the `eventfd' function.])
1726 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1727 [Define to 1 if you have the `eventfd_read' function.])
1732 # Check whether compiler can process #include <thread> without errors
1733 # clang 3.3 cannot process <thread> from e.g.
1734 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1736 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1738 safe_CXXFLAGS=$CXXFLAGS
1741 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1745 ac_cxx_can_include_thread_header=yes
1746 AC_MSG_RESULT([yes])
1748 ac_cxx_can_include_thread_header=no
1751 CXXFLAGS=$safe_CXXFLAGS
1754 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1757 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1758 # of the user_regs_struct from sys/user.h. They are structurally the same
1759 # but we get either one or the other.
1761 AC_CHECK_TYPE([struct user_regs_struct],
1762 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1763 [[#include <sys/ptrace.h>]
1764 [#include <sys/time.h>]
1765 [#include <sys/user.h>]])
1766 if test "$sys_user_has_user_regs" = "yes"; then
1767 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1768 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1771 AC_MSG_CHECKING([for __NR_membarrier])
1772 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1773 #include <linux/unistd.h>
1775 return __NR_membarrier
1777 ac_have_nr_membarrier=yes
1778 AC_MSG_RESULT([yes])
1780 ac_have_nr_membarrier=no
1784 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
1786 #----------------------------------------------------------------------------
1787 # Checking for supported compiler flags.
1788 #----------------------------------------------------------------------------
1790 case "${host_cpu}" in
1792 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1793 if test -z "$ARCH"; then
1794 # does this compiler support -march=mips32 (mips32 default) ?
1795 AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
1798 CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
1800 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1803 FLAG_M32="-mips32 -mabi=32"
1804 AC_MSG_RESULT([yes])
1814 # does this compiler support -march=mips64r2 (mips64r2 default) ?
1815 AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
1818 CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
1820 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1823 FLAG_M64="-march=mips64r2 -mabi=64"
1824 AC_MSG_RESULT([yes])
1837 # does this compiler support -m32 ?
1838 AC_MSG_CHECKING([if gcc accepts -m32])
1841 CFLAGS="-m32 -Werror"
1843 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1847 AC_MSG_RESULT([yes])
1857 # does this compiler support -m64 ?
1858 AC_MSG_CHECKING([if gcc accepts -m64])
1861 CFLAGS="-m64 -Werror"
1863 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1867 AC_MSG_RESULT([yes])
1879 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1880 if test -z "$ARCH"; then
1881 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1882 AC_MSG_CHECKING([if gcc accepts -march=octeon])
1885 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
1887 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1890 FLAG_OCTEON="-march=octeon"
1891 AC_MSG_RESULT([yes])
1898 AC_SUBST(FLAG_OCTEON)
1901 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1902 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1905 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
1907 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1910 FLAG_OCTEON2="-march=octeon2"
1911 AC_MSG_RESULT([yes])
1918 AC_SUBST(FLAG_OCTEON2)
1922 # does this compiler support -mmsa (MIPS MSA ASE) ?
1923 AC_MSG_CHECKING([if gcc accepts -mmsa])
1926 CFLAGS="$CFLAGS -mmsa -Werror"
1928 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1932 AC_MSG_RESULT([yes])
1941 # Are we compiling for the MIPS64 n32 ABI?
1942 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
1943 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1944 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
1949 FLAG_M64="-march=mips64r2 -mabi=n32"
1950 AC_MSG_RESULT([yes])
1955 # Are we compiling for the MIPS64 n64 ABI?
1956 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
1957 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1958 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
1963 AC_MSG_RESULT([yes])
1968 # We enter the code block below in the following case:
1969 # Target architecture is set to mips64, the desired abi
1970 # was not specified and the compiler's default abi setting
1971 # is neither n32 nor n64.
1972 # Probe for and set the abi to either n64 or n32, in that order,
1973 # which is required for a mips64 build of valgrind.
1974 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
1976 CFLAGS="$CFLAGS -mabi=64 -Werror"
1977 AC_MSG_CHECKING([if gcc is n64 capable])
1978 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1982 AC_MSG_RESULT([yes])
1988 if test "x$VGCONF_ABI" = "x"; then
1990 CFLAGS="$CFLAGS -mabi=n32 -Werror"
1991 AC_MSG_CHECKING([if gcc is n32 capable])
1992 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1996 FLAG_M64="-march=mips64r2 -mabi=n32"
1997 AC_MSG_RESULT([yes])
2005 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2006 [test x$VGCONF_ABI != x])
2007 AC_SUBST(VGCONF_ABI)
2010 # does this compiler support -mmmx ?
2011 AC_MSG_CHECKING([if gcc accepts -mmmx])
2014 CFLAGS="-mmmx -Werror"
2016 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2020 AC_MSG_RESULT([yes])
2030 # does this compiler support -msse ?
2031 AC_MSG_CHECKING([if gcc accepts -msse])
2034 CFLAGS="-msse -Werror"
2036 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2040 AC_MSG_RESULT([yes])
2050 # does this compiler support -mpreferred-stack-boundary=2 when
2051 # generating code for a 32-bit target? Note that we only care about
2052 # this when generating code for (32-bit) x86, so if the compiler
2053 # doesn't recognise -m32 it's no big deal. We'll just get code for
2054 # the Memcheck and other helper functions, that is a bit slower than
2055 # it could be, on x86; and no difference at all on any other platform.
2056 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2059 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2061 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2064 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2065 AC_MSG_RESULT([yes])
2067 PREFERRED_STACK_BOUNDARY_2=""
2072 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2075 # does this compiler support -mlong-double-128 ?
2076 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2078 CFLAGS="-mlong-double-128 -Werror"
2079 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2082 ac_compiler_supports_mlong_double_128=yes
2083 AC_MSG_RESULT([yes])
2085 ac_compiler_supports_mlong_double_128=no
2089 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2090 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2091 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2093 # does this toolchain support lto ?
2094 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2096 # If not enable-lto=* arg is provided, default to no, as lto builds are
2097 # a lot slower, and so not appropriate for Valgrind developments.
2098 # --enable-lto=yes should be used by distro packagers.
2099 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2101 [ --enable-lto enables building with link time optimisation],
2102 [vg_cv_lto=$enableval],
2105 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2106 AC_MSG_CHECKING([if toolchain accepts lto])
2108 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2109 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2110 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2111 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2113 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2114 extern void somefun(void);
2118 LTO_CFLAGS=$TEST_LTO_CFLAGS
2119 AC_MSG_RESULT([yes])
2127 AC_SUBST(LTO_CFLAGS)
2129 # if we could not compile with lto args, or lto was disabled,
2130 # then set LTO_AR/LTO_RANLIB to the non lto values
2131 # define in config.h ENABLE_LTO (not needed by the code currently, but
2132 # this guarantees we recompile everything if we re-configure and rebuild
2133 # in a build dir previously build with another value of --enable-lto
2134 if test "x${LTO_CFLAGS}" = "x"; then
2136 LTO_RANLIB=${RANLIB}
2140 AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2143 # Convenience function to check whether GCC supports a particular
2144 # warning option. Takes two arguments,
2145 # first the warning flag name to check (without -W), then the
2146 # substitution name to set with -Wno-warning-flag if the flag exists,
2147 # or the empty string if the compiler doesn't accept the flag. Note
2148 # that checking is done against the warning flag itself, but the
2149 # substitution is then done to cancel the warning flag.
2150 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2151 AC_MSG_CHECKING([if gcc accepts -W$1])
2153 CFLAGS="-W$1 -Werror"
2154 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2155 AC_SUBST([$2], [-Wno-$1])
2156 AC_MSG_RESULT([yes])], [
2158 AC_MSG_RESULT([no])])
2162 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2163 # -W$1 (instead of -Wno-$1).
2164 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2165 AC_MSG_CHECKING([if gcc accepts -W$1])
2167 CFLAGS="-W$1 -Werror"
2168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2169 AC_SUBST([$2], [-W$1])
2170 AC_MSG_RESULT([yes])], [
2172 AC_MSG_RESULT([no])])
2176 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2177 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2178 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2179 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2180 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2181 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2182 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2183 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2184 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2186 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2187 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2188 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2189 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2190 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2191 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2192 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2193 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2194 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2195 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2196 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2198 # Does this compiler support -Wformat-security ?
2199 # Special handling is needed, because certain GCC versions require -Wformat
2200 # being present if -Wformat-security is given. Otherwise a warning is issued.
2201 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2202 # And with that the warning will be turned into an error with the result
2203 # that -Wformat-security is believed to be unsupported when in fact it is.
2204 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2206 CFLAGS="-Wformat -Wformat-security -Werror"
2207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2208 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2209 AC_MSG_RESULT([yes])], [
2210 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2211 AC_MSG_RESULT([no])])
2214 # does this compiler support -Wextra or the older -W ?
2216 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2219 CFLAGS="-Wextra -Werror"
2221 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2224 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2225 AC_MSG_RESULT([-Wextra])
2228 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2231 AC_SUBST([FLAG_W_EXTRA], [-W])
2234 AC_SUBST([FLAG_W_EXTRA], [])
2235 AC_MSG_RESULT([not supported])
2240 # On ARM we do not want to pass -Wcast-align as that produces loads
2241 # of warnings. GCC is just being conservative. See here:
2242 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2243 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2244 AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2246 AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2249 # does this compiler support -faligned-new ?
2250 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2252 safe_CXXFLAGS=$CXXFLAGS
2253 CXXFLAGS="-faligned-new -Werror"
2256 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2259 FLAG_FALIGNED_NEW="-faligned-new"
2260 AC_MSG_RESULT([yes])
2262 FLAG_FALIGNED_NEW=""
2265 CXXFLAGS=$safe_CXXFLAGS
2268 AC_SUBST(FLAG_FALIGNED_NEW)
2270 # does this compiler support -fno-stack-protector ?
2271 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2274 CFLAGS="-fno-stack-protector -Werror"
2276 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2279 no_stack_protector=yes
2280 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2281 AC_MSG_RESULT([yes])
2283 no_stack_protector=no
2284 FLAG_FNO_STACK_PROTECTOR=""
2289 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2291 # does this compiler support -finline-functions ?
2292 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2295 CFLAGS="-finline-functions -Werror"
2297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2300 inline_functions=yes
2301 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2302 AC_MSG_RESULT([yes])
2305 FLAG_FINLINE_FUNCTIONS=""
2310 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2312 # Does GCC support disabling Identical Code Folding?
2313 # We want to disabled Identical Code Folding for the
2314 # tools preload shared objects to get better backraces.
2315 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2316 # "The optimization reduces code size and may disturb
2317 # unwind stacks by replacing a function by equivalent
2318 # one with a different name."
2319 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2322 CFLAGS="-fno-ipa-icf -Werror"
2324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2328 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2329 AC_MSG_RESULT([yes])
2337 AC_SUBST(FLAG_FNO_IPA_ICF)
2340 # Does this compiler support -fsanitize=undefined. This is true for
2341 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2342 # also checks for alignment violations on memory accesses which the valgrind
2343 # code base is sprinkled (if not littered) with. As those alignment issues
2344 # don't pose a problem we want to suppress warnings about them.
2345 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2346 # GCCs do not support that.
2348 # Only checked for if --enable-ubsan was given.
2349 if test "x${vg_cv_ubsan}" = "xyes"; then
2350 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2352 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2356 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2357 LIB_UBSAN="-static-libubsan"
2358 AC_MSG_RESULT([yes])
2360 CFLAGS="-fsanitize=undefined -Werror"
2361 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2364 FLAG_FSANITIZE="-fsanitize=undefined"
2365 LIB_UBSAN="-static-libubsan"
2366 AC_MSG_RESULT([yes])
2374 AC_SUBST(FLAG_FSANITIZE)
2377 # does this compiler support --param inline-unit-growth=... ?
2379 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2382 CFLAGS="--param inline-unit-growth=900 -Werror"
2384 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2387 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2388 ["--param inline-unit-growth=900"])
2389 AC_MSG_RESULT([yes])
2391 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2397 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2399 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2402 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2404 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2408 AC_MSG_RESULT([yes])
2413 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2417 # does this compiler support -g -gz=zlib ?
2419 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2422 CFLAGS="-g -gz=zlib"
2424 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2428 AC_MSG_RESULT([yes])
2433 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2437 # does this compiler support -g -gz=zlib-gnu ?
2439 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2442 CFLAGS="-g -gz=zlib-gnu"
2444 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2447 ac_have_gz_zlib_gnu=yes
2448 AC_MSG_RESULT([yes])
2450 ac_have_gz_zlib_gnu=no
2453 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2457 # does this compiler support nested functions ?
2459 AC_MSG_CHECKING([if gcc accepts nested functions])
2461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2462 int foo() { return 1; }
2465 ac_have_nested_functions=yes
2466 AC_MSG_RESULT([yes])
2468 ac_have_nested_functions=no
2471 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2474 # does this compiler support the 'p' constraint in ASM statements ?
2476 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2478 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2480 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2482 ac_have_asm_constraint_p=yes
2483 AC_MSG_RESULT([yes])
2485 ac_have_asm_constraint_p=no
2488 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2491 # Does this compiler and linker support -pie?
2492 # Some compilers actually do not support -pie and report its usage
2493 # as an error. We need to check if it is safe to use it first.
2495 AC_MSG_CHECKING([if gcc accepts -pie])
2500 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2503 AC_SUBST([FLAG_PIE], ["-pie"])
2504 AC_MSG_RESULT([yes])
2506 AC_SUBST([FLAG_PIE], [""])
2512 # Does this compiler support -no-pie?
2513 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2514 # default. However this gets in the way with some tests, we use -no-pie
2517 AC_MSG_CHECKING([if gcc accepts -no-pie])
2522 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2525 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2526 AC_MSG_RESULT([yes])
2528 AC_SUBST([FLAG_NO_PIE], [""])
2534 # We want to use use the -Ttext-segment option to the linker.
2535 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2536 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2537 # semantics are NOT what we want (GNU gold -Ttext is fine).
2539 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2540 # will reside. -Ttext aligns just the .text section start (but not any
2543 # So test for -Ttext-segment which is supported by all bfd ld versions
2544 # and use that if it exists. If it doesn't exist it must be an older
2545 # version of gold and we can fall back to using -Ttext which has the
2548 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2551 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2554 [AC_LANG_SOURCE([int _start () { return 0; }])],
2556 linker_using_t_text="no"
2557 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2558 AC_MSG_RESULT([yes])
2560 linker_using_t_text="yes"
2561 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2566 # If the linker only supports -Ttext (not -Ttext-segment) then we will
2567 # have to strip any build-id ELF NOTEs from the statically linked tools.
2568 # Otherwise the build-id NOTE might end up at the default load address.
2569 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2570 # gold versions also support -Ttext-segment. So just assume that unless
2571 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2572 if test "x${linker_using_t_text}" = "xyes"; then
2573 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2574 # does the linker support -Wl,--build-id=none ? Note, it's
2575 # important that we test indirectly via whichever C compiler
2576 # is selected, rather than testing /usr/bin/ld or whatever
2578 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2580 CFLAGS="-Wl,--build-id=none -Werror"
2583 [AC_LANG_PROGRAM([ ], [return 0;])],
2585 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2586 AC_MSG_RESULT([yes])
2588 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2592 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2593 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2597 # does the ppc assembler support "mtocrf" et al?
2598 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2600 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2601 __asm__ __volatile__("mtocrf 4,0");
2602 __asm__ __volatile__("mfocrf 0,4");
2604 ac_have_as_ppc_mftocrf=yes
2605 AC_MSG_RESULT([yes])
2607 ac_have_as_ppc_mftocrf=no
2610 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2611 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2615 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2616 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2618 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2619 do { typedef struct {
2623 dbl_pair_t dbl_pair[3];
2624 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2627 ac_have_as_ppc_fpPO=yes
2628 AC_MSG_RESULT([yes])
2630 ac_have_as_ppc_fpPO=no
2633 if test x$ac_have_as_ppc_fpPO = xyes ; then
2634 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2638 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2639 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2641 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2643 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2644 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2646 ac_have_as_amd64_fxsave64=yes
2647 AC_MSG_RESULT([yes])
2649 ac_have_as_amd64_fxsave64=no
2652 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2653 AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2656 # does the x86/amd64 assembler understand SSE3 instructions?
2657 # Note, this doesn't generate a C-level symbol. It generates a
2658 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2659 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2661 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2662 do { long long int x;
2663 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
2667 AC_MSG_RESULT([yes])
2673 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2676 # Ditto for SSSE3 instructions (note extra S)
2677 # Note, this doesn't generate a C-level symbol. It generates a
2678 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2679 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2681 save_CFLAGS="$CFLAGS"
2682 CFLAGS="$CFLAGS -msse -Werror"
2683 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2684 do { long long int x;
2685 __asm__ __volatile__(
2686 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2689 ac_have_as_ssse3=yes
2690 AC_MSG_RESULT([yes])
2695 CFLAGS="$save_CFLAGS"
2697 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2700 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2701 # Note, this doesn't generate a C-level symbol. It generates a
2702 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2703 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2704 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2706 __asm__ __volatile__(
2707 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2710 ac_have_as_pclmulqdq=yes
2711 AC_MSG_RESULT([yes])
2713 ac_have_as_pclmulqdq=no
2717 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2720 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2721 # Note, this doesn't generate a C-level symbol. It generates a
2722 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2723 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2724 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2727 * Carry-less multiplication of xmm1 with xmm2 and store the result in
2728 * xmm3. The immediate is used to determine which quadwords of xmm1 and
2729 * xmm2 should be used.
2731 __asm__ __volatile__(
2732 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2735 ac_have_as_vpclmulqdq=yes
2736 AC_MSG_RESULT([yes])
2738 ac_have_as_vpclmulqdq=no
2742 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2745 # does the x86/amd64 assembler understand FMA4 instructions?
2746 # Note, this doesn't generate a C-level symbol. It generates a
2747 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
2748 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
2749 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2751 __asm__ __volatile__(
2752 "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
2755 ac_have_as_vfmaddpd=yes
2756 AC_MSG_RESULT([yes])
2758 ac_have_as_vfmaddpd=no
2762 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
2765 # does the x86/amd64 assembler understand the LZCNT instruction?
2766 # Note, this doesn't generate a C-level symbol. It generates a
2767 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2768 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2770 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2772 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2775 ac_have_as_lzcnt=yes
2776 AC_MSG_RESULT([yes])
2782 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2785 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2786 # Note, this doesn't generate a C-level symbol. It generates a
2787 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2788 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2790 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2792 __asm__ __volatile__("1: loopnel 1b\n");
2795 ac_have_as_loopnel=yes
2796 AC_MSG_RESULT([yes])
2798 ac_have_as_loopnel=no
2802 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2805 # does the x86/amd64 assembler understand ADDR32 ?
2806 # Note, this doesn't generate a C-level symbol. It generates a
2807 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2808 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2810 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2812 asm volatile ("addr32 rep movsb");
2815 ac_have_as_addr32=yes
2816 AC_MSG_RESULT([yes])
2818 ac_have_as_addr32=no
2822 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2825 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2826 # Note, this doesn't generate a C-level symbol. It generates a
2827 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2828 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2830 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2831 do { long long int x;
2832 __asm__ __volatile__(
2833 "crc32q %%r15,%%r15" : : : "r15" );
2834 __asm__ __volatile__(
2835 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2836 __asm__ __volatile__(
2837 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2840 ac_have_as_sse42=yes
2841 AC_MSG_RESULT([yes])
2847 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2850 # does the x86/amd64 assembler understand AVX instructions?
2851 # Note, this doesn't generate a C-level symbol. It generates a
2852 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2853 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2855 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2856 do { long long int x;
2857 __asm__ __volatile__(
2858 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2859 __asm__ __volatile__(
2860 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2864 AC_MSG_RESULT([yes])
2870 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2873 # does the x86/amd64 assembler understand AVX2 instructions?
2874 # Note, this doesn't generate a C-level symbol. It generates a
2875 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2876 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2878 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2879 do { long long int x;
2880 __asm__ __volatile__(
2881 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2882 __asm__ __volatile__(
2883 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2887 AC_MSG_RESULT([yes])
2893 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2896 # does the x86/amd64 assembler understand TSX instructions and
2897 # the XACQUIRE/XRELEASE prefixes?
2898 # Note, this doesn't generate a C-level symbol. It generates a
2899 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2900 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2902 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2904 __asm__ __volatile__(
2907 " xacquire lock incq 0(%rsp) \n\t"
2908 " xrelease lock incq 0(%rsp) \n"
2913 AC_MSG_RESULT([yes])
2919 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2922 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2923 # Note, this doesn't generate a C-level symbol. It generates a
2924 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2925 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2927 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2928 do { unsigned int h, l;
2929 __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2930 __asm__ __volatile__(
2931 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2932 __asm__ __volatile__(
2933 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2937 AC_MSG_RESULT([yes])
2943 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2946 # does the x86/amd64 assembler understand FMA instructions?
2947 # Note, this doesn't generate a C-level symbol. It generates a
2948 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2949 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2951 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2952 do { unsigned int h, l;
2953 __asm__ __volatile__(
2954 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2955 __asm__ __volatile__(
2956 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2957 __asm__ __volatile__(
2958 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2962 AC_MSG_RESULT([yes])
2968 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2971 # does the amd64 assembler understand MPX instructions?
2972 # Note, this doesn't generate a C-level symbol. It generates a
2973 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2974 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2976 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2978 asm ("bndmov %bnd0,(%rsp)");
2979 asm ("bndldx 3(%rbx,%rdx), %bnd2");
2980 asm ("bnd call foo\n"
2987 AC_MSG_RESULT([yes])
2993 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2996 # does the amd64 assembler understand ADX instructions?
2997 # Note, this doesn't generate a C-level symbol. It generates a
2998 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
2999 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3001 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3003 asm ("adcxq %r14,%r8");
3007 AC_MSG_RESULT([yes])
3013 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3016 # does the amd64 assembler understand the RDRAND instruction?
3017 # Note, this doesn't generate a C-level symbol. It generates a
3018 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3019 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3021 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3023 asm ("rdrand %r14");
3024 asm ("rdrand %r14d");
3025 asm ("rdrand %r14w");
3028 ac_have_as_rdrand=yes
3029 AC_MSG_RESULT([yes])
3031 ac_have_as_rdrand=no
3035 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3038 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3040 # Note, this doesn't generate a C-level symbol. It generates a
3041 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3042 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3044 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3046 asm ("vcvtph2ps %xmm5, %ymm10");
3047 // If we put the dollar sign and zero together, the shell processing
3048 // this configure.ac script substitutes the command name in. Sigh.
3049 asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3053 AC_MSG_RESULT([yes])
3059 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3062 # does the x86/amd64 assembler understand MOVBE?
3063 # Note, this doesn't generate a C-level symbol. It generates a
3064 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3065 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3067 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3068 do { long long int x;
3069 __asm__ __volatile__(
3070 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3073 ac_have_as_movbe=yes
3074 AC_MSG_RESULT([yes])
3080 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3083 # Does the C compiler support the "ifunc" attribute
3084 # Note, this doesn't generate a C-level symbol. It generates a
3085 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3086 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3088 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3089 static void mytest(void) {}
3091 static void (*resolve_test(void))(void)
3093 return (void (*)(void))&mytest;
3096 void test(void) __attribute__((ifunc("resolve_test")));
3104 ac_have_ifunc_attr=yes
3105 AC_MSG_RESULT([yes])
3107 ac_have_ifunc_attr=no
3111 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3113 # Does the C compiler support the armv8 crc feature flag
3114 # Note, this doesn't generate a C-level symbol. It generates a
3115 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3116 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3118 save_CFLAGS="$CFLAGS"
3119 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3120 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3126 ac_have_armv8_crc_feature=yes
3127 AC_MSG_RESULT([yes])
3129 ac_have_armv8_crc_feature=no
3132 CFLAGS="$save_CFLAGS"
3134 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3137 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3138 # Note, this doesn't generate a C-level symbol. It generates a
3139 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3140 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3142 save_CFLAGS="$CFLAGS"
3143 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3144 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3147 __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3151 ac_have_armv81_feature=yes
3152 AC_MSG_RESULT([yes])
3154 ac_have_armv81_feature=no
3157 CFLAGS="$save_CFLAGS"
3159 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3162 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
3163 # when building the tool executables. I think we should get rid of it.
3165 # Check for TLS support in the compiler and linker
3166 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3168 [vg_cv_linktime_tls=yes],
3169 [vg_cv_linktime_tls=no])
3170 # Native compilation: check whether running a program using TLS succeeds.
3171 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3172 # succeeds but running programs using TLS fails.
3173 # Cross-compiling: check whether linking a program using TLS succeeds.
3174 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3175 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
3176 [vg_cv_tls=$enableval],
3177 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3181 [vg_cv_tls=$vg_cv_linktime_tls])])])
3183 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3184 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3188 #----------------------------------------------------------------------------
3189 # Solaris-specific checks.
3190 #----------------------------------------------------------------------------
3192 if test "$VGCONF_OS" = "solaris" ; then
3193 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3195 # Solaris-specific check determining if the Sun Studio Assembler is used to
3196 # build Valgrind. The test checks if the x86/amd64 assembler understands the
3197 # cmovl.l instruction, if yes then it's Sun Assembler.
3199 # C-level symbol: none
3200 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3202 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3203 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3205 __asm__ __volatile__("cmovl.l %edx, %eax");
3207 solaris_have_sun_studio_as=yes
3208 AC_MSG_RESULT([yes])
3210 solaris_have_sun_studio_as=no
3213 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3215 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3216 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3217 # See solaris/vgpreload-solaris.mapfile for details.
3218 # gcc on older Solaris instructs linker to include these symbols,
3219 # gcc on illumos and newer Solaris does not.
3221 # C-level symbol: none
3222 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3224 save_CFLAGS="$CFLAGS"
3225 CFLAGS="$CFLAGS -std=gnu99"
3226 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3227 temp_dir=$( /usr/bin/mktemp -d )
3228 cat <<_ACEOF >${temp_dir}/mylib.c
3230 int myfunc(void) { printf("LaPutyka\n"); }
3232 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3233 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3234 if test "x${xpg_present}" = "x" ; then
3235 solaris_xpg_symbols_present=no
3238 solaris_xpg_symbols_present=yes
3239 AC_MSG_RESULT([yes])
3242 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3243 CFLAGS="$save_CFLAGS"
3246 # Solaris-specific check determining if gcc enables largefile support by
3247 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3248 # variable with gcc flags which disable it.
3250 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3251 save_CFLAGS="$CFLAGS"
3252 CFLAGS="$CFLAGS -m32"
3253 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3254 return _LARGEFILE_SOURCE;
3256 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3257 AC_MSG_RESULT([yes])
3259 SOLARIS_UNDEF_LARGESOURCE=""
3263 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3266 # Solaris-specific check determining if /proc/self/cmdline
3267 # or /proc/<pid>/cmdline is supported.
3269 # C-level symbol: SOLARIS_PROC_CMDLINE
3270 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3272 AC_CHECK_FILE([/proc/self/cmdline],
3274 solaris_proc_cmdline=yes
3275 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3276 [Define to 1 if you have /proc/self/cmdline.])
3278 solaris_proc_cmdline=no
3280 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3283 # Solaris-specific check determining default platform for the Valgrind launcher.
3284 # Used in case the launcher cannot select platform by looking at the client
3285 # image (for example because the executable is a shell script).
3287 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3288 # Automake-level symbol: none
3290 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3291 # Get the ELF class of /bin/sh first.
3292 if ! test -f /bin/sh; then
3293 AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3295 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3296 case "$elf_class" in
3298 default_arch="$VGCONF_ARCH_PRI";
3301 if test "x$VGCONF_ARCH_SEC" != "x"; then
3302 default_arch="$VGCONF_ARCH_SEC"
3304 default_arch="$VGCONF_ARCH_PRI";
3308 AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3311 default_platform="$default_arch-$VGCONF_OS"
3312 AC_MSG_RESULT([$default_platform])
3313 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3314 [Default platform for Valgrind launcher.])
3317 # Solaris-specific check determining if the old syscalls are available.
3319 # C-level symbol: SOLARIS_OLD_SYSCALLS
3320 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3322 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3323 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3324 #include <sys/syscall.h>
3328 solaris_old_syscalls=yes
3329 AC_MSG_RESULT([yes])
3330 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3331 [Define to 1 if you have the old Solaris syscalls.])
3333 solaris_old_syscalls=no
3336 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3339 # Solaris-specific check determining if the new accept() syscall is available.
3342 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3345 # New syscall (available on illumos):
3346 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3347 # int version, int flags);
3349 # If the old syscall is present then the following syscall will fail with
3350 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3351 # available then it will fail with EINVAL (because the flags parameter is
3354 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3355 # Automake-level symbol: none
3357 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3358 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3359 #include <sys/syscall.h>
3363 syscall(SYS_accept, 0, 0, 0, 0, -1);
3364 return !(errno == EINVAL);
3366 AC_MSG_RESULT([yes])
3367 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3368 [Define to 1 if you have the new `accept' syscall.])
3374 # Solaris-specific check determining if the new illumos pipe() syscall is
3378 # longlong_t pipe();
3380 # New syscall (available on illumos):
3381 # int pipe(intptr_t arg, int flags);
3383 # If the old syscall is present then the following call will succeed, if the
3384 # new syscall is available then it will fail with EFAULT (because address 0
3385 # cannot be accessed).
3387 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3388 # Automake-level symbol: none
3390 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3391 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3392 #include <sys/syscall.h>
3396 syscall(SYS_pipe, 0, 0);
3397 return !(errno == EFAULT);
3399 AC_MSG_RESULT([yes])
3400 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3401 [Define to 1 if you have the new `pipe' syscall.])
3407 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3411 # int lwp_kill(id_t lwpid, int sig);
3413 # New syscall (available on Solaris 11):
3414 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3415 # int si_code, timespec_t *timeout);
3417 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3418 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3420 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3421 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3422 #include <sys/syscall.h>
3424 return !SYS_lwp_sigqueue;
3426 solaris_lwp_sigqueue_syscall=yes
3427 AC_MSG_RESULT([yes])
3428 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3429 [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3431 solaris_lwp_sigqueue_syscall=no
3434 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3437 # Solaris-specific check determining if the lwp_sigqueue() syscall
3438 # takes both pid and thread id arguments or just thread id.
3440 # Old syscall (available up to Solaris 11.3):
3441 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3442 # int si_code, timespec_t *timeout);
3444 # New syscall (available since Solaris 11.4):
3445 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3446 # int si_code, timespec_t *timeout);
3448 # If the old syscall is present then the following syscall will fail with
3449 # EINVAL (because signal is out of range); if the new syscall is available
3450 # then it will fail with ESRCH (because it would not find such thread in the
3453 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3454 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3456 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3457 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3458 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3459 #include <sys/syscall.h>
3463 syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3464 return !(errno == ESRCH);
3466 solaris_lwp_sigqueue_syscall_takes_pid=yes
3467 AC_MSG_RESULT([yes])
3468 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3469 [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3471 solaris_lwp_sigqueue_syscall_takes_pid=no
3474 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3475 test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3477 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3481 # Solaris-specific check determining if the new lwp_name() syscall is
3484 # New syscall (available on Solaris 11):
3485 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3487 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3488 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3490 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3491 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3492 #include <sys/syscall.h>
3494 return !SYS_lwp_name;
3496 solaris_lwp_name_syscall=yes
3497 AC_MSG_RESULT([yes])
3498 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3499 [Define to 1 if you have the new `lwp_name' syscall.])
3501 solaris_lwp_name_syscall=no
3504 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3507 # Solaris-specific check determining if the new getrandom() syscall is
3510 # New syscall (available on Solaris 11):
3511 # int getrandom(void *buf, size_t buflen, uint_t flags);
3513 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3514 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3516 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3517 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3518 #include <sys/syscall.h>
3520 return !SYS_getrandom;
3522 solaris_getrandom_syscall=yes
3523 AC_MSG_RESULT([yes])
3524 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3525 [Define to 1 if you have the new `getrandom' syscall.])
3527 solaris_getrandom_syscall=no
3530 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3533 # Solaris-specific check determining if the new zone() syscall subcodes
3534 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available. These subcodes
3535 # were added in Solaris 11 but are missing on illumos.
3537 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3538 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3540 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3541 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3542 #include <sys/zone.h>
3544 return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3546 solaris_zone_defunct=yes
3547 AC_MSG_RESULT([yes])
3548 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3549 [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3551 solaris_zone_defunct=no
3554 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3557 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3558 # for auditon(2) subcode of the auditsys() syscall are available.
3559 # These commands are available in Solaris 11 and illumos but were removed
3562 # C-level symbol: SOLARIS_AUDITON_STAT
3563 # Automake-level symbol: SOLARIS_AUDITON_STAT
3565 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3566 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3567 #include <bsm/audit.h>
3569 return !(A_GETSTAT && A_SETSTAT);
3571 solaris_auditon_stat=yes
3572 AC_MSG_RESULT([yes])
3573 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3574 [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3576 solaris_auditon_stat=no
3579 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3582 # Solaris-specific check determining if the new shmsys() syscall subcodes
3583 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3584 # These subcodes were added in Solaris 11 but are missing on illumos.
3586 # C-level symbol: SOLARIS_SHM_NEW
3587 # Automake-level symbol: SOLARIS_SHM_NEW
3589 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3590 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3591 #include <sys/ipc_impl.h>
3592 #include <sys/shm.h>
3593 #include <sys/shm_impl.h>
3595 return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3598 AC_MSG_RESULT([yes])
3599 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3600 [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3605 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3608 # Solaris-specific check determining if prxregset_t is available. Illumos
3609 # currently does not define it on the x86 platform.
3611 # C-level symbol: SOLARIS_PRXREGSET_T
3612 # Automake-level symbol: SOLARIS_PRXREGSET_T
3614 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3615 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3616 #include <sys/procfs_isa.h>
3618 return !sizeof(prxregset_t);
3620 solaris_prxregset_t=yes
3621 AC_MSG_RESULT([yes])
3622 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3623 [Define to 1 if you have the `prxregset_t' type.])
3625 solaris_prxregset_t=no
3628 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3631 # Solaris-specific check determining if the new frealpathat() syscall is
3634 # New syscall (available on Solaris 11.1):
3635 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
3637 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3638 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3640 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3641 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3642 #include <sys/syscall.h>
3644 return !SYS_frealpathat;
3646 solaris_frealpathat_syscall=yes
3647 AC_MSG_RESULT([yes])
3648 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3649 [Define to 1 if you have the new `frealpathat' syscall.])
3651 solaris_frealpathat_syscall=no
3654 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3657 # Solaris-specific check determining if the new uuidsys() syscall is
3660 # New syscall (available on newer Solaris):
3661 # int uuidsys(struct uuid *uuid);
3663 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3664 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3666 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3668 #include <sys/syscall.h>
3670 return !SYS_uuidsys;
3672 solaris_uuidsys_syscall=yes
3673 AC_MSG_RESULT([yes])
3674 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
3675 [Define to 1 if you have the new `uuidsys' syscall.])
3677 solaris_uuidsys_syscall=no
3680 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
3683 # Solaris-specific check determining if the new labelsys() syscall subcode
3684 # TNDB_GET_TNIP is available. This subcode was added in Solaris 11 but is
3685 # missing on illumos.
3687 # C-level symbol: SOLARIS_TNDB_GET_TNIP
3688 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
3690 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
3691 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3692 #include <sys/tsol/tndb.h>
3694 return !TNDB_GET_TNIP;
3696 solaris_tndb_get_tnip=yes
3697 AC_MSG_RESULT([yes])
3698 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
3699 [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
3701 solaris_tndb_get_tnip=no
3704 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
3707 # Solaris-specific check determining if the new labelsys() syscall opcodes
3708 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
3709 # added in Solaris 11 but are missing on illumos.
3711 # C-level symbol: SOLARIS_TSOL_CLEARANCE
3712 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
3714 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
3715 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3716 #include <sys/tsol/tsyscall.h>
3718 return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
3720 solaris_tsol_clearance=yes
3721 AC_MSG_RESULT([yes])
3722 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
3723 [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
3725 solaris_tsol_clearance=no
3728 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
3731 # Solaris-specific check determining if the new pset() syscall subcode
3732 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
3733 # is missing on illumos and Solaris 11.3.
3735 # C-level symbol: SOLARIS_PSET_GET_NAME
3736 # Automake-level symbol: SOLARIS_PSET_GET_NAME
3738 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
3739 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3740 #include <sys/pset.h>
3742 return !(PSET_GET_NAME);
3744 solaris_pset_get_name=yes
3745 AC_MSG_RESULT([yes])
3746 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
3747 [Define to 1 if you have the `PSET_GET_NAME' constants.])
3749 solaris_pset_get_name=no
3752 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
3755 # Solaris-specific check determining if the utimesys() syscall is
3756 # available (on illumos and older Solaris).
3758 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
3759 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
3761 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
3762 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3763 #include <sys/syscall.h>
3765 return !SYS_utimesys;
3767 solaris_utimesys_syscall=yes
3768 AC_MSG_RESULT([yes])
3769 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
3770 [Define to 1 if you have the `utimesys' syscall.])
3772 solaris_utimesys_syscall=no
3775 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
3778 # Solaris-specific check determining if the utimensat() syscall is
3779 # available (on newer Solaris).
3781 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3782 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3784 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
3785 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3786 #include <sys/syscall.h>
3788 return !SYS_utimensat;
3790 solaris_utimensat_syscall=yes
3791 AC_MSG_RESULT([yes])
3792 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
3793 [Define to 1 if you have the `utimensat' syscall.])
3795 solaris_utimensat_syscall=no
3798 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
3801 # Solaris-specific check determining if the spawn() syscall is available
3802 # (on newer Solaris).
3804 # C-level symbol: SOLARIS_SPAWN_SYSCALL
3805 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
3807 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
3808 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3809 #include <sys/syscall.h>
3813 solaris_spawn_syscall=yes
3814 AC_MSG_RESULT([yes])
3815 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
3816 [Define to 1 if you have the `spawn' syscall.])
3818 solaris_spawn_syscall=no
3821 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
3824 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
3825 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
3827 # C-level symbol: SOLARIS_MODCTL_MODNVL
3828 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
3830 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
3831 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3832 #include <sys/modctl.h>
3834 return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
3836 solaris_modctl_modnvl=yes
3837 AC_MSG_RESULT([yes])
3838 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
3839 [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
3841 solaris_modctl_modnvl=no
3844 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
3847 # Solaris-specific check determining whether nscd (name switch cache daemon)
3848 # attaches its door at /system/volatile/name_service_door (Solaris)
3849 # or at /var/run/name_service_door (illumos).
3851 # Note that /var/run is a symlink to /system/volatile on Solaris
3852 # but not vice versa on illumos.
3854 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3855 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3857 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
3858 if test -e /system/volatile/name_service_door; then
3859 solaris_nscd_door_system_volatile=yes
3860 AC_MSG_RESULT([/system/volatile/name_service_door])
3861 AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
3862 [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
3864 solaris_nscd_door_system_volatile=no
3865 AC_MSG_RESULT([/var/run/name_service_door])
3867 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
3870 # Solaris-specific check determining if the new gethrt() fasttrap is available.
3872 # New fasttrap (available on Solaris 11):
3873 # hrt_t *gethrt(void);
3875 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
3876 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
3878 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
3879 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3880 #include <sys/trap.h>
3884 solaris_gethrt_fasttrap=yes
3885 AC_MSG_RESULT([yes])
3886 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
3887 [Define to 1 if you have the new `gethrt' fasttrap.])
3889 solaris_gethrt_fasttrap=no
3892 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
3895 # Solaris-specific check determining if the new get_zone_offset() fasttrap
3898 # New fasttrap (available on Solaris 11):
3899 # zonehrtoffset_t *get_zone_offset(void);
3901 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3902 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3904 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
3905 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3906 #include <sys/trap.h>
3908 return !T_GETZONEOFFSET;
3910 solaris_getzoneoffset_fasttrap=yes
3911 AC_MSG_RESULT([yes])
3912 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
3913 [Define to 1 if you have the new `get_zone_offset' fasttrap.])
3915 solaris_getzoneoffset_fasttrap=no
3918 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
3921 # Solaris-specific check determining if the execve() syscall
3922 # takes fourth argument (flags) or not.
3924 # Old syscall (available on illumos):
3925 # int execve(const char *fname, const char **argv, const char **envp);
3927 # New syscall (available on Solaris):
3928 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
3930 # If the new syscall is present then it will fail with EINVAL (because flags
3931 # are invalid); if the old syscall is available then it will fail with ENOENT
3932 # (because the file could not be found).
3934 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3935 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3937 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
3938 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3939 #include <sys/syscall.h>
3943 syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
3944 return !(errno == EINVAL);
3946 solaris_execve_syscall_takes_flags=yes
3947 AC_MSG_RESULT([yes])
3948 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
3949 [Define to 1 if you have the new `execve' syscall which accepts flags.])
3951 solaris_execve_syscall_takes_flags=no
3954 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
3955 test x$solaris_execve_syscall_takes_flags = xyes)
3958 # Solaris-specific check determining version of the repository cache protocol.
3959 # Every Solaris version uses a different one, ranging from 21 to current 25.
3960 # The check is very ugly, though.
3962 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
3963 # Automake-level symbol: none
3965 AC_PATH_PROG(DIS_PATH, dis, false)
3966 if test "x$DIS_PATH" = "xfalse"; then
3967 AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
3969 AC_CHECK_LIB(scf, scf_handle_bind, [], [
3970 AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
3971 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3974 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
3975 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
3976 libscf=/usr/lib/64/libscf.so.1
3978 libscf=/usr/lib/libscf.so.1
3980 if ! $DIS_PATH -F scf_handle_bind $libscf | grep -q 0x526570; then
3981 AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
3982 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3984 hex=$( $DIS_PATH -F scf_handle_bind $libscf | sed -n 's/.*0x526570\(..\).*/\1/p' )
3985 if test -z "$hex"; then
3986 AC_MSG_WARN([Version of the repository cache protocol is empty?!])
3987 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3989 version=$( printf "%d\n" 0x$hex )
3990 AC_MSG_RESULT([$version])
3991 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
3992 [Version number of the repository door cache protocol.])
3995 # Solaris-specific check determining if "sysstat" segment reservation type
3998 # New "sysstat" segment reservation (available on Solaris 11.4):
3999 # - program header type: PT_SUNW_SYSSTAT
4000 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4002 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4003 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4005 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4006 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4007 #include <sys/auxv.h>
4009 return !AT_SUN_SYSSTAT_ADDR;
4011 solaris_reserve_sysstat_addr=yes
4012 AC_MSG_RESULT([yes])
4013 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4014 [Define to 1 if you have the new `sysstat' segment reservation.])
4016 solaris_reserve_sysstat_addr=no
4019 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4022 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4025 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4026 # - program header type: PT_SUNW_SYSSTAT_ZONE
4027 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4029 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4030 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4032 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4033 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4034 #include <sys/auxv.h>
4036 return !AT_SUN_SYSSTAT_ZONE_ADDR;
4038 solaris_reserve_sysstat_zone_addr=yes
4039 AC_MSG_RESULT([yes])
4040 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4041 [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4043 solaris_reserve_sysstat_zone_addr=no
4046 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4049 # Solaris-specific check determining if the system_stats() syscall is available
4050 # (on newer Solaris).
4052 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4053 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4055 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4056 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4057 #include <sys/syscall.h>
4059 return !SYS_system_stats;
4061 solaris_system_stats_syscall=yes
4062 AC_MSG_RESULT([yes])
4063 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4064 [Define to 1 if you have the `system_stats' syscall.])
4066 solaris_system_stats_syscall=no
4069 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4072 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4073 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4075 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4076 # Automake-level symbol: none
4078 AC_CHECK_TYPE([struct _fpchip_state],
4079 [solaris_fpchip_state_takes_underscore=yes],
4080 [solaris_fpchip_state_takes_underscore=no],
4081 [[#include <sys/regset.h>]])
4082 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4083 AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4084 [Define to 1 if fpregset_t defines struct _fpchip_state])
4088 # Solaris-specific check determining if schedctl page shared between kernel
4089 # and userspace program is executable (illumos, older Solaris) or not (newer
4092 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4093 # Automake-level symbol: none
4095 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4096 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4100 #include <schedctl.h>
4104 schedctl_t *scp = schedctl_init();
4108 int fd = open("/proc/self/map", O_RDONLY);
4113 while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4114 if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4115 fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4116 (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4117 return (map.pr_mflags & MA_EXEC);
4123 solaris_schedctl_page_exec=no
4126 solaris_schedctl_page_exec=yes
4127 AC_MSG_RESULT([yes])
4128 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4129 [Define to 1 if you have the schedctl page executable.])
4133 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4134 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4135 # an initial thread pointer for libc (newer Solaris).
4137 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4138 # Automake-level symbol: none
4140 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4141 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4142 #include <sys/fasttrap_isa.h>
4144 return !FT_SCRATCHSIZE;
4146 solaris_pt_sunwdtrace_thrp=yes
4147 AC_MSG_RESULT([yes])
4148 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4149 [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4151 solaris_pt_sunwdtrace_thrp=no
4156 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4157 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4158 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4159 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4160 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4161 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4162 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4163 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4164 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4165 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4166 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4167 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4168 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4169 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4170 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4171 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4172 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4173 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4174 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4175 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4176 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4177 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4178 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4179 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4180 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4181 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4182 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4183 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4184 fi # test "$VGCONF_OS" = "solaris"
4187 #----------------------------------------------------------------------------
4188 # Checks for C header files.
4189 #----------------------------------------------------------------------------
4191 AC_CHECK_HEADERS([ \
4209 # Verify whether the <linux/futex.h> header is usable.
4210 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4212 save_CFLAGS="$CFLAGS"
4213 CFLAGS="$CFLAGS -D__user="
4214 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4215 #include <linux/futex.h>
4219 ac_have_usable_linux_futex_h=yes
4220 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4221 [Define to 1 if you have a usable <linux/futex.h> header file.])
4222 AC_MSG_RESULT([yes])
4224 ac_have_usable_linux_futex_h=no
4227 CFLAGS="$save_CFLAGS"
4230 #----------------------------------------------------------------------------
4231 # Checks for typedefs, structures, and compiler characteristics.
4232 #----------------------------------------------------------------------------
4239 #----------------------------------------------------------------------------
4240 # Checks for library functions.
4241 #----------------------------------------------------------------------------
4245 AC_CHECK_LIB([pthread], [pthread_create])
4246 AC_CHECK_LIB([rt], [clock_gettime])
4259 pthread_barrier_init \
4260 pthread_condattr_setclock \
4261 pthread_mutex_timedlock \
4262 pthread_rwlock_timedrdlock \
4263 pthread_rwlock_timedwrlock \
4266 pthread_setname_np \
4287 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4288 # libraries with any shared object and/or executable. This is NOT what we
4289 # want for e.g. vgpreload_core-x86-linux.so
4292 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4293 [test x$ac_cv_func_pthread_barrier_init = xyes])
4294 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4295 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4296 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4297 [test x$ac_cv_func_pthread_spin_lock = xyes])
4298 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4299 [test x$ac_cv_func_pthread_setname_np = xyes])
4300 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4301 [test x$ac_cv_func_copy_file_range = xyes])
4302 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4303 [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4304 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4305 [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4307 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4308 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4309 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4310 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4311 [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4314 #----------------------------------------------------------------------------
4316 #----------------------------------------------------------------------------
4317 # Do we have a useable MPI setup on the primary and/or secondary targets?
4318 # On Linux, by default, assumes mpicc and -m32/-m64
4319 # Note: this is a kludge in that it assumes the specified mpicc
4320 # understands -m32/-m64 regardless of what is specified using
4322 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4323 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4326 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4327 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4328 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4329 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4330 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4331 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4332 mflag_primary=$FLAG_M32
4333 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4334 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4335 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4336 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4337 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4338 mflag_primary=$FLAG_M64
4339 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4340 mflag_primary="$FLAG_M32 -arch i386"
4341 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4342 mflag_primary="$FLAG_M64 -arch x86_64"
4346 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4347 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4348 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4349 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX ; then
4350 mflag_secondary=$FLAG_M32
4351 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4352 mflag_secondary="$FLAG_M32 -arch i386"
4357 [ --with-mpicc= Specify name of MPI2-ised C compiler],
4362 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4363 ## use these values in the check for a functioning mpicc.
4365 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4366 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4367 AM_COND_IF([VGCONF_OS_IS_LINUX],
4368 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4369 LDFLAGS_MPI="-fpic -shared"])
4370 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4371 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4372 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4373 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4374 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4375 LDFLAGS_MPI="-fpic -shared"])
4377 AC_SUBST([CFLAGS_MPI])
4378 AC_SUBST([LDFLAGS_MPI])
4381 ## See if MPI_CC works for the primary target
4383 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4385 saved_CFLAGS=$CFLAGS
4387 CFLAGS="$CFLAGS_MPI $mflag_primary"
4388 saved_LDFLAGS="$LDFLAGS"
4389 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4390 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4394 int ni, na, nd, comb;
4395 int r = MPI_Init(NULL,NULL);
4396 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4397 r |= MPI_Finalize();
4400 ac_have_mpi2_pri=yes
4401 AC_MSG_RESULT([yes, $MPI_CC])
4407 CFLAGS=$saved_CFLAGS
4408 LDFLAGS="$saved_LDFLAGS"
4409 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4411 ## See if MPI_CC works for the secondary target. Complication: what if
4412 ## there is no secondary target? We need this to then fail.
4413 ## Kludge this by making MPI_CC something which will surely fail in
4416 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4418 saved_CFLAGS=$CFLAGS
4419 saved_LDFLAGS="$LDFLAGS"
4420 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4421 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4422 CC="$MPI_CC this will surely fail"
4426 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4427 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4431 int ni, na, nd, comb;
4432 int r = MPI_Init(NULL,NULL);
4433 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4434 r |= MPI_Finalize();
4437 ac_have_mpi2_sec=yes
4438 AC_MSG_RESULT([yes, $MPI_CC])
4444 CFLAGS=$saved_CFLAGS
4445 LDFLAGS="$saved_LDFLAGS"
4446 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4449 #----------------------------------------------------------------------------
4450 # Other library checks
4451 #----------------------------------------------------------------------------
4452 # There now follow some tests for Boost, and OpenMP. These
4453 # tests are present because Drd has some regression tests that use
4454 # these packages. All regression test programs all compiled only
4455 # for the primary target. And so it is important that the configure
4456 # checks that follow, use the correct -m32 or -m64 flag for the
4457 # primary target (called $mflag_primary). Otherwise, we can end up
4458 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4459 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4460 # only build (meaning, the primary target is x86-linux), the build
4461 # of the regtest programs that use Boost fails, because they are
4462 # build as 32-bit (IN THIS EXAMPLE).
4464 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4465 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4468 # Check whether the boost library 1.35 or later has been installed.
4469 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4471 AC_MSG_CHECKING([for boost])
4474 safe_CXXFLAGS=$CXXFLAGS
4475 CXXFLAGS="$mflag_primary"
4477 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4479 AC_LINK_IFELSE([AC_LANG_SOURCE([
4480 #include <boost/thread.hpp>
4481 static void thread_func(void)
4483 int main(int argc, char** argv)
4485 boost::thread t(thread_func);
4490 ac_have_boost_1_35=yes
4491 AC_SUBST([BOOST_CFLAGS], [])
4492 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4493 AC_MSG_RESULT([yes])
4495 ac_have_boost_1_35=no
4500 CXXFLAGS=$safe_CXXFLAGS
4503 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4506 # does this compiler support -fopenmp, does it have the include file
4507 # <omp.h> and does it have libgomp ?
4509 AC_MSG_CHECKING([for OpenMP])
4512 CFLAGS="-fopenmp $mflag_primary -Werror"
4514 AC_LINK_IFELSE([AC_LANG_SOURCE([
4516 int main(int argc, char** argv)
4524 AC_MSG_RESULT([yes])
4531 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4534 # Check for __builtin_popcount
4535 AC_MSG_CHECKING([for __builtin_popcount()])
4536 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4538 __builtin_popcount(2);
4541 AC_MSG_RESULT([yes])
4542 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4543 [Define to 1 if compiler provides __builtin_popcount().])
4548 # Check for __builtin_clz
4549 AC_MSG_CHECKING([for __builtin_clz()])
4550 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4555 AC_MSG_RESULT([yes])
4556 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4557 [Define to 1 if compiler provides __builtin_clz().])
4562 # Check for __builtin_ctz
4563 AC_MSG_CHECKING([for __builtin_ctz()])
4564 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4569 AC_MSG_RESULT([yes])
4570 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4571 [Define to 1 if compiler provides __builtin_ctz().])
4576 # does this compiler have built-in functions for atomic memory access for the
4578 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4581 CFLAGS="$mflag_primary"
4583 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4585 return (__sync_bool_compare_and_swap(&variable, 1, 2)
4586 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4588 ac_have_builtin_atomic_primary=yes
4589 AC_MSG_RESULT([yes])
4590 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])
4592 ac_have_builtin_atomic_primary=no
4598 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4599 [test x$ac_have_builtin_atomic_primary = xyes])
4602 # does this compiler have built-in functions for atomic memory access for the
4603 # secondary target ?
4605 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4607 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
4610 CFLAGS="$mflag_secondary"
4612 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4614 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
4616 ac_have_builtin_atomic_secondary=yes
4617 AC_MSG_RESULT([yes])
4619 ac_have_builtin_atomic_secondary=no
4627 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
4628 [test x$ac_have_builtin_atomic_secondary = xyes])
4630 # does this compiler have built-in functions for atomic memory access on
4631 # 64-bit integers for all targets ?
4633 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
4635 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4638 uint64_t variable = 1;
4639 return __sync_add_and_fetch(&variable, 1)
4641 ac_have_builtin_atomic64_primary=yes
4643 ac_have_builtin_atomic64_primary=no
4646 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4649 CFLAGS="$mflag_secondary"
4651 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4654 uint64_t variable = 1;
4655 return __sync_add_and_fetch(&variable, 1)
4657 ac_have_builtin_atomic64_secondary=yes
4659 ac_have_builtin_atomic64_secondary=no
4666 if test x$ac_have_builtin_atomic64_primary = xyes && \
4667 test x$VGCONF_PLATFORM_SEC_CAPS = x \
4668 -o x$ac_have_builtin_atomic64_secondary = xyes; then
4669 AC_MSG_RESULT([yes])
4670 ac_have_builtin_atomic64=yes
4673 ac_have_builtin_atomic64=no
4676 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
4677 [test x$ac_have_builtin_atomic64 = xyes])
4680 # does g++ have built-in functions for atomic memory access ?
4681 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
4683 safe_CXXFLAGS=$CXXFLAGS
4684 CXXFLAGS="$mflag_primary"
4687 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4689 return (__sync_bool_compare_and_swap(&variable, 1, 2)
4690 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4692 ac_have_builtin_atomic_cxx=yes
4693 AC_MSG_RESULT([yes])
4694 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
4696 ac_have_builtin_atomic_cxx=no
4701 CXXFLAGS=$safe_CXXFLAGS
4703 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
4706 if test x$ac_have_usable_linux_futex_h = xyes \
4707 -a x$ac_have_builtin_atomic_primary = xyes; then
4708 ac_enable_linux_ticket_lock_primary=yes
4710 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
4711 [test x$ac_enable_linux_ticket_lock_primary = xyes])
4713 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
4714 -a x$ac_have_usable_linux_futex_h = xyes \
4715 -a x$ac_have_builtin_atomic_secondary = xyes; then
4716 ac_enable_linux_ticket_lock_secondary=yes
4718 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
4719 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
4722 # does libstdc++ support annotating shared pointers ?
4723 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
4725 safe_CXXFLAGS=$CXXFLAGS
4726 CXXFLAGS="-std=c++0x"
4729 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4732 std::shared_ptr<int> p
4734 ac_have_shared_ptr=yes
4736 ac_have_shared_ptr=no
4738 if test x$ac_have_shared_ptr = xyes; then
4739 # If compilation of the program below fails because of a syntax error
4740 # triggered by substituting one of the annotation macros then that
4741 # means that libstdc++ supports these macros.
4742 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4743 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
4744 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
4747 std::shared_ptr<int> p
4749 ac_have_shared_pointer_annotation=no
4752 ac_have_shared_pointer_annotation=yes
4753 AC_MSG_RESULT([yes])
4754 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
4755 [Define to 1 if libstd++ supports annotating shared pointers])
4758 ac_have_shared_pointer_annotation=no
4763 CXXFLAGS=$safe_CXXFLAGS
4765 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
4766 [test x$ac_have_shared_pointer_annotation = xyes])
4769 #----------------------------------------------------------------------------
4770 # Ok. We're done checking.
4771 #----------------------------------------------------------------------------
4773 # Nb: VEX/Makefile is generated from Makefile.vex.in.
4776 VEX/Makefile:Makefile.vex.in
4785 gdbserver_tests/Makefile
4786 gdbserver_tests/solaris/Makefile
4792 memcheck/tests/Makefile
4793 memcheck/tests/common/Makefile
4794 memcheck/tests/amd64/Makefile
4795 memcheck/tests/x86/Makefile
4796 memcheck/tests/linux/Makefile
4797 memcheck/tests/darwin/Makefile
4798 memcheck/tests/solaris/Makefile
4799 memcheck/tests/amd64-linux/Makefile
4800 memcheck/tests/arm64-linux/Makefile
4801 memcheck/tests/x86-linux/Makefile
4802 memcheck/tests/amd64-solaris/Makefile
4803 memcheck/tests/x86-solaris/Makefile
4804 memcheck/tests/ppc32/Makefile
4805 memcheck/tests/ppc64/Makefile
4806 memcheck/tests/s390x/Makefile
4807 memcheck/tests/mips32/Makefile
4808 memcheck/tests/mips64/Makefile
4809 memcheck/tests/vbit-test/Makefile
4811 cachegrind/tests/Makefile
4812 cachegrind/tests/x86/Makefile
4813 cachegrind/cg_annotate
4816 callgrind/callgrind_annotate
4817 callgrind/callgrind_control
4818 callgrind/tests/Makefile
4820 helgrind/tests/Makefile
4822 drd/scripts/download-and-build-splash2
4825 massif/tests/Makefile
4830 lackey/tests/Makefile
4833 none/tests/scripts/Makefile
4834 none/tests/amd64/Makefile
4835 none/tests/ppc32/Makefile
4836 none/tests/ppc64/Makefile
4837 none/tests/x86/Makefile
4838 none/tests/arm/Makefile
4839 none/tests/arm64/Makefile
4840 none/tests/s390x/Makefile
4841 none/tests/mips32/Makefile
4842 none/tests/mips64/Makefile
4843 none/tests/nanomips/Makefile
4844 none/tests/linux/Makefile
4845 none/tests/darwin/Makefile
4846 none/tests/solaris/Makefile
4847 none/tests/amd64-linux/Makefile
4848 none/tests/x86-linux/Makefile
4849 none/tests/amd64-darwin/Makefile
4850 none/tests/x86-darwin/Makefile
4851 none/tests/amd64-solaris/Makefile
4852 none/tests/x86-solaris/Makefile
4854 exp-bbv/tests/Makefile
4855 exp-bbv/tests/x86/Makefile
4856 exp-bbv/tests/x86-linux/Makefile
4857 exp-bbv/tests/amd64-linux/Makefile
4858 exp-bbv/tests/ppc32-linux/Makefile
4859 exp-bbv/tests/arm-linux/Makefile
4863 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
4864 [chmod +x coregrind/link_tool_exe_linux])
4865 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
4866 [chmod +x coregrind/link_tool_exe_darwin])
4867 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
4868 [chmod +x coregrind/link_tool_exe_solaris])
4873 Maximum build arch: ${ARCH_MAX}
4874 Primary build arch: ${VGCONF_ARCH_PRI}
4875 Secondary build arch: ${VGCONF_ARCH_SEC}
4876 Build OS: ${VGCONF_OS}
4877 Link Time Optimisation: ${vg_cv_lto}
4878 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
4879 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
4880 Platform variant: ${VGCONF_PLATVARIANT}
4881 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
4882 Default supp files: ${DEFAULT_SUPP}