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.0*)
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})])
272 AC_MSG_RESULT([no (${host_cpu})])
273 AC_MSG_ERROR([Unsupported host architecture. Sorry])
277 #----------------------------------------------------------------------------
279 # Sometimes it's convenient to subvert the bi-arch build system and
280 # just have a single build even though the underlying platform is
281 # capable of both. Hence handle --enable-only64bit and
282 # --enable-only32bit. Complain if both are issued :-)
283 # [Actually, if either of these options are used, I think both get built,
284 # but only one gets installed. So if you use an in-place build, both can be
287 # Check if a 64-bit only build has been requested
288 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
289 [AC_ARG_ENABLE(only64bit,
290 [ --enable-only64bit do a 64-bit only build],
291 [vg_cv_only64bit=$enableval],
292 [vg_cv_only64bit=no])])
294 # Check if a 32-bit only build has been requested
295 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
296 [AC_ARG_ENABLE(only32bit,
297 [ --enable-only32bit do a 32-bit only build],
298 [vg_cv_only32bit=$enableval],
299 [vg_cv_only32bit=no])])
302 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
304 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
307 #----------------------------------------------------------------------------
309 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
310 # compilation of many C files via -VGO_$(VGCONF_OS) and
311 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
312 AC_MSG_CHECKING([for a supported OS])
319 AC_MSG_RESULT([ok (${host_os})])
322 # Ok, this is linux. Check the kernel version
323 AC_MSG_CHECKING([for the kernel version])
328 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*)
329 AC_MSG_RESULT([unsupported (${kernel})])
330 AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
334 AC_MSG_RESULT([2.6 or later (${kernel})])
341 AC_MSG_RESULT([ok (${host_os})])
343 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
344 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
345 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
346 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
347 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
348 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
350 AC_MSG_CHECKING([for the kernel version])
353 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
354 # has only one relevant version, the OS version. The `uname` check
355 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
356 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
357 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
358 # and we don't know of an macros similar to __GLIBC__ to get that info.
360 # XXX: `uname -r` won't do the right thing for cross-compiles, but
361 # that's not a problem yet.
363 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
364 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
365 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
366 # time support for 10.5 (the 9.* pattern just below), I'll leave it
367 # in for now, just in case anybody wants to give it a try. But I'm
368 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
371 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
372 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
373 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
374 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
377 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
378 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
379 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
380 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
383 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
384 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
385 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
386 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
389 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
390 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
391 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
392 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
395 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
396 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
397 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
398 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
401 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
402 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
403 DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
404 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
407 AC_MSG_RESULT([unsupported (${kernel})])
408 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)])
414 AC_MSG_RESULT([no (${host_os})])
415 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
419 #----------------------------------------------------------------------------
421 # If we are building on a 64 bit platform test to see if the system
422 # supports building 32 bit programs and disable 32 bit support if it
423 # does not support building 32 bit programs
425 case "$ARCH_MAX-$VGCONF_OS" in
426 amd64-linux|ppc64be-linux|arm64-linux)
427 AC_MSG_CHECKING([for 32 bit build support])
430 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
435 vg_cv_only64bit="yes"
438 CFLAGS=$safe_CFLAGS;;
441 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
443 [--enable-only32bit was specified but system does not support 32 bit builds])
446 #----------------------------------------------------------------------------
448 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
449 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
450 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
451 # above) will be "amd64" since that reflects the most that this cpu can do,
452 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
453 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
454 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
455 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
456 AC_SUBST(VGCONF_ARCH_PRI)
458 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
459 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
460 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
461 # It is empty if there is no secondary target.
462 AC_SUBST(VGCONF_ARCH_SEC)
464 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
465 # The entire system, including regression and performance tests, will be
466 # built for this target. The "_CAPS" indicates that the name is in capital
467 # letters, and it also uses '_' rather than '-' as a separator, because it's
468 # used to create various Makefile variables, which are all in caps by
469 # convention and cannot contain '-' characters. This is in contrast to
470 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
471 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
473 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
474 # Valgrind and tools will also be built for this target, but not the
475 # regression or performance tests.
477 # By default, the primary arch is the same as the "max" arch, as commented
478 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
479 # the big case statement just below here, in the case where we're building
480 # on a 64 bit machine but have been requested only to do a 32 bit build.
481 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
483 AC_MSG_CHECKING([for a supported CPU/OS combination])
485 # NB. The load address for a given platform may be specified in more
486 # than one place, in some cases, depending on whether we're doing a biarch,
487 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
488 # Be careful to give consistent values in all subcases. Also, all four
489 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
490 # even if it is to "0xUNSET".
492 case "$ARCH_MAX-$VGCONF_OS" in
494 VGCONF_ARCH_PRI="x86"
496 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
497 VGCONF_PLATFORM_SEC_CAPS=""
498 valt_load_address_pri_norml="0x38000000"
499 valt_load_address_pri_inner="0x28000000"
500 valt_load_address_sec_norml="0xUNSET"
501 valt_load_address_sec_inner="0xUNSET"
502 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
505 valt_load_address_sec_norml="0xUNSET"
506 valt_load_address_sec_inner="0xUNSET"
507 if test x$vg_cv_only64bit = xyes; then
508 VGCONF_ARCH_PRI="amd64"
510 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
511 VGCONF_PLATFORM_SEC_CAPS=""
512 valt_load_address_pri_norml="0x38000000"
513 valt_load_address_pri_inner="0x28000000"
514 elif test x$vg_cv_only32bit = xyes; then
515 VGCONF_ARCH_PRI="x86"
517 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
518 VGCONF_PLATFORM_SEC_CAPS=""
519 valt_load_address_pri_norml="0x38000000"
520 valt_load_address_pri_inner="0x28000000"
522 VGCONF_ARCH_PRI="amd64"
523 VGCONF_ARCH_SEC="x86"
524 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
525 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
526 valt_load_address_pri_norml="0x38000000"
527 valt_load_address_pri_inner="0x28000000"
528 valt_load_address_sec_norml="0x38000000"
529 valt_load_address_sec_inner="0x28000000"
531 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
534 VGCONF_ARCH_PRI="ppc32"
536 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
537 VGCONF_PLATFORM_SEC_CAPS=""
538 valt_load_address_pri_norml="0x38000000"
539 valt_load_address_pri_inner="0x28000000"
540 valt_load_address_sec_norml="0xUNSET"
541 valt_load_address_sec_inner="0xUNSET"
542 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
545 valt_load_address_sec_norml="0xUNSET"
546 valt_load_address_sec_inner="0xUNSET"
547 if test x$vg_cv_only64bit = xyes; then
548 VGCONF_ARCH_PRI="ppc64be"
550 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
551 VGCONF_PLATFORM_SEC_CAPS=""
552 valt_load_address_pri_norml="0x38000000"
553 valt_load_address_pri_inner="0x28000000"
554 elif test x$vg_cv_only32bit = xyes; then
555 VGCONF_ARCH_PRI="ppc32"
557 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
558 VGCONF_PLATFORM_SEC_CAPS=""
559 valt_load_address_pri_norml="0x38000000"
560 valt_load_address_pri_inner="0x28000000"
562 VGCONF_ARCH_PRI="ppc64be"
563 VGCONF_ARCH_SEC="ppc32"
564 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
565 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
566 valt_load_address_pri_norml="0x38000000"
567 valt_load_address_pri_inner="0x28000000"
568 valt_load_address_sec_norml="0x38000000"
569 valt_load_address_sec_inner="0x28000000"
571 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
574 # Little Endian is only supported on PPC64
575 valt_load_address_sec_norml="0xUNSET"
576 valt_load_address_sec_inner="0xUNSET"
577 VGCONF_ARCH_PRI="ppc64le"
579 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
580 VGCONF_PLATFORM_SEC_CAPS=""
581 valt_load_address_pri_norml="0x38000000"
582 valt_load_address_pri_inner="0x28000000"
583 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
585 # Darwin gets identified as 32-bit even when it supports 64-bit.
586 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
587 # all Macs support both 32-bit and 64-bit, so we just build both. If
588 # someone has a really old 32-bit only machine they can (hopefully?)
589 # build with --enable-only32bit. See bug 243362.
590 x86-darwin|amd64-darwin)
592 valt_load_address_sec_norml="0xUNSET"
593 valt_load_address_sec_inner="0xUNSET"
594 if test x$vg_cv_only64bit = xyes; then
595 VGCONF_ARCH_PRI="amd64"
597 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
598 VGCONF_PLATFORM_SEC_CAPS=""
599 valt_load_address_pri_norml="0x138000000"
600 valt_load_address_pri_inner="0x128000000"
601 elif test x$vg_cv_only32bit = xyes; then
602 VGCONF_ARCH_PRI="x86"
604 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
605 VGCONF_PLATFORM_SEC_CAPS=""
606 VGCONF_ARCH_PRI_CAPS="x86"
607 valt_load_address_pri_norml="0x38000000"
608 valt_load_address_pri_inner="0x28000000"
610 VGCONF_ARCH_PRI="amd64"
611 VGCONF_ARCH_SEC="x86"
612 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
613 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
614 valt_load_address_pri_norml="0x138000000"
615 valt_load_address_pri_inner="0x128000000"
616 valt_load_address_sec_norml="0x38000000"
617 valt_load_address_sec_inner="0x28000000"
619 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
622 VGCONF_ARCH_PRI="arm"
623 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
624 VGCONF_PLATFORM_SEC_CAPS=""
625 valt_load_address_pri_norml="0x38000000"
626 valt_load_address_pri_inner="0x28000000"
627 valt_load_address_sec_norml="0xUNSET"
628 valt_load_address_sec_inner="0xUNSET"
629 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
632 valt_load_address_sec_norml="0xUNSET"
633 valt_load_address_sec_inner="0xUNSET"
634 if test x$vg_cv_only64bit = xyes; then
635 VGCONF_ARCH_PRI="arm64"
637 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
638 VGCONF_PLATFORM_SEC_CAPS=""
639 valt_load_address_pri_norml="0x38000000"
640 valt_load_address_pri_inner="0x28000000"
641 elif test x$vg_cv_only32bit = xyes; then
642 VGCONF_ARCH_PRI="arm"
644 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
645 VGCONF_PLATFORM_SEC_CAPS=""
646 valt_load_address_pri_norml="0x38000000"
647 valt_load_address_pri_inner="0x28000000"
649 VGCONF_ARCH_PRI="arm64"
650 VGCONF_ARCH_SEC="arm"
651 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
652 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
653 valt_load_address_pri_norml="0x38000000"
654 valt_load_address_pri_inner="0x28000000"
655 valt_load_address_sec_norml="0x38000000"
656 valt_load_address_sec_inner="0x28000000"
658 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
661 VGCONF_ARCH_PRI="s390x"
663 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
664 VGCONF_PLATFORM_SEC_CAPS=""
665 # To improve branch prediction hit rate we want to have
666 # the generated code close to valgrind (host) code
667 valt_load_address_pri_norml="0x800000000"
668 valt_load_address_pri_inner="0x810000000"
669 valt_load_address_sec_norml="0xUNSET"
670 valt_load_address_sec_inner="0xUNSET"
671 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
674 VGCONF_ARCH_PRI="mips32"
675 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
676 VGCONF_PLATFORM_SEC_CAPS=""
677 valt_load_address_pri_norml="0x38000000"
678 valt_load_address_pri_inner="0x28000000"
679 valt_load_address_sec_norml="0xUNSET"
680 valt_load_address_sec_inner="0xUNSET"
681 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
684 VGCONF_ARCH_PRI="mips64"
685 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
686 VGCONF_PLATFORM_SEC_CAPS=""
687 valt_load_address_pri_norml="0x38000000"
688 valt_load_address_pri_inner="0x28000000"
689 valt_load_address_sec_norml="0xUNSET"
690 valt_load_address_sec_inner="0xUNSET"
691 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
694 VGCONF_ARCH_PRI="unknown"
695 VGCONF_ARCH_SEC="unknown"
696 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
697 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
698 valt_load_address_pri_norml="0xUNSET"
699 valt_load_address_pri_inner="0xUNSET"
700 valt_load_address_sec_norml="0xUNSET"
701 valt_load_address_sec_inner="0xUNSET"
702 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
703 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
707 #----------------------------------------------------------------------------
709 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
711 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
712 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
713 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
714 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
715 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
716 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
717 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
718 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
719 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
720 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
721 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
722 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
723 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
724 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
725 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
726 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
727 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
728 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
729 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
730 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
731 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
732 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
733 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
734 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
735 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
737 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
739 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
740 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
741 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
742 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
743 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
744 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
745 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
746 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
747 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
748 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
749 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
750 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
751 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
752 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
753 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
754 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
755 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
756 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
757 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
758 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
759 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
760 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
761 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
762 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
763 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
764 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
765 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
766 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
767 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
770 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
771 # Relies on the assumption that the primary and secondary targets are
772 # for the same OS, so therefore only necessary to test the primary.
773 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
774 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
775 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
776 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
777 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
778 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
779 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
780 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
781 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
782 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
783 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
784 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
785 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
786 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
789 # Sometimes, in the Makefile.am files, it's useful to know whether or not
790 # there is a secondary target.
791 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
792 test x$VGCONF_PLATFORM_SEC_CAPS != x)
794 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
795 dnl fallback definition
796 dnl The macro is courtesy of Dave Hart:
797 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
798 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
799 if test -z "$$1_TRUE"; then :
808 #----------------------------------------------------------------------------
810 #----------------------------------------------------------------------------
812 # Check if this should be built as an inner Valgrind, to be run within
813 # another Valgrind. Choose the load address accordingly.
814 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
815 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
816 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
817 [AC_ARG_ENABLE(inner,
818 [ --enable-inner enables self-hosting],
819 [vg_cv_inner=$enableval],
821 if test "$vg_cv_inner" = yes; then
822 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
823 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
824 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
826 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
827 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
830 #----------------------------------------------------------------------------
831 # Undefined behaviour sanitiser
832 #----------------------------------------------------------------------------
833 # Check whether we should build with the undefined beahviour sanitiser.
835 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
836 [AC_ARG_ENABLE(ubsan,
837 [ --enable-ubsan enables the undefined behaviour sanitiser],
838 [vg_cv_ubsan=$enableval],
841 #----------------------------------------------------------------------------
842 # Define MIPS_PAGE_SHIFT (--with-pagesize)
843 #----------------------------------------------------------------------------
844 AC_ARG_WITH(pagesize,
845 [ --with-pagesize= override detected page size (4, 16 or 64)],
850 if test "$psize" = "0"; then
851 psizer=`getconf PAGESIZE`
852 psize=$((${psizer}/1024))
855 if test "$psize" = "4"; then
856 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
857 elif test "$psize" = "16"; then
858 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
859 elif test "$psize" = "64"; then
860 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
862 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
864 AC_MSG_RESULT([checking for Pagesize... ${psize}k])
867 #----------------------------------------------------------------------------
868 # Extra fine-tuning of installation directories
869 #----------------------------------------------------------------------------
871 [ --with-tmpdir=PATH Specify path for temporary files],
874 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
875 AC_SUBST(VG_TMPDIR, [$tmpdir])
878 #----------------------------------------------------------------------------
879 # Libc and suppressions
880 #----------------------------------------------------------------------------
881 # This variable will collect the suppression files to be used.
882 AC_SUBST(DEFAULT_SUPP)
884 AC_CHECK_HEADER([features.h])
886 if test x$ac_cv_header_features_h = xyes; then
887 rm -f conftest.$ac_ext
888 cat <<_ACEOF >conftest.$ac_ext
889 #include <features.h>
890 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
891 glibc version is: __GLIBC__ __GLIBC_MINOR__
894 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
897 # not really a version check
898 AC_EGREP_CPP([DARWIN_LIBC], [
899 #include <sys/cdefs.h>
900 #if defined(__DARWIN_VERS_1050)
904 GLIBC_VERSION="darwin")
906 # not really a version check
907 AC_EGREP_CPP([BIONIC_LIBC], [
908 #if defined(__ANDROID__)
912 GLIBC_VERSION="bionic")
915 AC_MSG_CHECKING([the glibc version])
917 case "${GLIBC_VERSION}" in
919 AC_MSG_RESULT(${GLIBC_VERSION} family)
920 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
921 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
922 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
925 AC_MSG_RESULT(${GLIBC_VERSION} family)
926 DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
927 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
928 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
931 AC_MSG_RESULT(${GLIBC_VERSION} family)
932 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
933 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
934 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
937 AC_MSG_RESULT(${GLIBC_VERSION} family)
938 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
939 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
940 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
941 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
942 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
945 AC_MSG_RESULT(${GLIBC_VERSION} family)
946 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
947 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
948 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
949 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
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(Darwin)
956 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
957 # DEFAULT_SUPP set by kernel version check above.
960 AC_MSG_RESULT(Bionic)
961 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
962 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
965 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
966 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later])
967 AC_MSG_ERROR([or Darwin or Bionic libc])
971 AC_SUBST(GLIBC_VERSION)
974 # Add default suppressions for the X client libraries. Make no
975 # attempt to detect whether such libraries are installed on the
976 # build machine (or even if any X facilities are present); just
977 # add the suppressions antidisirregardless.
978 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
979 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
981 # Add glibc and X11 suppressions for exp-sgcheck
982 DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
985 #----------------------------------------------------------------------------
987 #----------------------------------------------------------------------------
989 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
990 # But there are times where we need a bit more control. The motivating
991 # and currently only case is Android: this is almost identical to
992 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
993 # platform variant tags, which get passed in the compile as
994 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
996 # In almost all cases, the <variant> bit is "vanilla". But for Android
997 # it is "android" instead.
999 # Consequently (eg), plain arm-linux would build with
1001 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1003 # whilst an Android build would have
1005 # -DVGP_arm_linux -DVGPV_arm_linux_android
1007 # Same for x86. The setup of the platform variant is pushed relatively far
1008 # down this file in order that we can inspect any of the variables set above.
1010 # In the normal case ..
1011 VGCONF_PLATVARIANT="vanilla"
1014 if test "$GLIBC_VERSION" = "bionic";
1016 VGCONF_PLATVARIANT="android"
1019 AC_SUBST(VGCONF_PLATVARIANT)
1022 # FIXME: do we also want to define automake variables
1023 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1024 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1025 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1026 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1027 # that's what we'd need to do to use this, since what we'd want to write
1030 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1032 # Hmm. Can't think of a nice clean solution to this.
1034 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1035 test x$VGCONF_PLATVARIANT = xvanilla)
1036 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1037 test x$VGCONF_PLATVARIANT = xandroid)
1040 #----------------------------------------------------------------------------
1041 # Checking for various library functions and other definitions
1042 #----------------------------------------------------------------------------
1044 # Check for AT_FDCWD
1046 AC_MSG_CHECKING([for AT_FDCWD])
1047 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1054 ac_have_at_fdcwd=yes
1055 AC_MSG_RESULT([yes])
1061 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1063 # Check for stpncpy function definition in string.h
1064 # This explicitly checks with _GNU_SOURCE defined since that is also
1065 # used in the test case (some systems might define it without anyway
1066 # since stpncpy is part of The Open Group Base Specifications Issue 7
1067 # IEEE Std 1003.1-2008.
1068 AC_MSG_CHECKING([for stpncpy])
1069 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1076 char *r = stpncpy(d, s, n);
1078 ac_have_gnu_stpncpy=yes
1079 AC_MSG_RESULT([yes])
1081 ac_have_gnu_stpncpy=no
1085 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1087 # Check for PTRACE_GETREGS
1089 AC_MSG_CHECKING([for PTRACE_GETREGS])
1090 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1093 #include <sys/ptrace.h>
1094 #include <sys/user.h>
1097 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1099 AC_MSG_RESULT([yes])
1100 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1101 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1107 # Check for CLOCK_MONOTONIC
1109 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1111 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1115 clock_gettime(CLOCK_MONOTONIC, &t);
1118 AC_MSG_RESULT([yes])
1119 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1120 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1126 # Check for PTHREAD_RWLOCK_T
1128 AC_MSG_CHECKING([for pthread_rwlock_t])
1130 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1132 #include <pthread.h>
1134 pthread_rwlock_t rwl;
1136 AC_MSG_RESULT([yes])
1137 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1138 [Define to 1 if you have the `pthread_rwlock_t' type.])
1144 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1146 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1148 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1150 #include <pthread.h>
1152 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1154 AC_MSG_RESULT([yes])
1155 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1156 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1162 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1164 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1168 #include <pthread.h>
1170 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1172 AC_MSG_RESULT([yes])
1173 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1174 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1180 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1182 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1184 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1186 #include <pthread.h>
1188 return (PTHREAD_MUTEX_RECURSIVE_NP);
1190 AC_MSG_RESULT([yes])
1191 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1192 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1198 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1200 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1202 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1204 #include <pthread.h>
1206 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1209 AC_MSG_RESULT([yes])
1210 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1211 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1217 # Check whether pthread_mutex_t has a member called __m_kind.
1219 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1220 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1222 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1225 [#include <pthread.h>])
1228 # Check whether pthread_mutex_t has a member called __data.__kind.
1230 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1231 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1233 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1236 [#include <pthread.h>])
1239 # does this compiler support -maltivec and does it have the include file
1242 AC_MSG_CHECKING([for Altivec])
1247 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1248 #include <altivec.h>
1250 vector unsigned int v;
1253 AC_MSG_RESULT([yes])
1254 AC_DEFINE([HAS_ALTIVEC], 1,
1255 [Define to 1 if gcc/as can do Altivec.])
1262 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
1265 # Check that both: the compiler supports -mvsx and that the assembler
1266 # understands VSX instructions. If either of those doesn't work,
1267 # conclude that we can't do VSX. NOTE: basically this is a kludge
1268 # in that it conflates two things that should be separate -- whether
1269 # the compiler understands the flag vs whether the assembler
1270 # understands the opcodes. This really ought to be cleaned up
1271 # and done properly, like it is for x86/x86_64.
1273 AC_MSG_CHECKING([for VSX])
1278 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1279 #include <altivec.h>
1281 vector unsigned int v;
1282 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1285 AC_MSG_RESULT([yes])
1292 AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1295 AC_MSG_CHECKING([that assembler knows DFP])
1297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1299 __asm__ __volatile__("dadd 1, 2, 3");
1300 __asm__ __volatile__("dcffix 1, 2");
1303 AC_MSG_RESULT([yes])
1310 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1313 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1315 __asm__ __volatile__("dadd 1, 2, 3");
1316 __asm__ __volatile__("dcffix 1, 2");
1319 AC_MSG_RESULT([yes])
1327 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
1330 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1331 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1333 _Decimal64 x = 0.0DD;
1335 ac_gcc_have_dfp_type=yes
1336 AC_MSG_RESULT([yes])
1338 ac_gcc_have_dfp_type=no
1342 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_gcc_have_dfp_type = xyes)
1345 AC_MSG_CHECKING([that assembler knows ISA 2.07 ])
1347 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1349 __asm__ __volatile__("mtvsrd 1,2 ");
1351 ac_asm_have_isa_2_07=yes
1352 AC_MSG_RESULT([yes])
1354 ac_asm_have_isa_2_07=no
1358 AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes)
1360 # Check for pthread_create@GLIBC2.0
1361 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1365 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1366 extern int pthread_create_glibc_2_0(void*, const void*,
1367 void *(*)(void*), void*);
1368 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1372 * Apparently on PowerPC linking this program succeeds and generates an
1373 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1375 #error This test does not work properly on PowerPC.
1377 pthread_create_glibc_2_0(0, 0, 0, 0);
1381 ac_have_pthread_create_glibc_2_0=yes
1382 AC_MSG_RESULT([yes])
1383 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1384 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1386 ac_have_pthread_create_glibc_2_0=no
1391 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1392 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1395 # Check for dlinfo RTLD_DI_TLS_MODID
1396 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1400 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1407 size_t sizes[10000];
1408 size_t modid_offset;
1409 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1412 ac_have_dlinfo_rtld_di_tls_modid=yes
1413 AC_MSG_RESULT([yes])
1414 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1415 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1417 ac_have_dlinfo_rtld_di_tls_modid=no
1422 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1423 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1426 # Check for eventfd_t, eventfd() and eventfd_read()
1427 AC_MSG_CHECKING([for eventfd()])
1429 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1430 #include <sys/eventfd.h>
1436 eventfd_read(fd, &ev);
1439 AC_MSG_RESULT([yes])
1440 AC_DEFINE([HAVE_EVENTFD], 1,
1441 [Define to 1 if you have the `eventfd' function.])
1442 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1443 [Define to 1 if you have the `eventfd_read' function.])
1448 # Check whether compiler can process #include <thread> without errors
1449 # clang 3.3 cannot process <thread> from e.g.
1450 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1452 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1454 safe_CXXFLAGS=$CXXFLAGS
1457 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1461 ac_cxx_can_include_thread_header=yes
1462 AC_MSG_RESULT([yes])
1464 ac_cxx_can_include_thread_header=no
1467 CXXFLAGS=$safe_CXXFLAGS
1470 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1473 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1474 # of the user_regs_struct from sys/user.h. They are structurally the same
1475 # but we get either one or the other.
1477 AC_CHECK_TYPE([struct user_regs_struct],
1478 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1479 [[#include <sys/ptrace.h>]
1480 [#include <sys/time.h>]
1481 [#include <sys/user.h>]])
1482 if test "$sys_user_has_user_regs" = "yes"; then
1483 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1484 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1488 #----------------------------------------------------------------------------
1489 # Checking for supported compiler flags.
1490 #----------------------------------------------------------------------------
1492 # does this compiler support -m32 ?
1493 AC_MSG_CHECKING([if gcc accepts -m32])
1498 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1502 AC_MSG_RESULT([yes])
1512 # does this compiler support -m64 ?
1513 AC_MSG_CHECKING([if gcc accepts -m64])
1518 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1522 AC_MSG_RESULT([yes])
1532 # does this compiler support -march=mips32 (mips32 default) ?
1533 AC_MSG_CHECKING([if gcc accepts -march=mips32])
1536 CFLAGS="$CFLAGS -march=mips32"
1538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1541 FLAG_MIPS32="-march=mips32"
1542 AC_MSG_RESULT([yes])
1549 AC_SUBST(FLAG_MIPS32)
1552 # does this compiler support -march=mips64 (mips64 default) ?
1553 AC_MSG_CHECKING([if gcc accepts -march=mips64])
1556 CFLAGS="$CFLAGS -march=mips64"
1558 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1561 FLAG_MIPS64="-march=mips64"
1562 AC_MSG_RESULT([yes])
1569 AC_SUBST(FLAG_MIPS64)
1572 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1573 AC_MSG_CHECKING([if gcc accepts -march=octeon])
1576 CFLAGS="$CFLAGS -march=octeon"
1578 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1581 FLAG_OCTEON="-march=octeon"
1582 AC_MSG_RESULT([yes])
1589 AC_SUBST(FLAG_OCTEON)
1592 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1593 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1596 CFLAGS="$CFLAGS -march=octeon2"
1598 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1601 FLAG_OCTEON2="-march=octeon2"
1602 AC_MSG_RESULT([yes])
1609 AC_SUBST(FLAG_OCTEON2)
1612 # does this compiler support -mmmx ?
1613 AC_MSG_CHECKING([if gcc accepts -mmmx])
1618 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1622 AC_MSG_RESULT([yes])
1632 # does this compiler support -msse ?
1633 AC_MSG_CHECKING([if gcc accepts -msse])
1638 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1642 AC_MSG_RESULT([yes])
1652 # does this compiler support -mpreferred-stack-boundary=2 when
1653 # generating code for a 32-bit target? Note that we only care about
1654 # this when generating code for (32-bit) x86, so if the compiler
1655 # doesn't recognise -m32 it's no big deal. We'll just get code for
1656 # the Memcheck and other helper functions, that is a bit slower than
1657 # it could be, on x86; and no difference at all on any other platform.
1658 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
1661 CFLAGS="-mpreferred-stack-boundary=2 -m32"
1663 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1666 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
1667 AC_MSG_RESULT([yes])
1669 PREFERRED_STACK_BOUNDARY_2=""
1674 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
1677 # Convenience function to check whether GCC supports a particular
1678 # warning option. Takes two arguments, first the warning flag name
1679 # to check (without -W), then the conditional name to set if that
1680 # warning flag is supported.
1681 AC_DEFUN([AC_GCC_WARNING_COND],[
1682 AC_MSG_CHECKING([if gcc accepts -W$1])
1685 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1686 has_warning_flag=yes
1687 AC_MSG_RESULT([yes])], [
1689 AC_MSG_RESULT([no])])
1691 AM_CONDITIONAL([$2], test x$has_warning_flag = xyes)
1694 AC_GCC_WARNING_COND([pointer-sign], [HAS_POINTER_SIGN_WARNING])
1696 # Convenience function to check whether GCC supports a particular
1697 # warning option. Similar to AC_GCC_WARNING_COND, but does a
1698 # substitution instead of setting an conditional. Takes two arguments,
1699 # first the warning flag name to check (without -W), then the
1700 # substitution name to set with -Wno-warning-flag if the flag exists,
1701 # or the empty string if the compiler doesn't accept the flag. Note
1702 # that checking is done against the warning flag itself, but the
1703 # substitution is then done to cancel the warning flag.
1704 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
1705 AC_MSG_CHECKING([if gcc accepts -W$1])
1708 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1709 AC_SUBST([$2], [-Wno-$1])
1710 AC_MSG_RESULT([yes])], [
1712 AC_MSG_RESULT([no])])
1716 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
1717 # -W$1 (instead of -Wno-$1).
1718 AC_DEFUN([AC_GCC_WARNING_SUBST],[
1719 AC_MSG_CHECKING([if gcc accepts -W$1])
1722 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1723 AC_SUBST([$2], [-W$1])
1724 AC_MSG_RESULT([yes])], [
1726 AC_MSG_RESULT([no])])
1730 AC_GCC_WARNING_SUBST_NO([empty-body], [FLAG_W_NO_EMPTY_BODY])
1731 AC_GCC_WARNING_SUBST_NO([format-zero-length], [FLAG_W_NO_FORMAT_ZERO_LENGTH])
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([uninitialized], [FLAG_W_NO_UNINITIALIZED])
1735 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
1736 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
1737 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
1738 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
1739 AC_GCC_WARNING_SUBST([format-security], [FLAG_W_FORMAT_SECURITY])
1740 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
1743 # does this compiler support -Wextra or the older -W ?
1745 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1750 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1753 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1754 AC_MSG_RESULT([-Wextra])
1757 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1760 AC_SUBST([FLAG_W_EXTRA], [-W])
1763 AC_SUBST([FLAG_W_EXTRA], [])
1764 AC_MSG_RESULT([not supported])
1769 # does this compiler support -fno-stack-protector ?
1770 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1773 CFLAGS="-fno-stack-protector"
1775 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1778 no_stack_protector=yes
1779 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1780 AC_MSG_RESULT([yes])
1782 no_stack_protector=no
1783 FLAG_FNO_STACK_PROTECTOR=""
1788 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1791 # Does this compiler support -fsanitize=undefined?
1792 # Only checked for if --enable-ubsan was given.
1793 if test "x${vg_cv_ubsan}" = "xyes"; then
1794 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined])
1796 CFLAGS="-fsanitize=undefined"
1797 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1800 FLAG_FSANITIZE="-fsanitize=undefined"
1801 LIB_UBSAN="-static-libubsan"
1802 AC_MSG_RESULT([yes])
1809 AC_SUBST(FLAG_FSANITIZE)
1812 # does this compiler support --param inline-unit-growth=... ?
1814 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1817 CFLAGS="--param inline-unit-growth=900"
1819 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1822 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1823 ["--param inline-unit-growth=900"])
1824 AC_MSG_RESULT([yes])
1826 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1832 # does this compiler support -gdwarf-4 -fdebug-types-section ?
1834 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1837 CFLAGS="-gdwarf-4 -fdebug-types-section"
1839 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1843 AC_MSG_RESULT([yes])
1848 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1852 # does this compiler support nested functions ?
1854 AC_MSG_CHECKING([if gcc accepts nested functions])
1856 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1857 int foo() { return 1; }
1860 ac_have_nested_functions=yes
1861 AC_MSG_RESULT([yes])
1863 ac_have_nested_functions=no
1866 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
1869 # does this compiler support the 'p' constraint in ASM statements ?
1871 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
1873 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1875 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
1877 ac_have_asm_constraint_p=yes
1878 AC_MSG_RESULT([yes])
1880 ac_have_asm_constraint_p=no
1883 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
1886 # We want to use use the -Ttext-segment option to the linker.
1887 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
1888 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
1889 # semantics are NOT what we want (GNU gold -Ttext is fine).
1891 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
1892 # will reside. -Ttext aligns just the .text section start (but not any
1895 # So test for -Ttext-segment which is supported by all bfd ld versions
1896 # and use that if it exists. If it doesn't exist it must be an older
1897 # version of gold and we can fall back to using -Ttext which has the
1900 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
1903 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml"
1906 [AC_LANG_SOURCE([int _start () { return 0; }])],
1908 linker_using_t_text="no"
1909 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
1910 AC_MSG_RESULT([yes])
1912 linker_using_t_text="yes"
1913 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
1918 # If the linker only supports -Ttext (not -Ttext-segment) then we will
1919 # have to strip any build-id ELF NOTEs from the staticly linked tools.
1920 # Otherwise the build-id NOTE might end up at the default load address.
1921 # (Pedantically if the linker is gold then -Ttext is fine, but newer
1922 # gold versions also support -Ttext-segment. So just assume that unless
1923 # we can use -Ttext-segment we need to strip the build-id NOTEs.
1924 if test "x${linker_using_t_text}" = "xyes"; then
1925 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
1926 # does the linker support -Wl,--build-id=none ? Note, it's
1927 # important that we test indirectly via whichever C compiler
1928 # is selected, rather than testing /usr/bin/ld or whatever
1930 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1932 CFLAGS="-Wl,--build-id=none"
1935 [AC_LANG_PROGRAM([ ], [return 0;])],
1937 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1938 AC_MSG_RESULT([yes])
1940 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1944 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
1945 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1949 # does the ppc assembler support "mtocrf" et al?
1950 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1952 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1953 __asm__ __volatile__("mtocrf 4,0");
1954 __asm__ __volatile__("mfocrf 0,4");
1956 ac_have_as_ppc_mftocrf=yes
1957 AC_MSG_RESULT([yes])
1959 ac_have_as_ppc_mftocrf=no
1962 if test x$ac_have_as_ppc_mftocrf = xyes ; then
1963 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1967 # does the ppc assembler support "lfdp" and other phased out floating point insns?
1968 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
1970 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1971 do { typedef struct {
1975 dbl_pair_t dbl_pair[3];
1976 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
1979 ac_have_as_ppc_fpPO=yes
1980 AC_MSG_RESULT([yes])
1982 ac_have_as_ppc_fpPO=no
1985 if test x$ac_have_as_ppc_fpPO = xyes ; then
1986 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
1990 # does the x86/amd64 assembler understand SSE3 instructions?
1991 # Note, this doesn't generate a C-level symbol. It generates a
1992 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
1993 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1995 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1996 do { long long int x;
1997 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
2001 AC_MSG_RESULT([yes])
2007 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2010 # Ditto for SSSE3 instructions (note extra S)
2011 # Note, this doesn't generate a C-level symbol. It generates a
2012 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2013 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2015 save_CFLAGS="$CFLAGS"
2016 CFLAGS="$CFLAGS -msse"
2017 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2018 do { long long int x;
2019 __asm__ __volatile__(
2020 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2023 ac_have_as_ssse3=yes
2024 AC_MSG_RESULT([yes])
2029 CFLAGS="$save_CFLAGS"
2031 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2034 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2035 # Note, this doesn't generate a C-level symbol. It generates a
2036 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2037 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2038 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2040 __asm__ __volatile__(
2041 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2044 ac_have_as_pclmulqdq=yes
2045 AC_MSG_RESULT([yes])
2047 ac_have_as_pclmulqdq=no
2051 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2054 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2055 # Note, this doesn't generate a C-level symbol. It generates a
2056 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2057 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2058 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2061 * Carry-less multiplication of xmm1 with xmm2 and store the result in
2062 * xmm3. The immediate is used to determine which quadwords of xmm1 and
2063 * xmm2 should be used.
2065 __asm__ __volatile__(
2066 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2069 ac_have_as_vpclmulqdq=yes
2070 AC_MSG_RESULT([yes])
2072 ac_have_as_vpclmulqdq=no
2076 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2079 # does the x86/amd64 assembler understand the LZCNT instruction?
2080 # Note, this doesn't generate a C-level symbol. It generates a
2081 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2082 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2084 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2086 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2089 ac_have_as_lzcnt=yes
2090 AC_MSG_RESULT([yes])
2096 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2099 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2100 # Note, this doesn't generate a C-level symbol. It generates a
2101 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2102 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2104 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2106 __asm__ __volatile__("1: loopnel 1b\n");
2109 ac_have_as_loopnel=yes
2110 AC_MSG_RESULT([yes])
2112 ac_have_as_loopnel=no
2116 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2119 # does the x86/amd64 assembler understand ADDR32 ?
2120 # Note, this doesn't generate a C-level symbol. It generates a
2121 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2122 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2124 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2126 asm volatile ("addr32 rep movsb");
2129 ac_have_as_addr32=yes
2130 AC_MSG_RESULT([yes])
2132 ac_have_as_addr32=no
2136 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2139 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2140 # Note, this doesn't generate a C-level symbol. It generates a
2141 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2142 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2144 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2145 do { long long int x;
2146 __asm__ __volatile__(
2147 "crc32q %%r15,%%r15" : : : "r15" );
2148 __asm__ __volatile__(
2149 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2150 __asm__ __volatile__(
2151 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2154 ac_have_as_sse42=yes
2155 AC_MSG_RESULT([yes])
2161 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2164 # does the x86/amd64 assembler understand AVX instructions?
2165 # Note, this doesn't generate a C-level symbol. It generates a
2166 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2167 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2169 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2170 do { long long int x;
2171 __asm__ __volatile__(
2172 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2173 __asm__ __volatile__(
2174 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2178 AC_MSG_RESULT([yes])
2184 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2187 # does the x86/amd64 assembler understand AVX2 instructions?
2188 # Note, this doesn't generate a C-level symbol. It generates a
2189 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2190 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2192 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2193 do { long long int x;
2194 __asm__ __volatile__(
2195 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2196 __asm__ __volatile__(
2197 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2201 AC_MSG_RESULT([yes])
2207 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2210 # does the x86/amd64 assembler understand TSX instructions and
2211 # the XACQUIRE/XRELEASE prefixes?
2212 # Note, this doesn't generate a C-level symbol. It generates a
2213 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2214 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2216 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2218 __asm__ __volatile__(
2221 " xacquire lock incq 0(%rsp) \n\t"
2222 " xrelease lock incq 0(%rsp) \n"
2227 AC_MSG_RESULT([yes])
2233 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2236 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2237 # Note, this doesn't generate a C-level symbol. It generates a
2238 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2239 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2241 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2242 do { unsigned int h, l;
2243 __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2244 __asm__ __volatile__(
2245 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2246 __asm__ __volatile__(
2247 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2251 AC_MSG_RESULT([yes])
2257 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2260 # does the x86/amd64 assembler understand FMA instructions?
2261 # Note, this doesn't generate a C-level symbol. It generates a
2262 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2263 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2265 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2266 do { unsigned int h, l;
2267 __asm__ __volatile__(
2268 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2269 __asm__ __volatile__(
2270 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2271 __asm__ __volatile__(
2272 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2276 AC_MSG_RESULT([yes])
2282 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2285 # does the amd64 assembler understand MPX instructions?
2286 # Note, this doesn't generate a C-level symbol. It generates a
2287 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2288 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2290 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2292 asm ("bndmov %bnd0,(%rsp)");
2293 asm ("bndldx 3(%rbx,%rdx), %bnd2");
2297 AC_MSG_RESULT([yes])
2303 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2306 # Does the C compiler support the "ifunc" attribute
2307 # Note, this doesn't generate a C-level symbol. It generates a
2308 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2309 # does the x86/amd64 assembler understand MOVBE?
2310 # Note, this doesn't generate a C-level symbol. It generates a
2311 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2312 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2314 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2315 do { long long int x;
2316 __asm__ __volatile__(
2317 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
2320 ac_have_as_movbe=yes
2321 AC_MSG_RESULT([yes])
2327 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2330 # Does the C compiler support the "ifunc" attribute
2331 # Note, this doesn't generate a C-level symbol. It generates a
2332 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2333 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2335 AC_LINK_IFELSE([AC_LANG_SOURCE([[
2336 static void mytest(void) {}
2338 static void (*resolve_test(void))(void)
2340 return (void (*)(void))&mytest;
2343 void test(void) __attribute__((ifunc("resolve_test")));
2351 ac_have_ifunc_attr=yes
2352 AC_MSG_RESULT([yes])
2354 ac_have_ifunc_attr=no
2358 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2361 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
2362 # when building the tool executables. I think we should get rid of it.
2364 # Check for TLS support in the compiler and linker
2365 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2367 [vg_cv_linktime_tls=yes],
2368 [vg_cv_linktime_tls=no])
2369 # Native compilation: check whether running a program using TLS succeeds.
2370 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2371 # succeeds but running programs using TLS fails.
2372 # Cross-compiling: check whether linking a program using TLS succeeds.
2373 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2374 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
2375 [vg_cv_tls=$enableval],
2376 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2380 [vg_cv_tls=$vg_cv_linktime_tls])])])
2382 if test "$vg_cv_tls" = yes; then
2383 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2387 #----------------------------------------------------------------------------
2388 # Checks for C header files.
2389 #----------------------------------------------------------------------------
2392 AC_CHECK_HEADERS([ \
2408 # Verify whether the <linux/futex.h> header is usable.
2409 AC_MSG_CHECKING([if <linux/futex.h> is usable])
2411 save_CFLAGS="$CFLAGS"
2412 CFLAGS="$CFLAGS -D__user="
2413 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2414 #include <linux/futex.h>
2418 ac_have_usable_linux_futex_h=yes
2419 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
2420 [Define to 1 if you have a usable <linux/futex.h> header file.])
2421 AC_MSG_RESULT([yes])
2423 ac_have_usable_linux_futex_h=no
2426 CFLAGS="$save_CFLAGS"
2429 #----------------------------------------------------------------------------
2430 # Checks for typedefs, structures, and compiler characteristics.
2431 #----------------------------------------------------------------------------
2438 #----------------------------------------------------------------------------
2439 # Checks for library functions.
2440 #----------------------------------------------------------------------------
2444 AC_CHECK_LIB([pthread], [pthread_create])
2445 AC_CHECK_LIB([rt], [clock_gettime])
2458 pthread_barrier_init \
2459 pthread_condattr_setclock \
2460 pthread_mutex_timedlock \
2461 pthread_rwlock_timedrdlock \
2462 pthread_rwlock_timedwrlock \
2465 pthread_setname_np \
2481 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
2482 # libraries with any shared object and/or executable. This is NOT what we
2483 # want for e.g. vgpreload_core-x86-linux.so
2486 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
2487 [test x$ac_cv_func_pthread_barrier_init = xyes])
2488 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
2489 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
2490 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
2491 [test x$ac_cv_func_pthread_spin_lock = xyes])
2492 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
2493 [test x$ac_cv_func_pthread_setname_np = xyes])
2495 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2496 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
2497 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
2498 [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
2501 #----------------------------------------------------------------------------
2503 #----------------------------------------------------------------------------
2504 # Do we have a useable MPI setup on the primary and/or secondary targets?
2505 # On Linux, by default, assumes mpicc and -m32/-m64
2506 # Note: this is a kludge in that it assumes the specified mpicc
2507 # understands -m32/-m64 regardless of what is specified using
2509 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
2510 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
2513 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
2514 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
2515 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
2516 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2517 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
2518 mflag_primary=$FLAG_M32
2519 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
2520 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
2521 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
2522 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
2523 mflag_primary=$FLAG_M64
2524 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
2525 mflag_primary="$FLAG_M32 -arch i386"
2526 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
2527 mflag_primary="$FLAG_M64 -arch x86_64"
2531 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2532 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
2533 mflag_secondary=$FLAG_M32
2534 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2535 mflag_secondary="$FLAG_M32 -arch i386"
2540 [ --with-mpicc= Specify name of MPI2-ised C compiler],
2545 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
2546 ## use these values in the check for a functioning mpicc.
2548 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
2549 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
2550 AM_COND_IF([VGCONF_OS_IS_LINUX],
2551 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2552 LDFLAGS_MPI="-fpic -shared"])
2553 AM_COND_IF([VGCONF_OS_IS_DARWIN],
2554 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2555 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2557 AC_SUBST([CFLAGS_MPI])
2558 AC_SUBST([LDFLAGS_MPI])
2561 ## See if MPI_CC works for the primary target
2563 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
2565 saved_CFLAGS=$CFLAGS
2567 CFLAGS="$CFLAGS_MPI $mflag_primary"
2568 saved_LDFLAGS="$LDFLAGS"
2569 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
2570 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2574 int ni, na, nd, comb;
2575 int r = MPI_Init(NULL,NULL);
2576 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2577 r |= MPI_Finalize();
2580 ac_have_mpi2_pri=yes
2581 AC_MSG_RESULT([yes, $MPI_CC])
2587 CFLAGS=$saved_CFLAGS
2588 LDFLAGS="$saved_LDFLAGS"
2589 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
2591 ## See if MPI_CC works for the secondary target. Complication: what if
2592 ## there is no secondary target? We need this to then fail.
2593 ## Kludge this by making MPI_CC something which will surely fail in
2596 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2598 saved_CFLAGS=$CFLAGS
2599 saved_LDFLAGS="$LDFLAGS"
2600 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
2601 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
2602 CC="$MPI_CC this will surely fail"
2606 CFLAGS="$CFLAGS_MPI $mflag_secondary"
2607 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2611 int ni, na, nd, comb;
2612 int r = MPI_Init(NULL,NULL);
2613 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2614 r |= MPI_Finalize();
2617 ac_have_mpi2_sec=yes
2618 AC_MSG_RESULT([yes, $MPI_CC])
2624 CFLAGS=$saved_CFLAGS
2625 LDFLAGS="$saved_LDFLAGS"
2626 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
2629 #----------------------------------------------------------------------------
2630 # Other library checks
2631 #----------------------------------------------------------------------------
2632 # There now follow some tests for Boost, and OpenMP. These
2633 # tests are present because Drd has some regression tests that use
2634 # these packages. All regression test programs all compiled only
2635 # for the primary target. And so it is important that the configure
2636 # checks that follow, use the correct -m32 or -m64 flag for the
2637 # primary target (called $mflag_primary). Otherwise, we can end up
2638 # in a situation (eg) where, on amd64-linux, the test for Boost checks
2639 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
2640 # only build (meaning, the primary target is x86-linux), the build
2641 # of the regtest programs that use Boost fails, because they are
2642 # build as 32-bit (IN THIS EXAMPLE).
2644 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2645 # NEEDED BY THE REGRESSION TEST PROGRAMS.
2648 # Check whether the boost library 1.35 or later has been installed.
2649 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
2651 AC_MSG_CHECKING([for boost])
2654 safe_CXXFLAGS=$CXXFLAGS
2655 CXXFLAGS="$mflag_primary"
2657 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
2659 AC_LINK_IFELSE([AC_LANG_SOURCE([
2660 #include <boost/thread.hpp>
2661 static void thread_func(void)
2663 int main(int argc, char** argv)
2665 boost::thread t(thread_func);
2670 ac_have_boost_1_35=yes
2671 AC_SUBST([BOOST_CFLAGS], [])
2672 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
2673 AC_MSG_RESULT([yes])
2675 ac_have_boost_1_35=no
2680 CXXFLAGS=$safe_CXXFLAGS
2683 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2686 # does this compiler support -fopenmp, does it have the include file
2687 # <omp.h> and does it have libgomp ?
2689 AC_MSG_CHECKING([for OpenMP])
2692 CFLAGS="-fopenmp $mflag_primary"
2694 AC_LINK_IFELSE([AC_LANG_SOURCE([
2696 int main(int argc, char** argv)
2704 AC_MSG_RESULT([yes])
2711 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2714 # Check for __builtin_popcount
2715 AC_MSG_CHECKING([for __builtin_popcount()])
2716 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2718 __builtin_popcount(2);
2721 AC_MSG_RESULT([yes])
2722 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
2723 [Define to 1 if compiler provides __builtin_popcount().])
2728 # Check for __builtin_clz
2729 AC_MSG_CHECKING([for __builtin_clz()])
2730 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2735 AC_MSG_RESULT([yes])
2736 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
2737 [Define to 1 if compiler provides __builtin_clz().])
2742 # Check for __builtin_ctz
2743 AC_MSG_CHECKING([for __builtin_ctz()])
2744 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2749 AC_MSG_RESULT([yes])
2750 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
2751 [Define to 1 if compiler provides __builtin_ctz().])
2756 # does this compiler have built-in functions for atomic memory access for the
2758 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
2761 CFLAGS="$mflag_primary"
2763 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2765 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2766 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2768 ac_have_builtin_atomic_primary=yes
2769 AC_MSG_RESULT([yes])
2770 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])
2772 ac_have_builtin_atomic_primary=no
2778 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2779 [test x$ac_have_builtin_atomic_primary = xyes])
2782 # does this compiler have built-in functions for atomic memory access for the
2783 # secondary target ?
2785 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2787 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2790 CFLAGS="$mflag_secondary"
2792 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2794 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2796 ac_have_builtin_atomic_secondary=yes
2797 AC_MSG_RESULT([yes])
2799 ac_have_builtin_atomic_secondary=no
2807 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2808 [test x$ac_have_builtin_atomic_secondary = xyes])
2810 # does this compiler have built-in functions for atomic memory access on
2811 # 64-bit integers for all targets ?
2813 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2815 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2818 uint64_t variable = 1;
2819 return __sync_add_and_fetch(&variable, 1)
2821 ac_have_builtin_atomic64_primary=yes
2823 ac_have_builtin_atomic64_primary=no
2826 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2829 CFLAGS="$mflag_secondary"
2831 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2834 uint64_t variable = 1;
2835 return __sync_add_and_fetch(&variable, 1)
2837 ac_have_builtin_atomic64_secondary=yes
2839 ac_have_builtin_atomic64_secondary=no
2846 if test x$ac_have_builtin_atomic64_primary = xyes && \
2847 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2848 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2849 AC_MSG_RESULT([yes])
2850 ac_have_builtin_atomic64=yes
2853 ac_have_builtin_atomic64=no
2856 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2857 [test x$ac_have_builtin_atomic64 = xyes])
2860 # does g++ have built-in functions for atomic memory access ?
2861 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
2863 safe_CXXFLAGS=$CXXFLAGS
2864 CXXFLAGS="$mflag_primary"
2867 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2869 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2870 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2872 ac_have_builtin_atomic_cxx=yes
2873 AC_MSG_RESULT([yes])
2874 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
2876 ac_have_builtin_atomic_cxx=no
2881 CXXFLAGS=$safe_CXXFLAGS
2883 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
2886 if test x$ac_have_usable_linux_futex_h = xyes \
2887 -a x$ac_have_builtin_atomic_primary = xyes; then
2888 ac_enable_linux_ticket_lock_primary=yes
2890 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2891 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2893 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2894 -a x$ac_have_usable_linux_futex_h = xyes \
2895 -a x$ac_have_builtin_atomic_secondary = xyes; then
2896 ac_enable_linux_ticket_lock_secondary=yes
2898 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2899 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2902 # does libstdc++ support annotating shared pointers ?
2903 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2905 safe_CXXFLAGS=$CXXFLAGS
2906 CXXFLAGS="-std=c++0x"
2909 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2912 std::shared_ptr<int> p
2914 ac_have_shared_ptr=yes
2916 ac_have_shared_ptr=no
2918 if test x$ac_have_shared_ptr = xyes; then
2919 # If compilation of the program below fails because of a syntax error
2920 # triggered by substituting one of the annotation macros then that
2921 # means that libstdc++ supports these macros.
2922 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2923 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2924 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2927 std::shared_ptr<int> p
2929 ac_have_shared_pointer_annotation=no
2932 ac_have_shared_pointer_annotation=yes
2933 AC_MSG_RESULT([yes])
2934 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2935 [Define to 1 if libstd++ supports annotating shared pointers])
2938 ac_have_shared_pointer_annotation=no
2943 CXXFLAGS=$safe_CXXFLAGS
2945 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2946 [test x$ac_have_shared_pointer_annotation = xyes])
2949 #----------------------------------------------------------------------------
2950 # Ok. We're done checking.
2951 #----------------------------------------------------------------------------
2953 # Nb: VEX/Makefile is generated from Makefile.vex.in.
2956 VEX/Makefile:Makefile.vex.in
2965 gdbserver_tests/Makefile
2971 memcheck/tests/Makefile
2972 memcheck/tests/common/Makefile
2973 memcheck/tests/amd64/Makefile
2974 memcheck/tests/x86/Makefile
2975 memcheck/tests/linux/Makefile
2976 memcheck/tests/darwin/Makefile
2977 memcheck/tests/amd64-linux/Makefile
2978 memcheck/tests/x86-linux/Makefile
2979 memcheck/tests/ppc32/Makefile
2980 memcheck/tests/ppc64/Makefile
2981 memcheck/tests/s390x/Makefile
2982 memcheck/tests/vbit-test/Makefile
2984 cachegrind/tests/Makefile
2985 cachegrind/tests/x86/Makefile
2986 cachegrind/cg_annotate
2989 callgrind/callgrind_annotate
2990 callgrind/callgrind_control
2991 callgrind/tests/Makefile
2993 helgrind/tests/Makefile
2995 massif/tests/Makefile
2998 lackey/tests/Makefile
3001 none/tests/amd64/Makefile
3002 none/tests/ppc32/Makefile
3003 none/tests/ppc64/Makefile
3004 none/tests/x86/Makefile
3005 none/tests/arm/Makefile
3006 none/tests/arm64/Makefile
3007 none/tests/s390x/Makefile
3008 none/tests/mips32/Makefile
3009 none/tests/mips64/Makefile
3010 none/tests/linux/Makefile
3011 none/tests/darwin/Makefile
3012 none/tests/x86-linux/Makefile
3013 exp-sgcheck/Makefile
3014 exp-sgcheck/tests/Makefile
3016 drd/scripts/download-and-build-splash2
3019 exp-bbv/tests/Makefile
3020 exp-bbv/tests/x86/Makefile
3021 exp-bbv/tests/x86-linux/Makefile
3022 exp-bbv/tests/amd64-linux/Makefile
3023 exp-bbv/tests/ppc32-linux/Makefile
3024 exp-bbv/tests/arm-linux/Makefile
3026 exp-dhat/tests/Makefile
3029 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
3030 [chmod +x coregrind/link_tool_exe_linux])
3031 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
3032 [chmod +x coregrind/link_tool_exe_darwin])
3037 Maximum build arch: ${ARCH_MAX}
3038 Primary build arch: ${VGCONF_ARCH_PRI}
3039 Secondary build arch: ${VGCONF_ARCH_SEC}
3040 Build OS: ${VGCONF_OS}
3041 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
3042 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
3043 Platform variant: ${VGCONF_PLATVARIANT}
3044 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
3045 Default supp files: ${DEFAULT_SUPP}