2 ##------------------------------------------------------------##
4 # The multiple-architecture stuff in this file is pretty
5 # cryptic. Read docs/internals/multiple-architectures.txt
6 # for at least a partial explanation of what is going on.
8 ##------------------------------------------------------------##
10 # Process this file with autoconf to produce a configure script.
11 AC_INIT([Valgrind],[3.11.0.SVN],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign subdir-objects])
18 #----------------------------------------------------------------------------
19 # Checks for various programs.
20 #----------------------------------------------------------------------------
21 CFLAGS="-Wno-long-long $CFLAGS"
22 CXXFLAGS="-Wno-long-long $CXXFLAGS"
29 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
30 # autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
31 # base (eg. most likely as Darwin-specific tests) we'll need one of the
33 # - put AC_PROG_OBJC in a Darwin-specific part of this file
34 # - Use AC_PROG_OBJC here and up the minimum autoconf version
35 # - Use the following, which is apparently equivalent:
36 # m4_ifdef([AC_PROG_OBJC],
38 # [AC_CHECK_TOOL([OBJC], [gcc])
40 # AC_SUBST([OBJCFLAGS])
43 # provide a very basic definition for AC_PROG_SED if it's not provided by
44 # autoconf (as e.g. in autoconf 2.59).
45 m4_ifndef([AC_PROG_SED],
46 [AC_DEFUN([AC_PROG_SED],
48 AC_CHECK_PROGS([SED],[gsed sed])])])
51 # If no AR variable was specified, look up the name of the archiver. Otherwise
52 # do not touch the AR variable.
53 if test "x$AR" = "x"; then
54 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
56 AC_ARG_VAR([AR],[Archiver command])
58 # Check for the compiler support
59 if test "${GCC}" != "yes" ; then
60 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
63 # figure out where perl lives
64 AC_PATH_PROG(PERL, perl)
66 # figure out where gdb lives
67 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
68 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
70 # some older automake's don't have it so try something on our own
71 ifdef([AM_PROG_AS],[AM_PROG_AS],
81 # Check if 'diff' supports -u (universal diffs) and use it if possible.
83 AC_MSG_CHECKING([for diff -u])
86 # Comparing two identical files results in 0.
87 tmpfile="tmp-xxx-yyy-zzz"
89 if diff -u $tmpfile $tmpfile ; then
99 # We don't want gcc < 3.0
100 AC_MSG_CHECKING([for a supported version of gcc])
102 # Obtain the compiler version.
104 # A few examples of how the ${CC} --version output looks like:
106 # ######## gcc variants ########
107 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
108 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
109 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
110 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
111 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
112 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
113 # 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)
115 # ######## clang variants ########
116 # Clang: clang version 2.9 (tags/RELEASE_29/final)
117 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
118 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
120 # ######## Apple LLVM variants ########
121 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
122 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
125 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
128 gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
129 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
132 # Don't use -dumpversion with clang: it will always produce "4.2.1".
133 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
134 elif test "x`${CC} --version | $SED -n -e 's/icc.+\(ICC\).*/\1/p'`" = "ICC" ; then
136 gcc_version=`${CC} --version | $SED -n -e 's/icc.+\(ICC\).+([0-9.]+).*$/\1/p'`
139 gcc_version=`${CC} -dumpversion 2>/dev/null`
140 if test "x$gcc_version" = x; then
141 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
145 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
146 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
148 if test $is_clang = clang -o $is_clang = applellvm ; then
149 CFLAGS="$CFLAGS -Wno-tautological-compare -Wno-cast-align -Wno-self-assign"
150 CXXFLAGS="$CXXFLAGS -Wno-tautological-compare -Wno-cast-align -Wno-self-assign"
153 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
154 # statements have to be quoted.
155 case "${is_clang}-${gcc_version}" in
156 applellvm-5.1|applellvm-6.0*)
157 AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
160 AC_MSG_RESULT([ok (ICC version ${gcc_version})])
162 notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
163 AC_MSG_RESULT([ok (${gcc_version})])
165 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
166 AC_MSG_RESULT([ok (clang-${gcc_version})])
169 AC_MSG_RESULT([no (${gcc_version})])
170 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0])
174 #----------------------------------------------------------------------------
175 # Arch/OS/platform tests.
176 #----------------------------------------------------------------------------
177 # We create a number of arch/OS/platform-related variables. We prefix them
178 # all with "VGCONF_" which indicates that they are defined at
179 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
180 # variables used when compiling C files.
184 AC_MSG_CHECKING([for a supported CPU])
186 # ARCH_MAX reflects the most that this CPU can do: for example if it
187 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
188 # Ditto for amd64. It is used for more configuration below, but is not used
191 # Power PC returns powerpc for Big Endian. This was not changed when Little
192 # Endian support was added to the 64-bit architecture. The 64-bit Little
193 # Endian systems explicitly state le in the host_cpu. For clarity in the
194 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianess of
195 # the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
196 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
197 # Endianess. The name PPC64 or ppc64 to 64-bit systems of either Endianess.
198 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
199 # Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
202 case "${host_cpu}" in
204 AC_MSG_RESULT([ok (${host_cpu})])
209 AC_MSG_RESULT([ok (${host_cpu})])
214 # this only referrs to 64-bit Big Endian
215 AC_MSG_RESULT([ok (${host_cpu})])
220 # this only referrs to 64-bit Little Endian
221 AC_MSG_RESULT([ok (${host_cpu})])
226 # On Linux this means only a 32-bit capable CPU.
227 AC_MSG_RESULT([ok (${host_cpu})])
232 AC_MSG_RESULT([ok (${host_cpu})])
237 AC_MSG_RESULT([ok (${host_cpu})])
242 AC_MSG_RESULT([ok (${host_cpu})])
247 AC_MSG_RESULT([ok (${host_cpu})])
252 AC_MSG_RESULT([ok (${host_cpu})])
257 AC_MSG_RESULT([ok (${host_cpu})])
262 AC_MSG_RESULT([ok (${host_cpu})])
267 AC_MSG_RESULT([ok (${host_cpu})])
271 AC_MSG_RESULT([no (${host_cpu})])
272 AC_MSG_ERROR([Unsupported host architecture. Sorry])
276 #----------------------------------------------------------------------------
278 # Sometimes it's convenient to subvert the bi-arch build system and
279 # just have a single build even though the underlying platform is
280 # capable of both. Hence handle --enable-only64bit and
281 # --enable-only32bit. Complain if both are issued :-)
282 # [Actually, if either of these options are used, I think both get built,
283 # but only one gets installed. So if you use an in-place build, both can be
286 # Check if a 64-bit only build has been requested
287 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
288 [AC_ARG_ENABLE(only64bit,
289 [ --enable-only64bit do a 64-bit only build],
290 [vg_cv_only64bit=$enableval],
291 [vg_cv_only64bit=no])])
293 # Check if a 32-bit only build has been requested
294 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
295 [AC_ARG_ENABLE(only32bit,
296 [ --enable-only32bit do a 32-bit only build],
297 [vg_cv_only32bit=$enableval],
298 [vg_cv_only32bit=no])])
301 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
303 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
306 #----------------------------------------------------------------------------
308 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
309 # compilation of many C files via -VGO_$(VGCONF_OS) and
310 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
311 AC_MSG_CHECKING([for a supported OS])
318 AC_MSG_RESULT([ok (${host_os})])
321 # Ok, this is linux. Check the kernel version
322 AC_MSG_CHECKING([for the kernel version])
328 AC_MSG_RESULT([2.6.x/3.x family (${kernel})])
329 AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x or Linux 3.x])
333 AC_MSG_RESULT([2.4 family (${kernel})])
334 AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
338 AC_MSG_RESULT([unsupported (${kernel})])
339 AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
346 AC_MSG_RESULT([ok (${host_os})])
348 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
349 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
350 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
351 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
352 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
353 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
355 AC_MSG_CHECKING([for the kernel version])
358 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
359 # has only one relevant version, the OS version. The `uname` check
360 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
361 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
362 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
363 # and we don't know of an macros similar to __GLIBC__ to get that info.
365 # XXX: `uname -r` won't do the right thing for cross-compiles, but
366 # that's not a problem yet.
368 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
369 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
370 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
371 # time support for 10.5 (the 9.* pattern just below), I'll leave it
372 # in for now, just in case anybody wants to give it a try. But I'm
373 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
376 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
377 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
378 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
379 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
382 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
383 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
384 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
385 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
388 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
389 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
390 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
391 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
394 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
395 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
396 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
397 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
400 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
401 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
402 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
403 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
406 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
407 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
408 DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
409 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
412 AC_MSG_RESULT([unsupported (${kernel})])
413 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)])
419 AC_MSG_RESULT([no (${host_os})])
420 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
424 #----------------------------------------------------------------------------
426 # If we are building on a 64 bit platform test to see if the system
427 # supports building 32 bit programs and disable 32 bit support if it
428 # does not support building 32 bit programs
430 case "$ARCH_MAX-$VGCONF_OS" in
431 amd64-linux|ppc64be-linux|arm64-linux)
432 AC_MSG_CHECKING([for 32 bit build support])
435 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
440 vg_cv_only64bit="yes"
443 CFLAGS=$safe_CFLAGS;;
446 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
448 [--enable-only32bit was specified but system does not support 32 bit builds])
451 #----------------------------------------------------------------------------
453 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
454 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
455 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
456 # above) will be "amd64" since that reflects the most that this cpu can do,
457 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
458 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
459 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
460 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
461 AC_SUBST(VGCONF_ARCH_PRI)
463 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
464 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
465 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
466 # It is empty if there is no secondary target.
467 AC_SUBST(VGCONF_ARCH_SEC)
469 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
470 # The entire system, including regression and performance tests, will be
471 # built for this target. The "_CAPS" indicates that the name is in capital
472 # letters, and it also uses '_' rather than '-' as a separator, because it's
473 # used to create various Makefile variables, which are all in caps by
474 # convention and cannot contain '-' characters. This is in contrast to
475 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
476 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
478 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
479 # Valgrind and tools will also be built for this target, but not the
480 # regression or performance tests.
482 # By default, the primary arch is the same as the "max" arch, as commented
483 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
484 # the big case statement just below here, in the case where we're building
485 # on a 64 bit machine but have been requested only to do a 32 bit build.
486 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
488 AC_MSG_CHECKING([for a supported CPU/OS combination])
490 # NB. The load address for a given platform may be specified in more
491 # than one place, in some cases, depending on whether we're doing a biarch,
492 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
493 # Be careful to give consistent values in all subcases. Also, all four
494 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
495 # even if it is to "0xUNSET".
497 case "$ARCH_MAX-$VGCONF_OS" in
499 VGCONF_ARCH_PRI="x86"
501 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
502 VGCONF_PLATFORM_SEC_CAPS=""
503 valt_load_address_pri_norml="0x38000000"
504 valt_load_address_pri_inner="0x28000000"
505 valt_load_address_sec_norml="0xUNSET"
506 valt_load_address_sec_inner="0xUNSET"
507 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
510 valt_load_address_sec_norml="0xUNSET"
511 valt_load_address_sec_inner="0xUNSET"
512 if test x$vg_cv_only64bit = xyes; then
513 VGCONF_ARCH_PRI="amd64"
515 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
516 VGCONF_PLATFORM_SEC_CAPS=""
517 valt_load_address_pri_norml="0x38000000"
518 valt_load_address_pri_inner="0x28000000"
519 elif test x$vg_cv_only32bit = xyes; then
520 VGCONF_ARCH_PRI="x86"
522 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
523 VGCONF_PLATFORM_SEC_CAPS=""
524 valt_load_address_pri_norml="0x38000000"
525 valt_load_address_pri_inner="0x28000000"
527 VGCONF_ARCH_PRI="amd64"
528 VGCONF_ARCH_SEC="x86"
529 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
530 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
531 valt_load_address_pri_norml="0x38000000"
532 valt_load_address_pri_inner="0x28000000"
533 valt_load_address_sec_norml="0x38000000"
534 valt_load_address_sec_inner="0x28000000"
536 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
539 VGCONF_ARCH_PRI="ppc32"
541 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
542 VGCONF_PLATFORM_SEC_CAPS=""
543 valt_load_address_pri_norml="0x38000000"
544 valt_load_address_pri_inner="0x28000000"
545 valt_load_address_sec_norml="0xUNSET"
546 valt_load_address_sec_inner="0xUNSET"
547 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
550 valt_load_address_sec_norml="0xUNSET"
551 valt_load_address_sec_inner="0xUNSET"
552 if test x$vg_cv_only64bit = xyes; then
553 VGCONF_ARCH_PRI="ppc64be"
555 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
556 VGCONF_PLATFORM_SEC_CAPS=""
557 valt_load_address_pri_norml="0x38000000"
558 valt_load_address_pri_inner="0x28000000"
559 elif test x$vg_cv_only32bit = xyes; then
560 VGCONF_ARCH_PRI="ppc32"
562 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
563 VGCONF_PLATFORM_SEC_CAPS=""
564 valt_load_address_pri_norml="0x38000000"
565 valt_load_address_pri_inner="0x28000000"
567 VGCONF_ARCH_PRI="ppc64be"
568 VGCONF_ARCH_SEC="ppc32"
569 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
570 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
571 valt_load_address_pri_norml="0x38000000"
572 valt_load_address_pri_inner="0x28000000"
573 valt_load_address_sec_norml="0x38000000"
574 valt_load_address_sec_inner="0x28000000"
576 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
579 # Little Endian is only supported on PPC64
580 valt_load_address_sec_norml="0xUNSET"
581 valt_load_address_sec_inner="0xUNSET"
582 VGCONF_ARCH_PRI="ppc64le"
584 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
585 VGCONF_PLATFORM_SEC_CAPS=""
586 valt_load_address_pri_norml="0x38000000"
587 valt_load_address_pri_inner="0x28000000"
588 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
590 # Darwin gets identified as 32-bit even when it supports 64-bit.
591 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
592 # all Macs support both 32-bit and 64-bit, so we just build both. If
593 # someone has a really old 32-bit only machine they can (hopefully?)
594 # build with --enable-only32bit. See bug 243362.
595 x86-darwin|amd64-darwin)
597 valt_load_address_sec_norml="0xUNSET"
598 valt_load_address_sec_inner="0xUNSET"
599 if test x$vg_cv_only64bit = xyes; then
600 VGCONF_ARCH_PRI="amd64"
602 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
603 VGCONF_PLATFORM_SEC_CAPS=""
604 valt_load_address_pri_norml="0x138000000"
605 valt_load_address_pri_inner="0x128000000"
606 elif test x$vg_cv_only32bit = xyes; then
607 VGCONF_ARCH_PRI="x86"
609 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
610 VGCONF_PLATFORM_SEC_CAPS=""
611 VGCONF_ARCH_PRI_CAPS="x86"
612 valt_load_address_pri_norml="0x38000000"
613 valt_load_address_pri_inner="0x28000000"
615 VGCONF_ARCH_PRI="amd64"
616 VGCONF_ARCH_SEC="x86"
617 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
618 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
619 valt_load_address_pri_norml="0x138000000"
620 valt_load_address_pri_inner="0x128000000"
621 valt_load_address_sec_norml="0x38000000"
622 valt_load_address_sec_inner="0x28000000"
624 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
627 VGCONF_ARCH_PRI="arm"
628 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
629 VGCONF_PLATFORM_SEC_CAPS=""
630 valt_load_address_pri_norml="0x38000000"
631 valt_load_address_pri_inner="0x28000000"
632 valt_load_address_sec_norml="0xUNSET"
633 valt_load_address_sec_inner="0xUNSET"
634 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
637 valt_load_address_sec_norml="0xUNSET"
638 valt_load_address_sec_inner="0xUNSET"
639 if test x$vg_cv_only64bit = xyes; then
640 VGCONF_ARCH_PRI="arm64"
642 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
643 VGCONF_PLATFORM_SEC_CAPS=""
644 valt_load_address_pri_norml="0x38000000"
645 valt_load_address_pri_inner="0x28000000"
646 elif test x$vg_cv_only32bit = xyes; then
647 VGCONF_ARCH_PRI="arm"
649 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
650 VGCONF_PLATFORM_SEC_CAPS=""
651 valt_load_address_pri_norml="0x38000000"
652 valt_load_address_pri_inner="0x28000000"
654 VGCONF_ARCH_PRI="arm64"
655 VGCONF_ARCH_SEC="arm"
656 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
657 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
658 valt_load_address_pri_norml="0x38000000"
659 valt_load_address_pri_inner="0x28000000"
660 valt_load_address_sec_norml="0x38000000"
661 valt_load_address_sec_inner="0x28000000"
663 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
666 VGCONF_ARCH_PRI="s390x"
668 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
669 VGCONF_PLATFORM_SEC_CAPS=""
670 # To improve branch prediction hit rate we want to have
671 # the generated code close to valgrind (host) code
672 valt_load_address_pri_norml="0x800000000"
673 valt_load_address_pri_inner="0x810000000"
674 valt_load_address_sec_norml="0xUNSET"
675 valt_load_address_sec_inner="0xUNSET"
676 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
679 VGCONF_ARCH_PRI="mips32"
680 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
681 VGCONF_PLATFORM_SEC_CAPS=""
682 valt_load_address_pri_norml="0x38000000"
683 valt_load_address_pri_inner="0x28000000"
684 valt_load_address_sec_norml="0xUNSET"
685 valt_load_address_sec_inner="0xUNSET"
686 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
689 VGCONF_ARCH_PRI="mips64"
690 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
691 VGCONF_PLATFORM_SEC_CAPS=""
692 valt_load_address_pri_norml="0x38000000"
693 valt_load_address_pri_inner="0x28000000"
694 valt_load_address_sec_norml="0xUNSET"
695 valt_load_address_sec_inner="0xUNSET"
696 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
699 VGCONF_ARCH_PRI="unknown"
700 VGCONF_ARCH_SEC="unknown"
701 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
702 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
703 valt_load_address_pri_norml="0xUNSET"
704 valt_load_address_pri_inner="0xUNSET"
705 valt_load_address_sec_norml="0xUNSET"
706 valt_load_address_sec_inner="0xUNSET"
707 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
708 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
712 #----------------------------------------------------------------------------
714 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
716 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
717 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
718 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
719 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
720 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN )
721 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
722 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
723 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN )
724 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
725 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
726 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
727 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
728 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
729 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
730 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
731 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
732 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
733 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
734 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
735 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
736 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
737 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
738 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
739 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
740 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
742 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
744 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
745 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
746 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
747 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
748 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
749 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
750 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
751 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
752 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
753 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
754 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
755 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
756 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
757 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
758 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
759 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
760 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
761 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
762 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
763 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
764 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
765 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
766 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
767 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
768 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
769 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
770 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
771 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
772 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
775 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
776 # Relies on the assumption that the primary and secondary targets are
777 # for the same OS, so therefore only necessary to test the primary.
778 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
779 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
780 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
781 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
782 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
783 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
784 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
785 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
786 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
787 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
788 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
789 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
790 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
791 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
794 # Sometimes, in the Makefile.am files, it's useful to know whether or not
795 # there is a secondary target.
796 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
797 test x$VGCONF_PLATFORM_SEC_CAPS != x)
799 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
800 dnl fallback definition
801 dnl The macro is courtesy of Dave Hart:
802 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
803 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
804 if test -z "$$1_TRUE"; then :
813 #----------------------------------------------------------------------------
815 #----------------------------------------------------------------------------
817 # Check if this should be built as an inner Valgrind, to be run within
818 # another Valgrind. Choose the load address accordingly.
819 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
820 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
821 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
822 [AC_ARG_ENABLE(inner,
823 [ --enable-inner enables self-hosting],
824 [vg_cv_inner=$enableval],
826 if test "$vg_cv_inner" = yes; then
827 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
828 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
829 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
831 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
832 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
836 #----------------------------------------------------------------------------
837 # Define MIPS_PAGE_SHIFT (--with-pagesize)
838 #----------------------------------------------------------------------------
839 AC_ARG_WITH(pagesize,
840 [ --with-pagesize= override detected page size (4, 16 or 64)],
845 if test "$psize" = "0"; then
846 psizer=`getconf PAGESIZE`
847 psize=$((${psizer}/1024))
850 if test "$psize" = "4"; then
851 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
852 elif test "$psize" = "16"; then
853 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
854 elif test "$psize" = "64"; then
855 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
857 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
859 AC_MSG_RESULT([checking for Pagesize... ${psize}k])
862 #----------------------------------------------------------------------------
863 # Extra fine-tuning of installation directories
864 #----------------------------------------------------------------------------
866 [ --with-tmpdir=PATH Specify path for temporary files],
869 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
870 AC_SUBST(VG_TMPDIR, [$tmpdir])
873 #----------------------------------------------------------------------------
874 # Libc and suppressions
875 #----------------------------------------------------------------------------
876 # This variable will collect the suppression files to be used.
877 AC_SUBST(DEFAULT_SUPP)
879 AC_CHECK_HEADER([features.h])
881 if test x$ac_cv_header_features_h = xyes; then
882 rm -f conftest.$ac_ext
883 cat <<_ACEOF >conftest.$ac_ext
884 #include <features.h>
885 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
886 glibc version is: __GLIBC__ __GLIBC_MINOR__
889 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
892 # not really a version check
893 AC_EGREP_CPP([DARWIN_LIBC], [
894 #include <sys/cdefs.h>
895 #if defined(__DARWIN_VERS_1050)
899 GLIBC_VERSION="darwin")
901 # not really a version check
902 AC_EGREP_CPP([BIONIC_LIBC], [
903 #if defined(__ANDROID__)
907 GLIBC_VERSION="bionic")
910 AC_MSG_CHECKING([the glibc version])
912 case "${GLIBC_VERSION}" in
914 AC_MSG_RESULT(${GLIBC_VERSION} family)
915 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
916 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
917 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
920 AC_MSG_RESULT(${GLIBC_VERSION} family)
921 DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
922 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
923 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
926 AC_MSG_RESULT(${GLIBC_VERSION} family)
927 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
928 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
929 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
932 AC_MSG_RESULT(${GLIBC_VERSION} family)
933 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
934 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
935 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
936 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
937 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
940 AC_MSG_RESULT(${GLIBC_VERSION} family)
941 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
942 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
943 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
944 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
945 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
946 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
947 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
950 AC_MSG_RESULT(Darwin)
951 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
952 # DEFAULT_SUPP set by kernel version check above.
955 AC_MSG_RESULT(Bionic)
956 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
957 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
960 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
961 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later])
962 AC_MSG_ERROR([or Darwin or Bionic libc])
966 AC_SUBST(GLIBC_VERSION)
969 # Add default suppressions for the X client libraries. Make no
970 # attempt to detect whether such libraries are installed on the
971 # build machine (or even if any X facilities are present); just
972 # add the suppressions antidisirregardless.
973 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
974 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
976 # Add glibc and X11 suppressions for exp-sgcheck
977 DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
980 #----------------------------------------------------------------------------
982 #----------------------------------------------------------------------------
984 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
985 # But there are times where we need a bit more control. The motivating
986 # and currently only case is Android: this is almost identical to
987 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
988 # platform variant tags, which get passed in the compile as
989 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
991 # In almost all cases, the <variant> bit is "vanilla". But for Android
992 # it is "android" instead.
994 # Consequently (eg), plain arm-linux would build with
996 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
998 # whilst an Android build would have
1000 # -DVGP_arm_linux -DVGPV_arm_linux_android
1002 # Same for x86. The setup of the platform variant is pushed relatively far
1003 # down this file in order that we can inspect any of the variables set above.
1005 # In the normal case ..
1006 VGCONF_PLATVARIANT="vanilla"
1009 if test "$GLIBC_VERSION" = "bionic";
1011 VGCONF_PLATVARIANT="android"
1014 AC_SUBST(VGCONF_PLATVARIANT)
1017 # FIXME: do we also want to define automake variables
1018 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1019 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1020 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1021 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1022 # that's what we'd need to do to use this, since what we'd want to write
1025 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1027 # Hmm. Can't think of a nice clean solution to this.
1029 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1030 test x$VGCONF_PLATVARIANT = xvanilla)
1031 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1032 test x$VGCONF_PLATVARIANT = xandroid)
1035 #----------------------------------------------------------------------------
1036 # Checking for various library functions and other definitions
1037 #----------------------------------------------------------------------------
1039 # Check for AT_FDCWD
1041 AC_MSG_CHECKING([for AT_FDCWD])
1042 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1049 ac_have_at_fdcwd=yes
1050 AC_MSG_RESULT([yes])
1056 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1058 # Check for stpncpy function definition in string.h
1059 # This explicitly checks with _GNU_SOURCE defined since that is also
1060 # used in the test case (some systems might define it without anyway
1061 # since stpncpy is part of The Open Group Base Specifications Issue 7
1062 # IEEE Std 1003.1-2008.
1063 AC_MSG_CHECKING([for stpncpy])
1064 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1071 char *r = stpncpy(d, s, n);
1073 ac_have_gnu_stpncpy=yes
1074 AC_MSG_RESULT([yes])
1076 ac_have_gnu_stpncpy=no
1080 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1082 # Check for PTRACE_GETREGS
1084 AC_MSG_CHECKING([for PTRACE_GETREGS])
1085 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1087 #include <sys/ptrace.h>
1088 #include <sys/user.h>
1091 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1093 AC_MSG_RESULT([yes])
1094 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1095 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1101 # Check for CLOCK_MONOTONIC
1103 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1105 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1109 clock_gettime(CLOCK_MONOTONIC, &t);
1112 AC_MSG_RESULT([yes])
1113 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1114 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1120 # Check for PTHREAD_RWLOCK_T
1122 AC_MSG_CHECKING([for pthread_rwlock_t])
1124 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1126 #include <pthread.h>
1128 pthread_rwlock_t rwl;
1130 AC_MSG_RESULT([yes])
1131 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1132 [Define to 1 if you have the `pthread_rwlock_t' type.])
1138 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1140 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1142 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1144 #include <pthread.h>
1146 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1148 AC_MSG_RESULT([yes])
1149 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1150 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1156 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1158 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1160 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1162 #include <pthread.h>
1164 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1166 AC_MSG_RESULT([yes])
1167 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1168 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1174 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1176 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1178 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1180 #include <pthread.h>
1182 return (PTHREAD_MUTEX_RECURSIVE_NP);
1184 AC_MSG_RESULT([yes])
1185 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1186 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1192 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1194 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1196 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1198 #include <pthread.h>
1200 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1203 AC_MSG_RESULT([yes])
1204 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1205 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1211 # Check whether pthread_mutex_t has a member called __m_kind.
1213 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1214 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1216 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1219 [#include <pthread.h>])
1222 # Check whether pthread_mutex_t has a member called __data.__kind.
1224 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1225 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1227 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1230 [#include <pthread.h>])
1233 # does this compiler support -maltivec and does it have the include file
1236 AC_MSG_CHECKING([for Altivec])
1241 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1242 #include <altivec.h>
1244 vector unsigned int v;
1247 AC_MSG_RESULT([yes])
1248 AC_DEFINE([HAS_ALTIVEC], 1,
1249 [Define to 1 if gcc/as can do Altivec.])
1256 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes])
1259 # Check that both: the compiler supports -mvsx and that the assembler
1260 # understands VSX instructions. If either of those doesn't work,
1261 # conclude that we can't do VSX. NOTE: basically this is a kludge
1262 # in that it conflates two things that should be separate -- whether
1263 # the compiler understands the flag vs whether the assembler
1264 # understands the opcodes. This really ought to be cleaned up
1265 # and done properly, like it is for x86/x86_64.
1267 AC_MSG_CHECKING([for VSX])
1272 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1273 #include <altivec.h>
1275 vector unsigned int v;
1276 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1279 AC_MSG_RESULT([yes])
1286 AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes)
1289 AC_MSG_CHECKING([that assembler knows DFP])
1291 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1293 __asm__ __volatile__("dadd 1, 2, 3");
1294 __asm__ __volatile__("dcffix 1, 2");
1297 AC_MSG_RESULT([yes])
1304 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1307 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1309 __asm__ __volatile__("dadd 1, 2, 3");
1310 __asm__ __volatile__("dcffix 1, 2");
1313 AC_MSG_RESULT([yes])
1321 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes)
1324 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1325 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1327 _Decimal64 x = 0.0DD;
1329 ac_gcc_have_dfp_type=yes
1330 AC_MSG_RESULT([yes])
1332 ac_gcc_have_dfp_type=no
1336 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_gcc_have_dfp_type = xyes)
1339 AC_MSG_CHECKING([that assembler knows ISA 2.07 ])
1341 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1343 __asm__ __volatile__("mtvsrd 1,2 ");
1345 ac_asm_have_isa_2_07=yes
1346 AC_MSG_RESULT([yes])
1348 ac_asm_have_isa_2_07=no
1352 AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes)
1354 # Check for pthread_create@GLIBC2.0
1355 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1359 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1360 extern int pthread_create_glibc_2_0(void*, const void*,
1361 void *(*)(void*), void*);
1362 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1366 * Apparently on PowerPC linking this program succeeds and generates an
1367 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1369 #error This test does not work properly on PowerPC.
1371 pthread_create_glibc_2_0(0, 0, 0, 0);
1375 ac_have_pthread_create_glibc_2_0=yes
1376 AC_MSG_RESULT([yes])
1377 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1378 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1380 ac_have_pthread_create_glibc_2_0=no
1385 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1386 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1389 # Check for dlinfo RTLD_DI_TLS_MODID
1390 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1394 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1401 size_t sizes[10000];
1402 size_t modid_offset;
1403 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1406 ac_have_dlinfo_rtld_di_tls_modid=yes
1407 AC_MSG_RESULT([yes])
1408 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1409 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1411 ac_have_dlinfo_rtld_di_tls_modid=no
1416 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1417 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1420 # Check for eventfd_t, eventfd() and eventfd_read()
1421 AC_MSG_CHECKING([for eventfd()])
1423 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1424 #include <sys/eventfd.h>
1430 eventfd_read(fd, &ev);
1433 AC_MSG_RESULT([yes])
1434 AC_DEFINE([HAVE_EVENTFD], 1,
1435 [Define to 1 if you have the `eventfd' function.])
1436 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1437 [Define to 1 if you have the `eventfd_read' function.])
1442 # Check whether compiler can process #include <thread> without errors
1443 # clang 3.3 cannot process <thread> from e.g.
1444 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1446 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1448 safe_CXXFLAGS=$CXXFLAGS
1451 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1455 ac_cxx_can_include_thread_header=yes
1456 AC_MSG_RESULT([yes])
1458 ac_cxx_can_include_thread_header=no
1461 CXXFLAGS=$safe_CXXFLAGS
1464 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1467 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1468 # of the user_regs_struct from sys/user.h. They are structurally the same
1469 # but we get either one or the other.
1471 AC_CHECK_TYPE([struct user_regs_struct],
1472 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1473 [[#include <sys/ptrace.h>]
1474 [#include <sys/time.h>]
1475 [#include <sys/user.h>]])
1476 if test "$sys_user_has_user_regs" = "yes"; then
1477 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1478 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1482 #----------------------------------------------------------------------------
1483 # Checking for supported compiler flags.
1484 #----------------------------------------------------------------------------
1486 # does this compiler support -m32 ?
1487 AC_MSG_CHECKING([if gcc accepts -m32])
1492 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1496 AC_MSG_RESULT([yes])
1506 # does this compiler support -m64 ?
1507 AC_MSG_CHECKING([if gcc accepts -m64])
1512 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1516 AC_MSG_RESULT([yes])
1526 # does this compiler support -march=mips32 (mips32 default) ?
1527 AC_MSG_CHECKING([if gcc accepts -march=mips32])
1530 CFLAGS="$CFLAGS -march=mips32"
1532 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1535 FLAG_MIPS32="-march=mips32"
1536 AC_MSG_RESULT([yes])
1543 AC_SUBST(FLAG_MIPS32)
1546 # does this compiler support -march=mips64 (mips64 default) ?
1547 AC_MSG_CHECKING([if gcc accepts -march=mips64])
1550 CFLAGS="$CFLAGS -march=mips64"
1552 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1555 FLAG_MIPS64="-march=mips64"
1556 AC_MSG_RESULT([yes])
1563 AC_SUBST(FLAG_MIPS64)
1566 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1567 AC_MSG_CHECKING([if gcc accepts -march=octeon])
1570 CFLAGS="$CFLAGS -march=octeon"
1572 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1575 FLAG_OCTEON="-march=octeon"
1576 AC_MSG_RESULT([yes])
1583 AC_SUBST(FLAG_OCTEON)
1586 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1587 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1590 CFLAGS="$CFLAGS -march=octeon2"
1592 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1595 FLAG_OCTEON2="-march=octeon2"
1596 AC_MSG_RESULT([yes])
1603 AC_SUBST(FLAG_OCTEON2)
1606 # does this compiler support -mmmx ?
1607 AC_MSG_CHECKING([if gcc accepts -mmmx])
1612 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1616 AC_MSG_RESULT([yes])
1626 # does this compiler support -msse ?
1627 AC_MSG_CHECKING([if gcc accepts -msse])
1632 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1636 AC_MSG_RESULT([yes])
1646 # does this compiler support -mpreferred-stack-boundary=2 when
1647 # generating code for a 32-bit target? Note that we only care about
1648 # this when generating code for (32-bit) x86, so if the compiler
1649 # doesn't recognise -m32 it's no big deal. We'll just get code for
1650 # the Memcheck and other helper functions, that is a bit slower than
1651 # it could be, on x86; and no difference at all on any other platform.
1652 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
1655 CFLAGS="-mpreferred-stack-boundary=2 -m32"
1657 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1660 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
1661 AC_MSG_RESULT([yes])
1663 PREFERRED_STACK_BOUNDARY_2=""
1668 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
1671 # Convenience function to check whether GCC supports a particular
1672 # warning option. Takes two arguments, first the warning flag name
1673 # to check (without -W), then the conditional name to set if that
1674 # warning flag is supported.
1675 AC_DEFUN([AC_GCC_WARNING_COND],[
1676 AC_MSG_CHECKING([if gcc accepts -W$1])
1679 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1680 has_warning_flag=yes
1681 AC_MSG_RESULT([yes])], [
1683 AC_MSG_RESULT([no])])
1685 AM_CONDITIONAL([$2], test x$has_warning_flag = xyes)
1688 AC_GCC_WARNING_COND([pointer-sign], [HAS_POINTER_SIGN_WARNING])
1689 AC_GCC_WARNING_COND([write-strings], [HAS_WRITE_STRINGS_WARNING])
1690 if test $has_warning_flag = yes; then
1691 CFLAGS="$CFLAGS -Wwrite-strings"
1692 CXXFLAGS="$CXXFLAGS -Wwrite-strings"
1695 # Convenience function to check whether GCC supports a particular
1696 # warning option. Similar to AC_GCC_WARNING_COND, but does a
1697 # substitution instead of setting an conditional. Takes two arguments,
1698 # first the warning flag name to check (without -W), then the
1699 # substitution name to set with -Wno-warning-flag if the flag exists,
1700 # or the empty string if the compiler doesn't accept the flag. Note
1701 # that checking is done against the warning flag itself, but the
1702 # substitution is then done to cancel the warning flag.
1703 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
1704 AC_MSG_CHECKING([if gcc accepts -W$1])
1707 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1708 AC_SUBST([$2], [-Wno-$1])
1709 AC_MSG_RESULT([yes])], [
1711 AC_MSG_RESULT([no])])
1715 AC_GCC_WARNING_SUBST_NO([empty-body], [FLAG_W_NO_EMPTY_BODY])
1716 AC_GCC_WARNING_SUBST_NO([format-zero-length], [FLAG_W_NO_FORMAT_ZERO_LENGTH])
1717 AC_GCC_WARNING_SUBST_NO([tautological-compare], [FLAG_W_NO_TAUTOLOGICAL_COMPARE])
1718 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
1719 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
1720 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
1721 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
1722 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
1725 # does this compiler support -Wextra or the older -W ?
1727 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1732 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1735 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1736 AC_MSG_RESULT([-Wextra])
1739 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1742 AC_SUBST([FLAG_W_EXTRA], [-W])
1745 AC_SUBST([FLAG_W_EXTRA], [])
1746 AC_MSG_RESULT([not supported])
1751 # does this compiler support -Wcast-qual ?
1752 AC_GCC_WARNING_COND([cast-qual], [HAS_CAST_QUAL_WARNING])
1753 if test $has_warning_flag = yes; then
1754 CFLAGS="$CFLAGS -Wcast-qual"
1755 CXXFLAGS="$CXXFLAGS -Wcast-qual"
1759 # does this compiler support -fno-stack-protector ?
1760 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1763 CFLAGS="-fno-stack-protector"
1765 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1768 no_stack_protector=yes
1769 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1770 AC_MSG_RESULT([yes])
1772 no_stack_protector=no
1773 FLAG_FNO_STACK_PROTECTOR=""
1778 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1780 if test x$no_stack_protector = xyes; then
1781 CFLAGS="$CFLAGS -fno-stack-protector"
1782 CXXFLAGS="$CXXFLAGS -fno-stack-protector"
1786 # does this compiler support --param inline-unit-growth=... ?
1788 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
1791 CFLAGS="--param inline-unit-growth=900"
1793 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1796 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
1797 ["--param inline-unit-growth=900"])
1798 AC_MSG_RESULT([yes])
1800 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
1806 # does this compiler support -gdwarf-4 -fdebug-types-section ?
1808 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
1811 CFLAGS="-gdwarf-4 -fdebug-types-section"
1813 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1817 AC_MSG_RESULT([yes])
1822 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
1826 # does this compiler support nested functions ?
1828 AC_MSG_CHECKING([if gcc accepts nested functions])
1830 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1831 int foo() { return 1; }
1834 ac_have_nested_functions=yes
1835 AC_MSG_RESULT([yes])
1837 ac_have_nested_functions=no
1840 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
1843 # does this compiler support the 'p' constraint in ASM statements ?
1845 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
1847 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1849 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
1851 ac_have_asm_constraint_p=yes
1852 AC_MSG_RESULT([yes])
1854 ac_have_asm_constraint_p=no
1857 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
1860 # We want to use use the -Ttext-segment option to the linker.
1861 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
1862 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
1863 # semantics are NOT what we want (GNU gold -Ttext is fine).
1865 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
1866 # will reside. -Ttext aligns just the .text section start (but not any
1869 # So test for -Ttext-segment which is supported by all bfd ld versions
1870 # and use that if it exists. If it doesn't exist it must be an older
1871 # version of gold and we can fall back to using -Ttext which has the
1874 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
1877 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml"
1880 [AC_LANG_SOURCE([int _start () { return 0; }])],
1882 linker_using_t_text="no"
1883 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
1884 AC_MSG_RESULT([yes])
1886 linker_using_t_text="yes"
1887 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
1892 # If the linker only supports -Ttext (not -Ttext-segment) then we will
1893 # have to strip any build-id ELF NOTEs from the staticly linked tools.
1894 # Otherwise the build-id NOTE might end up at the default load address.
1895 # (Pedantically if the linker is gold then -Ttext is fine, but newer
1896 # gold versions also support -Ttext-segment. So just assume that unless
1897 # we can use -Ttext-segment we need to strip the build-id NOTEs.
1898 if test "x${linker_using_t_text}" = "xyes"; then
1899 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
1900 # does the linker support -Wl,--build-id=none ? Note, it's
1901 # important that we test indirectly via whichever C compiler
1902 # is selected, rather than testing /usr/bin/ld or whatever
1904 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
1906 CFLAGS="-Wl,--build-id=none"
1909 [AC_LANG_PROGRAM([ ], [return 0;])],
1911 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
1912 AC_MSG_RESULT([yes])
1914 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1918 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
1919 AC_SUBST([FLAG_NO_BUILD_ID], [""])
1923 # does the ppc assembler support "mtocrf" et al?
1924 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
1926 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1927 __asm__ __volatile__("mtocrf 4,0");
1928 __asm__ __volatile__("mfocrf 0,4");
1930 ac_have_as_ppc_mftocrf=yes
1931 AC_MSG_RESULT([yes])
1933 ac_have_as_ppc_mftocrf=no
1936 if test x$ac_have_as_ppc_mftocrf = xyes ; then
1937 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
1941 # does the ppc assembler support "lfdp" and other phased out floating point insns?
1942 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
1944 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1945 do { typedef struct {
1949 dbl_pair_t dbl_pair[3];
1950 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
1953 ac_have_as_ppc_fpPO=yes
1954 AC_MSG_RESULT([yes])
1956 ac_have_as_ppc_fpPO=no
1959 if test x$ac_have_as_ppc_fpPO = xyes ; then
1960 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
1964 # does the x86/amd64 assembler understand SSE3 instructions?
1965 # Note, this doesn't generate a C-level symbol. It generates a
1966 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
1967 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
1969 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1970 do { long long int x;
1971 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
1975 AC_MSG_RESULT([yes])
1981 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
1984 # Ditto for SSSE3 instructions (note extra S)
1985 # Note, this doesn't generate a C-level symbol. It generates a
1986 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
1987 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
1989 save_CFLAGS="$CFLAGS"
1990 CFLAGS="$CFLAGS -msse"
1991 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1992 do { long long int x;
1993 __asm__ __volatile__(
1994 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
1997 ac_have_as_ssse3=yes
1998 AC_MSG_RESULT([yes])
2003 CFLAGS="$save_CFLAGS"
2005 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2008 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2009 # Note, this doesn't generate a C-level symbol. It generates a
2010 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2011 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2012 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2014 __asm__ __volatile__(
2015 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2018 ac_have_as_pclmulqdq=yes
2019 AC_MSG_RESULT([yes])
2021 ac_have_as_pclmulqdq=no
2025 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2028 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2029 # Note, this doesn't generate a C-level symbol. It generates a
2030 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2031 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2032 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2035 * Carry-less multiplication of xmm1 with xmm2 and store the result in
2036 * xmm3. The immediate is used to determine which quadwords of xmm1 and
2037 * xmm2 should be used.
2039 __asm__ __volatile__(
2040 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2043 ac_have_as_vpclmulqdq=yes
2044 AC_MSG_RESULT([yes])
2046 ac_have_as_vpclmulqdq=no
2050 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2053 # does the x86/amd64 assembler understand the LZCNT instruction?
2054 # Note, this doesn't generate a C-level symbol. It generates a
2055 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2056 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2058 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2060 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2063 ac_have_as_lzcnt=yes
2064 AC_MSG_RESULT([yes])
2070 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2073 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2074 # Note, this doesn't generate a C-level symbol. It generates a
2075 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2076 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2078 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2080 __asm__ __volatile__("1: loopnel 1b\n");
2083 ac_have_as_loopnel=yes
2084 AC_MSG_RESULT([yes])
2086 ac_have_as_loopnel=no
2090 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2093 # does the x86/amd64 assembler understand ADDR32 ?
2094 # Note, this doesn't generate a C-level symbol. It generates a
2095 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2096 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2098 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2100 asm volatile ("addr32 rep movsb");
2103 ac_have_as_addr32=yes
2104 AC_MSG_RESULT([yes])
2106 ac_have_as_addr32=no
2110 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2113 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2114 # Note, this doesn't generate a C-level symbol. It generates a
2115 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2116 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2118 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2119 do { long long int x;
2120 __asm__ __volatile__(
2121 "crc32q %%r15,%%r15" : : : "r15" );
2122 __asm__ __volatile__(
2123 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2124 __asm__ __volatile__(
2125 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2128 ac_have_as_sse42=yes
2129 AC_MSG_RESULT([yes])
2135 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2138 # does the x86/amd64 assembler understand AVX instructions?
2139 # Note, this doesn't generate a C-level symbol. It generates a
2140 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2141 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2143 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2144 do { long long int x;
2145 __asm__ __volatile__(
2146 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2147 __asm__ __volatile__(
2148 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2152 AC_MSG_RESULT([yes])
2158 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2161 # does the x86/amd64 assembler understand AVX2 instructions?
2162 # Note, this doesn't generate a C-level symbol. It generates a
2163 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2164 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2167 do { long long int x;
2168 __asm__ __volatile__(
2169 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2170 __asm__ __volatile__(
2171 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2175 AC_MSG_RESULT([yes])
2181 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2184 # does the x86/amd64 assembler understand TSX instructions and
2185 # the XACQUIRE/XRELEASE prefixes?
2186 # Note, this doesn't generate a C-level symbol. It generates a
2187 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2188 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2192 __asm__ __volatile__(
2195 " xacquire lock incq 0(%rsp) \n\t"
2196 " xrelease lock incq 0(%rsp) \n"
2201 AC_MSG_RESULT([yes])
2207 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2210 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2211 # Note, this doesn't generate a C-level symbol. It generates a
2212 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2213 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2215 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2216 do { unsigned int h, l;
2217 __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2218 __asm__ __volatile__(
2219 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2220 __asm__ __volatile__(
2221 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2225 AC_MSG_RESULT([yes])
2231 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2234 # does the x86/amd64 assembler understand FMA instructions?
2235 # Note, this doesn't generate a C-level symbol. It generates a
2236 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2237 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2239 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2240 do { unsigned int h, l;
2241 __asm__ __volatile__(
2242 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2243 __asm__ __volatile__(
2244 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2245 __asm__ __volatile__(
2246 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2250 AC_MSG_RESULT([yes])
2256 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2259 # does the amd64 assembler understand MPX instructions?
2260 # Note, this doesn't generate a C-level symbol. It generates a
2261 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2262 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2264 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2265 asm ("bndmov %bnd0,(%rsp)")
2268 AC_MSG_RESULT([yes])
2274 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2277 # Does the C compiler support the "ifunc" attribute
2278 # Note, this doesn't generate a C-level symbol. It generates a
2279 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2280 # does the x86/amd64 assembler understand MOVBE?
2281 # Note, this doesn't generate a C-level symbol. It generates a
2282 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2283 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2286 do { long long int x;
2287 __asm__ __volatile__(
2288 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
2291 ac_have_as_movbe=yes
2292 AC_MSG_RESULT([yes])
2298 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2301 # Does the C compiler support the "ifunc" attribute
2302 # Note, this doesn't generate a C-level symbol. It generates a
2303 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2304 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2306 AC_LINK_IFELSE([AC_LANG_SOURCE([[
2307 static void mytest(void) {}
2309 static void (*resolve_test(void))(void)
2311 return (void (*)(void))&mytest;
2314 void test(void) __attribute__((ifunc("resolve_test")));
2322 ac_have_ifunc_attr=yes
2323 AC_MSG_RESULT([yes])
2325 ac_have_ifunc_attr=no
2329 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2332 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
2333 # when building the tool executables. I think we should get rid of it.
2335 # Check for TLS support in the compiler and linker
2336 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2338 [vg_cv_linktime_tls=yes],
2339 [vg_cv_linktime_tls=no])
2340 # Native compilation: check whether running a program using TLS succeeds.
2341 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2342 # succeeds but running programs using TLS fails.
2343 # Cross-compiling: check whether linking a program using TLS succeeds.
2344 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2345 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
2346 [vg_cv_tls=$enableval],
2347 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2351 [vg_cv_tls=$vg_cv_linktime_tls])])])
2353 if test "$vg_cv_tls" = yes; then
2354 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2358 #----------------------------------------------------------------------------
2359 # Checks for C header files.
2360 #----------------------------------------------------------------------------
2363 AC_CHECK_HEADERS([ \
2379 # Verify whether the <linux/futex.h> header is usable.
2380 AC_MSG_CHECKING([if <linux/futex.h> is usable])
2382 save_CFLAGS="$CFLAGS"
2383 CFLAGS="$CFLAGS -D__user="
2384 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2385 #include <linux/futex.h>
2389 ac_have_usable_linux_futex_h=yes
2390 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
2391 [Define to 1 if you have a usable <linux/futex.h> header file.])
2392 AC_MSG_RESULT([yes])
2394 ac_have_usable_linux_futex_h=no
2397 CFLAGS="$save_CFLAGS"
2400 #----------------------------------------------------------------------------
2401 # Checks for typedefs, structures, and compiler characteristics.
2402 #----------------------------------------------------------------------------
2409 #----------------------------------------------------------------------------
2410 # Checks for library functions.
2411 #----------------------------------------------------------------------------
2415 AC_CHECK_LIB([pthread], [pthread_create])
2416 AC_CHECK_LIB([rt], [clock_gettime])
2429 pthread_barrier_init \
2430 pthread_condattr_setclock \
2431 pthread_mutex_timedlock \
2432 pthread_rwlock_timedrdlock \
2433 pthread_rwlock_timedwrlock \
2436 pthread_setname_np \
2452 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
2453 # libraries with any shared object and/or executable. This is NOT what we
2454 # want for e.g. vgpreload_core-x86-linux.so
2457 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
2458 [test x$ac_cv_func_pthread_barrier_init = xyes])
2459 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
2460 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
2461 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
2462 [test x$ac_cv_func_pthread_spin_lock = xyes])
2463 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
2464 [test x$ac_cv_func_pthread_setname_np = xyes])
2466 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2467 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
2468 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
2469 [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
2472 #----------------------------------------------------------------------------
2474 #----------------------------------------------------------------------------
2475 # Do we have a useable MPI setup on the primary and/or secondary targets?
2476 # On Linux, by default, assumes mpicc and -m32/-m64
2477 # Note: this is a kludge in that it assumes the specified mpicc
2478 # understands -m32/-m64 regardless of what is specified using
2480 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
2481 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
2484 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
2485 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
2486 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
2487 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
2488 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
2489 mflag_primary=$FLAG_M32
2490 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
2491 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
2492 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
2493 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
2494 mflag_primary=$FLAG_M64
2495 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
2496 mflag_primary="$FLAG_M32 -arch i386"
2497 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
2498 mflag_primary="$FLAG_M64 -arch x86_64"
2502 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
2503 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then
2504 mflag_secondary=$FLAG_M32
2505 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
2506 mflag_secondary="$FLAG_M32 -arch i386"
2511 [ --with-mpicc= Specify name of MPI2-ised C compiler],
2516 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
2517 ## use these values in the check for a functioning mpicc.
2519 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
2520 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
2521 AM_COND_IF([VGCONF_OS_IS_LINUX],
2522 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
2523 LDFLAGS_MPI="-fpic -shared"])
2524 AM_COND_IF([VGCONF_OS_IS_DARWIN],
2525 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
2526 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
2528 AC_SUBST([CFLAGS_MPI])
2529 AC_SUBST([LDFLAGS_MPI])
2532 ## See if MPI_CC works for the primary target
2534 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
2536 saved_CFLAGS=$CFLAGS
2538 CFLAGS="$CFLAGS_MPI $mflag_primary"
2539 saved_LDFLAGS="$LDFLAGS"
2540 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
2541 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2545 int ni, na, nd, comb;
2546 int r = MPI_Init(NULL,NULL);
2547 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2548 r |= MPI_Finalize();
2551 ac_have_mpi2_pri=yes
2552 AC_MSG_RESULT([yes, $MPI_CC])
2558 CFLAGS=$saved_CFLAGS
2559 LDFLAGS="$saved_LDFLAGS"
2560 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
2562 ## See if MPI_CC works for the secondary target. Complication: what if
2563 ## there is no secondary target? We need this to then fail.
2564 ## Kludge this by making MPI_CC something which will surely fail in
2567 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
2569 saved_CFLAGS=$CFLAGS
2570 saved_LDFLAGS="$LDFLAGS"
2571 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
2572 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
2573 CC="$MPI_CC this will surely fail"
2577 CFLAGS="$CFLAGS_MPI $mflag_secondary"
2578 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2582 int ni, na, nd, comb;
2583 int r = MPI_Init(NULL,NULL);
2584 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
2585 r |= MPI_Finalize();
2588 ac_have_mpi2_sec=yes
2589 AC_MSG_RESULT([yes, $MPI_CC])
2595 CFLAGS=$saved_CFLAGS
2596 LDFLAGS="$saved_LDFLAGS"
2597 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
2600 #----------------------------------------------------------------------------
2601 # Other library checks
2602 #----------------------------------------------------------------------------
2603 # There now follow some tests for Boost, and OpenMP. These
2604 # tests are present because Drd has some regression tests that use
2605 # these packages. All regression test programs all compiled only
2606 # for the primary target. And so it is important that the configure
2607 # checks that follow, use the correct -m32 or -m64 flag for the
2608 # primary target (called $mflag_primary). Otherwise, we can end up
2609 # in a situation (eg) where, on amd64-linux, the test for Boost checks
2610 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
2611 # only build (meaning, the primary target is x86-linux), the build
2612 # of the regtest programs that use Boost fails, because they are
2613 # build as 32-bit (IN THIS EXAMPLE).
2615 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
2616 # NEEDED BY THE REGRESSION TEST PROGRAMS.
2619 # Check whether the boost library 1.35 or later has been installed.
2620 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
2622 AC_MSG_CHECKING([for boost])
2625 safe_CXXFLAGS=$CXXFLAGS
2626 CXXFLAGS="$mflag_primary"
2628 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
2630 AC_LINK_IFELSE([AC_LANG_SOURCE([
2631 #include <boost/thread.hpp>
2632 static void thread_func(void)
2634 int main(int argc, char** argv)
2636 boost::thread t(thread_func);
2641 ac_have_boost_1_35=yes
2642 AC_SUBST([BOOST_CFLAGS], [])
2643 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
2644 AC_MSG_RESULT([yes])
2646 ac_have_boost_1_35=no
2651 CXXFLAGS=$safe_CXXFLAGS
2654 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
2657 # does this compiler support -fopenmp, does it have the include file
2658 # <omp.h> and does it have libgomp ?
2660 AC_MSG_CHECKING([for OpenMP])
2663 CFLAGS="-fopenmp $mflag_primary"
2665 AC_LINK_IFELSE([AC_LANG_SOURCE([
2667 int main(int argc, char** argv)
2675 AC_MSG_RESULT([yes])
2682 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
2685 # Check for __builtin_popcount
2686 AC_MSG_CHECKING([for __builtin_popcount()])
2687 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2689 __builtin_popcount(2);
2692 AC_MSG_RESULT([yes])
2693 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
2694 [Define to 1 if compiler provides __builtin_popcount().])
2699 # Check for __builtin_clz
2700 AC_MSG_CHECKING([for __builtin_clz()])
2701 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2706 AC_MSG_RESULT([yes])
2707 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
2708 [Define to 1 if compiler provides __builtin_clz().])
2713 # Check for __builtin_ctz
2714 AC_MSG_CHECKING([for __builtin_ctz()])
2715 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2720 AC_MSG_RESULT([yes])
2721 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
2722 [Define to 1 if compiler provides __builtin_ctz().])
2727 # does this compiler have built-in functions for atomic memory access for the
2729 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
2732 CFLAGS="$mflag_primary"
2734 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2736 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2737 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2739 ac_have_builtin_atomic_primary=yes
2740 AC_MSG_RESULT([yes])
2741 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])
2743 ac_have_builtin_atomic_primary=no
2749 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
2750 [test x$ac_have_builtin_atomic_primary = xyes])
2753 # does this compiler have built-in functions for atomic memory access for the
2754 # secondary target ?
2756 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2758 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
2761 CFLAGS="$mflag_secondary"
2763 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2765 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
2767 ac_have_builtin_atomic_secondary=yes
2768 AC_MSG_RESULT([yes])
2770 ac_have_builtin_atomic_secondary=no
2778 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
2779 [test x$ac_have_builtin_atomic_secondary = xyes])
2781 # does this compiler have built-in functions for atomic memory access on
2782 # 64-bit integers for all targets ?
2784 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
2786 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2789 uint64_t variable = 1;
2790 return __sync_add_and_fetch(&variable, 1)
2792 ac_have_builtin_atomic64_primary=yes
2794 ac_have_builtin_atomic64_primary=no
2797 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
2800 CFLAGS="$mflag_secondary"
2802 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2805 uint64_t variable = 1;
2806 return __sync_add_and_fetch(&variable, 1)
2808 ac_have_builtin_atomic64_secondary=yes
2810 ac_have_builtin_atomic64_secondary=no
2817 if test x$ac_have_builtin_atomic64_primary = xyes && \
2818 test x$VGCONF_PLATFORM_SEC_CAPS = x \
2819 -o x$ac_have_builtin_atomic64_secondary = xyes; then
2820 AC_MSG_RESULT([yes])
2821 ac_have_builtin_atomic64=yes
2824 ac_have_builtin_atomic64=no
2827 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
2828 [test x$ac_have_builtin_atomic64 = xyes])
2831 # does g++ have built-in functions for atomic memory access ?
2832 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
2834 safe_CXXFLAGS=$CXXFLAGS
2835 CXXFLAGS="$mflag_primary"
2838 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2840 return (__sync_bool_compare_and_swap(&variable, 1, 2)
2841 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
2843 ac_have_builtin_atomic_cxx=yes
2844 AC_MSG_RESULT([yes])
2845 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
2847 ac_have_builtin_atomic_cxx=no
2852 CXXFLAGS=$safe_CXXFLAGS
2854 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
2857 if test x$ac_have_usable_linux_futex_h = xyes \
2858 -a x$ac_have_builtin_atomic_primary = xyes; then
2859 ac_enable_linux_ticket_lock_primary=yes
2861 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
2862 [test x$ac_enable_linux_ticket_lock_primary = xyes])
2864 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
2865 -a x$ac_have_usable_linux_futex_h = xyes \
2866 -a x$ac_have_builtin_atomic_secondary = xyes; then
2867 ac_enable_linux_ticket_lock_secondary=yes
2869 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
2870 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
2873 # does libstdc++ support annotating shared pointers ?
2874 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
2876 safe_CXXFLAGS=$CXXFLAGS
2877 CXXFLAGS="-std=c++0x"
2880 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2883 std::shared_ptr<int> p
2885 ac_have_shared_ptr=yes
2887 ac_have_shared_ptr=no
2889 if test x$ac_have_shared_ptr = xyes; then
2890 # If compilation of the program below fails because of a syntax error
2891 # triggered by substituting one of the annotation macros then that
2892 # means that libstdc++ supports these macros.
2893 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2894 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
2895 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
2898 std::shared_ptr<int> p
2900 ac_have_shared_pointer_annotation=no
2903 ac_have_shared_pointer_annotation=yes
2904 AC_MSG_RESULT([yes])
2905 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
2906 [Define to 1 if libstd++ supports annotating shared pointers])
2909 ac_have_shared_pointer_annotation=no
2914 CXXFLAGS=$safe_CXXFLAGS
2916 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
2917 [test x$ac_have_shared_pointer_annotation = xyes])
2920 #----------------------------------------------------------------------------
2921 # Ok. We're done checking.
2922 #----------------------------------------------------------------------------
2924 # Nb: VEX/Makefile is generated from Makefile.vex.in.
2927 VEX/Makefile:Makefile.vex.in
2936 gdbserver_tests/Makefile
2942 memcheck/tests/Makefile
2943 memcheck/tests/common/Makefile
2944 memcheck/tests/amd64/Makefile
2945 memcheck/tests/x86/Makefile
2946 memcheck/tests/linux/Makefile
2947 memcheck/tests/darwin/Makefile
2948 memcheck/tests/amd64-linux/Makefile
2949 memcheck/tests/x86-linux/Makefile
2950 memcheck/tests/ppc32/Makefile
2951 memcheck/tests/ppc64/Makefile
2952 memcheck/tests/s390x/Makefile
2953 memcheck/tests/vbit-test/Makefile
2955 cachegrind/tests/Makefile
2956 cachegrind/tests/x86/Makefile
2957 cachegrind/cg_annotate
2960 callgrind/callgrind_annotate
2961 callgrind/callgrind_control
2962 callgrind/tests/Makefile
2964 helgrind/tests/Makefile
2966 massif/tests/Makefile
2969 lackey/tests/Makefile
2972 none/tests/amd64/Makefile
2973 none/tests/ppc32/Makefile
2974 none/tests/ppc64/Makefile
2975 none/tests/x86/Makefile
2976 none/tests/arm/Makefile
2977 none/tests/arm64/Makefile
2978 none/tests/s390x/Makefile
2979 none/tests/mips32/Makefile
2980 none/tests/mips64/Makefile
2981 none/tests/linux/Makefile
2982 none/tests/darwin/Makefile
2983 none/tests/x86-linux/Makefile
2984 exp-sgcheck/Makefile
2985 exp-sgcheck/tests/Makefile
2987 drd/scripts/download-and-build-splash2
2990 exp-bbv/tests/Makefile
2991 exp-bbv/tests/x86/Makefile
2992 exp-bbv/tests/x86-linux/Makefile
2993 exp-bbv/tests/amd64-linux/Makefile
2994 exp-bbv/tests/ppc32-linux/Makefile
2995 exp-bbv/tests/arm-linux/Makefile
2997 exp-dhat/tests/Makefile
3000 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
3001 [chmod +x coregrind/link_tool_exe_linux])
3002 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
3003 [chmod +x coregrind/link_tool_exe_darwin])
3008 Maximum build arch: ${ARCH_MAX}
3009 Primary build arch: ${VGCONF_ARCH_PRI}
3010 Secondary build arch: ${VGCONF_ARCH_SEC}
3011 Build OS: ${VGCONF_OS}
3012 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
3013 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
3014 Platform variant: ${VGCONF_PLATVARIANT}
3015 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
3016 Default supp files: ${DEFAULT_SUPP}