Fix "make post-regtest-checks" after 441bfc5f51c7f5f80cc6491d23cbe2dc711d191f (dhat...
[valgrind.git] / configure.ac
blobb885bd91bf50082492badf0950fa1f0290a472f6
2 ##------------------------------------------------------------##
3
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.15.0.GIT],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign subdir-objects])
16 AM_MAINTAINER_MODE
18 #----------------------------------------------------------------------------
19 # Do NOT modify these flags here. Except in feature tests in which case
20 # the original values must be properly restored.
21 #----------------------------------------------------------------------------
22 CFLAGS="$CFLAGS"
23 CXXFLAGS="$CXXFLAGS"
25 #----------------------------------------------------------------------------
26 # Checks for various programs.
27 #----------------------------------------------------------------------------
29 AC_PROG_LN_S
30 AC_PROG_CC
31 AM_PROG_CC_C_O
32 AC_PROG_CPP
33 AC_PROG_CXX
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
37 # following:
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],
42 #        [AC_PROG_OBJC],
43 #        [AC_CHECK_TOOL([OBJC], [gcc])
44 #         AC_SUBST([OBJC])
45 #         AC_SUBST([OBJCFLAGS])
46 #        ])
47 AC_PROG_RANLIB
48 # Set LTO_RANLIB variable to an lto enabled ranlib
49 if test "x$LTO_RANLIB" = "x"; then
50   AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
52 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
54 # provide a very basic definition for AC_PROG_SED if it's not provided by
55 # autoconf (as e.g. in autoconf 2.59).
56 m4_ifndef([AC_PROG_SED],
57           [AC_DEFUN([AC_PROG_SED],
58                     [AC_ARG_VAR([SED])
59                      AC_CHECK_PROGS([SED],[gsed sed])])])
60 AC_PROG_SED
62 # If no AR variable was specified, look up the name of the archiver. Otherwise
63 # do not touch the AR variable.
64 if test "x$AR" = "x"; then
65   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
67 AC_ARG_VAR([AR],[Archiver command])
69 # same for LTO_AR variable for lto enabled archiver
70 if test "x$LTO_AR" = "x"; then
71   AC_PATH_PROGS([LTO_AR], [gcc-ar])
73 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
76 # Check for the compiler support
77 if test "${GCC}" != "yes" ; then
78    AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
81 # figure out where perl lives
82 AC_PATH_PROG(PERL, perl)
84 # figure out where gdb lives
85 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
86 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
88 # some older automake's don't have it so try something on our own
89 ifdef([AM_PROG_AS],[AM_PROG_AS],
91 AS="${CC}"
92 AC_SUBST(AS)
94 ASFLAGS=""
95 AC_SUBST(ASFLAGS)
99 # Check if 'diff' supports -u (universal diffs) and use it if possible.
101 AC_MSG_CHECKING([for diff -u])
102 AC_SUBST(DIFF)
104 # Comparing two identical files results in 0.
105 tmpfile="tmp-xxx-yyy-zzz"
106 touch $tmpfile;
107 if diff -u $tmpfile $tmpfile ; then
108     AC_MSG_RESULT([yes])
109     DIFF="diff -u"
110 else
111     AC_MSG_RESULT([no])
112     DIFF="diff"
114 rm $tmpfile
116 # Make sure we can compile in C99 mode.
117 AC_PROG_CC_C99
118 if test "$ac_cv_prog_cc_c99" == "no"; then
119     AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
122 # We don't want gcc < 3.0
123 AC_MSG_CHECKING([for a supported version of gcc])
125 # Obtain the compiler version.
127 # A few examples of how the ${CC} --version output looks like:
129 # ######## gcc variants ########
130 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
131 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
132 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
133 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
134 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
135 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
136 # OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
138 # ######## clang variants ########
139 # Clang: clang version 2.9 (tags/RELEASE_29/final)
140 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
141 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
143 # ######## Apple LLVM variants ########
144 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
145 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
148 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
149 then
150     is_clang="applellvm"
151     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
152 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
153 then
154     is_clang="clang"
155     # Don't use -dumpversion with clang: it will always produce "4.2.1".
156     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
157 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
158 then
159     is_clang="icc"
160     gcc_version=`${CC} -dumpversion 2>/dev/null`
161 else
162     is_clang="notclang"
163     gcc_version=`${CC} -dumpversion 2>/dev/null`
164     if test "x$gcc_version" = x; then
165         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
166     fi
169 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
170 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
172 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
173 # statements have to be quoted.
174 case "${is_clang}-${gcc_version}" in
175      applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
176         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
177         ;;
178      icc-1[[3-9]].*)
179         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
180         ;;
181      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
182         AC_MSG_RESULT([ok (${gcc_version})])
183         ;;
184      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
185         AC_MSG_RESULT([ok (clang-${gcc_version})])
186         ;;
187      *)
188         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
189         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
190         ;;
191 esac
193 #----------------------------------------------------------------------------
194 # Arch/OS/platform tests.
195 #----------------------------------------------------------------------------
196 # We create a number of arch/OS/platform-related variables.  We prefix them
197 # all with "VGCONF_" which indicates that they are defined at
198 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
199 # variables used when compiling C files.
201 AC_CANONICAL_HOST
203 AC_MSG_CHECKING([for a supported CPU])
205 # ARCH_MAX reflects the most that this CPU can do: for example if it
206 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
207 # Ditto for amd64.  It is used for more configuration below, but is not used
208 # outside this file.
210 # Power PC returns powerpc for Big Endian.  This was not changed when Little
211 # Endian support was added to the 64-bit architecture.  The 64-bit Little
212 # Endian systems explicitly state le in the host_cpu.  For clarity in the
213 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
214 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
215 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
216 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
217 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
218 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
219 # Little Endian.
221 case "${host_cpu}" in
222      i?86) 
223         AC_MSG_RESULT([ok (${host_cpu})])
224         ARCH_MAX="x86"
225         ;;
227      x86_64) 
228         AC_MSG_RESULT([ok (${host_cpu})])
229         ARCH_MAX="amd64"
230         ;;
232      powerpc64)
233      # this only referrs to 64-bit Big Endian
234         AC_MSG_RESULT([ok (${host_cpu})])
235         ARCH_MAX="ppc64be"
236         ;;
238      powerpc64le)
239      # this only referrs to 64-bit Little Endian
240         AC_MSG_RESULT([ok (${host_cpu})])
241         ARCH_MAX="ppc64le"
242         ;;
244      powerpc)
245         # On Linux this means only a 32-bit capable CPU.
246         AC_MSG_RESULT([ok (${host_cpu})])
247         ARCH_MAX="ppc32"
248         ;;
250      s390x)
251         AC_MSG_RESULT([ok (${host_cpu})])
252         ARCH_MAX="s390x"
253         ;;
255      armv7*)
256         AC_MSG_RESULT([ok (${host_cpu})])
257         ARCH_MAX="arm"
258         ;;
260      aarch64*)
261        AC_MSG_RESULT([ok (${host_cpu})])
262        ARCH_MAX="arm64"
263        ;;
265      mips)
266         AC_MSG_RESULT([ok (${host_cpu})])
267         ARCH_MAX="mips32"
268         ;;
270      mipsel)
271         AC_MSG_RESULT([ok (${host_cpu})])
272         ARCH_MAX="mips32"
273         ;;
275      mipsisa32r2)
276         AC_MSG_RESULT([ok (${host_cpu})])
277         ARCH_MAX="mips32"
278         ;;
280      mips64*)
281         AC_MSG_RESULT([ok (${host_cpu})])
282         ARCH_MAX="mips64"
283         ;;
285      mipsisa64*)
286         AC_MSG_RESULT([ok (${host_cpu})])
287         ARCH_MAX="mips64"
288         ;;
290      *) 
291         AC_MSG_RESULT([no (${host_cpu})])
292         AC_MSG_ERROR([Unsupported host architecture. Sorry])
293         ;;
294 esac
296 #----------------------------------------------------------------------------
298 # Sometimes it's convenient to subvert the bi-arch build system and
299 # just have a single build even though the underlying platform is
300 # capable of both.  Hence handle --enable-only64bit and
301 # --enable-only32bit.  Complain if both are issued :-)
302 # [Actually, if either of these options are used, I think both get built,
303 # but only one gets installed.  So if you use an in-place build, both can be
304 # used. --njn]
306 # Check if a 64-bit only build has been requested
307 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
308    [AC_ARG_ENABLE(only64bit, 
309       [  --enable-only64bit      do a 64-bit only build],
310       [vg_cv_only64bit=$enableval],
311       [vg_cv_only64bit=no])])
313 # Check if a 32-bit only build has been requested
314 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
315    [AC_ARG_ENABLE(only32bit, 
316       [  --enable-only32bit      do a 32-bit only build],
317       [vg_cv_only32bit=$enableval],
318       [vg_cv_only32bit=no])])
320 # Stay sane
321 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
322    AC_MSG_ERROR(
323       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
326 #----------------------------------------------------------------------------
328 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
329 # compilation of many C files via -VGO_$(VGCONF_OS) and
330 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
331 AC_MSG_CHECKING([for a supported OS])
332 AC_SUBST(VGCONF_OS)
334 DEFAULT_SUPP=""
336 case "${host_os}" in
337      *linux*)
338         AC_MSG_RESULT([ok (${host_os})])
339         VGCONF_OS="linux"
341         # Ok, this is linux. Check the kernel version
342         AC_MSG_CHECKING([for the kernel version])
344         kernel=`uname -r`
346         case "${kernel}" in
347              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
348                     AC_MSG_RESULT([unsupported (${kernel})])
349                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
350                     ;;
352              *)
353                     AC_MSG_RESULT([2.6 or later (${kernel})])
354                     ;;
355         esac
357         ;;
359      *darwin*)
360         AC_MSG_RESULT([ok (${host_os})])
361         VGCONF_OS="darwin"
362         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
363         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
364         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
365         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
366         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
367         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
368         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
369         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
370         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
372         AC_MSG_CHECKING([for the kernel version])
373         kernel=`uname -r`
375         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
376         # has only one relevant version, the OS version. The `uname` check
377         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
378         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
379         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
380         # and we don't know of an macros similar to __GLIBC__ to get that info.
381         #
382         # XXX: `uname -r` won't do the right thing for cross-compiles, but
383         # that's not a problem yet.
384         #
385         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
386         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
387         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
388         # time support for 10.5 (the 9.* pattern just below), I'll leave it
389         # in for now, just in case anybody wants to give it a try.  But I'm
390         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
391         case "${kernel}" in
392              9.*)
393                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
394                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
395                   DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
396                   DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
397                   ;;
398              10.*)
399                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
400                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
401                   DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
402                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
403                   ;;
404              11.*)
405                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
406                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
407                   DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
408                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
409                   ;;
410              12.*)
411                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
412                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
413                   DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
414                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
415                   ;;
416              13.*)
417                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
418                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
419                   DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
420                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
421                   ;;
422              14.*)
423                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
424                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
425                   DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
426                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
427                   ;;
428              15.*)
429                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
430                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
431                   DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
432                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
433                   ;;
434              16.*)
435                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
436                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
437                   DEFAULT_SUPP="darwin16.supp ${DEFAULT_SUPP}"
438                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
439                   ;;
440              17.*)
441                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
442                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
443                   DEFAULT_SUPP="darwin17.supp ${DEFAULT_SUPP}"
444                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
445                   ;;
446              *) 
447                   AC_MSG_RESULT([unsupported (${kernel})])
448                   AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x and 17.x (Mac OS X 10.6/7/8/9/10/11 and macOS 10.12/13)])
449                   ;;
450         esac
451         ;;
453      solaris2.11*)
454         AC_MSG_RESULT([ok (${host_os})])
455         VGCONF_OS="solaris"
457         uname_v=$( uname -v )
458         case "$uname_v" in
459              11.4.*)
460                  DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
461                  ;;
462              *)
463                  DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
464                  ;;
465         esac
466         ;;
468      solaris2.12*)
469         AC_MSG_RESULT([ok (${host_os})])
470         VGCONF_OS="solaris"
471         DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
472         ;;
474      *) 
475         AC_MSG_RESULT([no (${host_os})])
476         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
477         ;;
478 esac
480 #----------------------------------------------------------------------------
482 # If we are building on a 64 bit platform test to see if the system
483 # supports building 32 bit programs and disable 32 bit support if it
484 # does not support building 32 bit programs
486 case "$ARCH_MAX-$VGCONF_OS" in
487      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
488         AC_MSG_CHECKING([for 32 bit build support])
489         safe_CFLAGS=$CFLAGS
490         CFLAGS="-m32"
491         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
492           return 0;
493         ]])], [
494         AC_MSG_RESULT([yes])
495         ], [
496         vg_cv_only64bit="yes"
497         AC_MSG_RESULT([no])
498         ])
499         CFLAGS=$safe_CFLAGS;;
500     mips64-linux)
501         AC_MSG_CHECKING([for 32 bit build support])
502         safe_CFLAGS=$CFLAGS
503         CFLAGS="$CFLAGS -mips32 -mabi=32"
504         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
505           #include <sys/prctl.h>
506         ]], [[]])], [
507         AC_MSG_RESULT([yes])
508         ], [
509         vg_cv_only64bit="yes"
510         AC_MSG_RESULT([no])
511         ])
512         CFLAGS=$safe_CFLAGS;;
513 esac
515 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
516    AC_MSG_ERROR(
517       [--enable-only32bit was specified but system does not support 32 bit builds])
520 #----------------------------------------------------------------------------
522 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
523 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
524 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
525 # above) will be "amd64" since that reflects the most that this cpu can do,
526 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
527 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
528 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
529 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
530 AC_SUBST(VGCONF_ARCH_PRI)
532 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
533 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
534 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
535 # It is empty if there is no secondary target.
536 AC_SUBST(VGCONF_ARCH_SEC)
538 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
539 # The entire system, including regression and performance tests, will be
540 # built for this target.  The "_CAPS" indicates that the name is in capital
541 # letters, and it also uses '_' rather than '-' as a separator, because it's
542 # used to create various Makefile variables, which are all in caps by
543 # convention and cannot contain '-' characters.  This is in contrast to
544 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
545 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
547 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
548 # Valgrind and tools will also be built for this target, but not the
549 # regression or performance tests.
551 # By default, the primary arch is the same as the "max" arch, as commented
552 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
553 # the big case statement just below here, in the case where we're building
554 # on a 64 bit machine but have been requested only to do a 32 bit build.
555 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
557 AC_MSG_CHECKING([for a supported CPU/OS combination])
559 # NB.  The load address for a given platform may be specified in more 
560 # than one place, in some cases, depending on whether we're doing a biarch,
561 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
562 # Be careful to give consistent values in all subcases.  Also, all four
563 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
564 # even if it is to "0xUNSET".
566 case "$ARCH_MAX-$VGCONF_OS" in
567      x86-linux)
568         VGCONF_ARCH_PRI="x86"
569         VGCONF_ARCH_SEC=""
570         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
571         VGCONF_PLATFORM_SEC_CAPS=""
572         valt_load_address_pri_norml="0x58000000"
573         valt_load_address_pri_inner="0x38000000"
574         valt_load_address_sec_norml="0xUNSET"
575         valt_load_address_sec_inner="0xUNSET"
576         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
577         ;;
578      amd64-linux)
579         valt_load_address_sec_norml="0xUNSET"
580         valt_load_address_sec_inner="0xUNSET"
581         if test x$vg_cv_only64bit = xyes; then
582            VGCONF_ARCH_PRI="amd64"
583            VGCONF_ARCH_SEC=""
584            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
585            VGCONF_PLATFORM_SEC_CAPS=""
586            valt_load_address_pri_norml="0x58000000"
587            valt_load_address_pri_inner="0x38000000"
588         elif test x$vg_cv_only32bit = xyes; then
589            VGCONF_ARCH_PRI="x86"
590            VGCONF_ARCH_SEC=""
591            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
592            VGCONF_PLATFORM_SEC_CAPS=""
593            valt_load_address_pri_norml="0x58000000"
594            valt_load_address_pri_inner="0x38000000"
595         else
596            VGCONF_ARCH_PRI="amd64"
597            VGCONF_ARCH_SEC="x86"
598            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
599            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
600            valt_load_address_pri_norml="0x58000000"
601            valt_load_address_pri_inner="0x38000000"
602            valt_load_address_sec_norml="0x58000000"
603            valt_load_address_sec_inner="0x38000000"
604         fi
605         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
606         ;;
607      ppc32-linux)
608         VGCONF_ARCH_PRI="ppc32"
609         VGCONF_ARCH_SEC=""
610         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
611         VGCONF_PLATFORM_SEC_CAPS=""
612         valt_load_address_pri_norml="0x58000000"
613         valt_load_address_pri_inner="0x38000000"
614         valt_load_address_sec_norml="0xUNSET"
615         valt_load_address_sec_inner="0xUNSET"
616         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
617         ;;
618      ppc64be-linux)
619         valt_load_address_sec_norml="0xUNSET"
620         valt_load_address_sec_inner="0xUNSET"
621         if test x$vg_cv_only64bit = xyes; then
622            VGCONF_ARCH_PRI="ppc64be"
623            VGCONF_ARCH_SEC=""
624            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
625            VGCONF_PLATFORM_SEC_CAPS=""
626            valt_load_address_pri_norml="0x58000000"
627            valt_load_address_pri_inner="0x38000000"
628         elif test x$vg_cv_only32bit = xyes; then
629            VGCONF_ARCH_PRI="ppc32"
630            VGCONF_ARCH_SEC=""
631            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
632            VGCONF_PLATFORM_SEC_CAPS=""
633            valt_load_address_pri_norml="0x58000000"
634            valt_load_address_pri_inner="0x38000000"
635         else
636            VGCONF_ARCH_PRI="ppc64be"
637            VGCONF_ARCH_SEC="ppc32"
638            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
639            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
640            valt_load_address_pri_norml="0x58000000"
641            valt_load_address_pri_inner="0x38000000"
642            valt_load_address_sec_norml="0x58000000"
643            valt_load_address_sec_inner="0x38000000"
644         fi
645         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
646         ;;
647      ppc64le-linux)
648         # Little Endian is only supported on PPC64
649         valt_load_address_sec_norml="0xUNSET"
650         valt_load_address_sec_inner="0xUNSET"
651         VGCONF_ARCH_PRI="ppc64le"
652         VGCONF_ARCH_SEC=""
653         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
654         VGCONF_PLATFORM_SEC_CAPS=""
655         valt_load_address_pri_norml="0x58000000"
656         valt_load_address_pri_inner="0x38000000"
657         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
658        ;;
659      # Darwin gets identified as 32-bit even when it supports 64-bit.
660      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
661      # all Macs support both 32-bit and 64-bit, so we just build both.  If
662      # someone has a really old 32-bit only machine they can (hopefully?)
663      # build with --enable-only32bit.  See bug 243362.
664      x86-darwin|amd64-darwin)
665         ARCH_MAX="amd64"
666         valt_load_address_sec_norml="0xUNSET"
667         valt_load_address_sec_inner="0xUNSET"
668         if test x$vg_cv_only64bit = xyes; then
669            VGCONF_ARCH_PRI="amd64"
670            VGCONF_ARCH_SEC=""
671            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
672            VGCONF_PLATFORM_SEC_CAPS=""
673            valt_load_address_pri_norml="0x158000000"
674            valt_load_address_pri_inner="0x138000000"
675         elif test x$vg_cv_only32bit = xyes; then
676            VGCONF_ARCH_PRI="x86"
677            VGCONF_ARCH_SEC=""
678            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
679            VGCONF_PLATFORM_SEC_CAPS=""
680            VGCONF_ARCH_PRI_CAPS="x86"
681            valt_load_address_pri_norml="0x58000000"
682            valt_load_address_pri_inner="0x38000000"
683         else
684            VGCONF_ARCH_PRI="amd64"
685            VGCONF_ARCH_SEC="x86"
686            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
687            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
688            valt_load_address_pri_norml="0x158000000"
689            valt_load_address_pri_inner="0x138000000"
690            valt_load_address_sec_norml="0x58000000"
691            valt_load_address_sec_inner="0x38000000"
692         fi
693         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
694         ;;
695      arm-linux) 
696         VGCONF_ARCH_PRI="arm"
697         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
698         VGCONF_PLATFORM_SEC_CAPS=""
699         valt_load_address_pri_norml="0x58000000"
700         valt_load_address_pri_inner="0x38000000"
701         valt_load_address_sec_norml="0xUNSET"
702         valt_load_address_sec_inner="0xUNSET"
703         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
704         ;;
705      arm64-linux)
706         valt_load_address_sec_norml="0xUNSET"
707         valt_load_address_sec_inner="0xUNSET"
708         if test x$vg_cv_only64bit = xyes; then
709            VGCONF_ARCH_PRI="arm64"
710            VGCONF_ARCH_SEC=""
711            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
712            VGCONF_PLATFORM_SEC_CAPS=""
713            valt_load_address_pri_norml="0x58000000"
714            valt_load_address_pri_inner="0x38000000"
715         elif test x$vg_cv_only32bit = xyes; then
716            VGCONF_ARCH_PRI="arm"
717            VGCONF_ARCH_SEC=""
718            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
719            VGCONF_PLATFORM_SEC_CAPS=""
720            valt_load_address_pri_norml="0x58000000"
721            valt_load_address_pri_inner="0x38000000"
722         else
723            VGCONF_ARCH_PRI="arm64"
724            VGCONF_ARCH_SEC="arm"
725            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
726            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
727            valt_load_address_pri_norml="0x58000000"
728            valt_load_address_pri_inner="0x38000000"
729            valt_load_address_sec_norml="0x58000000"
730            valt_load_address_sec_inner="0x38000000"
731         fi
732         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
733         ;;
734      s390x-linux)
735         VGCONF_ARCH_PRI="s390x"
736         VGCONF_ARCH_SEC=""
737         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
738         VGCONF_PLATFORM_SEC_CAPS=""
739         # To improve branch prediction hit rate we want to have
740         # the generated code close to valgrind (host) code
741         valt_load_address_pri_norml="0x800000000"
742         valt_load_address_pri_inner="0x810000000"
743         valt_load_address_sec_norml="0xUNSET"
744         valt_load_address_sec_inner="0xUNSET"
745         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
746         ;;
747      mips32-linux) 
748         VGCONF_ARCH_PRI="mips32"
749         VGCONF_ARCH_SEC=""
750         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
751         VGCONF_PLATFORM_SEC_CAPS=""
752         valt_load_address_pri_norml="0x58000000"
753         valt_load_address_pri_inner="0x38000000"
754         valt_load_address_sec_norml="0xUNSET"
755         valt_load_address_sec_inner="0xUNSET"
756         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
757         ;;
758      mips64-linux)
759         valt_load_address_sec_norml="0xUNSET"
760         valt_load_address_sec_inner="0xUNSET"
761         if test x$vg_cv_only64bit = xyes; then
762             VGCONF_ARCH_PRI="mips64"
763             VGCONF_PLATFORM_SEC_CAPS=""
764             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
765             VGCONF_PLATFORM_SEC_CAPS=""
766             valt_load_address_pri_norml="0x58000000"
767             valt_load_address_pri_inner="0x38000000"
768         elif test x$vg_cv_only32bit = xyes; then
769             VGCONF_ARCH_PRI="mips32"
770             VGCONF_ARCH_SEC=""
771             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
772             VGCONF_PLATFORM_SEC_CAPS=""
773             valt_load_address_pri_norml="0x58000000"
774             valt_load_address_pri_inner="0x38000000"
775         else
776             VGCONF_ARCH_PRI="mips64"
777             VGCONF_ARCH_SEC="mips32"
778             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
779             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
780             valt_load_address_pri_norml="0x58000000"
781             valt_load_address_pri_inner="0x38000000"
782             valt_load_address_sec_norml="0x58000000"
783             valt_load_address_sec_inner="0x38000000"
784         fi
785         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
786         ;;
787      x86-solaris)
788         VGCONF_ARCH_PRI="x86"
789         VGCONF_ARCH_SEC=""
790         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
791         VGCONF_PLATFORM_SEC_CAPS=""
792         valt_load_address_pri_norml="0x58000000"
793         valt_load_address_pri_inner="0x38000000"
794         valt_load_address_sec_norml="0xUNSET"
795         valt_load_address_sec_inner="0xUNSET"
796         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
797         ;;
798      amd64-solaris)
799         valt_load_address_sec_norml="0xUNSET"
800         valt_load_address_sec_inner="0xUNSET"
801         if test x$vg_cv_only64bit = xyes; then
802            VGCONF_ARCH_PRI="amd64"
803            VGCONF_ARCH_SEC=""
804            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
805            VGCONF_PLATFORM_SEC_CAPS=""
806            valt_load_address_pri_norml="0x58000000"
807            valt_load_address_pri_inner="0x38000000"
808         elif test x$vg_cv_only32bit = xyes; then
809            VGCONF_ARCH_PRI="x86"
810            VGCONF_ARCH_SEC=""
811            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
812            VGCONF_PLATFORM_SEC_CAPS=""
813            valt_load_address_pri_norml="0x58000000"
814            valt_load_address_pri_inner="0x38000000"
815         else
816            VGCONF_ARCH_PRI="amd64"
817            VGCONF_ARCH_SEC="x86"
818            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
819            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
820            valt_load_address_pri_norml="0x58000000"
821            valt_load_address_pri_inner="0x38000000"
822            valt_load_address_sec_norml="0x58000000"
823            valt_load_address_sec_inner="0x38000000"
824         fi
825         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
826         ;;
827     *)
828         VGCONF_ARCH_PRI="unknown"
829         VGCONF_ARCH_SEC="unknown"
830         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
831         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
832         valt_load_address_pri_norml="0xUNSET"
833         valt_load_address_pri_inner="0xUNSET"
834         valt_load_address_sec_norml="0xUNSET"
835         valt_load_address_sec_inner="0xUNSET"
836         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
837         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
838         ;;
839 esac
841 #----------------------------------------------------------------------------
843 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
844 # defined.
845 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
846                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
847                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
848                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
849                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
850                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
851                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
852 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
853                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
854                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
855                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
856 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
857                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
858                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
859 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
860                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
861                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
862 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
863                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
864                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
865 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
866                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
867 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
868                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
869 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
870                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
871                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
872 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
873                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
875 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
876 # become defined.
877 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
878                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
879                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
880 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
881                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
882 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
883                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
884                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
885 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
886                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
887 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
888                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
889 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
890                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
891                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
892 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
893                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
894 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
895                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
896                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
897 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
898                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
899                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
900 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
901                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
902 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,   
903                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
904                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
905 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
906                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
907 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
908                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
909                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
910 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
911                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
914 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
915 # Relies on the assumption that the primary and secondary targets are 
916 # for the same OS, so therefore only necessary to test the primary.
917 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
918                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
919                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
920                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
921                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
922                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
923                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
924                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
925                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
926                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
927                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
928 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
929                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
930                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
931 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
932                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
933                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
936 # Sometimes, in the Makefile.am files, it's useful to know whether or not
937 # there is a secondary target.
938 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
939                test x$VGCONF_PLATFORM_SEC_CAPS != x)
941 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
942 dnl fallback definition
943 dnl The macro is courtesy of Dave Hart:
944 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
945 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
946 if test -z "$$1_TRUE"; then :
947   m4_n([$2])[]dnl
948 m4_ifval([$3],
949 [else
950   $3
951 ])dnl
952 fi[]dnl
953 ])])
955 #----------------------------------------------------------------------------
956 # Inner Valgrind?
957 #----------------------------------------------------------------------------
959 # Check if this should be built as an inner Valgrind, to be run within
960 # another Valgrind.  Choose the load address accordingly.
961 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
962 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
963 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
964    [AC_ARG_ENABLE(inner, 
965       [  --enable-inner          enables self-hosting],
966       [vg_cv_inner=$enableval],
967       [vg_cv_inner=no])])
968 if test "$vg_cv_inner" = yes; then
969     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
970     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
971     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
972 else
973     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
974     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
977 #----------------------------------------------------------------------------
978 # Undefined behaviour sanitiser
979 #----------------------------------------------------------------------------
980 # Check whether we should build with the undefined beahviour sanitiser.
982 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
983    [AC_ARG_ENABLE(ubsan, 
984       [  --enable-ubsan          enables the undefined behaviour sanitiser],
985       [vg_cv_ubsan=$enableval],
986       [vg_cv_ubsan=no])])
988 #----------------------------------------------------------------------------
989 # Extra fine-tuning of installation directories
990 #----------------------------------------------------------------------------
991 AC_ARG_WITH(tmpdir,
992    [  --with-tmpdir=PATH      Specify path for temporary files],
993    tmpdir="$withval",
994    tmpdir="/tmp")
995 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
996 AC_SUBST(VG_TMPDIR, [$tmpdir])
999 #----------------------------------------------------------------------------
1000 # Libc and suppressions
1001 #----------------------------------------------------------------------------
1002 # This variable will collect the suppression files to be used.
1003 AC_SUBST(DEFAULT_SUPP)
1005 AC_CHECK_HEADER([features.h])
1007 if test x$ac_cv_header_features_h = xyes; then
1008   rm -f conftest.$ac_ext
1009   cat <<_ACEOF >conftest.$ac_ext
1010 #include <features.h>
1011 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1012 glibc version is: __GLIBC__ __GLIBC_MINOR__
1013 #endif
1014 _ACEOF
1015   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1018 # not really a version check
1019 AC_EGREP_CPP([DARWIN_LIBC], [
1020 #include <sys/cdefs.h>
1021 #if defined(__DARWIN_VERS_1050)
1022   DARWIN_LIBC
1023 #endif
1025 GLIBC_VERSION="darwin")
1027 # not really a version check
1028 AC_EGREP_CPP([BIONIC_LIBC], [
1029 #if defined(__ANDROID__)
1030   BIONIC_LIBC
1031 #endif
1033 GLIBC_VERSION="bionic")
1035 # there is only one version of libc on Solaris
1036 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1037      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1038     GLIBC_VERSION="solaris"
1041 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1042 # in this case.
1043 if test x$GLIBC_VERSION = x; then
1044     if $CC -dumpmachine | grep -q musl; then
1045         GLIBC_VERSION=musl
1046     fi
1049 AC_MSG_CHECKING([the glibc version])
1051 case "${GLIBC_VERSION}" in
1052      2.2)
1053         AC_MSG_RESULT(${GLIBC_VERSION} family)
1054         DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1055         DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1056         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1057         ;;
1058      2.[[3-6]])
1059         AC_MSG_RESULT(${GLIBC_VERSION} family)
1060         DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1061         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1062         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1063         ;;
1064      2.[[7-9]])
1065         AC_MSG_RESULT(${GLIBC_VERSION} family)
1066         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1067         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1068         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1069         ;;
1070      2.10|2.11)
1071         AC_MSG_RESULT(${GLIBC_VERSION} family)
1072         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1073                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1074         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1075         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1076         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1077         ;;
1078      2.*)
1079         AC_MSG_RESULT(${GLIBC_VERSION} family)
1080         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1081                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1082         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1083                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1084         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1085         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1086         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1087         ;;
1088      darwin)
1089         AC_MSG_RESULT(Darwin)
1090         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1091         # DEFAULT_SUPP set by kernel version check above.
1092         ;;
1093      bionic)
1094         AC_MSG_RESULT(Bionic)
1095         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1096         DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1097         ;;
1098      solaris)
1099         AC_MSG_RESULT(Solaris)
1100         # DEFAULT_SUPP set in host_os switch-case above.
1101         # No other suppression file is used.
1102         ;;
1103      musl)
1104         AC_MSG_RESULT(Musl)
1105         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1106         # no DEFAULT_SUPP file yet for musl libc.
1107         ;;
1108      2.0|2.1|*)
1109         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1110         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1111         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1112         ;;
1113 esac
1115 AC_SUBST(GLIBC_VERSION)
1118 if test "$VGCONF_OS" != "solaris"; then
1119     # Add default suppressions for the X client libraries.  Make no
1120     # attempt to detect whether such libraries are installed on the
1121     # build machine (or even if any X facilities are present); just
1122     # add the suppressions antidisirregardless.
1123     DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1124     DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1126     # Add glibc and X11 suppressions for exp-sgcheck
1127     DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
1131 #----------------------------------------------------------------------------
1132 # Platform variants?
1133 #----------------------------------------------------------------------------
1135 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1136 # But there are times where we need a bit more control.  The motivating
1137 # and currently only case is Android: this is almost identical to
1138 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1139 # platform variant tags, which get passed in the compile as
1140 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1142 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1143 # it is "android" instead.
1145 # Consequently (eg), plain arm-linux would build with
1147 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1149 # whilst an Android build would have
1151 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1153 # Same for x86. The setup of the platform variant is pushed relatively far
1154 # down this file in order that we can inspect any of the variables set above.
1156 # In the normal case ..
1157 VGCONF_PLATVARIANT="vanilla"
1159 # Android ?
1160 if test "$GLIBC_VERSION" = "bionic";
1161 then
1162    VGCONF_PLATVARIANT="android"
1165 AC_SUBST(VGCONF_PLATVARIANT)
1168 # FIXME: do we also want to define automake variables
1169 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1170 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1171 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1172 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1173 # that's what we'd need to do to use this, since what we'd want to write
1174 # is something like
1176 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1178 # Hmm.  Can't think of a nice clean solution to this.
1180 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1181                test x$VGCONF_PLATVARIANT = xvanilla)
1182 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1183                test x$VGCONF_PLATVARIANT = xandroid)
1186 #----------------------------------------------------------------------------
1187 # Checking for various library functions and other definitions
1188 #----------------------------------------------------------------------------
1190 # Check for AT_FDCWD
1192 AC_MSG_CHECKING([for AT_FDCWD])
1193 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1194 #define _GNU_SOURCE
1195 #include <fcntl.h>
1196 #include <unistd.h>
1197 ]], [[
1198   int a = AT_FDCWD;
1199 ]])], [
1200 ac_have_at_fdcwd=yes
1201 AC_MSG_RESULT([yes])
1202 ], [
1203 ac_have_at_fdcwd=no
1204 AC_MSG_RESULT([no])
1207 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1209 # Check for stpncpy function definition in string.h
1210 # This explicitly checks with _GNU_SOURCE defined since that is also
1211 # used in the test case (some systems might define it without anyway
1212 # since stpncpy is part of The Open Group Base Specifications Issue 7
1213 # IEEE Std 1003.1-2008.
1214 AC_MSG_CHECKING([for stpncpy])
1215 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1216 #define _GNU_SOURCE
1217 #include <string.h>
1218 ]], [[
1219   char *d;
1220   char *s;
1221   size_t n = 0;
1222   char *r = stpncpy(d, s, n);
1223 ]])], [
1224 ac_have_gnu_stpncpy=yes
1225 AC_MSG_RESULT([yes])
1226 ], [
1227 ac_have_gnu_stpncpy=no
1228 AC_MSG_RESULT([no])
1231 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1233 # Check for PTRACE_GETREGS
1235 AC_MSG_CHECKING([for PTRACE_GETREGS])
1236 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1237 #include <stdlib.h>
1238 #include <stddef.h>
1239 #include <sys/ptrace.h>
1240 #include <sys/user.h>
1241 ]], [[
1242   void *p;
1243   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1244 ]])], [
1245 AC_MSG_RESULT([yes])
1246 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1247           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1248 ], [
1249 AC_MSG_RESULT([no])
1253 # Check for CLOCK_MONOTONIC
1255 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1257 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1258 #include <time.h>
1259 ]], [[
1260   struct timespec t;
1261   clock_gettime(CLOCK_MONOTONIC, &t);
1262   return 0;
1263 ]])], [
1264 AC_MSG_RESULT([yes])
1265 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1266           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1267 ], [
1268 AC_MSG_RESULT([no])
1272 # Check for ELF32/64_CHDR
1274 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1277 # Check for PTHREAD_RWLOCK_T
1279 AC_MSG_CHECKING([for pthread_rwlock_t])
1281 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1282 #define _GNU_SOURCE
1283 #include <pthread.h>
1284 ]], [[
1285   pthread_rwlock_t rwl;
1286 ]])], [
1287 AC_MSG_RESULT([yes])
1288 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1289           [Define to 1 if you have the `pthread_rwlock_t' type.])
1290 ], [
1291 AC_MSG_RESULT([no])
1295 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1297 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1299 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1300 #define _GNU_SOURCE
1301 #include <pthread.h>
1302 ]], [[
1303   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1304 ]])], [
1305 AC_MSG_RESULT([yes])
1306 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1307           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1308 ], [
1309 AC_MSG_RESULT([no])
1313 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1315 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1317 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1318 #define _GNU_SOURCE
1319 #include <pthread.h>
1320 ]], [[
1321   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1322 ]])], [
1323 AC_MSG_RESULT([yes])
1324 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1325           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1326 ], [
1327 AC_MSG_RESULT([no])
1331 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1333 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1335 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1336 #define _GNU_SOURCE
1337 #include <pthread.h>
1338 ]], [[
1339   return (PTHREAD_MUTEX_RECURSIVE_NP);
1340 ]])], [
1341 AC_MSG_RESULT([yes])
1342 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1343           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1344 ], [
1345 AC_MSG_RESULT([no])
1349 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1351 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1354 #define _GNU_SOURCE
1355 #include <pthread.h>
1356 ]], [[
1357   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1358   return 0;
1359 ]])], [
1360 AC_MSG_RESULT([yes])
1361 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1362           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1363 ], [
1364 AC_MSG_RESULT([no])
1368 # Check whether pthread_mutex_t has a member called __m_kind.
1370 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1371                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1372                            1,                                   
1373                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1374                 ],
1375                 [],
1376                 [#include <pthread.h>])
1379 # Check whether pthread_mutex_t has a member called __data.__kind.
1381 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1382                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1383                           1,
1384                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1385                 ],
1386                 [],
1387                 [#include <pthread.h>])
1389 # Convenience function.  Set flags based on the existing HWCAP entries.
1390 # The AT_HWCAP entries are generated by glibc, and are based on
1391 # functions supported by the hardware/system/libc.
1392 # Subsequent support for whether the capability will actually be utilized
1393 # will also be checked against the compiler capabilities.
1394 # called as
1395 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1396 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1397   AUXV_CHECK_FOR=$1
1398   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1399   if LD_SHOW_AUXV=1 `which true` | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1400   then
1401     AC_MSG_RESULT([yes])
1402     AC_SUBST([$2],[yes])
1403   else
1404     AC_MSG_RESULT([no])
1405     AC_SUBST([$2],[])
1406   fi
1409 # gather hardware capabilities. (hardware/kernel/libc)
1410 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1411 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1412 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1413 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1414 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1415 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1416 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1417 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1419 # ISA Levels
1420 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1421 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1422 # compiler support for isa 2.07 level instructions
1423 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1424 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1425 ]], [[
1426   __asm__ __volatile__("mtvsrd 1,2 ");
1427 ]])], [
1428 ac_asm_have_isa_2_07=yes
1429 AC_MSG_RESULT([yes])
1430 ], [
1431 ac_asm_have_isa_2_07=no
1432 AC_MSG_RESULT([no])
1434 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1435                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1437 # altivec (vsx) support.
1438 # does this compiler support -maltivec and does it have the include file
1439 # <altivec.h> ?
1440 AC_MSG_CHECKING([for Altivec support in the compiler ])
1441 safe_CFLAGS=$CFLAGS
1442 CFLAGS="-maltivec -Werror"
1443 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1444 #include <altivec.h>
1445 ]], [[
1446   vector unsigned int v;
1447 ]])], [
1448 ac_have_altivec=yes
1449 AC_MSG_RESULT([yes])
1450 ], [
1451 ac_have_altivec=no
1452 AC_MSG_RESULT([no])
1454 CFLAGS=$safe_CFLAGS
1455 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1456                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1458 # Check that both: the compiler supports -mvsx and that the assembler
1459 # understands VSX instructions.  If either of those doesn't work,
1460 # conclude that we can't do VSX.
1461 AC_MSG_CHECKING([for VSX compiler flag support])
1462 safe_CFLAGS=$CFLAGS
1463 CFLAGS="-mvsx -Werror"
1464 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1465 ]], [[
1466 ]])], [
1467 ac_compiler_supports_vsx_flag=yes
1468 AC_MSG_RESULT([yes])
1469 ], [
1470 ac_compiler_supports_vsx_flag=no
1471 AC_MSG_RESULT([no])
1473 CFLAGS=$safe_CFLAGS
1475 AC_MSG_CHECKING([for VSX support in the assembler ])
1476 safe_CFLAGS=$CFLAGS
1477 CFLAGS="-mvsx -Werror"
1478 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1479 #include <altivec.h>
1480 ]], [[
1481   vector unsigned int v;
1482   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1483 ]])], [
1484 ac_compiler_supports_vsx=yes
1485 AC_MSG_RESULT([yes])
1486 ], [
1487 ac_compiler_supports_vsx=no
1488 AC_MSG_RESULT([no])
1490 CFLAGS=$safe_CFLAGS
1491 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1492                              -a x$ac_compiler_supports_vsx = xyes \
1493                              -a x$HWCAP_HAS_VSX = xyes ])
1495 # DFP (Decimal Float)
1496 AC_MSG_CHECKING([that assembler knows DFP])
1497 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1498 ]], [[
1499   #ifdef __s390__
1500   __asm__ __volatile__("adtr 1, 2, 3")
1501   #else
1502   __asm__ __volatile__("dadd 1, 2, 3");
1503   __asm__ __volatile__("dcffix 1, 2");
1504   #endif
1505 ]])], [
1506 ac_asm_have_dfp=yes
1507 AC_MSG_RESULT([yes])
1508 ], [
1509 ac_asm_have_dfp=no
1510 AC_MSG_RESULT([no])
1512 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1513 safe_CFLAGS=$CFLAGS
1514 CFLAGS="-mhard-dfp -Werror"
1515 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1516 ]], [[
1517   #ifdef __s390__
1518   __asm__ __volatile__("adtr 1, 2, 3")
1519   #else
1520   __asm__ __volatile__("dadd 1, 2, 3");
1521   __asm__ __volatile__("dcffix 1, 2");
1522   #endif
1523 ]])], [
1524 ac_compiler_have_dfp=yes
1525 AC_MSG_RESULT([yes])
1526 ], [
1527 ac_compiler_have_dfp=no
1528 AC_MSG_RESULT([no])
1530 CFLAGS=$safe_CFLAGS
1531 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1532                           -a x$ac_compiler_have_dfp = xyes \
1533                           -a x$HWCAP_HAS_DFP = xyes )
1535 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1536 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1537 ]], [[
1538   _Decimal64 x = 0.0DD;
1539 ]])], [
1540 ac_compiler_have_dfp_type=yes
1541 AC_MSG_RESULT([yes])
1542 ], [
1543 ac_compiler_have_dfp_type=no
1544 AC_MSG_RESULT([no])
1546 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1547                                   -a x$HWCAP_HAS_DFP = xyes )
1550 # HTM (Hardware Transactional Memory)
1551 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1552 safe_CFLAGS=$CFLAGS
1553 CFLAGS="-mhtm -Werror"
1554 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1555 ]], [[
1556   return 0;
1557 ]])], [
1558 AC_MSG_RESULT([yes])
1559 ac_compiler_supports_htm=yes
1560 ], [
1561 AC_MSG_RESULT([no])
1562 ac_compiler_supports_htm=no
1564 CFLAGS=$safe_CFLAGS
1566 AC_MSG_CHECKING([if compiler can find the htm builtins])
1567 safe_CFLAGS=$CFLAGS
1568 CFLAGS="-mhtm -Werror"
1569  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1570  ]], [[
1571    if (__builtin_tbegin (0))
1572       __builtin_tend (0);
1573  ]])], [
1574  AC_MSG_RESULT([yes])
1575 ac_compiler_sees_htm_builtins=yes
1576  ], [
1577  AC_MSG_RESULT([no])
1578 ac_compiler_sees_htm_builtins=no
1579  ])
1580 CFLAGS=$safe_CFLAGS
1582 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1583                                -a x$ac_compiler_sees_htm_builtins = xyes \
1584                                -a x$HWCAP_HAS_HTM = xyes )
1586 # isa 3.0 checking
1587 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1589 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1590 ]], [[
1591   __asm__ __volatile__("cnttzw 1,2 ");
1592 ]])], [
1593 ac_asm_have_isa_3_00=yes
1594 AC_MSG_RESULT([yes])
1595 ], [
1596 ac_asm_have_isa_3_00=no
1597 AC_MSG_RESULT([no])
1600 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1601                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1603 # Check for pthread_create@GLIBC2.0
1604 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1606 safe_CFLAGS=$CFLAGS
1607 CFLAGS="-lpthread -Werror"
1608 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1609 extern int pthread_create_glibc_2_0(void*, const void*,
1610                                     void *(*)(void*), void*);
1611 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1612 ]], [[
1613 #ifdef __powerpc__
1615  * Apparently on PowerPC linking this program succeeds and generates an
1616  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1617  */
1618 #error This test does not work properly on PowerPC.
1619 #else
1620   pthread_create_glibc_2_0(0, 0, 0, 0);
1621 #endif
1622   return 0;
1623 ]])], [
1624 ac_have_pthread_create_glibc_2_0=yes
1625 AC_MSG_RESULT([yes])
1626 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1627           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1628 ], [
1629 ac_have_pthread_create_glibc_2_0=no
1630 AC_MSG_RESULT([no])
1632 CFLAGS=$safe_CFLAGS
1634 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1635                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1638 # Check for dlinfo RTLD_DI_TLS_MODID
1639 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1641 safe_LIBS="$LIBS"
1642 LIBS="-ldl"
1643 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1644 #ifndef _GNU_SOURCE
1645 #define _GNU_SOURCE
1646 #endif
1647 #include <link.h>
1648 #include <dlfcn.h>
1649 ]], [[
1650   size_t sizes[10000];
1651   size_t modid_offset;
1652   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1653   return 0;
1654 ]])], [
1655 ac_have_dlinfo_rtld_di_tls_modid=yes
1656 AC_MSG_RESULT([yes])
1657 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1658           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1659 ], [
1660 ac_have_dlinfo_rtld_di_tls_modid=no
1661 AC_MSG_RESULT([no])
1663 LIBS=$safe_LIBS
1665 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1666                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1669 # Check for eventfd_t, eventfd() and eventfd_read()
1670 AC_MSG_CHECKING([for eventfd()])
1672 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1673 #include <sys/eventfd.h>
1674 ]], [[
1675   eventfd_t ev;
1676   int fd;
1678   fd = eventfd(5, 0);
1679   eventfd_read(fd, &ev);
1680   return 0;
1681 ]])], [
1682 AC_MSG_RESULT([yes])
1683 AC_DEFINE([HAVE_EVENTFD], 1,
1684           [Define to 1 if you have the `eventfd' function.])
1685 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1686           [Define to 1 if you have the `eventfd_read' function.])
1687 ], [
1688 AC_MSG_RESULT([no])
1691 # Check whether compiler can process #include <thread> without errors
1692 # clang 3.3 cannot process <thread> from e.g.
1693 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1695 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1696 AC_LANG(C++)
1697 safe_CXXFLAGS=$CXXFLAGS
1698 CXXFLAGS=-std=c++0x
1700 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1701 #include <thread> 
1702 ])],
1704 ac_cxx_can_include_thread_header=yes
1705 AC_MSG_RESULT([yes])
1706 ], [
1707 ac_cxx_can_include_thread_header=no
1708 AC_MSG_RESULT([no])
1710 CXXFLAGS=$safe_CXXFLAGS
1711 AC_LANG(C)
1713 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1716 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1717 # of the user_regs_struct from sys/user.h. They are structurally the same
1718 # but we get either one or the other.
1720 AC_CHECK_TYPE([struct user_regs_struct],
1721               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1722               [[#include <sys/ptrace.h>]
1723                [#include <sys/time.h>]
1724                [#include <sys/user.h>]])
1725 if test "$sys_user_has_user_regs" = "yes"; then
1726   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1727             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1730 AC_MSG_CHECKING([for __NR_membarrier])
1731 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1732 #include <linux/unistd.h>
1733 ]], [[
1734 return __NR_membarrier
1735 ]])], [
1736 ac_have_nr_membarrier=yes
1737 AC_MSG_RESULT([yes])
1738 ], [
1739 ac_have_nr_membarrier=no
1740 AC_MSG_RESULT([no])
1743 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
1745 #----------------------------------------------------------------------------
1746 # Checking for supported compiler flags.
1747 #----------------------------------------------------------------------------
1749 case "${host_cpu}" in
1750     mips*)
1751         # does this compiler support -march=mips32 (mips32 default) ?
1752         AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
1754         safe_CFLAGS=$CFLAGS
1755         CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
1757         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1758           return 0;
1759         ]])], [
1760         FLAG_M32="-mips32 -mabi=32"
1761         AC_MSG_RESULT([yes])
1762         ], [
1763         FLAG_M32=""
1764         AC_MSG_RESULT([no])
1765         ])
1766         CFLAGS=$safe_CFLAGS
1768         AC_SUBST(FLAG_M32)
1771         # does this compiler support -march=mips64r2 (mips64r2 default) ?
1772         AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
1774         safe_CFLAGS=$CFLAGS
1775         CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
1777         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1778           return 0;
1779         ]])], [
1780         FLAG_M64="-march=mips64r2 -mabi=64"
1781         AC_MSG_RESULT([yes])
1782         ], [
1783         FLAG_M64=""
1784         AC_MSG_RESULT([no])
1785         ])
1786         CFLAGS=$safe_CFLAGS
1788         AC_SUBST(FLAG_M64)
1789         ;;
1790     *)
1791         # does this compiler support -m32 ?
1792         AC_MSG_CHECKING([if gcc accepts -m32])
1794         safe_CFLAGS=$CFLAGS
1795         CFLAGS="-m32 -Werror"
1797         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1798           return 0;
1799         ]])], [
1800         FLAG_M32="-m32"
1801         AC_MSG_RESULT([yes])
1802         ], [
1803         FLAG_M32=""
1804         AC_MSG_RESULT([no])
1805         ])
1806         CFLAGS=$safe_CFLAGS
1808         AC_SUBST(FLAG_M32)
1811         # does this compiler support -m64 ?
1812         AC_MSG_CHECKING([if gcc accepts -m64])
1814         safe_CFLAGS=$CFLAGS
1815         CFLAGS="-m64 -Werror"
1817         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1818           return 0;
1819         ]])], [
1820         FLAG_M64="-m64"
1821         AC_MSG_RESULT([yes])
1822         ], [
1823         FLAG_M64=""
1824         AC_MSG_RESULT([no])
1825         ])
1826         CFLAGS=$safe_CFLAGS
1828         AC_SUBST(FLAG_M64)
1829         ;;
1830 esac
1832 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1833 AC_MSG_CHECKING([if gcc accepts -march=octeon])
1835 safe_CFLAGS=$CFLAGS
1836 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
1838 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1839   return 0;
1840 ]])], [
1841 FLAG_OCTEON="-march=octeon"
1842 AC_MSG_RESULT([yes])
1843 ], [
1844 FLAG_OCTEON=""
1845 AC_MSG_RESULT([no])
1847 CFLAGS=$safe_CFLAGS
1849 AC_SUBST(FLAG_OCTEON)
1852 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1853 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1855 safe_CFLAGS=$CFLAGS
1856 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
1858 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1859   return 0;
1860 ]])], [
1861 FLAG_OCTEON2="-march=octeon2"
1862 AC_MSG_RESULT([yes])
1863 ], [
1864 FLAG_OCTEON2=""
1865 AC_MSG_RESULT([no])
1867 CFLAGS=$safe_CFLAGS
1869 AC_SUBST(FLAG_OCTEON2)
1872 # does this compiler support -mmsa (MIPS MSA ASE) ?
1873 AC_MSG_CHECKING([if gcc accepts -mmsa])
1875 safe_CFLAGS=$CFLAGS
1876 CFLAGS="$CFLAGS -mmsa -Werror"
1878 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1879     return 0;
1880 ]])], [
1881 FLAG_MSA="-mmsa"
1882 AC_MSG_RESULT([yes])
1883 ], [
1884 FLAG_MSA=""
1885 AC_MSG_RESULT([no])
1887 CFLAGS=$safe_CFLAGS
1889 AC_SUBST(FLAG_MSA)
1891 # Are we compiling for the MIPS64 n32 ABI?
1892 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
1893 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1894 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
1895 #error NO
1896 #endif
1897 ]])], [
1898 VGCONF_ABI=N32
1899 FLAG_M64="-march=mips64r2 -mabi=n32"
1900 AC_MSG_RESULT([yes])
1901 ], [
1902 AC_MSG_RESULT([no])
1905 # Are we compiling for the MIPS64 n64 ABI?
1906 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
1907 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1908 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
1909 #error NO
1910 #endif
1911 ]])], [
1912 VGCONF_ABI=64
1913 AC_MSG_RESULT([yes])
1914 ], [
1915 AC_MSG_RESULT([no])
1918 AM_CONDITIONAL([VGCONF_HAVE_ABI],
1919                [test x$VGCONF_ABI != x])
1920 AC_SUBST(VGCONF_ABI)
1923 # does this compiler support -mmmx ?
1924 AC_MSG_CHECKING([if gcc accepts -mmmx])
1926 safe_CFLAGS=$CFLAGS
1927 CFLAGS="-mmmx -Werror"
1929 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1930   return 0;
1931 ]])], [
1932 FLAG_MMMX="-mmmx"
1933 AC_MSG_RESULT([yes])
1934 ], [
1935 FLAG_MMMX=""
1936 AC_MSG_RESULT([no])
1938 CFLAGS=$safe_CFLAGS
1940 AC_SUBST(FLAG_MMMX)
1943 # does this compiler support -msse ?
1944 AC_MSG_CHECKING([if gcc accepts -msse])
1946 safe_CFLAGS=$CFLAGS
1947 CFLAGS="-msse -Werror"
1949 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1950   return 0;
1951 ]])], [
1952 FLAG_MSSE="-msse"
1953 AC_MSG_RESULT([yes])
1954 ], [
1955 FLAG_MSSE=""
1956 AC_MSG_RESULT([no])
1958 CFLAGS=$safe_CFLAGS
1960 AC_SUBST(FLAG_MSSE)
1963 # does this compiler support -mpreferred-stack-boundary=2 when
1964 # generating code for a 32-bit target?  Note that we only care about
1965 # this when generating code for (32-bit) x86, so if the compiler
1966 # doesn't recognise -m32 it's no big deal.  We'll just get code for
1967 # the Memcheck and other helper functions, that is a bit slower than
1968 # it could be, on x86; and no difference at all on any other platform.
1969 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
1971 safe_CFLAGS=$CFLAGS
1972 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
1974 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1975   return 0;
1976 ]])], [
1977 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
1978 AC_MSG_RESULT([yes])
1979 ], [
1980 PREFERRED_STACK_BOUNDARY_2=""
1981 AC_MSG_RESULT([no])
1983 CFLAGS=$safe_CFLAGS
1985 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
1988 # does this compiler support -mlong-double-128 ?
1989 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
1990 safe_CFLAGS=$CFLAGS
1991 CFLAGS="-mlong-double-128 -Werror"
1992 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1993   return 0;
1994 ]])], [
1995 ac_compiler_supports_mlong_double_128=yes
1996 AC_MSG_RESULT([yes])
1997 ], [
1998 ac_compiler_supports_mlong_double_128=no
1999 AC_MSG_RESULT([no])
2001 CFLAGS=$safe_CFLAGS
2002 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2003 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2004 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2006 # does this toolchain support lto ?
2007 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2008 # are not defined
2009 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2010 # a lot slower, and so not appropriate for Valgrind developments.
2011 # --enable-lto=yes should be used by distro packagers.
2012 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2013    [AC_ARG_ENABLE(lto,
2014       [  --enable-lto          enables building with link time optimisation],
2015       [vg_cv_lto=$enableval],
2016       [vg_cv_lto=no])])
2018 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2019 AC_MSG_CHECKING([if toolchain accepts lto])
2020 safe_CFLAGS=$CFLAGS
2021 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2022 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2023 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2024 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2026 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2027   extern void somefun(void);
2028   somefun();
2029   return 0;
2030 ]])], [
2031 LTO_CFLAGS=$TEST_LTO_CFLAGS
2032 AC_MSG_RESULT([yes])
2033 ], [
2034 LTO_CFLAGS=""
2035 AC_MSG_RESULT([no])
2037 CFLAGS=$safe_CFLAGS
2040 AC_SUBST(LTO_CFLAGS)
2042 # if we could not compile with lto args, or lto was disabled,
2043 # then set LTO_AR/LTO_RANLIB to the non lto values
2044 # define in config.h ENABLE_LTO (not needed by the code currently, but
2045 # this guarantees we recompile everything if we re-configure and rebuild
2046 # in a build dir previously build with another value of --enable-lto
2047 if test "x${LTO_CFLAGS}" = "x"; then
2048    LTO_AR=${AR}
2049    LTO_RANLIB=${RANLIB}
2050    vg_cv_lto=no
2051 else
2052    vg_cv_lto=yes
2053    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2056 # Convenience function to check whether GCC supports a particular
2057 # warning option. Takes two arguments,
2058 # first the warning flag name to check (without -W), then the
2059 # substitution name to set with -Wno-warning-flag if the flag exists,
2060 # or the empty string if the compiler doesn't accept the flag. Note
2061 # that checking is done against the warning flag itself, but the
2062 # substitution is then done to cancel the warning flag.
2063 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2064   AC_MSG_CHECKING([if gcc accepts -W$1])
2065   safe_CFLAGS=$CFLAGS
2066   CFLAGS="-W$1 -Werror"
2067   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2068   AC_SUBST([$2], [-Wno-$1])
2069   AC_MSG_RESULT([yes])], [
2070   AC_SUBST([$2], [])
2071   AC_MSG_RESULT([no])])
2072   CFLAGS=$safe_CFLAGS
2075 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2076 # -W$1  (instead of -Wno-$1).
2077 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2078   AC_MSG_CHECKING([if gcc accepts -W$1])
2079   safe_CFLAGS=$CFLAGS
2080   CFLAGS="-W$1 -Werror"
2081   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2082   AC_SUBST([$2], [-W$1])
2083   AC_MSG_RESULT([yes])], [
2084   AC_SUBST([$2], [])
2085   AC_MSG_RESULT([no])])
2086   CFLAGS=$safe_CFLAGS
2089 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2090 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2091 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2092 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2093 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2094 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2095 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2096 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2097 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2099 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2100 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2101 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2102 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2103 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2104 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2105 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2106 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2107 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2108 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2110 # Does this compiler support -Wformat-security ?
2111 # Special handling is needed, because certain GCC versions require -Wformat
2112 # being present if -Wformat-security is given. Otherwise a warning is issued.
2113 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2114 # And with that the warning will be turned into an error with the result
2115 # that -Wformat-security is believed to be unsupported when in fact it is.
2116 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2117 safe_CFLAGS=$CFLAGS
2118 CFLAGS="-Wformat -Wformat-security -Werror"
2119 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2120 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2121 AC_MSG_RESULT([yes])], [
2122 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2123 AC_MSG_RESULT([no])])
2124 CFLAGS=$safe_CFLAGS
2126 # does this compiler support -Wextra or the older -W ?
2128 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2130 safe_CFLAGS=$CFLAGS
2131 CFLAGS="-Wextra -Werror"
2133 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2134   return 0;
2135 ]])], [
2136 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2137 AC_MSG_RESULT([-Wextra])
2138 ], [
2139   CFLAGS="-W -Werror"
2140   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2141     return 0;
2142   ]])], [
2143   AC_SUBST([FLAG_W_EXTRA], [-W])
2144   AC_MSG_RESULT([-W])
2145   ], [
2146   AC_SUBST([FLAG_W_EXTRA], [])
2147   AC_MSG_RESULT([not supported])
2148   ])
2150 CFLAGS=$safe_CFLAGS
2152 # On ARM we do not want to pass -Wcast-align as that produces loads
2153 # of warnings. GCC is just being conservative. See here:
2154 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2155 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2156   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2157 else
2158   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2161 # does this compiler support -faligned-new ?
2162 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2164 safe_CXXFLAGS=$CXXFLAGS
2165 CXXFLAGS="-faligned-new -Werror"
2167 AC_LANG(C++)
2168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2169   return 0;
2170 ]])], [
2171 FLAG_FALIGNED_NEW="-faligned-new"
2172 AC_MSG_RESULT([yes])
2173 ], [
2174 FLAG_FALIGNED_NEW=""
2175 AC_MSG_RESULT([no])
2177 CXXFLAGS=$safe_CXXFLAGS
2178 AC_LANG(C)
2180 AC_SUBST(FLAG_FALIGNED_NEW)
2182 # does this compiler support -fno-stack-protector ?
2183 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2185 safe_CFLAGS=$CFLAGS
2186 CFLAGS="-fno-stack-protector -Werror"
2188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2189   return 0;
2190 ]])], [
2191 no_stack_protector=yes
2192 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2193 AC_MSG_RESULT([yes])
2194 ], [
2195 no_stack_protector=no
2196 FLAG_FNO_STACK_PROTECTOR=""
2197 AC_MSG_RESULT([no])
2199 CFLAGS=$safe_CFLAGS
2201 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2203 # Does GCC support disabling Identical Code Folding?
2204 # We want to disabled Identical Code Folding for the
2205 # tools preload shared objects to get better backraces.
2206 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2207 # "The optimization reduces code size and may disturb
2208 #  unwind stacks by replacing a function by equivalent
2209 #  one with a different name."
2210 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2212 safe_CFLAGS=$CFLAGS
2213 CFLAGS="-fno-ipa-icf -Werror"
2215 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2216   return 0;
2217 ]])], [
2218 no_ipa_icf=yes
2219 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2220 AC_MSG_RESULT([yes])
2221 ], [
2222 no_ipa_icf=no
2223 FLAG_FNO_IPA_ICF=""
2224 AC_MSG_RESULT([no])
2226 CFLAGS=$safe_CFLAGS
2228 AC_SUBST(FLAG_FNO_IPA_ICF)
2231 # Does this compiler support -fsanitize=undefined. This is true for
2232 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2233 # also checks for alignment violations on memory accesses which the valgrind
2234 # code base is sprinkled (if not littered) with. As those alignment issues
2235 # don't pose a problem we want to suppress warnings about them.
2236 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2237 # GCCs do not support that.
2239 # Only checked for if --enable-ubsan was given.
2240 if test "x${vg_cv_ubsan}" = "xyes"; then
2241 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2242 safe_CFLAGS=$CFLAGS
2243 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2244 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2245   return 0;
2246 ]])], [
2247 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2248 LIB_UBSAN="-static-libubsan"
2249 AC_MSG_RESULT([yes])
2250 ], [
2251 CFLAGS="-fsanitize=undefined -Werror"
2252 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2253   return 0;
2254 ]])], [
2255 FLAG_FSANITIZE="-fsanitize=undefined"
2256 LIB_UBSAN="-static-libubsan"
2257 AC_MSG_RESULT([yes])
2258 ], [
2259 FLAG_FSANITIZE=""
2260 LIB_UBSAN=""
2261 AC_MSG_RESULT([no])
2264 CFLAGS=$safe_CFLAGS
2265 AC_SUBST(FLAG_FSANITIZE)
2266 AC_SUBST(LIB_UBSAN)
2268 # does this compiler support --param inline-unit-growth=... ?
2270 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2272 safe_CFLAGS=$CFLAGS
2273 CFLAGS="--param inline-unit-growth=900 -Werror"
2275 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2276   return 0;
2277 ]])], [
2278 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2279          ["--param inline-unit-growth=900"])
2280 AC_MSG_RESULT([yes])
2281 ], [
2282 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2283 AC_MSG_RESULT([no])
2285 CFLAGS=$safe_CFLAGS
2288 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2290 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2292 safe_CFLAGS=$CFLAGS
2293 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2295 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2296   return 0;
2297 ]])], [
2298 ac_have_dwarf4=yes
2299 AC_MSG_RESULT([yes])
2300 ], [
2301 ac_have_dwarf4=no
2302 AC_MSG_RESULT([no])
2304 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2305 CFLAGS=$safe_CFLAGS
2308 # does this compiler support -g -gz=zlib ?
2310 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2312 safe_CFLAGS=$CFLAGS
2313 CFLAGS="-g -gz=zlib"
2315 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2316   return 0;
2317 ]])], [
2318 ac_have_gz_zlib=yes
2319 AC_MSG_RESULT([yes])
2320 ], [
2321 ac_have_gz_zlib=no
2322 AC_MSG_RESULT([no])
2324 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2325 CFLAGS=$safe_CFLAGS
2328 # does this compiler support -g -gz=zlib-gnu ?
2330 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2332 safe_CFLAGS=$CFLAGS
2333 CFLAGS="-g -gz=zlib-gnu"
2335 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2336   return 0;
2337 ]])], [
2338 ac_have_gz_zlib_gnu=yes
2339 AC_MSG_RESULT([yes])
2340 ], [
2341 ac_have_gz_zlib_gnu=no
2342 AC_MSG_RESULT([no])
2344 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2345 CFLAGS=$safe_CFLAGS
2348 # does this compiler support nested functions ?
2350 AC_MSG_CHECKING([if gcc accepts nested functions])
2352 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2353   int foo() { return 1; }
2354   return foo();
2355 ]])], [
2356 ac_have_nested_functions=yes
2357 AC_MSG_RESULT([yes])
2358 ], [
2359 ac_have_nested_functions=no
2360 AC_MSG_RESULT([no])
2362 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2365 # does this compiler support the 'p' constraint in ASM statements ?
2367 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2369 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2370    char *p;
2371    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2372 ]])], [
2373 ac_have_asm_constraint_p=yes
2374 AC_MSG_RESULT([yes])
2375 ], [
2376 ac_have_asm_constraint_p=no
2377 AC_MSG_RESULT([no])
2379 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2382 # Does this compiler and linker support -pie?
2383 # Some compilers actually do not support -pie and report its usage
2384 # as an error. We need to check if it is safe to use it first.
2386 AC_MSG_CHECKING([if gcc accepts -pie])
2388 safe_CFLAGS=$CFLAGS
2389 CFLAGS="-pie"
2391 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2392   return 0;
2393 ]])], [
2394 AC_SUBST([FLAG_PIE], ["-pie"])
2395 AC_MSG_RESULT([yes])
2396 ], [
2397 AC_SUBST([FLAG_PIE], [""])
2398 AC_MSG_RESULT([no])
2400 CFLAGS=$safe_CFLAGS
2403 # Does this compiler support -no-pie?
2404 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2405 # default. However this gets in the way with some tests, we use -no-pie
2406 # for these.
2408 AC_MSG_CHECKING([if gcc accepts -no-pie])
2410 safe_CFLAGS=$CFLAGS
2411 CFLAGS="-no-pie"
2413 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2414   return 0;
2415 ]])], [
2416 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2417 AC_MSG_RESULT([yes])
2418 ], [
2419 AC_SUBST([FLAG_NO_PIE], [""])
2420 AC_MSG_RESULT([no])
2422 CFLAGS=$safe_CFLAGS
2425 # We want to use use the -Ttext-segment option to the linker.
2426 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2427 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2428 # semantics are NOT what we want (GNU gold -Ttext is fine).
2430 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2431 # will reside. -Ttext aligns just the .text section start (but not any
2432 # other section).
2434 # So test for -Ttext-segment which is supported by all bfd ld versions
2435 # and use that if it exists. If it doesn't exist it must be an older
2436 # version of gold and we can fall back to using -Ttext which has the
2437 # right semantics.
2439 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2441 safe_CFLAGS=$CFLAGS
2442 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2444 AC_LINK_IFELSE(
2445 [AC_LANG_SOURCE([int _start () { return 0; }])],
2447   linker_using_t_text="no"
2448   AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2449   AC_MSG_RESULT([yes])
2450 ], [
2451   linker_using_t_text="yes"
2452   AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2453   AC_MSG_RESULT([no])
2455 CFLAGS=$safe_CFLAGS
2457 # If the linker only supports -Ttext (not -Ttext-segment) then we will
2458 # have to strip any build-id ELF NOTEs from the statically linked tools.
2459 # Otherwise the build-id NOTE might end up at the default load address.
2460 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2461 # gold versions also support -Ttext-segment. So just assume that unless
2462 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2463 if test "x${linker_using_t_text}" = "xyes"; then
2464 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2465 # does the linker support -Wl,--build-id=none ?  Note, it's
2466 # important that we test indirectly via whichever C compiler
2467 # is selected, rather than testing /usr/bin/ld or whatever
2468 # directly.
2469 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2470 safe_CFLAGS=$CFLAGS
2471 CFLAGS="-Wl,--build-id=none -Werror"
2473 AC_LINK_IFELSE(
2474 [AC_LANG_PROGRAM([ ], [return 0;])],
2476   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2477   AC_MSG_RESULT([yes])
2478 ], [
2479   AC_SUBST([FLAG_NO_BUILD_ID], [""])
2480   AC_MSG_RESULT([no])
2482 else
2483 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2484 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2486 CFLAGS=$safe_CFLAGS
2488 # does the ppc assembler support "mtocrf" et al?
2489 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2491 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2492 __asm__ __volatile__("mtocrf 4,0");
2493 __asm__ __volatile__("mfocrf 0,4");
2494 ]])], [
2495 ac_have_as_ppc_mftocrf=yes
2496 AC_MSG_RESULT([yes])
2497 ], [
2498 ac_have_as_ppc_mftocrf=no
2499 AC_MSG_RESULT([no])
2501 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2502   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2506 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2507 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2509 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2510   do { typedef struct {
2511       double hi;
2512       double lo;
2513      } dbl_pair_t;
2514      dbl_pair_t dbl_pair[3];
2515      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2516    } while (0)
2517 ]])], [
2518 ac_have_as_ppc_fpPO=yes
2519 AC_MSG_RESULT([yes])
2520 ], [
2521 ac_have_as_ppc_fpPO=no
2522 AC_MSG_RESULT([no])
2524 if test x$ac_have_as_ppc_fpPO = xyes ; then
2525   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2529 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2530 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2532 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2533 void* p;
2534 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2535 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2536 ]])], [
2537 ac_have_as_amd64_fxsave64=yes
2538 AC_MSG_RESULT([yes])
2539 ], [
2540 ac_have_as_amd64_fxsave64=no
2541 AC_MSG_RESULT([no])
2543 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2544   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2547 # does the x86/amd64 assembler understand SSE3 instructions?
2548 # Note, this doesn't generate a C-level symbol.  It generates a
2549 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2550 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2552 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2553   do { long long int x; 
2554      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
2555   while (0)
2556 ]])], [
2557 ac_have_as_sse3=yes
2558 AC_MSG_RESULT([yes])
2559 ], [
2560 ac_have_as_sse3=no
2561 AC_MSG_RESULT([no])
2564 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2567 # Ditto for SSSE3 instructions (note extra S)
2568 # Note, this doesn't generate a C-level symbol.  It generates a
2569 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2570 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2572 save_CFLAGS="$CFLAGS"
2573 CFLAGS="$CFLAGS -msse -Werror"
2574 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2575   do { long long int x; 
2576    __asm__ __volatile__(
2577       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2578   while (0)
2579 ]])], [
2580 ac_have_as_ssse3=yes
2581 AC_MSG_RESULT([yes])
2582 ], [
2583 ac_have_as_ssse3=no
2584 AC_MSG_RESULT([no])
2586 CFLAGS="$save_CFLAGS"
2588 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2591 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2592 # Note, this doesn't generate a C-level symbol.  It generates a
2593 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2594 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2595 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2596   do {
2597    __asm__ __volatile__(
2598       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2599   while (0)
2600 ]])], [
2601 ac_have_as_pclmulqdq=yes
2602 AC_MSG_RESULT([yes])
2603 ], [
2604 ac_have_as_pclmulqdq=no
2605 AC_MSG_RESULT([no])
2608 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2611 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2612 # Note, this doesn't generate a C-level symbol.  It generates a
2613 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2614 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2615 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2616   do {
2617       /*
2618        * Carry-less multiplication of xmm1 with xmm2 and store the result in
2619        * xmm3. The immediate is used to determine which quadwords of xmm1 and
2620        * xmm2 should be used.
2621        */
2622    __asm__ __volatile__(
2623       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2624   } while (0)
2625 ]])], [
2626 ac_have_as_vpclmulqdq=yes
2627 AC_MSG_RESULT([yes])
2628 ], [
2629 ac_have_as_vpclmulqdq=no
2630 AC_MSG_RESULT([no])
2633 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2636 # does the x86/amd64 assembler understand FMA4 instructions?
2637 # Note, this doesn't generate a C-level symbol.  It generates a
2638 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
2639 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
2640 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2641   do {
2642    __asm__ __volatile__(
2643       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
2644   } while (0)
2645 ]])], [
2646 ac_have_as_vfmaddpd=yes
2647 AC_MSG_RESULT([yes])
2648 ], [
2649 ac_have_as_vfmaddpd=no
2650 AC_MSG_RESULT([no])
2653 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
2656 # does the x86/amd64 assembler understand the LZCNT instruction?
2657 # Note, this doesn't generate a C-level symbol.  It generates a
2658 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2659 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2661 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2662   do {           
2663       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2664   } while (0)
2665 ]])], [
2666   ac_have_as_lzcnt=yes
2667   AC_MSG_RESULT([yes])
2668 ], [
2669   ac_have_as_lzcnt=no
2670   AC_MSG_RESULT([no])
2673 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2676 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2677 # Note, this doesn't generate a C-level symbol.  It generates a
2678 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2679 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2682   do {           
2683       __asm__ __volatile__("1:  loopnel 1b\n");
2684   } while (0)
2685 ]])], [
2686   ac_have_as_loopnel=yes
2687   AC_MSG_RESULT([yes])
2688 ], [
2689   ac_have_as_loopnel=no
2690   AC_MSG_RESULT([no])
2693 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2696 # does the x86/amd64 assembler understand ADDR32 ?
2697 # Note, this doesn't generate a C-level symbol.  It generates a
2698 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2699 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2701 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2702   do {           
2703       asm volatile ("addr32 rep movsb");
2704   } while (0)
2705 ]])], [
2706   ac_have_as_addr32=yes
2707   AC_MSG_RESULT([yes])
2708 ], [
2709   ac_have_as_addr32=no
2710   AC_MSG_RESULT([no])
2713 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2716 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2717 # Note, this doesn't generate a C-level symbol.  It generates a
2718 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2719 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2721 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2722   do { long long int x; 
2723    __asm__ __volatile__(
2724       "crc32q %%r15,%%r15" : : : "r15" );
2725    __asm__ __volatile__(
2726       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
2727    __asm__ __volatile__(
2728       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2729   while (0)
2730 ]])], [
2731 ac_have_as_sse42=yes
2732 AC_MSG_RESULT([yes])
2733 ], [
2734 ac_have_as_sse42=no
2735 AC_MSG_RESULT([no])
2738 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2741 # does the x86/amd64 assembler understand AVX instructions?
2742 # Note, this doesn't generate a C-level symbol.  It generates a
2743 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2744 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2746 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2747   do { long long int x; 
2748    __asm__ __volatile__(
2749       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2750    __asm__ __volatile__(
2751       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2752   while (0)
2753 ]])], [
2754 ac_have_as_avx=yes
2755 AC_MSG_RESULT([yes])
2756 ], [
2757 ac_have_as_avx=no
2758 AC_MSG_RESULT([no])
2761 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2764 # does the x86/amd64 assembler understand AVX2 instructions?
2765 # Note, this doesn't generate a C-level symbol.  It generates a
2766 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2767 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2769 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2770   do { long long int x; 
2771    __asm__ __volatile__(
2772       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2773    __asm__ __volatile__(
2774       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2775   while (0)
2776 ]])], [
2777 ac_have_as_avx2=yes
2778 AC_MSG_RESULT([yes])
2779 ], [
2780 ac_have_as_avx2=no
2781 AC_MSG_RESULT([no])
2784 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2787 # does the x86/amd64 assembler understand TSX instructions and
2788 # the XACQUIRE/XRELEASE prefixes?
2789 # Note, this doesn't generate a C-level symbol.  It generates a
2790 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2791 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2793 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2794   do {
2795    __asm__ __volatile__(
2796       "       xbegin Lfoo  \n\t"
2797       "Lfoo:  xend         \n\t"
2798       "       xacquire lock incq 0(%rsp)     \n\t"
2799       "       xrelease lock incq 0(%rsp)     \n"
2800    );
2801   } while (0)
2802 ]])], [
2803 ac_have_as_tsx=yes
2804 AC_MSG_RESULT([yes])
2805 ], [
2806 ac_have_as_tsx=no
2807 AC_MSG_RESULT([no])
2810 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2813 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2814 # Note, this doesn't generate a C-level symbol.  It generates a
2815 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2816 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2818 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2819   do { unsigned int h, l;
2820    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2821    __asm__ __volatile__(
2822       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2823    __asm__ __volatile__(
2824       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2825   while (0)
2826 ]])], [
2827 ac_have_as_bmi=yes
2828 AC_MSG_RESULT([yes])
2829 ], [
2830 ac_have_as_bmi=no
2831 AC_MSG_RESULT([no])
2834 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2837 # does the x86/amd64 assembler understand FMA instructions?
2838 # Note, this doesn't generate a C-level symbol.  It generates a
2839 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2840 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2842 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2843   do { unsigned int h, l;
2844    __asm__ __volatile__(
2845       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2846    __asm__ __volatile__(
2847       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2848    __asm__ __volatile__(
2849       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2850   while (0)
2851 ]])], [
2852 ac_have_as_fma=yes
2853 AC_MSG_RESULT([yes])
2854 ], [
2855 ac_have_as_fma=no
2856 AC_MSG_RESULT([no])
2859 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2862 # does the amd64 assembler understand MPX instructions?
2863 # Note, this doesn't generate a C-level symbol.  It generates a
2864 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2865 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2867 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2868   do {
2869     asm ("bndmov %bnd0,(%rsp)");
2870     asm ("bndldx 3(%rbx,%rdx), %bnd2");
2871     asm ("bnd call foo\n"
2872           bnd jmp  end\n"
2873           foo: bnd ret\n"
2874           end: nop");
2875   } while (0)
2876 ]])], [
2877 ac_have_as_mpx=yes
2878 AC_MSG_RESULT([yes])
2879 ], [
2880 ac_have_as_mpx=no
2881 AC_MSG_RESULT([no])
2884 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2887 # does the amd64 assembler understand ADX instructions?
2888 # Note, this doesn't generate a C-level symbol.  It generates a
2889 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
2890 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
2892 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2893   do {
2894     asm ("adcxq %r14,%r8");
2895   } while (0)
2896 ]])], [
2897 ac_have_as_adx=yes
2898 AC_MSG_RESULT([yes])
2899 ], [
2900 ac_have_as_adx=no
2901 AC_MSG_RESULT([no])
2904 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
2907 # Does the C compiler support the "ifunc" attribute
2908 # Note, this doesn't generate a C-level symbol.  It generates a
2909 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2910 # does the x86/amd64 assembler understand MOVBE?
2911 # Note, this doesn't generate a C-level symbol.  It generates a
2912 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2913 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2915 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2916   do { long long int x; 
2917    __asm__ __volatile__(
2918       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
2919   while (0)
2920 ]])], [
2921 ac_have_as_movbe=yes
2922 AC_MSG_RESULT([yes])
2923 ], [
2924 ac_have_as_movbe=no
2925 AC_MSG_RESULT([no])
2928 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2931 # Does the C compiler support the "ifunc" attribute
2932 # Note, this doesn't generate a C-level symbol.  It generates a
2933 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2934 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2936 AC_LINK_IFELSE([AC_LANG_SOURCE([[
2937 static void mytest(void) {}
2939 static void (*resolve_test(void))(void)
2941     return (void (*)(void))&mytest;
2944 void test(void) __attribute__((ifunc("resolve_test")));
2946 int main()
2948     test();
2949     return 0;
2951 ]])], [
2952 ac_have_ifunc_attr=yes
2953 AC_MSG_RESULT([yes])
2954 ], [
2955 ac_have_ifunc_attr=no
2956 AC_MSG_RESULT([no])
2959 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2961 # Does the C compiler support the armv8 crc feature flag
2962 # Note, this doesn't generate a C-level symbol.  It generates a
2963 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
2964 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
2966 save_CFLAGS="$CFLAGS"
2967 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
2968 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2969 int main()
2971     return 0;
2973 ]])], [
2974 ac_have_armv8_crc_feature=yes
2975 AC_MSG_RESULT([yes])
2976 ], [
2977 ac_have_armv8_crc_feature=no
2978 AC_MSG_RESULT([no])
2980 CFLAGS="$save_CFLAGS"
2982 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
2985 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
2986 # when building the tool executables.  I think we should get rid of it.
2988 # Check for TLS support in the compiler and linker
2989 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2990                                 [[return foo;]])],
2991                                [vg_cv_linktime_tls=yes],
2992                                [vg_cv_linktime_tls=no])
2993 # Native compilation: check whether running a program using TLS succeeds.
2994 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2995 # succeeds but running programs using TLS fails.
2996 # Cross-compiling: check whether linking a program using TLS succeeds.
2997 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2998                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
2999                 [vg_cv_tls=$enableval],
3000                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3001                                                 [[return foo;]])],
3002                                [vg_cv_tls=yes],
3003                                [vg_cv_tls=no],
3004                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3006 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3007 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3011 #----------------------------------------------------------------------------
3012 # Solaris-specific checks.
3013 #----------------------------------------------------------------------------
3015 if test "$VGCONF_OS" = "solaris" ; then
3016 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3018 # Solaris-specific check determining if the Sun Studio Assembler is used to
3019 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3020 # cmovl.l instruction, if yes then it's Sun Assembler.
3022 # C-level symbol: none
3023 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3025 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3026 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3027 ]], [[
3028   __asm__ __volatile__("cmovl.l %edx, %eax");
3029 ]])], [
3030 solaris_have_sun_studio_as=yes
3031 AC_MSG_RESULT([yes])
3032 ], [
3033 solaris_have_sun_studio_as=no
3034 AC_MSG_RESULT([no])
3036 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3038 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3039 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3040 # See solaris/vgpreload-solaris.mapfile for details.
3041 # gcc on older Solaris instructs linker to include these symbols,
3042 # gcc on illumos and newer Solaris does not.
3044 # C-level symbol: none
3045 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3047 save_CFLAGS="$CFLAGS"
3048 CFLAGS="$CFLAGS -std=gnu99"
3049 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3050 temp_dir=$( /usr/bin/mktemp -d )
3051 cat <<_ACEOF >${temp_dir}/mylib.c
3052 #include <stdio.h>
3053 int myfunc(void) { printf("LaPutyka\n"); }
3054 _ACEOF
3055 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3056 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3057 if test "x${xpg_present}" = "x" ; then
3058     solaris_xpg_symbols_present=no
3059     AC_MSG_RESULT([no])
3060 else
3061     solaris_xpg_symbols_present=yes
3062     AC_MSG_RESULT([yes])
3064 rm -rf ${temp_dir}
3065 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3066 CFLAGS="$save_CFLAGS"
3069 # Solaris-specific check determining if gcc enables largefile support by
3070 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3071 # variable with gcc flags which disable it.
3073 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3074 save_CFLAGS="$CFLAGS"
3075 CFLAGS="$CFLAGS -m32"
3076 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3077   return _LARGEFILE_SOURCE;
3078 ]])], [
3079 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3080 AC_MSG_RESULT([yes])
3081 ], [
3082 SOLARIS_UNDEF_LARGESOURCE=""
3083 AC_MSG_RESULT([no])
3085 CFLAGS=$safe_CFLAGS
3086 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3089 # Solaris-specific check determining if /proc/self/cmdline
3090 # or /proc/<pid>/cmdline is supported.
3092 # C-level symbol: SOLARIS_PROC_CMDLINE
3093 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3095 AC_CHECK_FILE([/proc/self/cmdline],
3097 solaris_proc_cmdline=yes
3098 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3099           [Define to 1 if you have /proc/self/cmdline.])
3100 ], [
3101 solaris_proc_cmdline=no
3103 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3106 # Solaris-specific check determining default platform for the Valgrind launcher.
3107 # Used in case the launcher cannot select platform by looking at the client
3108 # image (for example because the executable is a shell script).
3110 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3111 # Automake-level symbol: none
3113 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3114 # Get the ELF class of /bin/sh first.
3115 if ! test -f /bin/sh; then
3116   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3118 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3119 case "$elf_class" in
3120   64)
3121     default_arch="$VGCONF_ARCH_PRI";
3122     ;;
3123   32)
3124     if test "x$VGCONF_ARCH_SEC" != "x"; then
3125       default_arch="$VGCONF_ARCH_SEC"
3126     else
3127       default_arch="$VGCONF_ARCH_PRI";
3128     fi
3129     ;;
3130   *)
3131     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3132     ;;
3133 esac
3134 default_platform="$default_arch-$VGCONF_OS"
3135 AC_MSG_RESULT([$default_platform])
3136 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3137                    [Default platform for Valgrind launcher.])
3140 # Solaris-specific check determining if the old syscalls are available.
3142 # C-level symbol: SOLARIS_OLD_SYSCALLS
3143 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3145 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3147 #include <sys/syscall.h>
3148 ]], [[
3149   return !SYS_open;
3150 ]])], [
3151 solaris_old_syscalls=yes
3152 AC_MSG_RESULT([yes])
3153 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3154           [Define to 1 if you have the old Solaris syscalls.])
3155 ], [
3156 solaris_old_syscalls=no
3157 AC_MSG_RESULT([no])
3159 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3162 # Solaris-specific check determining if the new accept() syscall is available.
3164 # Old syscall:
3165 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3166 #            int version);
3168 # New syscall (available on illumos):
3169 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3170 #            int version, int flags);
3172 # If the old syscall is present then the following syscall will fail with
3173 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3174 # available then it will fail with EINVAL (because the flags parameter is
3175 # invalid).
3177 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3178 # Automake-level symbol: none
3180 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3181 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3182 #include <sys/syscall.h>
3183 #include <errno.h>
3184 ]], [[
3185   errno = 0;
3186   syscall(SYS_accept, 0, 0, 0, 0, -1);
3187   return !(errno == EINVAL);
3188 ]])], [
3189 AC_MSG_RESULT([yes])
3190 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3191           [Define to 1 if you have the new `accept' syscall.])
3192 ], [
3193 AC_MSG_RESULT([no])
3197 # Solaris-specific check determining if the new illumos pipe() syscall is
3198 # available.
3200 # Old syscall:
3201 # longlong_t pipe();
3203 # New syscall (available on illumos):
3204 # int pipe(intptr_t arg, int flags);
3206 # If the old syscall is present then the following call will succeed, if the
3207 # new syscall is available then it will fail with EFAULT (because address 0
3208 # cannot be accessed).
3210 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3211 # Automake-level symbol: none
3213 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3214 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3215 #include <sys/syscall.h>
3216 #include <errno.h>
3217 ]], [[
3218   errno = 0;
3219   syscall(SYS_pipe, 0, 0);
3220   return !(errno == EFAULT);
3221 ]])], [
3222 AC_MSG_RESULT([yes])
3223 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3224           [Define to 1 if you have the new `pipe' syscall.])
3225 ], [
3226 AC_MSG_RESULT([no])
3230 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3231 # available.
3233 # Old syscall:
3234 # int lwp_kill(id_t lwpid, int sig);
3236 # New syscall (available on Solaris 11):
3237 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3238 #                  int si_code, timespec_t *timeout);
3240 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3241 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3243 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3244 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3245 #include <sys/syscall.h> 
3246 ]], [[
3247   return !SYS_lwp_sigqueue;
3248 ]])], [
3249 solaris_lwp_sigqueue_syscall=yes
3250 AC_MSG_RESULT([yes])
3251 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3252           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3253 ], [
3254 solaris_lwp_sigqueue_syscall=no
3255 AC_MSG_RESULT([no])
3257 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3260 # Solaris-specific check determining if the lwp_sigqueue() syscall
3261 # takes both pid and thread id arguments or just thread id.
3263 # Old syscall (available up to Solaris 11.3):
3264 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3265 #                  int si_code, timespec_t *timeout);
3267 # New syscall (available since Solaris 11.4):
3268 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3269 #                  int si_code, timespec_t *timeout);
3271 # If the old syscall is present then the following syscall will fail with
3272 # EINVAL (because signal is out of range); if the new syscall is available
3273 # then it will fail with ESRCH (because it would not find such thread in the
3274 # current process).
3276 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3277 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3279 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3280 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3281 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3282 #include <sys/syscall.h>
3283 #include <errno.h>
3284 ]], [[
3285   errno = 0;
3286   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3287   return !(errno == ESRCH);
3288 ]])], [
3289 solaris_lwp_sigqueue_syscall_takes_pid=yes
3290 AC_MSG_RESULT([yes])
3291 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3292           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3293 ], [
3294 solaris_lwp_sigqueue_syscall_takes_pid=no
3295 AC_MSG_RESULT([no])
3297 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3298                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3300 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3304 # Solaris-specific check determining if the new lwp_name() syscall is
3305 # available.
3307 # New syscall (available on Solaris 11):
3308 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3310 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3311 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3313 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3314 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3315 #include <sys/syscall.h>
3316 ]], [[
3317   return !SYS_lwp_name;
3318 ]])], [
3319 solaris_lwp_name_syscall=yes
3320 AC_MSG_RESULT([yes])
3321 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3322           [Define to 1 if you have the new `lwp_name' syscall.])
3323 ], [
3324 solaris_lwp_name_syscall=no
3325 AC_MSG_RESULT([no])
3327 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3330 # Solaris-specific check determining if the new getrandom() syscall is
3331 # available.
3333 # New syscall (available on Solaris 11):
3334 # int getrandom(void *buf, size_t buflen, uint_t flags);
3336 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3337 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3339 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3340 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3341 #include <sys/syscall.h>
3342 ]], [[
3343   return !SYS_getrandom;
3344 ]])], [
3345 solaris_getrandom_syscall=yes
3346 AC_MSG_RESULT([yes])
3347 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3348           [Define to 1 if you have the new `getrandom' syscall.])
3349 ], [
3350 solaris_getrandom_syscall=no
3351 AC_MSG_RESULT([no])
3353 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3356 # Solaris-specific check determining if the new zone() syscall subcodes
3357 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
3358 # were added in Solaris 11 but are missing on illumos.
3360 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3361 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3363 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3365 #include <sys/zone.h>
3366 ]], [[
3367   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3368 ]])], [
3369 solaris_zone_defunct=yes
3370 AC_MSG_RESULT([yes])
3371 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3372           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3373 ], [
3374 solaris_zone_defunct=no
3375 AC_MSG_RESULT([no])
3377 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3380 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3381 # for auditon(2) subcode of the auditsys() syscall are available.
3382 # These commands are available in Solaris 11 and illumos but were removed
3383 # in Solaris 11.4.
3385 # C-level symbol: SOLARIS_AUDITON_STAT
3386 # Automake-level symbol: SOLARIS_AUDITON_STAT
3388 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3389 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3390 #include <bsm/audit.h>
3391 ]], [[
3392   return !(A_GETSTAT && A_SETSTAT);
3393 ]])], [
3394 solaris_auditon_stat=yes
3395 AC_MSG_RESULT([yes])
3396 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3397           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3398 ], [
3399 solaris_auditon_stat=no
3400 AC_MSG_RESULT([no])
3402 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3405 # Solaris-specific check determining if the new shmsys() syscall subcodes
3406 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3407 # These subcodes were added in Solaris 11 but are missing on illumos.
3409 # C-level symbol: SOLARIS_SHM_NEW
3410 # Automake-level symbol: SOLARIS_SHM_NEW
3412 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3413 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3414 #include <sys/ipc_impl.h>
3415 #include <sys/shm.h>
3416 #include <sys/shm_impl.h>
3417 ]], [[
3418   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3419 ]])], [
3420 solaris_shm_new=yes
3421 AC_MSG_RESULT([yes])
3422 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3423           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3424 ], [
3425 solaris_shm_new=no
3426 AC_MSG_RESULT([no])
3428 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3431 # Solaris-specific check determining if prxregset_t is available.  Illumos
3432 # currently does not define it on the x86 platform.
3434 # C-level symbol: SOLARIS_PRXREGSET_T
3435 # Automake-level symbol: SOLARIS_PRXREGSET_T
3437 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3438 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3439 #include <sys/procfs_isa.h>
3440 ]], [[
3441   return !sizeof(prxregset_t);
3442 ]])], [
3443 solaris_prxregset_t=yes
3444 AC_MSG_RESULT([yes])
3445 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3446           [Define to 1 if you have the `prxregset_t' type.])
3447 ], [
3448 solaris_prxregset_t=no
3449 AC_MSG_RESULT([no])
3451 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3454 # Solaris-specific check determining if the new frealpathat() syscall is
3455 # available.
3457 # New syscall (available on Solaris 11.1):
3458 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
3460 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3461 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3463 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3464 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3465 #include <sys/syscall.h>
3466 ]], [[
3467   return !SYS_frealpathat;
3468 ]])], [
3469 solaris_frealpathat_syscall=yes
3470 AC_MSG_RESULT([yes])
3471 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3472           [Define to 1 if you have the new `frealpathat' syscall.])
3473 ], [
3474 solaris_frealpathat_syscall=no
3475 AC_MSG_RESULT([no])
3477 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3480 # Solaris-specific check determining if the new uuidsys() syscall is
3481 # available.
3483 # New syscall (available on newer Solaris):
3484 # int uuidsys(struct uuid *uuid);
3486 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3487 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3489 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3490 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3491 #include <sys/syscall.h>
3492 ]], [[
3493   return !SYS_uuidsys;
3494 ]])], [
3495 solaris_uuidsys_syscall=yes
3496 AC_MSG_RESULT([yes])
3497 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
3498           [Define to 1 if you have the new `uuidsys' syscall.])
3499 ], [
3500 solaris_uuidsys_syscall=no
3501 AC_MSG_RESULT([no])
3503 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
3506 # Solaris-specific check determining if the new labelsys() syscall subcode
3507 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
3508 # missing on illumos.
3510 # C-level symbol: SOLARIS_TNDB_GET_TNIP
3511 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
3513 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
3514 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3515 #include <sys/tsol/tndb.h>
3516 ]], [[
3517   return !TNDB_GET_TNIP;
3518 ]])], [
3519 solaris_tndb_get_tnip=yes
3520 AC_MSG_RESULT([yes])
3521 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
3522           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
3523 ], [
3524 solaris_tndb_get_tnip=no
3525 AC_MSG_RESULT([no])
3527 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
3530 # Solaris-specific check determining if the new labelsys() syscall opcodes
3531 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
3532 # added in Solaris 11 but are missing on illumos.
3534 # C-level symbol: SOLARIS_TSOL_CLEARANCE
3535 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
3537 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
3538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3539 #include <sys/tsol/tsyscall.h>
3540 ]], [[
3541   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
3542 ]])], [
3543 solaris_tsol_clearance=yes
3544 AC_MSG_RESULT([yes])
3545 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
3546           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
3547 ], [
3548 solaris_tsol_clearance=no
3549 AC_MSG_RESULT([no])
3551 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
3554 # Solaris-specific check determining if the new pset() syscall subcode
3555 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
3556 # is missing on illumos and Solaris 11.3.
3558 # C-level symbol: SOLARIS_PSET_GET_NAME
3559 # Automake-level symbol: SOLARIS_PSET_GET_NAME
3561 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
3562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3563 #include <sys/pset.h>
3564 ]], [[
3565   return !(PSET_GET_NAME);
3566 ]])], [
3567 solaris_pset_get_name=yes
3568 AC_MSG_RESULT([yes])
3569 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
3570           [Define to 1 if you have the `PSET_GET_NAME' constants.])
3571 ], [
3572 solaris_pset_get_name=no
3573 AC_MSG_RESULT([no])
3575 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
3578 # Solaris-specific check determining if the utimesys() syscall is
3579 # available (on illumos and older Solaris).
3581 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
3582 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
3584 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
3585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3586 #include <sys/syscall.h>
3587 ]], [[
3588   return !SYS_utimesys;
3589 ]])], [
3590 solaris_utimesys_syscall=yes
3591 AC_MSG_RESULT([yes])
3592 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
3593           [Define to 1 if you have the `utimesys' syscall.])
3594 ], [
3595 solaris_utimesys_syscall=no
3596 AC_MSG_RESULT([no])
3598 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
3601 # Solaris-specific check determining if the utimensat() syscall is
3602 # available (on newer Solaris).
3604 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3605 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3607 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
3608 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3609 #include <sys/syscall.h>
3610 ]], [[
3611   return !SYS_utimensat;
3612 ]])], [
3613 solaris_utimensat_syscall=yes
3614 AC_MSG_RESULT([yes])
3615 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
3616           [Define to 1 if you have the `utimensat' syscall.])
3617 ], [
3618 solaris_utimensat_syscall=no
3619 AC_MSG_RESULT([no])
3621 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
3624 # Solaris-specific check determining if the spawn() syscall is available
3625 # (on newer Solaris).
3627 # C-level symbol: SOLARIS_SPAWN_SYSCALL
3628 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
3630 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
3631 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3632 #include <sys/syscall.h>
3633 ]], [[
3634   return !SYS_spawn;
3635 ]])], [
3636 solaris_spawn_syscall=yes
3637 AC_MSG_RESULT([yes])
3638 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
3639           [Define to 1 if you have the `spawn' syscall.])
3640 ], [
3641 solaris_spawn_syscall=no
3642 AC_MSG_RESULT([no])
3644 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
3647 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
3648 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
3650 # C-level symbol: SOLARIS_MODCTL_MODNVL
3651 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
3653 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
3654 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3655 #include <sys/modctl.h>
3656 ]], [[
3657   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
3658 ]])], [
3659 solaris_modctl_modnvl=yes
3660 AC_MSG_RESULT([yes])
3661 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
3662           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
3663 ], [
3664 solaris_modctl_modnvl=no
3665 AC_MSG_RESULT([no])
3667 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
3670 # Solaris-specific check determining whether nscd (name switch cache daemon)
3671 # attaches its door at /system/volatile/name_service_door (Solaris)
3672 # or at /var/run/name_service_door (illumos).
3674 # Note that /var/run is a symlink to /system/volatile on Solaris
3675 # but not vice versa on illumos.
3677 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3678 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3680 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
3681 if test -e /system/volatile/name_service_door; then
3682     solaris_nscd_door_system_volatile=yes
3683     AC_MSG_RESULT([/system/volatile/name_service_door])
3684     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
3685               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
3686 else
3687     solaris_nscd_door_system_volatile=no
3688     AC_MSG_RESULT([/var/run/name_service_door])
3690 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
3693 # Solaris-specific check determining if the new gethrt() fasttrap is available.
3695 # New fasttrap (available on Solaris 11):
3696 # hrt_t *gethrt(void);
3698 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
3699 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
3701 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
3702 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3703 #include <sys/trap.h>
3704 ]], [[
3705   return !T_GETHRT;
3706 ]])], [
3707 solaris_gethrt_fasttrap=yes
3708 AC_MSG_RESULT([yes])
3709 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
3710           [Define to 1 if you have the new `gethrt' fasttrap.])
3711 ], [
3712 solaris_gethrt_fasttrap=no
3713 AC_MSG_RESULT([no])
3715 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
3718 # Solaris-specific check determining if the new get_zone_offset() fasttrap
3719 # is available.
3721 # New fasttrap (available on Solaris 11):
3722 # zonehrtoffset_t *get_zone_offset(void);
3724 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3725 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3727 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
3728 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3729 #include <sys/trap.h>
3730 ]], [[
3731   return !T_GETZONEOFFSET;
3732 ]])], [
3733 solaris_getzoneoffset_fasttrap=yes
3734 AC_MSG_RESULT([yes])
3735 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
3736           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
3737 ], [
3738 solaris_getzoneoffset_fasttrap=no
3739 AC_MSG_RESULT([no])
3741 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
3744 # Solaris-specific check determining if the execve() syscall
3745 # takes fourth argument (flags) or not.
3747 # Old syscall (available on illumos):
3748 # int execve(const char *fname, const char **argv, const char **envp);
3750 # New syscall (available on Solaris):
3751 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
3753 # If the new syscall is present then it will fail with EINVAL (because flags
3754 # are invalid); if the old syscall is available then it will fail with ENOENT
3755 # (because the file could not be found).
3757 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3758 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3760 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
3761 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3762 #include <sys/syscall.h>
3763 #include <errno.h>
3764 ]], [[
3765   errno = 0;
3766   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
3767   return !(errno == EINVAL);
3768 ]])], [
3769 solaris_execve_syscall_takes_flags=yes
3770 AC_MSG_RESULT([yes])
3771 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
3772           [Define to 1 if you have the new `execve' syscall which accepts flags.])
3773 ], [
3774 solaris_execve_syscall_takes_flags=no
3775 AC_MSG_RESULT([no])
3777 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
3778                test x$solaris_execve_syscall_takes_flags = xyes)
3781 # Solaris-specific check determining version of the repository cache protocol.
3782 # Every Solaris version uses a different one, ranging from 21 to current 25.
3783 # The check is very ugly, though.
3785 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
3786 # Automake-level symbol: none
3788 AC_PATH_PROG(DIS_PATH, dis, false)
3789 if test "x$DIS_PATH" = "xfalse"; then
3790   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
3792 AC_CHECK_LIB(scf, scf_handle_bind, [], [
3793   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
3794   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3797 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
3798 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
3799   libscf=/usr/lib/64/libscf.so.1
3800 else
3801   libscf=/usr/lib/libscf.so.1
3803 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
3804   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
3805   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3807 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
3808 if test -z "$hex"; then
3809   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
3810   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3812 version=$( printf "%d\n" 0x$hex )
3813 AC_MSG_RESULT([$version])
3814 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
3815                    [Version number of the repository door cache protocol.])
3818 # Solaris-specific check determining if "sysstat" segment reservation type
3819 # is available.
3821 # New "sysstat" segment reservation (available on Solaris 11.4):
3822 # - program header type:    PT_SUNW_SYSSTAT
3823 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
3825 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
3826 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
3828 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
3829 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3830 #include <sys/auxv.h>
3831 ]], [[
3832   return !AT_SUN_SYSSTAT_ADDR;
3833 ]])], [
3834 solaris_reserve_sysstat_addr=yes
3835 AC_MSG_RESULT([yes])
3836 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
3837           [Define to 1 if you have the new `sysstat' segment reservation.])
3838 ], [
3839 solaris_reserve_sysstat_addr=no
3840 AC_MSG_RESULT([no])
3842 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
3845 # Solaris-specific check determining if "sysstat_zone" segment reservation type
3846 # is available.
3848 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
3849 # - program header type:    PT_SUNW_SYSSTAT_ZONE
3850 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
3852 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
3853 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
3855 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
3856 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3857 #include <sys/auxv.h>
3858 ]], [[
3859   return !AT_SUN_SYSSTAT_ZONE_ADDR;
3860 ]])], [
3861 solaris_reserve_sysstat_zone_addr=yes
3862 AC_MSG_RESULT([yes])
3863 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
3864           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
3865 ], [
3866 solaris_reserve_sysstat_zone_addr=no
3867 AC_MSG_RESULT([no])
3869 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
3872 # Solaris-specific check determining if the system_stats() syscall is available
3873 # (on newer Solaris).
3875 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
3876 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
3878 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
3879 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3880 #include <sys/syscall.h>
3881 ]], [[
3882   return !SYS_system_stats;
3883 ]])], [
3884 solaris_system_stats_syscall=yes
3885 AC_MSG_RESULT([yes])
3886 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
3887           [Define to 1 if you have the `system_stats' syscall.])
3888 ], [
3889 solaris_system_stats_syscall=no
3890 AC_MSG_RESULT([no])
3892 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
3895 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
3896 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
3898 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
3899 # Automake-level symbol: none
3901 AC_CHECK_TYPE([struct _fpchip_state],
3902               [solaris_fpchip_state_takes_underscore=yes],
3903               [solaris_fpchip_state_takes_underscore=no],
3904               [[#include <sys/regset.h>]])
3905 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
3906   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
3907             [Define to 1 if fpregset_t defines struct _fpchip_state])
3911 # Solaris-specific check determining if schedctl page shared between kernel
3912 # and userspace program is executable (illumos, older Solaris) or not (newer
3913 # Solaris).
3915 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
3916 # Automake-level symbol: none
3918 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
3919 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3920 #include <assert.h>
3921 #include <fcntl.h>
3922 #include <procfs.h>
3923 #include <schedctl.h>
3924 #include <stdio.h>
3925 #include <unistd.h>
3926 ]], [[
3927     schedctl_t *scp = schedctl_init();
3928     if (scp == NULL)
3929         return 1;
3931     int fd = open("/proc/self/map", O_RDONLY);
3932     assert(fd >= 0);
3934     prmap_t map;
3935     ssize_t rd;
3936     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
3937         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
3938             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
3939                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
3940             return (map.pr_mflags & MA_EXEC);
3941         }
3942     }
3944     return 1;
3945 ]])], [
3946 solaris_schedctl_page_exec=no
3947 AC_MSG_RESULT([no])
3948 ], [
3949 solaris_schedctl_page_exec=yes
3950 AC_MSG_RESULT([yes])
3951 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
3952           [Define to 1 if you have the schedctl page executable.])
3956 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
3957 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
3958 # an initial thread pointer for libc (newer Solaris).
3960 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
3961 # Automake-level symbol: none
3963 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
3964 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3965 #include <sys/fasttrap_isa.h>
3966 ]], [[
3967     return !FT_SCRATCHSIZE;
3968 ]])], [
3969 solaris_pt_sunwdtrace_thrp=yes
3970 AC_MSG_RESULT([yes])
3971 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
3972           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
3973 ], [
3974 solaris_pt_sunwdtrace_thrp=no
3975 AC_MSG_RESULT([no])
3978 else
3979 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
3980 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
3981 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
3982 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
3983 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
3984 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
3985 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
3986 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
3987 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
3988 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
3989 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
3990 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
3991 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
3992 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
3993 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
3994 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
3995 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
3996 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
3997 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
3998 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
3999 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4000 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4001 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4002 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4003 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4004 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4005 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4006 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4007 fi # test "$VGCONF_OS" = "solaris"
4010 #----------------------------------------------------------------------------
4011 # Checks for C header files.
4012 #----------------------------------------------------------------------------
4014 AC_HEADER_STDC
4015 AC_CHECK_HEADERS([       \
4016         asm/unistd.h     \
4017         endian.h         \
4018         mqueue.h         \
4019         sys/endian.h     \
4020         sys/epoll.h      \
4021         sys/eventfd.h    \
4022         sys/klog.h       \
4023         sys/poll.h       \
4024         sys/prctl.h      \
4025         sys/signal.h     \
4026         sys/signalfd.h   \
4027         sys/syscall.h    \
4028         sys/sysnvl.h     \
4029         sys/time.h       \
4030         sys/types.h      \
4031         ])
4033 # Verify whether the <linux/futex.h> header is usable.
4034 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4036 save_CFLAGS="$CFLAGS"
4037 CFLAGS="$CFLAGS -D__user="
4038 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4039 #include <linux/futex.h>
4040 ]], [[
4041   return FUTEX_WAIT;
4042 ]])], [
4043 ac_have_usable_linux_futex_h=yes
4044 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4045           [Define to 1 if you have a usable <linux/futex.h> header file.])
4046 AC_MSG_RESULT([yes])
4047 ], [
4048 ac_have_usable_linux_futex_h=no
4049 AC_MSG_RESULT([no])
4051 CFLAGS="$save_CFLAGS"
4054 #----------------------------------------------------------------------------
4055 # Checks for typedefs, structures, and compiler characteristics.
4056 #----------------------------------------------------------------------------
4057 AC_TYPE_UID_T
4058 AC_TYPE_OFF_T
4059 AC_TYPE_SIZE_T
4060 AC_HEADER_TIME
4063 #----------------------------------------------------------------------------
4064 # Checks for library functions.
4065 #----------------------------------------------------------------------------
4066 AC_FUNC_MEMCMP
4067 AC_FUNC_MMAP
4069 AC_CHECK_LIB([pthread], [pthread_create])
4070 AC_CHECK_LIB([rt], [clock_gettime])
4072 AC_CHECK_FUNCS([     \
4073         clock_gettime\
4074         epoll_create \
4075         epoll_pwait  \
4076         klogctl      \
4077         mallinfo     \
4078         memchr       \
4079         memset       \
4080         mkdir        \
4081         mremap       \
4082         ppoll        \
4083         pthread_barrier_init       \
4084         pthread_condattr_setclock  \
4085         pthread_mutex_timedlock    \
4086         pthread_rwlock_timedrdlock \
4087         pthread_rwlock_timedwrlock \
4088         pthread_spin_lock          \
4089         pthread_yield              \
4090         pthread_setname_np         \
4091         readlinkat   \
4092         semtimedop   \
4093         signalfd     \
4094         sigwaitinfo  \
4095         strchr       \
4096         strdup       \
4097         strpbrk      \
4098         strrchr      \
4099         strstr       \
4100         syscall      \
4101         utimensat    \
4102         process_vm_readv  \
4103         process_vm_writev \
4104         ])
4106 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4107 # libraries with any shared object and/or executable. This is NOT what we
4108 # want for e.g. vgpreload_core-x86-linux.so
4109 LIBS=""
4111 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4112                [test x$ac_cv_func_pthread_barrier_init = xyes])
4113 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4114                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4115 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4116                [test x$ac_cv_func_pthread_spin_lock = xyes])
4117 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4118                [test x$ac_cv_func_pthread_setname_np = xyes])
4120 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4121      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
4122   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4123             [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
4126 #----------------------------------------------------------------------------
4127 # MPI checks
4128 #----------------------------------------------------------------------------
4129 # Do we have a useable MPI setup on the primary and/or secondary targets?
4130 # On Linux, by default, assumes mpicc and -m32/-m64
4131 # Note: this is a kludge in that it assumes the specified mpicc 
4132 # understands -m32/-m64 regardless of what is specified using
4133 # --with-mpicc=.
4134 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4135              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4137 mflag_primary=
4138 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4139      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4140      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4141      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4142      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4143   mflag_primary=$FLAG_M32
4144 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4145        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4146        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4147        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4148        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4149   mflag_primary=$FLAG_M64
4150 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4151   mflag_primary="$FLAG_M32 -arch i386"
4152 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4153   mflag_primary="$FLAG_M64 -arch x86_64"
4156 mflag_secondary=
4157 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4158      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4159      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4160      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX ; then
4161   mflag_secondary=$FLAG_M32
4162 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4163   mflag_secondary="$FLAG_M32 -arch i386"
4167 AC_ARG_WITH(mpicc,
4168    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4169    MPI_CC=$withval
4171 AC_SUBST(MPI_CC)
4173 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4174 ## use these values in the check for a functioning mpicc.
4176 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4177 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4178 AM_COND_IF([VGCONF_OS_IS_LINUX],
4179            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4180             LDFLAGS_MPI="-fpic -shared"])
4181 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4182            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4183             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4184 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4185            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4186             LDFLAGS_MPI="-fpic -shared"])
4188 AC_SUBST([CFLAGS_MPI])
4189 AC_SUBST([LDFLAGS_MPI])
4192 ## See if MPI_CC works for the primary target
4194 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4195 saved_CC=$CC
4196 saved_CFLAGS=$CFLAGS
4197 CC=$MPI_CC
4198 CFLAGS="$CFLAGS_MPI $mflag_primary"
4199 saved_LDFLAGS="$LDFLAGS"
4200 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4201 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4202 #include <mpi.h>
4203 #include <stdio.h>
4204 ]], [[
4205   int ni, na, nd, comb;
4206   int r = MPI_Init(NULL,NULL);
4207   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4208   r |= MPI_Finalize();
4209   return r; 
4210 ]])], [
4211 ac_have_mpi2_pri=yes
4212 AC_MSG_RESULT([yes, $MPI_CC])
4213 ], [
4214 ac_have_mpi2_pri=no
4215 AC_MSG_RESULT([no])
4217 CC=$saved_CC
4218 CFLAGS=$saved_CFLAGS
4219 LDFLAGS="$saved_LDFLAGS"
4220 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4222 ## See if MPI_CC works for the secondary target.  Complication: what if
4223 ## there is no secondary target?  We need this to then fail.
4224 ## Kludge this by making MPI_CC something which will surely fail in
4225 ## such a case.
4227 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4228 saved_CC=$CC
4229 saved_CFLAGS=$CFLAGS
4230 saved_LDFLAGS="$LDFLAGS"
4231 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4232 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4233   CC="$MPI_CC this will surely fail"
4234 else
4235   CC=$MPI_CC
4237 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4238 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4239 #include <mpi.h>
4240 #include <stdio.h>
4241 ]], [[
4242   int ni, na, nd, comb;
4243   int r = MPI_Init(NULL,NULL);
4244   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4245   r |= MPI_Finalize();
4246   return r; 
4247 ]])], [
4248 ac_have_mpi2_sec=yes
4249 AC_MSG_RESULT([yes, $MPI_CC])
4250 ], [
4251 ac_have_mpi2_sec=no
4252 AC_MSG_RESULT([no])
4254 CC=$saved_CC
4255 CFLAGS=$saved_CFLAGS
4256 LDFLAGS="$saved_LDFLAGS"
4257 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4260 #----------------------------------------------------------------------------
4261 # Other library checks
4262 #----------------------------------------------------------------------------
4263 # There now follow some tests for Boost, and OpenMP.  These
4264 # tests are present because Drd has some regression tests that use
4265 # these packages.  All regression test programs all compiled only
4266 # for the primary target.  And so it is important that the configure
4267 # checks that follow, use the correct -m32 or -m64 flag for the
4268 # primary target (called $mflag_primary).  Otherwise, we can end up
4269 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4270 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4271 # only build (meaning, the primary target is x86-linux), the build
4272 # of the regtest programs that use Boost fails, because they are 
4273 # build as 32-bit (IN THIS EXAMPLE).
4275 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4276 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4279 # Check whether the boost library 1.35 or later has been installed.
4280 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4282 AC_MSG_CHECKING([for boost])
4284 AC_LANG(C++)
4285 safe_CXXFLAGS=$CXXFLAGS
4286 CXXFLAGS="$mflag_primary"
4287 safe_LIBS="$LIBS"
4288 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4290 AC_LINK_IFELSE([AC_LANG_SOURCE([
4291 #include <boost/thread.hpp>
4292 static void thread_func(void)
4293 { }
4294 int main(int argc, char** argv)
4296   boost::thread t(thread_func);
4297   return 0;
4299 ])],
4301 ac_have_boost_1_35=yes
4302 AC_SUBST([BOOST_CFLAGS], [])
4303 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4304 AC_MSG_RESULT([yes])
4305 ], [
4306 ac_have_boost_1_35=no
4307 AC_MSG_RESULT([no])
4310 LIBS="$safe_LIBS"
4311 CXXFLAGS=$safe_CXXFLAGS
4312 AC_LANG(C)
4314 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4317 # does this compiler support -fopenmp, does it have the include file
4318 # <omp.h> and does it have libgomp ?
4320 AC_MSG_CHECKING([for OpenMP])
4322 safe_CFLAGS=$CFLAGS
4323 CFLAGS="-fopenmp $mflag_primary -Werror"
4325 AC_LINK_IFELSE([AC_LANG_SOURCE([
4326 #include <omp.h> 
4327 int main(int argc, char** argv)
4329   omp_set_dynamic(0);
4330   return 0;
4332 ])],
4334 ac_have_openmp=yes
4335 AC_MSG_RESULT([yes])
4336 ], [
4337 ac_have_openmp=no
4338 AC_MSG_RESULT([no])
4340 CFLAGS=$safe_CFLAGS
4342 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4345 # Check for __builtin_popcount
4346 AC_MSG_CHECKING([for __builtin_popcount()])
4347 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4348 ]], [[
4349   __builtin_popcount(2);
4350   return 0;
4351 ]])], [
4352 AC_MSG_RESULT([yes])
4353 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4354           [Define to 1 if compiler provides __builtin_popcount().])
4355 ], [
4356 AC_MSG_RESULT([no])
4359 # Check for __builtin_clz
4360 AC_MSG_CHECKING([for __builtin_clz()])
4361 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4362 ]], [[
4363   __builtin_clz(2);
4364   return 0;
4365 ]])], [
4366 AC_MSG_RESULT([yes])
4367 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4368           [Define to 1 if compiler provides __builtin_clz().])
4369 ], [
4370 AC_MSG_RESULT([no])
4373 # Check for __builtin_ctz
4374 AC_MSG_CHECKING([for __builtin_ctz()])
4375 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4376 ]], [[
4377   __builtin_ctz(2);
4378   return 0;
4379 ]])], [
4380 AC_MSG_RESULT([yes])
4381 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4382           [Define to 1 if compiler provides __builtin_ctz().])
4383 ], [
4384 AC_MSG_RESULT([no])
4387 # does this compiler have built-in functions for atomic memory access for the
4388 # primary target ?
4389 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4391 safe_CFLAGS=$CFLAGS
4392 CFLAGS="$mflag_primary"
4394 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4395   int variable = 1;
4396   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4397           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4398 ]])], [
4399   ac_have_builtin_atomic_primary=yes
4400   AC_MSG_RESULT([yes])
4401   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])
4402 ], [
4403   ac_have_builtin_atomic_primary=no
4404   AC_MSG_RESULT([no])
4407 CFLAGS=$safe_CFLAGS
4409 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4410                [test x$ac_have_builtin_atomic_primary = xyes])
4413 # does this compiler have built-in functions for atomic memory access for the
4414 # secondary target ?
4416 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4418 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
4420 safe_CFLAGS=$CFLAGS
4421 CFLAGS="$mflag_secondary"
4423 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4424   int variable = 1;
4425   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
4426 ]])], [
4427   ac_have_builtin_atomic_secondary=yes
4428   AC_MSG_RESULT([yes])
4429 ], [
4430   ac_have_builtin_atomic_secondary=no
4431   AC_MSG_RESULT([no])
4434 CFLAGS=$safe_CFLAGS
4438 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
4439                [test x$ac_have_builtin_atomic_secondary = xyes])
4441 # does this compiler have built-in functions for atomic memory access on
4442 # 64-bit integers for all targets ?
4444 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
4446 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4447   #include <stdint.h>
4448 ]], [[
4449   uint64_t variable = 1;
4450   return __sync_add_and_fetch(&variable, 1)
4451 ]])], [
4452   ac_have_builtin_atomic64_primary=yes
4453 ], [
4454   ac_have_builtin_atomic64_primary=no
4457 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4459 safe_CFLAGS=$CFLAGS
4460 CFLAGS="$mflag_secondary"
4462 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4463   #include <stdint.h>
4464 ]], [[
4465   uint64_t variable = 1;
4466   return __sync_add_and_fetch(&variable, 1)
4467 ]])], [
4468   ac_have_builtin_atomic64_secondary=yes
4469 ], [
4470   ac_have_builtin_atomic64_secondary=no
4473 CFLAGS=$safe_CFLAGS
4477 if test x$ac_have_builtin_atomic64_primary = xyes && \
4478    test x$VGCONF_PLATFORM_SEC_CAPS = x \
4479      -o x$ac_have_builtin_atomic64_secondary = xyes; then
4480   AC_MSG_RESULT([yes])
4481   ac_have_builtin_atomic64=yes
4482 else
4483   AC_MSG_RESULT([no])
4484   ac_have_builtin_atomic64=no
4487 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
4488                [test x$ac_have_builtin_atomic64 = xyes])
4491 # does g++ have built-in functions for atomic memory access ?
4492 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
4494 safe_CXXFLAGS=$CXXFLAGS
4495 CXXFLAGS="$mflag_primary"
4497 AC_LANG_PUSH(C++)
4498 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4499   int variable = 1;
4500   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4501           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4502 ]])], [
4503   ac_have_builtin_atomic_cxx=yes
4504   AC_MSG_RESULT([yes])
4505   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
4506 ], [
4507   ac_have_builtin_atomic_cxx=no
4508   AC_MSG_RESULT([no])
4510 AC_LANG_POP(C++)
4512 CXXFLAGS=$safe_CXXFLAGS
4514 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
4517 if test x$ac_have_usable_linux_futex_h = xyes \
4518         -a x$ac_have_builtin_atomic_primary = xyes; then
4519   ac_enable_linux_ticket_lock_primary=yes
4521 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
4522                [test x$ac_enable_linux_ticket_lock_primary = xyes])
4524 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
4525         -a x$ac_have_usable_linux_futex_h = xyes \
4526         -a x$ac_have_builtin_atomic_secondary = xyes; then
4527   ac_enable_linux_ticket_lock_secondary=yes
4529 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
4530                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
4533 # does libstdc++ support annotating shared pointers ?
4534 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
4536 safe_CXXFLAGS=$CXXFLAGS
4537 CXXFLAGS="-std=c++0x"
4539 AC_LANG_PUSH(C++)
4540 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4541   #include <memory>
4542 ]], [[
4543   std::shared_ptr<int> p
4544 ]])], [
4545   ac_have_shared_ptr=yes
4546 ], [
4547   ac_have_shared_ptr=no
4549 if test x$ac_have_shared_ptr = xyes; then
4550   # If compilation of the program below fails because of a syntax error
4551   # triggered by substituting one of the annotation macros then that
4552   # means that libstdc++ supports these macros.
4553   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4554     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
4555     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
4556     #include <memory>
4557   ]], [[
4558     std::shared_ptr<int> p
4559   ]])], [
4560     ac_have_shared_pointer_annotation=no
4561     AC_MSG_RESULT([no])
4562   ], [
4563     ac_have_shared_pointer_annotation=yes
4564     AC_MSG_RESULT([yes])
4565     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
4566               [Define to 1 if libstd++ supports annotating shared pointers])
4567   ])
4568 else
4569   ac_have_shared_pointer_annotation=no
4570   AC_MSG_RESULT([no])
4572 AC_LANG_POP(C++)
4574 CXXFLAGS=$safe_CXXFLAGS
4576 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
4577                [test x$ac_have_shared_pointer_annotation = xyes])
4580 #----------------------------------------------------------------------------
4581 # Ok.  We're done checking.
4582 #----------------------------------------------------------------------------
4584 # Nb: VEX/Makefile is generated from Makefile.vex.in.
4585 AC_CONFIG_FILES([
4586    Makefile 
4587    VEX/Makefile:Makefile.vex.in
4588    valgrind.spec
4589    valgrind.pc
4590    glibc-2.X.supp
4591    docs/Makefile 
4592    tests/Makefile 
4593    tests/vg_regtest 
4594    perf/Makefile 
4595    perf/vg_perf
4596    gdbserver_tests/Makefile
4597    gdbserver_tests/solaris/Makefile
4598    include/Makefile 
4599    auxprogs/Makefile
4600    mpi/Makefile
4601    coregrind/Makefile 
4602    memcheck/Makefile
4603    memcheck/tests/Makefile
4604    memcheck/tests/common/Makefile
4605    memcheck/tests/amd64/Makefile
4606    memcheck/tests/x86/Makefile
4607    memcheck/tests/linux/Makefile
4608    memcheck/tests/darwin/Makefile
4609    memcheck/tests/solaris/Makefile
4610    memcheck/tests/amd64-linux/Makefile
4611    memcheck/tests/arm64-linux/Makefile
4612    memcheck/tests/x86-linux/Makefile
4613    memcheck/tests/amd64-solaris/Makefile
4614    memcheck/tests/x86-solaris/Makefile
4615    memcheck/tests/ppc32/Makefile
4616    memcheck/tests/ppc64/Makefile
4617    memcheck/tests/s390x/Makefile
4618    memcheck/tests/mips32/Makefile
4619    memcheck/tests/mips64/Makefile
4620    memcheck/tests/vbit-test/Makefile
4621    cachegrind/Makefile
4622    cachegrind/tests/Makefile
4623    cachegrind/tests/x86/Makefile
4624    cachegrind/cg_annotate
4625    cachegrind/cg_diff
4626    callgrind/Makefile
4627    callgrind/callgrind_annotate
4628    callgrind/callgrind_control
4629    callgrind/tests/Makefile
4630    helgrind/Makefile
4631    helgrind/tests/Makefile
4632    drd/Makefile
4633    drd/scripts/download-and-build-splash2
4634    drd/tests/Makefile
4635    massif/Makefile
4636    massif/tests/Makefile
4637    massif/ms_print
4638    dhat/Makefile
4639    dhat/tests/Makefile
4640    lackey/Makefile
4641    lackey/tests/Makefile
4642    none/Makefile
4643    none/tests/Makefile
4644    none/tests/scripts/Makefile
4645    none/tests/amd64/Makefile
4646    none/tests/ppc32/Makefile
4647    none/tests/ppc64/Makefile
4648    none/tests/x86/Makefile
4649    none/tests/arm/Makefile
4650    none/tests/arm64/Makefile
4651    none/tests/s390x/Makefile
4652    none/tests/mips32/Makefile
4653    none/tests/mips64/Makefile
4654    none/tests/linux/Makefile
4655    none/tests/darwin/Makefile
4656    none/tests/solaris/Makefile
4657    none/tests/amd64-linux/Makefile
4658    none/tests/x86-linux/Makefile
4659    none/tests/amd64-darwin/Makefile
4660    none/tests/x86-darwin/Makefile
4661    none/tests/amd64-solaris/Makefile
4662    none/tests/x86-solaris/Makefile
4663    exp-sgcheck/Makefile
4664    exp-sgcheck/tests/Makefile
4665    exp-bbv/Makefile
4666    exp-bbv/tests/Makefile
4667    exp-bbv/tests/x86/Makefile
4668    exp-bbv/tests/x86-linux/Makefile
4669    exp-bbv/tests/amd64-linux/Makefile
4670    exp-bbv/tests/ppc32-linux/Makefile
4671    exp-bbv/tests/arm-linux/Makefile
4672    shared/Makefile
4673    solaris/Makefile
4675 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
4676                 [chmod +x coregrind/link_tool_exe_linux])
4677 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
4678                 [chmod +x coregrind/link_tool_exe_darwin])
4679 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
4680                 [chmod +x coregrind/link_tool_exe_solaris])
4681 AC_OUTPUT
4683 cat<<EOF
4685          Maximum build arch: ${ARCH_MAX}
4686          Primary build arch: ${VGCONF_ARCH_PRI}
4687        Secondary build arch: ${VGCONF_ARCH_SEC}
4688                    Build OS: ${VGCONF_OS}
4689      Link Time Optimisation: ${vg_cv_lto}
4690        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
4691      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
4692            Platform variant: ${VGCONF_PLATVARIANT}
4693       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
4694          Default supp files: ${DEFAULT_SUPP}