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.11.0.SVN],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign subdir-objects])
18 #----------------------------------------------------------------------------
19 # Checks for various programs.
20 #----------------------------------------------------------------------------
21 CFLAGS="-Wno-long-long $CFLAGS"
22 CXXFLAGS="-Wno-long-long $CXXFLAGS"
29 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
30 # autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
31 # base (eg. most likely as Darwin-specific tests) we'll need one of the
33 # - put AC_PROG_OBJC in a Darwin-specific part of this file
34 # - Use AC_PROG_OBJC here and up the minimum autoconf version
35 # - Use the following, which is apparently equivalent:
36 # m4_ifdef([AC_PROG_OBJC],
38 # [AC_CHECK_TOOL([OBJC], [gcc])
40 # AC_SUBST([OBJCFLAGS])
43 # provide a very basic definition for AC_PROG_SED if it's not provided by
44 # autoconf (as e.g. in autoconf 2.59).
45 m4_ifndef([AC_PROG_SED],
46 [AC_DEFUN([AC_PROG_SED],
48 AC_CHECK_PROGS([SED],[gsed sed])])])
51 # If no AR variable was specified, look up the name of the archiver. Otherwise
52 # do not touch the AR variable.
53 if test "x$AR" = "x"; then
54 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
56 AC_ARG_VAR([AR],[Archiver command])
58 # Check for the compiler support
59 if test "${GCC}" != "yes" ; then
60 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
63 # figure out where perl lives
64 AC_PATH_PROG(PERL, perl)
66 # figure out where gdb lives
67 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
68 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
70 # some older automake's don't have it so try something on our own
71 ifdef([AM_PROG_AS],[AM_PROG_AS],
81 # Check if 'diff' supports -u (universal diffs) and use it if possible.
83 AC_MSG_CHECKING([for diff -u])
86 # Comparing two identical files results in 0.
87 tmpfile="tmp-xxx-yyy-zzz"
89 if diff -u $tmpfile $tmpfile ; then
99 # We don't want gcc < 3.0
100 AC_MSG_CHECKING([for a supported version of gcc])
102 # Obtain the compiler version.
104 # A few examples of how the ${CC} --version output looks like:
106 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
107 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
108 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
109 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
110 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
111 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
112 # 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)
113 # Clang: clang version 2.9 (tags/RELEASE_29/final)
114 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
115 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
118 if test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ; then
120 # Don't use -dumpversion with clang: it will always produce "4.2.1".
121 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
122 CFLAGS="$CFLAGS -Wno-tautological-compare -Wno-cast-align -Wno-self-assign"
123 CXXFLAGS="$CXXFLAGS -Wno-tautological-compare -Wno-cast-align -Wno-self-assign"
126 gcc_version=`${CC} -dumpversion 2>/dev/null`
127 if test "x$gcc_version" = x; then
128 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
132 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang)
134 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
135 # statements have to be quoted.
136 case "${is_clang}-${gcc_version}" in
137 notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
138 AC_MSG_RESULT([ok (${gcc_version})])
140 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
141 AC_MSG_RESULT([ok (clang-${gcc_version})])
144 AC_MSG_RESULT([no (${gcc_version})])
145 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9])
149 #----------------------------------------------------------------------------
150 # Arch/OS/platform tests.
151 #----------------------------------------------------------------------------
152 # We create a number of arch/OS/platform-related variables. We prefix them
153 # all with "VGCONF_" which indicates that they are defined at
154 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
155 # variables used when compiling C files.
159 AC_MSG_CHECKING([for a supported CPU])
161 # ARCH_MAX reflects the most that this CPU can do: for example if it
162 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
163 # Ditto for amd64. It is used for more configuration below, but is not used
166 # Power PC returns powerpc for Big Endian. This was not changed when Little
167 # Endian support was added to the 64-bit architecture. The 64-bit Little
168 # Endian systems explicitly state le in the host_cpu. For clarity in the
169 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianess of
170 # the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
171 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
172 # Endianess. The name PPC64 or ppc64 to 64-bit systems of either Endianess.
173 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
174 # Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
177 case "${host_cpu}" in
179 AC_MSG_RESULT([ok (${host_cpu})])
184 AC_MSG_RESULT([ok (${host_cpu})])
189 # this only referrs to 64-bit Big Endian
190 AC_MSG_RESULT([ok (${host_cpu})])
195 # this only referrs to 64-bit Little Endian
196 AC_MSG_RESULT([ok (${host_cpu})])
201 # On Linux this means only a 32-bit capable CPU.
202 AC_MSG_RESULT([ok (${host_cpu})])
207 AC_MSG_RESULT([ok (${host_cpu})])
212 AC_MSG_RESULT([ok (${host_cpu})])
217 AC_MSG_RESULT([ok (${host_cpu})])
222 AC_MSG_RESULT([ok (${host_cpu})])
227 AC_MSG_RESULT([ok (${host_cpu})])
232 AC_MSG_RESULT([ok (${host_cpu})])
237 AC_MSG_RESULT([ok (${host_cpu})])
242 AC_MSG_RESULT([ok (${host_cpu})])
246 AC_MSG_RESULT([no (${host_cpu})])
247 AC_MSG_ERROR([Unsupported host architecture. Sorry])
251 #----------------------------------------------------------------------------
253 # Sometimes it's convenient to subvert the bi-arch build system and
254 # just have a single build even though the underlying platform is
255 # capable of both. Hence handle --enable-only64bit and
256 # --enable-only32bit. Complain if both are issued :-)
257 # [Actually, if either of these options are used, I think both get built,
258 # but only one gets installed. So if you use an in-place build, both can be
261 # Check if a 64-bit only build has been requested
262 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
263 [AC_ARG_ENABLE(only64bit,
264 [ --enable-only64bit do a 64-bit only build],
265 [vg_cv_only64bit=$enableval],
266 [vg_cv_only64bit=no])])
268 # Check if a 32-bit only build has been requested
269 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
270 [AC_ARG_ENABLE(only32bit,
271 [ --enable-only32bit do a 32-bit only build],
272 [vg_cv_only32bit=$enableval],
273 [vg_cv_only32bit=no])])
276 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
278 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
281 #----------------------------------------------------------------------------
283 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
284 # compilation of many C files via -VGO_$(VGCONF_OS) and
285 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
286 AC_MSG_CHECKING([for a supported OS])
293 AC_MSG_RESULT([ok (${host_os})])
296 # Ok, this is linux. Check the kernel version
297 AC_MSG_CHECKING([for the kernel version])
303 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
304 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x or Linux 3.x])
308 AC_MSG_RESULT([2.4 family (${kernel})])
309 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
313 AC_MSG_RESULT([unsupported (${kernel})])
314 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
321 AC_MSG_RESULT([ok (${host_os})])
323 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
324 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
325 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
326 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
327 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
329 AC_MSG_CHECKING([for the kernel version])
332 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
333 # has only one relevant version, the OS version. The `uname` check
334 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
335 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
336 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
337 # and we don't know of an macros similar to __GLIBC__ to get that info.
339 # XXX: `uname -r` won't do the right thing for cross-compiles, but
340 # that's not a problem yet.
342 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
343 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
344 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
345 # time support for 10.5 (the 9.* pattern just below), I'll leave it
346 # in for now, just in case anybody wants to give it a try. But I'm
347 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
350 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
351 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
352 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
353 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
356 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
357 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
358 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
359 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
362 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
363 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
364 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
365 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
368 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
369 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
370 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
371 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
374 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
375 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
376 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
377 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
380 AC_MSG_RESULT([unsupported (${kernel})])
381 AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x and 13.x (Mac OS X 10.6/7/8/9)])
387 AC_MSG_RESULT([no (${host_os})])
388 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
392 #----------------------------------------------------------------------------
394 # If we are building on a 64 bit platform test to see if the system
395 # supports building 32 bit programs and disable 32 bit support if it
396 # does not support building 32 bit programs
398 case "$ARCH_MAX-$VGCONF_OS" in
399 amd64-linux|ppc64be-linux|arm64-linux)
400 AC_MSG_CHECKING([for 32 bit build support])
403 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
408 vg_cv_only64bit="yes"
411 CFLAGS=$safe_CFLAGS;;
414 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
416 [--enable-only32bit was specified but system does not support 32 bit builds])
419 #----------------------------------------------------------------------------
421 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
422 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
423 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
424 # above) will be "amd64" since that reflects the most that this cpu can do,
425 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
426 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
427 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
428 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
429 AC_SUBST(VGCONF_ARCH_PRI)
431 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
432 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
433 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
434 # It is empty if there is no secondary target.
435 AC_SUBST(VGCONF_ARCH_SEC)
437 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
438 # The entire system, including regression and performance tests, will be
439 # built for this target. The "_CAPS" indicates that the name is in capital
440 # letters, and it also uses '_' rather than '-' as a separator, because it's
441 # used to create various Makefile variables, which are all in caps by
442 # convention and cannot contain '-' characters. This is in contrast to
443 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
444 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
446 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
447 # Valgrind and tools will also be built for this target, but not the
448 # regression or performance tests.
450 # By default, the primary arch is the same as the "max" arch, as commented
451 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
452 # the big case statement just below here, in the case where we're building
453 # on a 64 bit machine but have been requested only to do a 32 bit build.
454 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
456 AC_MSG_CHECKING([for a supported CPU/OS combination])
458 # NB. The load address for a given platform may be specified in more
459 # than one place, in some cases, depending on whether we're doing a biarch,
460 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
461 # Be careful to give consistent values in all subcases. Also, all four
462 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
463 # even if it is to "0xUNSET".
465 case "$ARCH_MAX-$VGCONF_OS" in
467 VGCONF_ARCH_PRI="x86"
469 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
470 VGCONF_PLATFORM_SEC_CAPS=""
471 valt_load_address_pri_norml="0x38000000"
472 valt_load_address_pri_inner="0x28000000"
473 valt_load_address_sec_norml="0xUNSET"
474 valt_load_address_sec_inner="0xUNSET"
475 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
478 valt_load_address_sec_norml="0xUNSET"
479 valt_load_address_sec_inner="0xUNSET"
480 if test x$vg_cv_only64bit = xyes; then
481 VGCONF_ARCH_PRI="amd64"
483 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
484 VGCONF_PLATFORM_SEC_CAPS=""
485 valt_load_address_pri_norml="0x38000000"
486 valt_load_address_pri_inner="0x28000000"
487 elif test x$vg_cv_only32bit = xyes; then
488 VGCONF_ARCH_PRI="x86"
490 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
491 VGCONF_PLATFORM_SEC_CAPS=""
492 valt_load_address_pri_norml="0x38000000"
493 valt_load_address_pri_inner="0x28000000"
495 VGCONF_ARCH_PRI="amd64"
496 VGCONF_ARCH_SEC="x86"
497 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
498 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
499 valt_load_address_pri_norml="0x38000000"
500 valt_load_address_pri_inner="0x28000000"
501 valt_load_address_sec_norml="0x38000000"
502 valt_load_address_sec_inner="0x28000000"
504 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
507 VGCONF_ARCH_PRI="ppc32"
509 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
510 VGCONF_PLATFORM_SEC_CAPS=""
511 valt_load_address_pri_norml="0x38000000"
512 valt_load_address_pri_inner="0x28000000"
513 valt_load_address_sec_norml="0xUNSET"
514 valt_load_address_sec_inner="0xUNSET"
515 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
518 valt_load_address_sec_norml="0xUNSET"
519 valt_load_address_sec_inner="0xUNSET"
520 if test x$vg_cv_only64bit = xyes; then
521 VGCONF_ARCH_PRI="ppc64be"
523 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
524 VGCONF_PLATFORM_SEC_CAPS=""
525 valt_load_address_pri_norml="0x38000000"
526 valt_load_address_pri_inner="0x28000000"
527 elif test x$vg_cv_only32bit = xyes; then
528 VGCONF_ARCH_PRI="ppc32"
530 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
531 VGCONF_PLATFORM_SEC_CAPS=""
532 valt_load_address_pri_norml="0x38000000"
533 valt_load_address_pri_inner="0x28000000"
535 VGCONF_ARCH_PRI="ppc64be"
536 VGCONF_ARCH_SEC="ppc32"
537 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
538 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
539 valt_load_address_pri_norml="0x38000000"
540 valt_load_address_pri_inner="0x28000000"
541 valt_load_address_sec_norml="0x38000000"
542 valt_load_address_sec_inner="0x28000000"
544 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
547 # Little Endian is only supported on PPC64
548 valt_load_address_sec_norml="0xUNSET"
549 valt_load_address_sec_inner="0xUNSET"
550 VGCONF_ARCH_PRI="ppc64le"
552 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
553 VGCONF_PLATFORM_SEC_CAPS=""
554 valt_load_address_pri_norml="0x38000000"
555 valt_load_address_pri_inner="0x28000000"
556 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
558 # Darwin gets identified as 32-bit even when it supports 64-bit.
559 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
560 # all Macs support both 32-bit and 64-bit, so we just build both. If
561 # someone has a really old 32-bit only machine they can (hopefully?)
562 # build with --enable-only32bit. See bug 243362.
563 x86-darwin|amd64-darwin)
565 valt_load_address_sec_norml="0xUNSET"
566 valt_load_address_sec_inner="0xUNSET"
567 if test x$vg_cv_only64bit = xyes; then
568 VGCONF_ARCH_PRI="amd64"
570 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
571 VGCONF_PLATFORM_SEC_CAPS=""
572 valt_load_address_pri_norml="0x138000000"
573 valt_load_address_pri_inner="0x128000000"
574 elif test x$vg_cv_only32bit = xyes; then
575 VGCONF_ARCH_PRI="x86"
577 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
578 VGCONF_PLATFORM_SEC_CAPS=""
579 VGCONF_ARCH_PRI_CAPS="x86"
580 valt_load_address_pri_norml="0x38000000"
581 valt_load_address_pri_inner="0x28000000"
583 VGCONF_ARCH_PRI="amd64"
584 VGCONF_ARCH_SEC="x86"
585 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
586 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
587 valt_load_address_pri_norml="0x138000000"
588 valt_load_address_pri_inner="0x128000000"
589 valt_load_address_sec_norml="0x38000000"
590 valt_load_address_sec_inner="0x28000000"
592 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
595 VGCONF_ARCH_PRI="arm"
596 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
597 VGCONF_PLATFORM_SEC_CAPS=""
598 valt_load_address_pri_norml="0x38000000"
599 valt_load_address_pri_inner="0x28000000"
600 valt_load_address_sec_norml="0xUNSET"
601 valt_load_address_sec_inner="0xUNSET"
602 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
605 valt_load_address_sec_norml="0xUNSET"
606 valt_load_address_sec_inner="0xUNSET"
607 if test x$vg_cv_only64bit = xyes; then
608 VGCONF_ARCH_PRI="arm64"
610 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
611 VGCONF_PLATFORM_SEC_CAPS=""
612 valt_load_address_pri_norml="0x38000000"
613 valt_load_address_pri_inner="0x28000000"
614 elif test x$vg_cv_only32bit = xyes; then
615 VGCONF_ARCH_PRI="arm"
617 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
618 VGCONF_PLATFORM_SEC_CAPS=""
619 valt_load_address_pri_norml="0x38000000"
620 valt_load_address_pri_inner="0x28000000"
622 VGCONF_ARCH_PRI="arm64"
623 VGCONF_ARCH_SEC="arm"
624 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
625 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
626 valt_load_address_pri_norml="0x38000000"
627 valt_load_address_pri_inner="0x28000000"
628 valt_load_address_sec_norml="0x38000000"
629 valt_load_address_sec_inner="0x28000000"
631 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
634 VGCONF_ARCH_PRI="s390x"
636 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
637 VGCONF_PLATFORM_SEC_CAPS=""
638 # To improve branch prediction hit rate we want to have
639 # the generated code close to valgrind (host) code
640 valt_load_address_pri_norml="0x800000000"
641 valt_load_address_pri_inner="0x810000000"
642 valt_load_address_sec_norml="0xUNSET"
643 valt_load_address_sec_inner="0xUNSET"
644 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
647 VGCONF_ARCH_PRI="mips32"
648 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
649 VGCONF_PLATFORM_SEC_CAPS=""
650 valt_load_address_pri_norml="0x38000000"
651 valt_load_address_pri_inner="0x28000000"
652 valt_load_address_sec_norml="0xUNSET"
653 valt_load_address_sec_inner="0xUNSET"
654 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
657 VGCONF_ARCH_PRI="mips64"
658 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
659 VGCONF_PLATFORM_SEC_CAPS=""
660 valt_load_address_pri_norml="0x38000000"
661 valt_load_address_pri_inner="0x28000000"
662 valt_load_address_sec_norml="0xUNSET"
663 valt_load_address_sec_inner="0xUNSET"
664 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
667 VGCONF_ARCH_PRI="unknown"
668 VGCONF_ARCH_SEC="unknown"
669 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
670 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
671 valt_load_address_pri_norml="0xUNSET"
672 valt_load_address_pri_inner="0xUNSET"
673 valt_load_address_sec_norml="0xUNSET"
674 valt_load_address_sec_inner="0xUNSET"
675 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
676 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
680 #----------------------------------------------------------------------------
682 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
684 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
685 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
686 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
687 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
688 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
689 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
690 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
691 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
692 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
693 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
694 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
695 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
696 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
697 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
698 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
699 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
700 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
701 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
702 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
703 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
704 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
705 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
706 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
707 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
708 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
710 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
712 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
713 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
714 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
715 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
716 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
717 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
718 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
719 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
720 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
721 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
722 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
723 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
724 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
725 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
726 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
727 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
728 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
729 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
730 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
731 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
732 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
733 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
734 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
735 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
736 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
737 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
738 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
739 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
740 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
743 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
744 # Relies on the assumption that the primary and secondary targets are
745 # for the same OS, so therefore only necessary to test the primary.
746 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
747 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
748 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
749 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
750 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
751 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
752 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
753 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
754 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
755 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
756 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
757 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
758 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
759 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
762 # Sometimes, in the Makefile.am files, it's useful to know whether or not
763 # there is a secondary target.
764 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
765 test x$VGCONF_PLATFORM_SEC_CAPS != x)
767 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
768 dnl fallback definition
769 dnl The macro is courtesy of Dave Hart:
770 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
771 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
772 if test -z "$$1_TRUE"; then :
781 #----------------------------------------------------------------------------
783 #----------------------------------------------------------------------------
785 # Check if this should be built as an inner Valgrind, to be run within
786 # another Valgrind. Choose the load address accordingly.
787 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
788 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
789 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
790 [AC_ARG_ENABLE(inner,
791 [ --enable-inner enables self-hosting],
792 [vg_cv_inner=$enableval],
794 if test "$vg_cv_inner" = yes; then
795 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
796 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
797 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
799 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
800 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
804 #----------------------------------------------------------------------------
805 # Define MIPS_PAGE_SHIFT (--with-pagesize)
806 #----------------------------------------------------------------------------
807 AC_ARG_WITH(pagesize,
808 [ --with-pagesize= override detected page size (4, 16 or 64)],
813 if test "$psize" = "0"; then
814 psizer=`getconf PAGESIZE`
815 psize=$((${psizer}/1024))
818 if test "$psize" = "4"; then
819 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
820 elif test "$psize" = "16"; then
821 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
822 elif test "$psize" = "64"; then
823 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
825 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
827 AC_MSG_RESULT([checking for Pagesize... ${psize}k])
830 #----------------------------------------------------------------------------
831 # Extra fine-tuning of installation directories
832 #----------------------------------------------------------------------------
834 [ --with-tmpdir=PATH Specify path for temporary files],
837 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
838 AC_SUBST(VG_TMPDIR, [$tmpdir])
841 #----------------------------------------------------------------------------
842 # Libc and suppressions
843 #----------------------------------------------------------------------------
844 # This variable will collect the suppression files to be used.
845 AC_SUBST(DEFAULT_SUPP)
847 AC_CHECK_HEADER([features.h])
849 if test x$ac_cv_header_features_h = xyes; then
850 rm -f conftest.$ac_ext
851 cat <<_ACEOF >conftest.$ac_ext
852 #include <features.h>
853 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
854 glibc version is: __GLIBC__ __GLIBC_MINOR__
857 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
860 # not really a version check
861 AC_EGREP_CPP([DARWIN_LIBC], [
862 #include <sys/cdefs.h>
863 #if defined(__DARWIN_VERS_1050)
867 GLIBC_VERSION="darwin")
869 # not really a version check
870 AC_EGREP_CPP([BIONIC_LIBC], [
871 #if defined(__ANDROID__)
875 GLIBC_VERSION="bionic")
878 AC_MSG_CHECKING([the GLIBC_VERSION version])
880 case "${GLIBC_VERSION}" in
882 AC_MSG_RESULT(2.2 family)
883 AC_DEFINE([GLIBC_2_2], 1, [Define to 1 if you're using glibc 2.2.x])
884 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
885 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
886 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
890 AC_MSG_RESULT(2.3 family)
891 AC_DEFINE([GLIBC_2_3], 1, [Define to 1 if you're using glibc 2.3.x])
892 DEFAULT_SUPP="glibc-2.3.supp ${DEFAULT_SUPP}"
893 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
894 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
898 AC_MSG_RESULT(2.4 family)
899 AC_DEFINE([GLIBC_2_4], 1, [Define to 1 if you're using glibc 2.4.x])
900 DEFAULT_SUPP="glibc-2.4.supp ${DEFAULT_SUPP}"
901 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
902 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
906 AC_MSG_RESULT(2.5 family)
907 AC_DEFINE([GLIBC_2_5], 1, [Define to 1 if you're using glibc 2.5.x])
908 DEFAULT_SUPP="glibc-2.5.supp ${DEFAULT_SUPP}"
909 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
910 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
913 AC_MSG_RESULT(2.6 family)
914 AC_DEFINE([GLIBC_2_6], 1, [Define to 1 if you're using glibc 2.6.x])
915 DEFAULT_SUPP="glibc-2.6.supp ${DEFAULT_SUPP}"
916 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
917 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
920 AC_MSG_RESULT(2.7 family)
921 AC_DEFINE([GLIBC_2_7], 1, [Define to 1 if you're using glibc 2.7.x])
922 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
923 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
924 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
927 AC_MSG_RESULT(2.8 family)
928 AC_DEFINE([GLIBC_2_8], 1, [Define to 1 if you're using glibc 2.8.x])
929 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
930 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
931 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
934 AC_MSG_RESULT(2.9 family)
935 AC_DEFINE([GLIBC_2_9], 1, [Define to 1 if you're using glibc 2.9.x])
936 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
937 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
938 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
941 AC_MSG_RESULT(2.10 family)
942 AC_DEFINE([GLIBC_2_10], 1, [Define to 1 if you're using glibc 2.10.x])
943 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
944 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
945 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
948 AC_MSG_RESULT(2.11 family)
949 AC_DEFINE([GLIBC_2_11], 1, [Define to 1 if you're using glibc 2.11.x])
950 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
951 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
952 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
955 AC_MSG_RESULT(2.12 family)
956 AC_DEFINE([GLIBC_2_12], 1, [Define to 1 if you're using glibc 2.12.x])
957 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
958 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
959 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
962 AC_MSG_RESULT(2.13 family)
963 AC_DEFINE([GLIBC_2_13], 1, [Define to 1 if you're using glibc 2.13.x])
964 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
965 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
966 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
969 AC_MSG_RESULT(2.14 family)
970 AC_DEFINE([GLIBC_2_14], 1, [Define to 1 if you're using glibc 2.14.x])
971 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
972 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
973 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
976 AC_MSG_RESULT(2.15 family)
977 AC_DEFINE([GLIBC_2_15], 1, [Define to 1 if you're using glibc 2.15.x])
978 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
979 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
980 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
983 AC_MSG_RESULT(2.16 family)
984 AC_DEFINE([GLIBC_2_16], 1, [Define to 1 if you're using glibc 2.16.x])
985 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
986 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
987 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
990 AC_MSG_RESULT(2.17 family)
991 AC_DEFINE([GLIBC_2_17], 1, [Define to 1 if you're using glibc 2.17.x])
992 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
993 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
994 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
997 AC_MSG_RESULT(2.18 family)
998 AC_DEFINE([GLIBC_2_18], 1, [Define to 1 if you're using glibc 2.18.x])
999 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1000 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1001 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1004 AC_MSG_RESULT(2.19 family)
1005 AC_DEFINE([GLIBC_2_19], 1, [Define to 1 if you're using glibc 2.19.x])
1006 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1007 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1008 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1011 AC_MSG_RESULT(2.20 family)
1012 AC_DEFINE([GLIBC_2_20], 1, [Define to 1 if you're using glibc 2.20.x])
1013 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1014 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1015 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1018 AC_MSG_RESULT(Darwin)
1019 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1020 # DEFAULT_SUPP set by kernel version check above.
1023 AC_MSG_RESULT(Bionic)
1024 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1025 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1029 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1030 AC_MSG_ERROR([Valgrind requires glibc version 2.2 - 2.19])
1031 AC_MSG_ERROR([or Darwin or Bionic libc])
1035 AC_SUBST(GLIBC_VERSION)
1038 # Add default suppressions for the X client libraries. Make no
1039 # attempt to detect whether such libraries are installed on the
1040 # build machine (or even if any X facilities are present); just
1041 # add the suppressions antidisirregardless.
1042 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1043 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1045 # Add glibc and X11 suppressions for exp-sgcheck
1046 DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
1049 #----------------------------------------------------------------------------
1050 # Platform variants?
1051 #----------------------------------------------------------------------------
1053 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1054 # But there are times where we need a bit more control. The motivating
1055 # and currently only case is Android: this is almost identical to
1056 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1057 # platform variant tags, which get passed in the compile as
1058 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1060 # In almost all cases, the <variant> bit is "vanilla". But for Android
1061 # it is "android" instead.
1063 # Consequently (eg), plain arm-linux would build with
1065 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1067 # whilst an Android build would have
1069 # -DVGP_arm_linux -DVGPV_arm_linux_android
1071 # Same for x86. The setup of the platform variant is pushed relatively far
1072 # down this file in order that we can inspect any of the variables set above.
1074 # In the normal case ..
1075 VGCONF_PLATVARIANT="vanilla"
1078 if test "$GLIBC_VERSION" = "bionic";
1080 VGCONF_PLATVARIANT="android"
1083 AC_SUBST(VGCONF_PLATVARIANT)
1086 # FIXME: do we also want to define automake variables
1087 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1088 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1089 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1090 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1091 # that's what we'd need to do to use this, since what we'd want to write
1094 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1096 # Hmm. Can't think of a nice clean solution to this.
1098 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1099 test x$VGCONF_PLATVARIANT = xvanilla)
1100 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1101 test x$VGCONF_PLATVARIANT = xandroid)
1104 #----------------------------------------------------------------------------
1105 # Checking for various library functions and other definitions
1106 #----------------------------------------------------------------------------
1108 # Check for AT_FDCWD
1110 AC_MSG_CHECKING([for AT_FDCWD])
1111 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1118 ac_have_at_fdcwd=yes
1119 AC_MSG_RESULT([yes])
1125 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1127 # Check for stpncpy function definition in string.h
1128 # This explicitly checks with _GNU_SOURCE defined since that is also
1129 # used in the test case (some systems might define it without anyway
1130 # since stpncpy is part of The Open Group Base Specifications Issue 7
1131 # IEEE Std 1003.1-2008.
1132 AC_MSG_CHECKING([for stpncpy])
1133 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1140 char *r = stpncpy(d, s, n);
1142 ac_have_gnu_stpncpy=yes
1143 AC_MSG_RESULT([yes])
1145 ac_have_gnu_stpncpy=no
1149 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1151 # Check for PTRACE_GETREGS
1153 AC_MSG_CHECKING([for PTRACE_GETREGS])
1154 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1156 #include <sys/ptrace.h>
1157 #include <sys/user.h>
1160 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1162 AC_MSG_RESULT([yes])
1163 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1164 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1170 # Check for CLOCK_MONOTONIC
1172 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1174 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1178 clock_gettime(CLOCK_MONOTONIC, &t);
1181 AC_MSG_RESULT([yes])
1182 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1183 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1189 # Check for PTHREAD_RWLOCK_T
1191 AC_MSG_CHECKING([for pthread_rwlock_t])
1193 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1195 #include <pthread.h>
1197 pthread_rwlock_t rwl;
1199 AC_MSG_RESULT([yes])
1200 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1201 [Define to 1 if you have the `pthread_rwlock_t' type.])
1207 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1209 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1211 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1213 #include <pthread.h>
1215 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1217 AC_MSG_RESULT([yes])
1218 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1219 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1225 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1227 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1229 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1231 #include <pthread.h>
1233 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1235 AC_MSG_RESULT([yes])
1236 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1237 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1243 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1245 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1247 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1249 #include <pthread.h>
1251 return (PTHREAD_MUTEX_RECURSIVE_NP);
1253 AC_MSG_RESULT([yes])
1254 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1255 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1261 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1263 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1265 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1267 #include <pthread.h>
1269 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1272 AC_MSG_RESULT([yes])
1273 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1274 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1280 # Check whether pthread_mutex_t has a member called __m_kind.
1282 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1283 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1285 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1288 [#include <pthread.h>])
1291 # Check whether pthread_mutex_t has a member called __data.__kind.
1293 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1294 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1296 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1299 [#include <pthread.h>])
1302 # does this compiler support -maltivec and does it have the include file
1305 AC_MSG_CHECKING([for Altivec])
1310 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1311 #include <altivec.h>
1313 vector unsigned int v;
1316 AC_MSG_RESULT([yes])
1317 AC_DEFINE([HAS_ALTIVEC], 1,
1318 [Define to 1 if gcc/as can do Altivec.])
1325 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
1328 # Check that both: the compiler supports -mvsx and that the assembler
1329 # understands VSX instructions. If either of those doesn't work,
1330 # conclude that we can't do VSX. NOTE: basically this is a kludge
1331 # in that it conflates two things that should be separate -- whether
1332 # the compiler understands the flag vs whether the assembler
1333 # understands the opcodes. This really ought to be cleaned up
1334 # and done properly, like it is for x86/x86_64.
1336 AC_MSG_CHECKING([for VSX])
1341 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1342 #include <altivec.h>
1344 vector unsigned int v;
1345 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1348 AC_MSG_RESULT([yes])
1355 AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1358 AC_MSG_CHECKING([that assembler knows DFP])
1360 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1362 __asm__ __volatile__("dadd 1, 2, 3");
1363 __asm__ __volatile__("dcffix 1, 2");
1366 AC_MSG_RESULT([yes])
1373 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1378 __asm__ __volatile__("dadd 1, 2, 3");
1379 __asm__ __volatile__("dcffix 1, 2");
1382 AC_MSG_RESULT([yes])
1390 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
1393 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1394 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1396 _Decimal64 x = 0.0DD;
1398 ac_gcc_have_dfp_type=yes
1399 AC_MSG_RESULT([yes])
1401 ac_gcc_have_dfp_type=no
1405 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_gcc_have_dfp_type = xyes)
1408 AC_MSG_CHECKING([that assembler knows ISA 2.07 ])
1410 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1412 __asm__ __volatile__("mtvsrd 1,2 ");
1414 ac_asm_have_isa_2_07=yes
1415 AC_MSG_RESULT([yes])
1417 ac_asm_have_isa_2_07=no
1421 AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes)
1423 # Check for pthread_create@GLIBC2.0
1424 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1428 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1429 extern int pthread_create_glibc_2_0(void*, const void*,
1430 void *(*)(void*), void*);
1431 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1435 * Apparently on PowerPC linking this program succeeds and generates an
1436 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1438 #error This test does not work properly on PowerPC.
1440 pthread_create_glibc_2_0(0, 0, 0, 0);
1444 ac_have_pthread_create_glibc_2_0=yes
1445 AC_MSG_RESULT([yes])
1446 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1447 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1449 ac_have_pthread_create_glibc_2_0=no
1454 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1455 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1458 # Check for dlinfo RTLD_DI_TLS_MODID
1459 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1463 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1470 size_t sizes[10000];
1471 size_t modid_offset;
1472 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1475 ac_have_dlinfo_rtld_di_tls_modid=yes
1476 AC_MSG_RESULT([yes])
1477 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1478 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1480 ac_have_dlinfo_rtld_di_tls_modid=no
1485 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1486 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1489 # Check for eventfd_t, eventfd() and eventfd_read()
1490 AC_MSG_CHECKING([for eventfd()])
1492 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1493 #include <sys/eventfd.h>
1499 eventfd_read(fd, &ev);
1502 AC_MSG_RESULT([yes])
1503 AC_DEFINE([HAVE_EVENTFD], 1,
1504 [Define to 1 if you have the `eventfd' function.])
1505 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1506 [Define to 1 if you have the `eventfd_read' function.])
1512 # Check whether compiler can process #include <thread> without errors
1513 # clang 3.3 cannot process <thread> from e.g.
1514 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1516 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1518 safe_CXXFLAGS=$CXXFLAGS
1521 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1525 ac_cxx_can_include_thread_header=yes
1526 AC_MSG_RESULT([yes])
1528 ac_cxx_can_include_thread_header=no
1531 CXXFLAGS=$safe_CXXFLAGS
1534 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1537 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1538 # of the user_regs_struct from sys/user.h. They are structurally the same
1539 # but we get either one or the other.
1541 AC_CHECK_TYPE([struct user_regs_struct],
1542 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1543 [[#include <sys/ptrace.h>]
1544 [#include <sys/time.h>]
1545 [#include <sys/user.h>]])
1546 if test "$sys_user_has_user_regs" = "yes"; then
1547 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1548 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1552 #----------------------------------------------------------------------------
1553 # Checking for supported compiler flags.
1554 #----------------------------------------------------------------------------
1556 # does this compiler support -m32 ?
1557 AC_MSG_CHECKING([if gcc accepts -m32])
1562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1566 AC_MSG_RESULT([yes])
1576 # does this compiler support -m64 ?
1577 AC_MSG_CHECKING([if gcc accepts -m64])
1582 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1586 AC_MSG_RESULT([yes])
1596 # does this compiler support -march=mips32 (mips32 default) ?
1597 AC_MSG_CHECKING([if gcc accepts -march=mips32])
1600 CFLAGS="$CFLAGS -march=mips32"
1602 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1605 FLAG_MIPS32="-march=mips32"
1606 AC_MSG_RESULT([yes])
1613 AC_SUBST(FLAG_MIPS32)
1616 # does this compiler support -march=mips64 (mips64 default) ?
1617 AC_MSG_CHECKING([if gcc accepts -march=mips64])
1620 CFLAGS="$CFLAGS -march=mips64"
1622 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1625 FLAG_MIPS64="-march=mips64"
1626 AC_MSG_RESULT([yes])
1633 AC_SUBST(FLAG_MIPS64)
1636 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1637 AC_MSG_CHECKING([if gcc accepts -march=octeon])
1640 CFLAGS="$CFLAGS -march=octeon"
1642 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1645 FLAG_OCTEON="-march=octeon"
1646 AC_MSG_RESULT([yes])
1653 AC_SUBST(FLAG_OCTEON)
1656 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1657 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1660 CFLAGS="$CFLAGS -march=octeon2"
1662 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1665 FLAG_OCTEON2="-march=octeon2"
1666 AC_MSG_RESULT([yes])
1673 AC_SUBST(FLAG_OCTEON2)
1676 # does this compiler support -mmmx ?
1677 AC_MSG_CHECKING([if gcc accepts -mmmx])
1682 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1686 AC_MSG_RESULT([yes])
1696 # does this compiler support -msse ?
1697 AC_MSG_CHECKING([if gcc accepts -msse])
1702 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1706 AC_MSG_RESULT([yes])
1716 # does this compiler support -mpreferred-stack-boundary=2 when
1717 # generating code for a 32-bit target? Note that we only care about
1718 # this when generating code for (32-bit) x86, so if the compiler
1719 # doesn't recognise -m32 it's no big deal. We'll just get code for
1720 # the Memcheck and other helper functions, that is a bit slower than
1721 # it could be, on x86; and no difference at all on any other platform.
1722 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
1725 CFLAGS="-mpreferred-stack-boundary=2 -m32"
1727 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1730 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
1731 AC_MSG_RESULT([yes])
1733 PREFERRED_STACK_BOUNDARY_2=""
1738 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
1741 # Convenience function to check whether GCC supports a particular
1742 # warning option. Takes two arguments, first the warning flag name
1743 # to check (without -W), then the conditional name to set if that
1744 # warning flag is supported.
1745 AC_DEFUN([AC_GCC_WARNING_COND],[
1746 AC_MSG_CHECKING([if gcc accepts -W$1])
1749 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1750 has_warning_flag=yes
1751 AC_MSG_RESULT([yes])], [
1753 AC_MSG_RESULT([no])])
1755 AM_CONDITIONAL([$2], test x$has_warning_flag = xyes)
1758 AC_GCC_WARNING_COND([pointer-sign], [HAS_POINTER_SIGN_WARNING])
1759 AC_GCC_WARNING_COND([write-strings], [HAS_WRITE_STRINGS_WARNING])
1761 # Convenience function to check whether GCC supports a particular
1762 # warning option. Similar to AC_GCC_WARNING_COND, but does a
1763 # substitution instead of setting an conditional. Takes two arguments,
1764 # first the warning flag name to check (without -W), then the
1765 # substitution name to set with -Wno-warning-flag if the flag exists,
1766 # or the empty string if the compiler doesn't accept the flag. Note
1767 # that checking is done against the warning flag itself, but the
1768 # substitution is then done to cancel the warning flag.
1769 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
1770 AC_MSG_CHECKING([if gcc accepts -W$1])
1773 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1774 AC_SUBST([$2], [-Wno-$1])
1775 AC_MSG_RESULT([yes])], [
1777 AC_MSG_RESULT([no])])
1781 AC_GCC_WARNING_SUBST_NO([empty-body], [FLAG_W_NO_EMPTY_BODY])
1782 AC_GCC_WARNING_SUBST_NO([format-zero-length], [FLAG_W_NO_FORMAT_ZERO_LENGTH])
1783 AC_GCC_WARNING_SUBST_NO([tautological-compare], [FLAG_W_NO_TAUTOLOGICAL_COMPARE])
1784 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
1785 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
1786 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
1787 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
1788 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
1791 # does this compiler support -Wextra or the older -W ?
1793 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1798 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1801 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1802 AC_MSG_RESULT([-Wextra])
1805 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1808 AC_SUBST([FLAG_W_EXTRA], [-W])
1811 AC_SUBST([FLAG_W_EXTRA], [])
1812 AC_MSG_RESULT([not supported])
1818 # does this compiler support -fno-stack-protector ?
1819 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1822 CFLAGS="-fno-stack-protector"
1824 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1827 no_stack_protector=yes
1828 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1829 AC_MSG_RESULT([yes])
1831 no_stack_protector=no
1832 FLAG_FNO_STACK_PROTECTOR=""
1837 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1839 if test x$no_stack_protector = xyes; then
1840 CFLAGS="$CFLAGS -fno-stack-protector"
1841 CXXFLAGS="$CXXFLAGS -fno-stack-protector"
1845 # does this compiler support --param inline-unit-growth=... ?
1847 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1850 CFLAGS="--param inline-unit-growth=900"
1852 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1855 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1856 ["--param inline-unit-growth=900"])
1857 AC_MSG_RESULT([yes])
1859 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1865 # does this compiler support -gdwarf-4 -fdebug-types-section ?
1867 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1870 CFLAGS="-gdwarf-4 -fdebug-types-section"
1872 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1876 AC_MSG_RESULT([yes])
1881 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1885 # does this compiler support -gstabs ?
1887 AC_MSG_CHECKING([if gcc accepts -gstabs])
1891 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1895 AC_MSG_RESULT([yes])
1901 AM_CONDITIONAL([HAVE_GSTABS], [test x$ac_have_gstabs = xyes])
1904 # does this compiler support nested functions ?
1906 AC_MSG_CHECKING([if gcc accepts nested functions])
1908 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1909 int foo() { return 1; }
1912 ac_have_nested_functions=yes
1913 AC_MSG_RESULT([yes])
1915 ac_have_nested_functions=no
1918 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
1921 # does this compiler support the 'p' constraint in ASM statements ?
1923 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
1925 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1927 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
1929 ac_have_asm_constraint_p=yes
1930 AC_MSG_RESULT([yes])
1932 ac_have_asm_constraint_p=no
1935 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
1938 # We want to use use the -Ttext-segment option to the linker.
1939 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
1940 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
1941 # semantics are NOT what we want (GNU gold -Ttext is fine).
1943 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
1944 # will reside. -Ttext aligns just the .text section start (but not any
1947 # So test for -Ttext-segment which is supported by all bfd ld versions
1948 # and use that if it exists. If it doesn't exist it must be an older
1949 # version of gold and we can fall back to using -Ttext which has the
1952 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
1955 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml"
1958 [AC_LANG_SOURCE([int _start () { return 0; }])],
1960 linker_using_t_text="no"
1961 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
1962 AC_MSG_RESULT([yes])
1964 linker_using_t_text="yes"
1965 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
1970 # If the linker only supports -Ttext (not -Ttext-segment) then we will
1971 # have to strip any build-id ELF NOTEs from the staticly linked tools.
1972 # Otherwise the build-id NOTE might end up at the default load address.
1973 # (Pedantically if the linker is gold then -Ttext is fine, but newer
1974 # gold versions also support -Ttext-segment. So just assume that unless
1975 # we can use -Ttext-segment we need to strip the build-id NOTEs.
1976 if test "x${linker_using_t_text}" = "xyes"; then
1977 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
1978 # does the linker support -Wl,--build-id=none ? Note, it's
1979 # important that we test indirectly via whichever C compiler
1980 # is selected, rather than testing /usr/bin/ld or whatever
1982 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1984 CFLAGS="-Wl,--build-id=none"
1987 [AC_LANG_PROGRAM([ ], [return 0;])],
1989 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1990 AC_MSG_RESULT([yes])
1992 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1996 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
1997 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2001 # does the ppc assembler support "mtocrf" et al?
2002 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2004 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2005 __asm__ __volatile__("mtocrf 4,0");
2006 __asm__ __volatile__("mfocrf 0,4");
2008 ac_have_as_ppc_mftocrf=yes
2009 AC_MSG_RESULT([yes])
2011 ac_have_as_ppc_mftocrf=no
2014 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2015 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2019 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2020 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2022 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2023 do { typedef struct {
2027 dbl_pair_t dbl_pair[3];
2028 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2031 ac_have_as_ppc_fpPO=yes
2032 AC_MSG_RESULT([yes])
2034 ac_have_as_ppc_fpPO=no
2037 if test x$ac_have_as_ppc_fpPO = xyes ; then
2038 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2042 # does the x86/amd64 assembler understand SSE3 instructions?
2043 # Note, this doesn't generate a C-level symbol. It generates a
2044 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2045 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2047 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2048 do { long long int x;
2049 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
2053 AC_MSG_RESULT([yes])
2059 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2062 # Ditto for SSSE3 instructions (note extra S)
2063 # Note, this doesn't generate a C-level symbol. It generates a
2064 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2065 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2067 save_CFLAGS="$CFLAGS"
2068 CFLAGS="$CFLAGS -msse"
2069 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2070 do { long long int x;
2071 __asm__ __volatile__(
2072 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2075 ac_have_as_ssse3=yes
2076 AC_MSG_RESULT([yes])
2081 CFLAGS="$save_CFLAGS"
2083 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2086 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2087 # Note, this doesn't generate a C-level symbol. It generates a
2088 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2089 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2090 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2092 __asm__ __volatile__(
2093 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2096 ac_have_as_pclmulqdq=yes
2097 AC_MSG_RESULT([yes])
2099 ac_have_as_pclmulqdq=no
2103 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2106 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2107 # Note, this doesn't generate a C-level symbol. It generates a
2108 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2109 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2110 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2113 * Carry-less multiplication of xmm1 with xmm2 and store the result in
2114 * xmm3. The immediate is used to determine which quadwords of xmm1 and
2115 * xmm2 should be used.
2117 __asm__ __volatile__(
2118 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2121 ac_have_as_vpclmulqdq=yes
2122 AC_MSG_RESULT([yes])
2124 ac_have_as_vpclmulqdq=no
2128 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2131 # does the x86/amd64 assembler understand the LZCNT instruction?
2132 # Note, this doesn't generate a C-level symbol. It generates a
2133 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2134 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2136 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2138 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2141 ac_have_as_lzcnt=yes
2142 AC_MSG_RESULT([yes])
2148 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2151 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2152 # Note, this doesn't generate a C-level symbol. It generates a
2153 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2154 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2156 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2158 __asm__ __volatile__("1: loopnel 1b\n");
2161 ac_have_as_loopnel=yes
2162 AC_MSG_RESULT([yes])
2164 ac_have_as_loopnel=no
2168 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2171 # does the x86/amd64 assembler understand ADDR32 ?
2172 # Note, this doesn't generate a C-level symbol. It generates a
2173 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2174 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2176 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2178 asm volatile ("addr32 rep movsb");
2181 ac_have_as_addr32=yes
2182 AC_MSG_RESULT([yes])
2184 ac_have_as_addr32=no
2188 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2191 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2192 # Note, this doesn't generate a C-level symbol. It generates a
2193 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2194 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2196 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2197 do { long long int x;
2198 __asm__ __volatile__(
2199 "crc32q %%r15,%%r15" : : : "r15" );
2200 __asm__ __volatile__(
2201 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2202 __asm__ __volatile__(
2203 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2206 ac_have_as_sse42=yes
2207 AC_MSG_RESULT([yes])
2213 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2216 # does the x86/amd64 assembler understand AVX instructions?
2217 # Note, this doesn't generate a C-level symbol. It generates a
2218 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2219 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2221 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2222 do { long long int x;
2223 __asm__ __volatile__(
2224 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2225 __asm__ __volatile__(
2226 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2230 AC_MSG_RESULT([yes])
2236 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2239 # does the x86/amd64 assembler understand AVX2 instructions?
2240 # Note, this doesn't generate a C-level symbol. It generates a
2241 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2242 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2244 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2245 do { long long int x;
2246 __asm__ __volatile__(
2247 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2248 __asm__ __volatile__(
2249 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2253 AC_MSG_RESULT([yes])
2259 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2262 # does the x86/amd64 assembler understand TSX instructions and
2263 # the XACQUIRE/XRELEASE prefixes?
2264 # Note, this doesn't generate a C-level symbol. It generates a
2265 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2266 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2268 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2270 __asm__ __volatile__(
2273 " xacquire lock incq 0(%rsp) \n\t"
2274 " xrelease lock incq 0(%rsp) \n"
2279 AC_MSG_RESULT([yes])
2285 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2288 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2289 # Note, this doesn't generate a C-level symbol. It generates a
2290 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2291 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2293 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2294 do { unsigned int h, l;
2295 __asm__ __volatile__(
2296 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2297 __asm__ __volatile__(
2298 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2302 AC_MSG_RESULT([yes])
2308 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2311 # does the x86/amd64 assembler understand FMA instructions?
2312 # Note, this doesn't generate a C-level symbol. It generates a
2313 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2314 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2316 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2317 do { unsigned int h, l;
2318 __asm__ __volatile__(
2319 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2320 __asm__ __volatile__(
2321 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2322 __asm__ __volatile__(
2323 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2327 AC_MSG_RESULT([yes])
2333 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2336 # does the amd64 assembler understand MPX instructions?
2337 # Note, this doesn't generate a C-level symbol. It generates a
2338 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2339 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2341 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2342 asm ("bndmov %bnd0,(%rsp)")
2345 AC_MSG_RESULT([yes])
2351 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2354 # Does the C compiler support the "ifunc" attribute
2355 # Note, this doesn't generate a C-level symbol. It generates a
2356 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2357 # does the x86/amd64 assembler understand MOVBE?
2358 # Note, this doesn't generate a C-level symbol. It generates a
2359 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2360 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2363 do { long long int x;
2364 __asm__ __volatile__(
2365 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
2368 ac_have_as_movbe=yes
2369 AC_MSG_RESULT([yes])
2375 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2378 # Does the C compiler support the "ifunc" attribute
2379 # Note, this doesn't generate a C-level symbol. It generates a
2380 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2381 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2383 AC_LINK_IFELSE([AC_LANG_SOURCE([[
2384 static void mytest(void) {}
2386 static void (*resolve_test(void))(void)
2388 return (void (*)(void))&mytest;
2391 void test(void) __attribute__((ifunc("resolve_test")));
2399 ac_have_ifunc_attr=yes
2400 AC_MSG_RESULT([yes])
2402 ac_have_ifunc_attr=no
2406 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2409 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
2410 # when building the tool executables. I think we should get rid of it.
2412 # Check for TLS support in the compiler and linker
2413 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2415 [vg_cv_linktime_tls=yes],
2416 [vg_cv_linktime_tls=no])
2417 # Native compilation: check whether running a program using TLS succeeds.
2418 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2419 # succeeds but running programs using TLS fails.
2420 # Cross-compiling: check whether linking a program using TLS succeeds.
2421 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2422 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
2423 [vg_cv_tls=$enableval],
2424 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2428 [vg_cv_tls=$vg_cv_linktime_tls])])])
2430 if test "$vg_cv_tls" = yes; then
2431 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2435 #----------------------------------------------------------------------------
2436 # Checks for C header files.
2437 #----------------------------------------------------------------------------
2440 AC_CHECK_HEADERS([ \
2456 # Verify whether the <linux/futex.h> header is usable.
2457 AC_MSG_CHECKING([if <linux/futex.h> is usable])
2459 save_CFLAGS="$CFLAGS"
2460 CFLAGS="$CFLAGS -D__user="
2461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2462 #include <linux/futex.h>
2466 ac_have_usable_linux_futex_h=yes
2467 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
2468 [Define to 1 if you have a usable <linux/futex.h> header file.])
2469 AC_MSG_RESULT([yes])
2471 ac_have_usable_linux_futex_h=no
2474 CFLAGS="$save_CFLAGS"
2477 #----------------------------------------------------------------------------
2478 # Checks for typedefs, structures, and compiler characteristics.
2479 #----------------------------------------------------------------------------
2486 #----------------------------------------------------------------------------
2487 # Checks for library functions.
2488 #----------------------------------------------------------------------------
2492 AC_CHECK_LIB([pthread], [pthread_create])
2493 AC_CHECK_LIB([rt], [clock_gettime])
2506 pthread_barrier_init \
2507 pthread_condattr_setclock \
2508 pthread_mutex_timedlock \
2509 pthread_rwlock_timedrdlock \
2510 pthread_rwlock_timedwrlock \
2513 pthread_setname_np \
2529 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
2530 # libraries with any shared object and/or executable. This is NOT what we
2531 # want for e.g. vgpreload_core-x86-linux.so
2534 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
2535 [test x$ac_cv_func_pthread_barrier_init = xyes])
2536 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
2537 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
2538 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
2539 [test x$ac_cv_func_pthread_spin_lock = xyes])
2540 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
2541 [test x$ac_cv_func_pthread_setname_np = xyes])
2543 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2544 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
2545 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
2546 [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
2549 #----------------------------------------------------------------------------
2551 #----------------------------------------------------------------------------
2552 # Do we have a useable MPI setup on the primary and/or secondary targets?
2553 # On Linux, by default, assumes mpicc and -m32/-m64
2554 # Note: this is a kludge in that it assumes the specified mpicc
2555 # understands -m32/-m64 regardless of what is specified using
2557 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
2558 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
2561 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
2562 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
2563 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
2564 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2565 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
2566 mflag_primary=$FLAG_M32
2567 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
2568 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
2569 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
2570 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
2571 mflag_primary=$FLAG_M64
2572 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
2573 mflag_primary="$FLAG_M32 -arch i386"
2574 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
2575 mflag_primary="$FLAG_M64 -arch x86_64"
2579 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2580 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
2581 mflag_secondary=$FLAG_M32
2582 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2583 mflag_secondary="$FLAG_M32 -arch i386"
2588 [ --with-mpicc= Specify name of MPI2-ised C compiler],
2593 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
2594 ## use these values in the check for a functioning mpicc.
2596 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
2597 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
2598 AM_COND_IF([VGCONF_OS_IS_LINUX],
2599 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2600 LDFLAGS_MPI="-fpic -shared"])
2601 AM_COND_IF([VGCONF_OS_IS_DARWIN],
2602 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2603 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2605 AC_SUBST([CFLAGS_MPI])
2606 AC_SUBST([LDFLAGS_MPI])
2609 ## See if MPI_CC works for the primary target
2611 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
2613 saved_CFLAGS=$CFLAGS
2615 CFLAGS="$CFLAGS_MPI $mflag_primary"
2616 saved_LDFLAGS="$LDFLAGS"
2617 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
2618 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2622 int ni, na, nd, comb;
2623 int r = MPI_Init(NULL,NULL);
2624 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2625 r |= MPI_Finalize();
2628 ac_have_mpi2_pri=yes
2629 AC_MSG_RESULT([yes, $MPI_CC])
2635 CFLAGS=$saved_CFLAGS
2636 LDFLAGS="$saved_LDFLAGS"
2637 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
2639 ## See if MPI_CC works for the secondary target. Complication: what if
2640 ## there is no secondary target? We need this to then fail.
2641 ## Kludge this by making MPI_CC something which will surely fail in
2644 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2646 saved_CFLAGS=$CFLAGS
2647 saved_LDFLAGS="$LDFLAGS"
2648 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
2649 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
2650 CC="$MPI_CC this will surely fail"
2654 CFLAGS="$CFLAGS_MPI $mflag_secondary"
2655 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2659 int ni, na, nd, comb;
2660 int r = MPI_Init(NULL,NULL);
2661 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2662 r |= MPI_Finalize();
2665 ac_have_mpi2_sec=yes
2666 AC_MSG_RESULT([yes, $MPI_CC])
2672 CFLAGS=$saved_CFLAGS
2673 LDFLAGS="$saved_LDFLAGS"
2674 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
2677 #----------------------------------------------------------------------------
2678 # Other library checks
2679 #----------------------------------------------------------------------------
2680 # There now follow some tests for Boost, and OpenMP. These
2681 # tests are present because Drd has some regression tests that use
2682 # these packages. All regression test programs all compiled only
2683 # for the primary target. And so it is important that the configure
2684 # checks that follow, use the correct -m32 or -m64 flag for the
2685 # primary target (called $mflag_primary). Otherwise, we can end up
2686 # in a situation (eg) where, on amd64-linux, the test for Boost checks
2687 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
2688 # only build (meaning, the primary target is x86-linux), the build
2689 # of the regtest programs that use Boost fails, because they are
2690 # build as 32-bit (IN THIS EXAMPLE).
2692 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2693 # NEEDED BY THE REGRESSION TEST PROGRAMS.
2696 # Check whether the boost library 1.35 or later has been installed.
2697 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
2699 AC_MSG_CHECKING([for boost])
2702 safe_CXXFLAGS=$CXXFLAGS
2703 CXXFLAGS="$mflag_primary"
2705 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
2707 AC_LINK_IFELSE([AC_LANG_SOURCE([
2708 #include <boost/thread.hpp>
2709 static void thread_func(void)
2711 int main(int argc, char** argv)
2713 boost::thread t(thread_func);
2718 ac_have_boost_1_35=yes
2719 AC_SUBST([BOOST_CFLAGS], [])
2720 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
2721 AC_MSG_RESULT([yes])
2723 ac_have_boost_1_35=no
2728 CXXFLAGS=$safe_CXXFLAGS
2731 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2734 # does this compiler support -fopenmp, does it have the include file
2735 # <omp.h> and does it have libgomp ?
2737 AC_MSG_CHECKING([for OpenMP])
2740 CFLAGS="-fopenmp $mflag_primary"
2742 AC_LINK_IFELSE([AC_LANG_SOURCE([
2744 int main(int argc, char** argv)
2752 AC_MSG_RESULT([yes])
2759 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2762 # does this compiler have built-in functions for atomic memory access for the
2764 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
2767 CFLAGS="$mflag_primary"
2769 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2771 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2772 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2774 ac_have_builtin_atomic_primary=yes
2775 AC_MSG_RESULT([yes])
2776 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])
2778 ac_have_builtin_atomic_primary=no
2784 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2785 [test x$ac_have_builtin_atomic_primary = xyes])
2788 # does this compiler have built-in functions for atomic memory access for the
2789 # secondary target ?
2791 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2793 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2796 CFLAGS="$mflag_secondary"
2798 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2800 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2802 ac_have_builtin_atomic_secondary=yes
2803 AC_MSG_RESULT([yes])
2805 ac_have_builtin_atomic_secondary=no
2813 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2814 [test x$ac_have_builtin_atomic_secondary = xyes])
2816 # does this compiler have built-in functions for atomic memory access on
2817 # 64-bit integers for all targets ?
2819 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2821 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2824 uint64_t variable = 1;
2825 return __sync_add_and_fetch(&variable, 1)
2827 ac_have_builtin_atomic64_primary=yes
2829 ac_have_builtin_atomic64_primary=no
2832 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2835 CFLAGS="$mflag_secondary"
2837 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2840 uint64_t variable = 1;
2841 return __sync_add_and_fetch(&variable, 1)
2843 ac_have_builtin_atomic64_secondary=yes
2845 ac_have_builtin_atomic64_secondary=no
2852 if test x$ac_have_builtin_atomic64_primary = xyes && \
2853 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2854 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2855 AC_MSG_RESULT([yes])
2856 ac_have_builtin_atomic64=yes
2859 ac_have_builtin_atomic64=no
2862 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2863 [test x$ac_have_builtin_atomic64 = xyes])
2866 # does g++ have built-in functions for atomic memory access ?
2867 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
2869 safe_CXXFLAGS=$CXXFLAGS
2870 CXXFLAGS="$mflag_primary"
2873 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2875 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2876 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2878 ac_have_builtin_atomic_cxx=yes
2879 AC_MSG_RESULT([yes])
2880 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
2882 ac_have_builtin_atomic_cxx=no
2887 CXXFLAGS=$safe_CXXFLAGS
2889 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
2892 if test x$ac_have_usable_linux_futex_h = xyes \
2893 -a x$ac_have_builtin_atomic_primary = xyes; then
2894 ac_enable_linux_ticket_lock_primary=yes
2896 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2897 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2899 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2900 -a x$ac_have_usable_linux_futex_h = xyes \
2901 -a x$ac_have_builtin_atomic_secondary = xyes; then
2902 ac_enable_linux_ticket_lock_secondary=yes
2904 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2905 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2908 # does libstdc++ support annotating shared pointers ?
2909 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2911 safe_CXXFLAGS=$CXXFLAGS
2912 CXXFLAGS="-std=c++0x"
2915 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2918 std::shared_ptr<int> p
2920 ac_have_shared_ptr=yes
2922 ac_have_shared_ptr=no
2924 if test x$ac_have_shared_ptr = xyes; then
2925 # If compilation of the program below fails because of a syntax error
2926 # triggered by substituting one of the annotation macros then that
2927 # means that libstdc++ supports these macros.
2928 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2929 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2930 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2933 std::shared_ptr<int> p
2935 ac_have_shared_pointer_annotation=no
2938 ac_have_shared_pointer_annotation=yes
2939 AC_MSG_RESULT([yes])
2940 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2941 [Define to 1 if libstd++ supports annotating shared pointers])
2944 ac_have_shared_pointer_annotation=no
2949 CXXFLAGS=$safe_CXXFLAGS
2951 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2952 [test x$ac_have_shared_pointer_annotation = xyes])
2955 #----------------------------------------------------------------------------
2956 # Ok. We're done checking.
2957 #----------------------------------------------------------------------------
2959 # Nb: VEX/Makefile is generated from Makefile.vex.in.
2962 VEX/Makefile:Makefile.vex.in
2971 gdbserver_tests/Makefile
2977 memcheck/tests/Makefile
2978 memcheck/tests/common/Makefile
2979 memcheck/tests/amd64/Makefile
2980 memcheck/tests/x86/Makefile
2981 memcheck/tests/linux/Makefile
2982 memcheck/tests/darwin/Makefile
2983 memcheck/tests/amd64-linux/Makefile
2984 memcheck/tests/x86-linux/Makefile
2985 memcheck/tests/ppc32/Makefile
2986 memcheck/tests/ppc64/Makefile
2987 memcheck/tests/s390x/Makefile
2988 memcheck/tests/vbit-test/Makefile
2990 cachegrind/tests/Makefile
2991 cachegrind/tests/x86/Makefile
2992 cachegrind/cg_annotate
2995 callgrind/callgrind_annotate
2996 callgrind/callgrind_control
2997 callgrind/tests/Makefile
2999 helgrind/tests/Makefile
3001 massif/tests/Makefile
3004 lackey/tests/Makefile
3007 none/tests/amd64/Makefile
3008 none/tests/ppc32/Makefile
3009 none/tests/ppc64/Makefile
3010 none/tests/x86/Makefile
3011 none/tests/arm/Makefile
3012 none/tests/arm64/Makefile
3013 none/tests/s390x/Makefile
3014 none/tests/mips32/Makefile
3015 none/tests/mips64/Makefile
3016 none/tests/linux/Makefile
3017 none/tests/darwin/Makefile
3018 none/tests/x86-linux/Makefile
3019 exp-sgcheck/Makefile
3020 exp-sgcheck/tests/Makefile
3022 drd/scripts/download-and-build-splash2
3025 exp-bbv/tests/Makefile
3026 exp-bbv/tests/x86/Makefile
3027 exp-bbv/tests/x86-linux/Makefile
3028 exp-bbv/tests/amd64-linux/Makefile
3029 exp-bbv/tests/ppc32-linux/Makefile
3030 exp-bbv/tests/arm-linux/Makefile
3032 exp-dhat/tests/Makefile
3035 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
3036 [chmod +x coregrind/link_tool_exe_linux])
3037 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
3038 [chmod +x coregrind/link_tool_exe_darwin])
3043 Maximum build arch: ${ARCH_MAX}
3044 Primary build arch: ${VGCONF_ARCH_PRI}
3045 Secondary build arch: ${VGCONF_ARCH_SEC}
3046 Build OS: ${VGCONF_OS}
3047 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
3048 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
3049 Platform variant: ${VGCONF_PLATVARIANT}
3050 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
3051 Default supp files: ${DEFAULT_SUPP}