Add 439590 glibc-2.34 breaks suppressions to NEWS
[valgrind.git] / configure.ac
blobbeb5bba792bb4395ebdb933190bba8305487d0cf
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.18.0.GIT],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign 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 # If this is glibc then figure out the generic (in file) libc.so and
1094 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1095 # was a separate library, afterwards it was merged into libc.so and
1096 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1097 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1098 case ${GLIBC_VERSION} in
1100   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1101   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1102   [
1103     AC_MSG_RESULT([no])
1104     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1105     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1106   ], [
1107     AC_MSG_RESULT([yes])
1108     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1109     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1110   ])
1111   ;;
1113   AC_MSG_CHECKING([not glibc...])
1114   AC_MSG_RESULT([${GLIBC_VERSION}])
1115   ;;
1116 esac
1118 AC_MSG_CHECKING([the glibc version])
1120 case "${GLIBC_VERSION}" in
1121      2.2)
1122         AC_MSG_RESULT(${GLIBC_VERSION} family)
1123         DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1124         DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1125         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1126         ;;
1127      2.[[3-6]])
1128         AC_MSG_RESULT(${GLIBC_VERSION} family)
1129         DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1130         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1131         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1132         ;;
1133      2.[[7-9]])
1134         AC_MSG_RESULT(${GLIBC_VERSION} family)
1135         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1136         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1137         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1138         ;;
1139      2.10|2.11)
1140         AC_MSG_RESULT(${GLIBC_VERSION} family)
1141         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1142                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1143         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1144         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1145         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1146         ;;
1147      2.*)
1148         AC_MSG_RESULT(${GLIBC_VERSION} family)
1149         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1150                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1151         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1152                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1153         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1154         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1155         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1156         ;;
1157      darwin)
1158         AC_MSG_RESULT(Darwin)
1159         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1160         # DEFAULT_SUPP set by kernel version check above.
1161         ;;
1162      bionic)
1163         AC_MSG_RESULT(Bionic)
1164         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1165         DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1166         ;;
1167      solaris)
1168         AC_MSG_RESULT(Solaris)
1169         # DEFAULT_SUPP set in host_os switch-case above.
1170         # No other suppression file is used.
1171         ;;
1172      musl)
1173         AC_MSG_RESULT(Musl)
1174         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1175         DEFAULT_SUPP="musl.supp ${DEFAULT_SUPP}"
1176         ;;
1177      2.0|2.1|*)
1178         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1179         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1180         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1181         ;;
1182 esac
1184 AC_SUBST(GLIBC_VERSION)
1185 AC_SUBST(GLIBC_LIBC_PATH)
1186 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1189 if test "$VGCONF_OS" != "solaris"; then
1190     # Add default suppressions for the X client libraries.  Make no
1191     # attempt to detect whether such libraries are installed on the
1192     # build machine (or even if any X facilities are present); just
1193     # add the suppressions antidisirregardless.
1194     DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1195     DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1199 #----------------------------------------------------------------------------
1200 # Platform variants?
1201 #----------------------------------------------------------------------------
1203 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1204 # But there are times where we need a bit more control.  The motivating
1205 # and currently only case is Android: this is almost identical to
1206 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1207 # platform variant tags, which get passed in the compile as
1208 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1210 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1211 # it is "android" instead.
1213 # Consequently (eg), plain arm-linux would build with
1215 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1217 # whilst an Android build would have
1219 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1221 # Same for x86. The setup of the platform variant is pushed relatively far
1222 # down this file in order that we can inspect any of the variables set above.
1224 # In the normal case ..
1225 VGCONF_PLATVARIANT="vanilla"
1227 # Android ?
1228 if test "$GLIBC_VERSION" = "bionic";
1229 then
1230    VGCONF_PLATVARIANT="android"
1233 AC_SUBST(VGCONF_PLATVARIANT)
1236 # FIXME: do we also want to define automake variables
1237 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1238 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1239 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1240 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1241 # that's what we'd need to do to use this, since what we'd want to write
1242 # is something like
1244 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1246 # Hmm.  Can't think of a nice clean solution to this.
1248 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1249                test x$VGCONF_PLATVARIANT = xvanilla)
1250 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1251                test x$VGCONF_PLATVARIANT = xandroid)
1254 #----------------------------------------------------------------------------
1255 # Checking for various library functions and other definitions
1256 #----------------------------------------------------------------------------
1258 # Check for AT_FDCWD
1260 AC_MSG_CHECKING([for AT_FDCWD])
1261 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1262 #define _GNU_SOURCE
1263 #include <fcntl.h>
1264 #include <unistd.h>
1265 ]], [[
1266   int a = AT_FDCWD;
1267 ]])], [
1268 ac_have_at_fdcwd=yes
1269 AC_MSG_RESULT([yes])
1270 ], [
1271 ac_have_at_fdcwd=no
1272 AC_MSG_RESULT([no])
1275 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1277 # Check for stpncpy function definition in string.h
1278 # This explicitly checks with _GNU_SOURCE defined since that is also
1279 # used in the test case (some systems might define it without anyway
1280 # since stpncpy is part of The Open Group Base Specifications Issue 7
1281 # IEEE Std 1003.1-2008.
1282 AC_MSG_CHECKING([for stpncpy])
1283 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1284 #define _GNU_SOURCE
1285 #include <string.h>
1286 ]], [[
1287   char *d;
1288   char *s;
1289   size_t n = 0;
1290   char *r = stpncpy(d, s, n);
1291 ]])], [
1292 ac_have_gnu_stpncpy=yes
1293 AC_MSG_RESULT([yes])
1294 ], [
1295 ac_have_gnu_stpncpy=no
1296 AC_MSG_RESULT([no])
1299 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1301 # Check for PTRACE_GETREGS
1303 AC_MSG_CHECKING([for PTRACE_GETREGS])
1304 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1305 #include <stdlib.h>
1306 #include <stddef.h>
1307 #include <sys/ptrace.h>
1308 #include <sys/user.h>
1309 ]], [[
1310   void *p;
1311   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1312 ]])], [
1313 AC_MSG_RESULT([yes])
1314 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1315           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1316 ], [
1317 AC_MSG_RESULT([no])
1321 # Check for CLOCK_MONOTONIC
1323 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1325 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1326 #include <time.h>
1327 ]], [[
1328   struct timespec t;
1329   clock_gettime(CLOCK_MONOTONIC, &t);
1330   return 0;
1331 ]])], [
1332 AC_MSG_RESULT([yes])
1333 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1334           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1335 ], [
1336 AC_MSG_RESULT([no])
1340 # Check for ELF32/64_CHDR
1342 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1345 # Check for PTHREAD_RWLOCK_T
1347 AC_MSG_CHECKING([for pthread_rwlock_t])
1349 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1350 #define _GNU_SOURCE
1351 #include <pthread.h>
1352 ]], [[
1353   pthread_rwlock_t rwl;
1354 ]])], [
1355 AC_MSG_RESULT([yes])
1356 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1357           [Define to 1 if you have the `pthread_rwlock_t' type.])
1358 ], [
1359 AC_MSG_RESULT([no])
1363 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1365 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1367 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1368 #define _GNU_SOURCE
1369 #include <pthread.h>
1370 ]], [[
1371   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1372 ]])], [
1373 AC_MSG_RESULT([yes])
1374 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1375           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1376 ], [
1377 AC_MSG_RESULT([no])
1381 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1383 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1385 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1386 #define _GNU_SOURCE
1387 #include <pthread.h>
1388 ]], [[
1389   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1390 ]])], [
1391 AC_MSG_RESULT([yes])
1392 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1393           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1394 ], [
1395 AC_MSG_RESULT([no])
1399 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1401 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1403 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1404 #define _GNU_SOURCE
1405 #include <pthread.h>
1406 ]], [[
1407   return (PTHREAD_MUTEX_RECURSIVE_NP);
1408 ]])], [
1409 AC_MSG_RESULT([yes])
1410 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1411           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1412 ], [
1413 AC_MSG_RESULT([no])
1417 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1419 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1421 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1422 #define _GNU_SOURCE
1423 #include <pthread.h>
1424 ]], [[
1425   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1426   return 0;
1427 ]])], [
1428 AC_MSG_RESULT([yes])
1429 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1430           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1431 ], [
1432 AC_MSG_RESULT([no])
1436 # Check whether pthread_mutex_t has a member called __m_kind.
1438 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1439                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1440                            1,                                   
1441                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1442                 ],
1443                 [],
1444                 [#include <pthread.h>])
1447 # Check whether pthread_mutex_t has a member called __data.__kind.
1449 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1450                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1451                           1,
1452                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1453                 ],
1454                 [],
1455                 [#include <pthread.h>])
1457 # Convenience function.  Set flags based on the existing HWCAP entries.
1458 # The AT_HWCAP entries are generated by glibc, and are based on
1459 # functions supported by the hardware/system/libc.
1460 # Subsequent support for whether the capability will actually be utilized
1461 # will also be checked against the compiler capabilities.
1462 # called as
1463 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1464 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1465   AUXV_CHECK_FOR=$1
1466   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1467   if LD_SHOW_AUXV=1 `which true` | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1468   then
1469     AC_MSG_RESULT([yes])
1470     AC_SUBST([$2],[yes])
1471   else
1472     AC_MSG_RESULT([no])
1473     AC_SUBST([$2],[])
1474   fi
1477 # gather hardware capabilities. (hardware/kernel/libc)
1478 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1479 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1480 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1481 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1482 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1483 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1484 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1485 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1486 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1487 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1489 # ISA Levels
1490 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1491 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1492 # compiler support for isa 2.07 level instructions
1493 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1494 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1495 ]], [[
1496   __asm__ __volatile__("mtvsrd 1,2 ");
1497 ]])], [
1498 ac_asm_have_isa_2_07=yes
1499 AC_MSG_RESULT([yes])
1500 ], [
1501 ac_asm_have_isa_2_07=no
1502 AC_MSG_RESULT([no])
1504 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1505                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1507 # altivec (vsx) support.
1508 # does this compiler support -maltivec and does it have the include file
1509 # <altivec.h> ?
1510 AC_MSG_CHECKING([for Altivec support in the compiler ])
1511 safe_CFLAGS=$CFLAGS
1512 CFLAGS="-maltivec -Werror"
1513 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1514 #include <altivec.h>
1515 ]], [[
1516   vector unsigned int v;
1517 ]])], [
1518 ac_have_altivec=yes
1519 AC_MSG_RESULT([yes])
1520 ], [
1521 ac_have_altivec=no
1522 AC_MSG_RESULT([no])
1524 CFLAGS=$safe_CFLAGS
1525 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1526                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1528 # Check that both: the compiler supports -mvsx and that the assembler
1529 # understands VSX instructions.  If either of those doesn't work,
1530 # conclude that we can't do VSX.
1531 AC_MSG_CHECKING([for VSX compiler flag support])
1532 safe_CFLAGS=$CFLAGS
1533 CFLAGS="-mvsx -Werror"
1534 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1535 ]], [[
1536 ]])], [
1537 ac_compiler_supports_vsx_flag=yes
1538 AC_MSG_RESULT([yes])
1539 ], [
1540 ac_compiler_supports_vsx_flag=no
1541 AC_MSG_RESULT([no])
1543 CFLAGS=$safe_CFLAGS
1545 AC_MSG_CHECKING([for VSX support in the assembler ])
1546 safe_CFLAGS=$CFLAGS
1547 CFLAGS="-mvsx -Werror"
1548 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1549 #include <altivec.h>
1550 ]], [[
1551   vector unsigned int v;
1552   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1553 ]])], [
1554 ac_compiler_supports_vsx=yes
1555 AC_MSG_RESULT([yes])
1556 ], [
1557 ac_compiler_supports_vsx=no
1558 AC_MSG_RESULT([no])
1560 CFLAGS=$safe_CFLAGS
1561 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1562                              -a x$ac_compiler_supports_vsx = xyes \
1563                              -a x$HWCAP_HAS_VSX = xyes ])
1565 # DFP (Decimal Float)
1566 AC_MSG_CHECKING([that assembler knows DFP])
1567 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1568 ]], [[
1569   #ifdef __s390__
1570   __asm__ __volatile__("adtr 1, 2, 3")
1571   #else
1572   __asm__ __volatile__("dadd 1, 2, 3");
1573   __asm__ __volatile__("dcffix 1, 2");
1574   #endif
1575 ]])], [
1576 ac_asm_have_dfp=yes
1577 AC_MSG_RESULT([yes])
1578 ], [
1579 ac_asm_have_dfp=no
1580 AC_MSG_RESULT([no])
1582 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1583 safe_CFLAGS=$CFLAGS
1584 CFLAGS="-mhard-dfp -Werror"
1585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1586 ]], [[
1587   #ifdef __s390__
1588   __asm__ __volatile__("adtr 1, 2, 3")
1589   #else
1590   __asm__ __volatile__("dadd 1, 2, 3");
1591   __asm__ __volatile__("dcffix 1, 2");
1592   #endif
1593 ]])], [
1594 ac_compiler_have_dfp=yes
1595 AC_MSG_RESULT([yes])
1596 ], [
1597 ac_compiler_have_dfp=no
1598 AC_MSG_RESULT([no])
1600 CFLAGS=$safe_CFLAGS
1601 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1602                           -a x$ac_compiler_have_dfp = xyes \
1603                           -a x$HWCAP_HAS_DFP = xyes )
1605 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1606 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1607 ]], [[
1608   _Decimal64 x = 0.0DD;
1609 ]])], [
1610 ac_compiler_have_dfp_type=yes
1611 AC_MSG_RESULT([yes])
1612 ], [
1613 ac_compiler_have_dfp_type=no
1614 AC_MSG_RESULT([no])
1616 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1617                                   -a x$HWCAP_HAS_DFP = xyes )
1620 # HTM (Hardware Transactional Memory)
1621 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1622 safe_CFLAGS=$CFLAGS
1623 CFLAGS="-mhtm -Werror"
1624 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1625 ]], [[
1626   return 0;
1627 ]])], [
1628 AC_MSG_RESULT([yes])
1629 ac_compiler_supports_htm=yes
1630 ], [
1631 AC_MSG_RESULT([no])
1632 ac_compiler_supports_htm=no
1634 CFLAGS=$safe_CFLAGS
1636 AC_MSG_CHECKING([if compiler can find the htm builtins])
1637 safe_CFLAGS=$CFLAGS
1638 CFLAGS="-mhtm -Werror"
1639  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1640  ]], [[
1641    if (__builtin_tbegin (0))
1642       __builtin_tend (0);
1643  ]])], [
1644  AC_MSG_RESULT([yes])
1645 ac_compiler_sees_htm_builtins=yes
1646  ], [
1647  AC_MSG_RESULT([no])
1648 ac_compiler_sees_htm_builtins=no
1649  ])
1650 CFLAGS=$safe_CFLAGS
1652 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1653                                -a x$ac_compiler_sees_htm_builtins = xyes \
1654                                -a x$HWCAP_HAS_HTM = xyes )
1656 # isa 3.0 checking. (actually 3.0 or newer)
1657 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1659 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1660 ]], [[
1661   __asm__ __volatile__("cnttzw 1,2 ");
1662 ]])], [
1663 ac_asm_have_isa_3_00=yes
1664 AC_MSG_RESULT([yes])
1665 ], [
1666 ac_asm_have_isa_3_00=no
1667 AC_MSG_RESULT([no])
1670 # xscvhpdp checking
1671 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1673 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1674 ]], [[
1675   __asm__ __volatile__("xscvhpdp 1,2 ");
1676 ]])], [
1677 ac_asm_have_xscvhpdp=yes
1678 AC_MSG_RESULT([yes])
1679 ], [
1680 ac_asm_have_xscvhpdp=no
1681 AC_MSG_RESULT([no])
1684 # darn instruction checking
1685 AC_MSG_CHECKING([that assembler knows darn instruction ])
1687 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1688 ]], [[
1689   __asm__ __volatile__("darn 1,0 ");
1690 ]])], [
1691 ac_asm_have_darn_inst=yes
1692 AC_MSG_RESULT([yes])
1693 ], [
1694 ac_asm_have_darn_inst=no
1695 AC_MSG_RESULT([no])
1698 # isa 3.01 checking
1699 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1701 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1702 ]], [[
1703   __asm__ __volatile__("brh 1,2 ");
1704 ]])], [
1705 ac_asm_have_isa_3_1=yes
1706 AC_MSG_RESULT([yes])
1707 ], [
1708 ac_asm_have_isa_3_1=no
1709 AC_MSG_RESULT([no])
1713 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1714                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1716 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1717 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1719 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1720                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1722 # Check for pthread_create@GLIBC2.0
1723 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1725 safe_CFLAGS=$CFLAGS
1726 CFLAGS="-lpthread -Werror"
1727 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1728 extern int pthread_create_glibc_2_0(void*, const void*,
1729                                     void *(*)(void*), void*);
1730 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1731 ]], [[
1732 #ifdef __powerpc__
1734  * Apparently on PowerPC linking this program succeeds and generates an
1735  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1736  */
1737 #error This test does not work properly on PowerPC.
1738 #else
1739   pthread_create_glibc_2_0(0, 0, 0, 0);
1740 #endif
1741   return 0;
1742 ]])], [
1743 ac_have_pthread_create_glibc_2_0=yes
1744 AC_MSG_RESULT([yes])
1745 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1746           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1747 ], [
1748 ac_have_pthread_create_glibc_2_0=no
1749 AC_MSG_RESULT([no])
1751 CFLAGS=$safe_CFLAGS
1753 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1754                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1757 # Check for dlinfo RTLD_DI_TLS_MODID
1758 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1760 safe_LIBS="$LIBS"
1761 LIBS="-ldl"
1762 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1763 #ifndef _GNU_SOURCE
1764 #define _GNU_SOURCE
1765 #endif
1766 #include <link.h>
1767 #include <dlfcn.h>
1768 ]], [[
1769   size_t sizes[10000];
1770   size_t modid_offset;
1771   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1772   return 0;
1773 ]])], [
1774 ac_have_dlinfo_rtld_di_tls_modid=yes
1775 AC_MSG_RESULT([yes])
1776 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1777           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1778 ], [
1779 ac_have_dlinfo_rtld_di_tls_modid=no
1780 AC_MSG_RESULT([no])
1782 LIBS=$safe_LIBS
1784 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1785                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1788 # Check for eventfd_t, eventfd() and eventfd_read()
1789 AC_MSG_CHECKING([for eventfd()])
1791 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1792 #include <sys/eventfd.h>
1793 ]], [[
1794   eventfd_t ev;
1795   int fd;
1797   fd = eventfd(5, 0);
1798   eventfd_read(fd, &ev);
1799   return 0;
1800 ]])], [
1801 AC_MSG_RESULT([yes])
1802 AC_DEFINE([HAVE_EVENTFD], 1,
1803           [Define to 1 if you have the `eventfd' function.])
1804 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1805           [Define to 1 if you have the `eventfd_read' function.])
1806 ], [
1807 AC_MSG_RESULT([no])
1810 # Check whether compiler can process #include <thread> without errors
1811 # clang 3.3 cannot process <thread> from e.g.
1812 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1814 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1815 AC_LANG(C++)
1816 safe_CXXFLAGS=$CXXFLAGS
1817 CXXFLAGS=-std=c++0x
1819 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1820 #include <thread> 
1821 ])],
1823 ac_cxx_can_include_thread_header=yes
1824 AC_MSG_RESULT([yes])
1825 ], [
1826 ac_cxx_can_include_thread_header=no
1827 AC_MSG_RESULT([no])
1829 CXXFLAGS=$safe_CXXFLAGS
1830 AC_LANG(C)
1832 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1835 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1836 # of the user_regs_struct from sys/user.h. They are structurally the same
1837 # but we get either one or the other.
1839 AC_CHECK_TYPE([struct user_regs_struct],
1840               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1841               [[#include <sys/ptrace.h>]
1842                [#include <sys/time.h>]
1843                [#include <sys/user.h>]])
1844 if test "$sys_user_has_user_regs" = "yes"; then
1845   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1846             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1849 AC_MSG_CHECKING([for __NR_membarrier])
1850 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1851 #include <linux/unistd.h>
1852 ]], [[
1853 return __NR_membarrier
1854 ]])], [
1855 ac_have_nr_membarrier=yes
1856 AC_MSG_RESULT([yes])
1857 ], [
1858 ac_have_nr_membarrier=no
1859 AC_MSG_RESULT([no])
1862 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
1864 #----------------------------------------------------------------------------
1865 # Checking for supported compiler flags.
1866 #----------------------------------------------------------------------------
1868 case "${host_cpu}" in
1869     mips*)
1870         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1871         if test -z "$ARCH"; then
1872           # does this compiler support -march=mips32 (mips32 default) ?
1873           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
1875           safe_CFLAGS=$CFLAGS
1876           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
1878           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1879             return 0;
1880           ]])], [
1881           FLAG_M32="-mips32 -mabi=32"
1882           AC_MSG_RESULT([yes])
1883           ], [
1884           FLAG_M32=""
1885           AC_MSG_RESULT([no])
1886           ])
1887           CFLAGS=$safe_CFLAGS
1889           AC_SUBST(FLAG_M32)
1892           # does this compiler support -march=mips64r2 (mips64r2 default) ?
1893           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
1895           safe_CFLAGS=$CFLAGS
1896           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
1898           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1899             return 0;
1900           ]])], [
1901           FLAG_M64="-march=mips64r2 -mabi=64"
1902           AC_MSG_RESULT([yes])
1903           ], [
1904           FLAG_M64=""
1905           AC_MSG_RESULT([no])
1906           ])
1907           CFLAGS=$safe_CFLAGS
1909           AC_SUBST(FLAG_M64)
1910         fi
1911         ;;
1912     nanomips*)
1913         ;;
1914     *)
1915         # does this compiler support -m32 ?
1916         AC_MSG_CHECKING([if gcc accepts -m32])
1918         safe_CFLAGS=$CFLAGS
1919         CFLAGS="-m32 -Werror"
1921         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1922           return 0;
1923         ]])], [
1924         FLAG_M32="-m32"
1925         AC_MSG_RESULT([yes])
1926         ], [
1927         FLAG_M32=""
1928         AC_MSG_RESULT([no])
1929         ])
1930         CFLAGS=$safe_CFLAGS
1932         AC_SUBST(FLAG_M32)
1935         # does this compiler support -m64 ?
1936         AC_MSG_CHECKING([if gcc accepts -m64])
1938         safe_CFLAGS=$CFLAGS
1939         CFLAGS="-m64 -Werror"
1941         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1942           return 0;
1943         ]])], [
1944         FLAG_M64="-m64"
1945         AC_MSG_RESULT([yes])
1946         ], [
1947         FLAG_M64=""
1948         AC_MSG_RESULT([no])
1949         ])
1950         CFLAGS=$safe_CFLAGS
1952         AC_SUBST(FLAG_M64)
1953         ;;
1954 esac
1957 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1958 if test -z "$ARCH"; then
1959   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1960   AC_MSG_CHECKING([if gcc accepts -march=octeon])
1962   safe_CFLAGS=$CFLAGS
1963   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
1965   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1966     return 0;
1967   ]])], [
1968   FLAG_OCTEON="-march=octeon"
1969   AC_MSG_RESULT([yes])
1970   ], [
1971   FLAG_OCTEON=""
1972   AC_MSG_RESULT([no])
1973   ])
1974   CFLAGS=$safe_CFLAGS
1976   AC_SUBST(FLAG_OCTEON)
1979   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1980   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1982   safe_CFLAGS=$CFLAGS
1983   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
1985   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1986     return 0;
1987   ]])], [
1988   FLAG_OCTEON2="-march=octeon2"
1989   AC_MSG_RESULT([yes])
1990   ], [
1991   FLAG_OCTEON2=""
1992   AC_MSG_RESULT([no])
1993   ])
1994   CFLAGS=$safe_CFLAGS
1996   AC_SUBST(FLAG_OCTEON2)
2000 # does this compiler support -mmsa (MIPS MSA ASE) ?
2001 AC_MSG_CHECKING([if gcc accepts -mmsa])
2003 safe_CFLAGS=$CFLAGS
2004 CFLAGS="$CFLAGS -mmsa -Werror"
2006 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2007     return 0;
2008 ]])], [
2009 FLAG_MSA="-mmsa"
2010 AC_MSG_RESULT([yes])
2011 ], [
2012 FLAG_MSA=""
2013 AC_MSG_RESULT([no])
2015 CFLAGS=$safe_CFLAGS
2017 AC_SUBST(FLAG_MSA)
2019 # Are we compiling for the MIPS64 n32 ABI?
2020 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2021 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2022 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2023 #error NO
2024 #endif
2025 ]])], [
2026 VGCONF_ABI=N32
2027 FLAG_M64="-march=mips64r2 -mabi=n32"
2028 AC_MSG_RESULT([yes])
2029 ], [
2030 AC_MSG_RESULT([no])
2033 # Are we compiling for the MIPS64 n64 ABI?
2034 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2035 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2036 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2037 #error NO
2038 #endif
2039 ]])], [
2040 VGCONF_ABI=64
2041 AC_MSG_RESULT([yes])
2042 ], [
2043 AC_MSG_RESULT([no])
2046 # We enter the code block below in the following case:
2047 # Target architecture is set to mips64, the desired abi
2048 # was not specified and the compiler's default abi setting
2049 # is neither n32 nor n64.
2050 # Probe for and set the abi to either n64 or n32, in that order,
2051 # which is required for a mips64 build of valgrind.
2052 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2053   safe_CFLAGS=$CFLAGS
2054   CFLAGS="$CFLAGS -mabi=64 -Werror"
2055   AC_MSG_CHECKING([if gcc is n64 capable])
2056   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2057       return 0;
2058   ]])], [
2059   VGCONF_ABI=64
2060   AC_MSG_RESULT([yes])
2061   ], [
2062   AC_MSG_RESULT([no])
2063   ])
2064   CFLAGS=$safe_CFLAGS
2066   if test "x$VGCONF_ABI" = "x"; then
2067     safe_CFLAGS=$CFLAGS
2068     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2069     AC_MSG_CHECKING([if gcc is n32 capable])
2070     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2071         return 0;
2072     ]])], [
2073     VGCONF_ABI=N32
2074     FLAG_M64="-march=mips64r2 -mabi=n32"
2075     AC_MSG_RESULT([yes])
2076     ], [
2077     AC_MSG_RESULT([no])
2078     ])
2079     CFLAGS=$safe_CFLAGS
2080   fi
2083 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2084                [test x$VGCONF_ABI != x])
2085 AC_SUBST(VGCONF_ABI)
2088 # does this compiler support -mmmx ?
2089 AC_MSG_CHECKING([if gcc accepts -mmmx])
2091 safe_CFLAGS=$CFLAGS
2092 CFLAGS="-mmmx -Werror"
2094 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2095   return 0;
2096 ]])], [
2097 FLAG_MMMX="-mmmx"
2098 AC_MSG_RESULT([yes])
2099 ], [
2100 FLAG_MMMX=""
2101 AC_MSG_RESULT([no])
2103 CFLAGS=$safe_CFLAGS
2105 AC_SUBST(FLAG_MMMX)
2108 # does this compiler support -msse ?
2109 AC_MSG_CHECKING([if gcc accepts -msse])
2111 safe_CFLAGS=$CFLAGS
2112 CFLAGS="-msse -Werror"
2114 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2115   return 0;
2116 ]])], [
2117 FLAG_MSSE="-msse"
2118 AC_MSG_RESULT([yes])
2119 ], [
2120 FLAG_MSSE=""
2121 AC_MSG_RESULT([no])
2123 CFLAGS=$safe_CFLAGS
2125 AC_SUBST(FLAG_MSSE)
2128 # does this compiler support -mpreferred-stack-boundary=2 when
2129 # generating code for a 32-bit target?  Note that we only care about
2130 # this when generating code for (32-bit) x86, so if the compiler
2131 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2132 # the Memcheck and other helper functions, that is a bit slower than
2133 # it could be, on x86; and no difference at all on any other platform.
2134 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2136 safe_CFLAGS=$CFLAGS
2137 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2139 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2140   return 0;
2141 ]])], [
2142 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2143 AC_MSG_RESULT([yes])
2144 ], [
2145 PREFERRED_STACK_BOUNDARY_2=""
2146 AC_MSG_RESULT([no])
2148 CFLAGS=$safe_CFLAGS
2150 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2153 # does this compiler support -mlong-double-128 ?
2154 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2155 safe_CFLAGS=$CFLAGS
2156 CFLAGS="-mlong-double-128 -Werror"
2157 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2158   return 0;
2159 ]])], [
2160 ac_compiler_supports_mlong_double_128=yes
2161 AC_MSG_RESULT([yes])
2162 ], [
2163 ac_compiler_supports_mlong_double_128=no
2164 AC_MSG_RESULT([no])
2166 CFLAGS=$safe_CFLAGS
2167 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2168 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2169 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2171 # does this toolchain support lto ?
2172 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2173 # are not defined
2174 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2175 # a lot slower, and so not appropriate for Valgrind developments.
2176 # --enable-lto=yes should be used by distro packagers.
2177 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2178    [AC_ARG_ENABLE(lto,
2179       [  --enable-lto          enables building with link time optimisation],
2180       [vg_cv_lto=$enableval],
2181       [vg_cv_lto=no])])
2183 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2184 AC_MSG_CHECKING([if toolchain accepts lto])
2185 safe_CFLAGS=$CFLAGS
2186 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2187 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2188 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2189 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2191 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2192   extern void somefun(void);
2193   somefun();
2194   return 0;
2195 ]])], [
2196 LTO_CFLAGS=$TEST_LTO_CFLAGS
2197 AC_MSG_RESULT([yes])
2198 ], [
2199 LTO_CFLAGS=""
2200 AC_MSG_RESULT([no])
2202 CFLAGS=$safe_CFLAGS
2205 AC_SUBST(LTO_CFLAGS)
2207 # if we could not compile with lto args, or lto was disabled,
2208 # then set LTO_AR/LTO_RANLIB to the non lto values
2209 # define in config.h ENABLE_LTO (not needed by the code currently, but
2210 # this guarantees we recompile everything if we re-configure and rebuild
2211 # in a build dir previously build with another value of --enable-lto
2212 if test "x${LTO_CFLAGS}" = "x"; then
2213    LTO_AR=${AR}
2214    LTO_RANLIB=${RANLIB}
2215    vg_cv_lto=no
2216 else
2217    vg_cv_lto=yes
2218    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2221 # Convenience function to check whether GCC supports a particular
2222 # warning option. Takes two arguments,
2223 # first the warning flag name to check (without -W), then the
2224 # substitution name to set with -Wno-warning-flag if the flag exists,
2225 # or the empty string if the compiler doesn't accept the flag. Note
2226 # that checking is done against the warning flag itself, but the
2227 # substitution is then done to cancel the warning flag.
2228 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2229   AC_MSG_CHECKING([if gcc accepts -W$1])
2230   safe_CFLAGS=$CFLAGS
2231   CFLAGS="-W$1 -Werror"
2232   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2233   AC_SUBST([$2], [-Wno-$1])
2234   AC_MSG_RESULT([yes])], [
2235   AC_SUBST([$2], [])
2236   AC_MSG_RESULT([no])])
2237   CFLAGS=$safe_CFLAGS
2240 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2241 # -W$1  (instead of -Wno-$1).
2242 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2243   AC_MSG_CHECKING([if gcc accepts -W$1])
2244   safe_CFLAGS=$CFLAGS
2245   CFLAGS="-W$1 -Werror"
2246   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2247   AC_SUBST([$2], [-W$1])
2248   AC_MSG_RESULT([yes])], [
2249   AC_SUBST([$2], [])
2250   AC_MSG_RESULT([no])])
2251   CFLAGS=$safe_CFLAGS
2254 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2255 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2256 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2257 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2258 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2259 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2260 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2261 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2262 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2264 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2265 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2266 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2267 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2268 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2269 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2270 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2271 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2272 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2273 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2274 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2276 # Does this compiler support -Wformat-security ?
2277 # Special handling is needed, because certain GCC versions require -Wformat
2278 # being present if -Wformat-security is given. Otherwise a warning is issued.
2279 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2280 # And with that the warning will be turned into an error with the result
2281 # that -Wformat-security is believed to be unsupported when in fact it is.
2282 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2283 safe_CFLAGS=$CFLAGS
2284 CFLAGS="-Wformat -Wformat-security -Werror"
2285 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2286 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2287 AC_MSG_RESULT([yes])], [
2288 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2289 AC_MSG_RESULT([no])])
2290 CFLAGS=$safe_CFLAGS
2292 # does this compiler support -Wextra or the older -W ?
2294 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2296 safe_CFLAGS=$CFLAGS
2297 CFLAGS="-Wextra -Werror"
2299 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2300   return 0;
2301 ]])], [
2302 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2303 AC_MSG_RESULT([-Wextra])
2304 ], [
2305   CFLAGS="-W -Werror"
2306   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2307     return 0;
2308   ]])], [
2309   AC_SUBST([FLAG_W_EXTRA], [-W])
2310   AC_MSG_RESULT([-W])
2311   ], [
2312   AC_SUBST([FLAG_W_EXTRA], [])
2313   AC_MSG_RESULT([not supported])
2314   ])
2316 CFLAGS=$safe_CFLAGS
2318 # On ARM we do not want to pass -Wcast-align as that produces loads
2319 # of warnings. GCC is just being conservative. See here:
2320 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2321 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2322   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2323 else
2324   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2327 # does this compiler support -faligned-new ?
2328 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2330 safe_CXXFLAGS=$CXXFLAGS
2331 CXXFLAGS="-faligned-new -Werror"
2333 AC_LANG(C++)
2334 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2335   return 0;
2336 ]])], [
2337 FLAG_FALIGNED_NEW="-faligned-new"
2338 AC_MSG_RESULT([yes])
2339 ], [
2340 FLAG_FALIGNED_NEW=""
2341 AC_MSG_RESULT([no])
2343 CXXFLAGS=$safe_CXXFLAGS
2344 AC_LANG(C)
2346 AC_SUBST(FLAG_FALIGNED_NEW)
2348 # does this compiler support -fsized-deallocation ?
2349 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2351 safe_CXXFLAGS=$CXXFLAGS
2352 CXXFLAGS="-fsized-deallocation -Werror"
2354 AC_LANG(C++)
2355 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2356   return 0;
2357 ]])], [
2358 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2359 ac_have_sized_deallocation=yes
2360 AC_MSG_RESULT([yes])
2361 ], [
2362 FLAG_FSIZED_DEALLOCATION=""
2363 ac_have_sized_deallocation=no
2364 AC_MSG_RESULT([no])
2366 CXXFLAGS=$safe_CXXFLAGS
2367 AC_LANG(C)
2369 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2370 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2372 # does this compiler support C++17 aligned new/delete?
2373 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2375 safe_CXXFLAGS=$CXXFLAGS
2376 CXXFLAGS="-std=c++17"
2378 AC_LANG(C++)
2379 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2380 #include <cstdlib>
2381 #include <new>
2382 ]], [[
2383   operator delete(nullptr, std::align_val_t(64U));
2384 ]])], [
2385 ac_have_aligned_cxx_alloc=yes
2386 AC_MSG_RESULT([yes])
2387 ], [
2388 ac_have_aligned_cxx_alloc=no
2389 AC_MSG_RESULT([no])
2391 CXXFLAGS=$safe_CXXFLAGS
2392 AC_LANG(C)
2394 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2396 # does this compiler support -fno-stack-protector ?
2397 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2399 safe_CFLAGS=$CFLAGS
2400 CFLAGS="-fno-stack-protector -Werror"
2402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2403   return 0;
2404 ]])], [
2405 no_stack_protector=yes
2406 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2407 AC_MSG_RESULT([yes])
2408 ], [
2409 no_stack_protector=no
2410 FLAG_FNO_STACK_PROTECTOR=""
2411 AC_MSG_RESULT([no])
2413 CFLAGS=$safe_CFLAGS
2415 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2417 # does this compiler support -finline-functions ?
2418 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2420 safe_CFLAGS=$CFLAGS
2421 CFLAGS="-finline-functions -Werror"
2423 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2424   return 0;
2425 ]])], [
2426 inline_functions=yes
2427 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2428 AC_MSG_RESULT([yes])
2429 ], [
2430 inline_functions=no
2431 FLAG_FINLINE_FUNCTIONS=""
2432 AC_MSG_RESULT([no])
2434 CFLAGS=$safe_CFLAGS
2436 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2438 # Does GCC support disabling Identical Code Folding?
2439 # We want to disabled Identical Code Folding for the
2440 # tools preload shared objects to get better backraces.
2441 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2442 # "The optimization reduces code size and may disturb
2443 #  unwind stacks by replacing a function by equivalent
2444 #  one with a different name."
2445 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2447 safe_CFLAGS=$CFLAGS
2448 CFLAGS="-fno-ipa-icf -Werror"
2450 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2451   return 0;
2452 ]])], [
2453 no_ipa_icf=yes
2454 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2455 AC_MSG_RESULT([yes])
2456 ], [
2457 no_ipa_icf=no
2458 FLAG_FNO_IPA_ICF=""
2459 AC_MSG_RESULT([no])
2461 CFLAGS=$safe_CFLAGS
2463 AC_SUBST(FLAG_FNO_IPA_ICF)
2466 # Does this compiler support -fsanitize=undefined. This is true for
2467 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2468 # also checks for alignment violations on memory accesses which the valgrind
2469 # code base is sprinkled (if not littered) with. As those alignment issues
2470 # don't pose a problem we want to suppress warnings about them.
2471 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2472 # GCCs do not support that.
2474 # Only checked for if --enable-ubsan was given.
2475 if test "x${vg_cv_ubsan}" = "xyes"; then
2476 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2477 safe_CFLAGS=$CFLAGS
2478 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2479 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2480   return 0;
2481 ]])], [
2482 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2483 LIB_UBSAN="-static-libubsan"
2484 AC_MSG_RESULT([yes])
2485 ], [
2486 CFLAGS="-fsanitize=undefined -Werror"
2487 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2488   return 0;
2489 ]])], [
2490 FLAG_FSANITIZE="-fsanitize=undefined"
2491 LIB_UBSAN="-static-libubsan"
2492 AC_MSG_RESULT([yes])
2493 ], [
2494 FLAG_FSANITIZE=""
2495 LIB_UBSAN=""
2496 AC_MSG_RESULT([no])
2499 CFLAGS=$safe_CFLAGS
2500 AC_SUBST(FLAG_FSANITIZE)
2501 AC_SUBST(LIB_UBSAN)
2503 # does this compiler support --param inline-unit-growth=... ?
2505 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2507 safe_CFLAGS=$CFLAGS
2508 CFLAGS="--param inline-unit-growth=900 -Werror"
2510 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2511   return 0;
2512 ]])], [
2513 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2514          ["--param inline-unit-growth=900"])
2515 AC_MSG_RESULT([yes])
2516 ], [
2517 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2518 AC_MSG_RESULT([no])
2520 CFLAGS=$safe_CFLAGS
2523 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2525 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2527 safe_CFLAGS=$CFLAGS
2528 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2530 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2531   return 0;
2532 ]])], [
2533 ac_have_dwarf4=yes
2534 AC_MSG_RESULT([yes])
2535 ], [
2536 ac_have_dwarf4=no
2537 AC_MSG_RESULT([no])
2539 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2540 CFLAGS=$safe_CFLAGS
2543 # does this compiler support -g -gz=zlib ?
2545 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2547 safe_CFLAGS=$CFLAGS
2548 CFLAGS="-g -gz=zlib"
2550 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2551   return 0;
2552 ]])], [
2553 ac_have_gz_zlib=yes
2554 AC_MSG_RESULT([yes])
2555 ], [
2556 ac_have_gz_zlib=no
2557 AC_MSG_RESULT([no])
2559 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2560 CFLAGS=$safe_CFLAGS
2563 # does this compiler support -g -gz=zlib-gnu ?
2565 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2567 safe_CFLAGS=$CFLAGS
2568 CFLAGS="-g -gz=zlib-gnu"
2570 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2571   return 0;
2572 ]])], [
2573 ac_have_gz_zlib_gnu=yes
2574 AC_MSG_RESULT([yes])
2575 ], [
2576 ac_have_gz_zlib_gnu=no
2577 AC_MSG_RESULT([no])
2579 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2580 CFLAGS=$safe_CFLAGS
2583 # does this compiler support nested functions ?
2585 AC_MSG_CHECKING([if gcc accepts nested functions])
2587 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2588   int foo() { return 1; }
2589   return foo();
2590 ]])], [
2591 ac_have_nested_functions=yes
2592 AC_MSG_RESULT([yes])
2593 ], [
2594 ac_have_nested_functions=no
2595 AC_MSG_RESULT([no])
2597 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2600 # does this compiler support the 'p' constraint in ASM statements ?
2602 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2604 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2605    char *p;
2606    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2607 ]])], [
2608 ac_have_asm_constraint_p=yes
2609 AC_MSG_RESULT([yes])
2610 ], [
2611 ac_have_asm_constraint_p=no
2612 AC_MSG_RESULT([no])
2614 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2617 # Does this compiler and linker support -pie?
2618 # Some compilers actually do not support -pie and report its usage
2619 # as an error. We need to check if it is safe to use it first.
2621 AC_MSG_CHECKING([if gcc accepts -pie])
2623 safe_CFLAGS=$CFLAGS
2624 CFLAGS="-pie"
2626 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2627   return 0;
2628 ]])], [
2629 AC_SUBST([FLAG_PIE], ["-pie"])
2630 AC_MSG_RESULT([yes])
2631 ], [
2632 AC_SUBST([FLAG_PIE], [""])
2633 AC_MSG_RESULT([no])
2635 CFLAGS=$safe_CFLAGS
2638 # Does this compiler support -no-pie?
2639 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2640 # default. However this gets in the way with some tests, we use -no-pie
2641 # for these.
2643 AC_MSG_CHECKING([if gcc accepts -no-pie])
2645 safe_CFLAGS=$CFLAGS
2646 CFLAGS="-no-pie"
2648 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2649   return 0;
2650 ]])], [
2651 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2652 AC_MSG_RESULT([yes])
2653 ], [
2654 AC_SUBST([FLAG_NO_PIE], [""])
2655 AC_MSG_RESULT([no])
2657 CFLAGS=$safe_CFLAGS
2660 # We want to use use the -Ttext-segment option to the linker.
2661 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2662 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2663 # semantics are NOT what we want (GNU gold -Ttext is fine).
2665 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2666 # will reside. -Ttext aligns just the .text section start (but not any
2667 # other section).
2669 # So test for -Ttext-segment which is supported by all bfd ld versions
2670 # and use that if it exists. If it doesn't exist it must be an older
2671 # version of gold and we can fall back to using -Ttext which has the
2672 # right semantics.
2674 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2676 safe_CFLAGS=$CFLAGS
2677 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2679 AC_LINK_IFELSE(
2680 [AC_LANG_SOURCE([int _start () { return 0; }])],
2682   linker_using_t_text="no"
2683   AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2684   AC_MSG_RESULT([yes])
2685 ], [
2686   linker_using_t_text="yes"
2687   AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2688   AC_MSG_RESULT([no])
2690 CFLAGS=$safe_CFLAGS
2692 # If the linker only supports -Ttext (not -Ttext-segment) then we will
2693 # have to strip any build-id ELF NOTEs from the statically linked tools.
2694 # Otherwise the build-id NOTE might end up at the default load address.
2695 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2696 # gold versions also support -Ttext-segment. So just assume that unless
2697 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2698 if test "x${linker_using_t_text}" = "xyes"; then
2699 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2700 # does the linker support -Wl,--build-id=none ?  Note, it's
2701 # important that we test indirectly via whichever C compiler
2702 # is selected, rather than testing /usr/bin/ld or whatever
2703 # directly.
2704 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2705 safe_CFLAGS=$CFLAGS
2706 CFLAGS="-Wl,--build-id=none -Werror"
2708 AC_LINK_IFELSE(
2709 [AC_LANG_PROGRAM([ ], [return 0;])],
2711   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2712   AC_MSG_RESULT([yes])
2713 ], [
2714   AC_SUBST([FLAG_NO_BUILD_ID], [""])
2715   AC_MSG_RESULT([no])
2717 else
2718 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2719 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2721 CFLAGS=$safe_CFLAGS
2723 # does the ppc assembler support "mtocrf" et al?
2724 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2726 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2727 __asm__ __volatile__("mtocrf 4,0");
2728 __asm__ __volatile__("mfocrf 0,4");
2729 ]])], [
2730 ac_have_as_ppc_mftocrf=yes
2731 AC_MSG_RESULT([yes])
2732 ], [
2733 ac_have_as_ppc_mftocrf=no
2734 AC_MSG_RESULT([no])
2736 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2737   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2741 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2742 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2744 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2745   do { typedef struct {
2746       double hi;
2747       double lo;
2748      } dbl_pair_t;
2749      dbl_pair_t dbl_pair[3];
2750      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2751    } while (0)
2752 ]])], [
2753 ac_have_as_ppc_fpPO=yes
2754 AC_MSG_RESULT([yes])
2755 ], [
2756 ac_have_as_ppc_fpPO=no
2757 AC_MSG_RESULT([no])
2759 if test x$ac_have_as_ppc_fpPO = xyes ; then
2760   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2764 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2765 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2767 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2768 void* p;
2769 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2770 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2771 ]])], [
2772 ac_have_as_amd64_fxsave64=yes
2773 AC_MSG_RESULT([yes])
2774 ], [
2775 ac_have_as_amd64_fxsave64=no
2776 AC_MSG_RESULT([no])
2778 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2779   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2782 # does the x86/amd64 assembler understand SSE3 instructions?
2783 # Note, this doesn't generate a C-level symbol.  It generates a
2784 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2785 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2787 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2788   do { long long int x; 
2789      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
2790   while (0)
2791 ]])], [
2792 ac_have_as_sse3=yes
2793 AC_MSG_RESULT([yes])
2794 ], [
2795 ac_have_as_sse3=no
2796 AC_MSG_RESULT([no])
2799 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2802 # Ditto for SSSE3 instructions (note extra S)
2803 # Note, this doesn't generate a C-level symbol.  It generates a
2804 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2805 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2807 save_CFLAGS="$CFLAGS"
2808 CFLAGS="$CFLAGS -msse -Werror"
2809 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2810   do { long long int x; 
2811    __asm__ __volatile__(
2812       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2813   while (0)
2814 ]])], [
2815 ac_have_as_ssse3=yes
2816 AC_MSG_RESULT([yes])
2817 ], [
2818 ac_have_as_ssse3=no
2819 AC_MSG_RESULT([no])
2821 CFLAGS="$save_CFLAGS"
2823 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2826 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2827 # Note, this doesn't generate a C-level symbol.  It generates a
2828 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2829 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2830 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2831   do {
2832    __asm__ __volatile__(
2833       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2834   while (0)
2835 ]])], [
2836 ac_have_as_pclmulqdq=yes
2837 AC_MSG_RESULT([yes])
2838 ], [
2839 ac_have_as_pclmulqdq=no
2840 AC_MSG_RESULT([no])
2843 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2846 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2847 # Note, this doesn't generate a C-level symbol.  It generates a
2848 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2849 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2850 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2851   do {
2852       /*
2853        * Carry-less multiplication of xmm1 with xmm2 and store the result in
2854        * xmm3. The immediate is used to determine which quadwords of xmm1 and
2855        * xmm2 should be used.
2856        */
2857    __asm__ __volatile__(
2858       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2859   } while (0)
2860 ]])], [
2861 ac_have_as_vpclmulqdq=yes
2862 AC_MSG_RESULT([yes])
2863 ], [
2864 ac_have_as_vpclmulqdq=no
2865 AC_MSG_RESULT([no])
2868 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2871 # does the x86/amd64 assembler understand FMA4 instructions?
2872 # Note, this doesn't generate a C-level symbol.  It generates a
2873 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
2874 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
2875 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2876   do {
2877    __asm__ __volatile__(
2878       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
2879   } while (0)
2880 ]])], [
2881 ac_have_as_vfmaddpd=yes
2882 AC_MSG_RESULT([yes])
2883 ], [
2884 ac_have_as_vfmaddpd=no
2885 AC_MSG_RESULT([no])
2888 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
2891 # does the x86/amd64 assembler understand the LZCNT instruction?
2892 # Note, this doesn't generate a C-level symbol.  It generates a
2893 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2894 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2896 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2897   do {           
2898       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2899   } while (0)
2900 ]])], [
2901   ac_have_as_lzcnt=yes
2902   AC_MSG_RESULT([yes])
2903 ], [
2904   ac_have_as_lzcnt=no
2905   AC_MSG_RESULT([no])
2908 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2911 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2912 # Note, this doesn't generate a C-level symbol.  It generates a
2913 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2914 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2916 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2917   do {           
2918       __asm__ __volatile__("1:  loopnel 1b\n");
2919   } while (0)
2920 ]])], [
2921   ac_have_as_loopnel=yes
2922   AC_MSG_RESULT([yes])
2923 ], [
2924   ac_have_as_loopnel=no
2925   AC_MSG_RESULT([no])
2928 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2931 # does the x86/amd64 assembler understand ADDR32 ?
2932 # Note, this doesn't generate a C-level symbol.  It generates a
2933 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2934 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2936 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2937   do {           
2938       asm volatile ("addr32 rep movsb");
2939   } while (0)
2940 ]])], [
2941   ac_have_as_addr32=yes
2942   AC_MSG_RESULT([yes])
2943 ], [
2944   ac_have_as_addr32=no
2945   AC_MSG_RESULT([no])
2948 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2951 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2952 # Note, this doesn't generate a C-level symbol.  It generates a
2953 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2954 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2956 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2957   do { long long int x; 
2958    __asm__ __volatile__(
2959       "crc32q %%r15,%%r15" : : : "r15" );
2960    __asm__ __volatile__(
2961       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
2962    __asm__ __volatile__(
2963       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2964   while (0)
2965 ]])], [
2966 ac_have_as_sse42=yes
2967 AC_MSG_RESULT([yes])
2968 ], [
2969 ac_have_as_sse42=no
2970 AC_MSG_RESULT([no])
2973 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2976 # does the x86/amd64 assembler understand AVX instructions?
2977 # Note, this doesn't generate a C-level symbol.  It generates a
2978 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2979 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2981 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2982   do { long long int x; 
2983    __asm__ __volatile__(
2984       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2985    __asm__ __volatile__(
2986       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2987   while (0)
2988 ]])], [
2989 ac_have_as_avx=yes
2990 AC_MSG_RESULT([yes])
2991 ], [
2992 ac_have_as_avx=no
2993 AC_MSG_RESULT([no])
2996 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2999 # does the x86/amd64 assembler understand AVX2 instructions?
3000 # Note, this doesn't generate a C-level symbol.  It generates a
3001 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3002 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3004 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3005   do { long long int x; 
3006    __asm__ __volatile__(
3007       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3008    __asm__ __volatile__(
3009       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3010   while (0)
3011 ]])], [
3012 ac_have_as_avx2=yes
3013 AC_MSG_RESULT([yes])
3014 ], [
3015 ac_have_as_avx2=no
3016 AC_MSG_RESULT([no])
3019 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3022 # does the x86/amd64 assembler understand TSX instructions and
3023 # the XACQUIRE/XRELEASE prefixes?
3024 # Note, this doesn't generate a C-level symbol.  It generates a
3025 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3026 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3028 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3029   do {
3030    __asm__ __volatile__(
3031       "       xbegin Lfoo  \n\t"
3032       "Lfoo:  xend         \n\t"
3033       "       xacquire lock incq 0(%rsp)     \n\t"
3034       "       xrelease lock incq 0(%rsp)     \n"
3035    );
3036   } while (0)
3037 ]])], [
3038 ac_have_as_tsx=yes
3039 AC_MSG_RESULT([yes])
3040 ], [
3041 ac_have_as_tsx=no
3042 AC_MSG_RESULT([no])
3045 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3048 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3049 # Note, this doesn't generate a C-level symbol.  It generates a
3050 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3051 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3053 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3054   do { unsigned int h, l;
3055    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3056    __asm__ __volatile__(
3057       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3058    __asm__ __volatile__(
3059       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3060   while (0)
3061 ]])], [
3062 ac_have_as_bmi=yes
3063 AC_MSG_RESULT([yes])
3064 ], [
3065 ac_have_as_bmi=no
3066 AC_MSG_RESULT([no])
3069 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3072 # does the x86/amd64 assembler understand FMA instructions?
3073 # Note, this doesn't generate a C-level symbol.  It generates a
3074 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3075 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3077 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3078   do { unsigned int h, l;
3079    __asm__ __volatile__(
3080       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3081    __asm__ __volatile__(
3082       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3083    __asm__ __volatile__(
3084       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3085   while (0)
3086 ]])], [
3087 ac_have_as_fma=yes
3088 AC_MSG_RESULT([yes])
3089 ], [
3090 ac_have_as_fma=no
3091 AC_MSG_RESULT([no])
3094 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3097 # does the amd64 assembler understand MPX instructions?
3098 # Note, this doesn't generate a C-level symbol.  It generates a
3099 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3100 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3102 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3103   do {
3104     asm ("bndmov %bnd0,(%rsp)");
3105     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3106     asm ("bnd call foo\n"
3107           bnd jmp  end\n"
3108           foo: bnd ret\n"
3109           end: nop");
3110   } while (0)
3111 ]])], [
3112 ac_have_as_mpx=yes
3113 AC_MSG_RESULT([yes])
3114 ], [
3115 ac_have_as_mpx=no
3116 AC_MSG_RESULT([no])
3119 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3122 # does the amd64 assembler understand ADX instructions?
3123 # Note, this doesn't generate a C-level symbol.  It generates a
3124 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3125 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3127 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3128   do {
3129     asm ("adcxq %r14,%r8");
3130   } while (0)
3131 ]])], [
3132 ac_have_as_adx=yes
3133 AC_MSG_RESULT([yes])
3134 ], [
3135 ac_have_as_adx=no
3136 AC_MSG_RESULT([no])
3139 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3142 # does the amd64 assembler understand the RDRAND instruction?
3143 # Note, this doesn't generate a C-level symbol.  It generates a
3144 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3145 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3147 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3148   do {
3149     asm ("rdrand %r14");
3150     asm ("rdrand %r14d");
3151     asm ("rdrand %r14w");
3152   } while (0)
3153 ]])], [
3154 ac_have_as_rdrand=yes
3155 AC_MSG_RESULT([yes])
3156 ], [
3157 ac_have_as_rdrand=no
3158 AC_MSG_RESULT([no])
3161 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3163 # does the amd64 assembler understand the RDSEED instruction?
3164 # Note, this doesn't generate a C-level symbol.  It generates a
3165 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3166 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3169   do {
3170     asm ("rdseed %r14");
3171     asm ("rdseed %r14d");
3172     asm ("rdseed %r14w");
3173   } while (0)
3174 ]])], [
3175 ac_have_as_rdseed=yes
3176 AC_MSG_RESULT([yes])
3177 ], [
3178 ac_have_as_rdseed=no
3179 AC_MSG_RESULT([no])
3182 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3184 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3185 # VCVTPS2PH) ?
3186 # Note, this doesn't generate a C-level symbol.  It generates a
3187 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3188 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3191   do {
3192     asm ("vcvtph2ps %xmm5, %ymm10");
3193     // If we put the dollar sign and zero together, the shell processing
3194     // this configure.ac script substitutes the command name in.  Sigh.
3195     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3196   } while (0)
3197 ]])], [
3198 ac_have_as_f16c=yes
3199 AC_MSG_RESULT([yes])
3200 ], [
3201 ac_have_as_f16c=no
3202 AC_MSG_RESULT([no])
3205 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3208 # does the x86/amd64 assembler understand MOVBE?
3209 # Note, this doesn't generate a C-level symbol.  It generates a
3210 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3211 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3213 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3214   do { long long int x; 
3215    __asm__ __volatile__(
3216       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3217   while (0)
3218 ]])], [
3219 ac_have_as_movbe=yes
3220 AC_MSG_RESULT([yes])
3221 ], [
3222 ac_have_as_movbe=no
3223 AC_MSG_RESULT([no])
3226 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3229 # Does the C compiler support the "ifunc" attribute
3230 # Note, this doesn't generate a C-level symbol.  It generates a
3231 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3232 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3234 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3235 static void mytest(void) {}
3237 static void (*resolve_test(void))(void)
3239     return (void (*)(void))&mytest;
3242 void test(void) __attribute__((ifunc("resolve_test")));
3244 int main()
3246     test();
3247     return 0;
3249 ]])], [
3250 ac_have_ifunc_attr=yes
3251 AC_MSG_RESULT([yes])
3252 ], [
3253 ac_have_ifunc_attr=no
3254 AC_MSG_RESULT([no])
3257 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3259 # Does the C compiler support the armv8 crc feature flag
3260 # Note, this doesn't generate a C-level symbol.  It generates a
3261 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3262 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3264 save_CFLAGS="$CFLAGS"
3265 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3266 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3267 int main()
3269     return 0;
3271 ]])], [
3272 ac_have_armv8_crc_feature=yes
3273 AC_MSG_RESULT([yes])
3274 ], [
3275 ac_have_armv8_crc_feature=no
3276 AC_MSG_RESULT([no])
3278 CFLAGS="$save_CFLAGS"
3280 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3283 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3284 # Note, this doesn't generate a C-level symbol.  It generates a
3285 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3286 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3288 save_CFLAGS="$CFLAGS"
3289 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3290 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3291 int main()
3293     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3294     return 0;
3296 ]])], [
3297 ac_have_armv81_feature=yes
3298 AC_MSG_RESULT([yes])
3299 ], [
3300 ac_have_armv81_feature=no
3301 AC_MSG_RESULT([no])
3303 CFLAGS="$save_CFLAGS"
3305 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3308 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3309 # Note, this doesn't generate a C-level symbol.  It generates a
3310 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3311 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3313 save_CFLAGS="$CFLAGS"
3314 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3315 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3316 int main()
3318     __asm__ __volatile__("faddp h0, v1.2h");
3319     return 0;
3321 ]])], [
3322 ac_have_armv82_feature=yes
3323 AC_MSG_RESULT([yes])
3324 ], [
3325 ac_have_armv82_feature=no
3326 AC_MSG_RESULT([no])
3328 CFLAGS="$save_CFLAGS"
3330 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3333 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3334 # when building the tool executables.  I think we should get rid of it.
3336 # Check for TLS support in the compiler and linker
3337 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3338                                 [[return foo;]])],
3339                                [vg_cv_linktime_tls=yes],
3340                                [vg_cv_linktime_tls=no])
3341 # Native compilation: check whether running a program using TLS succeeds.
3342 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3343 # succeeds but running programs using TLS fails.
3344 # Cross-compiling: check whether linking a program using TLS succeeds.
3345 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3346                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3347                 [vg_cv_tls=$enableval],
3348                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3349                                                 [[return foo;]])],
3350                                [vg_cv_tls=yes],
3351                                [vg_cv_tls=no],
3352                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3354 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3355 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3359 #----------------------------------------------------------------------------
3360 # Solaris-specific checks.
3361 #----------------------------------------------------------------------------
3363 if test "$VGCONF_OS" = "solaris" ; then
3364 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3366 # Solaris-specific check determining if the Sun Studio Assembler is used to
3367 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3368 # cmovl.l instruction, if yes then it's Sun Assembler.
3370 # C-level symbol: none
3371 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3373 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3375 ]], [[
3376   __asm__ __volatile__("cmovl.l %edx, %eax");
3377 ]])], [
3378 solaris_have_sun_studio_as=yes
3379 AC_MSG_RESULT([yes])
3380 ], [
3381 solaris_have_sun_studio_as=no
3382 AC_MSG_RESULT([no])
3384 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3386 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3387 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3388 # See solaris/vgpreload-solaris.mapfile for details.
3389 # gcc on older Solaris instructs linker to include these symbols,
3390 # gcc on illumos and newer Solaris does not.
3392 # C-level symbol: none
3393 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3395 save_CFLAGS="$CFLAGS"
3396 CFLAGS="$CFLAGS -std=gnu99"
3397 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3398 temp_dir=$( /usr/bin/mktemp -d )
3399 cat <<_ACEOF >${temp_dir}/mylib.c
3400 #include <stdio.h>
3401 int myfunc(void) { printf("LaPutyka\n"); }
3402 _ACEOF
3403 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3404 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3405 if test "x${xpg_present}" = "x" ; then
3406     solaris_xpg_symbols_present=no
3407     AC_MSG_RESULT([no])
3408 else
3409     solaris_xpg_symbols_present=yes
3410     AC_MSG_RESULT([yes])
3412 rm -rf ${temp_dir}
3413 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3414 CFLAGS="$save_CFLAGS"
3417 # Solaris-specific check determining if gcc enables largefile support by
3418 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3419 # variable with gcc flags which disable it.
3421 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3422 save_CFLAGS="$CFLAGS"
3423 CFLAGS="$CFLAGS -m32"
3424 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3425   return _LARGEFILE_SOURCE;
3426 ]])], [
3427 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3428 AC_MSG_RESULT([yes])
3429 ], [
3430 SOLARIS_UNDEF_LARGESOURCE=""
3431 AC_MSG_RESULT([no])
3433 CFLAGS=$safe_CFLAGS
3434 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3437 # Solaris-specific check determining if /proc/self/cmdline
3438 # or /proc/<pid>/cmdline is supported.
3440 # C-level symbol: SOLARIS_PROC_CMDLINE
3441 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3443 AC_CHECK_FILE([/proc/self/cmdline],
3445 solaris_proc_cmdline=yes
3446 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3447           [Define to 1 if you have /proc/self/cmdline.])
3448 ], [
3449 solaris_proc_cmdline=no
3451 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3454 # Solaris-specific check determining default platform for the Valgrind launcher.
3455 # Used in case the launcher cannot select platform by looking at the client
3456 # image (for example because the executable is a shell script).
3458 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3459 # Automake-level symbol: none
3461 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3462 # Get the ELF class of /bin/sh first.
3463 if ! test -f /bin/sh; then
3464   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3466 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3467 case "$elf_class" in
3468   64)
3469     default_arch="$VGCONF_ARCH_PRI";
3470     ;;
3471   32)
3472     if test "x$VGCONF_ARCH_SEC" != "x"; then
3473       default_arch="$VGCONF_ARCH_SEC"
3474     else
3475       default_arch="$VGCONF_ARCH_PRI";
3476     fi
3477     ;;
3478   *)
3479     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3480     ;;
3481 esac
3482 default_platform="$default_arch-$VGCONF_OS"
3483 AC_MSG_RESULT([$default_platform])
3484 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3485                    [Default platform for Valgrind launcher.])
3488 # Solaris-specific check determining if the old syscalls are available.
3490 # C-level symbol: SOLARIS_OLD_SYSCALLS
3491 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3493 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3494 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3495 #include <sys/syscall.h>
3496 ]], [[
3497   return !SYS_open;
3498 ]])], [
3499 solaris_old_syscalls=yes
3500 AC_MSG_RESULT([yes])
3501 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3502           [Define to 1 if you have the old Solaris syscalls.])
3503 ], [
3504 solaris_old_syscalls=no
3505 AC_MSG_RESULT([no])
3507 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3510 # Solaris-specific check determining if the new accept() syscall is available.
3512 # Old syscall:
3513 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3514 #            int version);
3516 # New syscall (available on illumos):
3517 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3518 #            int version, int flags);
3520 # If the old syscall is present then the following syscall will fail with
3521 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3522 # available then it will fail with EINVAL (because the flags parameter is
3523 # invalid).
3525 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3526 # Automake-level symbol: none
3528 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3529 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3530 #include <sys/syscall.h>
3531 #include <errno.h>
3532 ]], [[
3533   errno = 0;
3534   syscall(SYS_accept, 0, 0, 0, 0, -1);
3535   return !(errno == EINVAL);
3536 ]])], [
3537 AC_MSG_RESULT([yes])
3538 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3539           [Define to 1 if you have the new `accept' syscall.])
3540 ], [
3541 AC_MSG_RESULT([no])
3545 # Solaris-specific check determining if the new illumos pipe() syscall is
3546 # available.
3548 # Old syscall:
3549 # longlong_t pipe();
3551 # New syscall (available on illumos):
3552 # int pipe(intptr_t arg, int flags);
3554 # If the old syscall is present then the following call will succeed, if the
3555 # new syscall is available then it will fail with EFAULT (because address 0
3556 # cannot be accessed).
3558 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3559 # Automake-level symbol: none
3561 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3562 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3563 #include <sys/syscall.h>
3564 #include <errno.h>
3565 ]], [[
3566   errno = 0;
3567   syscall(SYS_pipe, 0, 0);
3568   return !(errno == EFAULT);
3569 ]])], [
3570 AC_MSG_RESULT([yes])
3571 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3572           [Define to 1 if you have the new `pipe' syscall.])
3573 ], [
3574 AC_MSG_RESULT([no])
3578 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3579 # available.
3581 # Old syscall:
3582 # int lwp_kill(id_t lwpid, int sig);
3584 # New syscall (available on Solaris 11):
3585 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3586 #                  int si_code, timespec_t *timeout);
3588 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3589 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3591 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3592 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3593 #include <sys/syscall.h> 
3594 ]], [[
3595   return !SYS_lwp_sigqueue;
3596 ]])], [
3597 solaris_lwp_sigqueue_syscall=yes
3598 AC_MSG_RESULT([yes])
3599 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3600           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3601 ], [
3602 solaris_lwp_sigqueue_syscall=no
3603 AC_MSG_RESULT([no])
3605 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3608 # Solaris-specific check determining if the lwp_sigqueue() syscall
3609 # takes both pid and thread id arguments or just thread id.
3611 # Old syscall (available up to Solaris 11.3):
3612 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3613 #                  int si_code, timespec_t *timeout);
3615 # New syscall (available since Solaris 11.4):
3616 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3617 #                  int si_code, timespec_t *timeout);
3619 # If the old syscall is present then the following syscall will fail with
3620 # EINVAL (because signal is out of range); if the new syscall is available
3621 # then it will fail with ESRCH (because it would not find such thread in the
3622 # current process).
3624 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3625 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3627 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3628 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3629 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3630 #include <sys/syscall.h>
3631 #include <errno.h>
3632 ]], [[
3633   errno = 0;
3634   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3635   return !(errno == ESRCH);
3636 ]])], [
3637 solaris_lwp_sigqueue_syscall_takes_pid=yes
3638 AC_MSG_RESULT([yes])
3639 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3640           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3641 ], [
3642 solaris_lwp_sigqueue_syscall_takes_pid=no
3643 AC_MSG_RESULT([no])
3645 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3646                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3648 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3652 # Solaris-specific check determining if the new lwp_name() syscall is
3653 # available.
3655 # New syscall (available on Solaris 11):
3656 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3658 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3659 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3661 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3662 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3663 #include <sys/syscall.h>
3664 ]], [[
3665   return !SYS_lwp_name;
3666 ]])], [
3667 solaris_lwp_name_syscall=yes
3668 AC_MSG_RESULT([yes])
3669 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3670           [Define to 1 if you have the new `lwp_name' syscall.])
3671 ], [
3672 solaris_lwp_name_syscall=no
3673 AC_MSG_RESULT([no])
3675 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3678 # Solaris-specific check determining if the new getrandom() syscall is
3679 # available.
3681 # New syscall (available on Solaris 11):
3682 # int getrandom(void *buf, size_t buflen, uint_t flags);
3684 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3685 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3687 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3688 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3689 #include <sys/syscall.h>
3690 ]], [[
3691   return !SYS_getrandom;
3692 ]])], [
3693 solaris_getrandom_syscall=yes
3694 AC_MSG_RESULT([yes])
3695 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3696           [Define to 1 if you have the new `getrandom' syscall.])
3697 ], [
3698 solaris_getrandom_syscall=no
3699 AC_MSG_RESULT([no])
3701 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3704 # Solaris-specific check determining if the new zone() syscall subcodes
3705 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
3706 # were added in Solaris 11 but are missing on illumos.
3708 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3709 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3711 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3712 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3713 #include <sys/zone.h>
3714 ]], [[
3715   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3716 ]])], [
3717 solaris_zone_defunct=yes
3718 AC_MSG_RESULT([yes])
3719 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3720           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3721 ], [
3722 solaris_zone_defunct=no
3723 AC_MSG_RESULT([no])
3725 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3728 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3729 # for auditon(2) subcode of the auditsys() syscall are available.
3730 # These commands are available in Solaris 11 and illumos but were removed
3731 # in Solaris 11.4.
3733 # C-level symbol: SOLARIS_AUDITON_STAT
3734 # Automake-level symbol: SOLARIS_AUDITON_STAT
3736 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3737 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3738 #include <bsm/audit.h>
3739 ]], [[
3740   return !(A_GETSTAT && A_SETSTAT);
3741 ]])], [
3742 solaris_auditon_stat=yes
3743 AC_MSG_RESULT([yes])
3744 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3745           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3746 ], [
3747 solaris_auditon_stat=no
3748 AC_MSG_RESULT([no])
3750 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3753 # Solaris-specific check determining if the new shmsys() syscall subcodes
3754 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3755 # These subcodes were added in Solaris 11 but are missing on illumos.
3757 # C-level symbol: SOLARIS_SHM_NEW
3758 # Automake-level symbol: SOLARIS_SHM_NEW
3760 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3761 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3762 #include <sys/ipc_impl.h>
3763 #include <sys/shm.h>
3764 #include <sys/shm_impl.h>
3765 ]], [[
3766   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3767 ]])], [
3768 solaris_shm_new=yes
3769 AC_MSG_RESULT([yes])
3770 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3771           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3772 ], [
3773 solaris_shm_new=no
3774 AC_MSG_RESULT([no])
3776 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3779 # Solaris-specific check determining if prxregset_t is available.  Illumos
3780 # currently does not define it on the x86 platform.
3782 # C-level symbol: SOLARIS_PRXREGSET_T
3783 # Automake-level symbol: SOLARIS_PRXREGSET_T
3785 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3786 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3787 #include <sys/procfs_isa.h>
3788 ]], [[
3789   return !sizeof(prxregset_t);
3790 ]])], [
3791 solaris_prxregset_t=yes
3792 AC_MSG_RESULT([yes])
3793 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3794           [Define to 1 if you have the `prxregset_t' type.])
3795 ], [
3796 solaris_prxregset_t=no
3797 AC_MSG_RESULT([no])
3799 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3802 # Solaris-specific check determining if the new frealpathat() syscall is
3803 # available.
3805 # New syscall (available on Solaris 11.1):
3806 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
3808 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3809 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3811 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3812 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3813 #include <sys/syscall.h>
3814 ]], [[
3815   return !SYS_frealpathat;
3816 ]])], [
3817 solaris_frealpathat_syscall=yes
3818 AC_MSG_RESULT([yes])
3819 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3820           [Define to 1 if you have the new `frealpathat' syscall.])
3821 ], [
3822 solaris_frealpathat_syscall=no
3823 AC_MSG_RESULT([no])
3825 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3828 # Solaris-specific check determining if the new uuidsys() syscall is
3829 # available.
3831 # New syscall (available on newer Solaris):
3832 # int uuidsys(struct uuid *uuid);
3834 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3835 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3837 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3838 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3839 #include <sys/syscall.h>
3840 ]], [[
3841   return !SYS_uuidsys;
3842 ]])], [
3843 solaris_uuidsys_syscall=yes
3844 AC_MSG_RESULT([yes])
3845 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
3846           [Define to 1 if you have the new `uuidsys' syscall.])
3847 ], [
3848 solaris_uuidsys_syscall=no
3849 AC_MSG_RESULT([no])
3851 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
3854 # Solaris-specific check determining if the new labelsys() syscall subcode
3855 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
3856 # missing on illumos.
3858 # C-level symbol: SOLARIS_TNDB_GET_TNIP
3859 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
3861 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
3862 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3863 #include <sys/tsol/tndb.h>
3864 ]], [[
3865   return !TNDB_GET_TNIP;
3866 ]])], [
3867 solaris_tndb_get_tnip=yes
3868 AC_MSG_RESULT([yes])
3869 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
3870           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
3871 ], [
3872 solaris_tndb_get_tnip=no
3873 AC_MSG_RESULT([no])
3875 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
3878 # Solaris-specific check determining if the new labelsys() syscall opcodes
3879 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
3880 # added in Solaris 11 but are missing on illumos.
3882 # C-level symbol: SOLARIS_TSOL_CLEARANCE
3883 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
3885 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
3886 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3887 #include <sys/tsol/tsyscall.h>
3888 ]], [[
3889   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
3890 ]])], [
3891 solaris_tsol_clearance=yes
3892 AC_MSG_RESULT([yes])
3893 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
3894           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
3895 ], [
3896 solaris_tsol_clearance=no
3897 AC_MSG_RESULT([no])
3899 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
3902 # Solaris-specific check determining if the new pset() syscall subcode
3903 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
3904 # is missing on illumos and Solaris 11.3.
3906 # C-level symbol: SOLARIS_PSET_GET_NAME
3907 # Automake-level symbol: SOLARIS_PSET_GET_NAME
3909 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
3910 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3911 #include <sys/pset.h>
3912 ]], [[
3913   return !(PSET_GET_NAME);
3914 ]])], [
3915 solaris_pset_get_name=yes
3916 AC_MSG_RESULT([yes])
3917 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
3918           [Define to 1 if you have the `PSET_GET_NAME' constants.])
3919 ], [
3920 solaris_pset_get_name=no
3921 AC_MSG_RESULT([no])
3923 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
3926 # Solaris-specific check determining if the utimesys() syscall is
3927 # available (on illumos and older Solaris).
3929 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
3930 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
3932 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
3933 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3934 #include <sys/syscall.h>
3935 ]], [[
3936   return !SYS_utimesys;
3937 ]])], [
3938 solaris_utimesys_syscall=yes
3939 AC_MSG_RESULT([yes])
3940 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
3941           [Define to 1 if you have the `utimesys' syscall.])
3942 ], [
3943 solaris_utimesys_syscall=no
3944 AC_MSG_RESULT([no])
3946 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
3949 # Solaris-specific check determining if the utimensat() syscall is
3950 # available (on newer Solaris).
3952 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3953 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3955 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
3956 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3957 #include <sys/syscall.h>
3958 ]], [[
3959   return !SYS_utimensat;
3960 ]])], [
3961 solaris_utimensat_syscall=yes
3962 AC_MSG_RESULT([yes])
3963 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
3964           [Define to 1 if you have the `utimensat' syscall.])
3965 ], [
3966 solaris_utimensat_syscall=no
3967 AC_MSG_RESULT([no])
3969 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
3972 # Solaris-specific check determining if the spawn() syscall is available
3973 # (on newer Solaris).
3975 # C-level symbol: SOLARIS_SPAWN_SYSCALL
3976 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
3978 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
3979 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3980 #include <sys/syscall.h>
3981 ]], [[
3982   return !SYS_spawn;
3983 ]])], [
3984 solaris_spawn_syscall=yes
3985 AC_MSG_RESULT([yes])
3986 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
3987           [Define to 1 if you have the `spawn' syscall.])
3988 ], [
3989 solaris_spawn_syscall=no
3990 AC_MSG_RESULT([no])
3992 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
3995 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
3996 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
3998 # C-level symbol: SOLARIS_MODCTL_MODNVL
3999 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4001 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4002 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4003 #include <sys/modctl.h>
4004 ]], [[
4005   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4006 ]])], [
4007 solaris_modctl_modnvl=yes
4008 AC_MSG_RESULT([yes])
4009 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4010           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4011 ], [
4012 solaris_modctl_modnvl=no
4013 AC_MSG_RESULT([no])
4015 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4018 # Solaris-specific check determining whether nscd (name switch cache daemon)
4019 # attaches its door at /system/volatile/name_service_door (Solaris)
4020 # or at /var/run/name_service_door (illumos).
4022 # Note that /var/run is a symlink to /system/volatile on Solaris
4023 # but not vice versa on illumos.
4025 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4026 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4028 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4029 if test -e /system/volatile/name_service_door; then
4030     solaris_nscd_door_system_volatile=yes
4031     AC_MSG_RESULT([/system/volatile/name_service_door])
4032     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4033               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4034 else
4035     solaris_nscd_door_system_volatile=no
4036     AC_MSG_RESULT([/var/run/name_service_door])
4038 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4041 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4043 # New fasttrap (available on Solaris 11):
4044 # hrt_t *gethrt(void);
4046 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4047 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4049 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4050 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4051 #include <sys/trap.h>
4052 ]], [[
4053   return !T_GETHRT;
4054 ]])], [
4055 solaris_gethrt_fasttrap=yes
4056 AC_MSG_RESULT([yes])
4057 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4058           [Define to 1 if you have the new `gethrt' fasttrap.])
4059 ], [
4060 solaris_gethrt_fasttrap=no
4061 AC_MSG_RESULT([no])
4063 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4066 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4067 # is available.
4069 # New fasttrap (available on Solaris 11):
4070 # zonehrtoffset_t *get_zone_offset(void);
4072 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4073 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4075 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4076 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4077 #include <sys/trap.h>
4078 ]], [[
4079   return !T_GETZONEOFFSET;
4080 ]])], [
4081 solaris_getzoneoffset_fasttrap=yes
4082 AC_MSG_RESULT([yes])
4083 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4084           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4085 ], [
4086 solaris_getzoneoffset_fasttrap=no
4087 AC_MSG_RESULT([no])
4089 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4092 # Solaris-specific check determining if the execve() syscall
4093 # takes fourth argument (flags) or not.
4095 # Old syscall (available on illumos):
4096 # int execve(const char *fname, const char **argv, const char **envp);
4098 # New syscall (available on Solaris):
4099 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4101 # If the new syscall is present then it will fail with EINVAL (because flags
4102 # are invalid); if the old syscall is available then it will fail with ENOENT
4103 # (because the file could not be found).
4105 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4106 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4108 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4109 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4110 #include <sys/syscall.h>
4111 #include <errno.h>
4112 ]], [[
4113   errno = 0;
4114   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4115   return !(errno == EINVAL);
4116 ]])], [
4117 solaris_execve_syscall_takes_flags=yes
4118 AC_MSG_RESULT([yes])
4119 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4120           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4121 ], [
4122 solaris_execve_syscall_takes_flags=no
4123 AC_MSG_RESULT([no])
4125 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4126                test x$solaris_execve_syscall_takes_flags = xyes)
4129 # Solaris-specific check determining version of the repository cache protocol.
4130 # Every Solaris version uses a different one, ranging from 21 to current 25.
4131 # The check is very ugly, though.
4133 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4134 # Automake-level symbol: none
4136 AC_PATH_PROG(DIS_PATH, dis, false)
4137 if test "x$DIS_PATH" = "xfalse"; then
4138   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4140 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4141   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4142   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4145 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4146 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4147   libscf=/usr/lib/64/libscf.so.1
4148 else
4149   libscf=/usr/lib/libscf.so.1
4151 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
4152   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4153   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4155 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
4156 if test -z "$hex"; then
4157   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4158   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4160 version=$( printf "%d\n" 0x$hex )
4161 AC_MSG_RESULT([$version])
4162 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4163                    [Version number of the repository door cache protocol.])
4166 # Solaris-specific check determining if "sysstat" segment reservation type
4167 # is available.
4169 # New "sysstat" segment reservation (available on Solaris 11.4):
4170 # - program header type:    PT_SUNW_SYSSTAT
4171 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4173 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4174 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4176 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4177 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4178 #include <sys/auxv.h>
4179 ]], [[
4180   return !AT_SUN_SYSSTAT_ADDR;
4181 ]])], [
4182 solaris_reserve_sysstat_addr=yes
4183 AC_MSG_RESULT([yes])
4184 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4185           [Define to 1 if you have the new `sysstat' segment reservation.])
4186 ], [
4187 solaris_reserve_sysstat_addr=no
4188 AC_MSG_RESULT([no])
4190 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4193 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4194 # is available.
4196 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4197 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4198 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4200 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4201 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4203 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4204 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4205 #include <sys/auxv.h>
4206 ]], [[
4207   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4208 ]])], [
4209 solaris_reserve_sysstat_zone_addr=yes
4210 AC_MSG_RESULT([yes])
4211 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4212           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4213 ], [
4214 solaris_reserve_sysstat_zone_addr=no
4215 AC_MSG_RESULT([no])
4217 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4220 # Solaris-specific check determining if the system_stats() syscall is available
4221 # (on newer Solaris).
4223 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4224 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4226 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4227 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4228 #include <sys/syscall.h>
4229 ]], [[
4230   return !SYS_system_stats;
4231 ]])], [
4232 solaris_system_stats_syscall=yes
4233 AC_MSG_RESULT([yes])
4234 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4235           [Define to 1 if you have the `system_stats' syscall.])
4236 ], [
4237 solaris_system_stats_syscall=no
4238 AC_MSG_RESULT([no])
4240 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4243 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4244 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4246 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4247 # Automake-level symbol: none
4249 AC_CHECK_TYPE([struct _fpchip_state],
4250               [solaris_fpchip_state_takes_underscore=yes],
4251               [solaris_fpchip_state_takes_underscore=no],
4252               [[#include <sys/regset.h>]])
4253 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4254   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4255             [Define to 1 if fpregset_t defines struct _fpchip_state])
4259 # Solaris-specific check determining if schedctl page shared between kernel
4260 # and userspace program is executable (illumos, older Solaris) or not (newer
4261 # Solaris).
4263 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4264 # Automake-level symbol: none
4266 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4267 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4268 #include <assert.h>
4269 #include <fcntl.h>
4270 #include <procfs.h>
4271 #include <schedctl.h>
4272 #include <stdio.h>
4273 #include <unistd.h>
4274 ]], [[
4275     schedctl_t *scp = schedctl_init();
4276     if (scp == NULL)
4277         return 1;
4279     int fd = open("/proc/self/map", O_RDONLY);
4280     assert(fd >= 0);
4282     prmap_t map;
4283     ssize_t rd;
4284     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4285         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4286             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4287                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4288             return (map.pr_mflags & MA_EXEC);
4289         }
4290     }
4292     return 1;
4293 ]])], [
4294 solaris_schedctl_page_exec=no
4295 AC_MSG_RESULT([no])
4296 ], [
4297 solaris_schedctl_page_exec=yes
4298 AC_MSG_RESULT([yes])
4299 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4300           [Define to 1 if you have the schedctl page executable.])
4304 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4305 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4306 # an initial thread pointer for libc (newer Solaris).
4308 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4309 # Automake-level symbol: none
4311 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4312 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4313 #include <sys/fasttrap_isa.h>
4314 ]], [[
4315     return !FT_SCRATCHSIZE;
4316 ]])], [
4317 solaris_pt_sunwdtrace_thrp=yes
4318 AC_MSG_RESULT([yes])
4319 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4320           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4321 ], [
4322 solaris_pt_sunwdtrace_thrp=no
4323 AC_MSG_RESULT([no])
4326 else
4327 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4328 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4329 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4330 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4331 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4332 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4333 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4334 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4335 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4336 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4337 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4338 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4339 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4340 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4341 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4342 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4343 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4344 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4345 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4346 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4347 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4348 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4349 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4350 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4351 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4352 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4353 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4354 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4355 fi # test "$VGCONF_OS" = "solaris"
4358 #----------------------------------------------------------------------------
4359 # Checks for C header files.
4360 #----------------------------------------------------------------------------
4362 AC_CHECK_HEADERS([       \
4363         asm/unistd.h     \
4364         endian.h         \
4365         mqueue.h         \
4366         sys/endian.h     \
4367         sys/epoll.h      \
4368         sys/eventfd.h    \
4369         sys/klog.h       \
4370         sys/poll.h       \
4371         sys/prctl.h      \
4372         sys/signal.h     \
4373         sys/signalfd.h   \
4374         sys/syscall.h    \
4375         sys/sysnvl.h     \
4376         sys/time.h       \
4377         sys/types.h      \
4378         ])
4380 # Verify whether the <linux/futex.h> header is usable.
4381 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4383 save_CFLAGS="$CFLAGS"
4384 CFLAGS="$CFLAGS -D__user="
4385 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4386 #include <linux/futex.h>
4387 ]], [[
4388   return FUTEX_WAIT;
4389 ]])], [
4390 ac_have_usable_linux_futex_h=yes
4391 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4392           [Define to 1 if you have a usable <linux/futex.h> header file.])
4393 AC_MSG_RESULT([yes])
4394 ], [
4395 ac_have_usable_linux_futex_h=no
4396 AC_MSG_RESULT([no])
4398 CFLAGS="$save_CFLAGS"
4401 #----------------------------------------------------------------------------
4402 # Checks for typedefs, structures, and compiler characteristics.
4403 #----------------------------------------------------------------------------
4404 AC_TYPE_UID_T
4405 AC_TYPE_OFF_T
4406 AC_TYPE_SIZE_T
4407 AC_HEADER_TIME
4410 #----------------------------------------------------------------------------
4411 # Checks for library functions.
4412 #----------------------------------------------------------------------------
4413 AC_FUNC_MEMCMP
4414 AC_FUNC_MMAP
4416 AC_CHECK_LIB([pthread], [pthread_create])
4417 AC_CHECK_LIB([rt], [clock_gettime])
4419 AC_CHECK_FUNCS([     \
4420         clock_gettime\
4421         copy_file_range \
4422         epoll_create \
4423         epoll_pwait  \
4424         klogctl      \
4425         mallinfo     \
4426         memchr       \
4427         memfd_create \
4428         memset       \
4429         mkdir        \
4430         mremap       \
4431         ppoll        \
4432         preadv       \
4433         preadv2      \
4434         process_vm_readv  \
4435         process_vm_writev \
4436         pthread_barrier_init       \
4437         pthread_condattr_setclock  \
4438         pthread_mutex_timedlock    \
4439         pthread_rwlock_timedrdlock \
4440         pthread_rwlock_timedwrlock \
4441         pthread_setname_np         \
4442         pthread_spin_lock          \
4443         pthread_yield              \
4444         pwritev      \
4445         pwritev2     \
4446         readlinkat   \
4447         semtimedop   \
4448         setcontext   \
4449         signalfd     \
4450         sigwaitinfo  \
4451         strchr       \
4452         strdup       \
4453         strpbrk      \
4454         strrchr      \
4455         strstr       \
4456         swapcontext  \
4457         syscall      \
4458         utimensat    \
4459         ])
4461 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4462 # libraries with any shared object and/or executable. This is NOT what we
4463 # want for e.g. vgpreload_core-x86-linux.so
4464 LIBS=""
4466 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4467                [test x$ac_cv_func_pthread_barrier_init = xyes])
4468 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4469                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4470 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4471                [test x$ac_cv_func_pthread_spin_lock = xyes])
4472 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4473                [test x$ac_cv_func_pthread_setname_np = xyes])
4474 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4475                [test x$ac_cv_func_copy_file_range = xyes])
4476 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4477                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4478 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4479                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4480 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4481 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4482 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4483                [test x$ac_cv_func_memfd_create = xyes])
4485 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4486      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4487      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4488   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4489             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4492 #----------------------------------------------------------------------------
4493 # MPI checks
4494 #----------------------------------------------------------------------------
4495 # Do we have a useable MPI setup on the primary and/or secondary targets?
4496 # On Linux, by default, assumes mpicc and -m32/-m64
4497 # Note: this is a kludge in that it assumes the specified mpicc 
4498 # understands -m32/-m64 regardless of what is specified using
4499 # --with-mpicc=.
4500 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4501              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4503 mflag_primary=
4504 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4505      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4506      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4507      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4508      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4509      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4510   mflag_primary=$FLAG_M32
4511 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4512        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4513        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4514        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4515        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4516   mflag_primary=$FLAG_M64
4517 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4518   mflag_primary="$FLAG_M32 -arch i386"
4519 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4520   mflag_primary="$FLAG_M64 -arch x86_64"
4523 mflag_secondary=
4524 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4525      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4526      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4527      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX ; then
4528   mflag_secondary=$FLAG_M32
4529 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4530   mflag_secondary="$FLAG_M32 -arch i386"
4534 AC_ARG_WITH(mpicc,
4535    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4536    MPI_CC=$withval
4538 AC_SUBST(MPI_CC)
4540 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4541 ## use these values in the check for a functioning mpicc.
4543 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4544 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4545 AM_COND_IF([VGCONF_OS_IS_LINUX],
4546            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4547             LDFLAGS_MPI="-fpic -shared"])
4548 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4549            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4550             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4551 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4552            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4553             LDFLAGS_MPI="-fpic -shared"])
4555 AC_SUBST([CFLAGS_MPI])
4556 AC_SUBST([LDFLAGS_MPI])
4559 ## See if MPI_CC works for the primary target
4561 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4562 saved_CC=$CC
4563 saved_CFLAGS=$CFLAGS
4564 CC=$MPI_CC
4565 CFLAGS="$CFLAGS_MPI $mflag_primary"
4566 saved_LDFLAGS="$LDFLAGS"
4567 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4568 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4569 #include <mpi.h>
4570 #include <stdio.h>
4571 ]], [[
4572   int ni, na, nd, comb;
4573   int r = MPI_Init(NULL,NULL);
4574   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4575   r |= MPI_Finalize();
4576   return r; 
4577 ]])], [
4578 ac_have_mpi2_pri=yes
4579 AC_MSG_RESULT([yes, $MPI_CC])
4580 ], [
4581 ac_have_mpi2_pri=no
4582 AC_MSG_RESULT([no])
4584 CC=$saved_CC
4585 CFLAGS=$saved_CFLAGS
4586 LDFLAGS="$saved_LDFLAGS"
4587 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4589 ## See if MPI_CC works for the secondary target.  Complication: what if
4590 ## there is no secondary target?  We need this to then fail.
4591 ## Kludge this by making MPI_CC something which will surely fail in
4592 ## such a case.
4594 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4595 saved_CC=$CC
4596 saved_CFLAGS=$CFLAGS
4597 saved_LDFLAGS="$LDFLAGS"
4598 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4599 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4600   CC="$MPI_CC this will surely fail"
4601 else
4602   CC=$MPI_CC
4604 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4605 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4606 #include <mpi.h>
4607 #include <stdio.h>
4608 ]], [[
4609   int ni, na, nd, comb;
4610   int r = MPI_Init(NULL,NULL);
4611   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4612   r |= MPI_Finalize();
4613   return r; 
4614 ]])], [
4615 ac_have_mpi2_sec=yes
4616 AC_MSG_RESULT([yes, $MPI_CC])
4617 ], [
4618 ac_have_mpi2_sec=no
4619 AC_MSG_RESULT([no])
4621 CC=$saved_CC
4622 CFLAGS=$saved_CFLAGS
4623 LDFLAGS="$saved_LDFLAGS"
4624 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4627 #----------------------------------------------------------------------------
4628 # Other library checks
4629 #----------------------------------------------------------------------------
4630 # There now follow some tests for Boost, and OpenMP.  These
4631 # tests are present because Drd has some regression tests that use
4632 # these packages.  All regression test programs all compiled only
4633 # for the primary target.  And so it is important that the configure
4634 # checks that follow, use the correct -m32 or -m64 flag for the
4635 # primary target (called $mflag_primary).  Otherwise, we can end up
4636 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4637 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4638 # only build (meaning, the primary target is x86-linux), the build
4639 # of the regtest programs that use Boost fails, because they are 
4640 # build as 32-bit (IN THIS EXAMPLE).
4642 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4643 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4646 # Check whether the boost library 1.35 or later has been installed.
4647 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4649 AC_MSG_CHECKING([for boost])
4651 AC_LANG(C++)
4652 safe_CXXFLAGS=$CXXFLAGS
4653 CXXFLAGS="$mflag_primary"
4654 safe_LIBS="$LIBS"
4655 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4657 AC_LINK_IFELSE([AC_LANG_SOURCE([
4658 #include <boost/thread.hpp>
4659 static void thread_func(void)
4660 { }
4661 int main(int argc, char** argv)
4663   boost::thread t(thread_func);
4664   return 0;
4666 ])],
4668 ac_have_boost_1_35=yes
4669 AC_SUBST([BOOST_CFLAGS], [])
4670 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4671 AC_MSG_RESULT([yes])
4672 ], [
4673 ac_have_boost_1_35=no
4674 AC_MSG_RESULT([no])
4677 LIBS="$safe_LIBS"
4678 CXXFLAGS=$safe_CXXFLAGS
4679 AC_LANG(C)
4681 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4684 # does this compiler support -fopenmp, does it have the include file
4685 # <omp.h> and does it have libgomp ?
4687 AC_MSG_CHECKING([for OpenMP])
4689 safe_CFLAGS=$CFLAGS
4690 CFLAGS="-fopenmp $mflag_primary -Werror"
4692 AC_LINK_IFELSE([AC_LANG_SOURCE([
4693 #include <omp.h> 
4694 int main(int argc, char** argv)
4696   omp_set_dynamic(0);
4697   return 0;
4699 ])],
4701 ac_have_openmp=yes
4702 AC_MSG_RESULT([yes])
4703 ], [
4704 ac_have_openmp=no
4705 AC_MSG_RESULT([no])
4707 CFLAGS=$safe_CFLAGS
4709 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4712 # Check for __builtin_popcount
4713 AC_MSG_CHECKING([for __builtin_popcount()])
4714 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4715 ]], [[
4716   __builtin_popcount(2);
4717   return 0;
4718 ]])], [
4719 AC_MSG_RESULT([yes])
4720 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4721           [Define to 1 if compiler provides __builtin_popcount().])
4722 ], [
4723 AC_MSG_RESULT([no])
4726 # Check for __builtin_clz
4727 AC_MSG_CHECKING([for __builtin_clz()])
4728 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4729 ]], [[
4730   __builtin_clz(2);
4731   return 0;
4732 ]])], [
4733 AC_MSG_RESULT([yes])
4734 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4735           [Define to 1 if compiler provides __builtin_clz().])
4736 ], [
4737 AC_MSG_RESULT([no])
4740 # Check for __builtin_ctz
4741 AC_MSG_CHECKING([for __builtin_ctz()])
4742 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4743 ]], [[
4744   __builtin_ctz(2);
4745   return 0;
4746 ]])], [
4747 AC_MSG_RESULT([yes])
4748 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4749           [Define to 1 if compiler provides __builtin_ctz().])
4750 ], [
4751 AC_MSG_RESULT([no])
4754 # does this compiler have built-in functions for atomic memory access for the
4755 # primary target ?
4756 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4758 safe_CFLAGS=$CFLAGS
4759 CFLAGS="$mflag_primary"
4761 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4762   int variable = 1;
4763   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4764           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4765 ]])], [
4766   ac_have_builtin_atomic_primary=yes
4767   AC_MSG_RESULT([yes])
4768   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])
4769 ], [
4770   ac_have_builtin_atomic_primary=no
4771   AC_MSG_RESULT([no])
4774 CFLAGS=$safe_CFLAGS
4776 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4777                [test x$ac_have_builtin_atomic_primary = xyes])
4780 # does this compiler have built-in functions for atomic memory access for the
4781 # secondary target ?
4783 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4785 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
4787 safe_CFLAGS=$CFLAGS
4788 CFLAGS="$mflag_secondary"
4790 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4791   int variable = 1;
4792   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
4793 ]])], [
4794   ac_have_builtin_atomic_secondary=yes
4795   AC_MSG_RESULT([yes])
4796 ], [
4797   ac_have_builtin_atomic_secondary=no
4798   AC_MSG_RESULT([no])
4801 CFLAGS=$safe_CFLAGS
4805 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
4806                [test x$ac_have_builtin_atomic_secondary = xyes])
4808 # does this compiler have built-in functions for atomic memory access on
4809 # 64-bit integers for all targets ?
4811 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
4813 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4814   #include <stdint.h>
4815 ]], [[
4816   uint64_t variable = 1;
4817   return __sync_add_and_fetch(&variable, 1)
4818 ]])], [
4819   ac_have_builtin_atomic64_primary=yes
4820 ], [
4821   ac_have_builtin_atomic64_primary=no
4824 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4826 safe_CFLAGS=$CFLAGS
4827 CFLAGS="$mflag_secondary"
4829 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4830   #include <stdint.h>
4831 ]], [[
4832   uint64_t variable = 1;
4833   return __sync_add_and_fetch(&variable, 1)
4834 ]])], [
4835   ac_have_builtin_atomic64_secondary=yes
4836 ], [
4837   ac_have_builtin_atomic64_secondary=no
4840 CFLAGS=$safe_CFLAGS
4844 if test x$ac_have_builtin_atomic64_primary = xyes && \
4845    test x$VGCONF_PLATFORM_SEC_CAPS = x \
4846      -o x$ac_have_builtin_atomic64_secondary = xyes; then
4847   AC_MSG_RESULT([yes])
4848   ac_have_builtin_atomic64=yes
4849 else
4850   AC_MSG_RESULT([no])
4851   ac_have_builtin_atomic64=no
4854 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
4855                [test x$ac_have_builtin_atomic64 = xyes])
4858 # does g++ have built-in functions for atomic memory access ?
4859 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
4861 safe_CXXFLAGS=$CXXFLAGS
4862 CXXFLAGS="$mflag_primary"
4864 AC_LANG_PUSH(C++)
4865 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4866   int variable = 1;
4867   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4868           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4869 ]])], [
4870   ac_have_builtin_atomic_cxx=yes
4871   AC_MSG_RESULT([yes])
4872   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
4873 ], [
4874   ac_have_builtin_atomic_cxx=no
4875   AC_MSG_RESULT([no])
4877 AC_LANG_POP(C++)
4879 CXXFLAGS=$safe_CXXFLAGS
4881 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
4884 if test x$ac_have_usable_linux_futex_h = xyes \
4885         -a x$ac_have_builtin_atomic_primary = xyes; then
4886   ac_enable_linux_ticket_lock_primary=yes
4888 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
4889                [test x$ac_enable_linux_ticket_lock_primary = xyes])
4891 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
4892         -a x$ac_have_usable_linux_futex_h = xyes \
4893         -a x$ac_have_builtin_atomic_secondary = xyes; then
4894   ac_enable_linux_ticket_lock_secondary=yes
4896 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
4897                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
4900 # does libstdc++ support annotating shared pointers ?
4901 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
4903 safe_CXXFLAGS=$CXXFLAGS
4904 CXXFLAGS="-std=c++0x"
4906 AC_LANG_PUSH(C++)
4907 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4908   #include <memory>
4909 ]], [[
4910   std::shared_ptr<int> p
4911 ]])], [
4912   ac_have_shared_ptr=yes
4913 ], [
4914   ac_have_shared_ptr=no
4916 if test x$ac_have_shared_ptr = xyes; then
4917   # If compilation of the program below fails because of a syntax error
4918   # triggered by substituting one of the annotation macros then that
4919   # means that libstdc++ supports these macros.
4920   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4921     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
4922     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
4923     #include <memory>
4924   ]], [[
4925     std::shared_ptr<int> p
4926   ]])], [
4927     ac_have_shared_pointer_annotation=no
4928     AC_MSG_RESULT([no])
4929   ], [
4930     ac_have_shared_pointer_annotation=yes
4931     AC_MSG_RESULT([yes])
4932     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
4933               [Define to 1 if libstd++ supports annotating shared pointers])
4934   ])
4935 else
4936   ac_have_shared_pointer_annotation=no
4937   AC_MSG_RESULT([no])
4939 AC_LANG_POP(C++)
4941 CXXFLAGS=$safe_CXXFLAGS
4943 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
4944                [test x$ac_have_shared_pointer_annotation = xyes])
4947 #----------------------------------------------------------------------------
4948 # Ok.  We're done checking.
4949 #----------------------------------------------------------------------------
4951 # Nb: VEX/Makefile is generated from Makefile.vex.in.
4952 AC_CONFIG_FILES([
4953    Makefile 
4954    VEX/Makefile:Makefile.vex.in
4955    valgrind.spec
4956    valgrind.pc
4957    glibc-2.X.supp
4958    glibc-2.X-helgrind.supp
4959    glibc-2.X-drd.supp
4960    docs/Makefile 
4961    tests/Makefile 
4962    tests/vg_regtest 
4963    perf/Makefile 
4964    perf/vg_perf
4965    gdbserver_tests/Makefile
4966    gdbserver_tests/solaris/Makefile
4967    include/Makefile 
4968    auxprogs/Makefile
4969    mpi/Makefile
4970    coregrind/Makefile 
4971    memcheck/Makefile
4972    memcheck/tests/Makefile
4973    memcheck/tests/common/Makefile
4974    memcheck/tests/amd64/Makefile
4975    memcheck/tests/x86/Makefile
4976    memcheck/tests/linux/Makefile
4977    memcheck/tests/linux/debuginfod-check.vgtest
4978    memcheck/tests/darwin/Makefile
4979    memcheck/tests/solaris/Makefile
4980    memcheck/tests/amd64-linux/Makefile
4981    memcheck/tests/arm64-linux/Makefile
4982    memcheck/tests/x86-linux/Makefile
4983    memcheck/tests/amd64-solaris/Makefile
4984    memcheck/tests/x86-solaris/Makefile
4985    memcheck/tests/ppc32/Makefile
4986    memcheck/tests/ppc64/Makefile
4987    memcheck/tests/s390x/Makefile
4988    memcheck/tests/mips32/Makefile
4989    memcheck/tests/mips64/Makefile
4990    memcheck/tests/vbit-test/Makefile
4991    cachegrind/Makefile
4992    cachegrind/tests/Makefile
4993    cachegrind/tests/x86/Makefile
4994    cachegrind/cg_annotate
4995    cachegrind/cg_diff
4996    callgrind/Makefile
4997    callgrind/callgrind_annotate
4998    callgrind/callgrind_control
4999    callgrind/tests/Makefile
5000    helgrind/Makefile
5001    helgrind/tests/Makefile
5002    drd/Makefile
5003    drd/scripts/download-and-build-splash2
5004    drd/tests/Makefile
5005    massif/Makefile
5006    massif/tests/Makefile
5007    massif/ms_print
5008    dhat/Makefile
5009    dhat/tests/Makefile
5010    lackey/Makefile
5011    lackey/tests/Makefile
5012    none/Makefile
5013    none/tests/Makefile
5014    none/tests/scripts/Makefile
5015    none/tests/amd64/Makefile
5016    none/tests/ppc32/Makefile
5017    none/tests/ppc64/Makefile
5018    none/tests/x86/Makefile
5019    none/tests/arm/Makefile
5020    none/tests/arm64/Makefile
5021    none/tests/s390x/Makefile
5022    none/tests/mips32/Makefile
5023    none/tests/mips64/Makefile
5024    none/tests/nanomips/Makefile
5025    none/tests/linux/Makefile
5026    none/tests/darwin/Makefile
5027    none/tests/solaris/Makefile
5028    none/tests/amd64-linux/Makefile
5029    none/tests/x86-linux/Makefile
5030    none/tests/amd64-darwin/Makefile
5031    none/tests/x86-darwin/Makefile
5032    none/tests/amd64-solaris/Makefile
5033    none/tests/x86-solaris/Makefile
5034    exp-bbv/Makefile
5035    exp-bbv/tests/Makefile
5036    exp-bbv/tests/x86/Makefile
5037    exp-bbv/tests/x86-linux/Makefile
5038    exp-bbv/tests/amd64-linux/Makefile
5039    exp-bbv/tests/ppc32-linux/Makefile
5040    exp-bbv/tests/arm-linux/Makefile
5041    shared/Makefile
5042    solaris/Makefile
5044 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5045                 [chmod +x coregrind/link_tool_exe_linux])
5046 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5047                 [chmod +x coregrind/link_tool_exe_darwin])
5048 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5049                 [chmod +x coregrind/link_tool_exe_solaris])
5050 AC_OUTPUT
5052 cat<<EOF
5054          Maximum build arch: ${ARCH_MAX}
5055          Primary build arch: ${VGCONF_ARCH_PRI}
5056        Secondary build arch: ${VGCONF_ARCH_SEC}
5057                    Build OS: ${VGCONF_OS}
5058      Link Time Optimisation: ${vg_cv_lto}
5059        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5060      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5061            Platform variant: ${VGCONF_PLATVARIANT}
5062       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5063          Default supp files: ${DEFAULT_SUPP}