Increase the size of the translation cache to keep up with the demands
[valgrind.git] / configure.ac
blobb95a041c67caea52979c2dec985de09f8800de74
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.13.0.SVN],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign subdir-objects])
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 # provide a very basic definition for AC_PROG_SED if it's not provided by
49 # autoconf (as e.g. in autoconf 2.59).
50 m4_ifndef([AC_PROG_SED],
51           [AC_DEFUN([AC_PROG_SED],
52                     [AC_ARG_VAR([SED])
53                      AC_CHECK_PROGS([SED],[gsed sed])])])
54 AC_PROG_SED
56 # If no AR variable was specified, look up the name of the archiver. Otherwise
57 # do not touch the AR variable.
58 if test "x$AR" = "x"; then
59   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
61 AC_ARG_VAR([AR],[Archiver command])
63 # Check for the compiler support
64 if test "${GCC}" != "yes" ; then
65    AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
68 # figure out where perl lives
69 AC_PATH_PROG(PERL, perl)
71 # figure out where gdb lives
72 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
73 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
75 # some older automake's don't have it so try something on our own
76 ifdef([AM_PROG_AS],[AM_PROG_AS],
78 AS="${CC}"
79 AC_SUBST(AS)
81 ASFLAGS=""
82 AC_SUBST(ASFLAGS)
86 # Check if 'diff' supports -u (universal diffs) and use it if possible.
88 AC_MSG_CHECKING([for diff -u])
89 AC_SUBST(DIFF)
91 # Comparing two identical files results in 0.
92 tmpfile="tmp-xxx-yyy-zzz"
93 touch $tmpfile;
94 if diff -u $tmpfile $tmpfile ; then
95     AC_MSG_RESULT([yes])
96     DIFF="diff -u"
97 else
98     AC_MSG_RESULT([no])
99     DIFF="diff"
101 rm $tmpfile
104 # We don't want gcc < 3.0
105 AC_MSG_CHECKING([for a supported version of gcc])
107 # Obtain the compiler version.
109 # A few examples of how the ${CC} --version output looks like:
111 # ######## gcc variants ########
112 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
113 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
114 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
115 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
116 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
117 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
118 # OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
120 # ######## clang variants ########
121 # Clang: clang version 2.9 (tags/RELEASE_29/final)
122 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
123 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
125 # ######## Apple LLVM variants ########
126 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
127 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
130 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
131 then
132     is_clang="applellvm"
133     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
134 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
135 then
136     is_clang="clang"
137     # Don't use -dumpversion with clang: it will always produce "4.2.1".
138     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
139 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
140 then
141     is_clang="icc"
142     gcc_version=`${CC} -dumpversion 2>/dev/null`
143 else
144     is_clang="notclang"
145     gcc_version=`${CC} -dumpversion 2>/dev/null`
146     if test "x$gcc_version" = x; then
147         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
148     fi
151 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
152 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
154 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
155 # statements have to be quoted.
156 case "${is_clang}-${gcc_version}" in
157      applellvm-5.1|applellvm-6.*|applellvm-7.*|applellvm-8.*)
158         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
159         ;;
160      icc-1[[3-9]].*)
161         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
162         ;;
163      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
164         AC_MSG_RESULT([ok (${gcc_version})])
165         ;;
166      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
167         AC_MSG_RESULT([ok (clang-${gcc_version})])
168         ;;
169      *)
170         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
171         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0])
172         ;;
173 esac
175 #----------------------------------------------------------------------------
176 # Arch/OS/platform tests.
177 #----------------------------------------------------------------------------
178 # We create a number of arch/OS/platform-related variables.  We prefix them
179 # all with "VGCONF_" which indicates that they are defined at
180 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
181 # variables used when compiling C files.
183 AC_CANONICAL_HOST
185 AC_MSG_CHECKING([for a supported CPU])
187 # ARCH_MAX reflects the most that this CPU can do: for example if it
188 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
189 # Ditto for amd64.  It is used for more configuration below, but is not used
190 # outside this file.
192 # Power PC returns powerpc for Big Endian.  This was not changed when Little
193 # Endian support was added to the 64-bit architecture.  The 64-bit Little
194 # Endian systems explicitly state le in the host_cpu.  For clarity in the
195 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
196 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
197 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
198 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
199 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
200 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
201 # Little Endian.
203 case "${host_cpu}" in
204      i?86) 
205         AC_MSG_RESULT([ok (${host_cpu})])
206         ARCH_MAX="x86"
207         ;;
209      x86_64) 
210         AC_MSG_RESULT([ok (${host_cpu})])
211         ARCH_MAX="amd64"
212         ;;
214      powerpc64)
215      # this only referrs to 64-bit Big Endian
216         AC_MSG_RESULT([ok (${host_cpu})])
217         ARCH_MAX="ppc64be"
218         ;;
220      powerpc64le)
221      # this only referrs to 64-bit Little Endian
222         AC_MSG_RESULT([ok (${host_cpu})])
223         ARCH_MAX="ppc64le"
224         ;;
226      powerpc)
227         # On Linux this means only a 32-bit capable CPU.
228         AC_MSG_RESULT([ok (${host_cpu})])
229         ARCH_MAX="ppc32"
230         ;;
232      s390x)
233         AC_MSG_RESULT([ok (${host_cpu})])
234         ARCH_MAX="s390x"
235         ;;
237      armv7*)
238         AC_MSG_RESULT([ok (${host_cpu})])
239         ARCH_MAX="arm"
240         ;;
242      aarch64*)
243        AC_MSG_RESULT([ok (${host_cpu})])
244        ARCH_MAX="arm64"
245        ;;
247      mips)
248         AC_MSG_RESULT([ok (${host_cpu})])
249         ARCH_MAX="mips32"
250         ;;
252      mipsel)
253         AC_MSG_RESULT([ok (${host_cpu})])
254         ARCH_MAX="mips32"
255         ;;
257      mipsisa32r2)
258         AC_MSG_RESULT([ok (${host_cpu})])
259         ARCH_MAX="mips32"
260         ;;
262      mips64*)
263         AC_MSG_RESULT([ok (${host_cpu})])
264         ARCH_MAX="mips64"
265         ;;
267      mipsisa64*)
268         AC_MSG_RESULT([ok (${host_cpu})])
269         ARCH_MAX="mips64"
270         ;;
272      *) 
273         AC_MSG_RESULT([no (${host_cpu})])
274         AC_MSG_ERROR([Unsupported host architecture. Sorry])
275         ;;
276 esac
278 #----------------------------------------------------------------------------
280 # Sometimes it's convenient to subvert the bi-arch build system and
281 # just have a single build even though the underlying platform is
282 # capable of both.  Hence handle --enable-only64bit and
283 # --enable-only32bit.  Complain if both are issued :-)
284 # [Actually, if either of these options are used, I think both get built,
285 # but only one gets installed.  So if you use an in-place build, both can be
286 # used. --njn]
288 # Check if a 64-bit only build has been requested
289 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
290    [AC_ARG_ENABLE(only64bit, 
291       [  --enable-only64bit      do a 64-bit only build],
292       [vg_cv_only64bit=$enableval],
293       [vg_cv_only64bit=no])])
295 # Check if a 32-bit only build has been requested
296 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
297    [AC_ARG_ENABLE(only32bit, 
298       [  --enable-only32bit      do a 32-bit only build],
299       [vg_cv_only32bit=$enableval],
300       [vg_cv_only32bit=no])])
302 # Stay sane
303 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
304    AC_MSG_ERROR(
305       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
308 #----------------------------------------------------------------------------
310 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
311 # compilation of many C files via -VGO_$(VGCONF_OS) and
312 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
313 AC_MSG_CHECKING([for a supported OS])
314 AC_SUBST(VGCONF_OS)
316 DEFAULT_SUPP=""
318 case "${host_os}" in
319      *linux*)
320         AC_MSG_RESULT([ok (${host_os})])
321         VGCONF_OS="linux"
323         # Ok, this is linux. Check the kernel version
324         AC_MSG_CHECKING([for the kernel version])
326         kernel=`uname -r`
328         case "${kernel}" in
329              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
330                     AC_MSG_RESULT([unsupported (${kernel})])
331                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
332                     ;;
334              *)
335                     AC_MSG_RESULT([2.6 or later (${kernel})])
336                     ;;
337         esac
339         ;;
341      *darwin*)
342         AC_MSG_RESULT([ok (${host_os})])
343         VGCONF_OS="darwin"
344         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
345         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
346         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
347         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
348         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
349         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
350         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
351         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
353         AC_MSG_CHECKING([for the kernel version])
354         kernel=`uname -r`
356         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
357         # has only one relevant version, the OS version. The `uname` check
358         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
359         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
360         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
361         # and we don't know of an macros similar to __GLIBC__ to get that info.
362         #
363         # XXX: `uname -r` won't do the right thing for cross-compiles, but
364         # that's not a problem yet.
365         #
366         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
367         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
368         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
369         # time support for 10.5 (the 9.* pattern just below), I'll leave it
370         # in for now, just in case anybody wants to give it a try.  But I'm
371         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
372         case "${kernel}" in
373              9.*)
374                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
375                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
376                   DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
377                   DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
378                   ;;
379              10.*)
380                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
381                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
382                   DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
383                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
384                   ;;
385              11.*)
386                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
387                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
388                   DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
389                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
390                   ;;
391              12.*)
392                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
393                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
394                   DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
395                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
396                   ;;
397              13.*)
398                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
399                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
400                   DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
401                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
402                   ;;
403              14.*)
404                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
405                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
406                   DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
407                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
408                   ;;
409              15.*)
410                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
411                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
412                   DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
413                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
414                   ;;
415              16.*)
416                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
417                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
418                   DEFAULT_SUPP="darwin16.supp ${DEFAULT_SUPP}"
419                   DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
420                   ;;
421              *) 
422                   AC_MSG_RESULT([unsupported (${kernel})])
423                   AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x, 15.x and 16.x (Mac OS X 10.6/7/8/9/10/11 and macOS 10.12)])
424                   ;;
425         esac
426         ;;
428      solaris2.11*)
429         AC_MSG_RESULT([ok (${host_os})])
430         VGCONF_OS="solaris"
431         DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
432         ;;
434      solaris2.12*)
435         AC_MSG_RESULT([ok (${host_os})])
436         VGCONF_OS="solaris"
437         DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
438         ;;
440      *) 
441         AC_MSG_RESULT([no (${host_os})])
442         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
443         ;;
444 esac
446 #----------------------------------------------------------------------------
448 # If we are building on a 64 bit platform test to see if the system
449 # supports building 32 bit programs and disable 32 bit support if it
450 # does not support building 32 bit programs
452 case "$ARCH_MAX-$VGCONF_OS" in
453      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
454         AC_MSG_CHECKING([for 32 bit build support])
455         safe_CFLAGS=$CFLAGS
456         CFLAGS="-m32"
457         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
458           return 0;
459         ]])], [
460         AC_MSG_RESULT([yes])
461         ], [
462         vg_cv_only64bit="yes"
463         AC_MSG_RESULT([no])
464         ])
465         CFLAGS=$safe_CFLAGS;;
466 esac
468 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
469    AC_MSG_ERROR(
470       [--enable-only32bit was specified but system does not support 32 bit builds])
473 #----------------------------------------------------------------------------
475 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
476 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
477 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
478 # above) will be "amd64" since that reflects the most that this cpu can do,
479 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
480 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
481 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
482 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
483 AC_SUBST(VGCONF_ARCH_PRI)
485 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
486 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
487 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
488 # It is empty if there is no secondary target.
489 AC_SUBST(VGCONF_ARCH_SEC)
491 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
492 # The entire system, including regression and performance tests, will be
493 # built for this target.  The "_CAPS" indicates that the name is in capital
494 # letters, and it also uses '_' rather than '-' as a separator, because it's
495 # used to create various Makefile variables, which are all in caps by
496 # convention and cannot contain '-' characters.  This is in contrast to
497 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
498 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
500 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
501 # Valgrind and tools will also be built for this target, but not the
502 # regression or performance tests.
504 # By default, the primary arch is the same as the "max" arch, as commented
505 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
506 # the big case statement just below here, in the case where we're building
507 # on a 64 bit machine but have been requested only to do a 32 bit build.
508 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
510 AC_MSG_CHECKING([for a supported CPU/OS combination])
512 # NB.  The load address for a given platform may be specified in more 
513 # than one place, in some cases, depending on whether we're doing a biarch,
514 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
515 # Be careful to give consistent values in all subcases.  Also, all four
516 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
517 # even if it is to "0xUNSET".
519 case "$ARCH_MAX-$VGCONF_OS" in
520      x86-linux)
521         VGCONF_ARCH_PRI="x86"
522         VGCONF_ARCH_SEC=""
523         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
524         VGCONF_PLATFORM_SEC_CAPS=""
525         valt_load_address_pri_norml="0x58000000"
526         valt_load_address_pri_inner="0x38000000"
527         valt_load_address_sec_norml="0xUNSET"
528         valt_load_address_sec_inner="0xUNSET"
529         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
530         ;;
531      amd64-linux)
532         valt_load_address_sec_norml="0xUNSET"
533         valt_load_address_sec_inner="0xUNSET"
534         if test x$vg_cv_only64bit = xyes; then
535            VGCONF_ARCH_PRI="amd64"
536            VGCONF_ARCH_SEC=""
537            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
538            VGCONF_PLATFORM_SEC_CAPS=""
539            valt_load_address_pri_norml="0x58000000"
540            valt_load_address_pri_inner="0x38000000"
541         elif test x$vg_cv_only32bit = xyes; then
542            VGCONF_ARCH_PRI="x86"
543            VGCONF_ARCH_SEC=""
544            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
545            VGCONF_PLATFORM_SEC_CAPS=""
546            valt_load_address_pri_norml="0x58000000"
547            valt_load_address_pri_inner="0x38000000"
548         else
549            VGCONF_ARCH_PRI="amd64"
550            VGCONF_ARCH_SEC="x86"
551            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
552            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
553            valt_load_address_pri_norml="0x58000000"
554            valt_load_address_pri_inner="0x38000000"
555            valt_load_address_sec_norml="0x58000000"
556            valt_load_address_sec_inner="0x38000000"
557         fi
558         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
559         ;;
560      ppc32-linux)
561         VGCONF_ARCH_PRI="ppc32"
562         VGCONF_ARCH_SEC=""
563         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
564         VGCONF_PLATFORM_SEC_CAPS=""
565         valt_load_address_pri_norml="0x58000000"
566         valt_load_address_pri_inner="0x38000000"
567         valt_load_address_sec_norml="0xUNSET"
568         valt_load_address_sec_inner="0xUNSET"
569         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
570         ;;
571      ppc64be-linux)
572         valt_load_address_sec_norml="0xUNSET"
573         valt_load_address_sec_inner="0xUNSET"
574         if test x$vg_cv_only64bit = xyes; then
575            VGCONF_ARCH_PRI="ppc64be"
576            VGCONF_ARCH_SEC=""
577            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
578            VGCONF_PLATFORM_SEC_CAPS=""
579            valt_load_address_pri_norml="0x58000000"
580            valt_load_address_pri_inner="0x38000000"
581         elif test x$vg_cv_only32bit = xyes; then
582            VGCONF_ARCH_PRI="ppc32"
583            VGCONF_ARCH_SEC=""
584            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
585            VGCONF_PLATFORM_SEC_CAPS=""
586            valt_load_address_pri_norml="0x58000000"
587            valt_load_address_pri_inner="0x38000000"
588         else
589            VGCONF_ARCH_PRI="ppc64be"
590            VGCONF_ARCH_SEC="ppc32"
591            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
592            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
593            valt_load_address_pri_norml="0x58000000"
594            valt_load_address_pri_inner="0x38000000"
595            valt_load_address_sec_norml="0x58000000"
596            valt_load_address_sec_inner="0x38000000"
597         fi
598         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
599         ;;
600      ppc64le-linux)
601         # Little Endian is only supported on PPC64
602         valt_load_address_sec_norml="0xUNSET"
603         valt_load_address_sec_inner="0xUNSET"
604         VGCONF_ARCH_PRI="ppc64le"
605         VGCONF_ARCH_SEC=""
606         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
607         VGCONF_PLATFORM_SEC_CAPS=""
608         valt_load_address_pri_norml="0x58000000"
609         valt_load_address_pri_inner="0x38000000"
610         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
611        ;;
612      # Darwin gets identified as 32-bit even when it supports 64-bit.
613      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
614      # all Macs support both 32-bit and 64-bit, so we just build both.  If
615      # someone has a really old 32-bit only machine they can (hopefully?)
616      # build with --enable-only32bit.  See bug 243362.
617      x86-darwin|amd64-darwin)
618         ARCH_MAX="amd64"
619         valt_load_address_sec_norml="0xUNSET"
620         valt_load_address_sec_inner="0xUNSET"
621         if test x$vg_cv_only64bit = xyes; then
622            VGCONF_ARCH_PRI="amd64"
623            VGCONF_ARCH_SEC=""
624            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
625            VGCONF_PLATFORM_SEC_CAPS=""
626            valt_load_address_pri_norml="0x158000000"
627            valt_load_address_pri_inner="0x138000000"
628         elif test x$vg_cv_only32bit = xyes; then
629            VGCONF_ARCH_PRI="x86"
630            VGCONF_ARCH_SEC=""
631            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
632            VGCONF_PLATFORM_SEC_CAPS=""
633            VGCONF_ARCH_PRI_CAPS="x86"
634            valt_load_address_pri_norml="0x58000000"
635            valt_load_address_pri_inner="0x38000000"
636         else
637            VGCONF_ARCH_PRI="amd64"
638            VGCONF_ARCH_SEC="x86"
639            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
640            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
641            valt_load_address_pri_norml="0x158000000"
642            valt_load_address_pri_inner="0x138000000"
643            valt_load_address_sec_norml="0x58000000"
644            valt_load_address_sec_inner="0x38000000"
645         fi
646         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
647         ;;
648      arm-linux) 
649         VGCONF_ARCH_PRI="arm"
650         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
651         VGCONF_PLATFORM_SEC_CAPS=""
652         valt_load_address_pri_norml="0x58000000"
653         valt_load_address_pri_inner="0x38000000"
654         valt_load_address_sec_norml="0xUNSET"
655         valt_load_address_sec_inner="0xUNSET"
656         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
657         ;;
658      arm64-linux)
659         valt_load_address_sec_norml="0xUNSET"
660         valt_load_address_sec_inner="0xUNSET"
661         if test x$vg_cv_only64bit = xyes; then
662            VGCONF_ARCH_PRI="arm64"
663            VGCONF_ARCH_SEC=""
664            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
665            VGCONF_PLATFORM_SEC_CAPS=""
666            valt_load_address_pri_norml="0x58000000"
667            valt_load_address_pri_inner="0x38000000"
668         elif test x$vg_cv_only32bit = xyes; then
669            VGCONF_ARCH_PRI="arm"
670            VGCONF_ARCH_SEC=""
671            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
672            VGCONF_PLATFORM_SEC_CAPS=""
673            valt_load_address_pri_norml="0x58000000"
674            valt_load_address_pri_inner="0x38000000"
675         else
676            VGCONF_ARCH_PRI="arm64"
677            VGCONF_ARCH_SEC="arm"
678            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
679            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
680            valt_load_address_pri_norml="0x58000000"
681            valt_load_address_pri_inner="0x38000000"
682            valt_load_address_sec_norml="0x58000000"
683            valt_load_address_sec_inner="0x38000000"
684         fi
685         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
686         ;;
687      s390x-linux)
688         VGCONF_ARCH_PRI="s390x"
689         VGCONF_ARCH_SEC=""
690         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
691         VGCONF_PLATFORM_SEC_CAPS=""
692         # To improve branch prediction hit rate we want to have
693         # the generated code close to valgrind (host) code
694         valt_load_address_pri_norml="0x800000000"
695         valt_load_address_pri_inner="0x810000000"
696         valt_load_address_sec_norml="0xUNSET"
697         valt_load_address_sec_inner="0xUNSET"
698         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
699         ;;
700      mips32-linux) 
701         VGCONF_ARCH_PRI="mips32"
702         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
703         VGCONF_PLATFORM_SEC_CAPS=""
704         valt_load_address_pri_norml="0x58000000"
705         valt_load_address_pri_inner="0x38000000"
706         valt_load_address_sec_norml="0xUNSET"
707         valt_load_address_sec_inner="0xUNSET"
708         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
709         ;;
710      mips64-linux)
711         VGCONF_ARCH_PRI="mips64"
712         VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
713         VGCONF_PLATFORM_SEC_CAPS=""
714         valt_load_address_pri_norml="0x58000000"
715         valt_load_address_pri_inner="0x38000000"
716         valt_load_address_sec_norml="0xUNSET"
717         valt_load_address_sec_inner="0xUNSET"
718         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
719         ;;
720      x86-solaris)
721         VGCONF_ARCH_PRI="x86"
722         VGCONF_ARCH_SEC=""
723         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
724         VGCONF_PLATFORM_SEC_CAPS=""
725         valt_load_address_pri_norml="0x58000000"
726         valt_load_address_pri_inner="0x38000000"
727         valt_load_address_sec_norml="0xUNSET"
728         valt_load_address_sec_inner="0xUNSET"
729         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
730         ;;
731      amd64-solaris)
732         valt_load_address_sec_norml="0xUNSET"
733         valt_load_address_sec_inner="0xUNSET"
734         if test x$vg_cv_only64bit = xyes; then
735            VGCONF_ARCH_PRI="amd64"
736            VGCONF_ARCH_SEC=""
737            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
738            VGCONF_PLATFORM_SEC_CAPS=""
739            valt_load_address_pri_norml="0x58000000"
740            valt_load_address_pri_inner="0x38000000"
741         elif test x$vg_cv_only32bit = xyes; then
742            VGCONF_ARCH_PRI="x86"
743            VGCONF_ARCH_SEC=""
744            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
745            VGCONF_PLATFORM_SEC_CAPS=""
746            valt_load_address_pri_norml="0x58000000"
747            valt_load_address_pri_inner="0x38000000"
748         else
749            VGCONF_ARCH_PRI="amd64"
750            VGCONF_ARCH_SEC="x86"
751            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
752            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
753            valt_load_address_pri_norml="0x58000000"
754            valt_load_address_pri_inner="0x38000000"
755            valt_load_address_sec_norml="0x58000000"
756            valt_load_address_sec_inner="0x38000000"
757         fi
758         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
759         ;;
760     *)
761         VGCONF_ARCH_PRI="unknown"
762         VGCONF_ARCH_SEC="unknown"
763         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
764         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
765         valt_load_address_pri_norml="0xUNSET"
766         valt_load_address_pri_inner="0xUNSET"
767         valt_load_address_sec_norml="0xUNSET"
768         valt_load_address_sec_inner="0xUNSET"
769         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
770         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
771         ;;
772 esac
774 #----------------------------------------------------------------------------
776 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
777 # defined.
778 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
779                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
780                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
781                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
782                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
783                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
784                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
785 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
786                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
787                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
788                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
789 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
790                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
791                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
792 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
793                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
794                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
795 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
796                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
797                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
798 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
799                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
800 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
801                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
802 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
803                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
804 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
805                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
807 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
808 # become defined.
809 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
810                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
811                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
812 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
813                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
814 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
815                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
816                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
817 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
818                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
819 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
820                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
821 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
822                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
823                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
824 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
825                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
826 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
827                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
828                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
829 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
830                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
831 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
832                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
833 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,   
834                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
835                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
836 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
837                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
838 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
839                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
840                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
841 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
842                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
845 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
846 # Relies on the assumption that the primary and secondary targets are 
847 # for the same OS, so therefore only necessary to test the primary.
848 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
849                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
850                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
851                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
852                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
853                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
854                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
855                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
856                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
857                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
858                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
859 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
860                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
861                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
862 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
863                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
864                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
867 # Sometimes, in the Makefile.am files, it's useful to know whether or not
868 # there is a secondary target.
869 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
870                test x$VGCONF_PLATFORM_SEC_CAPS != x)
872 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
873 dnl fallback definition
874 dnl The macro is courtesy of Dave Hart:
875 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
876 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
877 if test -z "$$1_TRUE"; then :
878   m4_n([$2])[]dnl
879 m4_ifval([$3],
880 [else
881   $3
882 ])dnl
883 fi[]dnl
884 ])])
886 #----------------------------------------------------------------------------
887 # Inner Valgrind?
888 #----------------------------------------------------------------------------
890 # Check if this should be built as an inner Valgrind, to be run within
891 # another Valgrind.  Choose the load address accordingly.
892 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
893 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
894 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
895    [AC_ARG_ENABLE(inner, 
896       [  --enable-inner          enables self-hosting],
897       [vg_cv_inner=$enableval],
898       [vg_cv_inner=no])])
899 if test "$vg_cv_inner" = yes; then
900     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
901     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
902     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
903 else
904     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
905     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
908 #----------------------------------------------------------------------------
909 # Undefined behaviour sanitiser
910 #----------------------------------------------------------------------------
911 # Check whether we should build with the undefined beahviour sanitiser.
913 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
914    [AC_ARG_ENABLE(ubsan, 
915       [  --enable-ubsan          enables the undefined behaviour sanitiser],
916       [vg_cv_ubsan=$enableval],
917       [vg_cv_ubsan=no])])
919 #----------------------------------------------------------------------------
920 # Extra fine-tuning of installation directories
921 #----------------------------------------------------------------------------
922 AC_ARG_WITH(tmpdir,
923    [  --with-tmpdir=PATH      Specify path for temporary files],
924    tmpdir="$withval",
925    tmpdir="/tmp")
926 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
927 AC_SUBST(VG_TMPDIR, [$tmpdir])
930 #----------------------------------------------------------------------------
931 # Libc and suppressions
932 #----------------------------------------------------------------------------
933 # This variable will collect the suppression files to be used.
934 AC_SUBST(DEFAULT_SUPP)
936 AC_CHECK_HEADER([features.h])
938 if test x$ac_cv_header_features_h = xyes; then
939   rm -f conftest.$ac_ext
940   cat <<_ACEOF >conftest.$ac_ext
941 #include <features.h>
942 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
943 glibc version is: __GLIBC__ __GLIBC_MINOR__
944 #endif
945 _ACEOF
946   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
949 # not really a version check
950 AC_EGREP_CPP([DARWIN_LIBC], [
951 #include <sys/cdefs.h>
952 #if defined(__DARWIN_VERS_1050)
953   DARWIN_LIBC
954 #endif
956 GLIBC_VERSION="darwin")
958 # not really a version check
959 AC_EGREP_CPP([BIONIC_LIBC], [
960 #if defined(__ANDROID__)
961   BIONIC_LIBC
962 #endif
964 GLIBC_VERSION="bionic")
966 # there is only one version of libc on Solaris
967 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
968      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
969     GLIBC_VERSION="solaris"
972 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
973 # in this case.
974 if test x$GLIBC_VERSION = x; then
975     if $CC -dumpmachine | grep -q musl; then
976         GLIBC_VERSION=musl
977     fi
980 AC_MSG_CHECKING([the glibc version])
982 case "${GLIBC_VERSION}" in
983      2.2)
984         AC_MSG_RESULT(${GLIBC_VERSION} family)
985         DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
986         DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
987         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
988         ;;
989      2.[[3-6]])
990         AC_MSG_RESULT(${GLIBC_VERSION} family)
991         DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
992         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
993         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
994         ;;
995      2.[[7-9]])
996         AC_MSG_RESULT(${GLIBC_VERSION} family)
997         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
998         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
999         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1000         ;;
1001      2.10|2.11)
1002         AC_MSG_RESULT(${GLIBC_VERSION} family)
1003         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1004                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1005         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1006         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1007         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1008         ;;
1009      2.*)
1010         AC_MSG_RESULT(${GLIBC_VERSION} family)
1011         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1012                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1013         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1014                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1015         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1016         DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1017         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1018         ;;
1019      darwin)
1020         AC_MSG_RESULT(Darwin)
1021         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1022         # DEFAULT_SUPP set by kernel version check above.
1023         ;;
1024      bionic)
1025         AC_MSG_RESULT(Bionic)
1026         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1027         DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1028         ;;
1029      solaris)
1030         AC_MSG_RESULT(Solaris)
1031         # DEFAULT_SUPP set in host_os switch-case above.
1032         # No other suppression file is used.
1033         ;;
1034      musl)
1035         AC_MSG_RESULT(Musl)
1036         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1037         # no DEFAULT_SUPP file yet for musl libc.
1038         ;;
1039      2.0|2.1|*)
1040         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1041         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1042         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1043         ;;
1044 esac
1046 AC_SUBST(GLIBC_VERSION)
1049 if test "$VGCONF_OS" != "solaris"; then
1050     # Add default suppressions for the X client libraries.  Make no
1051     # attempt to detect whether such libraries are installed on the
1052     # build machine (or even if any X facilities are present); just
1053     # add the suppressions antidisirregardless.
1054     DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1055     DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1057     # Add glibc and X11 suppressions for exp-sgcheck
1058     DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
1062 #----------------------------------------------------------------------------
1063 # Platform variants?
1064 #----------------------------------------------------------------------------
1066 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1067 # But there are times where we need a bit more control.  The motivating
1068 # and currently only case is Android: this is almost identical to
1069 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1070 # platform variant tags, which get passed in the compile as
1071 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1073 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1074 # it is "android" instead.
1076 # Consequently (eg), plain arm-linux would build with
1078 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1080 # whilst an Android build would have
1082 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1084 # Same for x86. The setup of the platform variant is pushed relatively far
1085 # down this file in order that we can inspect any of the variables set above.
1087 # In the normal case ..
1088 VGCONF_PLATVARIANT="vanilla"
1090 # Android ?
1091 if test "$GLIBC_VERSION" = "bionic";
1092 then
1093    VGCONF_PLATVARIANT="android"
1096 AC_SUBST(VGCONF_PLATVARIANT)
1099 # FIXME: do we also want to define automake variables
1100 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1101 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1102 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1103 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1104 # that's what we'd need to do to use this, since what we'd want to write
1105 # is something like
1107 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1109 # Hmm.  Can't think of a nice clean solution to this.
1111 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1112                test x$VGCONF_PLATVARIANT = xvanilla)
1113 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1114                test x$VGCONF_PLATVARIANT = xandroid)
1117 #----------------------------------------------------------------------------
1118 # Checking for various library functions and other definitions
1119 #----------------------------------------------------------------------------
1121 # Check for AT_FDCWD
1123 AC_MSG_CHECKING([for AT_FDCWD])
1124 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1125 #define _GNU_SOURCE
1126 #include <fcntl.h>
1127 #include <unistd.h>
1128 ]], [[
1129   int a = AT_FDCWD;
1130 ]])], [
1131 ac_have_at_fdcwd=yes
1132 AC_MSG_RESULT([yes])
1133 ], [
1134 ac_have_at_fdcwd=no
1135 AC_MSG_RESULT([no])
1138 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1140 # Check for stpncpy function definition in string.h
1141 # This explicitly checks with _GNU_SOURCE defined since that is also
1142 # used in the test case (some systems might define it without anyway
1143 # since stpncpy is part of The Open Group Base Specifications Issue 7
1144 # IEEE Std 1003.1-2008.
1145 AC_MSG_CHECKING([for stpncpy])
1146 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1147 #define _GNU_SOURCE
1148 #include <string.h>
1149 ]], [[
1150   char *d;
1151   char *s;
1152   size_t n = 0;
1153   char *r = stpncpy(d, s, n);
1154 ]])], [
1155 ac_have_gnu_stpncpy=yes
1156 AC_MSG_RESULT([yes])
1157 ], [
1158 ac_have_gnu_stpncpy=no
1159 AC_MSG_RESULT([no])
1162 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1164 # Check for PTRACE_GETREGS
1166 AC_MSG_CHECKING([for PTRACE_GETREGS])
1167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1168 #include <stdlib.h>
1169 #include <stddef.h>
1170 #include <sys/ptrace.h>
1171 #include <sys/user.h>
1172 ]], [[
1173   void *p;
1174   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1175 ]])], [
1176 AC_MSG_RESULT([yes])
1177 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1178           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1179 ], [
1180 AC_MSG_RESULT([no])
1184 # Check for CLOCK_MONOTONIC
1186 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1189 #include <time.h>
1190 ]], [[
1191   struct timespec t;
1192   clock_gettime(CLOCK_MONOTONIC, &t);
1193   return 0;
1194 ]])], [
1195 AC_MSG_RESULT([yes])
1196 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1197           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1198 ], [
1199 AC_MSG_RESULT([no])
1203 # Check for ELF32/64_CHDR
1205 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1208 # Check for PTHREAD_RWLOCK_T
1210 AC_MSG_CHECKING([for pthread_rwlock_t])
1212 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1213 #define _GNU_SOURCE
1214 #include <pthread.h>
1215 ]], [[
1216   pthread_rwlock_t rwl;
1217 ]])], [
1218 AC_MSG_RESULT([yes])
1219 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1220           [Define to 1 if you have the `pthread_rwlock_t' type.])
1221 ], [
1222 AC_MSG_RESULT([no])
1226 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1228 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1230 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1231 #define _GNU_SOURCE
1232 #include <pthread.h>
1233 ]], [[
1234   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1235 ]])], [
1236 AC_MSG_RESULT([yes])
1237 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1238           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1239 ], [
1240 AC_MSG_RESULT([no])
1244 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1246 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1248 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1249 #define _GNU_SOURCE
1250 #include <pthread.h>
1251 ]], [[
1252   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1253 ]])], [
1254 AC_MSG_RESULT([yes])
1255 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1256           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1257 ], [
1258 AC_MSG_RESULT([no])
1262 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1264 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1266 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1267 #define _GNU_SOURCE
1268 #include <pthread.h>
1269 ]], [[
1270   return (PTHREAD_MUTEX_RECURSIVE_NP);
1271 ]])], [
1272 AC_MSG_RESULT([yes])
1273 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1274           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1275 ], [
1276 AC_MSG_RESULT([no])
1280 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1282 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1284 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1285 #define _GNU_SOURCE
1286 #include <pthread.h>
1287 ]], [[
1288   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1289   return 0;
1290 ]])], [
1291 AC_MSG_RESULT([yes])
1292 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1293           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1294 ], [
1295 AC_MSG_RESULT([no])
1299 # Check whether pthread_mutex_t has a member called __m_kind.
1301 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1302                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1303                            1,                                   
1304                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1305                 ],
1306                 [],
1307                 [#include <pthread.h>])
1310 # Check whether pthread_mutex_t has a member called __data.__kind.
1312 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1313                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1314                           1,
1315                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1316                 ],
1317                 [],
1318                 [#include <pthread.h>])
1320 # Convenience function.  Set flags based on the existing HWCAP entries.
1321 # The AT_HWCAP entries are generated by glibc, and are based on
1322 # functions supported by the hardware/system/libc.
1323 # Subsequent support for whether the capability will actually be utilized
1324 # will also be checked against the compiler capabilities.
1325 # called as
1326 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1327 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1328   AUXV_CHECK_FOR=$1
1329   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1330   if LD_SHOW_AUXV=1 `which true` | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1331   then
1332     AC_MSG_RESULT([yes])
1333     AC_SUBST([$2],[yes])
1334   else
1335     AC_MSG_RESULT([no])
1336     AC_SUBST([$2],[])
1337   fi
1340 # gather hardware capabilities. (hardware/kernel/libc)
1341 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1342 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1343 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1344 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1345 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1346 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1347 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1348 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1350 # ISA Levels
1351 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1352 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1353 # compiler support for isa 2.07 level instructions
1354 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1355 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1356 ]], [[
1357   __asm__ __volatile__("mtvsrd 1,2 ");
1358 ]])], [
1359 ac_asm_have_isa_2_07=yes
1360 AC_MSG_RESULT([yes])
1361 ], [
1362 ac_asm_have_isa_2_07=no
1363 AC_MSG_RESULT([no])
1365 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1366                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1368 # altivec (vsx) support.
1369 # does this compiler support -maltivec and does it have the include file
1370 # <altivec.h> ?
1371 AC_MSG_CHECKING([for Altivec support in the compiler ])
1372 safe_CFLAGS=$CFLAGS
1373 CFLAGS="-maltivec -Werror"
1374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1375 #include <altivec.h>
1376 ]], [[
1377   vector unsigned int v;
1378 ]])], [
1379 ac_have_altivec=yes
1380 AC_MSG_RESULT([yes])
1381 ], [
1382 ac_have_altivec=no
1383 AC_MSG_RESULT([no])
1385 CFLAGS=$safe_CFLAGS
1386 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1387                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1389 # Check that both: the compiler supports -mvsx and that the assembler
1390 # understands VSX instructions.  If either of those doesn't work,
1391 # conclude that we can't do VSX.
1392 AC_MSG_CHECKING([for VSX compiler flag support])
1393 safe_CFLAGS=$CFLAGS
1394 CFLAGS="-mvsx -Werror"
1395 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1396 ]], [[
1397 ]])], [
1398 ac_compiler_supports_vsx_flag=yes
1399 AC_MSG_RESULT([yes])
1400 ], [
1401 ac_compiler_supports_vsx_flag=no
1402 AC_MSG_RESULT([no])
1404 CFLAGS=$safe_CFLAGS
1406 AC_MSG_CHECKING([for VSX support in the assembler ])
1407 safe_CFLAGS=$CFLAGS
1408 CFLAGS="-mvsx -Werror"
1409 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1410 #include <altivec.h>
1411 ]], [[
1412   vector unsigned int v;
1413   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1414 ]])], [
1415 ac_compiler_supports_vsx=yes
1416 AC_MSG_RESULT([yes])
1417 ], [
1418 ac_compiler_supports_vsx=no
1419 AC_MSG_RESULT([no])
1421 CFLAGS=$safe_CFLAGS
1422 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1423                              -a x$ac_compiler_supports_vsx = xyes \
1424                              -a x$HWCAP_HAS_VSX = xyes ])
1426 # DFP (Decimal Float)
1427 AC_MSG_CHECKING([that assembler knows DFP])
1428 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1429 ]], [[
1430   #ifdef __s390__
1431   __asm__ __volatile__("adtr 1, 2, 3")
1432   #else
1433   __asm__ __volatile__("dadd 1, 2, 3");
1434   __asm__ __volatile__("dcffix 1, 2");
1435   #endif
1436 ]])], [
1437 ac_asm_have_dfp=yes
1438 AC_MSG_RESULT([yes])
1439 ], [
1440 ac_asm_have_dfp=no
1441 AC_MSG_RESULT([no])
1443 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1444 safe_CFLAGS=$CFLAGS
1445 CFLAGS="-mhard-dfp -Werror"
1446 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1447 ]], [[
1448   #ifdef __s390__
1449   __asm__ __volatile__("adtr 1, 2, 3")
1450   #else
1451   __asm__ __volatile__("dadd 1, 2, 3");
1452   __asm__ __volatile__("dcffix 1, 2");
1453   #endif
1454 ]])], [
1455 ac_compiler_have_dfp=yes
1456 AC_MSG_RESULT([yes])
1457 ], [
1458 ac_compiler_have_dfp=no
1459 AC_MSG_RESULT([no])
1461 CFLAGS=$safe_CFLAGS
1462 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1463                           -a x$ac_compiler_have_dfp = xyes \
1464                           -a x$HWCAP_HAS_DFP = xyes )
1466 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1467 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1468 ]], [[
1469   _Decimal64 x = 0.0DD;
1470 ]])], [
1471 ac_compiler_have_dfp_type=yes
1472 AC_MSG_RESULT([yes])
1473 ], [
1474 ac_compiler_have_dfp_type=no
1475 AC_MSG_RESULT([no])
1477 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1478                                   -a x$HWCAP_HAS_DFP = xyes )
1481 # HTM (Hardware Transactional Memory)
1482 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1483 safe_CFLAGS=$CFLAGS
1484 CFLAGS="-mhtm -Werror"
1485 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1486 ]], [[
1487   return 0;
1488 ]])], [
1489 AC_MSG_RESULT([yes])
1490 ac_compiler_supports_htm=yes
1491 ], [
1492 AC_MSG_RESULT([no])
1493 ac_compiler_supports_htm=no
1495 CFLAGS=$safe_CFLAGS
1497 AC_MSG_CHECKING([if compiler can find the htm builtins])
1498 safe_CFLAGS=$CFLAGS
1499 CFLAGS="-mhtm -Werror"
1500  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1501  ]], [[
1502    if (__builtin_tbegin (0))
1503       __builtin_tend (0);
1504  ]])], [
1505  AC_MSG_RESULT([yes])
1506 ac_compiler_sees_htm_builtins=yes
1507  ], [
1508  AC_MSG_RESULT([no])
1509 ac_compiler_sees_htm_builtins=no
1510  ])
1511 CFLAGS=$safe_CFLAGS
1513 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1514                                -a x$ac_compiler_sees_htm_builtins = xyes \
1515                                -a x$HWCAP_HAS_HTM = xyes )
1517 # isa 3.0 checking
1518 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1520 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1521 ]], [[
1522   __asm__ __volatile__("cnttzw 1,2 ");
1523 ]])], [
1524 ac_asm_have_isa_3_00=yes
1525 AC_MSG_RESULT([yes])
1526 ], [
1527 ac_asm_have_isa_3_00=no
1528 AC_MSG_RESULT([no])
1531 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1532                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1534 # Check for pthread_create@GLIBC2.0
1535 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1537 safe_CFLAGS=$CFLAGS
1538 CFLAGS="-lpthread -Werror"
1539 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1540 extern int pthread_create_glibc_2_0(void*, const void*,
1541                                     void *(*)(void*), void*);
1542 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1543 ]], [[
1544 #ifdef __powerpc__
1546  * Apparently on PowerPC linking this program succeeds and generates an
1547  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1548  */
1549 #error This test does not work properly on PowerPC.
1550 #else
1551   pthread_create_glibc_2_0(0, 0, 0, 0);
1552 #endif
1553   return 0;
1554 ]])], [
1555 ac_have_pthread_create_glibc_2_0=yes
1556 AC_MSG_RESULT([yes])
1557 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1558           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1559 ], [
1560 ac_have_pthread_create_glibc_2_0=no
1561 AC_MSG_RESULT([no])
1563 CFLAGS=$safe_CFLAGS
1565 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1566                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1569 # Check for dlinfo RTLD_DI_TLS_MODID
1570 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1572 safe_LIBS="$LIBS"
1573 LIBS="-ldl"
1574 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1575 #ifndef _GNU_SOURCE
1576 #define _GNU_SOURCE
1577 #endif
1578 #include <link.h>
1579 #include <dlfcn.h>
1580 ]], [[
1581   size_t sizes[10000];
1582   size_t modid_offset;
1583   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1584   return 0;
1585 ]])], [
1586 ac_have_dlinfo_rtld_di_tls_modid=yes
1587 AC_MSG_RESULT([yes])
1588 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1589           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1590 ], [
1591 ac_have_dlinfo_rtld_di_tls_modid=no
1592 AC_MSG_RESULT([no])
1594 LIBS=$safe_LIBS
1596 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1597                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1600 # Check for eventfd_t, eventfd() and eventfd_read()
1601 AC_MSG_CHECKING([for eventfd()])
1603 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1604 #include <sys/eventfd.h>
1605 ]], [[
1606   eventfd_t ev;
1607   int fd;
1609   fd = eventfd(5, 0);
1610   eventfd_read(fd, &ev);
1611   return 0;
1612 ]])], [
1613 AC_MSG_RESULT([yes])
1614 AC_DEFINE([HAVE_EVENTFD], 1,
1615           [Define to 1 if you have the `eventfd' function.])
1616 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1617           [Define to 1 if you have the `eventfd_read' function.])
1618 ], [
1619 AC_MSG_RESULT([no])
1622 # Check whether compiler can process #include <thread> without errors
1623 # clang 3.3 cannot process <thread> from e.g.
1624 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1626 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1627 AC_LANG(C++)
1628 safe_CXXFLAGS=$CXXFLAGS
1629 CXXFLAGS=-std=c++0x
1631 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1632 #include <thread> 
1633 ])],
1635 ac_cxx_can_include_thread_header=yes
1636 AC_MSG_RESULT([yes])
1637 ], [
1638 ac_cxx_can_include_thread_header=no
1639 AC_MSG_RESULT([no])
1641 CXXFLAGS=$safe_CXXFLAGS
1642 AC_LANG(C)
1644 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1647 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1648 # of the user_regs_struct from sys/user.h. They are structurally the same
1649 # but we get either one or the other.
1651 AC_CHECK_TYPE([struct user_regs_struct],
1652               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1653               [[#include <sys/ptrace.h>]
1654                [#include <sys/time.h>]
1655                [#include <sys/user.h>]])
1656 if test "$sys_user_has_user_regs" = "yes"; then
1657   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1658             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1662 #----------------------------------------------------------------------------
1663 # Checking for supported compiler flags.
1664 #----------------------------------------------------------------------------
1666 # does this compiler support -m32 ?
1667 AC_MSG_CHECKING([if gcc accepts -m32])
1669 safe_CFLAGS=$CFLAGS
1670 CFLAGS="-m32 -Werror"
1672 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1673   return 0;
1674 ]])], [
1675 FLAG_M32="-m32"
1676 AC_MSG_RESULT([yes])
1677 ], [
1678 FLAG_M32=""
1679 AC_MSG_RESULT([no])
1681 CFLAGS=$safe_CFLAGS
1683 AC_SUBST(FLAG_M32)
1686 # does this compiler support -m64 ?
1687 AC_MSG_CHECKING([if gcc accepts -m64])
1689 safe_CFLAGS=$CFLAGS
1690 CFLAGS="-m64 -Werror"
1692 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1693   return 0;
1694 ]])], [
1695 FLAG_M64="-m64"
1696 AC_MSG_RESULT([yes])
1697 ], [
1698 FLAG_M64=""
1699 AC_MSG_RESULT([no])
1701 CFLAGS=$safe_CFLAGS
1703 AC_SUBST(FLAG_M64)
1706 # does this compiler support -march=mips32 (mips32 default) ?
1707 AC_MSG_CHECKING([if gcc accepts -march=mips32])
1709 safe_CFLAGS=$CFLAGS
1710 CFLAGS="$CFLAGS -march=mips32 -Werror"
1712 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1713   return 0;
1714 ]])], [
1715 FLAG_MIPS32="-march=mips32"
1716 AC_MSG_RESULT([yes])
1717 ], [
1718 FLAG_MIPS32=""
1719 AC_MSG_RESULT([no])
1721 CFLAGS=$safe_CFLAGS
1723 AC_SUBST(FLAG_MIPS32)
1726 # does this compiler support -march=mips64 (mips64 default) ?
1727 AC_MSG_CHECKING([if gcc accepts -march=mips64])
1729 safe_CFLAGS=$CFLAGS
1730 CFLAGS="$CFLAGS -march=mips64 -Werror"
1732 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1733   return 0;
1734 ]])], [
1735 FLAG_MIPS64="-march=mips64"
1736 AC_MSG_RESULT([yes])
1737 ], [
1738 FLAG_MIPS64=""
1739 AC_MSG_RESULT([no])
1741 CFLAGS=$safe_CFLAGS
1743 AC_SUBST(FLAG_MIPS64)
1746 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1747 AC_MSG_CHECKING([if gcc accepts -march=octeon])
1749 safe_CFLAGS=$CFLAGS
1750 CFLAGS="$CFLAGS -march=octeon -Werror"
1752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1753   return 0;
1754 ]])], [
1755 FLAG_OCTEON="-march=octeon"
1756 AC_MSG_RESULT([yes])
1757 ], [
1758 FLAG_OCTEON=""
1759 AC_MSG_RESULT([no])
1761 CFLAGS=$safe_CFLAGS
1763 AC_SUBST(FLAG_OCTEON)
1766 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1767 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1769 safe_CFLAGS=$CFLAGS
1770 CFLAGS="$CFLAGS -march=octeon2 -Werror"
1772 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1773   return 0;
1774 ]])], [
1775 FLAG_OCTEON2="-march=octeon2"
1776 AC_MSG_RESULT([yes])
1777 ], [
1778 FLAG_OCTEON2=""
1779 AC_MSG_RESULT([no])
1781 CFLAGS=$safe_CFLAGS
1783 AC_SUBST(FLAG_OCTEON2)
1786 # does this compiler support -mmmx ?
1787 AC_MSG_CHECKING([if gcc accepts -mmmx])
1789 safe_CFLAGS=$CFLAGS
1790 CFLAGS="-mmmx -Werror"
1792 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1793   return 0;
1794 ]])], [
1795 FLAG_MMMX="-mmmx"
1796 AC_MSG_RESULT([yes])
1797 ], [
1798 FLAG_MMMX=""
1799 AC_MSG_RESULT([no])
1801 CFLAGS=$safe_CFLAGS
1803 AC_SUBST(FLAG_MMMX)
1806 # does this compiler support -msse ?
1807 AC_MSG_CHECKING([if gcc accepts -msse])
1809 safe_CFLAGS=$CFLAGS
1810 CFLAGS="-msse -Werror"
1812 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1813   return 0;
1814 ]])], [
1815 FLAG_MSSE="-msse"
1816 AC_MSG_RESULT([yes])
1817 ], [
1818 FLAG_MSSE=""
1819 AC_MSG_RESULT([no])
1821 CFLAGS=$safe_CFLAGS
1823 AC_SUBST(FLAG_MSSE)
1826 # does this compiler support -mpreferred-stack-boundary=2 when
1827 # generating code for a 32-bit target?  Note that we only care about
1828 # this when generating code for (32-bit) x86, so if the compiler
1829 # doesn't recognise -m32 it's no big deal.  We'll just get code for
1830 # the Memcheck and other helper functions, that is a bit slower than
1831 # it could be, on x86; and no difference at all on any other platform.
1832 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
1834 safe_CFLAGS=$CFLAGS
1835 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
1837 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1838   return 0;
1839 ]])], [
1840 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
1841 AC_MSG_RESULT([yes])
1842 ], [
1843 PREFERRED_STACK_BOUNDARY_2=""
1844 AC_MSG_RESULT([no])
1846 CFLAGS=$safe_CFLAGS
1848 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
1851 # does this compiler support -mlong-double-128 ?
1852 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
1853 safe_CFLAGS=$CFLAGS
1854 CFLAGS="-mlong-double-128 -Werror"
1855 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1856   return 0;
1857 ]])], [
1858 ac_compiler_supports_mlong_double_128=yes
1859 AC_MSG_RESULT([yes])
1860 ], [
1861 ac_compiler_supports_mlong_double_128=no
1862 AC_MSG_RESULT([no])
1864 CFLAGS=$safe_CFLAGS
1865 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
1866 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
1867 AC_SUBST(FLAG_MLONG_DOUBLE_128)
1870 # Convenience function to check whether GCC supports a particular
1871 # warning option. Takes two arguments,
1872 # first the warning flag name to check (without -W), then the
1873 # substitution name to set with -Wno-warning-flag if the flag exists,
1874 # or the empty string if the compiler doesn't accept the flag. Note
1875 # that checking is done against the warning flag itself, but the
1876 # substitution is then done to cancel the warning flag.
1877 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
1878   AC_MSG_CHECKING([if gcc accepts -W$1])
1879   safe_CFLAGS=$CFLAGS
1880   CFLAGS="-W$1 -Werror"
1881   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1882   AC_SUBST([$2], [-Wno-$1])
1883   AC_MSG_RESULT([yes])], [
1884   AC_SUBST([$2], [])
1885   AC_MSG_RESULT([no])])
1886   CFLAGS=$safe_CFLAGS
1889 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
1890 # -W$1  (instead of -Wno-$1).
1891 AC_DEFUN([AC_GCC_WARNING_SUBST],[
1892   AC_MSG_CHECKING([if gcc accepts -W$1])
1893   safe_CFLAGS=$CFLAGS
1894   CFLAGS="-W$1 -Werror"
1895   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1896   AC_SUBST([$2], [-W$1])
1897   AC_MSG_RESULT([yes])], [
1898   AC_SUBST([$2], [])
1899   AC_MSG_RESULT([no])])
1900   CFLAGS=$safe_CFLAGS
1903 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
1904 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
1905 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
1906 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
1907 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
1908 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
1909 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
1910 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
1911 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
1912 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
1913 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
1914 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
1915 # Disabled for now until all platforms are clean
1916 format_checking_enabled=no
1917 #format_checking_enabled=yes
1918 if test "$format_checking_enabled" = "yes"; then
1919    AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
1920 else
1921    dumy_assignment_to_avoid_syntax_errors=1
1922    AC_SUBST([FLAG_W_FORMAT_SIGNEDNESS], [])
1924 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
1925 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
1926 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
1927 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
1929 # Does this compiler support -Wformat-security ?
1930 # Special handling is needed, because certain GCC versions require -Wformat
1931 # being present if -Wformat-security is given. Otherwise a warning is issued.
1932 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
1933 # And with that the warning will be turned into an error with the result
1934 # that -Wformat-security is believed to be unsupported when in fact it is.
1935 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
1936 safe_CFLAGS=$CFLAGS
1937 CFLAGS="-Wformat -Wformat-security -Werror"
1938 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1939 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
1940 AC_MSG_RESULT([yes])], [
1941 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
1942 AC_MSG_RESULT([no])])
1943 CFLAGS=$safe_CFLAGS
1945 # does this compiler support -Wextra or the older -W ?
1947 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1949 safe_CFLAGS=$CFLAGS
1950 CFLAGS="-Wextra -Werror"
1952 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1953   return 0;
1954 ]])], [
1955 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1956 AC_MSG_RESULT([-Wextra])
1957 ], [
1958   CFLAGS="-W -Werror"
1959   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1960     return 0;
1961   ]])], [
1962   AC_SUBST([FLAG_W_EXTRA], [-W])
1963   AC_MSG_RESULT([-W])
1964   ], [
1965   AC_SUBST([FLAG_W_EXTRA], [])
1966   AC_MSG_RESULT([not supported])
1967   ])
1969 CFLAGS=$safe_CFLAGS
1971 # On ARM we do not want to pass -Wcast-align as that produces loads
1972 # of warnings. GCC is just being conservative. See here:
1973 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
1974 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
1975   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
1976 else
1977   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
1980 # does this compiler support -fno-stack-protector ?
1981 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1983 safe_CFLAGS=$CFLAGS
1984 CFLAGS="-fno-stack-protector -Werror"
1986 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1987   return 0;
1988 ]])], [
1989 no_stack_protector=yes
1990 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1991 AC_MSG_RESULT([yes])
1992 ], [
1993 no_stack_protector=no
1994 FLAG_FNO_STACK_PROTECTOR=""
1995 AC_MSG_RESULT([no])
1997 CFLAGS=$safe_CFLAGS
1999 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2001 # Does GCC support disabling Identical Code Folding?
2002 # We want to disabled Identical Code Folding for the
2003 # tools preload shared objects to get better backraces.
2004 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2005 # "The optimization reduces code size and may disturb
2006 #  unwind stacks by replacing a function by equivalent
2007 #  one with a different name."
2008 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2010 safe_CFLAGS=$CFLAGS
2011 CFLAGS="-fno-ipa-icf -Werror"
2013 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2014   return 0;
2015 ]])], [
2016 no_ipa_icf=yes
2017 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2018 AC_MSG_RESULT([yes])
2019 ], [
2020 no_ipa_icf=no
2021 FLAG_FNO_IPA_ICF=""
2022 AC_MSG_RESULT([no])
2024 CFLAGS=$safe_CFLAGS
2026 AC_SUBST(FLAG_FNO_IPA_ICF)
2029 # Does this compiler support -fsanitize=undefined. This is true for
2030 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2031 # also checks for alignment violations on memory accesses which the valgrind
2032 # code base is sprinkled (if not littered) with. As those alignment issues
2033 # don't pose a problem we want to suppress warnings about them.
2034 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2035 # GCCs do not support that.
2037 # Only checked for if --enable-ubsan was given.
2038 if test "x${vg_cv_ubsan}" = "xyes"; then
2039 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2040 safe_CFLAGS=$CFLAGS
2041 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2042 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2043   return 0;
2044 ]])], [
2045 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2046 LIB_UBSAN="-static-libubsan"
2047 AC_MSG_RESULT([yes])
2048 ], [
2049 CFLAGS="-fsanitize=undefined -Werror"
2050 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2051   return 0;
2052 ]])], [
2053 FLAG_FSANITIZE="-fsanitize=undefined"
2054 LIB_UBSAN="-static-libubsan"
2055 AC_MSG_RESULT([yes])
2056 ], [
2057 FLAG_FSANITIZE=""
2058 LIB_UBSAN=""
2059 AC_MSG_RESULT([no])
2062 CFLAGS=$safe_CFLAGS
2063 AC_SUBST(FLAG_FSANITIZE)
2064 AC_SUBST(LIB_UBSAN)
2066 # does this compiler support --param inline-unit-growth=... ?
2068 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2070 safe_CFLAGS=$CFLAGS
2071 CFLAGS="--param inline-unit-growth=900 -Werror"
2073 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2074   return 0;
2075 ]])], [
2076 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2077          ["--param inline-unit-growth=900"])
2078 AC_MSG_RESULT([yes])
2079 ], [
2080 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2081 AC_MSG_RESULT([no])
2083 CFLAGS=$safe_CFLAGS
2086 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2088 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2090 safe_CFLAGS=$CFLAGS
2091 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2093 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2094   return 0;
2095 ]])], [
2096 ac_have_dwarf4=yes
2097 AC_MSG_RESULT([yes])
2098 ], [
2099 ac_have_dwarf4=no
2100 AC_MSG_RESULT([no])
2102 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2103 CFLAGS=$safe_CFLAGS
2106 # does this compiler support -g -gz=zlib ?
2108 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2110 safe_CFLAGS=$CFLAGS
2111 CFLAGS="-g -gz=zlib"
2113 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2114   return 0;
2115 ]])], [
2116 ac_have_gz_zlib=yes
2117 AC_MSG_RESULT([yes])
2118 ], [
2119 ac_have_gz_zlib=no
2120 AC_MSG_RESULT([no])
2122 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2123 CFLAGS=$safe_CFLAGS
2126 # does this compiler support -g -gz=zlib-gnu ?
2128 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2130 safe_CFLAGS=$CFLAGS
2131 CFLAGS="-g -gz=zlib-gnu"
2133 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2134   return 0;
2135 ]])], [
2136 ac_have_gz_zlib_gnu=yes
2137 AC_MSG_RESULT([yes])
2138 ], [
2139 ac_have_gz_zlib_gnu=no
2140 AC_MSG_RESULT([no])
2142 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2143 CFLAGS=$safe_CFLAGS
2146 # does this compiler support nested functions ?
2148 AC_MSG_CHECKING([if gcc accepts nested functions])
2150 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2151   int foo() { return 1; }
2152   return foo();
2153 ]])], [
2154 ac_have_nested_functions=yes
2155 AC_MSG_RESULT([yes])
2156 ], [
2157 ac_have_nested_functions=no
2158 AC_MSG_RESULT([no])
2160 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2163 # does this compiler support the 'p' constraint in ASM statements ?
2165 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2168    char *p;
2169    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2170 ]])], [
2171 ac_have_asm_constraint_p=yes
2172 AC_MSG_RESULT([yes])
2173 ], [
2174 ac_have_asm_constraint_p=no
2175 AC_MSG_RESULT([no])
2177 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2180 # Does this compiler support -no-pie?
2181 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2182 # default. However this gets in the way with some tests, we use -no-pie
2183 # for these.
2185 AC_MSG_CHECKING([if gcc accepts -no-pie])
2187 safe_CFLAGS=$CFLAGS
2188 CFLAGS="-no-pie"
2190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2191   return 0;
2192 ]])], [
2193 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2194 AC_MSG_RESULT([yes])
2195 ], [
2196 AC_SUBST([FLAG_NO_PIE], [""])
2197 AC_MSG_RESULT([no])
2199 CFLAGS=$safe_CFLAGS
2202 # We want to use use the -Ttext-segment option to the linker.
2203 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2204 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2205 # semantics are NOT what we want (GNU gold -Ttext is fine).
2207 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2208 # will reside. -Ttext aligns just the .text section start (but not any
2209 # other section).
2211 # So test for -Ttext-segment which is supported by all bfd ld versions
2212 # and use that if it exists. If it doesn't exist it must be an older
2213 # version of gold and we can fall back to using -Ttext which has the
2214 # right semantics.
2216 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2218 safe_CFLAGS=$CFLAGS
2219 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2221 AC_LINK_IFELSE(
2222 [AC_LANG_SOURCE([int _start () { return 0; }])],
2224   linker_using_t_text="no"
2225   AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2226   AC_MSG_RESULT([yes])
2227 ], [
2228   linker_using_t_text="yes"
2229   AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2230   AC_MSG_RESULT([no])
2232 CFLAGS=$safe_CFLAGS
2234 # If the linker only supports -Ttext (not -Ttext-segment) then we will
2235 # have to strip any build-id ELF NOTEs from the statically linked tools.
2236 # Otherwise the build-id NOTE might end up at the default load address.
2237 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2238 # gold versions also support -Ttext-segment. So just assume that unless
2239 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2240 if test "x${linker_using_t_text}" = "xyes"; then
2241 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2242 # does the linker support -Wl,--build-id=none ?  Note, it's
2243 # important that we test indirectly via whichever C compiler
2244 # is selected, rather than testing /usr/bin/ld or whatever
2245 # directly.
2246 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2247 safe_CFLAGS=$CFLAGS
2248 CFLAGS="-Wl,--build-id=none -Werror"
2250 AC_LINK_IFELSE(
2251 [AC_LANG_PROGRAM([ ], [return 0;])],
2253   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2254   AC_MSG_RESULT([yes])
2255 ], [
2256   AC_SUBST([FLAG_NO_BUILD_ID], [""])
2257   AC_MSG_RESULT([no])
2259 else
2260 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2261 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2263 CFLAGS=$safe_CFLAGS
2265 # does the ppc assembler support "mtocrf" et al?
2266 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2268 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2269 __asm__ __volatile__("mtocrf 4,0");
2270 __asm__ __volatile__("mfocrf 0,4");
2271 ]])], [
2272 ac_have_as_ppc_mftocrf=yes
2273 AC_MSG_RESULT([yes])
2274 ], [
2275 ac_have_as_ppc_mftocrf=no
2276 AC_MSG_RESULT([no])
2278 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2279   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2283 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2284 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2286 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2287   do { typedef struct {
2288       double hi;
2289       double lo;
2290      } dbl_pair_t;
2291      dbl_pair_t dbl_pair[3];
2292      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2293    } while (0)
2294 ]])], [
2295 ac_have_as_ppc_fpPO=yes
2296 AC_MSG_RESULT([yes])
2297 ], [
2298 ac_have_as_ppc_fpPO=no
2299 AC_MSG_RESULT([no])
2301 if test x$ac_have_as_ppc_fpPO = xyes ; then
2302   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2306 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2307 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2309 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2310 void* p;
2311 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2312 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2313 ]])], [
2314 ac_have_as_amd64_fxsave64=yes
2315 AC_MSG_RESULT([yes])
2316 ], [
2317 ac_have_as_amd64_fxsave64=no
2318 AC_MSG_RESULT([no])
2320 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2321   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2324 # does the x86/amd64 assembler understand SSE3 instructions?
2325 # Note, this doesn't generate a C-level symbol.  It generates a
2326 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2327 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2329 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2330   do { long long int x; 
2331      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
2332   while (0)
2333 ]])], [
2334 ac_have_as_sse3=yes
2335 AC_MSG_RESULT([yes])
2336 ], [
2337 ac_have_as_sse3=no
2338 AC_MSG_RESULT([no])
2341 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2344 # Ditto for SSSE3 instructions (note extra S)
2345 # Note, this doesn't generate a C-level symbol.  It generates a
2346 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2347 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2349 save_CFLAGS="$CFLAGS"
2350 CFLAGS="$CFLAGS -msse -Werror"
2351 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2352   do { long long int x; 
2353    __asm__ __volatile__(
2354       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2355   while (0)
2356 ]])], [
2357 ac_have_as_ssse3=yes
2358 AC_MSG_RESULT([yes])
2359 ], [
2360 ac_have_as_ssse3=no
2361 AC_MSG_RESULT([no])
2363 CFLAGS="$save_CFLAGS"
2365 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2368 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2369 # Note, this doesn't generate a C-level symbol.  It generates a
2370 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2371 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2372 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2373   do {
2374    __asm__ __volatile__(
2375       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2376   while (0)
2377 ]])], [
2378 ac_have_as_pclmulqdq=yes
2379 AC_MSG_RESULT([yes])
2380 ], [
2381 ac_have_as_pclmulqdq=no
2382 AC_MSG_RESULT([no])
2385 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2388 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2389 # Note, this doesn't generate a C-level symbol.  It generates a
2390 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2391 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2392 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2393   do {
2394       /*
2395        * Carry-less multiplication of xmm1 with xmm2 and store the result in
2396        * xmm3. The immediate is used to determine which quadwords of xmm1 and
2397        * xmm2 should be used.
2398        */
2399    __asm__ __volatile__(
2400       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2401   } while (0)
2402 ]])], [
2403 ac_have_as_vpclmulqdq=yes
2404 AC_MSG_RESULT([yes])
2405 ], [
2406 ac_have_as_vpclmulqdq=no
2407 AC_MSG_RESULT([no])
2410 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2413 # does the x86/amd64 assembler understand FMA4 instructions?
2414 # Note, this doesn't generate a C-level symbol.  It generates a
2415 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
2416 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
2417 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2418   do {
2419    __asm__ __volatile__(
2420       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
2421   } while (0)
2422 ]])], [
2423 ac_have_as_vfmaddpd=yes
2424 AC_MSG_RESULT([yes])
2425 ], [
2426 ac_have_as_vfmaddpd=no
2427 AC_MSG_RESULT([no])
2430 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
2433 # does the x86/amd64 assembler understand the LZCNT instruction?
2434 # Note, this doesn't generate a C-level symbol.  It generates a
2435 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2436 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2438 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2439   do {           
2440       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2441   } while (0)
2442 ]])], [
2443   ac_have_as_lzcnt=yes
2444   AC_MSG_RESULT([yes])
2445 ], [
2446   ac_have_as_lzcnt=no
2447   AC_MSG_RESULT([no])
2450 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2453 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2454 # Note, this doesn't generate a C-level symbol.  It generates a
2455 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2456 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2458 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2459   do {           
2460       __asm__ __volatile__("1:  loopnel 1b\n");
2461   } while (0)
2462 ]])], [
2463   ac_have_as_loopnel=yes
2464   AC_MSG_RESULT([yes])
2465 ], [
2466   ac_have_as_loopnel=no
2467   AC_MSG_RESULT([no])
2470 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2473 # does the x86/amd64 assembler understand ADDR32 ?
2474 # Note, this doesn't generate a C-level symbol.  It generates a
2475 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2476 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2478 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2479   do {           
2480       asm volatile ("addr32 rep movsb");
2481   } while (0)
2482 ]])], [
2483   ac_have_as_addr32=yes
2484   AC_MSG_RESULT([yes])
2485 ], [
2486   ac_have_as_addr32=no
2487   AC_MSG_RESULT([no])
2490 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2493 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2494 # Note, this doesn't generate a C-level symbol.  It generates a
2495 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2496 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2498 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2499   do { long long int x; 
2500    __asm__ __volatile__(
2501       "crc32q %%r15,%%r15" : : : "r15" );
2502    __asm__ __volatile__(
2503       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
2504    __asm__ __volatile__(
2505       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2506   while (0)
2507 ]])], [
2508 ac_have_as_sse42=yes
2509 AC_MSG_RESULT([yes])
2510 ], [
2511 ac_have_as_sse42=no
2512 AC_MSG_RESULT([no])
2515 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2518 # does the x86/amd64 assembler understand AVX instructions?
2519 # Note, this doesn't generate a C-level symbol.  It generates a
2520 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2521 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2523 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2524   do { long long int x; 
2525    __asm__ __volatile__(
2526       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2527    __asm__ __volatile__(
2528       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2529   while (0)
2530 ]])], [
2531 ac_have_as_avx=yes
2532 AC_MSG_RESULT([yes])
2533 ], [
2534 ac_have_as_avx=no
2535 AC_MSG_RESULT([no])
2538 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2541 # does the x86/amd64 assembler understand AVX2 instructions?
2542 # Note, this doesn't generate a C-level symbol.  It generates a
2543 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2544 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2546 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2547   do { long long int x; 
2548    __asm__ __volatile__(
2549       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2550    __asm__ __volatile__(
2551       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2552   while (0)
2553 ]])], [
2554 ac_have_as_avx2=yes
2555 AC_MSG_RESULT([yes])
2556 ], [
2557 ac_have_as_avx2=no
2558 AC_MSG_RESULT([no])
2561 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2564 # does the x86/amd64 assembler understand TSX instructions and
2565 # the XACQUIRE/XRELEASE prefixes?
2566 # Note, this doesn't generate a C-level symbol.  It generates a
2567 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2568 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2570 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2571   do {
2572    __asm__ __volatile__(
2573       "       xbegin Lfoo  \n\t"
2574       "Lfoo:  xend         \n\t"
2575       "       xacquire lock incq 0(%rsp)     \n\t"
2576       "       xrelease lock incq 0(%rsp)     \n"
2577    );
2578   } while (0)
2579 ]])], [
2580 ac_have_as_tsx=yes
2581 AC_MSG_RESULT([yes])
2582 ], [
2583 ac_have_as_tsx=no
2584 AC_MSG_RESULT([no])
2587 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2590 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2591 # Note, this doesn't generate a C-level symbol.  It generates a
2592 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2593 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2595 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2596   do { unsigned int h, l;
2597    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2598    __asm__ __volatile__(
2599       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2600    __asm__ __volatile__(
2601       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2602   while (0)
2603 ]])], [
2604 ac_have_as_bmi=yes
2605 AC_MSG_RESULT([yes])
2606 ], [
2607 ac_have_as_bmi=no
2608 AC_MSG_RESULT([no])
2611 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2614 # does the x86/amd64 assembler understand FMA instructions?
2615 # Note, this doesn't generate a C-level symbol.  It generates a
2616 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2617 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2619 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2620   do { unsigned int h, l;
2621    __asm__ __volatile__(
2622       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2623    __asm__ __volatile__(
2624       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2625    __asm__ __volatile__(
2626       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2627   while (0)
2628 ]])], [
2629 ac_have_as_fma=yes
2630 AC_MSG_RESULT([yes])
2631 ], [
2632 ac_have_as_fma=no
2633 AC_MSG_RESULT([no])
2636 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2639 # does the amd64 assembler understand MPX instructions?
2640 # Note, this doesn't generate a C-level symbol.  It generates a
2641 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2642 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2644 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2645   do {
2646     asm ("bndmov %bnd0,(%rsp)");
2647     asm ("bndldx 3(%rbx,%rdx), %bnd2");
2648     asm ("bnd call foo\n"
2649           bnd jmp  end\n"
2650           foo: bnd ret\n"
2651           end: nop");
2652   } while (0)
2653 ]])], [
2654 ac_have_as_mpx=yes
2655 AC_MSG_RESULT([yes])
2656 ], [
2657 ac_have_as_mpx=no
2658 AC_MSG_RESULT([no])
2661 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2664 # does the amd64 assembler understand ADX instructions?
2665 # Note, this doesn't generate a C-level symbol.  It generates a
2666 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
2667 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
2669 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2670   do {
2671     asm ("adcxq %r14,%r8");
2672   } while (0)
2673 ]])], [
2674 ac_have_as_adx=yes
2675 AC_MSG_RESULT([yes])
2676 ], [
2677 ac_have_as_adx=no
2678 AC_MSG_RESULT([no])
2681 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
2684 # Does the C compiler support the "ifunc" attribute
2685 # Note, this doesn't generate a C-level symbol.  It generates a
2686 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2687 # does the x86/amd64 assembler understand MOVBE?
2688 # Note, this doesn't generate a C-level symbol.  It generates a
2689 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2690 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2692 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2693   do { long long int x; 
2694    __asm__ __volatile__(
2695       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
2696   while (0)
2697 ]])], [
2698 ac_have_as_movbe=yes
2699 AC_MSG_RESULT([yes])
2700 ], [
2701 ac_have_as_movbe=no
2702 AC_MSG_RESULT([no])
2705 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2708 # Does the C compiler support the "ifunc" attribute
2709 # Note, this doesn't generate a C-level symbol.  It generates a
2710 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2711 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2713 AC_LINK_IFELSE([AC_LANG_SOURCE([[
2714 static void mytest(void) {}
2716 static void (*resolve_test(void))(void)
2718     return (void (*)(void))&mytest;
2721 void test(void) __attribute__((ifunc("resolve_test")));
2723 int main()
2725     test();
2726     return 0;
2728 ]])], [
2729 ac_have_ifunc_attr=yes
2730 AC_MSG_RESULT([yes])
2731 ], [
2732 ac_have_ifunc_attr=no
2733 AC_MSG_RESULT([no])
2736 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2738 # Does the C compiler support the armv8 crc feature flag
2739 # Note, this doesn't generate a C-level symbol.  It generates a
2740 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
2741 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
2743 save_CFLAGS="$CFLAGS"
2744 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
2745 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2746 int main()
2748     return 0;
2750 ]])], [
2751 ac_have_armv8_crc_feature=yes
2752 AC_MSG_RESULT([yes])
2753 ], [
2754 ac_have_armv8_crc_feature=no
2755 AC_MSG_RESULT([no])
2757 CFLAGS="$save_CFLAGS"
2759 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
2762 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
2763 # when building the tool executables.  I think we should get rid of it.
2765 # Check for TLS support in the compiler and linker
2766 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2767                                 [[return foo;]])],
2768                                [vg_cv_linktime_tls=yes],
2769                                [vg_cv_linktime_tls=no])
2770 # Native compilation: check whether running a program using TLS succeeds.
2771 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2772 # succeeds but running programs using TLS fails.
2773 # Cross-compiling: check whether linking a program using TLS succeeds.
2774 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2775                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
2776                 [vg_cv_tls=$enableval],
2777                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2778                                                 [[return foo;]])],
2779                                [vg_cv_tls=yes],
2780                                [vg_cv_tls=no],
2781                                [vg_cv_tls=$vg_cv_linktime_tls])])])
2783 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
2784 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2788 #----------------------------------------------------------------------------
2789 # Solaris-specific checks.
2790 #----------------------------------------------------------------------------
2792 if test "$VGCONF_OS" = "solaris" ; then
2793 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
2795 # Solaris-specific check determining if the Sun Studio Assembler is used to
2796 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
2797 # cmovl.l instruction, if yes then it's Sun Assembler.
2799 # C-level symbol: none
2800 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
2802 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
2803 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2804 ]], [[
2805   __asm__ __volatile__("cmovl.l %edx, %eax");
2806 ]])], [
2807 solaris_have_sun_studio_as=yes
2808 AC_MSG_RESULT([yes])
2809 ], [
2810 solaris_have_sun_studio_as=no
2811 AC_MSG_RESULT([no])
2813 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
2815 # Solaris-specific check determining if symbols __xpg4 and __xpg6
2816 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
2817 # See solaris/vgpreload-solaris.mapfile for details.
2818 # gcc on older Solaris instructs linker to include these symbols,
2819 # gcc on illumos and newer Solaris does not.
2821 # C-level symbol: none
2822 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
2824 save_CFLAGS="$CFLAGS"
2825 CFLAGS="$CFLAGS -std=gnu99"
2826 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
2827 temp_dir=$( /usr/bin/mktemp -d )
2828 cat <<_ACEOF >${temp_dir}/mylib.c
2829 #include <stdio.h>
2830 int myfunc(void) { printf("LaPutyka\n"); }
2831 _ACEOF
2832 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
2833 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
2834 if test "x${xpg_present}" = "x" ; then
2835     solaris_xpg_symbols_present=no
2836     AC_MSG_RESULT([no])
2837 else
2838     solaris_xpg_symbols_present=yes
2839     AC_MSG_RESULT([yes])
2841 rm -rf ${temp_dir}
2842 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
2843 CFLAGS="$save_CFLAGS"
2846 # Solaris-specific check determining if gcc enables largefile support by
2847 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
2848 # variable with gcc flags which disable it.
2850 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
2851 save_CFLAGS="$CFLAGS"
2852 CFLAGS="$CFLAGS -m32"
2853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2854   return _LARGEFILE_SOURCE;
2855 ]])], [
2856 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
2857 AC_MSG_RESULT([yes])
2858 ], [
2859 SOLARIS_UNDEF_LARGESOURCE=""
2860 AC_MSG_RESULT([no])
2862 CFLAGS=$safe_CFLAGS
2863 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
2866 # Solaris-specific check determining if /proc/self/cmdline
2867 # or /proc/<pid>/cmdline is supported.
2869 # C-level symbol: SOLARIS_PROC_CMDLINE
2870 # Automake-level symbol: SOLARIS_PROC_CMDLINE
2872 AC_CHECK_FILE([/proc/self/cmdline],
2874 solaris_proc_cmdline=yes
2875 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
2876           [Define to 1 if you have /proc/self/cmdline.])
2877 ], [
2878 solaris_proc_cmdline=no
2880 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
2883 # Solaris-specific check determining default platform for the Valgrind launcher.
2884 # Used in case the launcher cannot select platform by looking at the client
2885 # image (for example because the executable is a shell script).
2887 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
2888 # Automake-level symbol: none
2890 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
2891 # Get the ELF class of /bin/sh first.
2892 if ! test -f /bin/sh; then
2893   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
2895 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
2896 case "$elf_class" in
2897   64)
2898     default_arch="$VGCONF_ARCH_PRI";
2899     ;;
2900   32)
2901     if test "x$VGCONF_ARCH_SEC" != "x"; then
2902       default_arch="$VGCONF_ARCH_SEC"
2903     else
2904       default_arch="$VGCONF_ARCH_PRI";
2905     fi
2906     ;;
2907   *)
2908     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
2909     ;;
2910 esac
2911 default_platform="$default_arch-$VGCONF_OS"
2912 AC_MSG_RESULT([$default_platform])
2913 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
2914                    [Default platform for Valgrind launcher.])
2917 # Solaris-specific check determining if the old syscalls are available.
2919 # C-level symbol: SOLARIS_OLD_SYSCALLS
2920 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
2922 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
2923 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2924 #include <sys/syscall.h>
2925 ]], [[
2926   return !SYS_open;
2927 ]])], [
2928 solaris_old_syscalls=yes
2929 AC_MSG_RESULT([yes])
2930 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
2931           [Define to 1 if you have the old Solaris syscalls.])
2932 ], [
2933 solaris_old_syscalls=no
2934 AC_MSG_RESULT([no])
2936 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
2939 # Solaris-specific check determining if the new accept() syscall is available.
2941 # Old syscall:
2942 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
2943 #            int version);
2945 # New syscall (available on illumos):
2946 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
2947 #            int version, int flags);
2949 # If the old syscall is present then the following syscall will fail with
2950 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
2951 # available then it will fail with EINVAL (because the flags parameter is
2952 # invalid).
2954 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
2955 # Automake-level symbol: none
2957 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
2958 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
2959 #include <sys/syscall.h>
2960 #include <errno.h>
2961 ]], [[
2962   errno = 0;
2963   syscall(SYS_accept, 0, 0, 0, 0, -1);
2964   return !(errno == EINVAL);
2965 ]])], [
2966 AC_MSG_RESULT([yes])
2967 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
2968           [Define to 1 if you have the new `accept' syscall.])
2969 ], [
2970 AC_MSG_RESULT([no])
2974 # Solaris-specific check determining if the new illumos pipe() syscall is
2975 # available.
2977 # Old syscall:
2978 # longlong_t pipe();
2980 # New syscall (available on illumos):
2981 # int pipe(intptr_t arg, int flags);
2983 # If the old syscall is present then the following call will succeed, if the
2984 # new syscall is available then it will fail with EFAULT (because address 0
2985 # cannot be accessed).
2987 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
2988 # Automake-level symbol: none
2990 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
2991 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
2992 #include <sys/syscall.h>
2993 #include <errno.h>
2994 ]], [[
2995   errno = 0;
2996   syscall(SYS_pipe, 0, 0);
2997   return !(errno == EFAULT);
2998 ]])], [
2999 AC_MSG_RESULT([yes])
3000 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3001           [Define to 1 if you have the new `pipe' syscall.])
3002 ], [
3003 AC_MSG_RESULT([no])
3007 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3008 # available.
3010 # Old syscall:
3011 # int lwp_kill(id_t lwpid, int sig);
3013 # New syscall (available on Solaris 11):
3014 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3015 #                  int si_code, timespec_t *timeout);
3017 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3018 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3020 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3021 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3022 #include <sys/syscall.h> 
3023 ]], [[
3024   return !SYS_lwp_sigqueue;
3025 ]])], [
3026 solaris_lwp_sigqueue_syscall=yes
3027 AC_MSG_RESULT([yes])
3028 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3029           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3030 ], [
3031 solaris_lwp_sigqueue_syscall=no
3032 AC_MSG_RESULT([no])
3034 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3037 # Solaris-specific check determining if the lwp_sigqueue() syscall
3038 # takes both pid and thread id arguments or just thread id.
3040 # Old syscall (available on Solaris 11.x):
3041 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3042 #                  int si_code, timespec_t *timeout);
3044 # New syscall (available on Solaris 12):
3045 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3046 #                  int si_code, timespec_t *timeout);
3048 # If the old syscall is present then the following syscall will fail with
3049 # EINVAL (because signal is out of range); if the new syscall is available
3050 # then it will fail with ESRCH (because it would not find such thread in the
3051 # current process).
3053 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3054 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3056 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3057 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3058 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3059 #include <sys/syscall.h>
3060 #include <errno.h>
3061 ]], [[
3062   errno = 0;
3063   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3064   return !(errno == ESRCH);
3065 ]])], [
3066 solaris_lwp_sigqueue_syscall_takes_pid=yes
3067 AC_MSG_RESULT([yes])
3068 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3069           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3070 ], [
3071 solaris_lwp_sigqueue_syscall_takes_pid=no
3072 AC_MSG_RESULT([no])
3074 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3075                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3077 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3081 # Solaris-specific check determining if the new lwp_name() syscall is
3082 # available.
3084 # New syscall (available on Solaris 11):
3085 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3087 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3088 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3090 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3091 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3092 #include <sys/syscall.h>
3093 ]], [[
3094   return !SYS_lwp_name;
3095 ]])], [
3096 solaris_lwp_name_syscall=yes
3097 AC_MSG_RESULT([yes])
3098 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3099           [Define to 1 if you have the new `lwp_name' syscall.])
3100 ], [
3101 solaris_lwp_name_syscall=no
3102 AC_MSG_RESULT([no])
3104 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3107 # Solaris-specific check determining if the new getrandom() syscall is
3108 # available.
3110 # New syscall (available on Solaris 11):
3111 # int getrandom(void *buf, size_t buflen, uint_t flags);
3113 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3114 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3116 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3117 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3118 #include <sys/syscall.h>
3119 ]], [[
3120   return !SYS_getrandom;
3121 ]])], [
3122 solaris_getrandom_syscall=yes
3123 AC_MSG_RESULT([yes])
3124 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3125           [Define to 1 if you have the new `getrandom' syscall.])
3126 ], [
3127 solaris_getrandom_syscall=no
3128 AC_MSG_RESULT([no])
3130 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3133 # Solaris-specific check determining if the new zone() syscall subcodes
3134 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
3135 # were added in Solaris 11 but are missing on illumos.
3137 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3138 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3140 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3141 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3142 #include <sys/zone.h>
3143 ]], [[
3144   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3145 ]])], [
3146 solaris_zone_defunct=yes
3147 AC_MSG_RESULT([yes])
3148 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3149           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3150 ], [
3151 solaris_zone_defunct=no
3152 AC_MSG_RESULT([no])
3154 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3157 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3158 # for auditon(2) subcode of the auditsys() syscall are available.
3159 # These commands are available in Solaris 11 and illumos but were removed
3160 # in Solaris 12.
3162 # C-level symbol: SOLARIS_AUDITON_STAT
3163 # Automake-level symbol: SOLARIS_AUDITON_STAT
3165 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3167 #include <bsm/audit.h>
3168 ]], [[
3169   return !(A_GETSTAT && A_SETSTAT);
3170 ]])], [
3171 solaris_auditon_stat=yes
3172 AC_MSG_RESULT([yes])
3173 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3174           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3175 ], [
3176 solaris_auditon_stat=no
3177 AC_MSG_RESULT([no])
3179 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3182 # Solaris-specific check determining if the new shmsys() syscall subcodes
3183 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3184 # These subcodes were added in Solaris 11 but are missing on illumos.
3186 # C-level symbol: SOLARIS_SHM_NEW
3187 # Automake-level symbol: SOLARIS_SHM_NEW
3189 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3191 #include <sys/ipc_impl.h>
3192 #include <sys/shm.h>
3193 #include <sys/shm_impl.h>
3194 ]], [[
3195   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3196 ]])], [
3197 solaris_shm_new=yes
3198 AC_MSG_RESULT([yes])
3199 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3200           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3201 ], [
3202 solaris_shm_new=no
3203 AC_MSG_RESULT([no])
3205 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3208 # Solaris-specific check determining if prxregset_t is available.  Illumos
3209 # currently does not define it on the x86 platform.
3211 # C-level symbol: SOLARIS_PRXREGSET_T
3212 # Automake-level symbol: SOLARIS_PRXREGSET_T
3214 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3215 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3216 #include <sys/procfs_isa.h>
3217 ]], [[
3218   return !sizeof(prxregset_t);
3219 ]])], [
3220 solaris_prxregset_t=yes
3221 AC_MSG_RESULT([yes])
3222 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3223           [Define to 1 if you have the `prxregset_t' type.])
3224 ], [
3225 solaris_prxregset_t=no
3226 AC_MSG_RESULT([no])
3228 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3231 # Solaris-specific check determining if the new frealpathat() syscall is
3232 # available.
3234 # New syscall (available on Solaris 11.1):
3235 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
3237 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3238 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3240 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3241 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3242 #include <sys/syscall.h>
3243 ]], [[
3244   return !SYS_frealpathat;
3245 ]])], [
3246 solaris_frealpathat_syscall=yes
3247 AC_MSG_RESULT([yes])
3248 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3249           [Define to 1 if you have the new `frealpathat' syscall.])
3250 ], [
3251 solaris_frealpathat_syscall=no
3252 AC_MSG_RESULT([no])
3254 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3257 # Solaris-specific check determining if the new uuidsys() syscall is
3258 # available.
3260 # New syscall (available on newer Solaris):
3261 # int uuidsys(struct uuid *uuid);
3263 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3264 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3266 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3267 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3268 #include <sys/syscall.h>
3269 ]], [[
3270   return !SYS_uuidsys;
3271 ]])], [
3272 solaris_uuidsys_syscall=yes
3273 AC_MSG_RESULT([yes])
3274 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
3275           [Define to 1 if you have the new `uuidsys' syscall.])
3276 ], [
3277 solaris_uuidsys_syscall=no
3278 AC_MSG_RESULT([no])
3280 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
3283 # Solaris-specific check determining if the new labelsys() syscall subcode
3284 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
3285 # missing on illumos.
3287 # C-level symbol: SOLARIS_TNDB_GET_TNIP
3288 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
3290 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
3291 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3292 #include <sys/tsol/tndb.h>
3293 ]], [[
3294   return !TNDB_GET_TNIP;
3295 ]])], [
3296 solaris_tndb_get_tnip=yes
3297 AC_MSG_RESULT([yes])
3298 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
3299           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
3300 ], [
3301 solaris_tndb_get_tnip=no
3302 AC_MSG_RESULT([no])
3304 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
3307 # Solaris-specific check determining if the new labelsys() syscall opcodes
3308 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
3309 # added in Solaris 11 but are missing on illumos.
3311 # C-level symbol: SOLARIS_TSOL_CLEARANCE
3312 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
3314 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
3315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3316 #include <sys/tsol/tsyscall.h>
3317 ]], [[
3318   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
3319 ]])], [
3320 solaris_tsol_clearance=yes
3321 AC_MSG_RESULT([yes])
3322 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
3323           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
3324 ], [
3325 solaris_tsol_clearance=no
3326 AC_MSG_RESULT([no])
3328 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
3331 # Solaris-specific check determining if the new pset() syscall subcode
3332 # PSET_GET_NAME is available. This subcode was added in Solaris 12 but
3333 # is missing on illumos and Solaris 11.
3335 # C-level symbol: SOLARIS_PSET_GET_NAME
3336 # Automake-level symbol: SOLARIS_PSET_GET_NAME
3338 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
3339 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3340 #include <sys/pset.h>
3341 ]], [[
3342   return !(PSET_GET_NAME);
3343 ]])], [
3344 solaris_pset_get_name=yes
3345 AC_MSG_RESULT([yes])
3346 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
3347           [Define to 1 if you have the `PSET_GET_NAME' constants.])
3348 ], [
3349 solaris_pset_get_name=no
3350 AC_MSG_RESULT([no])
3352 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
3355 # Solaris-specific check determining if the utimesys() syscall is
3356 # available (on illumos and older Solaris).
3358 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
3359 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
3361 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
3362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3363 #include <sys/syscall.h>
3364 ]], [[
3365   return !SYS_utimesys;
3366 ]])], [
3367 solaris_utimesys_syscall=yes
3368 AC_MSG_RESULT([yes])
3369 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
3370           [Define to 1 if you have the `utimesys' syscall.])
3371 ], [
3372 solaris_utimesys_syscall=no
3373 AC_MSG_RESULT([no])
3375 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
3378 # Solaris-specific check determining if the utimensat() syscall is
3379 # available (on newer Solaris).
3381 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3382 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3384 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
3385 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3386 #include <sys/syscall.h>
3387 ]], [[
3388   return !SYS_utimensat;
3389 ]])], [
3390 solaris_utimensat_syscall=yes
3391 AC_MSG_RESULT([yes])
3392 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
3393           [Define to 1 if you have the `utimensat' syscall.])
3394 ], [
3395 solaris_utimensat_syscall=no
3396 AC_MSG_RESULT([no])
3398 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
3401 # Solaris-specific check determining if the spawn() syscall is available
3402 # (on newer Solaris).
3404 # C-level symbol: SOLARIS_SPAWN_SYSCALL
3405 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
3407 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
3408 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3409 #include <sys/syscall.h>
3410 ]], [[
3411   return !SYS_spawn;
3412 ]])], [
3413 solaris_spawn_syscall=yes
3414 AC_MSG_RESULT([yes])
3415 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
3416           [Define to 1 if you have the `spawn' syscall.])
3417 ], [
3418 solaris_spawn_syscall=no
3419 AC_MSG_RESULT([no])
3421 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
3424 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
3425 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
3427 # C-level symbol: SOLARIS_MODCTL_MODNVL
3428 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
3430 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
3431 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3432 #include <sys/modctl.h>
3433 ]], [[
3434   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
3435 ]])], [
3436 solaris_modctl_modnvl=yes
3437 AC_MSG_RESULT([yes])
3438 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
3439           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
3440 ], [
3441 solaris_modctl_modnvl=no
3442 AC_MSG_RESULT([no])
3444 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
3447 # Solaris-specific check determining whether nscd (name switch cache daemon)
3448 # attaches its door at /system/volatile/name_service_door (Solaris)
3449 # or at /var/run/name_service_door (illumos).
3451 # Note that /var/run is a symlink to /system/volatile on Solaris
3452 # but not vice versa on illumos.
3454 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3455 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3457 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
3458 if test -e /system/volatile/name_service_door; then
3459     solaris_nscd_door_system_volatile=yes
3460     AC_MSG_RESULT([/system/volatile/name_service_door])
3461     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
3462               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
3463 else
3464     solaris_nscd_door_system_volatile=no
3465     AC_MSG_RESULT([/var/run/name_service_door])
3467 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
3470 # Solaris-specific check determining if the new gethrt() fasttrap is available.
3472 # New fasttrap (available on Solaris 11):
3473 # hrt_t *gethrt(void);
3475 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
3476 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
3478 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
3479 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3480 #include <sys/trap.h>
3481 ]], [[
3482   return !T_GETHRT;
3483 ]])], [
3484 solaris_gethrt_fasttrap=yes
3485 AC_MSG_RESULT([yes])
3486 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
3487           [Define to 1 if you have the new `gethrt' fasttrap.])
3488 ], [
3489 solaris_gethrt_fasttrap=no
3490 AC_MSG_RESULT([no])
3492 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
3495 # Solaris-specific check determining if the new get_zone_offset() fasttrap
3496 # is available.
3498 # New fasttrap (available on Solaris 11):
3499 # zonehrtoffset_t *get_zone_offset(void);
3501 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3502 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3504 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
3505 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3506 #include <sys/trap.h>
3507 ]], [[
3508   return !T_GETZONEOFFSET;
3509 ]])], [
3510 solaris_getzoneoffset_fasttrap=yes
3511 AC_MSG_RESULT([yes])
3512 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
3513           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
3514 ], [
3515 solaris_getzoneoffset_fasttrap=no
3516 AC_MSG_RESULT([no])
3518 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
3521 # Solaris-specific check determining if the execve() syscall
3522 # takes fourth argument (flags) or not.
3524 # Old syscall (available on illumos):
3525 # int execve(const char *fname, const char **argv, const char **envp);
3527 # New syscall (available on Solaris):
3528 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
3530 # If the new syscall is present then it will fail with EINVAL (because flags
3531 # are invalid); if the old syscall is available then it will fail with ENOENT
3532 # (because the file could not be found).
3534 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3535 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3537 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
3538 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3539 #include <sys/syscall.h>
3540 #include <errno.h>
3541 ]], [[
3542   errno = 0;
3543   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
3544   return !(errno == EINVAL);
3545 ]])], [
3546 solaris_execve_syscall_takes_flags=yes
3547 AC_MSG_RESULT([yes])
3548 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
3549           [Define to 1 if you have the new `execve' syscall which accepts flags.])
3550 ], [
3551 solaris_execve_syscall_takes_flags=no
3552 AC_MSG_RESULT([no])
3554 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
3555                test x$solaris_execve_syscall_takes_flags = xyes)
3558 # Solaris-specific check determining version of the repository cache protocol.
3559 # Every Solaris version uses a different one, ranging from 21 to current 25.
3560 # The check is very ugly, though.
3562 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
3563 # Automake-level symbol: none
3565 AC_PATH_PROG(DIS_PATH, dis, false)
3566 if test "x$DIS_PATH" = "xfalse"; then
3567   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
3569 AC_CHECK_LIB(scf, scf_handle_bind, [], [
3570   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
3571   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3574 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
3575 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
3576   libscf=/usr/lib/64/libscf.so.1
3577 else
3578   libscf=/usr/lib/libscf.so.1
3580 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
3581   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
3582   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3584 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
3585 if test -z "$hex"; then
3586   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
3587   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3589 version=$( printf "%d\n" 0x$hex )
3590 AC_MSG_RESULT([$version])
3591 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
3592                    [Version number of the repository door cache protocol.])
3595 # Solaris-specific check determining if "sysstat" segment reservation type
3596 # is available.
3598 # New "sysstat" segment reservation (available on Solaris 12):
3599 # - program header type:    PT_SUNW_SYSSTAT
3600 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
3602 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
3603 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
3605 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
3606 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3607 #include <sys/auxv.h>
3608 ]], [[
3609   return !AT_SUN_SYSSTAT_ADDR;
3610 ]])], [
3611 solaris_reserve_sysstat_addr=yes
3612 AC_MSG_RESULT([yes])
3613 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
3614           [Define to 1 if you have the new `sysstat' segment reservation.])
3615 ], [
3616 solaris_reserve_sysstat_addr=no
3617 AC_MSG_RESULT([no])
3619 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
3622 # Solaris-specific check determining if "sysstat_zone" segment reservation type
3623 # is available.
3625 # New "sysstat_zone" segment reservation (available on Solaris 12):
3626 # - program header type:    PT_SUNW_SYSSTAT_ZONE
3627 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
3629 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
3630 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
3632 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
3633 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3634 #include <sys/auxv.h>
3635 ]], [[
3636   return !AT_SUN_SYSSTAT_ZONE_ADDR;
3637 ]])], [
3638 solaris_reserve_sysstat_zone_addr=yes
3639 AC_MSG_RESULT([yes])
3640 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
3641           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
3642 ], [
3643 solaris_reserve_sysstat_zone_addr=no
3644 AC_MSG_RESULT([no])
3646 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
3649 # Solaris-specific check determining if the system_stats() syscall is available
3650 # (on newer Solaris).
3652 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
3653 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
3655 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
3656 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3657 #include <sys/syscall.h>
3658 ]], [[
3659   return !SYS_system_stats;
3660 ]])], [
3661 solaris_system_stats_syscall=yes
3662 AC_MSG_RESULT([yes])
3663 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
3664           [Define to 1 if you have the `system_stats' syscall.])
3665 ], [
3666 solaris_system_stats_syscall=no
3667 AC_MSG_RESULT([no])
3669 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
3672 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
3673 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
3675 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
3676 # Automake-level symbol: none
3678 AC_CHECK_TYPE([struct _fpchip_state],
3679               [solaris_fpchip_state_takes_underscore=yes],
3680               [solaris_fpchip_state_takes_underscore=no],
3681               [[#include <sys/regset.h>]])
3682 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
3683   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
3684             [Define to 1 if fpregset_t defines struct _fpchip_state])
3688 # Solaris-specific check determining if schedctl page shared between kernel
3689 # and userspace program is executable (illumos, older Solaris) or not (newer
3690 # Solaris).
3692 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
3693 # Automake-level symbol: none
3695 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
3696 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3697 #include <assert.h>
3698 #include <fcntl.h>
3699 #include <procfs.h>
3700 #include <schedctl.h>
3701 #include <stdio.h>
3702 #include <unistd.h>
3703 ]], [[
3704     schedctl_t *scp = schedctl_init();
3705     if (scp == NULL)
3706         return 1;
3708     int fd = open("/proc/self/map", O_RDONLY);
3709     assert(fd >= 0);
3711     prmap_t map;
3712     ssize_t rd;
3713     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
3714         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
3715             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
3716                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
3717             return (map.pr_mflags & MA_EXEC);
3718         }
3719     }
3721     return 1;
3722 ]])], [
3723 solaris_schedctl_page_exec=no
3724 AC_MSG_RESULT([no])
3725 ], [
3726 solaris_schedctl_page_exec=yes
3727 AC_MSG_RESULT([yes])
3728 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
3729           [Define to 1 if you have the schedctl page executable.])
3733 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
3734 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
3735 # an initial thread pointer for libc (newer Solaris).
3737 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
3738 # Automake-level symbol: none
3740 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
3741 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3742 #include <sys/fasttrap_isa.h>
3743 ]], [[
3744     return !FT_SCRATCHSIZE;
3745 ]])], [
3746 solaris_pt_sunwdtrace_thrp=yes
3747 AC_MSG_RESULT([yes])
3748 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
3749           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
3750 ], [
3751 solaris_pt_sunwdtrace_thrp=no
3752 AC_MSG_RESULT([no])
3755 else
3756 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
3757 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
3758 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
3759 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
3760 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
3761 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
3762 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
3763 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
3764 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
3765 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
3766 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
3767 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
3768 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
3769 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
3770 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
3771 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
3772 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
3773 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
3774 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
3775 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
3776 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
3777 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
3778 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
3779 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
3780 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
3781 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
3782 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
3783 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
3784 fi # test "$VGCONF_OS" = "solaris"
3787 #----------------------------------------------------------------------------
3788 # Checks for C header files.
3789 #----------------------------------------------------------------------------
3791 AC_HEADER_STDC
3792 AC_CHECK_HEADERS([       \
3793         asm/unistd.h     \
3794         endian.h         \
3795         mqueue.h         \
3796         sys/endian.h     \
3797         sys/epoll.h      \
3798         sys/eventfd.h    \
3799         sys/klog.h       \
3800         sys/poll.h       \
3801         sys/prctl.h      \
3802         sys/signal.h     \
3803         sys/signalfd.h   \
3804         sys/syscall.h    \
3805         sys/sysnvl.h     \
3806         sys/time.h       \
3807         sys/types.h      \
3808         ])
3810 # Verify whether the <linux/futex.h> header is usable.
3811 AC_MSG_CHECKING([if <linux/futex.h> is usable])
3813 save_CFLAGS="$CFLAGS"
3814 CFLAGS="$CFLAGS -D__user="
3815 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3816 #include <linux/futex.h>
3817 ]], [[
3818   return FUTEX_WAIT;
3819 ]])], [
3820 ac_have_usable_linux_futex_h=yes
3821 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
3822           [Define to 1 if you have a usable <linux/futex.h> header file.])
3823 AC_MSG_RESULT([yes])
3824 ], [
3825 ac_have_usable_linux_futex_h=no
3826 AC_MSG_RESULT([no])
3828 CFLAGS="$save_CFLAGS"
3831 #----------------------------------------------------------------------------
3832 # Checks for typedefs, structures, and compiler characteristics.
3833 #----------------------------------------------------------------------------
3834 AC_TYPE_UID_T
3835 AC_TYPE_OFF_T
3836 AC_TYPE_SIZE_T
3837 AC_HEADER_TIME
3840 #----------------------------------------------------------------------------
3841 # Checks for library functions.
3842 #----------------------------------------------------------------------------
3843 AC_FUNC_MEMCMP
3844 AC_FUNC_MMAP
3846 AC_CHECK_LIB([pthread], [pthread_create])
3847 AC_CHECK_LIB([rt], [clock_gettime])
3849 AC_CHECK_FUNCS([     \
3850         clock_gettime\
3851         epoll_create \
3852         epoll_pwait  \
3853         klogctl      \
3854         mallinfo     \
3855         memchr       \
3856         memset       \
3857         mkdir        \
3858         mremap       \
3859         ppoll        \
3860         pthread_barrier_init       \
3861         pthread_condattr_setclock  \
3862         pthread_mutex_timedlock    \
3863         pthread_rwlock_timedrdlock \
3864         pthread_rwlock_timedwrlock \
3865         pthread_spin_lock          \
3866         pthread_yield              \
3867         pthread_setname_np         \
3868         readlinkat   \
3869         semtimedop   \
3870         signalfd     \
3871         sigwaitinfo  \
3872         strchr       \
3873         strdup       \
3874         strpbrk      \
3875         strrchr      \
3876         strstr       \
3877         syscall      \
3878         utimensat    \
3879         process_vm_readv  \
3880         process_vm_writev \
3881         ])
3883 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
3884 # libraries with any shared object and/or executable. This is NOT what we
3885 # want for e.g. vgpreload_core-x86-linux.so
3886 LIBS=""
3888 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
3889                [test x$ac_cv_func_pthread_barrier_init = xyes])
3890 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
3891                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
3892 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
3893                [test x$ac_cv_func_pthread_spin_lock = xyes])
3894 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
3895                [test x$ac_cv_func_pthread_setname_np = xyes])
3897 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
3898      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
3899   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
3900             [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
3903 #----------------------------------------------------------------------------
3904 # MPI checks
3905 #----------------------------------------------------------------------------
3906 # Do we have a useable MPI setup on the primary and/or secondary targets?
3907 # On Linux, by default, assumes mpicc and -m32/-m64
3908 # Note: this is a kludge in that it assumes the specified mpicc 
3909 # understands -m32/-m64 regardless of what is specified using
3910 # --with-mpicc=.
3911 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
3912              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
3914 mflag_primary=
3915 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
3916      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
3917      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
3918      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
3919      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
3920      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
3921   mflag_primary=$FLAG_M32
3922 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
3923        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
3924        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
3925        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
3926   mflag_primary=$FLAG_M64
3927 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
3928   mflag_primary="$FLAG_M32 -arch i386"
3929 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
3930   mflag_primary="$FLAG_M64 -arch x86_64"
3933 mflag_secondary=
3934 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
3935      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
3936      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS ; then
3937   mflag_secondary=$FLAG_M32
3938 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
3939   mflag_secondary="$FLAG_M32 -arch i386"
3943 AC_ARG_WITH(mpicc,
3944    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
3945    MPI_CC=$withval
3947 AC_SUBST(MPI_CC)
3949 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
3950 ## use these values in the check for a functioning mpicc.
3952 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
3953 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
3954 AM_COND_IF([VGCONF_OS_IS_LINUX],
3955            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
3956             LDFLAGS_MPI="-fpic -shared"])
3957 AM_COND_IF([VGCONF_OS_IS_DARWIN],
3958            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
3959             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
3960 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
3961            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
3962             LDFLAGS_MPI="-fpic -shared"])
3964 AC_SUBST([CFLAGS_MPI])
3965 AC_SUBST([LDFLAGS_MPI])
3968 ## See if MPI_CC works for the primary target
3970 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
3971 saved_CC=$CC
3972 saved_CFLAGS=$CFLAGS
3973 CC=$MPI_CC
3974 CFLAGS="$CFLAGS_MPI $mflag_primary"
3975 saved_LDFLAGS="$LDFLAGS"
3976 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
3977 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3978 #include <mpi.h>
3979 #include <stdio.h>
3980 ]], [[
3981   int ni, na, nd, comb;
3982   int r = MPI_Init(NULL,NULL);
3983   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
3984   r |= MPI_Finalize();
3985   return r; 
3986 ]])], [
3987 ac_have_mpi2_pri=yes
3988 AC_MSG_RESULT([yes, $MPI_CC])
3989 ], [
3990 ac_have_mpi2_pri=no
3991 AC_MSG_RESULT([no])
3993 CC=$saved_CC
3994 CFLAGS=$saved_CFLAGS
3995 LDFLAGS="$saved_LDFLAGS"
3996 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
3998 ## See if MPI_CC works for the secondary target.  Complication: what if
3999 ## there is no secondary target?  We need this to then fail.
4000 ## Kludge this by making MPI_CC something which will surely fail in
4001 ## such a case.
4003 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4004 saved_CC=$CC
4005 saved_CFLAGS=$CFLAGS
4006 saved_LDFLAGS="$LDFLAGS"
4007 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4008 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4009   CC="$MPI_CC this will surely fail"
4010 else
4011   CC=$MPI_CC
4013 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4014 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4015 #include <mpi.h>
4016 #include <stdio.h>
4017 ]], [[
4018   int ni, na, nd, comb;
4019   int r = MPI_Init(NULL,NULL);
4020   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4021   r |= MPI_Finalize();
4022   return r; 
4023 ]])], [
4024 ac_have_mpi2_sec=yes
4025 AC_MSG_RESULT([yes, $MPI_CC])
4026 ], [
4027 ac_have_mpi2_sec=no
4028 AC_MSG_RESULT([no])
4030 CC=$saved_CC
4031 CFLAGS=$saved_CFLAGS
4032 LDFLAGS="$saved_LDFLAGS"
4033 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4036 #----------------------------------------------------------------------------
4037 # Other library checks
4038 #----------------------------------------------------------------------------
4039 # There now follow some tests for Boost, and OpenMP.  These
4040 # tests are present because Drd has some regression tests that use
4041 # these packages.  All regression test programs all compiled only
4042 # for the primary target.  And so it is important that the configure
4043 # checks that follow, use the correct -m32 or -m64 flag for the
4044 # primary target (called $mflag_primary).  Otherwise, we can end up
4045 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4046 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4047 # only build (meaning, the primary target is x86-linux), the build
4048 # of the regtest programs that use Boost fails, because they are 
4049 # build as 32-bit (IN THIS EXAMPLE).
4051 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4052 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4055 # Check whether the boost library 1.35 or later has been installed.
4056 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4058 AC_MSG_CHECKING([for boost])
4060 AC_LANG(C++)
4061 safe_CXXFLAGS=$CXXFLAGS
4062 CXXFLAGS="$mflag_primary"
4063 safe_LIBS="$LIBS"
4064 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4066 AC_LINK_IFELSE([AC_LANG_SOURCE([
4067 #include <boost/thread.hpp>
4068 static void thread_func(void)
4069 { }
4070 int main(int argc, char** argv)
4072   boost::thread t(thread_func);
4073   return 0;
4075 ])],
4077 ac_have_boost_1_35=yes
4078 AC_SUBST([BOOST_CFLAGS], [])
4079 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4080 AC_MSG_RESULT([yes])
4081 ], [
4082 ac_have_boost_1_35=no
4083 AC_MSG_RESULT([no])
4086 LIBS="$safe_LIBS"
4087 CXXFLAGS=$safe_CXXFLAGS
4088 AC_LANG(C)
4090 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4093 # does this compiler support -fopenmp, does it have the include file
4094 # <omp.h> and does it have libgomp ?
4096 AC_MSG_CHECKING([for OpenMP])
4098 safe_CFLAGS=$CFLAGS
4099 CFLAGS="-fopenmp $mflag_primary -Werror"
4101 AC_LINK_IFELSE([AC_LANG_SOURCE([
4102 #include <omp.h> 
4103 int main(int argc, char** argv)
4105   omp_set_dynamic(0);
4106   return 0;
4108 ])],
4110 ac_have_openmp=yes
4111 AC_MSG_RESULT([yes])
4112 ], [
4113 ac_have_openmp=no
4114 AC_MSG_RESULT([no])
4116 CFLAGS=$safe_CFLAGS
4118 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4121 # Check for __builtin_popcount
4122 AC_MSG_CHECKING([for __builtin_popcount()])
4123 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4124 ]], [[
4125   __builtin_popcount(2);
4126   return 0;
4127 ]])], [
4128 AC_MSG_RESULT([yes])
4129 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4130           [Define to 1 if compiler provides __builtin_popcount().])
4131 ], [
4132 AC_MSG_RESULT([no])
4135 # Check for __builtin_clz
4136 AC_MSG_CHECKING([for __builtin_clz()])
4137 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4138 ]], [[
4139   __builtin_clz(2);
4140   return 0;
4141 ]])], [
4142 AC_MSG_RESULT([yes])
4143 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4144           [Define to 1 if compiler provides __builtin_clz().])
4145 ], [
4146 AC_MSG_RESULT([no])
4149 # Check for __builtin_ctz
4150 AC_MSG_CHECKING([for __builtin_ctz()])
4151 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4152 ]], [[
4153   __builtin_ctz(2);
4154   return 0;
4155 ]])], [
4156 AC_MSG_RESULT([yes])
4157 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4158           [Define to 1 if compiler provides __builtin_ctz().])
4159 ], [
4160 AC_MSG_RESULT([no])
4163 # does this compiler have built-in functions for atomic memory access for the
4164 # primary target ?
4165 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4167 safe_CFLAGS=$CFLAGS
4168 CFLAGS="$mflag_primary"
4170 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4171   int variable = 1;
4172   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4173           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4174 ]])], [
4175   ac_have_builtin_atomic_primary=yes
4176   AC_MSG_RESULT([yes])
4177   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])
4178 ], [
4179   ac_have_builtin_atomic_primary=no
4180   AC_MSG_RESULT([no])
4183 CFLAGS=$safe_CFLAGS
4185 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4186                [test x$ac_have_builtin_atomic_primary = xyes])
4189 # does this compiler have built-in functions for atomic memory access for the
4190 # secondary target ?
4192 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4194 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
4196 safe_CFLAGS=$CFLAGS
4197 CFLAGS="$mflag_secondary"
4199 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4200   int variable = 1;
4201   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
4202 ]])], [
4203   ac_have_builtin_atomic_secondary=yes
4204   AC_MSG_RESULT([yes])
4205 ], [
4206   ac_have_builtin_atomic_secondary=no
4207   AC_MSG_RESULT([no])
4210 CFLAGS=$safe_CFLAGS
4214 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
4215                [test x$ac_have_builtin_atomic_secondary = xyes])
4217 # does this compiler have built-in functions for atomic memory access on
4218 # 64-bit integers for all targets ?
4220 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
4222 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4223   #include <stdint.h>
4224 ]], [[
4225   uint64_t variable = 1;
4226   return __sync_add_and_fetch(&variable, 1)
4227 ]])], [
4228   ac_have_builtin_atomic64_primary=yes
4229 ], [
4230   ac_have_builtin_atomic64_primary=no
4233 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4235 safe_CFLAGS=$CFLAGS
4236 CFLAGS="$mflag_secondary"
4238 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4239   #include <stdint.h>
4240 ]], [[
4241   uint64_t variable = 1;
4242   return __sync_add_and_fetch(&variable, 1)
4243 ]])], [
4244   ac_have_builtin_atomic64_secondary=yes
4245 ], [
4246   ac_have_builtin_atomic64_secondary=no
4249 CFLAGS=$safe_CFLAGS
4253 if test x$ac_have_builtin_atomic64_primary = xyes && \
4254    test x$VGCONF_PLATFORM_SEC_CAPS = x \
4255      -o x$ac_have_builtin_atomic64_secondary = xyes; then
4256   AC_MSG_RESULT([yes])
4257   ac_have_builtin_atomic64=yes
4258 else
4259   AC_MSG_RESULT([no])
4260   ac_have_builtin_atomic64=no
4263 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
4264                [test x$ac_have_builtin_atomic64 = xyes])
4267 # does g++ have built-in functions for atomic memory access ?
4268 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
4270 safe_CXXFLAGS=$CXXFLAGS
4271 CXXFLAGS="$mflag_primary"
4273 AC_LANG_PUSH(C++)
4274 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4275   int variable = 1;
4276   return (__sync_bool_compare_and_swap(&variable, 1, 2)
4277           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4278 ]])], [
4279   ac_have_builtin_atomic_cxx=yes
4280   AC_MSG_RESULT([yes])
4281   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
4282 ], [
4283   ac_have_builtin_atomic_cxx=no
4284   AC_MSG_RESULT([no])
4286 AC_LANG_POP(C++)
4288 CXXFLAGS=$safe_CXXFLAGS
4290 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
4293 if test x$ac_have_usable_linux_futex_h = xyes \
4294         -a x$ac_have_builtin_atomic_primary = xyes; then
4295   ac_enable_linux_ticket_lock_primary=yes
4297 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
4298                [test x$ac_enable_linux_ticket_lock_primary = xyes])
4300 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
4301         -a x$ac_have_usable_linux_futex_h = xyes \
4302         -a x$ac_have_builtin_atomic_secondary = xyes; then
4303   ac_enable_linux_ticket_lock_secondary=yes
4305 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
4306                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
4309 # does libstdc++ support annotating shared pointers ?
4310 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
4312 safe_CXXFLAGS=$CXXFLAGS
4313 CXXFLAGS="-std=c++0x"
4315 AC_LANG_PUSH(C++)
4316 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4317   #include <memory>
4318 ]], [[
4319   std::shared_ptr<int> p
4320 ]])], [
4321   ac_have_shared_ptr=yes
4322 ], [
4323   ac_have_shared_ptr=no
4325 if test x$ac_have_shared_ptr = xyes; then
4326   # If compilation of the program below fails because of a syntax error
4327   # triggered by substituting one of the annotation macros then that
4328   # means that libstdc++ supports these macros.
4329   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4330     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
4331     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
4332     #include <memory>
4333   ]], [[
4334     std::shared_ptr<int> p
4335   ]])], [
4336     ac_have_shared_pointer_annotation=no
4337     AC_MSG_RESULT([no])
4338   ], [
4339     ac_have_shared_pointer_annotation=yes
4340     AC_MSG_RESULT([yes])
4341     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
4342               [Define to 1 if libstd++ supports annotating shared pointers])
4343   ])
4344 else
4345   ac_have_shared_pointer_annotation=no
4346   AC_MSG_RESULT([no])
4348 AC_LANG_POP(C++)
4350 CXXFLAGS=$safe_CXXFLAGS
4352 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
4353                [test x$ac_have_shared_pointer_annotation = xyes])
4356 #----------------------------------------------------------------------------
4357 # Ok.  We're done checking.
4358 #----------------------------------------------------------------------------
4360 # Nb: VEX/Makefile is generated from Makefile.vex.in.
4361 AC_CONFIG_FILES([
4362    Makefile 
4363    VEX/Makefile:Makefile.vex.in
4364    valgrind.spec
4365    valgrind.pc
4366    glibc-2.X.supp
4367    docs/Makefile 
4368    tests/Makefile 
4369    tests/vg_regtest 
4370    perf/Makefile 
4371    perf/vg_perf
4372    gdbserver_tests/Makefile
4373    gdbserver_tests/solaris/Makefile
4374    include/Makefile 
4375    auxprogs/Makefile
4376    mpi/Makefile
4377    coregrind/Makefile 
4378    memcheck/Makefile
4379    memcheck/tests/Makefile
4380    memcheck/tests/common/Makefile
4381    memcheck/tests/amd64/Makefile
4382    memcheck/tests/x86/Makefile
4383    memcheck/tests/linux/Makefile
4384    memcheck/tests/darwin/Makefile
4385    memcheck/tests/solaris/Makefile
4386    memcheck/tests/amd64-linux/Makefile
4387    memcheck/tests/arm64-linux/Makefile
4388    memcheck/tests/x86-linux/Makefile
4389    memcheck/tests/amd64-solaris/Makefile
4390    memcheck/tests/x86-solaris/Makefile
4391    memcheck/tests/ppc32/Makefile
4392    memcheck/tests/ppc64/Makefile
4393    memcheck/tests/s390x/Makefile
4394    memcheck/tests/mips32/Makefile
4395    memcheck/tests/mips64/Makefile
4396    memcheck/tests/vbit-test/Makefile
4397    cachegrind/Makefile
4398    cachegrind/tests/Makefile
4399    cachegrind/tests/x86/Makefile
4400    cachegrind/cg_annotate
4401    cachegrind/cg_diff
4402    callgrind/Makefile
4403    callgrind/callgrind_annotate
4404    callgrind/callgrind_control
4405    callgrind/tests/Makefile
4406    helgrind/Makefile
4407    helgrind/tests/Makefile
4408    massif/Makefile
4409    massif/tests/Makefile
4410    massif/ms_print
4411    lackey/Makefile
4412    lackey/tests/Makefile
4413    none/Makefile
4414    none/tests/Makefile
4415    none/tests/scripts/Makefile
4416    none/tests/amd64/Makefile
4417    none/tests/ppc32/Makefile
4418    none/tests/ppc64/Makefile
4419    none/tests/x86/Makefile
4420    none/tests/arm/Makefile
4421    none/tests/arm64/Makefile
4422    none/tests/s390x/Makefile
4423    none/tests/mips32/Makefile
4424    none/tests/mips64/Makefile
4425    none/tests/linux/Makefile
4426    none/tests/darwin/Makefile
4427    none/tests/solaris/Makefile
4428    none/tests/amd64-linux/Makefile
4429    none/tests/x86-linux/Makefile
4430    none/tests/amd64-darwin/Makefile
4431    none/tests/x86-darwin/Makefile
4432    none/tests/amd64-solaris/Makefile
4433    none/tests/x86-solaris/Makefile
4434    exp-sgcheck/Makefile
4435    exp-sgcheck/tests/Makefile
4436    drd/Makefile
4437    drd/scripts/download-and-build-splash2
4438    drd/tests/Makefile
4439    exp-bbv/Makefile
4440    exp-bbv/tests/Makefile
4441    exp-bbv/tests/x86/Makefile
4442    exp-bbv/tests/x86-linux/Makefile
4443    exp-bbv/tests/amd64-linux/Makefile
4444    exp-bbv/tests/ppc32-linux/Makefile
4445    exp-bbv/tests/arm-linux/Makefile
4446    exp-dhat/Makefile
4447    exp-dhat/tests/Makefile
4448    shared/Makefile
4449    solaris/Makefile
4451 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
4452                 [chmod +x coregrind/link_tool_exe_linux])
4453 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
4454                 [chmod +x coregrind/link_tool_exe_darwin])
4455 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
4456                 [chmod +x coregrind/link_tool_exe_solaris])
4457 AC_OUTPUT
4459 cat<<EOF
4461          Maximum build arch: ${ARCH_MAX}
4462          Primary build arch: ${VGCONF_ARCH_PRI}
4463        Secondary build arch: ${VGCONF_ARCH_SEC}
4464                    Build OS: ${VGCONF_OS}
4465        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
4466      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
4467            Platform variant: ${VGCONF_PLATVARIANT}
4468       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
4469          Default supp files: ${DEFAULT_SUPP}