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 # 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 # provide a very basic definition for AC_PROG_SED if it's not provided by
49 # autoconf (as e.g. in autoconf 2.59).
50 m4_ifndef([AC_PROG_SED],
51 [AC_DEFUN([AC_PROG_SED],
53 AC_CHECK_PROGS([SED],[gsed sed])])])
56 # If no AR variable was specified, look up the name of the archiver. Otherwise
57 # do not touch the AR variable.
58 if test "x$AR" = "x"; then
59 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
61 AC_ARG_VAR([AR],[Archiver command])
63 # Check for the compiler support
64 if test "${GCC}" != "yes" ; then
65 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
68 # figure out where perl lives
69 AC_PATH_PROG(PERL, perl)
71 # figure out where gdb lives
72 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
73 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
75 # some older automake's don't have it so try something on our own
76 ifdef([AM_PROG_AS],[AM_PROG_AS],
86 # Check if 'diff' supports -u (universal diffs) and use it if possible.
88 AC_MSG_CHECKING([for diff -u])
91 # Comparing two identical files results in 0.
92 tmpfile="tmp-xxx-yyy-zzz"
94 if diff -u $tmpfile $tmpfile ; then
104 # We don't want gcc < 3.0
105 AC_MSG_CHECKING([for a supported version of gcc])
107 # Obtain the compiler version.
109 # A few examples of how the ${CC} --version output looks like:
111 # ######## gcc variants ########
112 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
113 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
114 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
115 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
116 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
117 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
118 # 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)
120 # ######## clang variants ########
121 # Clang: clang version 2.9 (tags/RELEASE_29/final)
122 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
123 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
125 # ######## Apple LLVM variants ########
126 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
127 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
130 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
133 gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
134 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
137 # Don't use -dumpversion with clang: it will always produce "4.2.1".
138 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
139 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ;
142 gcc_version=`${CC} -dumpversion 2>/dev/null`
145 gcc_version=`${CC} -dumpversion 2>/dev/null`
146 if test "x$gcc_version" = x; then
147 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
151 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
152 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
154 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
155 # statements have to be quoted.
156 case "${is_clang}-${gcc_version}" in
157 applellvm-5.1|applellvm-6.*)
158 AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
161 AC_MSG_RESULT([ok (ICC version ${gcc_version})])
163 notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
164 AC_MSG_RESULT([ok (${gcc_version})])
166 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
167 AC_MSG_RESULT([ok (clang-${gcc_version})])
170 AC_MSG_RESULT([no (${gcc_version})])
171 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0])
175 #----------------------------------------------------------------------------
176 # Arch/OS/platform tests.
177 #----------------------------------------------------------------------------
178 # We create a number of arch/OS/platform-related variables. We prefix them
179 # all with "VGCONF_" which indicates that they are defined at
180 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
181 # variables used when compiling C files.
185 AC_MSG_CHECKING([for a supported CPU])
187 # ARCH_MAX reflects the most that this CPU can do: for example if it
188 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
189 # Ditto for amd64. It is used for more configuration below, but is not used
192 # Power PC returns powerpc for Big Endian. This was not changed when Little
193 # Endian support was added to the 64-bit architecture. The 64-bit Little
194 # Endian systems explicitly state le in the host_cpu. For clarity in the
195 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianess of
196 # the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
197 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
198 # Endianess. The name PPC64 or ppc64 to 64-bit systems of either Endianess.
199 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
200 # Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
203 case "${host_cpu}" in
205 AC_MSG_RESULT([ok (${host_cpu})])
210 AC_MSG_RESULT([ok (${host_cpu})])
215 # this only referrs to 64-bit Big Endian
216 AC_MSG_RESULT([ok (${host_cpu})])
221 # this only referrs to 64-bit Little Endian
222 AC_MSG_RESULT([ok (${host_cpu})])
227 # On Linux this means only a 32-bit capable CPU.
228 AC_MSG_RESULT([ok (${host_cpu})])
233 AC_MSG_RESULT([ok (${host_cpu})])
238 AC_MSG_RESULT([ok (${host_cpu})])
243 AC_MSG_RESULT([ok (${host_cpu})])
248 AC_MSG_RESULT([ok (${host_cpu})])
253 AC_MSG_RESULT([ok (${host_cpu})])
258 AC_MSG_RESULT([ok (${host_cpu})])
263 AC_MSG_RESULT([ok (${host_cpu})])
268 AC_MSG_RESULT([ok (${host_cpu})])
273 AC_MSG_RESULT([ok (${host_cpu})])
278 AC_MSG_RESULT([no (${host_cpu})])
279 AC_MSG_ERROR([Unsupported host architecture. Sorry])
283 #----------------------------------------------------------------------------
285 # Sometimes it's convenient to subvert the bi-arch build system and
286 # just have a single build even though the underlying platform is
287 # capable of both. Hence handle --enable-only64bit and
288 # --enable-only32bit. Complain if both are issued :-)
289 # [Actually, if either of these options are used, I think both get built,
290 # but only one gets installed. So if you use an in-place build, both can be
293 # Check if a 64-bit only build has been requested
294 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
295 [AC_ARG_ENABLE(only64bit,
296 [ --enable-only64bit do a 64-bit only build],
297 [vg_cv_only64bit=$enableval],
298 [vg_cv_only64bit=no])])
300 # Check if a 32-bit only build has been requested
301 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
302 [AC_ARG_ENABLE(only32bit,
303 [ --enable-only32bit do a 32-bit only build],
304 [vg_cv_only32bit=$enableval],
305 [vg_cv_only32bit=no])])
308 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
310 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
313 #----------------------------------------------------------------------------
315 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
316 # compilation of many C files via -VGO_$(VGCONF_OS) and
317 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
318 AC_MSG_CHECKING([for a supported OS])
325 AC_MSG_RESULT([ok (${host_os})])
328 # Ok, this is linux. Check the kernel version
329 AC_MSG_CHECKING([for the kernel version])
334 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*)
335 AC_MSG_RESULT([unsupported (${kernel})])
336 AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
340 AC_MSG_RESULT([2.6 or later (${kernel})])
347 AC_MSG_RESULT([ok (${host_os})])
349 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
350 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
351 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
352 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
353 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
354 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
356 AC_MSG_CHECKING([for the kernel version])
359 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
360 # has only one relevant version, the OS version. The `uname` check
361 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
362 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
363 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
364 # and we don't know of an macros similar to __GLIBC__ to get that info.
366 # XXX: `uname -r` won't do the right thing for cross-compiles, but
367 # that's not a problem yet.
369 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
370 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
371 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
372 # time support for 10.5 (the 9.* pattern just below), I'll leave it
373 # in for now, just in case anybody wants to give it a try. But I'm
374 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
377 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
378 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
379 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
380 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
383 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
384 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
385 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
386 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
389 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
390 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
391 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
392 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
395 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
396 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
397 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
398 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
401 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
402 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
403 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
404 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
407 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
408 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
409 DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
410 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
413 AC_MSG_RESULT([unsupported (${kernel})])
414 AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x and 14.x (Mac OS X 10.6/7/8/9/10)])
420 AC_MSG_RESULT([no (${host_os})])
421 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
425 #----------------------------------------------------------------------------
427 # If we are building on a 64 bit platform test to see if the system
428 # supports building 32 bit programs and disable 32 bit support if it
429 # does not support building 32 bit programs
431 case "$ARCH_MAX-$VGCONF_OS" in
432 amd64-linux|ppc64be-linux|arm64-linux)
433 AC_MSG_CHECKING([for 32 bit build support])
436 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
441 vg_cv_only64bit="yes"
444 CFLAGS=$safe_CFLAGS;;
447 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
449 [--enable-only32bit was specified but system does not support 32 bit builds])
452 #----------------------------------------------------------------------------
454 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
455 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
456 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
457 # above) will be "amd64" since that reflects the most that this cpu can do,
458 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
459 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
460 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
461 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
462 AC_SUBST(VGCONF_ARCH_PRI)
464 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
465 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
466 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
467 # It is empty if there is no secondary target.
468 AC_SUBST(VGCONF_ARCH_SEC)
470 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
471 # The entire system, including regression and performance tests, will be
472 # built for this target. The "_CAPS" indicates that the name is in capital
473 # letters, and it also uses '_' rather than '-' as a separator, because it's
474 # used to create various Makefile variables, which are all in caps by
475 # convention and cannot contain '-' characters. This is in contrast to
476 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
477 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
479 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
480 # Valgrind and tools will also be built for this target, but not the
481 # regression or performance tests.
483 # By default, the primary arch is the same as the "max" arch, as commented
484 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
485 # the big case statement just below here, in the case where we're building
486 # on a 64 bit machine but have been requested only to do a 32 bit build.
487 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
489 AC_MSG_CHECKING([for a supported CPU/OS combination])
491 # NB. The load address for a given platform may be specified in more
492 # than one place, in some cases, depending on whether we're doing a biarch,
493 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
494 # Be careful to give consistent values in all subcases. Also, all four
495 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
496 # even if it is to "0xUNSET".
498 case "$ARCH_MAX-$VGCONF_OS" in
500 VGCONF_ARCH_PRI="x86"
502 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
503 VGCONF_PLATFORM_SEC_CAPS=""
504 valt_load_address_pri_norml="0x38000000"
505 valt_load_address_pri_inner="0x28000000"
506 valt_load_address_sec_norml="0xUNSET"
507 valt_load_address_sec_inner="0xUNSET"
508 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
511 valt_load_address_sec_norml="0xUNSET"
512 valt_load_address_sec_inner="0xUNSET"
513 if test x$vg_cv_only64bit = xyes; then
514 VGCONF_ARCH_PRI="amd64"
516 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
517 VGCONF_PLATFORM_SEC_CAPS=""
518 valt_load_address_pri_norml="0x38000000"
519 valt_load_address_pri_inner="0x28000000"
520 elif test x$vg_cv_only32bit = xyes; then
521 VGCONF_ARCH_PRI="x86"
523 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
524 VGCONF_PLATFORM_SEC_CAPS=""
525 valt_load_address_pri_norml="0x38000000"
526 valt_load_address_pri_inner="0x28000000"
528 VGCONF_ARCH_PRI="amd64"
529 VGCONF_ARCH_SEC="x86"
530 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
531 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
532 valt_load_address_pri_norml="0x38000000"
533 valt_load_address_pri_inner="0x28000000"
534 valt_load_address_sec_norml="0x38000000"
535 valt_load_address_sec_inner="0x28000000"
537 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
540 VGCONF_ARCH_PRI="ppc32"
542 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
543 VGCONF_PLATFORM_SEC_CAPS=""
544 valt_load_address_pri_norml="0x38000000"
545 valt_load_address_pri_inner="0x28000000"
546 valt_load_address_sec_norml="0xUNSET"
547 valt_load_address_sec_inner="0xUNSET"
548 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
551 valt_load_address_sec_norml="0xUNSET"
552 valt_load_address_sec_inner="0xUNSET"
553 if test x$vg_cv_only64bit = xyes; then
554 VGCONF_ARCH_PRI="ppc64be"
556 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
557 VGCONF_PLATFORM_SEC_CAPS=""
558 valt_load_address_pri_norml="0x38000000"
559 valt_load_address_pri_inner="0x28000000"
560 elif test x$vg_cv_only32bit = xyes; then
561 VGCONF_ARCH_PRI="ppc32"
563 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
564 VGCONF_PLATFORM_SEC_CAPS=""
565 valt_load_address_pri_norml="0x38000000"
566 valt_load_address_pri_inner="0x28000000"
568 VGCONF_ARCH_PRI="ppc64be"
569 VGCONF_ARCH_SEC="ppc32"
570 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
571 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
572 valt_load_address_pri_norml="0x38000000"
573 valt_load_address_pri_inner="0x28000000"
574 valt_load_address_sec_norml="0x38000000"
575 valt_load_address_sec_inner="0x28000000"
577 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
580 # Little Endian is only supported on PPC64
581 valt_load_address_sec_norml="0xUNSET"
582 valt_load_address_sec_inner="0xUNSET"
583 VGCONF_ARCH_PRI="ppc64le"
585 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
586 VGCONF_PLATFORM_SEC_CAPS=""
587 valt_load_address_pri_norml="0x38000000"
588 valt_load_address_pri_inner="0x28000000"
589 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
591 # Darwin gets identified as 32-bit even when it supports 64-bit.
592 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
593 # all Macs support both 32-bit and 64-bit, so we just build both. If
594 # someone has a really old 32-bit only machine they can (hopefully?)
595 # build with --enable-only32bit. See bug 243362.
596 x86-darwin|amd64-darwin)
598 valt_load_address_sec_norml="0xUNSET"
599 valt_load_address_sec_inner="0xUNSET"
600 if test x$vg_cv_only64bit = xyes; then
601 VGCONF_ARCH_PRI="amd64"
603 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
604 VGCONF_PLATFORM_SEC_CAPS=""
605 valt_load_address_pri_norml="0x138000000"
606 valt_load_address_pri_inner="0x128000000"
607 elif test x$vg_cv_only32bit = xyes; then
608 VGCONF_ARCH_PRI="x86"
610 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
611 VGCONF_PLATFORM_SEC_CAPS=""
612 VGCONF_ARCH_PRI_CAPS="x86"
613 valt_load_address_pri_norml="0x38000000"
614 valt_load_address_pri_inner="0x28000000"
616 VGCONF_ARCH_PRI="amd64"
617 VGCONF_ARCH_SEC="x86"
618 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
619 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
620 valt_load_address_pri_norml="0x138000000"
621 valt_load_address_pri_inner="0x128000000"
622 valt_load_address_sec_norml="0x38000000"
623 valt_load_address_sec_inner="0x28000000"
625 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
628 VGCONF_ARCH_PRI="arm"
629 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
630 VGCONF_PLATFORM_SEC_CAPS=""
631 valt_load_address_pri_norml="0x38000000"
632 valt_load_address_pri_inner="0x28000000"
633 valt_load_address_sec_norml="0xUNSET"
634 valt_load_address_sec_inner="0xUNSET"
635 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
638 valt_load_address_sec_norml="0xUNSET"
639 valt_load_address_sec_inner="0xUNSET"
640 if test x$vg_cv_only64bit = xyes; then
641 VGCONF_ARCH_PRI="arm64"
643 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
644 VGCONF_PLATFORM_SEC_CAPS=""
645 valt_load_address_pri_norml="0x38000000"
646 valt_load_address_pri_inner="0x28000000"
647 elif test x$vg_cv_only32bit = xyes; then
648 VGCONF_ARCH_PRI="arm"
650 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
651 VGCONF_PLATFORM_SEC_CAPS=""
652 valt_load_address_pri_norml="0x38000000"
653 valt_load_address_pri_inner="0x28000000"
655 VGCONF_ARCH_PRI="arm64"
656 VGCONF_ARCH_SEC="arm"
657 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
658 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
659 valt_load_address_pri_norml="0x38000000"
660 valt_load_address_pri_inner="0x28000000"
661 valt_load_address_sec_norml="0x38000000"
662 valt_load_address_sec_inner="0x28000000"
664 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
667 VGCONF_ARCH_PRI="s390x"
669 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
670 VGCONF_PLATFORM_SEC_CAPS=""
671 # To improve branch prediction hit rate we want to have
672 # the generated code close to valgrind (host) code
673 valt_load_address_pri_norml="0x800000000"
674 valt_load_address_pri_inner="0x810000000"
675 valt_load_address_sec_norml="0xUNSET"
676 valt_load_address_sec_inner="0xUNSET"
677 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
680 VGCONF_ARCH_PRI="mips32"
681 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
682 VGCONF_PLATFORM_SEC_CAPS=""
683 valt_load_address_pri_norml="0x38000000"
684 valt_load_address_pri_inner="0x28000000"
685 valt_load_address_sec_norml="0xUNSET"
686 valt_load_address_sec_inner="0xUNSET"
687 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
690 VGCONF_ARCH_PRI="mips64"
691 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
692 VGCONF_PLATFORM_SEC_CAPS=""
693 valt_load_address_pri_norml="0x38000000"
694 valt_load_address_pri_inner="0x28000000"
695 valt_load_address_sec_norml="0xUNSET"
696 valt_load_address_sec_inner="0xUNSET"
697 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
700 VGCONF_ARCH_PRI="tilegx"
702 VGCONF_PLATFORM_PRI_CAPS="TILEGX_LINUX"
703 VGCONF_PLATFORM_SEC_CAPS=""
704 valt_load_address_pri_norml="0x38000000"
705 valt_load_address_pri_inner="0x28000000"
706 valt_load_address_sec_norml="0xUNSET"
707 valt_load_address_sec_inner="0xUNSET"
708 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
711 VGCONF_ARCH_PRI="unknown"
712 VGCONF_ARCH_SEC="unknown"
713 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
714 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
715 valt_load_address_pri_norml="0xUNSET"
716 valt_load_address_pri_inner="0xUNSET"
717 valt_load_address_sec_norml="0xUNSET"
718 valt_load_address_sec_inner="0xUNSET"
719 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
720 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
724 #----------------------------------------------------------------------------
726 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
728 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
729 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
730 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
731 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
732 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
733 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
734 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
735 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
736 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
737 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
738 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
739 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
740 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
741 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
742 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
743 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
744 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
745 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
746 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
747 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
748 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
749 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
750 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
751 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
752 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
753 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_TILEGX,
754 test x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX )
756 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
758 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
759 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
760 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
761 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
762 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
763 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
764 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
765 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
766 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
767 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
768 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
769 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
770 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
771 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
772 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
773 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
774 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
775 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
776 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
777 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
778 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
779 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
780 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
781 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
782 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_TILEGX_LINUX,
783 test x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX)
784 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
785 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
786 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
787 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
788 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
791 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
792 # Relies on the assumption that the primary and secondary targets are
793 # for the same OS, so therefore only necessary to test the primary.
794 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
795 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
796 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
797 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
798 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
799 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
800 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
801 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
802 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
803 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
804 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
805 -o x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX)
806 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
807 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
808 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
811 # Sometimes, in the Makefile.am files, it's useful to know whether or not
812 # there is a secondary target.
813 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
814 test x$VGCONF_PLATFORM_SEC_CAPS != x)
816 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
817 dnl fallback definition
818 dnl The macro is courtesy of Dave Hart:
819 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
820 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
821 if test -z "$$1_TRUE"; then :
830 #----------------------------------------------------------------------------
832 #----------------------------------------------------------------------------
834 # Check if this should be built as an inner Valgrind, to be run within
835 # another Valgrind. Choose the load address accordingly.
836 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
837 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
838 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
839 [AC_ARG_ENABLE(inner,
840 [ --enable-inner enables self-hosting],
841 [vg_cv_inner=$enableval],
843 if test "$vg_cv_inner" = yes; then
844 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
845 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
846 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
848 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
849 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
852 #----------------------------------------------------------------------------
853 # Undefined behaviour sanitiser
854 #----------------------------------------------------------------------------
855 # Check whether we should build with the undefined beahviour sanitiser.
857 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
858 [AC_ARG_ENABLE(ubsan,
859 [ --enable-ubsan enables the undefined behaviour sanitiser],
860 [vg_cv_ubsan=$enableval],
863 #----------------------------------------------------------------------------
864 # Define MIPS_PAGE_SHIFT (--with-pagesize)
865 #----------------------------------------------------------------------------
866 AC_ARG_WITH(pagesize,
867 [ --with-pagesize= override detected page size (4, 16 or 64)],
872 if test "$psize" = "0"; then
873 psizer=`getconf PAGESIZE`
874 psize=$((${psizer}/1024))
877 if test "$psize" = "4"; then
878 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
879 elif test "$psize" = "16"; then
880 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
881 elif test "$psize" = "64"; then
882 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
884 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
886 AC_MSG_RESULT([checking for Pagesize... ${psize}k])
889 #----------------------------------------------------------------------------
890 # Extra fine-tuning of installation directories
891 #----------------------------------------------------------------------------
893 [ --with-tmpdir=PATH Specify path for temporary files],
896 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
897 AC_SUBST(VG_TMPDIR, [$tmpdir])
900 #----------------------------------------------------------------------------
901 # Libc and suppressions
902 #----------------------------------------------------------------------------
903 # This variable will collect the suppression files to be used.
904 AC_SUBST(DEFAULT_SUPP)
906 AC_CHECK_HEADER([features.h])
908 if test x$ac_cv_header_features_h = xyes; then
909 rm -f conftest.$ac_ext
910 cat <<_ACEOF >conftest.$ac_ext
911 #include <features.h>
912 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
913 glibc version is: __GLIBC__ __GLIBC_MINOR__
916 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
919 # not really a version check
920 AC_EGREP_CPP([DARWIN_LIBC], [
921 #include <sys/cdefs.h>
922 #if defined(__DARWIN_VERS_1050)
926 GLIBC_VERSION="darwin")
928 # not really a version check
929 AC_EGREP_CPP([BIONIC_LIBC], [
930 #if defined(__ANDROID__)
934 GLIBC_VERSION="bionic")
937 AC_MSG_CHECKING([the glibc version])
939 case "${GLIBC_VERSION}" in
941 AC_MSG_RESULT(${GLIBC_VERSION} family)
942 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
943 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
944 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
947 AC_MSG_RESULT(${GLIBC_VERSION} family)
948 DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
949 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
950 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
953 AC_MSG_RESULT(${GLIBC_VERSION} family)
954 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
955 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
956 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
959 AC_MSG_RESULT(${GLIBC_VERSION} family)
960 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
961 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
962 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
963 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
964 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
967 AC_MSG_RESULT(${GLIBC_VERSION} family)
968 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
969 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
970 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
971 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
972 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
973 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
974 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
977 AC_MSG_RESULT(Darwin)
978 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
979 # DEFAULT_SUPP set by kernel version check above.
982 AC_MSG_RESULT(Bionic)
983 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
984 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
987 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
988 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later])
989 AC_MSG_ERROR([or Darwin or Bionic libc])
993 AC_SUBST(GLIBC_VERSION)
996 # Add default suppressions for the X client libraries. Make no
997 # attempt to detect whether such libraries are installed on the
998 # build machine (or even if any X facilities are present); just
999 # add the suppressions antidisirregardless.
1000 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1001 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1003 # Add glibc and X11 suppressions for exp-sgcheck
1004 DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
1007 #----------------------------------------------------------------------------
1008 # Platform variants?
1009 #----------------------------------------------------------------------------
1011 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1012 # But there are times where we need a bit more control. The motivating
1013 # and currently only case is Android: this is almost identical to
1014 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1015 # platform variant tags, which get passed in the compile as
1016 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1018 # In almost all cases, the <variant> bit is "vanilla". But for Android
1019 # it is "android" instead.
1021 # Consequently (eg), plain arm-linux would build with
1023 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1025 # whilst an Android build would have
1027 # -DVGP_arm_linux -DVGPV_arm_linux_android
1029 # Same for x86. The setup of the platform variant is pushed relatively far
1030 # down this file in order that we can inspect any of the variables set above.
1032 # In the normal case ..
1033 VGCONF_PLATVARIANT="vanilla"
1036 if test "$GLIBC_VERSION" = "bionic";
1038 VGCONF_PLATVARIANT="android"
1041 AC_SUBST(VGCONF_PLATVARIANT)
1044 # FIXME: do we also want to define automake variables
1045 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1046 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1047 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1048 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1049 # that's what we'd need to do to use this, since what we'd want to write
1052 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1054 # Hmm. Can't think of a nice clean solution to this.
1056 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1057 test x$VGCONF_PLATVARIANT = xvanilla)
1058 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1059 test x$VGCONF_PLATVARIANT = xandroid)
1062 #----------------------------------------------------------------------------
1063 # Checking for various library functions and other definitions
1064 #----------------------------------------------------------------------------
1066 # Check for AT_FDCWD
1068 AC_MSG_CHECKING([for AT_FDCWD])
1069 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1076 ac_have_at_fdcwd=yes
1077 AC_MSG_RESULT([yes])
1083 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1085 # Check for stpncpy function definition in string.h
1086 # This explicitly checks with _GNU_SOURCE defined since that is also
1087 # used in the test case (some systems might define it without anyway
1088 # since stpncpy is part of The Open Group Base Specifications Issue 7
1089 # IEEE Std 1003.1-2008.
1090 AC_MSG_CHECKING([for stpncpy])
1091 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1098 char *r = stpncpy(d, s, n);
1100 ac_have_gnu_stpncpy=yes
1101 AC_MSG_RESULT([yes])
1103 ac_have_gnu_stpncpy=no
1107 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1109 # Check for PTRACE_GETREGS
1111 AC_MSG_CHECKING([for PTRACE_GETREGS])
1112 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1115 #include <sys/ptrace.h>
1116 #include <sys/user.h>
1119 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1121 AC_MSG_RESULT([yes])
1122 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1123 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1129 # Check for CLOCK_MONOTONIC
1131 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1133 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1137 clock_gettime(CLOCK_MONOTONIC, &t);
1140 AC_MSG_RESULT([yes])
1141 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1142 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1148 # Check for PTHREAD_RWLOCK_T
1150 AC_MSG_CHECKING([for pthread_rwlock_t])
1152 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1154 #include <pthread.h>
1156 pthread_rwlock_t rwl;
1158 AC_MSG_RESULT([yes])
1159 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1160 [Define to 1 if you have the `pthread_rwlock_t' type.])
1166 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1168 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1170 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1172 #include <pthread.h>
1174 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1176 AC_MSG_RESULT([yes])
1177 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1178 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1184 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1186 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1190 #include <pthread.h>
1192 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1194 AC_MSG_RESULT([yes])
1195 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1196 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1202 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1204 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1208 #include <pthread.h>
1210 return (PTHREAD_MUTEX_RECURSIVE_NP);
1212 AC_MSG_RESULT([yes])
1213 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1214 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1220 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1222 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1224 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1226 #include <pthread.h>
1228 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1231 AC_MSG_RESULT([yes])
1232 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1233 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1239 # Check whether pthread_mutex_t has a member called __m_kind.
1241 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1242 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1244 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1247 [#include <pthread.h>])
1250 # Check whether pthread_mutex_t has a member called __data.__kind.
1252 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1253 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1255 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1258 [#include <pthread.h>])
1261 # does this compiler support -maltivec and does it have the include file
1264 AC_MSG_CHECKING([for Altivec])
1267 CFLAGS="-maltivec -Werror"
1269 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1270 #include <altivec.h>
1272 vector unsigned int v;
1275 AC_MSG_RESULT([yes])
1276 AC_DEFINE([HAS_ALTIVEC], 1,
1277 [Define to 1 if gcc/as can do Altivec.])
1284 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
1287 # Check that both: the compiler supports -mvsx and that the assembler
1288 # understands VSX instructions. If either of those doesn't work,
1289 # conclude that we can't do VSX. NOTE: basically this is a kludge
1290 # in that it conflates two things that should be separate -- whether
1291 # the compiler understands the flag vs whether the assembler
1292 # understands the opcodes. This really ought to be cleaned up
1293 # and done properly, like it is for x86/x86_64.
1295 AC_MSG_CHECKING([for VSX])
1298 CFLAGS="-mvsx -Werror"
1300 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1301 #include <altivec.h>
1303 vector unsigned int v;
1304 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1307 AC_MSG_RESULT([yes])
1314 AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1317 AC_MSG_CHECKING([that assembler knows DFP])
1319 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1321 __asm__ __volatile__("dadd 1, 2, 3");
1322 __asm__ __volatile__("dcffix 1, 2");
1325 AC_MSG_RESULT([yes])
1332 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1334 CFLAGS="-mhard-dfp -Werror"
1335 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1337 __asm__ __volatile__("dadd 1, 2, 3");
1338 __asm__ __volatile__("dcffix 1, 2");
1341 AC_MSG_RESULT([yes])
1349 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
1352 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1355 _Decimal64 x = 0.0DD;
1357 ac_gcc_have_dfp_type=yes
1358 AC_MSG_RESULT([yes])
1360 ac_gcc_have_dfp_type=no
1364 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_gcc_have_dfp_type = xyes)
1367 AC_MSG_CHECKING([that assembler knows ISA 2.07 ])
1369 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1371 __asm__ __volatile__("mtvsrd 1,2 ");
1373 ac_asm_have_isa_2_07=yes
1374 AC_MSG_RESULT([yes])
1376 ac_asm_have_isa_2_07=no
1380 AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes)
1382 # Check for pthread_create@GLIBC2.0
1383 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1386 CFLAGS="-lpthread -Werror"
1387 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1388 extern int pthread_create_glibc_2_0(void*, const void*,
1389 void *(*)(void*), void*);
1390 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1394 * Apparently on PowerPC linking this program succeeds and generates an
1395 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1397 #error This test does not work properly on PowerPC.
1399 pthread_create_glibc_2_0(0, 0, 0, 0);
1403 ac_have_pthread_create_glibc_2_0=yes
1404 AC_MSG_RESULT([yes])
1405 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1406 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1408 ac_have_pthread_create_glibc_2_0=no
1413 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1414 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1417 # Check for dlinfo RTLD_DI_TLS_MODID
1418 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1422 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1429 size_t sizes[10000];
1430 size_t modid_offset;
1431 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1434 ac_have_dlinfo_rtld_di_tls_modid=yes
1435 AC_MSG_RESULT([yes])
1436 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1437 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1439 ac_have_dlinfo_rtld_di_tls_modid=no
1444 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1445 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1448 # Check for eventfd_t, eventfd() and eventfd_read()
1449 AC_MSG_CHECKING([for eventfd()])
1451 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1452 #include <sys/eventfd.h>
1458 eventfd_read(fd, &ev);
1461 AC_MSG_RESULT([yes])
1462 AC_DEFINE([HAVE_EVENTFD], 1,
1463 [Define to 1 if you have the `eventfd' function.])
1464 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1465 [Define to 1 if you have the `eventfd_read' function.])
1470 # Check whether compiler can process #include <thread> without errors
1471 # clang 3.3 cannot process <thread> from e.g.
1472 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1474 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1476 safe_CXXFLAGS=$CXXFLAGS
1479 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1483 ac_cxx_can_include_thread_header=yes
1484 AC_MSG_RESULT([yes])
1486 ac_cxx_can_include_thread_header=no
1489 CXXFLAGS=$safe_CXXFLAGS
1492 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1495 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1496 # of the user_regs_struct from sys/user.h. They are structurally the same
1497 # but we get either one or the other.
1499 AC_CHECK_TYPE([struct user_regs_struct],
1500 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1501 [[#include <sys/ptrace.h>]
1502 [#include <sys/time.h>]
1503 [#include <sys/user.h>]])
1504 if test "$sys_user_has_user_regs" = "yes"; then
1505 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1506 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1510 #----------------------------------------------------------------------------
1511 # Checking for supported compiler flags.
1512 #----------------------------------------------------------------------------
1514 # does this compiler support -m32 ?
1515 AC_MSG_CHECKING([if gcc accepts -m32])
1518 CFLAGS="-m32 -Werror"
1520 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1524 AC_MSG_RESULT([yes])
1534 # does this compiler support -m64 ?
1535 AC_MSG_CHECKING([if gcc accepts -m64])
1538 CFLAGS="-m64 -Werror"
1540 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1544 AC_MSG_RESULT([yes])
1554 # does this compiler support -march=mips32 (mips32 default) ?
1555 AC_MSG_CHECKING([if gcc accepts -march=mips32])
1558 CFLAGS="$CFLAGS -march=mips32 -Werror"
1560 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1563 FLAG_MIPS32="-march=mips32"
1564 AC_MSG_RESULT([yes])
1571 AC_SUBST(FLAG_MIPS32)
1574 # does this compiler support -march=mips64 (mips64 default) ?
1575 AC_MSG_CHECKING([if gcc accepts -march=mips64])
1578 CFLAGS="$CFLAGS -march=mips64 -Werror"
1580 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1583 FLAG_MIPS64="-march=mips64"
1584 AC_MSG_RESULT([yes])
1591 AC_SUBST(FLAG_MIPS64)
1594 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1595 AC_MSG_CHECKING([if gcc accepts -march=octeon])
1598 CFLAGS="$CFLAGS -march=octeon -Werror"
1600 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1603 FLAG_OCTEON="-march=octeon"
1604 AC_MSG_RESULT([yes])
1611 AC_SUBST(FLAG_OCTEON)
1614 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1615 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1618 CFLAGS="$CFLAGS -march=octeon2 -Werror"
1620 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1623 FLAG_OCTEON2="-march=octeon2"
1624 AC_MSG_RESULT([yes])
1631 AC_SUBST(FLAG_OCTEON2)
1634 # does this compiler support -mmmx ?
1635 AC_MSG_CHECKING([if gcc accepts -mmmx])
1638 CFLAGS="-mmmx -Werror"
1640 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1644 AC_MSG_RESULT([yes])
1654 # does this compiler support -msse ?
1655 AC_MSG_CHECKING([if gcc accepts -msse])
1658 CFLAGS="-msse -Werror"
1660 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1664 AC_MSG_RESULT([yes])
1674 # does this compiler support -mpreferred-stack-boundary=2 when
1675 # generating code for a 32-bit target? Note that we only care about
1676 # this when generating code for (32-bit) x86, so if the compiler
1677 # doesn't recognise -m32 it's no big deal. We'll just get code for
1678 # the Memcheck and other helper functions, that is a bit slower than
1679 # it could be, on x86; and no difference at all on any other platform.
1680 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
1683 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
1685 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1688 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
1689 AC_MSG_RESULT([yes])
1691 PREFERRED_STACK_BOUNDARY_2=""
1696 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
1699 # Convenience function to check whether GCC supports a particular
1700 # warning option. Takes two arguments,
1701 # first the warning flag name to check (without -W), then the
1702 # substitution name to set with -Wno-warning-flag if the flag exists,
1703 # or the empty string if the compiler doesn't accept the flag. Note
1704 # that checking is done against the warning flag itself, but the
1705 # substitution is then done to cancel the warning flag.
1706 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
1707 AC_MSG_CHECKING([if gcc accepts -W$1])
1709 CFLAGS="-W$1 -Werror"
1710 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1711 AC_SUBST([$2], [-Wno-$1])
1712 AC_MSG_RESULT([yes])], [
1714 AC_MSG_RESULT([no])])
1718 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
1719 # -W$1 (instead of -Wno-$1).
1720 AC_DEFUN([AC_GCC_WARNING_SUBST],[
1721 AC_MSG_CHECKING([if gcc accepts -W$1])
1723 CFLAGS="-W$1 -Werror"
1724 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1725 AC_SUBST([$2], [-W$1])
1726 AC_MSG_RESULT([yes])], [
1728 AC_MSG_RESULT([no])])
1732 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
1733 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
1734 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
1735 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
1736 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
1737 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
1738 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
1739 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
1740 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
1741 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
1742 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
1743 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
1744 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
1746 # Does this compiler support -Wformat-security ?
1747 # Special handling is needed, because certain GCC versions require -Wformat
1748 # being present if -Wformat-security is given. Otherwise a warning is issued.
1749 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
1750 # And with that the warning will be turned into an error with the result
1751 # that -Wformat-security is believed to be unsupported when in fact it is.
1752 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
1754 CFLAGS="-Wformat -Wformat-security -Werror"
1755 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1756 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
1757 AC_MSG_RESULT([yes])], [
1758 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
1759 AC_MSG_RESULT([no])])
1762 # does this compiler support -Wextra or the older -W ?
1764 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1767 CFLAGS="-Wextra -Werror"
1769 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1772 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1773 AC_MSG_RESULT([-Wextra])
1776 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1779 AC_SUBST([FLAG_W_EXTRA], [-W])
1782 AC_SUBST([FLAG_W_EXTRA], [])
1783 AC_MSG_RESULT([not supported])
1788 # does this compiler support -fno-stack-protector ?
1789 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1792 CFLAGS="-fno-stack-protector -Werror"
1794 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1797 no_stack_protector=yes
1798 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1799 AC_MSG_RESULT([yes])
1801 no_stack_protector=no
1802 FLAG_FNO_STACK_PROTECTOR=""
1807 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1809 # Does GCC support disabling Identical Code Folding?
1810 # We want to disabled Identical Code Folding for the
1811 # tools preload shared objects to get better backraces.
1812 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
1813 # "The optimization reduces code size and may disturb
1814 # unwind stacks by replacing a function by equivalent
1815 # one with a different name."
1816 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
1819 CFLAGS="-fno-ipa-icf -Werror"
1821 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1825 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
1826 AC_MSG_RESULT([yes])
1834 AC_SUBST(FLAG_FNO_IPA_ICF)
1837 # Does this compiler support -fsanitize=undefined. This is true for
1838 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
1839 # also checks for alignment violations on memory accesses which the valgrind
1840 # code base is sprinkled (if not littered) with. As those alignment issues
1841 # don't pose a problem we want to suppress warnings about them.
1842 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
1843 # GCCs do not support that.
1845 # Only checked for if --enable-ubsan was given.
1846 if test "x${vg_cv_ubsan}" = "xyes"; then
1847 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
1849 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
1850 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1853 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
1854 LIB_UBSAN="-static-libubsan"
1855 AC_MSG_RESULT([yes])
1857 CFLAGS="-fsanitize=undefined -Werror"
1858 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1861 FLAG_FSANITIZE="-fsanitize=undefined"
1862 LIB_UBSAN="-static-libubsan"
1863 AC_MSG_RESULT([yes])
1871 AC_SUBST(FLAG_FSANITIZE)
1874 # does this compiler support --param inline-unit-growth=... ?
1876 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1879 CFLAGS="--param inline-unit-growth=900 -Werror"
1881 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1884 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1885 ["--param inline-unit-growth=900"])
1886 AC_MSG_RESULT([yes])
1888 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1894 # does this compiler support -gdwarf-4 -fdebug-types-section ?
1896 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1899 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
1901 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1905 AC_MSG_RESULT([yes])
1910 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1914 # does this compiler support nested functions ?
1916 AC_MSG_CHECKING([if gcc accepts nested functions])
1918 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1919 int foo() { return 1; }
1922 ac_have_nested_functions=yes
1923 AC_MSG_RESULT([yes])
1925 ac_have_nested_functions=no
1928 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
1931 # does this compiler support the 'p' constraint in ASM statements ?
1933 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
1935 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1937 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
1939 ac_have_asm_constraint_p=yes
1940 AC_MSG_RESULT([yes])
1942 ac_have_asm_constraint_p=no
1945 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
1948 # We want to use use the -Ttext-segment option to the linker.
1949 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
1950 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
1951 # semantics are NOT what we want (GNU gold -Ttext is fine).
1953 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
1954 # will reside. -Ttext aligns just the .text section start (but not any
1957 # So test for -Ttext-segment which is supported by all bfd ld versions
1958 # and use that if it exists. If it doesn't exist it must be an older
1959 # version of gold and we can fall back to using -Ttext which has the
1962 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
1965 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
1968 [AC_LANG_SOURCE([int _start () { return 0; }])],
1970 linker_using_t_text="no"
1971 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
1972 AC_MSG_RESULT([yes])
1974 linker_using_t_text="yes"
1975 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
1980 # If the linker only supports -Ttext (not -Ttext-segment) then we will
1981 # have to strip any build-id ELF NOTEs from the staticly linked tools.
1982 # Otherwise the build-id NOTE might end up at the default load address.
1983 # (Pedantically if the linker is gold then -Ttext is fine, but newer
1984 # gold versions also support -Ttext-segment. So just assume that unless
1985 # we can use -Ttext-segment we need to strip the build-id NOTEs.
1986 if test "x${linker_using_t_text}" = "xyes"; then
1987 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
1988 # does the linker support -Wl,--build-id=none ? Note, it's
1989 # important that we test indirectly via whichever C compiler
1990 # is selected, rather than testing /usr/bin/ld or whatever
1992 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1994 CFLAGS="-Wl,--build-id=none -Werror"
1997 [AC_LANG_PROGRAM([ ], [return 0;])],
1999 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2000 AC_MSG_RESULT([yes])
2002 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2006 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2007 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2011 # does the ppc assembler support "mtocrf" et al?
2012 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2014 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2015 __asm__ __volatile__("mtocrf 4,0");
2016 __asm__ __volatile__("mfocrf 0,4");
2018 ac_have_as_ppc_mftocrf=yes
2019 AC_MSG_RESULT([yes])
2021 ac_have_as_ppc_mftocrf=no
2024 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2025 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2029 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2030 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2032 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2033 do { typedef struct {
2037 dbl_pair_t dbl_pair[3];
2038 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2041 ac_have_as_ppc_fpPO=yes
2042 AC_MSG_RESULT([yes])
2044 ac_have_as_ppc_fpPO=no
2047 if test x$ac_have_as_ppc_fpPO = xyes ; then
2048 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2052 # does the x86/amd64 assembler understand SSE3 instructions?
2053 # Note, this doesn't generate a C-level symbol. It generates a
2054 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2055 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2058 do { long long int x;
2059 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
2063 AC_MSG_RESULT([yes])
2069 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2072 # Ditto for SSSE3 instructions (note extra S)
2073 # Note, this doesn't generate a C-level symbol. It generates a
2074 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2075 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2077 save_CFLAGS="$CFLAGS"
2078 CFLAGS="$CFLAGS -msse -Werror"
2079 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2080 do { long long int x;
2081 __asm__ __volatile__(
2082 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2085 ac_have_as_ssse3=yes
2086 AC_MSG_RESULT([yes])
2091 CFLAGS="$save_CFLAGS"
2093 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2096 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2097 # Note, this doesn't generate a C-level symbol. It generates a
2098 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2099 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2100 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2102 __asm__ __volatile__(
2103 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2106 ac_have_as_pclmulqdq=yes
2107 AC_MSG_RESULT([yes])
2109 ac_have_as_pclmulqdq=no
2113 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2116 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2117 # Note, this doesn't generate a C-level symbol. It generates a
2118 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2119 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2120 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2123 * Carry-less multiplication of xmm1 with xmm2 and store the result in
2124 * xmm3. The immediate is used to determine which quadwords of xmm1 and
2125 * xmm2 should be used.
2127 __asm__ __volatile__(
2128 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2131 ac_have_as_vpclmulqdq=yes
2132 AC_MSG_RESULT([yes])
2134 ac_have_as_vpclmulqdq=no
2138 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2141 # does the x86/amd64 assembler understand the LZCNT instruction?
2142 # Note, this doesn't generate a C-level symbol. It generates a
2143 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2144 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2148 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2151 ac_have_as_lzcnt=yes
2152 AC_MSG_RESULT([yes])
2158 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2161 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2162 # Note, this doesn't generate a C-level symbol. It generates a
2163 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2164 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2168 __asm__ __volatile__("1: loopnel 1b\n");
2171 ac_have_as_loopnel=yes
2172 AC_MSG_RESULT([yes])
2174 ac_have_as_loopnel=no
2178 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2181 # does the x86/amd64 assembler understand ADDR32 ?
2182 # Note, this doesn't generate a C-level symbol. It generates a
2183 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2184 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2186 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2188 asm volatile ("addr32 rep movsb");
2191 ac_have_as_addr32=yes
2192 AC_MSG_RESULT([yes])
2194 ac_have_as_addr32=no
2198 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2201 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2202 # Note, this doesn't generate a C-level symbol. It generates a
2203 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2204 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2207 do { long long int x;
2208 __asm__ __volatile__(
2209 "crc32q %%r15,%%r15" : : : "r15" );
2210 __asm__ __volatile__(
2211 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2212 __asm__ __volatile__(
2213 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2216 ac_have_as_sse42=yes
2217 AC_MSG_RESULT([yes])
2223 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2226 # does the x86/amd64 assembler understand AVX instructions?
2227 # Note, this doesn't generate a C-level symbol. It generates a
2228 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2229 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2231 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2232 do { long long int x;
2233 __asm__ __volatile__(
2234 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2235 __asm__ __volatile__(
2236 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2240 AC_MSG_RESULT([yes])
2246 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2249 # does the x86/amd64 assembler understand AVX2 instructions?
2250 # Note, this doesn't generate a C-level symbol. It generates a
2251 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2252 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2254 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2255 do { long long int x;
2256 __asm__ __volatile__(
2257 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2258 __asm__ __volatile__(
2259 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2263 AC_MSG_RESULT([yes])
2269 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2272 # does the x86/amd64 assembler understand TSX instructions and
2273 # the XACQUIRE/XRELEASE prefixes?
2274 # Note, this doesn't generate a C-level symbol. It generates a
2275 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2276 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2278 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2280 __asm__ __volatile__(
2283 " xacquire lock incq 0(%rsp) \n\t"
2284 " xrelease lock incq 0(%rsp) \n"
2289 AC_MSG_RESULT([yes])
2295 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2298 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2299 # Note, this doesn't generate a C-level symbol. It generates a
2300 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2301 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2303 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2304 do { unsigned int h, l;
2305 __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2306 __asm__ __volatile__(
2307 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2308 __asm__ __volatile__(
2309 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2313 AC_MSG_RESULT([yes])
2319 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2322 # does the x86/amd64 assembler understand FMA instructions?
2323 # Note, this doesn't generate a C-level symbol. It generates a
2324 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2325 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2327 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2328 do { unsigned int h, l;
2329 __asm__ __volatile__(
2330 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2331 __asm__ __volatile__(
2332 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2333 __asm__ __volatile__(
2334 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2338 AC_MSG_RESULT([yes])
2344 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2347 # does the amd64 assembler understand MPX instructions?
2348 # Note, this doesn't generate a C-level symbol. It generates a
2349 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2350 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2352 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2354 asm ("bndmov %bnd0,(%rsp)");
2355 asm ("bndldx 3(%rbx,%rdx), %bnd2");
2359 AC_MSG_RESULT([yes])
2365 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2368 # Does the C compiler support the "ifunc" attribute
2369 # Note, this doesn't generate a C-level symbol. It generates a
2370 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2371 # does the x86/amd64 assembler understand MOVBE?
2372 # Note, this doesn't generate a C-level symbol. It generates a
2373 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2374 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2377 do { long long int x;
2378 __asm__ __volatile__(
2379 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
2382 ac_have_as_movbe=yes
2383 AC_MSG_RESULT([yes])
2389 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2392 # Does the C compiler support the "ifunc" attribute
2393 # Note, this doesn't generate a C-level symbol. It generates a
2394 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2395 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2397 AC_LINK_IFELSE([AC_LANG_SOURCE([[
2398 static void mytest(void) {}
2400 static void (*resolve_test(void))(void)
2402 return (void (*)(void))&mytest;
2405 void test(void) __attribute__((ifunc("resolve_test")));
2413 ac_have_ifunc_attr=yes
2414 AC_MSG_RESULT([yes])
2416 ac_have_ifunc_attr=no
2420 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2423 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
2424 # when building the tool executables. I think we should get rid of it.
2426 # Check for TLS support in the compiler and linker
2427 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2429 [vg_cv_linktime_tls=yes],
2430 [vg_cv_linktime_tls=no])
2431 # Native compilation: check whether running a program using TLS succeeds.
2432 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2433 # succeeds but running programs using TLS fails.
2434 # Cross-compiling: check whether linking a program using TLS succeeds.
2435 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2436 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
2437 [vg_cv_tls=$enableval],
2438 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2442 [vg_cv_tls=$vg_cv_linktime_tls])])])
2444 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
2445 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2449 #----------------------------------------------------------------------------
2450 # Checks for C header files.
2451 #----------------------------------------------------------------------------
2454 AC_CHECK_HEADERS([ \
2470 # Verify whether the <linux/futex.h> header is usable.
2471 AC_MSG_CHECKING([if <linux/futex.h> is usable])
2473 save_CFLAGS="$CFLAGS"
2474 CFLAGS="$CFLAGS -D__user="
2475 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2476 #include <linux/futex.h>
2480 ac_have_usable_linux_futex_h=yes
2481 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
2482 [Define to 1 if you have a usable <linux/futex.h> header file.])
2483 AC_MSG_RESULT([yes])
2485 ac_have_usable_linux_futex_h=no
2488 CFLAGS="$save_CFLAGS"
2491 #----------------------------------------------------------------------------
2492 # Checks for typedefs, structures, and compiler characteristics.
2493 #----------------------------------------------------------------------------
2500 #----------------------------------------------------------------------------
2501 # Checks for library functions.
2502 #----------------------------------------------------------------------------
2506 AC_CHECK_LIB([pthread], [pthread_create])
2507 AC_CHECK_LIB([rt], [clock_gettime])
2520 pthread_barrier_init \
2521 pthread_condattr_setclock \
2522 pthread_mutex_timedlock \
2523 pthread_rwlock_timedrdlock \
2524 pthread_rwlock_timedwrlock \
2527 pthread_setname_np \
2543 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
2544 # libraries with any shared object and/or executable. This is NOT what we
2545 # want for e.g. vgpreload_core-x86-linux.so
2548 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
2549 [test x$ac_cv_func_pthread_barrier_init = xyes])
2550 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
2551 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
2552 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
2553 [test x$ac_cv_func_pthread_spin_lock = xyes])
2554 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
2555 [test x$ac_cv_func_pthread_setname_np = xyes])
2557 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2558 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
2559 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
2560 [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
2563 #----------------------------------------------------------------------------
2565 #----------------------------------------------------------------------------
2566 # Do we have a useable MPI setup on the primary and/or secondary targets?
2567 # On Linux, by default, assumes mpicc and -m32/-m64
2568 # Note: this is a kludge in that it assumes the specified mpicc
2569 # understands -m32/-m64 regardless of what is specified using
2571 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
2572 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
2575 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
2576 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
2577 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
2578 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2579 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
2580 mflag_primary=$FLAG_M32
2581 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
2582 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
2583 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
2584 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
2585 mflag_primary=$FLAG_M64
2586 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
2587 mflag_primary="$FLAG_M32 -arch i386"
2588 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
2589 mflag_primary="$FLAG_M64 -arch x86_64"
2593 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2594 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
2595 mflag_secondary=$FLAG_M32
2596 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2597 mflag_secondary="$FLAG_M32 -arch i386"
2602 [ --with-mpicc= Specify name of MPI2-ised C compiler],
2607 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
2608 ## use these values in the check for a functioning mpicc.
2610 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
2611 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
2612 AM_COND_IF([VGCONF_OS_IS_LINUX],
2613 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2614 LDFLAGS_MPI="-fpic -shared"])
2615 AM_COND_IF([VGCONF_OS_IS_DARWIN],
2616 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2617 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2619 AC_SUBST([CFLAGS_MPI])
2620 AC_SUBST([LDFLAGS_MPI])
2623 ## See if MPI_CC works for the primary target
2625 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
2627 saved_CFLAGS=$CFLAGS
2629 CFLAGS="$CFLAGS_MPI $mflag_primary"
2630 saved_LDFLAGS="$LDFLAGS"
2631 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
2632 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2636 int ni, na, nd, comb;
2637 int r = MPI_Init(NULL,NULL);
2638 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2639 r |= MPI_Finalize();
2642 ac_have_mpi2_pri=yes
2643 AC_MSG_RESULT([yes, $MPI_CC])
2649 CFLAGS=$saved_CFLAGS
2650 LDFLAGS="$saved_LDFLAGS"
2651 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
2653 ## See if MPI_CC works for the secondary target. Complication: what if
2654 ## there is no secondary target? We need this to then fail.
2655 ## Kludge this by making MPI_CC something which will surely fail in
2658 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2660 saved_CFLAGS=$CFLAGS
2661 saved_LDFLAGS="$LDFLAGS"
2662 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
2663 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
2664 CC="$MPI_CC this will surely fail"
2668 CFLAGS="$CFLAGS_MPI $mflag_secondary"
2669 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2673 int ni, na, nd, comb;
2674 int r = MPI_Init(NULL,NULL);
2675 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2676 r |= MPI_Finalize();
2679 ac_have_mpi2_sec=yes
2680 AC_MSG_RESULT([yes, $MPI_CC])
2686 CFLAGS=$saved_CFLAGS
2687 LDFLAGS="$saved_LDFLAGS"
2688 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
2691 #----------------------------------------------------------------------------
2692 # Other library checks
2693 #----------------------------------------------------------------------------
2694 # There now follow some tests for Boost, and OpenMP. These
2695 # tests are present because Drd has some regression tests that use
2696 # these packages. All regression test programs all compiled only
2697 # for the primary target. And so it is important that the configure
2698 # checks that follow, use the correct -m32 or -m64 flag for the
2699 # primary target (called $mflag_primary). Otherwise, we can end up
2700 # in a situation (eg) where, on amd64-linux, the test for Boost checks
2701 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
2702 # only build (meaning, the primary target is x86-linux), the build
2703 # of the regtest programs that use Boost fails, because they are
2704 # build as 32-bit (IN THIS EXAMPLE).
2706 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2707 # NEEDED BY THE REGRESSION TEST PROGRAMS.
2710 # Check whether the boost library 1.35 or later has been installed.
2711 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
2713 AC_MSG_CHECKING([for boost])
2716 safe_CXXFLAGS=$CXXFLAGS
2717 CXXFLAGS="$mflag_primary"
2719 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
2721 AC_LINK_IFELSE([AC_LANG_SOURCE([
2722 #include <boost/thread.hpp>
2723 static void thread_func(void)
2725 int main(int argc, char** argv)
2727 boost::thread t(thread_func);
2732 ac_have_boost_1_35=yes
2733 AC_SUBST([BOOST_CFLAGS], [])
2734 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
2735 AC_MSG_RESULT([yes])
2737 ac_have_boost_1_35=no
2742 CXXFLAGS=$safe_CXXFLAGS
2745 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2748 # does this compiler support -fopenmp, does it have the include file
2749 # <omp.h> and does it have libgomp ?
2751 AC_MSG_CHECKING([for OpenMP])
2754 CFLAGS="-fopenmp $mflag_primary -Werror"
2756 AC_LINK_IFELSE([AC_LANG_SOURCE([
2758 int main(int argc, char** argv)
2766 AC_MSG_RESULT([yes])
2773 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2776 # Check for __builtin_popcount
2777 AC_MSG_CHECKING([for __builtin_popcount()])
2778 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2780 __builtin_popcount(2);
2783 AC_MSG_RESULT([yes])
2784 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
2785 [Define to 1 if compiler provides __builtin_popcount().])
2790 # Check for __builtin_clz
2791 AC_MSG_CHECKING([for __builtin_clz()])
2792 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2797 AC_MSG_RESULT([yes])
2798 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
2799 [Define to 1 if compiler provides __builtin_clz().])
2804 # Check for __builtin_ctz
2805 AC_MSG_CHECKING([for __builtin_ctz()])
2806 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2811 AC_MSG_RESULT([yes])
2812 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
2813 [Define to 1 if compiler provides __builtin_ctz().])
2818 # does this compiler have built-in functions for atomic memory access for the
2820 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
2823 CFLAGS="$mflag_primary"
2825 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2827 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2828 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2830 ac_have_builtin_atomic_primary=yes
2831 AC_MSG_RESULT([yes])
2832 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])
2834 ac_have_builtin_atomic_primary=no
2840 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2841 [test x$ac_have_builtin_atomic_primary = xyes])
2844 # does this compiler have built-in functions for atomic memory access for the
2845 # secondary target ?
2847 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2849 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2852 CFLAGS="$mflag_secondary"
2854 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2856 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2858 ac_have_builtin_atomic_secondary=yes
2859 AC_MSG_RESULT([yes])
2861 ac_have_builtin_atomic_secondary=no
2869 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2870 [test x$ac_have_builtin_atomic_secondary = xyes])
2872 # does this compiler have built-in functions for atomic memory access on
2873 # 64-bit integers for all targets ?
2875 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2877 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2880 uint64_t variable = 1;
2881 return __sync_add_and_fetch(&variable, 1)
2883 ac_have_builtin_atomic64_primary=yes
2885 ac_have_builtin_atomic64_primary=no
2888 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2891 CFLAGS="$mflag_secondary"
2893 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2896 uint64_t variable = 1;
2897 return __sync_add_and_fetch(&variable, 1)
2899 ac_have_builtin_atomic64_secondary=yes
2901 ac_have_builtin_atomic64_secondary=no
2908 if test x$ac_have_builtin_atomic64_primary = xyes && \
2909 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2910 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2911 AC_MSG_RESULT([yes])
2912 ac_have_builtin_atomic64=yes
2915 ac_have_builtin_atomic64=no
2918 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2919 [test x$ac_have_builtin_atomic64 = xyes])
2922 # does g++ have built-in functions for atomic memory access ?
2923 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
2925 safe_CXXFLAGS=$CXXFLAGS
2926 CXXFLAGS="$mflag_primary"
2929 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2931 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2932 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2934 ac_have_builtin_atomic_cxx=yes
2935 AC_MSG_RESULT([yes])
2936 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
2938 ac_have_builtin_atomic_cxx=no
2943 CXXFLAGS=$safe_CXXFLAGS
2945 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
2948 if test x$ac_have_usable_linux_futex_h = xyes \
2949 -a x$ac_have_builtin_atomic_primary = xyes; then
2950 ac_enable_linux_ticket_lock_primary=yes
2952 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2953 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2955 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2956 -a x$ac_have_usable_linux_futex_h = xyes \
2957 -a x$ac_have_builtin_atomic_secondary = xyes; then
2958 ac_enable_linux_ticket_lock_secondary=yes
2960 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2961 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2964 # does libstdc++ support annotating shared pointers ?
2965 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2967 safe_CXXFLAGS=$CXXFLAGS
2968 CXXFLAGS="-std=c++0x"
2971 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2974 std::shared_ptr<int> p
2976 ac_have_shared_ptr=yes
2978 ac_have_shared_ptr=no
2980 if test x$ac_have_shared_ptr = xyes; then
2981 # If compilation of the program below fails because of a syntax error
2982 # triggered by substituting one of the annotation macros then that
2983 # means that libstdc++ supports these macros.
2984 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2985 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2986 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2989 std::shared_ptr<int> p
2991 ac_have_shared_pointer_annotation=no
2994 ac_have_shared_pointer_annotation=yes
2995 AC_MSG_RESULT([yes])
2996 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2997 [Define to 1 if libstd++ supports annotating shared pointers])
3000 ac_have_shared_pointer_annotation=no
3005 CXXFLAGS=$safe_CXXFLAGS
3007 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
3008 [test x$ac_have_shared_pointer_annotation = xyes])
3011 #----------------------------------------------------------------------------
3012 # Ok. We're done checking.
3013 #----------------------------------------------------------------------------
3015 # Nb: VEX/Makefile is generated from Makefile.vex.in.
3018 VEX/Makefile:Makefile.vex.in
3027 gdbserver_tests/Makefile
3033 memcheck/tests/Makefile
3034 memcheck/tests/common/Makefile
3035 memcheck/tests/amd64/Makefile
3036 memcheck/tests/x86/Makefile
3037 memcheck/tests/linux/Makefile
3038 memcheck/tests/darwin/Makefile
3039 memcheck/tests/amd64-linux/Makefile
3040 memcheck/tests/x86-linux/Makefile
3041 memcheck/tests/ppc32/Makefile
3042 memcheck/tests/ppc64/Makefile
3043 memcheck/tests/s390x/Makefile
3044 memcheck/tests/vbit-test/Makefile
3046 cachegrind/tests/Makefile
3047 cachegrind/tests/x86/Makefile
3048 cachegrind/cg_annotate
3051 callgrind/callgrind_annotate
3052 callgrind/callgrind_control
3053 callgrind/tests/Makefile
3055 helgrind/tests/Makefile
3057 massif/tests/Makefile
3060 lackey/tests/Makefile
3063 none/tests/scripts/Makefile
3064 none/tests/amd64/Makefile
3065 none/tests/ppc32/Makefile
3066 none/tests/ppc64/Makefile
3067 none/tests/x86/Makefile
3068 none/tests/arm/Makefile
3069 none/tests/arm64/Makefile
3070 none/tests/s390x/Makefile
3071 none/tests/mips32/Makefile
3072 none/tests/mips64/Makefile
3073 none/tests/tilegx/Makefile
3074 none/tests/linux/Makefile
3075 none/tests/darwin/Makefile
3076 none/tests/amd64-linux/Makefile
3077 none/tests/x86-linux/Makefile
3078 none/tests/amd64-darwin/Makefile
3079 none/tests/x86-darwin/Makefile
3080 exp-sgcheck/Makefile
3081 exp-sgcheck/tests/Makefile
3083 drd/scripts/download-and-build-splash2
3086 exp-bbv/tests/Makefile
3087 exp-bbv/tests/x86/Makefile
3088 exp-bbv/tests/x86-linux/Makefile
3089 exp-bbv/tests/amd64-linux/Makefile
3090 exp-bbv/tests/ppc32-linux/Makefile
3091 exp-bbv/tests/arm-linux/Makefile
3093 exp-dhat/tests/Makefile
3096 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
3097 [chmod +x coregrind/link_tool_exe_linux])
3098 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
3099 [chmod +x coregrind/link_tool_exe_darwin])
3104 Maximum build arch: ${ARCH_MAX}
3105 Primary build arch: ${VGCONF_ARCH_PRI}
3106 Secondary build arch: ${VGCONF_ARCH_SEC}
3107 Build OS: ${VGCONF_OS}
3108 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
3109 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
3110 Platform variant: ${VGCONF_PLATVARIANT}
3111 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
3112 Default supp files: ${DEFAULT_SUPP}