-> 3.17.0 final.
[valgrind.git] / configure.ac
bloba3584c93ae928a574e2199e2d626988905517fc4
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.17.0],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign dist-bzip2 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         ;;
289      nanomips)
290         AC_MSG_RESULT([ok (${host_cpu})])
291         ARCH_MAX="nanomips"
292         ;;
294      *) 
295         AC_MSG_RESULT([no (${host_cpu})])
296         AC_MSG_ERROR([Unsupported host architecture. Sorry])
297         ;;
298 esac
300 #----------------------------------------------------------------------------
302 # Sometimes it's convenient to subvert the bi-arch build system and
303 # just have a single build even though the underlying platform is
304 # capable of both.  Hence handle --enable-only64bit and
305 # --enable-only32bit.  Complain if both are issued :-)
306 # [Actually, if either of these options are used, I think both get built,
307 # but only one gets installed.  So if you use an in-place build, both can be
308 # used. --njn]
310 # Check if a 64-bit only build has been requested
311 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
312    [AC_ARG_ENABLE(only64bit, 
313       [  --enable-only64bit      do a 64-bit only build],
314       [vg_cv_only64bit=$enableval],
315       [vg_cv_only64bit=no])])
317 # Check if a 32-bit only build has been requested
318 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
319    [AC_ARG_ENABLE(only32bit, 
320       [  --enable-only32bit      do a 32-bit only build],
321       [vg_cv_only32bit=$enableval],
322       [vg_cv_only32bit=no])])
324 # Stay sane
325 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
326    AC_MSG_ERROR(
327       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
330 #----------------------------------------------------------------------------
332 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
333 # compilation of many C files via -VGO_$(VGCONF_OS) and
334 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
335 AC_MSG_CHECKING([for a supported OS])
336 AC_SUBST(VGCONF_OS)
338 DEFAULT_SUPP=""
340 case "${host_os}" in
341      *linux*)
342         AC_MSG_RESULT([ok (${host_os})])
343         VGCONF_OS="linux"
345         # Ok, this is linux. Check the kernel version
346         AC_MSG_CHECKING([for the kernel version])
348         kernel=`uname -r`
350         case "${kernel}" in
351              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
352                     AC_MSG_RESULT([unsupported (${kernel})])
353                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
354                     ;;
356              *)
357                     AC_MSG_RESULT([2.6 or later (${kernel})])
358                     ;;
359         esac
361         ;;
363      *darwin*)
364         AC_MSG_RESULT([ok (${host_os})])
365         VGCONF_OS="darwin"
366         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
367         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
368         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
369         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
370         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
371         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
372         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
373         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
374         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
376         AC_MSG_CHECKING([for the kernel version])
377         kernel=`uname -r`
379         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
380         # has only one relevant version, the OS version. The `uname` check
381         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
382         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
383         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
384         # and we don't know of an macros similar to __GLIBC__ to get that info.
385         #
386         # XXX: `uname -r` won't do the right thing for cross-compiles, but
387         # that's not a problem yet.
388         #
389         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
390         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
391         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
392         # time support for 10.5 (the 9.* pattern just below), I'll leave it
393         # in for now, just in case anybody wants to give it a try.  But I'm
394         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
395         case "${kernel}" in
396              9.*)
397                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
398                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
399                   DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
400                   DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
401                   ;;
402              10.*)
403                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
404                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
405                   DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
406                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
407                   ;;
408              11.*)
409                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
410                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
411                   DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
412                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
413                   ;;
414              12.*)
415                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
416                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
417                   DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
418                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
419                   ;;
420              13.*)
421                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
422                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
423                   DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
424                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
425                   ;;
426              14.*)
427                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
428                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
429                   DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
430                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
431                   ;;
432              15.*)
433                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
434                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
435                   DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
436                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
437                   ;;
438              16.*)
439                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
440                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
441                   DEFAULT_SUPP="darwin16.supp ${DEFAULT_SUPP}"
442                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
443                   ;;
444              17.*)
445                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
446                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
447                   DEFAULT_SUPP="darwin17.supp ${DEFAULT_SUPP}"
448                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
449                   ;;
450              *) 
451                   AC_MSG_RESULT([unsupported (${kernel})])
452                   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)])
453                   ;;
454         esac
455         ;;
457      solaris2.11*)
458         AC_MSG_RESULT([ok (${host_os})])
459         VGCONF_OS="solaris"
461         uname_v=$( uname -v )
462         case "$uname_v" in
463              11.4.*)
464                  DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
465                  ;;
466              *)
467                  DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
468                  ;;
469         esac
470         ;;
472      solaris2.12*)
473         AC_MSG_RESULT([ok (${host_os})])
474         VGCONF_OS="solaris"
475         DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
476         ;;
478      *) 
479         AC_MSG_RESULT([no (${host_os})])
480         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
481         ;;
482 esac
484 #----------------------------------------------------------------------------
486 # If we are building on a 64 bit platform test to see if the system
487 # supports building 32 bit programs and disable 32 bit support if it
488 # does not support building 32 bit programs
490 case "$ARCH_MAX-$VGCONF_OS" in
491      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
492         AC_MSG_CHECKING([for 32 bit build support])
493         safe_CFLAGS=$CFLAGS
494         CFLAGS="-m32"
495         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
496           return 0;
497         ]])], [
498         AC_MSG_RESULT([yes])
499         ], [
500         vg_cv_only64bit="yes"
501         AC_MSG_RESULT([no])
502         ])
503         CFLAGS=$safe_CFLAGS;;
504     mips64-linux)
505         AC_MSG_CHECKING([for 32 bit build support])
506         safe_CFLAGS=$CFLAGS
507         CFLAGS="$CFLAGS -mips32 -mabi=32"
508         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
509           #include <sys/prctl.h>
510         ]], [[]])], [
511         AC_MSG_RESULT([yes])
512         ], [
513         vg_cv_only64bit="yes"
514         AC_MSG_RESULT([no])
515         ])
516         CFLAGS=$safe_CFLAGS;;
517 esac
519 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
520    AC_MSG_ERROR(
521       [--enable-only32bit was specified but system does not support 32 bit builds])
524 #----------------------------------------------------------------------------
526 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
527 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
528 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
529 # above) will be "amd64" since that reflects the most that this cpu can do,
530 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
531 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
532 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
533 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
534 AC_SUBST(VGCONF_ARCH_PRI)
536 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
537 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
538 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
539 # It is empty if there is no secondary target.
540 AC_SUBST(VGCONF_ARCH_SEC)
542 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
543 # The entire system, including regression and performance tests, will be
544 # built for this target.  The "_CAPS" indicates that the name is in capital
545 # letters, and it also uses '_' rather than '-' as a separator, because it's
546 # used to create various Makefile variables, which are all in caps by
547 # convention and cannot contain '-' characters.  This is in contrast to
548 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
549 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
551 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
552 # Valgrind and tools will also be built for this target, but not the
553 # regression or performance tests.
555 # By default, the primary arch is the same as the "max" arch, as commented
556 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
557 # the big case statement just below here, in the case where we're building
558 # on a 64 bit machine but have been requested only to do a 32 bit build.
559 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
561 AC_MSG_CHECKING([for a supported CPU/OS combination])
563 # NB.  The load address for a given platform may be specified in more 
564 # than one place, in some cases, depending on whether we're doing a biarch,
565 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
566 # Be careful to give consistent values in all subcases.  Also, all four
567 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
568 # even if it is to "0xUNSET".
570 case "$ARCH_MAX-$VGCONF_OS" in
571      x86-linux)
572         VGCONF_ARCH_PRI="x86"
573         VGCONF_ARCH_SEC=""
574         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
575         VGCONF_PLATFORM_SEC_CAPS=""
576         valt_load_address_pri_norml="0x58000000"
577         valt_load_address_pri_inner="0x38000000"
578         valt_load_address_sec_norml="0xUNSET"
579         valt_load_address_sec_inner="0xUNSET"
580         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
581         ;;
582      amd64-linux)
583         valt_load_address_sec_norml="0xUNSET"
584         valt_load_address_sec_inner="0xUNSET"
585         if test x$vg_cv_only64bit = xyes; then
586            VGCONF_ARCH_PRI="amd64"
587            VGCONF_ARCH_SEC=""
588            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
589            VGCONF_PLATFORM_SEC_CAPS=""
590            valt_load_address_pri_norml="0x58000000"
591            valt_load_address_pri_inner="0x38000000"
592         elif test x$vg_cv_only32bit = xyes; then
593            VGCONF_ARCH_PRI="x86"
594            VGCONF_ARCH_SEC=""
595            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
596            VGCONF_PLATFORM_SEC_CAPS=""
597            valt_load_address_pri_norml="0x58000000"
598            valt_load_address_pri_inner="0x38000000"
599         else
600            VGCONF_ARCH_PRI="amd64"
601            VGCONF_ARCH_SEC="x86"
602            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
603            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
604            valt_load_address_pri_norml="0x58000000"
605            valt_load_address_pri_inner="0x38000000"
606            valt_load_address_sec_norml="0x58000000"
607            valt_load_address_sec_inner="0x38000000"
608         fi
609         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
610         ;;
611      ppc32-linux)
612         VGCONF_ARCH_PRI="ppc32"
613         VGCONF_ARCH_SEC=""
614         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
615         VGCONF_PLATFORM_SEC_CAPS=""
616         valt_load_address_pri_norml="0x58000000"
617         valt_load_address_pri_inner="0x38000000"
618         valt_load_address_sec_norml="0xUNSET"
619         valt_load_address_sec_inner="0xUNSET"
620         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
621         ;;
622      ppc64be-linux)
623         valt_load_address_sec_norml="0xUNSET"
624         valt_load_address_sec_inner="0xUNSET"
625         if test x$vg_cv_only64bit = xyes; then
626            VGCONF_ARCH_PRI="ppc64be"
627            VGCONF_ARCH_SEC=""
628            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
629            VGCONF_PLATFORM_SEC_CAPS=""
630            valt_load_address_pri_norml="0x58000000"
631            valt_load_address_pri_inner="0x38000000"
632         elif test x$vg_cv_only32bit = xyes; then
633            VGCONF_ARCH_PRI="ppc32"
634            VGCONF_ARCH_SEC=""
635            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
636            VGCONF_PLATFORM_SEC_CAPS=""
637            valt_load_address_pri_norml="0x58000000"
638            valt_load_address_pri_inner="0x38000000"
639         else
640            VGCONF_ARCH_PRI="ppc64be"
641            VGCONF_ARCH_SEC="ppc32"
642            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
643            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
644            valt_load_address_pri_norml="0x58000000"
645            valt_load_address_pri_inner="0x38000000"
646            valt_load_address_sec_norml="0x58000000"
647            valt_load_address_sec_inner="0x38000000"
648         fi
649         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
650         ;;
651      ppc64le-linux)
652         # Little Endian is only supported on PPC64
653         valt_load_address_sec_norml="0xUNSET"
654         valt_load_address_sec_inner="0xUNSET"
655         VGCONF_ARCH_PRI="ppc64le"
656         VGCONF_ARCH_SEC=""
657         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
658         VGCONF_PLATFORM_SEC_CAPS=""
659         valt_load_address_pri_norml="0x58000000"
660         valt_load_address_pri_inner="0x38000000"
661         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
662        ;;
663      # Darwin gets identified as 32-bit even when it supports 64-bit.
664      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
665      # all Macs support both 32-bit and 64-bit, so we just build both.  If
666      # someone has a really old 32-bit only machine they can (hopefully?)
667      # build with --enable-only32bit.  See bug 243362.
668      x86-darwin|amd64-darwin)
669         ARCH_MAX="amd64"
670         valt_load_address_sec_norml="0xUNSET"
671         valt_load_address_sec_inner="0xUNSET"
672         if test x$vg_cv_only64bit = xyes; then
673            VGCONF_ARCH_PRI="amd64"
674            VGCONF_ARCH_SEC=""
675            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
676            VGCONF_PLATFORM_SEC_CAPS=""
677            valt_load_address_pri_norml="0x158000000"
678            valt_load_address_pri_inner="0x138000000"
679         elif test x$vg_cv_only32bit = xyes; then
680            VGCONF_ARCH_PRI="x86"
681            VGCONF_ARCH_SEC=""
682            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
683            VGCONF_PLATFORM_SEC_CAPS=""
684            VGCONF_ARCH_PRI_CAPS="x86"
685            valt_load_address_pri_norml="0x58000000"
686            valt_load_address_pri_inner="0x38000000"
687         else
688            VGCONF_ARCH_PRI="amd64"
689            VGCONF_ARCH_SEC="x86"
690            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
691            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
692            valt_load_address_pri_norml="0x158000000"
693            valt_load_address_pri_inner="0x138000000"
694            valt_load_address_sec_norml="0x58000000"
695            valt_load_address_sec_inner="0x38000000"
696         fi
697         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
698         ;;
699      arm-linux) 
700         VGCONF_ARCH_PRI="arm"
701         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
702         VGCONF_PLATFORM_SEC_CAPS=""
703         valt_load_address_pri_norml="0x58000000"
704         valt_load_address_pri_inner="0x38000000"
705         valt_load_address_sec_norml="0xUNSET"
706         valt_load_address_sec_inner="0xUNSET"
707         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
708         ;;
709      arm64-linux)
710         valt_load_address_sec_norml="0xUNSET"
711         valt_load_address_sec_inner="0xUNSET"
712         if test x$vg_cv_only64bit = xyes; then
713            VGCONF_ARCH_PRI="arm64"
714            VGCONF_ARCH_SEC=""
715            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
716            VGCONF_PLATFORM_SEC_CAPS=""
717            valt_load_address_pri_norml="0x58000000"
718            valt_load_address_pri_inner="0x38000000"
719         elif test x$vg_cv_only32bit = xyes; then
720            VGCONF_ARCH_PRI="arm"
721            VGCONF_ARCH_SEC=""
722            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
723            VGCONF_PLATFORM_SEC_CAPS=""
724            valt_load_address_pri_norml="0x58000000"
725            valt_load_address_pri_inner="0x38000000"
726         else
727            VGCONF_ARCH_PRI="arm64"
728            VGCONF_ARCH_SEC="arm"
729            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
730            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
731            valt_load_address_pri_norml="0x58000000"
732            valt_load_address_pri_inner="0x38000000"
733            valt_load_address_sec_norml="0x58000000"
734            valt_load_address_sec_inner="0x38000000"
735         fi
736         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
737         ;;
738      s390x-linux)
739         VGCONF_ARCH_PRI="s390x"
740         VGCONF_ARCH_SEC=""
741         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
742         VGCONF_PLATFORM_SEC_CAPS=""
743         # To improve branch prediction hit rate we want to have
744         # the generated code close to valgrind (host) code
745         valt_load_address_pri_norml="0x800000000"
746         valt_load_address_pri_inner="0x810000000"
747         valt_load_address_sec_norml="0xUNSET"
748         valt_load_address_sec_inner="0xUNSET"
749         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
750         ;;
751      mips32-linux) 
752         VGCONF_ARCH_PRI="mips32"
753         VGCONF_ARCH_SEC=""
754         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
755         VGCONF_PLATFORM_SEC_CAPS=""
756         valt_load_address_pri_norml="0x58000000"
757         valt_load_address_pri_inner="0x38000000"
758         valt_load_address_sec_norml="0xUNSET"
759         valt_load_address_sec_inner="0xUNSET"
760         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
761         ;;
762      mips64-linux)
763         valt_load_address_sec_norml="0xUNSET"
764         valt_load_address_sec_inner="0xUNSET"
765         if test x$vg_cv_only64bit = xyes; then
766             VGCONF_ARCH_PRI="mips64"
767             VGCONF_PLATFORM_SEC_CAPS=""
768             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
769             VGCONF_PLATFORM_SEC_CAPS=""
770             valt_load_address_pri_norml="0x58000000"
771             valt_load_address_pri_inner="0x38000000"
772         elif test x$vg_cv_only32bit = xyes; then
773             VGCONF_ARCH_PRI="mips32"
774             VGCONF_ARCH_SEC=""
775             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
776             VGCONF_PLATFORM_SEC_CAPS=""
777             valt_load_address_pri_norml="0x58000000"
778             valt_load_address_pri_inner="0x38000000"
779         else
780             VGCONF_ARCH_PRI="mips64"
781             VGCONF_ARCH_SEC="mips32"
782             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
783             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
784             valt_load_address_pri_norml="0x58000000"
785             valt_load_address_pri_inner="0x38000000"
786             valt_load_address_sec_norml="0x58000000"
787             valt_load_address_sec_inner="0x38000000"
788         fi
789         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
790         ;;
791      nanomips-linux)
792         VGCONF_ARCH_PRI="nanomips"
793         VGCONF_ARCH_SEC=""
794         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
795         VGCONF_PLATFORM_SEC_CAPS=""
796         valt_load_address_pri_norml="0x58000000"
797         valt_load_address_pri_inner="0x38000000"
798         valt_load_address_sec_norml="0xUNSET"
799         valt_load_address_sec_inner="0xUNSET"
800         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
801         ;;
802      x86-solaris)
803         VGCONF_ARCH_PRI="x86"
804         VGCONF_ARCH_SEC=""
805         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
806         VGCONF_PLATFORM_SEC_CAPS=""
807         valt_load_address_pri_norml="0x58000000"
808         valt_load_address_pri_inner="0x38000000"
809         valt_load_address_sec_norml="0xUNSET"
810         valt_load_address_sec_inner="0xUNSET"
811         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
812         ;;
813      amd64-solaris)
814         valt_load_address_sec_norml="0xUNSET"
815         valt_load_address_sec_inner="0xUNSET"
816         if test x$vg_cv_only64bit = xyes; then
817            VGCONF_ARCH_PRI="amd64"
818            VGCONF_ARCH_SEC=""
819            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
820            VGCONF_PLATFORM_SEC_CAPS=""
821            valt_load_address_pri_norml="0x58000000"
822            valt_load_address_pri_inner="0x38000000"
823         elif test x$vg_cv_only32bit = xyes; then
824            VGCONF_ARCH_PRI="x86"
825            VGCONF_ARCH_SEC=""
826            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
827            VGCONF_PLATFORM_SEC_CAPS=""
828            valt_load_address_pri_norml="0x58000000"
829            valt_load_address_pri_inner="0x38000000"
830         else
831            VGCONF_ARCH_PRI="amd64"
832            VGCONF_ARCH_SEC="x86"
833            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
834            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
835            valt_load_address_pri_norml="0x58000000"
836            valt_load_address_pri_inner="0x38000000"
837            valt_load_address_sec_norml="0x58000000"
838            valt_load_address_sec_inner="0x38000000"
839         fi
840         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
841         ;;
842     *)
843         VGCONF_ARCH_PRI="unknown"
844         VGCONF_ARCH_SEC="unknown"
845         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
846         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
847         valt_load_address_pri_norml="0xUNSET"
848         valt_load_address_pri_inner="0xUNSET"
849         valt_load_address_sec_norml="0xUNSET"
850         valt_load_address_sec_inner="0xUNSET"
851         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
852         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
853         ;;
854 esac
856 #----------------------------------------------------------------------------
858 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
859 # defined.
860 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
861                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
862                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
863                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
864                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
865                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
866                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
867 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
868                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
869                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
870                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
871 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
872                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
873                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
874 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
875                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
876                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
877 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
878                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
879                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
880 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
881                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
882 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
883                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
884 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
885                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
886                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
887 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
888                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
889 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
890                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
892 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
893 # become defined.
894 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
895                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
896                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
897 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
898                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
899 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
900                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
901                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
902 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
903                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
904 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
905                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
906 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
907                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
908                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
909 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
910                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
911 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
912                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
913                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
914 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
915                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
916                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
917 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
918                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
919 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
920                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
921 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,   
922                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
923                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
924 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
925                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
926 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
927                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
928                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
929 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
930                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
933 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
934 # Relies on the assumption that the primary and secondary targets are 
935 # for the same OS, so therefore only necessary to test the primary.
936 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
937                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
938                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
939                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
940                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
941                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
942                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
943                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
944                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
945                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
946                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
947                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
948 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
949                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
950                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
951 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
952                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
953                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
956 # Sometimes, in the Makefile.am files, it's useful to know whether or not
957 # there is a secondary target.
958 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
959                test x$VGCONF_PLATFORM_SEC_CAPS != x)
961 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
962 dnl fallback definition
963 dnl The macro is courtesy of Dave Hart:
964 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
965 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
966 if test -z "$$1_TRUE"; then :
967   m4_n([$2])[]dnl
968 m4_ifval([$3],
969 [else
970   $3
971 ])dnl
972 fi[]dnl
973 ])])
975 #----------------------------------------------------------------------------
976 # Inner Valgrind?
977 #----------------------------------------------------------------------------
979 # Check if this should be built as an inner Valgrind, to be run within
980 # another Valgrind.  Choose the load address accordingly.
981 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
982 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
983 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
984    [AC_ARG_ENABLE(inner, 
985       [  --enable-inner          enables self-hosting],
986       [vg_cv_inner=$enableval],
987       [vg_cv_inner=no])])
988 if test "$vg_cv_inner" = yes; then
989     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
990     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
991     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
992 else
993     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
994     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
997 #----------------------------------------------------------------------------
998 # Undefined behaviour sanitiser
999 #----------------------------------------------------------------------------
1000 # Check whether we should build with the undefined beahviour sanitiser.
1002 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1003    [AC_ARG_ENABLE(ubsan, 
1004       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1005       [vg_cv_ubsan=$enableval],
1006       [vg_cv_ubsan=no])])
1008 #----------------------------------------------------------------------------
1009 # Extra fine-tuning of installation directories
1010 #----------------------------------------------------------------------------
1011 AC_ARG_WITH(tmpdir,
1012    [  --with-tmpdir=PATH      Specify path for temporary files],
1013    tmpdir="$withval",
1014    tmpdir="/tmp")
1015 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1016 AC_SUBST(VG_TMPDIR, [$tmpdir])
1018 #----------------------------------------------------------------------------
1019 # Detect xcode path
1020 #----------------------------------------------------------------------------
1021 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1022 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1023 AC_MSG_CHECKING([for xcode sdk include path])
1024 AC_ARG_WITH(xcodedir,
1025    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1026    [xcodedir="$withval"],
1027    [
1028       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1029          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1030          if test -z "$xcrundir"; then
1031             xcodedir="/usr/include"
1032          else
1033             xcodedir="$xcrundir/usr/include"
1034          fi
1035       else
1036          xcodedir="/usr/include"
1037       fi
1038    ])
1039 AC_MSG_RESULT([$xcodedir])
1040 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1041 AC_SUBST(XCODE_DIR, [$xcodedir])])
1043 #----------------------------------------------------------------------------
1044 # Libc and suppressions
1045 #----------------------------------------------------------------------------
1046 # This variable will collect the suppression files to be used.
1047 AC_SUBST(DEFAULT_SUPP)
1049 AC_CHECK_HEADER([features.h])
1051 if test x$ac_cv_header_features_h = xyes; then
1052   rm -f conftest.$ac_ext
1053   cat <<_ACEOF >conftest.$ac_ext
1054 #include <features.h>
1055 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1056 glibc version is: __GLIBC__ __GLIBC_MINOR__
1057 #endif
1058 _ACEOF
1059   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1062 # not really a version check
1063 AC_EGREP_CPP([DARWIN_LIBC], [
1064 #include <sys/cdefs.h>
1065 #if defined(__DARWIN_VERS_1050)
1066   DARWIN_LIBC
1067 #endif
1069 GLIBC_VERSION="darwin")
1071 # not really a version check
1072 AC_EGREP_CPP([BIONIC_LIBC], [
1073 #if defined(__ANDROID__)
1074   BIONIC_LIBC
1075 #endif
1077 GLIBC_VERSION="bionic")
1079 # there is only one version of libc on Solaris
1080 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1081      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1082     GLIBC_VERSION="solaris"
1085 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1086 # in this case.
1087 if test x$GLIBC_VERSION = x; then
1088     if $CC -dumpmachine | grep -q musl; then
1089         GLIBC_VERSION=musl
1090     fi
1093 AC_MSG_CHECKING([the glibc version])
1095 case "${GLIBC_VERSION}" in
1096      2.2)
1097         AC_MSG_RESULT(${GLIBC_VERSION} family)
1098         DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1099         DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1100         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1101         ;;
1102      2.[[3-6]])
1103         AC_MSG_RESULT(${GLIBC_VERSION} family)
1104         DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1105         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1106         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1107         ;;
1108      2.[[7-9]])
1109         AC_MSG_RESULT(${GLIBC_VERSION} family)
1110         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1111         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1112         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1113         ;;
1114      2.10|2.11)
1115         AC_MSG_RESULT(${GLIBC_VERSION} family)
1116         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1117                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1118         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1119         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1120         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1121         ;;
1122      2.*)
1123         AC_MSG_RESULT(${GLIBC_VERSION} family)
1124         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1125                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1126         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1127                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1128         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1129         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1130         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1131         ;;
1132      darwin)
1133         AC_MSG_RESULT(Darwin)
1134         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1135         # DEFAULT_SUPP set by kernel version check above.
1136         ;;
1137      bionic)
1138         AC_MSG_RESULT(Bionic)
1139         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1140         DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1141         ;;
1142      solaris)
1143         AC_MSG_RESULT(Solaris)
1144         # DEFAULT_SUPP set in host_os switch-case above.
1145         # No other suppression file is used.
1146         ;;
1147      musl)
1148         AC_MSG_RESULT(Musl)
1149         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1150         DEFAULT_SUPP="musl.supp ${DEFAULT_SUPP}"
1151         ;;
1152      2.0|2.1|*)
1153         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1154         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1155         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1156         ;;
1157 esac
1159 AC_SUBST(GLIBC_VERSION)
1162 if test "$VGCONF_OS" != "solaris"; then
1163     # Add default suppressions for the X client libraries.  Make no
1164     # attempt to detect whether such libraries are installed on the
1165     # build machine (or even if any X facilities are present); just
1166     # add the suppressions antidisirregardless.
1167     DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1168     DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1172 #----------------------------------------------------------------------------
1173 # Platform variants?
1174 #----------------------------------------------------------------------------
1176 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1177 # But there are times where we need a bit more control.  The motivating
1178 # and currently only case is Android: this is almost identical to
1179 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1180 # platform variant tags, which get passed in the compile as
1181 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1183 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1184 # it is "android" instead.
1186 # Consequently (eg), plain arm-linux would build with
1188 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1190 # whilst an Android build would have
1192 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1194 # Same for x86. The setup of the platform variant is pushed relatively far
1195 # down this file in order that we can inspect any of the variables set above.
1197 # In the normal case ..
1198 VGCONF_PLATVARIANT="vanilla"
1200 # Android ?
1201 if test "$GLIBC_VERSION" = "bionic";
1202 then
1203    VGCONF_PLATVARIANT="android"
1206 AC_SUBST(VGCONF_PLATVARIANT)
1209 # FIXME: do we also want to define automake variables
1210 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1211 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1212 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1213 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1214 # that's what we'd need to do to use this, since what we'd want to write
1215 # is something like
1217 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1219 # Hmm.  Can't think of a nice clean solution to this.
1221 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1222                test x$VGCONF_PLATVARIANT = xvanilla)
1223 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1224                test x$VGCONF_PLATVARIANT = xandroid)
1227 #----------------------------------------------------------------------------
1228 # Checking for various library functions and other definitions
1229 #----------------------------------------------------------------------------
1231 # Check for AT_FDCWD
1233 AC_MSG_CHECKING([for AT_FDCWD])
1234 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1235 #define _GNU_SOURCE
1236 #include <fcntl.h>
1237 #include <unistd.h>
1238 ]], [[
1239   int a = AT_FDCWD;
1240 ]])], [
1241 ac_have_at_fdcwd=yes
1242 AC_MSG_RESULT([yes])
1243 ], [
1244 ac_have_at_fdcwd=no
1245 AC_MSG_RESULT([no])
1248 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1250 # Check for stpncpy function definition in string.h
1251 # This explicitly checks with _GNU_SOURCE defined since that is also
1252 # used in the test case (some systems might define it without anyway
1253 # since stpncpy is part of The Open Group Base Specifications Issue 7
1254 # IEEE Std 1003.1-2008.
1255 AC_MSG_CHECKING([for stpncpy])
1256 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1257 #define _GNU_SOURCE
1258 #include <string.h>
1259 ]], [[
1260   char *d;
1261   char *s;
1262   size_t n = 0;
1263   char *r = stpncpy(d, s, n);
1264 ]])], [
1265 ac_have_gnu_stpncpy=yes
1266 AC_MSG_RESULT([yes])
1267 ], [
1268 ac_have_gnu_stpncpy=no
1269 AC_MSG_RESULT([no])
1272 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1274 # Check for PTRACE_GETREGS
1276 AC_MSG_CHECKING([for PTRACE_GETREGS])
1277 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1278 #include <stdlib.h>
1279 #include <stddef.h>
1280 #include <sys/ptrace.h>
1281 #include <sys/user.h>
1282 ]], [[
1283   void *p;
1284   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1285 ]])], [
1286 AC_MSG_RESULT([yes])
1287 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1288           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1289 ], [
1290 AC_MSG_RESULT([no])
1294 # Check for CLOCK_MONOTONIC
1296 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1298 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1299 #include <time.h>
1300 ]], [[
1301   struct timespec t;
1302   clock_gettime(CLOCK_MONOTONIC, &t);
1303   return 0;
1304 ]])], [
1305 AC_MSG_RESULT([yes])
1306 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1307           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1308 ], [
1309 AC_MSG_RESULT([no])
1313 # Check for ELF32/64_CHDR
1315 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1318 # Check for PTHREAD_RWLOCK_T
1320 AC_MSG_CHECKING([for pthread_rwlock_t])
1322 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1323 #define _GNU_SOURCE
1324 #include <pthread.h>
1325 ]], [[
1326   pthread_rwlock_t rwl;
1327 ]])], [
1328 AC_MSG_RESULT([yes])
1329 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1330           [Define to 1 if you have the `pthread_rwlock_t' type.])
1331 ], [
1332 AC_MSG_RESULT([no])
1336 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1338 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1340 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1341 #define _GNU_SOURCE
1342 #include <pthread.h>
1343 ]], [[
1344   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1345 ]])], [
1346 AC_MSG_RESULT([yes])
1347 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1348           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1349 ], [
1350 AC_MSG_RESULT([no])
1354 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1356 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1358 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1359 #define _GNU_SOURCE
1360 #include <pthread.h>
1361 ]], [[
1362   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1363 ]])], [
1364 AC_MSG_RESULT([yes])
1365 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1366           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1367 ], [
1368 AC_MSG_RESULT([no])
1372 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1374 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1377 #define _GNU_SOURCE
1378 #include <pthread.h>
1379 ]], [[
1380   return (PTHREAD_MUTEX_RECURSIVE_NP);
1381 ]])], [
1382 AC_MSG_RESULT([yes])
1383 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1384           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1385 ], [
1386 AC_MSG_RESULT([no])
1390 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1392 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1394 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1395 #define _GNU_SOURCE
1396 #include <pthread.h>
1397 ]], [[
1398   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1399   return 0;
1400 ]])], [
1401 AC_MSG_RESULT([yes])
1402 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1403           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1404 ], [
1405 AC_MSG_RESULT([no])
1409 # Check whether pthread_mutex_t has a member called __m_kind.
1411 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1412                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1413                            1,                                   
1414                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1415                 ],
1416                 [],
1417                 [#include <pthread.h>])
1420 # Check whether pthread_mutex_t has a member called __data.__kind.
1422 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1423                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1424                           1,
1425                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1426                 ],
1427                 [],
1428                 [#include <pthread.h>])
1430 # Convenience function.  Set flags based on the existing HWCAP entries.
1431 # The AT_HWCAP entries are generated by glibc, and are based on
1432 # functions supported by the hardware/system/libc.
1433 # Subsequent support for whether the capability will actually be utilized
1434 # will also be checked against the compiler capabilities.
1435 # called as
1436 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1437 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1438   AUXV_CHECK_FOR=$1
1439   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1440   if LD_SHOW_AUXV=1 `which true` | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1441   then
1442     AC_MSG_RESULT([yes])
1443     AC_SUBST([$2],[yes])
1444   else
1445     AC_MSG_RESULT([no])
1446     AC_SUBST([$2],[])
1447   fi
1450 # gather hardware capabilities. (hardware/kernel/libc)
1451 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1452 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1453 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1454 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1455 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1456 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1457 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1458 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1459 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1460 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1462 # ISA Levels
1463 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1464 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1465 # compiler support for isa 2.07 level instructions
1466 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1467 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1468 ]], [[
1469   __asm__ __volatile__("mtvsrd 1,2 ");
1470 ]])], [
1471 ac_asm_have_isa_2_07=yes
1472 AC_MSG_RESULT([yes])
1473 ], [
1474 ac_asm_have_isa_2_07=no
1475 AC_MSG_RESULT([no])
1477 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1478                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1480 # altivec (vsx) support.
1481 # does this compiler support -maltivec and does it have the include file
1482 # <altivec.h> ?
1483 AC_MSG_CHECKING([for Altivec support in the compiler ])
1484 safe_CFLAGS=$CFLAGS
1485 CFLAGS="-maltivec -Werror"
1486 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1487 #include <altivec.h>
1488 ]], [[
1489   vector unsigned int v;
1490 ]])], [
1491 ac_have_altivec=yes
1492 AC_MSG_RESULT([yes])
1493 ], [
1494 ac_have_altivec=no
1495 AC_MSG_RESULT([no])
1497 CFLAGS=$safe_CFLAGS
1498 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1499                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1501 # Check that both: the compiler supports -mvsx and that the assembler
1502 # understands VSX instructions.  If either of those doesn't work,
1503 # conclude that we can't do VSX.
1504 AC_MSG_CHECKING([for VSX compiler flag support])
1505 safe_CFLAGS=$CFLAGS
1506 CFLAGS="-mvsx -Werror"
1507 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1508 ]], [[
1509 ]])], [
1510 ac_compiler_supports_vsx_flag=yes
1511 AC_MSG_RESULT([yes])
1512 ], [
1513 ac_compiler_supports_vsx_flag=no
1514 AC_MSG_RESULT([no])
1516 CFLAGS=$safe_CFLAGS
1518 AC_MSG_CHECKING([for VSX support in the assembler ])
1519 safe_CFLAGS=$CFLAGS
1520 CFLAGS="-mvsx -Werror"
1521 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1522 #include <altivec.h>
1523 ]], [[
1524   vector unsigned int v;
1525   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1526 ]])], [
1527 ac_compiler_supports_vsx=yes
1528 AC_MSG_RESULT([yes])
1529 ], [
1530 ac_compiler_supports_vsx=no
1531 AC_MSG_RESULT([no])
1533 CFLAGS=$safe_CFLAGS
1534 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1535                              -a x$ac_compiler_supports_vsx = xyes \
1536                              -a x$HWCAP_HAS_VSX = xyes ])
1538 # DFP (Decimal Float)
1539 AC_MSG_CHECKING([that assembler knows DFP])
1540 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1541 ]], [[
1542   #ifdef __s390__
1543   __asm__ __volatile__("adtr 1, 2, 3")
1544   #else
1545   __asm__ __volatile__("dadd 1, 2, 3");
1546   __asm__ __volatile__("dcffix 1, 2");
1547   #endif
1548 ]])], [
1549 ac_asm_have_dfp=yes
1550 AC_MSG_RESULT([yes])
1551 ], [
1552 ac_asm_have_dfp=no
1553 AC_MSG_RESULT([no])
1555 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1556 safe_CFLAGS=$CFLAGS
1557 CFLAGS="-mhard-dfp -Werror"
1558 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1559 ]], [[
1560   #ifdef __s390__
1561   __asm__ __volatile__("adtr 1, 2, 3")
1562   #else
1563   __asm__ __volatile__("dadd 1, 2, 3");
1564   __asm__ __volatile__("dcffix 1, 2");
1565   #endif
1566 ]])], [
1567 ac_compiler_have_dfp=yes
1568 AC_MSG_RESULT([yes])
1569 ], [
1570 ac_compiler_have_dfp=no
1571 AC_MSG_RESULT([no])
1573 CFLAGS=$safe_CFLAGS
1574 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1575                           -a x$ac_compiler_have_dfp = xyes \
1576                           -a x$HWCAP_HAS_DFP = xyes )
1578 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1579 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1580 ]], [[
1581   _Decimal64 x = 0.0DD;
1582 ]])], [
1583 ac_compiler_have_dfp_type=yes
1584 AC_MSG_RESULT([yes])
1585 ], [
1586 ac_compiler_have_dfp_type=no
1587 AC_MSG_RESULT([no])
1589 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1590                                   -a x$HWCAP_HAS_DFP = xyes )
1593 # HTM (Hardware Transactional Memory)
1594 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1595 safe_CFLAGS=$CFLAGS
1596 CFLAGS="-mhtm -Werror"
1597 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1598 ]], [[
1599   return 0;
1600 ]])], [
1601 AC_MSG_RESULT([yes])
1602 ac_compiler_supports_htm=yes
1603 ], [
1604 AC_MSG_RESULT([no])
1605 ac_compiler_supports_htm=no
1607 CFLAGS=$safe_CFLAGS
1609 AC_MSG_CHECKING([if compiler can find the htm builtins])
1610 safe_CFLAGS=$CFLAGS
1611 CFLAGS="-mhtm -Werror"
1612  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1613  ]], [[
1614    if (__builtin_tbegin (0))
1615       __builtin_tend (0);
1616  ]])], [
1617  AC_MSG_RESULT([yes])
1618 ac_compiler_sees_htm_builtins=yes
1619  ], [
1620  AC_MSG_RESULT([no])
1621 ac_compiler_sees_htm_builtins=no
1622  ])
1623 CFLAGS=$safe_CFLAGS
1625 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1626                                -a x$ac_compiler_sees_htm_builtins = xyes \
1627                                -a x$HWCAP_HAS_HTM = xyes )
1629 # isa 3.0 checking. (actually 3.0 or newer)
1630 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1632 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1633 ]], [[
1634   __asm__ __volatile__("cnttzw 1,2 ");
1635 ]])], [
1636 ac_asm_have_isa_3_00=yes
1637 AC_MSG_RESULT([yes])
1638 ], [
1639 ac_asm_have_isa_3_00=no
1640 AC_MSG_RESULT([no])
1643 # xscvhpdp checking
1644 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1646 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1647 ]], [[
1648   __asm__ __volatile__("xscvhpdp 1,2 ");
1649 ]])], [
1650 ac_asm_have_xscvhpdp=yes
1651 AC_MSG_RESULT([yes])
1652 ], [
1653 ac_asm_have_xscvhpdp=no
1654 AC_MSG_RESULT([no])
1657 # isa 3.01 checking
1658 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1660 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1661 ]], [[
1662   __asm__ __volatile__("brh 1,2 ");
1663 ]])], [
1664 ac_asm_have_isa_3_1=yes
1665 AC_MSG_RESULT([yes])
1666 ], [
1667 ac_asm_have_isa_3_1=no
1668 AC_MSG_RESULT([no])
1672 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1673                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1675 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1677 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1678                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1680 # Check for pthread_create@GLIBC2.0
1681 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1683 safe_CFLAGS=$CFLAGS
1684 CFLAGS="-lpthread -Werror"
1685 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1686 extern int pthread_create_glibc_2_0(void*, const void*,
1687                                     void *(*)(void*), void*);
1688 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1689 ]], [[
1690 #ifdef __powerpc__
1692  * Apparently on PowerPC linking this program succeeds and generates an
1693  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1694  */
1695 #error This test does not work properly on PowerPC.
1696 #else
1697   pthread_create_glibc_2_0(0, 0, 0, 0);
1698 #endif
1699   return 0;
1700 ]])], [
1701 ac_have_pthread_create_glibc_2_0=yes
1702 AC_MSG_RESULT([yes])
1703 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1704           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1705 ], [
1706 ac_have_pthread_create_glibc_2_0=no
1707 AC_MSG_RESULT([no])
1709 CFLAGS=$safe_CFLAGS
1711 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1712                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1715 # Check for dlinfo RTLD_DI_TLS_MODID
1716 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1718 safe_LIBS="$LIBS"
1719 LIBS="-ldl"
1720 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1721 #ifndef _GNU_SOURCE
1722 #define _GNU_SOURCE
1723 #endif
1724 #include <link.h>
1725 #include <dlfcn.h>
1726 ]], [[
1727   size_t sizes[10000];
1728   size_t modid_offset;
1729   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1730   return 0;
1731 ]])], [
1732 ac_have_dlinfo_rtld_di_tls_modid=yes
1733 AC_MSG_RESULT([yes])
1734 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1735           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1736 ], [
1737 ac_have_dlinfo_rtld_di_tls_modid=no
1738 AC_MSG_RESULT([no])
1740 LIBS=$safe_LIBS
1742 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1743                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1746 # Check for eventfd_t, eventfd() and eventfd_read()
1747 AC_MSG_CHECKING([for eventfd()])
1749 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1750 #include <sys/eventfd.h>
1751 ]], [[
1752   eventfd_t ev;
1753   int fd;
1755   fd = eventfd(5, 0);
1756   eventfd_read(fd, &ev);
1757   return 0;
1758 ]])], [
1759 AC_MSG_RESULT([yes])
1760 AC_DEFINE([HAVE_EVENTFD], 1,
1761           [Define to 1 if you have the `eventfd' function.])
1762 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1763           [Define to 1 if you have the `eventfd_read' function.])
1764 ], [
1765 AC_MSG_RESULT([no])
1768 # Check whether compiler can process #include <thread> without errors
1769 # clang 3.3 cannot process <thread> from e.g.
1770 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1772 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1773 AC_LANG(C++)
1774 safe_CXXFLAGS=$CXXFLAGS
1775 CXXFLAGS=-std=c++0x
1777 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1778 #include <thread> 
1779 ])],
1781 ac_cxx_can_include_thread_header=yes
1782 AC_MSG_RESULT([yes])
1783 ], [
1784 ac_cxx_can_include_thread_header=no
1785 AC_MSG_RESULT([no])
1787 CXXFLAGS=$safe_CXXFLAGS
1788 AC_LANG(C)
1790 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1793 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1794 # of the user_regs_struct from sys/user.h. They are structurally the same
1795 # but we get either one or the other.
1797 AC_CHECK_TYPE([struct user_regs_struct],
1798               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1799               [[#include <sys/ptrace.h>]
1800                [#include <sys/time.h>]
1801                [#include <sys/user.h>]])
1802 if test "$sys_user_has_user_regs" = "yes"; then
1803   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1804             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1807 AC_MSG_CHECKING([for __NR_membarrier])
1808 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1809 #include <linux/unistd.h>
1810 ]], [[
1811 return __NR_membarrier
1812 ]])], [
1813 ac_have_nr_membarrier=yes
1814 AC_MSG_RESULT([yes])
1815 ], [
1816 ac_have_nr_membarrier=no
1817 AC_MSG_RESULT([no])
1820 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
1822 #----------------------------------------------------------------------------
1823 # Checking for supported compiler flags.
1824 #----------------------------------------------------------------------------
1826 case "${host_cpu}" in
1827     mips*)
1828         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1829         if test -z "$ARCH"; then
1830           # does this compiler support -march=mips32 (mips32 default) ?
1831           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
1833           safe_CFLAGS=$CFLAGS
1834           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
1836           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1837             return 0;
1838           ]])], [
1839           FLAG_M32="-mips32 -mabi=32"
1840           AC_MSG_RESULT([yes])
1841           ], [
1842           FLAG_M32=""
1843           AC_MSG_RESULT([no])
1844           ])
1845           CFLAGS=$safe_CFLAGS
1847           AC_SUBST(FLAG_M32)
1850           # does this compiler support -march=mips64r2 (mips64r2 default) ?
1851           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
1853           safe_CFLAGS=$CFLAGS
1854           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
1856           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1857             return 0;
1858           ]])], [
1859           FLAG_M64="-march=mips64r2 -mabi=64"
1860           AC_MSG_RESULT([yes])
1861           ], [
1862           FLAG_M64=""
1863           AC_MSG_RESULT([no])
1864           ])
1865           CFLAGS=$safe_CFLAGS
1867           AC_SUBST(FLAG_M64)
1868         fi
1869         ;;
1870     nanomips*)
1871         ;;
1872     *)
1873         # does this compiler support -m32 ?
1874         AC_MSG_CHECKING([if gcc accepts -m32])
1876         safe_CFLAGS=$CFLAGS
1877         CFLAGS="-m32 -Werror"
1879         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1880           return 0;
1881         ]])], [
1882         FLAG_M32="-m32"
1883         AC_MSG_RESULT([yes])
1884         ], [
1885         FLAG_M32=""
1886         AC_MSG_RESULT([no])
1887         ])
1888         CFLAGS=$safe_CFLAGS
1890         AC_SUBST(FLAG_M32)
1893         # does this compiler support -m64 ?
1894         AC_MSG_CHECKING([if gcc accepts -m64])
1896         safe_CFLAGS=$CFLAGS
1897         CFLAGS="-m64 -Werror"
1899         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1900           return 0;
1901         ]])], [
1902         FLAG_M64="-m64"
1903         AC_MSG_RESULT([yes])
1904         ], [
1905         FLAG_M64=""
1906         AC_MSG_RESULT([no])
1907         ])
1908         CFLAGS=$safe_CFLAGS
1910         AC_SUBST(FLAG_M64)
1911         ;;
1912 esac
1915 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1916 if test -z "$ARCH"; then
1917   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1918   AC_MSG_CHECKING([if gcc accepts -march=octeon])
1920   safe_CFLAGS=$CFLAGS
1921   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
1923   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1924     return 0;
1925   ]])], [
1926   FLAG_OCTEON="-march=octeon"
1927   AC_MSG_RESULT([yes])
1928   ], [
1929   FLAG_OCTEON=""
1930   AC_MSG_RESULT([no])
1931   ])
1932   CFLAGS=$safe_CFLAGS
1934   AC_SUBST(FLAG_OCTEON)
1937   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1938   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1940   safe_CFLAGS=$CFLAGS
1941   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
1943   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1944     return 0;
1945   ]])], [
1946   FLAG_OCTEON2="-march=octeon2"
1947   AC_MSG_RESULT([yes])
1948   ], [
1949   FLAG_OCTEON2=""
1950   AC_MSG_RESULT([no])
1951   ])
1952   CFLAGS=$safe_CFLAGS
1954   AC_SUBST(FLAG_OCTEON2)
1958 # does this compiler support -mmsa (MIPS MSA ASE) ?
1959 AC_MSG_CHECKING([if gcc accepts -mmsa])
1961 safe_CFLAGS=$CFLAGS
1962 CFLAGS="$CFLAGS -mmsa -Werror"
1964 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1965     return 0;
1966 ]])], [
1967 FLAG_MSA="-mmsa"
1968 AC_MSG_RESULT([yes])
1969 ], [
1970 FLAG_MSA=""
1971 AC_MSG_RESULT([no])
1973 CFLAGS=$safe_CFLAGS
1975 AC_SUBST(FLAG_MSA)
1977 # Are we compiling for the MIPS64 n32 ABI?
1978 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
1979 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1980 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
1981 #error NO
1982 #endif
1983 ]])], [
1984 VGCONF_ABI=N32
1985 FLAG_M64="-march=mips64r2 -mabi=n32"
1986 AC_MSG_RESULT([yes])
1987 ], [
1988 AC_MSG_RESULT([no])
1991 # Are we compiling for the MIPS64 n64 ABI?
1992 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
1993 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1994 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
1995 #error NO
1996 #endif
1997 ]])], [
1998 VGCONF_ABI=64
1999 AC_MSG_RESULT([yes])
2000 ], [
2001 AC_MSG_RESULT([no])
2004 # We enter the code block below in the following case:
2005 # Target architecture is set to mips64, the desired abi
2006 # was not specified and the compiler's default abi setting
2007 # is neither n32 nor n64.
2008 # Probe for and set the abi to either n64 or n32, in that order,
2009 # which is required for a mips64 build of valgrind.
2010 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2011   safe_CFLAGS=$CFLAGS
2012   CFLAGS="$CFLAGS -mabi=64 -Werror"
2013   AC_MSG_CHECKING([if gcc is n64 capable])
2014   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2015       return 0;
2016   ]])], [
2017   VGCONF_ABI=64
2018   AC_MSG_RESULT([yes])
2019   ], [
2020   AC_MSG_RESULT([no])
2021   ])
2022   CFLAGS=$safe_CFLAGS
2024   if test "x$VGCONF_ABI" = "x"; then
2025     safe_CFLAGS=$CFLAGS
2026     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2027     AC_MSG_CHECKING([if gcc is n32 capable])
2028     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2029         return 0;
2030     ]])], [
2031     VGCONF_ABI=N32
2032     FLAG_M64="-march=mips64r2 -mabi=n32"
2033     AC_MSG_RESULT([yes])
2034     ], [
2035     AC_MSG_RESULT([no])
2036     ])
2037     CFLAGS=$safe_CFLAGS
2038   fi
2041 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2042                [test x$VGCONF_ABI != x])
2043 AC_SUBST(VGCONF_ABI)
2046 # does this compiler support -mmmx ?
2047 AC_MSG_CHECKING([if gcc accepts -mmmx])
2049 safe_CFLAGS=$CFLAGS
2050 CFLAGS="-mmmx -Werror"
2052 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2053   return 0;
2054 ]])], [
2055 FLAG_MMMX="-mmmx"
2056 AC_MSG_RESULT([yes])
2057 ], [
2058 FLAG_MMMX=""
2059 AC_MSG_RESULT([no])
2061 CFLAGS=$safe_CFLAGS
2063 AC_SUBST(FLAG_MMMX)
2066 # does this compiler support -msse ?
2067 AC_MSG_CHECKING([if gcc accepts -msse])
2069 safe_CFLAGS=$CFLAGS
2070 CFLAGS="-msse -Werror"
2072 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2073   return 0;
2074 ]])], [
2075 FLAG_MSSE="-msse"
2076 AC_MSG_RESULT([yes])
2077 ], [
2078 FLAG_MSSE=""
2079 AC_MSG_RESULT([no])
2081 CFLAGS=$safe_CFLAGS
2083 AC_SUBST(FLAG_MSSE)
2086 # does this compiler support -mpreferred-stack-boundary=2 when
2087 # generating code for a 32-bit target?  Note that we only care about
2088 # this when generating code for (32-bit) x86, so if the compiler
2089 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2090 # the Memcheck and other helper functions, that is a bit slower than
2091 # it could be, on x86; and no difference at all on any other platform.
2092 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2094 safe_CFLAGS=$CFLAGS
2095 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2097 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2098   return 0;
2099 ]])], [
2100 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2101 AC_MSG_RESULT([yes])
2102 ], [
2103 PREFERRED_STACK_BOUNDARY_2=""
2104 AC_MSG_RESULT([no])
2106 CFLAGS=$safe_CFLAGS
2108 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2111 # does this compiler support -mlong-double-128 ?
2112 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2113 safe_CFLAGS=$CFLAGS
2114 CFLAGS="-mlong-double-128 -Werror"
2115 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2116   return 0;
2117 ]])], [
2118 ac_compiler_supports_mlong_double_128=yes
2119 AC_MSG_RESULT([yes])
2120 ], [
2121 ac_compiler_supports_mlong_double_128=no
2122 AC_MSG_RESULT([no])
2124 CFLAGS=$safe_CFLAGS
2125 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2126 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2127 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2129 # does this toolchain support lto ?
2130 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2131 # are not defined
2132 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2133 # a lot slower, and so not appropriate for Valgrind developments.
2134 # --enable-lto=yes should be used by distro packagers.
2135 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2136    [AC_ARG_ENABLE(lto,
2137       [  --enable-lto          enables building with link time optimisation],
2138       [vg_cv_lto=$enableval],
2139       [vg_cv_lto=no])])
2141 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2142 AC_MSG_CHECKING([if toolchain accepts lto])
2143 safe_CFLAGS=$CFLAGS
2144 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2145 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2146 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2147 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2149 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2150   extern void somefun(void);
2151   somefun();
2152   return 0;
2153 ]])], [
2154 LTO_CFLAGS=$TEST_LTO_CFLAGS
2155 AC_MSG_RESULT([yes])
2156 ], [
2157 LTO_CFLAGS=""
2158 AC_MSG_RESULT([no])
2160 CFLAGS=$safe_CFLAGS
2163 AC_SUBST(LTO_CFLAGS)
2165 # if we could not compile with lto args, or lto was disabled,
2166 # then set LTO_AR/LTO_RANLIB to the non lto values
2167 # define in config.h ENABLE_LTO (not needed by the code currently, but
2168 # this guarantees we recompile everything if we re-configure and rebuild
2169 # in a build dir previously build with another value of --enable-lto
2170 if test "x${LTO_CFLAGS}" = "x"; then
2171    LTO_AR=${AR}
2172    LTO_RANLIB=${RANLIB}
2173    vg_cv_lto=no
2174 else
2175    vg_cv_lto=yes
2176    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2179 # Convenience function to check whether GCC supports a particular
2180 # warning option. Takes two arguments,
2181 # first the warning flag name to check (without -W), then the
2182 # substitution name to set with -Wno-warning-flag if the flag exists,
2183 # or the empty string if the compiler doesn't accept the flag. Note
2184 # that checking is done against the warning flag itself, but the
2185 # substitution is then done to cancel the warning flag.
2186 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2187   AC_MSG_CHECKING([if gcc accepts -W$1])
2188   safe_CFLAGS=$CFLAGS
2189   CFLAGS="-W$1 -Werror"
2190   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2191   AC_SUBST([$2], [-Wno-$1])
2192   AC_MSG_RESULT([yes])], [
2193   AC_SUBST([$2], [])
2194   AC_MSG_RESULT([no])])
2195   CFLAGS=$safe_CFLAGS
2198 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2199 # -W$1  (instead of -Wno-$1).
2200 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2201   AC_MSG_CHECKING([if gcc accepts -W$1])
2202   safe_CFLAGS=$CFLAGS
2203   CFLAGS="-W$1 -Werror"
2204   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2205   AC_SUBST([$2], [-W$1])
2206   AC_MSG_RESULT([yes])], [
2207   AC_SUBST([$2], [])
2208   AC_MSG_RESULT([no])])
2209   CFLAGS=$safe_CFLAGS
2212 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2213 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2214 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2215 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2216 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2217 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2218 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2219 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2220 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2222 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2223 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2224 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2225 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2226 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2227 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2228 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2229 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2230 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2231 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2232 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2234 # Does this compiler support -Wformat-security ?
2235 # Special handling is needed, because certain GCC versions require -Wformat
2236 # being present if -Wformat-security is given. Otherwise a warning is issued.
2237 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2238 # And with that the warning will be turned into an error with the result
2239 # that -Wformat-security is believed to be unsupported when in fact it is.
2240 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2241 safe_CFLAGS=$CFLAGS
2242 CFLAGS="-Wformat -Wformat-security -Werror"
2243 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2244 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2245 AC_MSG_RESULT([yes])], [
2246 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2247 AC_MSG_RESULT([no])])
2248 CFLAGS=$safe_CFLAGS
2250 # does this compiler support -Wextra or the older -W ?
2252 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2254 safe_CFLAGS=$CFLAGS
2255 CFLAGS="-Wextra -Werror"
2257 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2258   return 0;
2259 ]])], [
2260 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2261 AC_MSG_RESULT([-Wextra])
2262 ], [
2263   CFLAGS="-W -Werror"
2264   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2265     return 0;
2266   ]])], [
2267   AC_SUBST([FLAG_W_EXTRA], [-W])
2268   AC_MSG_RESULT([-W])
2269   ], [
2270   AC_SUBST([FLAG_W_EXTRA], [])
2271   AC_MSG_RESULT([not supported])
2272   ])
2274 CFLAGS=$safe_CFLAGS
2276 # On ARM we do not want to pass -Wcast-align as that produces loads
2277 # of warnings. GCC is just being conservative. See here:
2278 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2279 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2280   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2281 else
2282   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2285 # does this compiler support -faligned-new ?
2286 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2288 safe_CXXFLAGS=$CXXFLAGS
2289 CXXFLAGS="-faligned-new -Werror"
2291 AC_LANG(C++)
2292 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2293   return 0;
2294 ]])], [
2295 FLAG_FALIGNED_NEW="-faligned-new"
2296 AC_MSG_RESULT([yes])
2297 ], [
2298 FLAG_FALIGNED_NEW=""
2299 AC_MSG_RESULT([no])
2301 CXXFLAGS=$safe_CXXFLAGS
2302 AC_LANG(C)
2304 AC_SUBST(FLAG_FALIGNED_NEW)
2306 # does this compiler support -fsized-deallocation ?
2307 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2309 safe_CXXFLAGS=$CXXFLAGS
2310 CXXFLAGS="-fsized-deallocation -Werror"
2312 AC_LANG(C++)
2313 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2314   return 0;
2315 ]])], [
2316 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2317 ac_have_sized_deallocation=yes
2318 AC_MSG_RESULT([yes])
2319 ], [
2320 FLAG_FSIZED_DEALLOCATION=""
2321 ac_have_sized_deallocation=no
2322 AC_MSG_RESULT([no])
2324 CXXFLAGS=$safe_CXXFLAGS
2325 AC_LANG(C)
2327 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2328 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2330 # does this compiler support C++17 aligned new/delete?
2331 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2333 safe_CXXFLAGS=$CXXFLAGS
2334 CXXFLAGS="-std=c++17"
2336 AC_LANG(C++)
2337 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2338 #include <cstdlib>
2339 #include <new>
2340 ]], [[
2341   operator delete(nullptr, std::align_val_t(64U));
2342 ]])], [
2343 ac_have_aligned_cxx_alloc=yes
2344 AC_MSG_RESULT([yes])
2345 ], [
2346 ac_have_aligned_cxx_alloc=no
2347 AC_MSG_RESULT([no])
2349 CXXFLAGS=$safe_CXXFLAGS
2350 AC_LANG(C)
2352 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2354 # does this compiler support -fno-stack-protector ?
2355 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2357 safe_CFLAGS=$CFLAGS
2358 CFLAGS="-fno-stack-protector -Werror"
2360 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2361   return 0;
2362 ]])], [
2363 no_stack_protector=yes
2364 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2365 AC_MSG_RESULT([yes])
2366 ], [
2367 no_stack_protector=no
2368 FLAG_FNO_STACK_PROTECTOR=""
2369 AC_MSG_RESULT([no])
2371 CFLAGS=$safe_CFLAGS
2373 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2375 # does this compiler support -finline-functions ?
2376 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2378 safe_CFLAGS=$CFLAGS
2379 CFLAGS="-finline-functions -Werror"
2381 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2382   return 0;
2383 ]])], [
2384 inline_functions=yes
2385 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2386 AC_MSG_RESULT([yes])
2387 ], [
2388 inline_functions=no
2389 FLAG_FINLINE_FUNCTIONS=""
2390 AC_MSG_RESULT([no])
2392 CFLAGS=$safe_CFLAGS
2394 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2396 # Does GCC support disabling Identical Code Folding?
2397 # We want to disabled Identical Code Folding for the
2398 # tools preload shared objects to get better backraces.
2399 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2400 # "The optimization reduces code size and may disturb
2401 #  unwind stacks by replacing a function by equivalent
2402 #  one with a different name."
2403 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2405 safe_CFLAGS=$CFLAGS
2406 CFLAGS="-fno-ipa-icf -Werror"
2408 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2409   return 0;
2410 ]])], [
2411 no_ipa_icf=yes
2412 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2413 AC_MSG_RESULT([yes])
2414 ], [
2415 no_ipa_icf=no
2416 FLAG_FNO_IPA_ICF=""
2417 AC_MSG_RESULT([no])
2419 CFLAGS=$safe_CFLAGS
2421 AC_SUBST(FLAG_FNO_IPA_ICF)
2424 # Does this compiler support -fsanitize=undefined. This is true for
2425 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2426 # also checks for alignment violations on memory accesses which the valgrind
2427 # code base is sprinkled (if not littered) with. As those alignment issues
2428 # don't pose a problem we want to suppress warnings about them.
2429 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2430 # GCCs do not support that.
2432 # Only checked for if --enable-ubsan was given.
2433 if test "x${vg_cv_ubsan}" = "xyes"; then
2434 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2435 safe_CFLAGS=$CFLAGS
2436 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2437 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2438   return 0;
2439 ]])], [
2440 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2441 LIB_UBSAN="-static-libubsan"
2442 AC_MSG_RESULT([yes])
2443 ], [
2444 CFLAGS="-fsanitize=undefined -Werror"
2445 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2446   return 0;
2447 ]])], [
2448 FLAG_FSANITIZE="-fsanitize=undefined"
2449 LIB_UBSAN="-static-libubsan"
2450 AC_MSG_RESULT([yes])
2451 ], [
2452 FLAG_FSANITIZE=""
2453 LIB_UBSAN=""
2454 AC_MSG_RESULT([no])
2457 CFLAGS=$safe_CFLAGS
2458 AC_SUBST(FLAG_FSANITIZE)
2459 AC_SUBST(LIB_UBSAN)
2461 # does this compiler support --param inline-unit-growth=... ?
2463 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2465 safe_CFLAGS=$CFLAGS
2466 CFLAGS="--param inline-unit-growth=900 -Werror"
2468 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2469   return 0;
2470 ]])], [
2471 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2472          ["--param inline-unit-growth=900"])
2473 AC_MSG_RESULT([yes])
2474 ], [
2475 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2476 AC_MSG_RESULT([no])
2478 CFLAGS=$safe_CFLAGS
2481 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2483 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2485 safe_CFLAGS=$CFLAGS
2486 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2488 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2489   return 0;
2490 ]])], [
2491 ac_have_dwarf4=yes
2492 AC_MSG_RESULT([yes])
2493 ], [
2494 ac_have_dwarf4=no
2495 AC_MSG_RESULT([no])
2497 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2498 CFLAGS=$safe_CFLAGS
2501 # does this compiler support -g -gz=zlib ?
2503 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2505 safe_CFLAGS=$CFLAGS
2506 CFLAGS="-g -gz=zlib"
2508 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2509   return 0;
2510 ]])], [
2511 ac_have_gz_zlib=yes
2512 AC_MSG_RESULT([yes])
2513 ], [
2514 ac_have_gz_zlib=no
2515 AC_MSG_RESULT([no])
2517 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2518 CFLAGS=$safe_CFLAGS
2521 # does this compiler support -g -gz=zlib-gnu ?
2523 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2525 safe_CFLAGS=$CFLAGS
2526 CFLAGS="-g -gz=zlib-gnu"
2528 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2529   return 0;
2530 ]])], [
2531 ac_have_gz_zlib_gnu=yes
2532 AC_MSG_RESULT([yes])
2533 ], [
2534 ac_have_gz_zlib_gnu=no
2535 AC_MSG_RESULT([no])
2537 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2538 CFLAGS=$safe_CFLAGS
2541 # does this compiler support nested functions ?
2543 AC_MSG_CHECKING([if gcc accepts nested functions])
2545 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2546   int foo() { return 1; }
2547   return foo();
2548 ]])], [
2549 ac_have_nested_functions=yes
2550 AC_MSG_RESULT([yes])
2551 ], [
2552 ac_have_nested_functions=no
2553 AC_MSG_RESULT([no])
2555 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2558 # does this compiler support the 'p' constraint in ASM statements ?
2560 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2563    char *p;
2564    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2565 ]])], [
2566 ac_have_asm_constraint_p=yes
2567 AC_MSG_RESULT([yes])
2568 ], [
2569 ac_have_asm_constraint_p=no
2570 AC_MSG_RESULT([no])
2572 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2575 # Does this compiler and linker support -pie?
2576 # Some compilers actually do not support -pie and report its usage
2577 # as an error. We need to check if it is safe to use it first.
2579 AC_MSG_CHECKING([if gcc accepts -pie])
2581 safe_CFLAGS=$CFLAGS
2582 CFLAGS="-pie"
2584 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2585   return 0;
2586 ]])], [
2587 AC_SUBST([FLAG_PIE], ["-pie"])
2588 AC_MSG_RESULT([yes])
2589 ], [
2590 AC_SUBST([FLAG_PIE], [""])
2591 AC_MSG_RESULT([no])
2593 CFLAGS=$safe_CFLAGS
2596 # Does this compiler support -no-pie?
2597 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2598 # default. However this gets in the way with some tests, we use -no-pie
2599 # for these.
2601 AC_MSG_CHECKING([if gcc accepts -no-pie])
2603 safe_CFLAGS=$CFLAGS
2604 CFLAGS="-no-pie"
2606 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2607   return 0;
2608 ]])], [
2609 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2610 AC_MSG_RESULT([yes])
2611 ], [
2612 AC_SUBST([FLAG_NO_PIE], [""])
2613 AC_MSG_RESULT([no])
2615 CFLAGS=$safe_CFLAGS
2618 # We want to use use the -Ttext-segment option to the linker.
2619 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2620 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2621 # semantics are NOT what we want (GNU gold -Ttext is fine).
2623 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2624 # will reside. -Ttext aligns just the .text section start (but not any
2625 # other section).
2627 # So test for -Ttext-segment which is supported by all bfd ld versions
2628 # and use that if it exists. If it doesn't exist it must be an older
2629 # version of gold and we can fall back to using -Ttext which has the
2630 # right semantics.
2632 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2634 safe_CFLAGS=$CFLAGS
2635 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2637 AC_LINK_IFELSE(
2638 [AC_LANG_SOURCE([int _start () { return 0; }])],
2640   linker_using_t_text="no"
2641   AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2642   AC_MSG_RESULT([yes])
2643 ], [
2644   linker_using_t_text="yes"
2645   AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2646   AC_MSG_RESULT([no])
2648 CFLAGS=$safe_CFLAGS
2650 # If the linker only supports -Ttext (not -Ttext-segment) then we will
2651 # have to strip any build-id ELF NOTEs from the statically linked tools.
2652 # Otherwise the build-id NOTE might end up at the default load address.
2653 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2654 # gold versions also support -Ttext-segment. So just assume that unless
2655 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2656 if test "x${linker_using_t_text}" = "xyes"; then
2657 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2658 # does the linker support -Wl,--build-id=none ?  Note, it's
2659 # important that we test indirectly via whichever C compiler
2660 # is selected, rather than testing /usr/bin/ld or whatever
2661 # directly.
2662 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2663 safe_CFLAGS=$CFLAGS
2664 CFLAGS="-Wl,--build-id=none -Werror"
2666 AC_LINK_IFELSE(
2667 [AC_LANG_PROGRAM([ ], [return 0;])],
2669   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2670   AC_MSG_RESULT([yes])
2671 ], [
2672   AC_SUBST([FLAG_NO_BUILD_ID], [""])
2673   AC_MSG_RESULT([no])
2675 else
2676 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2677 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2679 CFLAGS=$safe_CFLAGS
2681 # does the ppc assembler support "mtocrf" et al?
2682 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2684 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2685 __asm__ __volatile__("mtocrf 4,0");
2686 __asm__ __volatile__("mfocrf 0,4");
2687 ]])], [
2688 ac_have_as_ppc_mftocrf=yes
2689 AC_MSG_RESULT([yes])
2690 ], [
2691 ac_have_as_ppc_mftocrf=no
2692 AC_MSG_RESULT([no])
2694 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2695   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2699 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2700 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2702 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2703   do { typedef struct {
2704       double hi;
2705       double lo;
2706      } dbl_pair_t;
2707      dbl_pair_t dbl_pair[3];
2708      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2709    } while (0)
2710 ]])], [
2711 ac_have_as_ppc_fpPO=yes
2712 AC_MSG_RESULT([yes])
2713 ], [
2714 ac_have_as_ppc_fpPO=no
2715 AC_MSG_RESULT([no])
2717 if test x$ac_have_as_ppc_fpPO = xyes ; then
2718   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2722 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2723 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2725 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2726 void* p;
2727 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2728 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2729 ]])], [
2730 ac_have_as_amd64_fxsave64=yes
2731 AC_MSG_RESULT([yes])
2732 ], [
2733 ac_have_as_amd64_fxsave64=no
2734 AC_MSG_RESULT([no])
2736 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2737   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2740 # does the x86/amd64 assembler understand SSE3 instructions?
2741 # Note, this doesn't generate a C-level symbol.  It generates a
2742 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2743 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2745 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2746   do { long long int x; 
2747      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
2748   while (0)
2749 ]])], [
2750 ac_have_as_sse3=yes
2751 AC_MSG_RESULT([yes])
2752 ], [
2753 ac_have_as_sse3=no
2754 AC_MSG_RESULT([no])
2757 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2760 # Ditto for SSSE3 instructions (note extra S)
2761 # Note, this doesn't generate a C-level symbol.  It generates a
2762 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2763 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2765 save_CFLAGS="$CFLAGS"
2766 CFLAGS="$CFLAGS -msse -Werror"
2767 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2768   do { long long int x; 
2769    __asm__ __volatile__(
2770       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2771   while (0)
2772 ]])], [
2773 ac_have_as_ssse3=yes
2774 AC_MSG_RESULT([yes])
2775 ], [
2776 ac_have_as_ssse3=no
2777 AC_MSG_RESULT([no])
2779 CFLAGS="$save_CFLAGS"
2781 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2784 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2785 # Note, this doesn't generate a C-level symbol.  It generates a
2786 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2787 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2788 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2789   do {
2790    __asm__ __volatile__(
2791       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2792   while (0)
2793 ]])], [
2794 ac_have_as_pclmulqdq=yes
2795 AC_MSG_RESULT([yes])
2796 ], [
2797 ac_have_as_pclmulqdq=no
2798 AC_MSG_RESULT([no])
2801 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2804 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2805 # Note, this doesn't generate a C-level symbol.  It generates a
2806 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2807 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2808 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2809   do {
2810       /*
2811        * Carry-less multiplication of xmm1 with xmm2 and store the result in
2812        * xmm3. The immediate is used to determine which quadwords of xmm1 and
2813        * xmm2 should be used.
2814        */
2815    __asm__ __volatile__(
2816       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2817   } while (0)
2818 ]])], [
2819 ac_have_as_vpclmulqdq=yes
2820 AC_MSG_RESULT([yes])
2821 ], [
2822 ac_have_as_vpclmulqdq=no
2823 AC_MSG_RESULT([no])
2826 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2829 # does the x86/amd64 assembler understand FMA4 instructions?
2830 # Note, this doesn't generate a C-level symbol.  It generates a
2831 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
2832 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
2833 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2834   do {
2835    __asm__ __volatile__(
2836       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
2837   } while (0)
2838 ]])], [
2839 ac_have_as_vfmaddpd=yes
2840 AC_MSG_RESULT([yes])
2841 ], [
2842 ac_have_as_vfmaddpd=no
2843 AC_MSG_RESULT([no])
2846 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
2849 # does the x86/amd64 assembler understand the LZCNT instruction?
2850 # Note, this doesn't generate a C-level symbol.  It generates a
2851 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2852 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2854 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2855   do {           
2856       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2857   } while (0)
2858 ]])], [
2859   ac_have_as_lzcnt=yes
2860   AC_MSG_RESULT([yes])
2861 ], [
2862   ac_have_as_lzcnt=no
2863   AC_MSG_RESULT([no])
2866 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2869 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2870 # Note, this doesn't generate a C-level symbol.  It generates a
2871 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2872 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2874 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2875   do {           
2876       __asm__ __volatile__("1:  loopnel 1b\n");
2877   } while (0)
2878 ]])], [
2879   ac_have_as_loopnel=yes
2880   AC_MSG_RESULT([yes])
2881 ], [
2882   ac_have_as_loopnel=no
2883   AC_MSG_RESULT([no])
2886 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2889 # does the x86/amd64 assembler understand ADDR32 ?
2890 # Note, this doesn't generate a C-level symbol.  It generates a
2891 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2892 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2894 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2895   do {           
2896       asm volatile ("addr32 rep movsb");
2897   } while (0)
2898 ]])], [
2899   ac_have_as_addr32=yes
2900   AC_MSG_RESULT([yes])
2901 ], [
2902   ac_have_as_addr32=no
2903   AC_MSG_RESULT([no])
2906 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2909 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2910 # Note, this doesn't generate a C-level symbol.  It generates a
2911 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2912 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2914 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2915   do { long long int x; 
2916    __asm__ __volatile__(
2917       "crc32q %%r15,%%r15" : : : "r15" );
2918    __asm__ __volatile__(
2919       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
2920    __asm__ __volatile__(
2921       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2922   while (0)
2923 ]])], [
2924 ac_have_as_sse42=yes
2925 AC_MSG_RESULT([yes])
2926 ], [
2927 ac_have_as_sse42=no
2928 AC_MSG_RESULT([no])
2931 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2934 # does the x86/amd64 assembler understand AVX instructions?
2935 # Note, this doesn't generate a C-level symbol.  It generates a
2936 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2937 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2939 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2940   do { long long int x; 
2941    __asm__ __volatile__(
2942       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2943    __asm__ __volatile__(
2944       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2945   while (0)
2946 ]])], [
2947 ac_have_as_avx=yes
2948 AC_MSG_RESULT([yes])
2949 ], [
2950 ac_have_as_avx=no
2951 AC_MSG_RESULT([no])
2954 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2957 # does the x86/amd64 assembler understand AVX2 instructions?
2958 # Note, this doesn't generate a C-level symbol.  It generates a
2959 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2960 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2962 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2963   do { long long int x; 
2964    __asm__ __volatile__(
2965       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2966    __asm__ __volatile__(
2967       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2968   while (0)
2969 ]])], [
2970 ac_have_as_avx2=yes
2971 AC_MSG_RESULT([yes])
2972 ], [
2973 ac_have_as_avx2=no
2974 AC_MSG_RESULT([no])
2977 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2980 # does the x86/amd64 assembler understand TSX instructions and
2981 # the XACQUIRE/XRELEASE prefixes?
2982 # Note, this doesn't generate a C-level symbol.  It generates a
2983 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2984 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2986 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2987   do {
2988    __asm__ __volatile__(
2989       "       xbegin Lfoo  \n\t"
2990       "Lfoo:  xend         \n\t"
2991       "       xacquire lock incq 0(%rsp)     \n\t"
2992       "       xrelease lock incq 0(%rsp)     \n"
2993    );
2994   } while (0)
2995 ]])], [
2996 ac_have_as_tsx=yes
2997 AC_MSG_RESULT([yes])
2998 ], [
2999 ac_have_as_tsx=no
3000 AC_MSG_RESULT([no])
3003 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3006 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3007 # Note, this doesn't generate a C-level symbol.  It generates a
3008 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3009 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3011 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3012   do { unsigned int h, l;
3013    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3014    __asm__ __volatile__(
3015       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3016    __asm__ __volatile__(
3017       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3018   while (0)
3019 ]])], [
3020 ac_have_as_bmi=yes
3021 AC_MSG_RESULT([yes])
3022 ], [
3023 ac_have_as_bmi=no
3024 AC_MSG_RESULT([no])
3027 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3030 # does the x86/amd64 assembler understand FMA instructions?
3031 # Note, this doesn't generate a C-level symbol.  It generates a
3032 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3033 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3035 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3036   do { unsigned int h, l;
3037    __asm__ __volatile__(
3038       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3039    __asm__ __volatile__(
3040       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3041    __asm__ __volatile__(
3042       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3043   while (0)
3044 ]])], [
3045 ac_have_as_fma=yes
3046 AC_MSG_RESULT([yes])
3047 ], [
3048 ac_have_as_fma=no
3049 AC_MSG_RESULT([no])
3052 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3055 # does the amd64 assembler understand MPX instructions?
3056 # Note, this doesn't generate a C-level symbol.  It generates a
3057 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3058 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3060 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3061   do {
3062     asm ("bndmov %bnd0,(%rsp)");
3063     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3064     asm ("bnd call foo\n"
3065           bnd jmp  end\n"
3066           foo: bnd ret\n"
3067           end: nop");
3068   } while (0)
3069 ]])], [
3070 ac_have_as_mpx=yes
3071 AC_MSG_RESULT([yes])
3072 ], [
3073 ac_have_as_mpx=no
3074 AC_MSG_RESULT([no])
3077 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3080 # does the amd64 assembler understand ADX instructions?
3081 # Note, this doesn't generate a C-level symbol.  It generates a
3082 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3083 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3085 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3086   do {
3087     asm ("adcxq %r14,%r8");
3088   } while (0)
3089 ]])], [
3090 ac_have_as_adx=yes
3091 AC_MSG_RESULT([yes])
3092 ], [
3093 ac_have_as_adx=no
3094 AC_MSG_RESULT([no])
3097 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3100 # does the amd64 assembler understand the RDRAND instruction?
3101 # Note, this doesn't generate a C-level symbol.  It generates a
3102 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3103 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3105 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3106   do {
3107     asm ("rdrand %r14");
3108     asm ("rdrand %r14d");
3109     asm ("rdrand %r14w");
3110   } while (0)
3111 ]])], [
3112 ac_have_as_rdrand=yes
3113 AC_MSG_RESULT([yes])
3114 ], [
3115 ac_have_as_rdrand=no
3116 AC_MSG_RESULT([no])
3119 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3121 # does the amd64 assembler understand the RDSEED instruction?
3122 # Note, this doesn't generate a C-level symbol.  It generates a
3123 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3124 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3126 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3127   do {
3128     asm ("rdseed %r14");
3129     asm ("rdseed %r14d");
3130     asm ("rdseed %r14w");
3131   } while (0)
3132 ]])], [
3133 ac_have_as_rdseed=yes
3134 AC_MSG_RESULT([yes])
3135 ], [
3136 ac_have_as_rdseed=no
3137 AC_MSG_RESULT([no])
3140 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3142 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3143 # VCVTPS2PH) ?
3144 # Note, this doesn't generate a C-level symbol.  It generates a
3145 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3146 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3148 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3149   do {
3150     asm ("vcvtph2ps %xmm5, %ymm10");
3151     // If we put the dollar sign and zero together, the shell processing
3152     // this configure.ac script substitutes the command name in.  Sigh.
3153     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3154   } while (0)
3155 ]])], [
3156 ac_have_as_f16c=yes
3157 AC_MSG_RESULT([yes])
3158 ], [
3159 ac_have_as_f16c=no
3160 AC_MSG_RESULT([no])
3163 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3166 # does the x86/amd64 assembler understand MOVBE?
3167 # Note, this doesn't generate a C-level symbol.  It generates a
3168 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3169 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3171 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3172   do { long long int x; 
3173    __asm__ __volatile__(
3174       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3175   while (0)
3176 ]])], [
3177 ac_have_as_movbe=yes
3178 AC_MSG_RESULT([yes])
3179 ], [
3180 ac_have_as_movbe=no
3181 AC_MSG_RESULT([no])
3184 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3187 # Does the C compiler support the "ifunc" attribute
3188 # Note, this doesn't generate a C-level symbol.  It generates a
3189 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3190 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3192 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3193 static void mytest(void) {}
3195 static void (*resolve_test(void))(void)
3197     return (void (*)(void))&mytest;
3200 void test(void) __attribute__((ifunc("resolve_test")));
3202 int main()
3204     test();
3205     return 0;
3207 ]])], [
3208 ac_have_ifunc_attr=yes
3209 AC_MSG_RESULT([yes])
3210 ], [
3211 ac_have_ifunc_attr=no
3212 AC_MSG_RESULT([no])
3215 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3217 # Does the C compiler support the armv8 crc feature flag
3218 # Note, this doesn't generate a C-level symbol.  It generates a
3219 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3220 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3222 save_CFLAGS="$CFLAGS"
3223 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3224 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3225 int main()
3227     return 0;
3229 ]])], [
3230 ac_have_armv8_crc_feature=yes
3231 AC_MSG_RESULT([yes])
3232 ], [
3233 ac_have_armv8_crc_feature=no
3234 AC_MSG_RESULT([no])
3236 CFLAGS="$save_CFLAGS"
3238 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3241 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3242 # Note, this doesn't generate a C-level symbol.  It generates a
3243 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3244 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3246 save_CFLAGS="$CFLAGS"
3247 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3248 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3249 int main()
3251     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3252     return 0;
3254 ]])], [
3255 ac_have_armv81_feature=yes
3256 AC_MSG_RESULT([yes])
3257 ], [
3258 ac_have_armv81_feature=no
3259 AC_MSG_RESULT([no])
3261 CFLAGS="$save_CFLAGS"
3263 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3266 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3267 # Note, this doesn't generate a C-level symbol.  It generates a
3268 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3269 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3271 save_CFLAGS="$CFLAGS"
3272 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3273 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3274 int main()
3276     __asm__ __volatile__("faddp h0, v1.2h");
3277     return 0;
3279 ]])], [
3280 ac_have_armv82_feature=yes
3281 AC_MSG_RESULT([yes])
3282 ], [
3283 ac_have_armv82_feature=no
3284 AC_MSG_RESULT([no])
3286 CFLAGS="$save_CFLAGS"
3288 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3291 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3292 # when building the tool executables.  I think we should get rid of it.
3294 # Check for TLS support in the compiler and linker
3295 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3296                                 [[return foo;]])],
3297                                [vg_cv_linktime_tls=yes],
3298                                [vg_cv_linktime_tls=no])
3299 # Native compilation: check whether running a program using TLS succeeds.
3300 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3301 # succeeds but running programs using TLS fails.
3302 # Cross-compiling: check whether linking a program using TLS succeeds.
3303 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3304                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3305                 [vg_cv_tls=$enableval],
3306                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3307                                                 [[return foo;]])],
3308                                [vg_cv_tls=yes],
3309                                [vg_cv_tls=no],
3310                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3312 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3313 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3317 #----------------------------------------------------------------------------
3318 # Solaris-specific checks.
3319 #----------------------------------------------------------------------------
3321 if test "$VGCONF_OS" = "solaris" ; then
3322 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3324 # Solaris-specific check determining if the Sun Studio Assembler is used to
3325 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3326 # cmovl.l instruction, if yes then it's Sun Assembler.
3328 # C-level symbol: none
3329 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3331 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3332 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3333 ]], [[
3334   __asm__ __volatile__("cmovl.l %edx, %eax");
3335 ]])], [
3336 solaris_have_sun_studio_as=yes
3337 AC_MSG_RESULT([yes])
3338 ], [
3339 solaris_have_sun_studio_as=no
3340 AC_MSG_RESULT([no])
3342 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3344 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3345 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3346 # See solaris/vgpreload-solaris.mapfile for details.
3347 # gcc on older Solaris instructs linker to include these symbols,
3348 # gcc on illumos and newer Solaris does not.
3350 # C-level symbol: none
3351 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3353 save_CFLAGS="$CFLAGS"
3354 CFLAGS="$CFLAGS -std=gnu99"
3355 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3356 temp_dir=$( /usr/bin/mktemp -d )
3357 cat <<_ACEOF >${temp_dir}/mylib.c
3358 #include <stdio.h>
3359 int myfunc(void) { printf("LaPutyka\n"); }
3360 _ACEOF
3361 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3362 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3363 if test "x${xpg_present}" = "x" ; then
3364     solaris_xpg_symbols_present=no
3365     AC_MSG_RESULT([no])
3366 else
3367     solaris_xpg_symbols_present=yes
3368     AC_MSG_RESULT([yes])
3370 rm -rf ${temp_dir}
3371 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3372 CFLAGS="$save_CFLAGS"
3375 # Solaris-specific check determining if gcc enables largefile support by
3376 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3377 # variable with gcc flags which disable it.
3379 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3380 save_CFLAGS="$CFLAGS"
3381 CFLAGS="$CFLAGS -m32"
3382 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3383   return _LARGEFILE_SOURCE;
3384 ]])], [
3385 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3386 AC_MSG_RESULT([yes])
3387 ], [
3388 SOLARIS_UNDEF_LARGESOURCE=""
3389 AC_MSG_RESULT([no])
3391 CFLAGS=$safe_CFLAGS
3392 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3395 # Solaris-specific check determining if /proc/self/cmdline
3396 # or /proc/<pid>/cmdline is supported.
3398 # C-level symbol: SOLARIS_PROC_CMDLINE
3399 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3401 AC_CHECK_FILE([/proc/self/cmdline],
3403 solaris_proc_cmdline=yes
3404 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3405           [Define to 1 if you have /proc/self/cmdline.])
3406 ], [
3407 solaris_proc_cmdline=no
3409 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3412 # Solaris-specific check determining default platform for the Valgrind launcher.
3413 # Used in case the launcher cannot select platform by looking at the client
3414 # image (for example because the executable is a shell script).
3416 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3417 # Automake-level symbol: none
3419 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3420 # Get the ELF class of /bin/sh first.
3421 if ! test -f /bin/sh; then
3422   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3424 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3425 case "$elf_class" in
3426   64)
3427     default_arch="$VGCONF_ARCH_PRI";
3428     ;;
3429   32)
3430     if test "x$VGCONF_ARCH_SEC" != "x"; then
3431       default_arch="$VGCONF_ARCH_SEC"
3432     else
3433       default_arch="$VGCONF_ARCH_PRI";
3434     fi
3435     ;;
3436   *)
3437     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3438     ;;
3439 esac
3440 default_platform="$default_arch-$VGCONF_OS"
3441 AC_MSG_RESULT([$default_platform])
3442 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3443                    [Default platform for Valgrind launcher.])
3446 # Solaris-specific check determining if the old syscalls are available.
3448 # C-level symbol: SOLARIS_OLD_SYSCALLS
3449 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3451 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3452 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3453 #include <sys/syscall.h>
3454 ]], [[
3455   return !SYS_open;
3456 ]])], [
3457 solaris_old_syscalls=yes
3458 AC_MSG_RESULT([yes])
3459 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3460           [Define to 1 if you have the old Solaris syscalls.])
3461 ], [
3462 solaris_old_syscalls=no
3463 AC_MSG_RESULT([no])
3465 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3468 # Solaris-specific check determining if the new accept() syscall is available.
3470 # Old syscall:
3471 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3472 #            int version);
3474 # New syscall (available on illumos):
3475 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3476 #            int version, int flags);
3478 # If the old syscall is present then the following syscall will fail with
3479 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3480 # available then it will fail with EINVAL (because the flags parameter is
3481 # invalid).
3483 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3484 # Automake-level symbol: none
3486 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3487 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3488 #include <sys/syscall.h>
3489 #include <errno.h>
3490 ]], [[
3491   errno = 0;
3492   syscall(SYS_accept, 0, 0, 0, 0, -1);
3493   return !(errno == EINVAL);
3494 ]])], [
3495 AC_MSG_RESULT([yes])
3496 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3497           [Define to 1 if you have the new `accept' syscall.])
3498 ], [
3499 AC_MSG_RESULT([no])
3503 # Solaris-specific check determining if the new illumos pipe() syscall is
3504 # available.
3506 # Old syscall:
3507 # longlong_t pipe();
3509 # New syscall (available on illumos):
3510 # int pipe(intptr_t arg, int flags);
3512 # If the old syscall is present then the following call will succeed, if the
3513 # new syscall is available then it will fail with EFAULT (because address 0
3514 # cannot be accessed).
3516 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3517 # Automake-level symbol: none
3519 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3520 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3521 #include <sys/syscall.h>
3522 #include <errno.h>
3523 ]], [[
3524   errno = 0;
3525   syscall(SYS_pipe, 0, 0);
3526   return !(errno == EFAULT);
3527 ]])], [
3528 AC_MSG_RESULT([yes])
3529 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3530           [Define to 1 if you have the new `pipe' syscall.])
3531 ], [
3532 AC_MSG_RESULT([no])
3536 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3537 # available.
3539 # Old syscall:
3540 # int lwp_kill(id_t lwpid, int sig);
3542 # New syscall (available on Solaris 11):
3543 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3544 #                  int si_code, timespec_t *timeout);
3546 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3547 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3549 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3550 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3551 #include <sys/syscall.h> 
3552 ]], [[
3553   return !SYS_lwp_sigqueue;
3554 ]])], [
3555 solaris_lwp_sigqueue_syscall=yes
3556 AC_MSG_RESULT([yes])
3557 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3558           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3559 ], [
3560 solaris_lwp_sigqueue_syscall=no
3561 AC_MSG_RESULT([no])
3563 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3566 # Solaris-specific check determining if the lwp_sigqueue() syscall
3567 # takes both pid and thread id arguments or just thread id.
3569 # Old syscall (available up to Solaris 11.3):
3570 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3571 #                  int si_code, timespec_t *timeout);
3573 # New syscall (available since Solaris 11.4):
3574 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3575 #                  int si_code, timespec_t *timeout);
3577 # If the old syscall is present then the following syscall will fail with
3578 # EINVAL (because signal is out of range); if the new syscall is available
3579 # then it will fail with ESRCH (because it would not find such thread in the
3580 # current process).
3582 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3583 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3585 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3586 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3587 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3588 #include <sys/syscall.h>
3589 #include <errno.h>
3590 ]], [[
3591   errno = 0;
3592   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3593   return !(errno == ESRCH);
3594 ]])], [
3595 solaris_lwp_sigqueue_syscall_takes_pid=yes
3596 AC_MSG_RESULT([yes])
3597 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3598           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3599 ], [
3600 solaris_lwp_sigqueue_syscall_takes_pid=no
3601 AC_MSG_RESULT([no])
3603 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3604                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3606 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3610 # Solaris-specific check determining if the new lwp_name() syscall is
3611 # available.
3613 # New syscall (available on Solaris 11):
3614 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3616 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3617 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3619 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3620 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3621 #include <sys/syscall.h>
3622 ]], [[
3623   return !SYS_lwp_name;
3624 ]])], [
3625 solaris_lwp_name_syscall=yes
3626 AC_MSG_RESULT([yes])
3627 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3628           [Define to 1 if you have the new `lwp_name' syscall.])
3629 ], [
3630 solaris_lwp_name_syscall=no
3631 AC_MSG_RESULT([no])
3633 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3636 # Solaris-specific check determining if the new getrandom() syscall is
3637 # available.
3639 # New syscall (available on Solaris 11):
3640 # int getrandom(void *buf, size_t buflen, uint_t flags);
3642 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3643 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3645 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3646 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3647 #include <sys/syscall.h>
3648 ]], [[
3649   return !SYS_getrandom;
3650 ]])], [
3651 solaris_getrandom_syscall=yes
3652 AC_MSG_RESULT([yes])
3653 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3654           [Define to 1 if you have the new `getrandom' syscall.])
3655 ], [
3656 solaris_getrandom_syscall=no
3657 AC_MSG_RESULT([no])
3659 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3662 # Solaris-specific check determining if the new zone() syscall subcodes
3663 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
3664 # were added in Solaris 11 but are missing on illumos.
3666 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3667 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3669 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3670 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3671 #include <sys/zone.h>
3672 ]], [[
3673   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3674 ]])], [
3675 solaris_zone_defunct=yes
3676 AC_MSG_RESULT([yes])
3677 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3678           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3679 ], [
3680 solaris_zone_defunct=no
3681 AC_MSG_RESULT([no])
3683 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3686 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3687 # for auditon(2) subcode of the auditsys() syscall are available.
3688 # These commands are available in Solaris 11 and illumos but were removed
3689 # in Solaris 11.4.
3691 # C-level symbol: SOLARIS_AUDITON_STAT
3692 # Automake-level symbol: SOLARIS_AUDITON_STAT
3694 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3695 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3696 #include <bsm/audit.h>
3697 ]], [[
3698   return !(A_GETSTAT && A_SETSTAT);
3699 ]])], [
3700 solaris_auditon_stat=yes
3701 AC_MSG_RESULT([yes])
3702 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3703           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3704 ], [
3705 solaris_auditon_stat=no
3706 AC_MSG_RESULT([no])
3708 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3711 # Solaris-specific check determining if the new shmsys() syscall subcodes
3712 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3713 # These subcodes were added in Solaris 11 but are missing on illumos.
3715 # C-level symbol: SOLARIS_SHM_NEW
3716 # Automake-level symbol: SOLARIS_SHM_NEW
3718 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3719 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3720 #include <sys/ipc_impl.h>
3721 #include <sys/shm.h>
3722 #include <sys/shm_impl.h>
3723 ]], [[
3724   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3725 ]])], [
3726 solaris_shm_new=yes
3727 AC_MSG_RESULT([yes])
3728 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3729           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3730 ], [
3731 solaris_shm_new=no
3732 AC_MSG_RESULT([no])
3734 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3737 # Solaris-specific check determining if prxregset_t is available.  Illumos
3738 # currently does not define it on the x86 platform.
3740 # C-level symbol: SOLARIS_PRXREGSET_T
3741 # Automake-level symbol: SOLARIS_PRXREGSET_T
3743 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3744 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3745 #include <sys/procfs_isa.h>
3746 ]], [[
3747   return !sizeof(prxregset_t);
3748 ]])], [
3749 solaris_prxregset_t=yes
3750 AC_MSG_RESULT([yes])
3751 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3752           [Define to 1 if you have the `prxregset_t' type.])
3753 ], [
3754 solaris_prxregset_t=no
3755 AC_MSG_RESULT([no])
3757 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3760 # Solaris-specific check determining if the new frealpathat() syscall is
3761 # available.
3763 # New syscall (available on Solaris 11.1):
3764 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
3766 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3767 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3769 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3770 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3771 #include <sys/syscall.h>
3772 ]], [[
3773   return !SYS_frealpathat;
3774 ]])], [
3775 solaris_frealpathat_syscall=yes
3776 AC_MSG_RESULT([yes])
3777 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3778           [Define to 1 if you have the new `frealpathat' syscall.])
3779 ], [
3780 solaris_frealpathat_syscall=no
3781 AC_MSG_RESULT([no])
3783 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3786 # Solaris-specific check determining if the new uuidsys() syscall is
3787 # available.
3789 # New syscall (available on newer Solaris):
3790 # int uuidsys(struct uuid *uuid);
3792 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3793 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3795 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3796 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3797 #include <sys/syscall.h>
3798 ]], [[
3799   return !SYS_uuidsys;
3800 ]])], [
3801 solaris_uuidsys_syscall=yes
3802 AC_MSG_RESULT([yes])
3803 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
3804           [Define to 1 if you have the new `uuidsys' syscall.])
3805 ], [
3806 solaris_uuidsys_syscall=no
3807 AC_MSG_RESULT([no])
3809 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
3812 # Solaris-specific check determining if the new labelsys() syscall subcode
3813 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
3814 # missing on illumos.
3816 # C-level symbol: SOLARIS_TNDB_GET_TNIP
3817 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
3819 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
3820 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3821 #include <sys/tsol/tndb.h>
3822 ]], [[
3823   return !TNDB_GET_TNIP;
3824 ]])], [
3825 solaris_tndb_get_tnip=yes
3826 AC_MSG_RESULT([yes])
3827 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
3828           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
3829 ], [
3830 solaris_tndb_get_tnip=no
3831 AC_MSG_RESULT([no])
3833 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
3836 # Solaris-specific check determining if the new labelsys() syscall opcodes
3837 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
3838 # added in Solaris 11 but are missing on illumos.
3840 # C-level symbol: SOLARIS_TSOL_CLEARANCE
3841 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
3843 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
3844 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3845 #include <sys/tsol/tsyscall.h>
3846 ]], [[
3847   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
3848 ]])], [
3849 solaris_tsol_clearance=yes
3850 AC_MSG_RESULT([yes])
3851 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
3852           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
3853 ], [
3854 solaris_tsol_clearance=no
3855 AC_MSG_RESULT([no])
3857 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
3860 # Solaris-specific check determining if the new pset() syscall subcode
3861 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
3862 # is missing on illumos and Solaris 11.3.
3864 # C-level symbol: SOLARIS_PSET_GET_NAME
3865 # Automake-level symbol: SOLARIS_PSET_GET_NAME
3867 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
3868 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3869 #include <sys/pset.h>
3870 ]], [[
3871   return !(PSET_GET_NAME);
3872 ]])], [
3873 solaris_pset_get_name=yes
3874 AC_MSG_RESULT([yes])
3875 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
3876           [Define to 1 if you have the `PSET_GET_NAME' constants.])
3877 ], [
3878 solaris_pset_get_name=no
3879 AC_MSG_RESULT([no])
3881 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
3884 # Solaris-specific check determining if the utimesys() syscall is
3885 # available (on illumos and older Solaris).
3887 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
3888 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
3890 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
3891 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3892 #include <sys/syscall.h>
3893 ]], [[
3894   return !SYS_utimesys;
3895 ]])], [
3896 solaris_utimesys_syscall=yes
3897 AC_MSG_RESULT([yes])
3898 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
3899           [Define to 1 if you have the `utimesys' syscall.])
3900 ], [
3901 solaris_utimesys_syscall=no
3902 AC_MSG_RESULT([no])
3904 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
3907 # Solaris-specific check determining if the utimensat() syscall is
3908 # available (on newer Solaris).
3910 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3911 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3913 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
3914 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3915 #include <sys/syscall.h>
3916 ]], [[
3917   return !SYS_utimensat;
3918 ]])], [
3919 solaris_utimensat_syscall=yes
3920 AC_MSG_RESULT([yes])
3921 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
3922           [Define to 1 if you have the `utimensat' syscall.])
3923 ], [
3924 solaris_utimensat_syscall=no
3925 AC_MSG_RESULT([no])
3927 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
3930 # Solaris-specific check determining if the spawn() syscall is available
3931 # (on newer Solaris).
3933 # C-level symbol: SOLARIS_SPAWN_SYSCALL
3934 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
3936 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
3937 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3938 #include <sys/syscall.h>
3939 ]], [[
3940   return !SYS_spawn;
3941 ]])], [
3942 solaris_spawn_syscall=yes
3943 AC_MSG_RESULT([yes])
3944 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
3945           [Define to 1 if you have the `spawn' syscall.])
3946 ], [
3947 solaris_spawn_syscall=no
3948 AC_MSG_RESULT([no])
3950 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
3953 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
3954 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
3956 # C-level symbol: SOLARIS_MODCTL_MODNVL
3957 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
3959 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
3960 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3961 #include <sys/modctl.h>
3962 ]], [[
3963   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
3964 ]])], [
3965 solaris_modctl_modnvl=yes
3966 AC_MSG_RESULT([yes])
3967 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
3968           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
3969 ], [
3970 solaris_modctl_modnvl=no
3971 AC_MSG_RESULT([no])
3973 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
3976 # Solaris-specific check determining whether nscd (name switch cache daemon)
3977 # attaches its door at /system/volatile/name_service_door (Solaris)
3978 # or at /var/run/name_service_door (illumos).
3980 # Note that /var/run is a symlink to /system/volatile on Solaris
3981 # but not vice versa on illumos.
3983 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3984 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3986 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
3987 if test -e /system/volatile/name_service_door; then
3988     solaris_nscd_door_system_volatile=yes
3989     AC_MSG_RESULT([/system/volatile/name_service_door])
3990     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
3991               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
3992 else
3993     solaris_nscd_door_system_volatile=no
3994     AC_MSG_RESULT([/var/run/name_service_door])
3996 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
3999 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4001 # New fasttrap (available on Solaris 11):
4002 # hrt_t *gethrt(void);
4004 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4005 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4007 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4008 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4009 #include <sys/trap.h>
4010 ]], [[
4011   return !T_GETHRT;
4012 ]])], [
4013 solaris_gethrt_fasttrap=yes
4014 AC_MSG_RESULT([yes])
4015 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4016           [Define to 1 if you have the new `gethrt' fasttrap.])
4017 ], [
4018 solaris_gethrt_fasttrap=no
4019 AC_MSG_RESULT([no])
4021 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4024 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4025 # is available.
4027 # New fasttrap (available on Solaris 11):
4028 # zonehrtoffset_t *get_zone_offset(void);
4030 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4031 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4033 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4034 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4035 #include <sys/trap.h>
4036 ]], [[
4037   return !T_GETZONEOFFSET;
4038 ]])], [
4039 solaris_getzoneoffset_fasttrap=yes
4040 AC_MSG_RESULT([yes])
4041 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4042           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4043 ], [
4044 solaris_getzoneoffset_fasttrap=no
4045 AC_MSG_RESULT([no])
4047 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4050 # Solaris-specific check determining if the execve() syscall
4051 # takes fourth argument (flags) or not.
4053 # Old syscall (available on illumos):
4054 # int execve(const char *fname, const char **argv, const char **envp);
4056 # New syscall (available on Solaris):
4057 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4059 # If the new syscall is present then it will fail with EINVAL (because flags
4060 # are invalid); if the old syscall is available then it will fail with ENOENT
4061 # (because the file could not be found).
4063 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4064 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4066 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4067 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4068 #include <sys/syscall.h>
4069 #include <errno.h>
4070 ]], [[
4071   errno = 0;
4072   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4073   return !(errno == EINVAL);
4074 ]])], [
4075 solaris_execve_syscall_takes_flags=yes
4076 AC_MSG_RESULT([yes])
4077 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4078           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4079 ], [
4080 solaris_execve_syscall_takes_flags=no
4081 AC_MSG_RESULT([no])
4083 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4084                test x$solaris_execve_syscall_takes_flags = xyes)
4087 # Solaris-specific check determining version of the repository cache protocol.
4088 # Every Solaris version uses a different one, ranging from 21 to current 25.
4089 # The check is very ugly, though.
4091 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4092 # Automake-level symbol: none
4094 AC_PATH_PROG(DIS_PATH, dis, false)
4095 if test "x$DIS_PATH" = "xfalse"; then
4096   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4098 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4099   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4100   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4103 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4104 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4105   libscf=/usr/lib/64/libscf.so.1
4106 else
4107   libscf=/usr/lib/libscf.so.1
4109 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
4110   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4111   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4113 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
4114 if test -z "$hex"; then
4115   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4116   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4118 version=$( printf "%d\n" 0x$hex )
4119 AC_MSG_RESULT([$version])
4120 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4121                    [Version number of the repository door cache protocol.])
4124 # Solaris-specific check determining if "sysstat" segment reservation type
4125 # is available.
4127 # New "sysstat" segment reservation (available on Solaris 11.4):
4128 # - program header type:    PT_SUNW_SYSSTAT
4129 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4131 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4132 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4134 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4135 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4136 #include <sys/auxv.h>
4137 ]], [[
4138   return !AT_SUN_SYSSTAT_ADDR;
4139 ]])], [
4140 solaris_reserve_sysstat_addr=yes
4141 AC_MSG_RESULT([yes])
4142 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4143           [Define to 1 if you have the new `sysstat' segment reservation.])
4144 ], [
4145 solaris_reserve_sysstat_addr=no
4146 AC_MSG_RESULT([no])
4148 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4151 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4152 # is available.
4154 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4155 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4156 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4158 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4159 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4161 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4162 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4163 #include <sys/auxv.h>
4164 ]], [[
4165   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4166 ]])], [
4167 solaris_reserve_sysstat_zone_addr=yes
4168 AC_MSG_RESULT([yes])
4169 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4170           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4171 ], [
4172 solaris_reserve_sysstat_zone_addr=no
4173 AC_MSG_RESULT([no])
4175 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4178 # Solaris-specific check determining if the system_stats() syscall is available
4179 # (on newer Solaris).
4181 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4182 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4184 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4185 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4186 #include <sys/syscall.h>
4187 ]], [[
4188   return !SYS_system_stats;
4189 ]])], [
4190 solaris_system_stats_syscall=yes
4191 AC_MSG_RESULT([yes])
4192 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4193           [Define to 1 if you have the `system_stats' syscall.])
4194 ], [
4195 solaris_system_stats_syscall=no
4196 AC_MSG_RESULT([no])
4198 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4201 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4202 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4204 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4205 # Automake-level symbol: none
4207 AC_CHECK_TYPE([struct _fpchip_state],
4208               [solaris_fpchip_state_takes_underscore=yes],
4209               [solaris_fpchip_state_takes_underscore=no],
4210               [[#include <sys/regset.h>]])
4211 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4212   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4213             [Define to 1 if fpregset_t defines struct _fpchip_state])
4217 # Solaris-specific check determining if schedctl page shared between kernel
4218 # and userspace program is executable (illumos, older Solaris) or not (newer
4219 # Solaris).
4221 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4222 # Automake-level symbol: none
4224 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4225 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4226 #include <assert.h>
4227 #include <fcntl.h>
4228 #include <procfs.h>
4229 #include <schedctl.h>
4230 #include <stdio.h>
4231 #include <unistd.h>
4232 ]], [[
4233     schedctl_t *scp = schedctl_init();
4234     if (scp == NULL)
4235         return 1;
4237     int fd = open("/proc/self/map", O_RDONLY);
4238     assert(fd >= 0);
4240     prmap_t map;
4241     ssize_t rd;
4242     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4243         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4244             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4245                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4246             return (map.pr_mflags & MA_EXEC);
4247         }
4248     }
4250     return 1;
4251 ]])], [
4252 solaris_schedctl_page_exec=no
4253 AC_MSG_RESULT([no])
4254 ], [
4255 solaris_schedctl_page_exec=yes
4256 AC_MSG_RESULT([yes])
4257 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4258           [Define to 1 if you have the schedctl page executable.])
4262 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4263 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4264 # an initial thread pointer for libc (newer Solaris).
4266 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4267 # Automake-level symbol: none
4269 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4270 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4271 #include <sys/fasttrap_isa.h>
4272 ]], [[
4273     return !FT_SCRATCHSIZE;
4274 ]])], [
4275 solaris_pt_sunwdtrace_thrp=yes
4276 AC_MSG_RESULT([yes])
4277 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4278           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4279 ], [
4280 solaris_pt_sunwdtrace_thrp=no
4281 AC_MSG_RESULT([no])
4284 else
4285 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4286 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4287 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4288 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4289 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4290 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4291 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4292 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4293 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4294 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4295 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4296 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4297 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4298 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4299 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4300 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4301 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4302 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4303 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4304 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4305 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4306 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4307 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4308 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4309 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4310 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4311 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4312 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4313 fi # test "$VGCONF_OS" = "solaris"
4316 #----------------------------------------------------------------------------
4317 # Checks for C header files.
4318 #----------------------------------------------------------------------------
4320 AC_CHECK_HEADERS([       \
4321         asm/unistd.h     \
4322         endian.h         \
4323         mqueue.h         \
4324         sys/endian.h     \
4325         sys/epoll.h      \
4326         sys/eventfd.h    \
4327         sys/klog.h       \
4328         sys/poll.h       \
4329         sys/prctl.h      \
4330         sys/signal.h     \
4331         sys/signalfd.h   \
4332         sys/syscall.h    \
4333         sys/sysnvl.h     \
4334         sys/time.h       \
4335         sys/types.h      \
4336         ])
4338 # Verify whether the <linux/futex.h> header is usable.
4339 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4341 save_CFLAGS="$CFLAGS"
4342 CFLAGS="$CFLAGS -D__user="
4343 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4344 #include <linux/futex.h>
4345 ]], [[
4346   return FUTEX_WAIT;
4347 ]])], [
4348 ac_have_usable_linux_futex_h=yes
4349 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4350           [Define to 1 if you have a usable <linux/futex.h> header file.])
4351 AC_MSG_RESULT([yes])
4352 ], [
4353 ac_have_usable_linux_futex_h=no
4354 AC_MSG_RESULT([no])
4356 CFLAGS="$save_CFLAGS"
4359 #----------------------------------------------------------------------------
4360 # Checks for typedefs, structures, and compiler characteristics.
4361 #----------------------------------------------------------------------------
4362 AC_TYPE_UID_T
4363 AC_TYPE_OFF_T
4364 AC_TYPE_SIZE_T
4365 AC_HEADER_TIME
4368 #----------------------------------------------------------------------------
4369 # Checks for library functions.
4370 #----------------------------------------------------------------------------
4371 AC_FUNC_MEMCMP
4372 AC_FUNC_MMAP
4374 AC_CHECK_LIB([pthread], [pthread_create])
4375 AC_CHECK_LIB([rt], [clock_gettime])
4377 AC_CHECK_FUNCS([     \
4378         clock_gettime\
4379         epoll_create \
4380         epoll_pwait  \
4381         klogctl      \
4382         mallinfo     \
4383         memchr       \
4384         memfd_create \
4385         memset       \
4386         mkdir        \
4387         mremap       \
4388         ppoll        \
4389         pthread_barrier_init       \
4390         pthread_condattr_setclock  \
4391         pthread_mutex_timedlock    \
4392         pthread_rwlock_timedrdlock \
4393         pthread_rwlock_timedwrlock \
4394         pthread_spin_lock          \
4395         pthread_yield              \
4396         pthread_setname_np         \
4397         readlinkat   \
4398         semtimedop   \
4399         signalfd     \
4400         sigwaitinfo  \
4401         strchr       \
4402         strdup       \
4403         strpbrk      \
4404         strrchr      \
4405         strstr       \
4406         syscall      \
4407         utimensat    \
4408         process_vm_readv  \
4409         process_vm_writev \
4410         copy_file_range \
4411         preadv \
4412         pwritev \
4413         preadv2 \
4414         pwritev2 \
4415         ])
4417 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4418 # libraries with any shared object and/or executable. This is NOT what we
4419 # want for e.g. vgpreload_core-x86-linux.so
4420 LIBS=""
4422 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4423                [test x$ac_cv_func_pthread_barrier_init = xyes])
4424 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4425                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4426 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4427                [test x$ac_cv_func_pthread_spin_lock = xyes])
4428 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4429                [test x$ac_cv_func_pthread_setname_np = xyes])
4430 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4431                [test x$ac_cv_func_copy_file_range = xyes])
4432 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4433                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4434 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4435                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4436 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4437                [test x$ac_cv_func_memfd_create = xyes])
4439 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4440      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4441      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4442   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4443             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4446 #----------------------------------------------------------------------------
4447 # MPI checks
4448 #----------------------------------------------------------------------------
4449 # Do we have a useable MPI setup on the primary and/or secondary targets?
4450 # On Linux, by default, assumes mpicc and -m32/-m64
4451 # Note: this is a kludge in that it assumes the specified mpicc 
4452 # understands -m32/-m64 regardless of what is specified using
4453 # --with-mpicc=.
4454 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4455              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4457 mflag_primary=
4458 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4459      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4460      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4461      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4462      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4463      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4464   mflag_primary=$FLAG_M32
4465 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4466        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4467        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4468        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4469        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4470   mflag_primary=$FLAG_M64
4471 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4472   mflag_primary="$FLAG_M32 -arch i386"
4473 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4474   mflag_primary="$FLAG_M64 -arch x86_64"
4477 mflag_secondary=
4478 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4479      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4480      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4481      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX ; then
4482   mflag_secondary=$FLAG_M32
4483 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4484   mflag_secondary="$FLAG_M32 -arch i386"
4488 AC_ARG_WITH(mpicc,
4489    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4490    MPI_CC=$withval
4492 AC_SUBST(MPI_CC)
4494 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4495 ## use these values in the check for a functioning mpicc.
4497 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4498 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4499 AM_COND_IF([VGCONF_OS_IS_LINUX],
4500            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4501             LDFLAGS_MPI="-fpic -shared"])
4502 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4503            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4504             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4505 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4506            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4507             LDFLAGS_MPI="-fpic -shared"])
4509 AC_SUBST([CFLAGS_MPI])
4510 AC_SUBST([LDFLAGS_MPI])
4513 ## See if MPI_CC works for the primary target
4515 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4516 saved_CC=$CC
4517 saved_CFLAGS=$CFLAGS
4518 CC=$MPI_CC
4519 CFLAGS="$CFLAGS_MPI $mflag_primary"
4520 saved_LDFLAGS="$LDFLAGS"
4521 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4522 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4523 #include <mpi.h>
4524 #include <stdio.h>
4525 ]], [[
4526   int ni, na, nd, comb;
4527   int r = MPI_Init(NULL,NULL);
4528   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4529   r |= MPI_Finalize();
4530   return r; 
4531 ]])], [
4532 ac_have_mpi2_pri=yes
4533 AC_MSG_RESULT([yes, $MPI_CC])
4534 ], [
4535 ac_have_mpi2_pri=no
4536 AC_MSG_RESULT([no])
4538 CC=$saved_CC
4539 CFLAGS=$saved_CFLAGS
4540 LDFLAGS="$saved_LDFLAGS"
4541 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4543 ## See if MPI_CC works for the secondary target.  Complication: what if
4544 ## there is no secondary target?  We need this to then fail.
4545 ## Kludge this by making MPI_CC something which will surely fail in
4546 ## such a case.
4548 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4549 saved_CC=$CC
4550 saved_CFLAGS=$CFLAGS
4551 saved_LDFLAGS="$LDFLAGS"
4552 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4553 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4554   CC="$MPI_CC this will surely fail"
4555 else
4556   CC=$MPI_CC
4558 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4559 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4560 #include <mpi.h>
4561 #include <stdio.h>
4562 ]], [[
4563   int ni, na, nd, comb;
4564   int r = MPI_Init(NULL,NULL);
4565   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4566   r |= MPI_Finalize();
4567   return r; 
4568 ]])], [
4569 ac_have_mpi2_sec=yes
4570 AC_MSG_RESULT([yes, $MPI_CC])
4571 ], [
4572 ac_have_mpi2_sec=no
4573 AC_MSG_RESULT([no])
4575 CC=$saved_CC
4576 CFLAGS=$saved_CFLAGS
4577 LDFLAGS="$saved_LDFLAGS"
4578 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4581 #----------------------------------------------------------------------------
4582 # Other library checks
4583 #----------------------------------------------------------------------------
4584 # There now follow some tests for Boost, and OpenMP.  These
4585 # tests are present because Drd has some regression tests that use
4586 # these packages.  All regression test programs all compiled only
4587 # for the primary target.  And so it is important that the configure
4588 # checks that follow, use the correct -m32 or -m64 flag for the
4589 # primary target (called $mflag_primary).  Otherwise, we can end up
4590 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4591 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4592 # only build (meaning, the primary target is x86-linux), the build
4593 # of the regtest programs that use Boost fails, because they are 
4594 # build as 32-bit (IN THIS EXAMPLE).
4596 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4597 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4600 # Check whether the boost library 1.35 or later has been installed.
4601 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4603 AC_MSG_CHECKING([for boost])
4605 AC_LANG(C++)
4606 safe_CXXFLAGS=$CXXFLAGS
4607 CXXFLAGS="$mflag_primary"
4608 safe_LIBS="$LIBS"
4609 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4611 AC_LINK_IFELSE([AC_LANG_SOURCE([
4612 #include <boost/thread.hpp>
4613 static void thread_func(void)
4614 { }
4615 int main(int argc, char** argv)
4617   boost::thread t(thread_func);
4618   return 0;
4620 ])],
4622 ac_have_boost_1_35=yes
4623 AC_SUBST([BOOST_CFLAGS], [])
4624 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4625 AC_MSG_RESULT([yes])
4626 ], [
4627 ac_have_boost_1_35=no
4628 AC_MSG_RESULT([no])
4631 LIBS="$safe_LIBS"
4632 CXXFLAGS=$safe_CXXFLAGS
4633 AC_LANG(C)
4635 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4638 # does this compiler support -fopenmp, does it have the include file
4639 # <omp.h> and does it have libgomp ?
4641 AC_MSG_CHECKING([for OpenMP])
4643 safe_CFLAGS=$CFLAGS
4644 CFLAGS="-fopenmp $mflag_primary -Werror"
4646 AC_LINK_IFELSE([AC_LANG_SOURCE([
4647 #include <omp.h> 
4648 int main(int argc, char** argv)
4650   omp_set_dynamic(0);
4651   return 0;
4653 ])],
4655 ac_have_openmp=yes
4656 AC_MSG_RESULT([yes])
4657 ], [
4658 ac_have_openmp=no
4659 AC_MSG_RESULT([no])
4661 CFLAGS=$safe_CFLAGS
4663 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4666 # Check for __builtin_popcount
4667 AC_MSG_CHECKING([for __builtin_popcount()])
4668 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4669 ]], [[
4670   __builtin_popcount(2);
4671   return 0;
4672 ]])], [
4673 AC_MSG_RESULT([yes])
4674 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4675           [Define to 1 if compiler provides __builtin_popcount().])
4676 ], [
4677 AC_MSG_RESULT([no])
4680 # Check for __builtin_clz
4681 AC_MSG_CHECKING([for __builtin_clz()])
4682 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4683 ]], [[
4684   __builtin_clz(2);
4685   return 0;
4686 ]])], [
4687 AC_MSG_RESULT([yes])
4688 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4689           [Define to 1 if compiler provides __builtin_clz().])
4690 ], [
4691 AC_MSG_RESULT([no])
4694 # Check for __builtin_ctz
4695 AC_MSG_CHECKING([for __builtin_ctz()])
4696 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4697 ]], [[
4698   __builtin_ctz(2);
4699   return 0;
4700 ]])], [
4701 AC_MSG_RESULT([yes])
4702 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4703           [Define to 1 if compiler provides __builtin_ctz().])
4704 ], [
4705 AC_MSG_RESULT([no])
4708 # does this compiler have built-in functions for atomic memory access for the
4709 # primary target ?
4710 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4712 safe_CFLAGS=$CFLAGS
4713 CFLAGS="$mflag_primary"
4715 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4716   int variable = 1;
4717   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4718           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4719 ]])], [
4720   ac_have_builtin_atomic_primary=yes
4721   AC_MSG_RESULT([yes])
4722   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])
4723 ], [
4724   ac_have_builtin_atomic_primary=no
4725   AC_MSG_RESULT([no])
4728 CFLAGS=$safe_CFLAGS
4730 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4731                [test x$ac_have_builtin_atomic_primary = xyes])
4734 # does this compiler have built-in functions for atomic memory access for the
4735 # secondary target ?
4737 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4739 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
4741 safe_CFLAGS=$CFLAGS
4742 CFLAGS="$mflag_secondary"
4744 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4745   int variable = 1;
4746   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
4747 ]])], [
4748   ac_have_builtin_atomic_secondary=yes
4749   AC_MSG_RESULT([yes])
4750 ], [
4751   ac_have_builtin_atomic_secondary=no
4752   AC_MSG_RESULT([no])
4755 CFLAGS=$safe_CFLAGS
4759 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
4760                [test x$ac_have_builtin_atomic_secondary = xyes])
4762 # does this compiler have built-in functions for atomic memory access on
4763 # 64-bit integers for all targets ?
4765 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
4767 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4768   #include <stdint.h>
4769 ]], [[
4770   uint64_t variable = 1;
4771   return __sync_add_and_fetch(&variable, 1)
4772 ]])], [
4773   ac_have_builtin_atomic64_primary=yes
4774 ], [
4775   ac_have_builtin_atomic64_primary=no
4778 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4780 safe_CFLAGS=$CFLAGS
4781 CFLAGS="$mflag_secondary"
4783 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4784   #include <stdint.h>
4785 ]], [[
4786   uint64_t variable = 1;
4787   return __sync_add_and_fetch(&variable, 1)
4788 ]])], [
4789   ac_have_builtin_atomic64_secondary=yes
4790 ], [
4791   ac_have_builtin_atomic64_secondary=no
4794 CFLAGS=$safe_CFLAGS
4798 if test x$ac_have_builtin_atomic64_primary = xyes && \
4799    test x$VGCONF_PLATFORM_SEC_CAPS = x \
4800      -o x$ac_have_builtin_atomic64_secondary = xyes; then
4801   AC_MSG_RESULT([yes])
4802   ac_have_builtin_atomic64=yes
4803 else
4804   AC_MSG_RESULT([no])
4805   ac_have_builtin_atomic64=no
4808 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
4809                [test x$ac_have_builtin_atomic64 = xyes])
4812 # does g++ have built-in functions for atomic memory access ?
4813 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
4815 safe_CXXFLAGS=$CXXFLAGS
4816 CXXFLAGS="$mflag_primary"
4818 AC_LANG_PUSH(C++)
4819 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4820   int variable = 1;
4821   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4822           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4823 ]])], [
4824   ac_have_builtin_atomic_cxx=yes
4825   AC_MSG_RESULT([yes])
4826   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
4827 ], [
4828   ac_have_builtin_atomic_cxx=no
4829   AC_MSG_RESULT([no])
4831 AC_LANG_POP(C++)
4833 CXXFLAGS=$safe_CXXFLAGS
4835 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
4838 if test x$ac_have_usable_linux_futex_h = xyes \
4839         -a x$ac_have_builtin_atomic_primary = xyes; then
4840   ac_enable_linux_ticket_lock_primary=yes
4842 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
4843                [test x$ac_enable_linux_ticket_lock_primary = xyes])
4845 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
4846         -a x$ac_have_usable_linux_futex_h = xyes \
4847         -a x$ac_have_builtin_atomic_secondary = xyes; then
4848   ac_enable_linux_ticket_lock_secondary=yes
4850 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
4851                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
4854 # does libstdc++ support annotating shared pointers ?
4855 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
4857 safe_CXXFLAGS=$CXXFLAGS
4858 CXXFLAGS="-std=c++0x"
4860 AC_LANG_PUSH(C++)
4861 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4862   #include <memory>
4863 ]], [[
4864   std::shared_ptr<int> p
4865 ]])], [
4866   ac_have_shared_ptr=yes
4867 ], [
4868   ac_have_shared_ptr=no
4870 if test x$ac_have_shared_ptr = xyes; then
4871   # If compilation of the program below fails because of a syntax error
4872   # triggered by substituting one of the annotation macros then that
4873   # means that libstdc++ supports these macros.
4874   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4875     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
4876     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
4877     #include <memory>
4878   ]], [[
4879     std::shared_ptr<int> p
4880   ]])], [
4881     ac_have_shared_pointer_annotation=no
4882     AC_MSG_RESULT([no])
4883   ], [
4884     ac_have_shared_pointer_annotation=yes
4885     AC_MSG_RESULT([yes])
4886     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
4887               [Define to 1 if libstd++ supports annotating shared pointers])
4888   ])
4889 else
4890   ac_have_shared_pointer_annotation=no
4891   AC_MSG_RESULT([no])
4893 AC_LANG_POP(C++)
4895 CXXFLAGS=$safe_CXXFLAGS
4897 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
4898                [test x$ac_have_shared_pointer_annotation = xyes])
4901 #----------------------------------------------------------------------------
4902 # Ok.  We're done checking.
4903 #----------------------------------------------------------------------------
4905 # Nb: VEX/Makefile is generated from Makefile.vex.in.
4906 AC_CONFIG_FILES([
4907    Makefile 
4908    VEX/Makefile:Makefile.vex.in
4909    valgrind.spec
4910    valgrind.pc
4911    glibc-2.X.supp
4912    docs/Makefile 
4913    tests/Makefile 
4914    tests/vg_regtest 
4915    perf/Makefile 
4916    perf/vg_perf
4917    gdbserver_tests/Makefile
4918    gdbserver_tests/solaris/Makefile
4919    include/Makefile 
4920    auxprogs/Makefile
4921    mpi/Makefile
4922    coregrind/Makefile 
4923    memcheck/Makefile
4924    memcheck/tests/Makefile
4925    memcheck/tests/common/Makefile
4926    memcheck/tests/amd64/Makefile
4927    memcheck/tests/x86/Makefile
4928    memcheck/tests/linux/Makefile
4929    memcheck/tests/linux/debuginfod-check.vgtest
4930    memcheck/tests/darwin/Makefile
4931    memcheck/tests/solaris/Makefile
4932    memcheck/tests/amd64-linux/Makefile
4933    memcheck/tests/arm64-linux/Makefile
4934    memcheck/tests/x86-linux/Makefile
4935    memcheck/tests/amd64-solaris/Makefile
4936    memcheck/tests/x86-solaris/Makefile
4937    memcheck/tests/ppc32/Makefile
4938    memcheck/tests/ppc64/Makefile
4939    memcheck/tests/s390x/Makefile
4940    memcheck/tests/mips32/Makefile
4941    memcheck/tests/mips64/Makefile
4942    memcheck/tests/vbit-test/Makefile
4943    cachegrind/Makefile
4944    cachegrind/tests/Makefile
4945    cachegrind/tests/x86/Makefile
4946    cachegrind/cg_annotate
4947    cachegrind/cg_diff
4948    callgrind/Makefile
4949    callgrind/callgrind_annotate
4950    callgrind/callgrind_control
4951    callgrind/tests/Makefile
4952    helgrind/Makefile
4953    helgrind/tests/Makefile
4954    drd/Makefile
4955    drd/scripts/download-and-build-splash2
4956    drd/tests/Makefile
4957    massif/Makefile
4958    massif/tests/Makefile
4959    massif/ms_print
4960    dhat/Makefile
4961    dhat/tests/Makefile
4962    lackey/Makefile
4963    lackey/tests/Makefile
4964    none/Makefile
4965    none/tests/Makefile
4966    none/tests/scripts/Makefile
4967    none/tests/amd64/Makefile
4968    none/tests/ppc32/Makefile
4969    none/tests/ppc64/Makefile
4970    none/tests/x86/Makefile
4971    none/tests/arm/Makefile
4972    none/tests/arm64/Makefile
4973    none/tests/s390x/Makefile
4974    none/tests/mips32/Makefile
4975    none/tests/mips64/Makefile
4976    none/tests/nanomips/Makefile
4977    none/tests/linux/Makefile
4978    none/tests/darwin/Makefile
4979    none/tests/solaris/Makefile
4980    none/tests/amd64-linux/Makefile
4981    none/tests/x86-linux/Makefile
4982    none/tests/amd64-darwin/Makefile
4983    none/tests/x86-darwin/Makefile
4984    none/tests/amd64-solaris/Makefile
4985    none/tests/x86-solaris/Makefile
4986    exp-bbv/Makefile
4987    exp-bbv/tests/Makefile
4988    exp-bbv/tests/x86/Makefile
4989    exp-bbv/tests/x86-linux/Makefile
4990    exp-bbv/tests/amd64-linux/Makefile
4991    exp-bbv/tests/ppc32-linux/Makefile
4992    exp-bbv/tests/arm-linux/Makefile
4993    shared/Makefile
4994    solaris/Makefile
4996 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
4997                 [chmod +x coregrind/link_tool_exe_linux])
4998 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
4999                 [chmod +x coregrind/link_tool_exe_darwin])
5000 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5001                 [chmod +x coregrind/link_tool_exe_solaris])
5002 AC_OUTPUT
5004 cat<<EOF
5006          Maximum build arch: ${ARCH_MAX}
5007          Primary build arch: ${VGCONF_ARCH_PRI}
5008        Secondary build arch: ${VGCONF_ARCH_SEC}
5009                    Build OS: ${VGCONF_OS}
5010      Link Time Optimisation: ${vg_cv_lto}
5011        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5012      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5013            Platform variant: ${VGCONF_PLATVARIANT}
5014       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5015          Default supp files: ${DEFAULT_SUPP}