1
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.
7#
8##------------------------------------------------------------##
9
10# Process this file with autoconf to produce a configure script.
11AC_INIT([Valgrind],[3.12.0.SVN],[valgrind-users@lists.sourceforge.net])
12AC_CONFIG_SRCDIR(coregrind/m_main.c)
13AC_CONFIG_HEADERS([config.h])
14AM_INIT_AUTOMAKE([foreign subdir-objects])
15
16AM_MAINTAINER_MODE
17
18#----------------------------------------------------------------------------
19# Do NOT modify these flags here. Except in feature tests in which case
20# the original values must be properly restored.
21#----------------------------------------------------------------------------
22CFLAGS="$CFLAGS"
23CXXFLAGS="$CXXFLAGS"
24
25#----------------------------------------------------------------------------
26# Checks for various programs.
27#----------------------------------------------------------------------------
28
29AC_PROG_LN_S
30AC_PROG_CC
31AM_PROG_CC_C_O
32AC_PROG_CPP
33AC_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#        ])
47AC_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).
50m4_ifndef([AC_PROG_SED],
51          [AC_DEFUN([AC_PROG_SED],
52                    [AC_ARG_VAR([SED])
53                     AC_CHECK_PROGS([SED],[gsed sed])])])
54AC_PROG_SED
55
56# If no AR variable was specified, look up the name of the archiver. Otherwise
57# do not touch the AR variable.
58if test "x$AR" = "x"; then
59  AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
60fi
61AC_ARG_VAR([AR],[Archiver command])
62
63# Check for the compiler support
64if test "${GCC}" != "yes" ; then
65   AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
66fi
67
68# figure out where perl lives
69AC_PATH_PROG(PERL, perl)
70
71# figure out where gdb lives
72AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
73AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
74
75# some older automake's don't have it so try something on our own
76ifdef([AM_PROG_AS],[AM_PROG_AS],
77[
78AS="${CC}"
79AC_SUBST(AS)
80
81ASFLAGS=""
82AC_SUBST(ASFLAGS)
83])
84
85
86# Check if 'diff' supports -u (universal diffs) and use it if possible.
87
88AC_MSG_CHECKING([for diff -u])
89AC_SUBST(DIFF)
90
91# Comparing two identical files results in 0.
92tmpfile="tmp-xxx-yyy-zzz"
93touch $tmpfile;
94if diff -u $tmpfile $tmpfile ; then
95    AC_MSG_RESULT([yes])
96    DIFF="diff -u"
97else
98    AC_MSG_RESULT([no])
99    DIFF="diff"
100fi
101rm $tmpfile
102
103
104# We don't want gcc < 3.0
105AC_MSG_CHECKING([for a supported version of gcc])
106
107# Obtain the compiler version.
108#
109# A few examples of how the ${CC} --version output looks like:
110#
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)
119#
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
124#
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)
128#
129[
130if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
131then
132    is_clang="applellvm"
133    gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
134elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
135then
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'`
139elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ;
140then
141    is_clang="icc"
142    gcc_version=`${CC} -dumpversion 2>/dev/null`
143else
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
149fi
150]
151AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
152AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
153
154# Note: m4 arguments are quoted with [ and ] so square brackets in shell
155# statements have to be quoted.
156case "${is_clang}-${gcc_version}" in
157     applellvm-5.1|applellvm-6.*|applellvm-7.*)
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-[[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 (${gcc_version})])
171	AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0])
172	;;
173esac
174
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.
182
183AC_CANONICAL_HOST
184
185AC_MSG_CHECKING([for a supported CPU])
186
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.
191#
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 endianess 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# Endianess.  The name PPC64 or ppc64 to 64-bit systems of either Endianess.
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.
202
203case "${host_cpu}" in
204     i?86)
205	AC_MSG_RESULT([ok (${host_cpu})])
206        ARCH_MAX="x86"
207        ;;
208
209     x86_64)
210        AC_MSG_RESULT([ok (${host_cpu})])
211        ARCH_MAX="amd64"
212        ;;
213
214     powerpc64)
215     # this only referrs to 64-bit Big Endian
216        AC_MSG_RESULT([ok (${host_cpu})])
217        ARCH_MAX="ppc64be"
218        ;;
219
220     powerpc64le)
221     # this only referrs to 64-bit Little Endian
222        AC_MSG_RESULT([ok (${host_cpu})])
223        ARCH_MAX="ppc64le"
224        ;;
225
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        ;;
231
232     s390x)
233        AC_MSG_RESULT([ok (${host_cpu})])
234        ARCH_MAX="s390x"
235        ;;
236
237     armv7*)
238	AC_MSG_RESULT([ok (${host_cpu})])
239	ARCH_MAX="arm"
240	;;
241
242     aarch64*)
243       AC_MSG_RESULT([ok (${host_cpu})])
244       ARCH_MAX="arm64"
245       ;;
246
247     mips)
248        AC_MSG_RESULT([ok (${host_cpu})])
249        ARCH_MAX="mips32"
250        ;;
251
252     mipsel)
253        AC_MSG_RESULT([ok (${host_cpu})])
254        ARCH_MAX="mips32"
255        ;;
256
257     mipsisa32r2)
258        AC_MSG_RESULT([ok (${host_cpu})])
259        ARCH_MAX="mips32"
260        ;;
261
262     mips64*)
263        AC_MSG_RESULT([ok (${host_cpu})])
264        ARCH_MAX="mips64"
265        ;;
266
267     mipsisa64*)
268        AC_MSG_RESULT([ok (${host_cpu})])
269        ARCH_MAX="mips64"
270        ;;
271
272     tilegx)
273        AC_MSG_RESULT([ok (${host_cpu})])
274        ARCH_MAX="tilegx"
275        ;;
276
277     *)
278	AC_MSG_RESULT([no (${host_cpu})])
279	AC_MSG_ERROR([Unsupported host architecture. Sorry])
280	;;
281esac
282
283#----------------------------------------------------------------------------
284
285# Sometimes it's convenient to subvert the bi-arch build system and
286# just have a single build even though the underlying platform is
287# capable of both.  Hence handle --enable-only64bit and
288# --enable-only32bit.  Complain if both are issued :-)
289# [Actually, if either of these options are used, I think both get built,
290# but only one gets installed.  So if you use an in-place build, both can be
291# used. --njn]
292
293# Check if a 64-bit only build has been requested
294AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
295   [AC_ARG_ENABLE(only64bit,
296      [  --enable-only64bit      do a 64-bit only build],
297      [vg_cv_only64bit=$enableval],
298      [vg_cv_only64bit=no])])
299
300# Check if a 32-bit only build has been requested
301AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
302   [AC_ARG_ENABLE(only32bit,
303      [  --enable-only32bit      do a 32-bit only build],
304      [vg_cv_only32bit=$enableval],
305      [vg_cv_only32bit=no])])
306
307# Stay sane
308if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
309   AC_MSG_ERROR(
310      [Nonsensical: both --enable-only64bit and --enable-only32bit.])
311fi
312
313#----------------------------------------------------------------------------
314
315# VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
316# compilation of many C files via -VGO_$(VGCONF_OS) and
317# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
318AC_MSG_CHECKING([for a supported OS])
319AC_SUBST(VGCONF_OS)
320
321DEFAULT_SUPP=""
322
323case "${host_os}" in
324     *linux*)
325	AC_MSG_RESULT([ok (${host_os})])
326        VGCONF_OS="linux"
327
328        # Ok, this is linux. Check the kernel version
329        AC_MSG_CHECKING([for the kernel version])
330
331        kernel=`uname -r`
332
333        case "${kernel}" in
334             0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*)
335        	    AC_MSG_RESULT([unsupported (${kernel})])
336        	    AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
337        	    ;;
338
339             *)
340        	    AC_MSG_RESULT([2.6 or later (${kernel})])
341                    ;;
342        esac
343
344        ;;
345
346     *darwin*)
347        AC_MSG_RESULT([ok (${host_os})])
348        VGCONF_OS="darwin"
349        AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
350        AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
351        AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
352        AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
353        AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
354        AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
355        AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
356
357	AC_MSG_CHECKING([for the kernel version])
358	kernel=`uname -r`
359
360        # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
361        # has only one relevant version, the OS version. The `uname` check
362        # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
363        # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
364        # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
365        # and we don't know of an macros similar to __GLIBC__ to get that info.
366        #
367        # XXX: `uname -r` won't do the right thing for cross-compiles, but
368        # that's not a problem yet.
369        #
370        # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
371        # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
372        # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
373        # time support for 10.5 (the 9.* pattern just below), I'll leave it
374        # in for now, just in case anybody wants to give it a try.  But I'm
375        # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
376	case "${kernel}" in
377	     9.*)
378		  AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
379		  AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
380		  DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
381		  DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
382		  ;;
383	     10.*)
384		  AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
385		  AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
386		  DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
387		  DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
388		  ;;
389	     11.*)
390		  AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
391		  AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
392		  DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
393		  DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
394		  ;;
395	     12.*)
396		  AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
397		  AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
398		  DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
399		  DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
400		  ;;
401	     13.*)
402		  AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
403		  AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
404		  DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
405		  DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
406		  ;;
407	     14.*)
408		  AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
409		  AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
410		  DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
411		  DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
412		  ;;
413	     15.*)
414		  AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
415		  AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
416		  DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
417		  DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
418		  ;;
419             *)
420		  AC_MSG_RESULT([unsupported (${kernel})])
421		  AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x and 15.x (Mac OS X 10.6/7/8/9/10/11)])
422		  ;;
423	esac
424        ;;
425
426     solaris2.11*)
427        AC_MSG_RESULT([ok (${host_os})])
428        VGCONF_OS="solaris"
429        DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
430        ;;
431
432     solaris2.12*)
433        AC_MSG_RESULT([ok (${host_os})])
434        VGCONF_OS="solaris"
435        DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
436        ;;
437
438     *)
439	AC_MSG_RESULT([no (${host_os})])
440	AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
441	;;
442esac
443
444#----------------------------------------------------------------------------
445
446# If we are building on a 64 bit platform test to see if the system
447# supports building 32 bit programs and disable 32 bit support if it
448# does not support building 32 bit programs
449
450case "$ARCH_MAX-$VGCONF_OS" in
451     amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
452        AC_MSG_CHECKING([for 32 bit build support])
453        safe_CFLAGS=$CFLAGS
454        CFLAGS="-m32"
455        AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
456          return 0;
457        ]])], [
458        AC_MSG_RESULT([yes])
459        ], [
460        vg_cv_only64bit="yes"
461        AC_MSG_RESULT([no])
462        ])
463        CFLAGS=$safe_CFLAGS;;
464esac
465
466if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
467   AC_MSG_ERROR(
468      [--enable-only32bit was specified but system does not support 32 bit builds])
469fi
470
471#----------------------------------------------------------------------------
472
473# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
474# default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
475# machine, but --enable-only32bit has been requested, then ARCH_MAX (see
476# above) will be "amd64" since that reflects the most that this cpu can do,
477# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
478# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
479# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
480# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
481AC_SUBST(VGCONF_ARCH_PRI)
482
483# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
484# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
485# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
486# It is empty if there is no secondary target.
487AC_SUBST(VGCONF_ARCH_SEC)
488
489# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
490# The entire system, including regression and performance tests, will be
491# built for this target.  The "_CAPS" indicates that the name is in capital
492# letters, and it also uses '_' rather than '-' as a separator, because it's
493# used to create various Makefile variables, which are all in caps by
494# convention and cannot contain '-' characters.  This is in contrast to
495# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
496AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
497
498# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
499# Valgrind and tools will also be built for this target, but not the
500# regression or performance tests.
501#
502# By default, the primary arch is the same as the "max" arch, as commented
503# above (at the definition of ARCH_MAX).  We may choose to downgrade it in
504# the big case statement just below here, in the case where we're building
505# on a 64 bit machine but have been requested only to do a 32 bit build.
506AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
507
508AC_MSG_CHECKING([for a supported CPU/OS combination])
509
510# NB.  The load address for a given platform may be specified in more
511# than one place, in some cases, depending on whether we're doing a biarch,
512# 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
513# Be careful to give consistent values in all subcases.  Also, all four
514# valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
515# even if it is to "0xUNSET".
516#
517case "$ARCH_MAX-$VGCONF_OS" in
518     x86-linux)
519        VGCONF_ARCH_PRI="x86"
520        VGCONF_ARCH_SEC=""
521	VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
522	VGCONF_PLATFORM_SEC_CAPS=""
523        valt_load_address_pri_norml="0x38000000"
524        valt_load_address_pri_inner="0x28000000"
525        valt_load_address_sec_norml="0xUNSET"
526        valt_load_address_sec_inner="0xUNSET"
527        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
528	;;
529     amd64-linux)
530        valt_load_address_sec_norml="0xUNSET"
531        valt_load_address_sec_inner="0xUNSET"
532	if test x$vg_cv_only64bit = xyes; then
533           VGCONF_ARCH_PRI="amd64"
534           VGCONF_ARCH_SEC=""
535	   VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
536	   VGCONF_PLATFORM_SEC_CAPS=""
537           valt_load_address_pri_norml="0x38000000"
538           valt_load_address_pri_inner="0x28000000"
539	elif test x$vg_cv_only32bit = xyes; then
540	   VGCONF_ARCH_PRI="x86"
541           VGCONF_ARCH_SEC=""
542	   VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
543	   VGCONF_PLATFORM_SEC_CAPS=""
544           valt_load_address_pri_norml="0x38000000"
545           valt_load_address_pri_inner="0x28000000"
546	else
547           VGCONF_ARCH_PRI="amd64"
548           VGCONF_ARCH_SEC="x86"
549	   VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
550	   VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
551           valt_load_address_pri_norml="0x38000000"
552           valt_load_address_pri_inner="0x28000000"
553           valt_load_address_sec_norml="0x38000000"
554           valt_load_address_sec_inner="0x28000000"
555	fi
556        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
557	;;
558     ppc32-linux)
559        VGCONF_ARCH_PRI="ppc32"
560        VGCONF_ARCH_SEC=""
561	VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
562	VGCONF_PLATFORM_SEC_CAPS=""
563        valt_load_address_pri_norml="0x38000000"
564        valt_load_address_pri_inner="0x28000000"
565        valt_load_address_sec_norml="0xUNSET"
566        valt_load_address_sec_inner="0xUNSET"
567        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
568	;;
569     ppc64be-linux)
570        valt_load_address_sec_norml="0xUNSET"
571        valt_load_address_sec_inner="0xUNSET"
572	if test x$vg_cv_only64bit = xyes; then
573	   VGCONF_ARCH_PRI="ppc64be"
574           VGCONF_ARCH_SEC=""
575	   VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
576	   VGCONF_PLATFORM_SEC_CAPS=""
577           valt_load_address_pri_norml="0x38000000"
578           valt_load_address_pri_inner="0x28000000"
579	elif test x$vg_cv_only32bit = xyes; then
580	   VGCONF_ARCH_PRI="ppc32"
581           VGCONF_ARCH_SEC=""
582	   VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
583	   VGCONF_PLATFORM_SEC_CAPS=""
584           valt_load_address_pri_norml="0x38000000"
585           valt_load_address_pri_inner="0x28000000"
586	else
587	   VGCONF_ARCH_PRI="ppc64be"
588           VGCONF_ARCH_SEC="ppc32"
589	   VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
590	   VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
591           valt_load_address_pri_norml="0x38000000"
592           valt_load_address_pri_inner="0x28000000"
593           valt_load_address_sec_norml="0x38000000"
594           valt_load_address_sec_inner="0x28000000"
595	fi
596        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
597	;;
598     ppc64le-linux)
599        # Little Endian is only supported on PPC64
600        valt_load_address_sec_norml="0xUNSET"
601        valt_load_address_sec_inner="0xUNSET"
602        VGCONF_ARCH_PRI="ppc64le"
603        VGCONF_ARCH_SEC=""
604        VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
605        VGCONF_PLATFORM_SEC_CAPS=""
606        valt_load_address_pri_norml="0x38000000"
607        valt_load_address_pri_inner="0x28000000"
608        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
609       ;;
610     # Darwin gets identified as 32-bit even when it supports 64-bit.
611     # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
612     # all Macs support both 32-bit and 64-bit, so we just build both.  If
613     # someone has a really old 32-bit only machine they can (hopefully?)
614     # build with --enable-only32bit.  See bug 243362.
615     x86-darwin|amd64-darwin)
616        ARCH_MAX="amd64"
617        valt_load_address_sec_norml="0xUNSET"
618        valt_load_address_sec_inner="0xUNSET"
619	if test x$vg_cv_only64bit = xyes; then
620           VGCONF_ARCH_PRI="amd64"
621           VGCONF_ARCH_SEC=""
622	   VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
623	   VGCONF_PLATFORM_SEC_CAPS=""
624           valt_load_address_pri_norml="0x138000000"
625           valt_load_address_pri_inner="0x128000000"
626	elif test x$vg_cv_only32bit = xyes; then
627           VGCONF_ARCH_PRI="x86"
628           VGCONF_ARCH_SEC=""
629	   VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
630	   VGCONF_PLATFORM_SEC_CAPS=""
631	   VGCONF_ARCH_PRI_CAPS="x86"
632           valt_load_address_pri_norml="0x38000000"
633           valt_load_address_pri_inner="0x28000000"
634	else
635           VGCONF_ARCH_PRI="amd64"
636           VGCONF_ARCH_SEC="x86"
637	   VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
638	   VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
639           valt_load_address_pri_norml="0x138000000"
640           valt_load_address_pri_inner="0x128000000"
641           valt_load_address_sec_norml="0x38000000"
642           valt_load_address_sec_inner="0x28000000"
643	fi
644        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
645	;;
646     arm-linux)
647	VGCONF_ARCH_PRI="arm"
648	VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
649	VGCONF_PLATFORM_SEC_CAPS=""
650	valt_load_address_pri_norml="0x38000000"
651	valt_load_address_pri_inner="0x28000000"
652        valt_load_address_sec_norml="0xUNSET"
653        valt_load_address_sec_inner="0xUNSET"
654	AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
655	;;
656     arm64-linux)
657        valt_load_address_sec_norml="0xUNSET"
658        valt_load_address_sec_inner="0xUNSET"
659        if test x$vg_cv_only64bit = xyes; then
660           VGCONF_ARCH_PRI="arm64"
661           VGCONF_ARCH_SEC=""
662           VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
663           VGCONF_PLATFORM_SEC_CAPS=""
664           valt_load_address_pri_norml="0x38000000"
665           valt_load_address_pri_inner="0x28000000"
666        elif test x$vg_cv_only32bit = xyes; then
667           VGCONF_ARCH_PRI="arm"
668           VGCONF_ARCH_SEC=""
669           VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
670           VGCONF_PLATFORM_SEC_CAPS=""
671           valt_load_address_pri_norml="0x38000000"
672           valt_load_address_pri_inner="0x28000000"
673        else
674           VGCONF_ARCH_PRI="arm64"
675           VGCONF_ARCH_SEC="arm"
676           VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
677           VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
678           valt_load_address_pri_norml="0x38000000"
679           valt_load_address_pri_inner="0x28000000"
680           valt_load_address_sec_norml="0x38000000"
681           valt_load_address_sec_inner="0x28000000"
682        fi
683        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
684        ;;
685     s390x-linux)
686        VGCONF_ARCH_PRI="s390x"
687        VGCONF_ARCH_SEC=""
688        VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
689        VGCONF_PLATFORM_SEC_CAPS=""
690        # To improve branch prediction hit rate we want to have
691        # the generated code close to valgrind (host) code
692        valt_load_address_pri_norml="0x800000000"
693        valt_load_address_pri_inner="0x810000000"
694        valt_load_address_sec_norml="0xUNSET"
695        valt_load_address_sec_inner="0xUNSET"
696        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
697        ;;
698     mips32-linux)
699        VGCONF_ARCH_PRI="mips32"
700        VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
701        VGCONF_PLATFORM_SEC_CAPS=""
702        valt_load_address_pri_norml="0x38000000"
703        valt_load_address_pri_inner="0x28000000"
704        valt_load_address_sec_norml="0xUNSET"
705        valt_load_address_sec_inner="0xUNSET"
706        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
707        ;;
708     mips64-linux)
709        VGCONF_ARCH_PRI="mips64"
710        VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
711        VGCONF_PLATFORM_SEC_CAPS=""
712        valt_load_address_pri_norml="0x38000000"
713        valt_load_address_pri_inner="0x28000000"
714        valt_load_address_sec_norml="0xUNSET"
715        valt_load_address_sec_inner="0xUNSET"
716        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
717        ;;
718     tilegx-linux)
719        VGCONF_ARCH_PRI="tilegx"
720        VGCONF_ARCH_SEC=""
721        VGCONF_PLATFORM_PRI_CAPS="TILEGX_LINUX"
722        VGCONF_PLATFORM_SEC_CAPS=""
723        valt_load_address_pri_norml="0x38000000"
724        valt_load_address_pri_inner="0x28000000"
725        valt_load_address_sec_norml="0xUNSET"
726        valt_load_address_sec_inner="0xUNSET"
727        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
728        ;;
729     x86-solaris)
730        VGCONF_ARCH_PRI="x86"
731        VGCONF_ARCH_SEC=""
732        VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
733        VGCONF_PLATFORM_SEC_CAPS=""
734        valt_load_address_pri_norml="0x38000000"
735        valt_load_address_pri_inner="0x28000000"
736        valt_load_address_sec_norml="0xUNSET"
737        valt_load_address_sec_inner="0xUNSET"
738        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
739        ;;
740     amd64-solaris)
741        valt_load_address_sec_norml="0xUNSET"
742        valt_load_address_sec_inner="0xUNSET"
743        if test x$vg_cv_only64bit = xyes; then
744           VGCONF_ARCH_PRI="amd64"
745           VGCONF_ARCH_SEC=""
746           VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
747           VGCONF_PLATFORM_SEC_CAPS=""
748           valt_load_address_pri_norml="0x38000000"
749           valt_load_address_pri_inner="0x28000000"
750        elif test x$vg_cv_only32bit = xyes; then
751           VGCONF_ARCH_PRI="x86"
752           VGCONF_ARCH_SEC=""
753           VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
754           VGCONF_PLATFORM_SEC_CAPS=""
755           valt_load_address_pri_norml="0x38000000"
756           valt_load_address_pri_inner="0x28000000"
757        else
758           VGCONF_ARCH_PRI="amd64"
759           VGCONF_ARCH_SEC="x86"
760           VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
761           VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
762           valt_load_address_pri_norml="0x38000000"
763           valt_load_address_pri_inner="0x28000000"
764           valt_load_address_sec_norml="0x38000000"
765           valt_load_address_sec_inner="0x28000000"
766        fi
767        AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
768        ;;
769    *)
770        VGCONF_ARCH_PRI="unknown"
771        VGCONF_ARCH_SEC="unknown"
772	VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
773	VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
774        valt_load_address_pri_norml="0xUNSET"
775        valt_load_address_pri_inner="0xUNSET"
776        valt_load_address_sec_norml="0xUNSET"
777        valt_load_address_sec_inner="0xUNSET"
778        AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
779        AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
780        ;;
781esac
782
783#----------------------------------------------------------------------------
784
785# Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
786# defined.
787AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
788               test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
789                 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
790                 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
791                 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
792                 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
793                 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
794AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
795               test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
796                 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
797                 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
798AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
799               test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
800                 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
801AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
802               test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
803                 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
804AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
805               test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
806                 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
807AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
808               test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
809AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
810               test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
811AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
812               test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
813AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
814               test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
815AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_TILEGX,
816               test x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX )
817
818# Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
819# become defined.
820AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
821               test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
822                 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
823AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
824               test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
825AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
826               test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
827                 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
828AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
829               test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
830AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
831               test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
832AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
833               test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
834                 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
835AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
836               test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
837AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
838               test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
839                 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
840AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
841               test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
842AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
843               test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
844AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_TILEGX_LINUX,
845               test x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX)
846AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
847               test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
848                 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
849AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
850               test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
851AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
852               test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
853                 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
854AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
855               test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
856
857
858# Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
859# Relies on the assumption that the primary and secondary targets are
860# for the same OS, so therefore only necessary to test the primary.
861AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
862               test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
863                 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
864                 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
865                 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
866                 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
867                 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
868                 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
869                 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
870                 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
871                 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
872                 -o x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX)
873AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
874               test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
875                 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
876AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
877               test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
878                 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
879
880
881# Sometimes, in the Makefile.am files, it's useful to know whether or not
882# there is a secondary target.
883AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
884               test x$VGCONF_PLATFORM_SEC_CAPS != x)
885
886dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
887dnl fallback definition
888dnl The macro is courtesy of Dave Hart:
889dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
890m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
891if test -z "$$1_TRUE"; then :
892  m4_n([$2])[]dnl
893m4_ifval([$3],
894[else
895  $3
896])dnl
897fi[]dnl
898])])
899
900#----------------------------------------------------------------------------
901# Inner Valgrind?
902#----------------------------------------------------------------------------
903
904# Check if this should be built as an inner Valgrind, to be run within
905# another Valgrind.  Choose the load address accordingly.
906AC_SUBST(VALT_LOAD_ADDRESS_PRI)
907AC_SUBST(VALT_LOAD_ADDRESS_SEC)
908AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
909   [AC_ARG_ENABLE(inner,
910      [  --enable-inner          enables self-hosting],
911      [vg_cv_inner=$enableval],
912      [vg_cv_inner=no])])
913if test "$vg_cv_inner" = yes; then
914    AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
915    VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
916    VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
917else
918    VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
919    VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
920fi
921
922#----------------------------------------------------------------------------
923# Undefined behaviour sanitiser
924#----------------------------------------------------------------------------
925# Check whether we should build with the undefined beahviour sanitiser.
926
927AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
928   [AC_ARG_ENABLE(ubsan,
929      [  --enable-ubsan          enables the undefined behaviour sanitiser],
930      [vg_cv_ubsan=$enableval],
931      [vg_cv_ubsan=no])])
932
933#----------------------------------------------------------------------------
934# Define MIPS_PAGE_SHIFT (--with-pagesize)
935#----------------------------------------------------------------------------
936AC_ARG_WITH(pagesize,
937   [  --with-pagesize=        override detected page size (4, 16 or 64)],
938   [psize=$withval],
939   [psize=0]
940)
941
942if test "$psize" = "0"; then
943    psizer=`getconf PAGESIZE`
944    psize=$((${psizer}/1024))
945fi
946
947if test "$psize" = "4"; then
948    AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k])
949elif test "$psize" = "16"; then
950    AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k])
951elif test "$psize" = "64"; then
952    AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k])
953else
954   AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k])
955fi
956AC_MSG_RESULT([checking for Pagesize... ${psize}k])
957
958
959#----------------------------------------------------------------------------
960# Extra fine-tuning of installation directories
961#----------------------------------------------------------------------------
962AC_ARG_WITH(tmpdir,
963   [  --with-tmpdir=PATH      Specify path for temporary files],
964   tmpdir="$withval",
965   tmpdir="/tmp")
966AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
967AC_SUBST(VG_TMPDIR, [$tmpdir])
968
969
970#----------------------------------------------------------------------------
971# Libc and suppressions
972#----------------------------------------------------------------------------
973# This variable will collect the suppression files to be used.
974AC_SUBST(DEFAULT_SUPP)
975
976AC_CHECK_HEADER([features.h])
977
978if test x$ac_cv_header_features_h = xyes; then
979  rm -f conftest.$ac_ext
980  cat <<_ACEOF >conftest.$ac_ext
981#include <features.h>
982#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
983glibc version is: __GLIBC__ __GLIBC_MINOR__
984#endif
985_ACEOF
986  GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
987fi
988
989# not really a version check
990AC_EGREP_CPP([DARWIN_LIBC], [
991#include <sys/cdefs.h>
992#if defined(__DARWIN_VERS_1050)
993  DARWIN_LIBC
994#endif
995],
996GLIBC_VERSION="darwin")
997
998# not really a version check
999AC_EGREP_CPP([BIONIC_LIBC], [
1000#if defined(__ANDROID__)
1001  BIONIC_LIBC
1002#endif
1003],
1004GLIBC_VERSION="bionic")
1005
1006# there is only one version of libc on Solaris
1007if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1008     -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1009    GLIBC_VERSION="solaris"
1010fi
1011
1012
1013AC_MSG_CHECKING([the glibc version])
1014
1015case "${GLIBC_VERSION}" in
1016     2.2)
1017	AC_MSG_RESULT(${GLIBC_VERSION} family)
1018	DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1019	DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1020	DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1021	;;
1022     2.[[3-6]])
1023	AC_MSG_RESULT(${GLIBC_VERSION} family)
1024	DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1025	DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1026	DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1027	;;
1028     2.[[7-9]])
1029	AC_MSG_RESULT(${GLIBC_VERSION} family)
1030	DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1031	DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1032	DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1033	;;
1034     2.10|2.11)
1035	AC_MSG_RESULT(${GLIBC_VERSION} family)
1036	AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1037		  [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1038	DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1039	DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1040	DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1041	;;
1042     2.*)
1043	AC_MSG_RESULT(${GLIBC_VERSION} family)
1044	AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1045		  [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1046	AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1047		  [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1048	DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1049	DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1050	DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1051	;;
1052     darwin)
1053	AC_MSG_RESULT(Darwin)
1054	AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1055	# DEFAULT_SUPP set by kernel version check above.
1056	;;
1057     bionic)
1058	AC_MSG_RESULT(Bionic)
1059	AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1060	DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1061	;;
1062     solaris)
1063	AC_MSG_RESULT(Solaris)
1064	# DEFAULT_SUPP set in host_os switch-case above.
1065	# No other suppression file is used.
1066	;;
1067     2.0|2.1|*)
1068	AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1069	AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later,])
1070	AC_MSG_ERROR([Darwin libc, Bionic libc or Solaris libc])
1071	;;
1072esac
1073
1074AC_SUBST(GLIBC_VERSION)
1075
1076
1077if test "$VGCONF_OS" != "solaris"; then
1078    # Add default suppressions for the X client libraries.  Make no
1079    # attempt to detect whether such libraries are installed on the
1080    # build machine (or even if any X facilities are present); just
1081    # add the suppressions antidisirregardless.
1082    DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1083    DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1084
1085    # Add glibc and X11 suppressions for exp-sgcheck
1086    DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
1087fi
1088
1089
1090#----------------------------------------------------------------------------
1091# Platform variants?
1092#----------------------------------------------------------------------------
1093
1094# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1095# But there are times where we need a bit more control.  The motivating
1096# and currently only case is Android: this is almost identical to
1097# {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1098# platform variant tags, which get passed in the compile as
1099# -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1100#
1101# In almost all cases, the <variant> bit is "vanilla".  But for Android
1102# it is "android" instead.
1103#
1104# Consequently (eg), plain arm-linux would build with
1105#
1106#   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1107#
1108# whilst an Android build would have
1109#
1110#   -DVGP_arm_linux -DVGPV_arm_linux_android
1111#
1112# Same for x86. The setup of the platform variant is pushed relatively far
1113# down this file in order that we can inspect any of the variables set above.
1114
1115# In the normal case ..
1116VGCONF_PLATVARIANT="vanilla"
1117
1118# Android ?
1119if test "$GLIBC_VERSION" = "bionic";
1120then
1121   VGCONF_PLATVARIANT="android"
1122fi
1123
1124AC_SUBST(VGCONF_PLATVARIANT)
1125
1126
1127# FIXME: do we also want to define automake variables
1128# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1129# VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1130# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1131# do that.  Problem is that we can't do and-ing in Makefile.am's, but
1132# that's what we'd need to do to use this, since what we'd want to write
1133# is something like
1134#
1135# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1136#
1137# Hmm.  Can't think of a nice clean solution to this.
1138
1139AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1140               test x$VGCONF_PLATVARIANT = xvanilla)
1141AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1142               test x$VGCONF_PLATVARIANT = xandroid)
1143
1144
1145#----------------------------------------------------------------------------
1146# Checking for various library functions and other definitions
1147#----------------------------------------------------------------------------
1148
1149# Check for AT_FDCWD
1150
1151AC_MSG_CHECKING([for AT_FDCWD])
1152AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1153#define _GNU_SOURCE
1154#include <fcntl.h>
1155#include <unistd.h>
1156]], [[
1157  int a = AT_FDCWD;
1158]])], [
1159ac_have_at_fdcwd=yes
1160AC_MSG_RESULT([yes])
1161], [
1162ac_have_at_fdcwd=no
1163AC_MSG_RESULT([no])
1164])
1165
1166AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1167
1168# Check for stpncpy function definition in string.h
1169# This explicitly checks with _GNU_SOURCE defined since that is also
1170# used in the test case (some systems might define it without anyway
1171# since stpncpy is part of The Open Group Base Specifications Issue 7
1172# IEEE Std 1003.1-2008.
1173AC_MSG_CHECKING([for stpncpy])
1174AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1175#define _GNU_SOURCE
1176#include <string.h>
1177]], [[
1178  char *d;
1179  char *s;
1180  size_t n = 0;
1181  char *r = stpncpy(d, s, n);
1182]])], [
1183ac_have_gnu_stpncpy=yes
1184AC_MSG_RESULT([yes])
1185], [
1186ac_have_gnu_stpncpy=no
1187AC_MSG_RESULT([no])
1188])
1189
1190AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1191
1192# Check for PTRACE_GETREGS
1193
1194AC_MSG_CHECKING([for PTRACE_GETREGS])
1195AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1196#include <stdlib.h>
1197#include <stddef.h>
1198#include <sys/ptrace.h>
1199#include <sys/user.h>
1200]], [[
1201  void *p;
1202  long res = ptrace (PTRACE_GETREGS, 0, p, p);
1203]])], [
1204AC_MSG_RESULT([yes])
1205AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1206          [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1207], [
1208AC_MSG_RESULT([no])
1209])
1210
1211
1212# Check for CLOCK_MONOTONIC
1213
1214AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1215
1216AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1217#include <time.h>
1218]], [[
1219  struct timespec t;
1220  clock_gettime(CLOCK_MONOTONIC, &t);
1221  return 0;
1222]])], [
1223AC_MSG_RESULT([yes])
1224AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1225          [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1226], [
1227AC_MSG_RESULT([no])
1228])
1229
1230
1231# Check for PTHREAD_RWLOCK_T
1232
1233AC_MSG_CHECKING([for pthread_rwlock_t])
1234
1235AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1236#define _GNU_SOURCE
1237#include <pthread.h>
1238]], [[
1239  pthread_rwlock_t rwl;
1240]])], [
1241AC_MSG_RESULT([yes])
1242AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1243          [Define to 1 if you have the `pthread_rwlock_t' type.])
1244], [
1245AC_MSG_RESULT([no])
1246])
1247
1248
1249# Check for PTHREAD_MUTEX_ADAPTIVE_NP
1250
1251AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1252
1253AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1254#define _GNU_SOURCE
1255#include <pthread.h>
1256]], [[
1257  return (PTHREAD_MUTEX_ADAPTIVE_NP);
1258]])], [
1259AC_MSG_RESULT([yes])
1260AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1261          [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1262], [
1263AC_MSG_RESULT([no])
1264])
1265
1266
1267# Check for PTHREAD_MUTEX_ERRORCHECK_NP
1268
1269AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1270
1271AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1272#define _GNU_SOURCE
1273#include <pthread.h>
1274]], [[
1275  return (PTHREAD_MUTEX_ERRORCHECK_NP);
1276]])], [
1277AC_MSG_RESULT([yes])
1278AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1279          [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1280], [
1281AC_MSG_RESULT([no])
1282])
1283
1284
1285# Check for PTHREAD_MUTEX_RECURSIVE_NP
1286
1287AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1288
1289AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1290#define _GNU_SOURCE
1291#include <pthread.h>
1292]], [[
1293  return (PTHREAD_MUTEX_RECURSIVE_NP);
1294]])], [
1295AC_MSG_RESULT([yes])
1296AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1297          [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1298], [
1299AC_MSG_RESULT([no])
1300])
1301
1302
1303# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1304
1305AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1306
1307AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1308#define _GNU_SOURCE
1309#include <pthread.h>
1310]], [[
1311  pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1312  return 0;
1313]])], [
1314AC_MSG_RESULT([yes])
1315AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1316          [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1317], [
1318AC_MSG_RESULT([no])
1319])
1320
1321
1322# Check whether pthread_mutex_t has a member called __m_kind.
1323
1324AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1325	        [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1326		           1,
1327			   [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1328                ],
1329		[],
1330		[#include <pthread.h>])
1331
1332
1333# Check whether pthread_mutex_t has a member called __data.__kind.
1334
1335AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1336                [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1337		          1,
1338			  [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1339                ],
1340		[],
1341		[#include <pthread.h>])
1342
1343# Convenience function.  Set flags based on the existing HWCAP entries.
1344# The AT_HWCAP entries are generated by glibc, and are based on
1345# functions supported by the hardware/system/libc.
1346# Subsequent support for whether the capability will actually be utilized
1347# will also be checked against the compiler capabilities.
1348# called as
1349#      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1350AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1351  AUXV_CHECK_FOR=$1
1352  AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1353  if LD_SHOW_AUXV=1 `which true` | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1354  then
1355    AC_MSG_RESULT([yes])
1356    AC_SUBST([$2],[yes])
1357  else
1358    AC_MSG_RESULT([no])
1359    AC_SUBST([$2],[])
1360  fi
1361])
1362
1363# gather hardware capabilities. (hardware/kernel/libc)
1364AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1365AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1366AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1367AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1368AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1369AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1370AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1371
1372# ISA Levels
1373AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1374AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1375# compiler support for isa 2.07 level instructions
1376AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1377AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1378]], [[
1379  __asm__ __volatile__("mtvsrd 1,2 ");
1380]])], [
1381ac_asm_have_isa_2_07=yes
1382AC_MSG_RESULT([yes])
1383], [
1384ac_asm_have_isa_2_07=no
1385AC_MSG_RESULT([no])
1386])
1387AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1388                               -a x$HWCAP_HAS_ISA_2_07 = xyes])
1389
1390# altivec (vsx) support.
1391# does this compiler support -maltivec and does it have the include file
1392# <altivec.h> ?
1393AC_MSG_CHECKING([for Altivec support in the compiler ])
1394safe_CFLAGS=$CFLAGS
1395CFLAGS="-maltivec -Werror"
1396AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1397#include <altivec.h>
1398]], [[
1399  vector unsigned int v;
1400]])], [
1401ac_have_altivec=yes
1402AC_MSG_RESULT([yes])
1403AC_DEFINE([HAS_ALTIVEC], 1,
1404          [Define to 1 if gcc/as can do Altivec.])
1405], [
1406ac_have_altivec=no
1407AC_MSG_RESULT([no])
1408])
1409CFLAGS=$safe_CFLAGS
1410AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1411                                 -a x$HWCAP_HAS_ALTIVEC = xyes])
1412
1413# Check that both: the compiler supports -mvsx and that the assembler
1414# understands VSX instructions.  If either of those doesn't work,
1415# conclude that we can't do VSX.
1416AC_MSG_CHECKING([for VSX compiler flag support])
1417safe_CFLAGS=$CFLAGS
1418CFLAGS="-mvsx -Werror"
1419AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1420]], [[
1421]])], [
1422ac_compiler_supports_vsx_flag=yes
1423AC_MSG_RESULT([yes])
1424], [
1425ac_compiler_supports_vsx_flag=no
1426AC_MSG_RESULT([no])
1427])
1428CFLAGS=$safe_CFLAGS
1429
1430AC_MSG_CHECKING([for VSX support in the assembler ])
1431safe_CFLAGS=$CFLAGS
1432CFLAGS="-mvsx -Werror"
1433AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1434#include <altivec.h>
1435]], [[
1436  vector unsigned int v;
1437  __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1438]])], [
1439ac_compiler_supports_vsx=yes
1440AC_MSG_RESULT([yes])
1441], [
1442ac_compiler_supports_vsx=no
1443AC_MSG_RESULT([no])
1444])
1445CFLAGS=$safe_CFLAGS
1446AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1447                             -a x$ac_compiler_supports_vsx = xyes \
1448                             -a x$HWCAP_HAS_VSX = xyes ])
1449
1450# DFP (Decimal Float)
1451AC_MSG_CHECKING([that assembler knows DFP])
1452AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1453]], [[
1454  __asm__ __volatile__("dadd 1, 2, 3");
1455  __asm__ __volatile__("dcffix 1, 2");
1456]])], [
1457ac_asm_have_dfp=yes
1458AC_MSG_RESULT([yes])
1459], [
1460ac_asm_have_dfp=no
1461AC_MSG_RESULT([no])
1462])
1463AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1464safe_CFLAGS=$CFLAGS
1465CFLAGS="-mhard-dfp -Werror"
1466AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1467]], [[
1468  __asm__ __volatile__("dadd 1, 2, 3");
1469  __asm__ __volatile__("dcffix 1, 2");
1470]])], [
1471ac_compiler_have_dfp=yes
1472AC_MSG_RESULT([yes])
1473], [
1474ac_compiler_have_dfp=no
1475AC_MSG_RESULT([no])
1476])
1477CFLAGS=$safe_CFLAGS
1478AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1479                          -a x$ac_compiler_have_dfp = xyes \
1480                          -a x$HWCAP_HAS_DFP = xyes )
1481
1482AC_MSG_CHECKING([that compiler knows DFP datatypes])
1483AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1484]], [[
1485  _Decimal64 x = 0.0DD;
1486]])], [
1487ac_compiler_have_dfp_type=yes
1488AC_MSG_RESULT([yes])
1489], [
1490ac_compiler_have_dfp_type=no
1491AC_MSG_RESULT([no])
1492])
1493AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1494                                  -a xHWCAP_$HAS_DFP = xyes )
1495
1496
1497# HTM (Hardware Transactional Memory)
1498AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1499safe_CFLAGS=$CFLAGS
1500CFLAGS="-mhtm -Werror"
1501AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1502]], [[
1503  return 0;
1504]])], [
1505AC_MSG_RESULT([yes])
1506ac_compiler_supports_htm=yes
1507], [
1508AC_MSG_RESULT([no])
1509ac_compiler_supports_htm=no
1510])
1511CFLAGS=$safe_CFLAGS
1512
1513AC_MSG_CHECKING([if compiler can find the htm builtins])
1514safe_CFLAGS=$CFLAGS
1515CFLAGS="-mhtm -Werror"
1516 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1517 ]], [[
1518   if (__builtin_tbegin (0))
1519      __builtin_tend (0);
1520 ]])], [
1521 AC_MSG_RESULT([yes])
1522ac_compiler_sees_htm_builtins=yes
1523 ], [
1524 AC_MSG_RESULT([no])
1525ac_compiler_sees_htm_builtins=no
1526 ])
1527CFLAGS=$safe_CFLAGS
1528
1529AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1530                               -a x$ac_compiler_sees_htm_builtins = xyes \
1531                               -a x$HWCAP_HAS_HTM = xyes )
1532
1533# Check for pthread_create@GLIBC2.0
1534AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1535
1536safe_CFLAGS=$CFLAGS
1537CFLAGS="-lpthread -Werror"
1538AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1539extern int pthread_create_glibc_2_0(void*, const void*,
1540                                    void *(*)(void*), void*);
1541__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1542]], [[
1543#ifdef __powerpc__
1544/*
1545 * Apparently on PowerPC linking this program succeeds and generates an
1546 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1547 */
1548#error This test does not work properly on PowerPC.
1549#else
1550  pthread_create_glibc_2_0(0, 0, 0, 0);
1551#endif
1552  return 0;
1553]])], [
1554ac_have_pthread_create_glibc_2_0=yes
1555AC_MSG_RESULT([yes])
1556AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1557          [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1558], [
1559ac_have_pthread_create_glibc_2_0=no
1560AC_MSG_RESULT([no])
1561])
1562CFLAGS=$safe_CFLAGS
1563
1564AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1565	       test x$ac_have_pthread_create_glibc_2_0 = xyes)
1566
1567
1568# Check for dlinfo RTLD_DI_TLS_MODID
1569AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1570
1571safe_LIBS="$LIBS"
1572LIBS="-ldl"
1573AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1574#ifndef _GNU_SOURCE
1575#define _GNU_SOURCE
1576#endif
1577#include <link.h>
1578#include <dlfcn.h>
1579]], [[
1580  size_t sizes[10000];
1581  size_t modid_offset;
1582  (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1583  return 0;
1584]])], [
1585ac_have_dlinfo_rtld_di_tls_modid=yes
1586AC_MSG_RESULT([yes])
1587AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1588          [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1589], [
1590ac_have_dlinfo_rtld_di_tls_modid=no
1591AC_MSG_RESULT([no])
1592])
1593LIBS=$safe_LIBS
1594
1595AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1596	       test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1597
1598
1599# Check for eventfd_t, eventfd() and eventfd_read()
1600AC_MSG_CHECKING([for eventfd()])
1601
1602AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1603#include <sys/eventfd.h>
1604]], [[
1605  eventfd_t ev;
1606  int fd;
1607
1608  fd = eventfd(5, 0);
1609  eventfd_read(fd, &ev);
1610  return 0;
1611]])], [
1612AC_MSG_RESULT([yes])
1613AC_DEFINE([HAVE_EVENTFD], 1,
1614          [Define to 1 if you have the `eventfd' function.])
1615AC_DEFINE([HAVE_EVENTFD_READ], 1,
1616          [Define to 1 if you have the `eventfd_read' function.])
1617], [
1618AC_MSG_RESULT([no])
1619])
1620
1621# Check whether compiler can process #include <thread> without errors
1622# clang 3.3 cannot process <thread> from e.g.
1623# gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1624
1625AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1626AC_LANG(C++)
1627safe_CXXFLAGS=$CXXFLAGS
1628CXXFLAGS=-std=c++0x
1629
1630AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1631#include <thread>
1632])],
1633[
1634ac_cxx_can_include_thread_header=yes
1635AC_MSG_RESULT([yes])
1636], [
1637ac_cxx_can_include_thread_header=no
1638AC_MSG_RESULT([no])
1639])
1640CXXFLAGS=$safe_CXXFLAGS
1641AC_LANG(C)
1642
1643AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1644
1645
1646# On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1647# of the user_regs_struct from sys/user.h. They are structurally the same
1648# but we get either one or the other.
1649
1650AC_CHECK_TYPE([struct user_regs_struct],
1651              [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1652              [[#include <sys/ptrace.h>]
1653               [#include <sys/time.h>]
1654               [#include <sys/user.h>]])
1655if test "$sys_user_has_user_regs" = "yes"; then
1656  AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1657            [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1658fi
1659
1660
1661#----------------------------------------------------------------------------
1662# Checking for supported compiler flags.
1663#----------------------------------------------------------------------------
1664
1665# does this compiler support -m32 ?
1666AC_MSG_CHECKING([if gcc accepts -m32])
1667
1668safe_CFLAGS=$CFLAGS
1669CFLAGS="-m32 -Werror"
1670
1671AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1672  return 0;
1673]])], [
1674FLAG_M32="-m32"
1675AC_MSG_RESULT([yes])
1676], [
1677FLAG_M32=""
1678AC_MSG_RESULT([no])
1679])
1680CFLAGS=$safe_CFLAGS
1681
1682AC_SUBST(FLAG_M32)
1683
1684
1685# does this compiler support -m64 ?
1686AC_MSG_CHECKING([if gcc accepts -m64])
1687
1688safe_CFLAGS=$CFLAGS
1689CFLAGS="-m64 -Werror"
1690
1691AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1692  return 0;
1693]])], [
1694FLAG_M64="-m64"
1695AC_MSG_RESULT([yes])
1696], [
1697FLAG_M64=""
1698AC_MSG_RESULT([no])
1699])
1700CFLAGS=$safe_CFLAGS
1701
1702AC_SUBST(FLAG_M64)
1703
1704
1705# does this compiler support -march=mips32 (mips32 default) ?
1706AC_MSG_CHECKING([if gcc accepts -march=mips32])
1707
1708safe_CFLAGS=$CFLAGS
1709CFLAGS="$CFLAGS -march=mips32 -Werror"
1710
1711AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1712  return 0;
1713]])], [
1714FLAG_MIPS32="-march=mips32"
1715AC_MSG_RESULT([yes])
1716], [
1717FLAG_MIPS32=""
1718AC_MSG_RESULT([no])
1719])
1720CFLAGS=$safe_CFLAGS
1721
1722AC_SUBST(FLAG_MIPS32)
1723
1724
1725# does this compiler support -march=mips64 (mips64 default) ?
1726AC_MSG_CHECKING([if gcc accepts -march=mips64])
1727
1728safe_CFLAGS=$CFLAGS
1729CFLAGS="$CFLAGS -march=mips64 -Werror"
1730
1731AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1732  return 0;
1733]])], [
1734FLAG_MIPS64="-march=mips64"
1735AC_MSG_RESULT([yes])
1736], [
1737FLAG_MIPS64=""
1738AC_MSG_RESULT([no])
1739])
1740CFLAGS=$safe_CFLAGS
1741
1742AC_SUBST(FLAG_MIPS64)
1743
1744
1745# does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1746AC_MSG_CHECKING([if gcc accepts -march=octeon])
1747
1748safe_CFLAGS=$CFLAGS
1749CFLAGS="$CFLAGS -march=octeon -Werror"
1750
1751AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1752  return 0;
1753]])], [
1754FLAG_OCTEON="-march=octeon"
1755AC_MSG_RESULT([yes])
1756], [
1757FLAG_OCTEON=""
1758AC_MSG_RESULT([no])
1759])
1760CFLAGS=$safe_CFLAGS
1761
1762AC_SUBST(FLAG_OCTEON)
1763
1764
1765# does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1766AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1767
1768safe_CFLAGS=$CFLAGS
1769CFLAGS="$CFLAGS -march=octeon2 -Werror"
1770
1771AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1772  return 0;
1773]])], [
1774FLAG_OCTEON2="-march=octeon2"
1775AC_MSG_RESULT([yes])
1776], [
1777FLAG_OCTEON2=""
1778AC_MSG_RESULT([no])
1779])
1780CFLAGS=$safe_CFLAGS
1781
1782AC_SUBST(FLAG_OCTEON2)
1783
1784
1785# does this compiler support -mmmx ?
1786AC_MSG_CHECKING([if gcc accepts -mmmx])
1787
1788safe_CFLAGS=$CFLAGS
1789CFLAGS="-mmmx -Werror"
1790
1791AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1792  return 0;
1793]])], [
1794FLAG_MMMX="-mmmx"
1795AC_MSG_RESULT([yes])
1796], [
1797FLAG_MMMX=""
1798AC_MSG_RESULT([no])
1799])
1800CFLAGS=$safe_CFLAGS
1801
1802AC_SUBST(FLAG_MMMX)
1803
1804
1805# does this compiler support -msse ?
1806AC_MSG_CHECKING([if gcc accepts -msse])
1807
1808safe_CFLAGS=$CFLAGS
1809CFLAGS="-msse -Werror"
1810
1811AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1812  return 0;
1813]])], [
1814FLAG_MSSE="-msse"
1815AC_MSG_RESULT([yes])
1816], [
1817FLAG_MSSE=""
1818AC_MSG_RESULT([no])
1819])
1820CFLAGS=$safe_CFLAGS
1821
1822AC_SUBST(FLAG_MSSE)
1823
1824
1825# does this compiler support -mpreferred-stack-boundary=2 when
1826# generating code for a 32-bit target?  Note that we only care about
1827# this when generating code for (32-bit) x86, so if the compiler
1828# doesn't recognise -m32 it's no big deal.  We'll just get code for
1829# the Memcheck and other helper functions, that is a bit slower than
1830# it could be, on x86; and no difference at all on any other platform.
1831AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
1832
1833safe_CFLAGS=$CFLAGS
1834CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
1835
1836AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1837  return 0;
1838]])], [
1839PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
1840AC_MSG_RESULT([yes])
1841], [
1842PREFERRED_STACK_BOUNDARY_2=""
1843AC_MSG_RESULT([no])
1844])
1845CFLAGS=$safe_CFLAGS
1846
1847AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
1848
1849
1850# does this compiler support -mlong-double-128 ?
1851AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
1852safe_CFLAGS=$CFLAGS
1853CFLAGS="-mlong-double-128 -Werror"
1854AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1855  return 0;
1856]])], [
1857ac_compiler_supports_mlong_double_128=yes
1858AC_MSG_RESULT([yes])
1859], [
1860ac_compiler_supports_mlong_double_128=no
1861AC_MSG_RESULT([no])
1862])
1863CFLAGS=$safe_CFLAGS
1864AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
1865FLAG_MLONG_DOUBLE_128="-mlong-double-128"
1866AC_SUBST(FLAG_MLONG_DOUBLE_128)
1867
1868
1869# Convenience function to check whether GCC supports a particular
1870# warning option. Takes two arguments,
1871# first the warning flag name to check (without -W), then the
1872# substitution name to set with -Wno-warning-flag if the flag exists,
1873# or the empty string if the compiler doesn't accept the flag. Note
1874# that checking is done against the warning flag itself, but the
1875# substitution is then done to cancel the warning flag.
1876AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
1877  AC_MSG_CHECKING([if gcc accepts -W$1])
1878  safe_CFLAGS=$CFLAGS
1879  CFLAGS="-W$1 -Werror"
1880  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1881  AC_SUBST([$2], [-Wno-$1])
1882  AC_MSG_RESULT([yes])], [
1883  AC_SUBST([$2], [])
1884  AC_MSG_RESULT([no])])
1885  CFLAGS=$safe_CFLAGS
1886])
1887
1888# Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
1889# -W$1  (instead of -Wno-$1).
1890AC_DEFUN([AC_GCC_WARNING_SUBST],[
1891  AC_MSG_CHECKING([if gcc accepts -W$1])
1892  safe_CFLAGS=$CFLAGS
1893  CFLAGS="-W$1 -Werror"
1894  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1895  AC_SUBST([$2], [-W$1])
1896  AC_MSG_RESULT([yes])], [
1897  AC_SUBST([$2], [])
1898  AC_MSG_RESULT([no])])
1899  CFLAGS=$safe_CFLAGS
1900])
1901
1902AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
1903AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
1904AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
1905AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
1906AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
1907AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
1908AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
1909AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
1910AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
1911AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
1912AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
1913AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
1914# Disabled for now until all platforms are clean
1915format_checking_enabled=no
1916#format_checking_enabled=yes
1917if test "$format_checking_enabled" = "yes"; then
1918   AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
1919else
1920   dumy_assignment_to_avoid_syntax_errors=1
1921   AC_SUBST([FLAG_W_FORMAT_SIGNEDNESS], [])
1922fi
1923AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
1924AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
1925AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
1926AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
1927
1928# Does this compiler support -Wformat-security ?
1929# Special handling is needed, because certain GCC versions require -Wformat
1930# being present if -Wformat-security is given. Otherwise a warning is issued.
1931# However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
1932# And with that the warning will be turned into an error with the result
1933# that -Wformat-security is believed to be unsupported when in fact it is.
1934AC_MSG_CHECKING([if gcc accepts -Wformat-security])
1935safe_CFLAGS=$CFLAGS
1936CFLAGS="-Wformat -Wformat-security -Werror"
1937AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
1938AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
1939AC_MSG_RESULT([yes])], [
1940AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
1941AC_MSG_RESULT([no])])
1942CFLAGS=$safe_CFLAGS
1943
1944# does this compiler support -Wextra or the older -W ?
1945
1946AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
1947
1948safe_CFLAGS=$CFLAGS
1949CFLAGS="-Wextra -Werror"
1950
1951AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1952  return 0;
1953]])], [
1954AC_SUBST([FLAG_W_EXTRA], [-Wextra])
1955AC_MSG_RESULT([-Wextra])
1956], [
1957  CFLAGS="-W -Werror"
1958  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
1959    return 0;
1960  ]])], [
1961  AC_SUBST([FLAG_W_EXTRA], [-W])
1962  AC_MSG_RESULT([-W])
1963  ], [
1964  AC_SUBST([FLAG_W_EXTRA], [])
1965  AC_MSG_RESULT([not supported])
1966  ])
1967])
1968CFLAGS=$safe_CFLAGS
1969
1970# On ARM we do not want to pass -Wcast-align as that produces loads
1971# of warnings. GCC is just being conservative. See here:
1972# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
1973if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
1974  AC_SUBST([FLAG_W_CAST_ALIGN], [""])
1975else
1976  AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
1977fi
1978
1979# does this compiler support -fno-stack-protector ?
1980AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
1981
1982safe_CFLAGS=$CFLAGS
1983CFLAGS="-fno-stack-protector -Werror"
1984
1985AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1986  return 0;
1987]])], [
1988no_stack_protector=yes
1989FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
1990AC_MSG_RESULT([yes])
1991], [
1992no_stack_protector=no
1993FLAG_FNO_STACK_PROTECTOR=""
1994AC_MSG_RESULT([no])
1995])
1996CFLAGS=$safe_CFLAGS
1997
1998AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
1999
2000# Does GCC support disabling Identical Code Folding?
2001# We want to disabled Identical Code Folding for the
2002# tools preload shared objects to get better backraces.
2003# For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2004# "The optimization reduces code size and may disturb
2005#  unwind stacks by replacing a function by equivalent
2006#  one with a different name."
2007AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2008
2009safe_CFLAGS=$CFLAGS
2010CFLAGS="-fno-ipa-icf -Werror"
2011
2012AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2013  return 0;
2014]])], [
2015no_ipa_icf=yes
2016FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2017AC_MSG_RESULT([yes])
2018], [
2019no_ipa_icf=no
2020FLAG_FNO_IPA_ICF=""
2021AC_MSG_RESULT([no])
2022])
2023CFLAGS=$safe_CFLAGS
2024
2025AC_SUBST(FLAG_FNO_IPA_ICF)
2026
2027
2028# Does this compiler support -fsanitize=undefined. This is true for
2029# GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2030# also checks for alignment violations on memory accesses which the valgrind
2031# code base is sprinkled (if not littered) with. As those alignment issues
2032# don't pose a problem we want to suppress warnings about them.
2033# In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2034# GCCs do not support that.
2035#
2036# Only checked for if --enable-ubsan was given.
2037if test "x${vg_cv_ubsan}" = "xyes"; then
2038AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2039safe_CFLAGS=$CFLAGS
2040CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2041AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2042  return 0;
2043]])], [
2044FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2045LIB_UBSAN="-static-libubsan"
2046AC_MSG_RESULT([yes])
2047], [
2048CFLAGS="-fsanitize=undefined -Werror"
2049AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2050  return 0;
2051]])], [
2052FLAG_FSANITIZE="-fsanitize=undefined"
2053LIB_UBSAN="-static-libubsan"
2054AC_MSG_RESULT([yes])
2055], [
2056FLAG_FSANITIZE=""
2057LIB_UBSAN=""
2058AC_MSG_RESULT([no])
2059])
2060])
2061CFLAGS=$safe_CFLAGS
2062AC_SUBST(FLAG_FSANITIZE)
2063AC_SUBST(LIB_UBSAN)
2064fi
2065# does this compiler support --param inline-unit-growth=... ?
2066
2067AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2068
2069safe_CFLAGS=$CFLAGS
2070CFLAGS="--param inline-unit-growth=900 -Werror"
2071
2072AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2073  return 0;
2074]])], [
2075AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2076         ["--param inline-unit-growth=900"])
2077AC_MSG_RESULT([yes])
2078], [
2079AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2080AC_MSG_RESULT([no])
2081])
2082CFLAGS=$safe_CFLAGS
2083
2084
2085# does this compiler support -gdwarf-4 -fdebug-types-section ?
2086
2087AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2088
2089safe_CFLAGS=$CFLAGS
2090CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2091
2092AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2093  return 0;
2094]])], [
2095ac_have_dwarf4=yes
2096AC_MSG_RESULT([yes])
2097], [
2098ac_have_dwarf4=no
2099AC_MSG_RESULT([no])
2100])
2101AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2102CFLAGS=$safe_CFLAGS
2103
2104
2105# does this compiler support nested functions ?
2106
2107AC_MSG_CHECKING([if gcc accepts nested functions])
2108
2109AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2110  int foo() { return 1; }
2111  return foo();
2112]])], [
2113ac_have_nested_functions=yes
2114AC_MSG_RESULT([yes])
2115], [
2116ac_have_nested_functions=no
2117AC_MSG_RESULT([no])
2118])
2119AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2120
2121
2122# does this compiler support the 'p' constraint in ASM statements ?
2123
2124AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2125
2126AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2127   char *p;
2128   __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2129]])], [
2130ac_have_asm_constraint_p=yes
2131AC_MSG_RESULT([yes])
2132], [
2133ac_have_asm_constraint_p=no
2134AC_MSG_RESULT([no])
2135])
2136AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2137
2138
2139# We want to use use the -Ttext-segment option to the linker.
2140# GNU (bfd) ld supports this directly. Newer GNU gold linkers
2141# support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2142# semantics are NOT what we want (GNU gold -Ttext is fine).
2143#
2144# For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2145# will reside. -Ttext aligns just the .text section start (but not any
2146# other section).
2147#
2148# So test for -Ttext-segment which is supported by all bfd ld versions
2149# and use that if it exists. If it doesn't exist it must be an older
2150# version of gold and we can fall back to using -Ttext which has the
2151# right semantics.
2152
2153AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2154
2155safe_CFLAGS=$CFLAGS
2156CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2157
2158AC_LINK_IFELSE(
2159[AC_LANG_SOURCE([int _start () { return 0; }])],
2160[
2161  linker_using_t_text="no"
2162  AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2163  AC_MSG_RESULT([yes])
2164], [
2165  linker_using_t_text="yes"
2166  AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2167  AC_MSG_RESULT([no])
2168])
2169CFLAGS=$safe_CFLAGS
2170
2171# If the linker only supports -Ttext (not -Ttext-segment) then we will
2172# have to strip any build-id ELF NOTEs from the staticly linked tools.
2173# Otherwise the build-id NOTE might end up at the default load address.
2174# (Pedantically if the linker is gold then -Ttext is fine, but newer
2175# gold versions also support -Ttext-segment. So just assume that unless
2176# we can use -Ttext-segment we need to strip the build-id NOTEs.
2177if test "x${linker_using_t_text}" = "xyes"; then
2178AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2179# does the linker support -Wl,--build-id=none ?  Note, it's
2180# important that we test indirectly via whichever C compiler
2181# is selected, rather than testing /usr/bin/ld or whatever
2182# directly.
2183AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2184safe_CFLAGS=$CFLAGS
2185CFLAGS="-Wl,--build-id=none -Werror"
2186
2187AC_LINK_IFELSE(
2188[AC_LANG_PROGRAM([ ], [return 0;])],
2189[
2190  AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2191  AC_MSG_RESULT([yes])
2192], [
2193  AC_SUBST([FLAG_NO_BUILD_ID], [""])
2194  AC_MSG_RESULT([no])
2195])
2196else
2197AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2198AC_SUBST([FLAG_NO_BUILD_ID], [""])
2199fi
2200CFLAGS=$safe_CFLAGS
2201
2202# does the ppc assembler support "mtocrf" et al?
2203AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2204
2205AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2206__asm__ __volatile__("mtocrf 4,0");
2207__asm__ __volatile__("mfocrf 0,4");
2208]])], [
2209ac_have_as_ppc_mftocrf=yes
2210AC_MSG_RESULT([yes])
2211], [
2212ac_have_as_ppc_mftocrf=no
2213AC_MSG_RESULT([no])
2214])
2215if test x$ac_have_as_ppc_mftocrf = xyes ; then
2216  AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2217fi
2218
2219
2220# does the ppc assembler support "lfdp" and other phased out floating point insns?
2221AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2222
2223AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2224  do { typedef struct {
2225      double hi;
2226      double lo;
2227     } dbl_pair_t;
2228     dbl_pair_t dbl_pair[3];
2229     __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2230   } while (0)
2231]])], [
2232ac_have_as_ppc_fpPO=yes
2233AC_MSG_RESULT([yes])
2234], [
2235ac_have_as_ppc_fpPO=no
2236AC_MSG_RESULT([no])
2237])
2238if test x$ac_have_as_ppc_fpPO = xyes ; then
2239  AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2240fi
2241
2242
2243# does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2244AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2245
2246AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2247void* p;
2248asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2249asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2250]])], [
2251ac_have_as_amd64_fxsave64=yes
2252AC_MSG_RESULT([yes])
2253], [
2254ac_have_as_amd64_fxsave64=no
2255AC_MSG_RESULT([no])
2256])
2257if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2258  AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2259fi
2260
2261# does the x86/amd64 assembler understand SSE3 instructions?
2262# Note, this doesn't generate a C-level symbol.  It generates a
2263# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2264AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2265
2266AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2267  do { long long int x;
2268     __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
2269  while (0)
2270]])], [
2271ac_have_as_sse3=yes
2272AC_MSG_RESULT([yes])
2273], [
2274ac_have_as_sse3=no
2275AC_MSG_RESULT([no])
2276])
2277
2278AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2279
2280
2281# Ditto for SSSE3 instructions (note extra S)
2282# Note, this doesn't generate a C-level symbol.  It generates a
2283# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2284AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2285
2286save_CFLAGS="$CFLAGS"
2287CFLAGS="$CFLAGS -msse -Werror"
2288AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2289  do { long long int x;
2290   __asm__ __volatile__(
2291      "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2292  while (0)
2293]])], [
2294ac_have_as_ssse3=yes
2295AC_MSG_RESULT([yes])
2296], [
2297ac_have_as_ssse3=no
2298AC_MSG_RESULT([no])
2299])
2300CFLAGS="$save_CFLAGS"
2301
2302AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2303
2304
2305# does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2306# Note, this doesn't generate a C-level symbol.  It generates a
2307# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2308AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2309AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2310  do {
2311   __asm__ __volatile__(
2312      "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2313  while (0)
2314]])], [
2315ac_have_as_pclmulqdq=yes
2316AC_MSG_RESULT([yes])
2317], [
2318ac_have_as_pclmulqdq=no
2319AC_MSG_RESULT([no])
2320])
2321
2322AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2323
2324
2325# does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2326# Note, this doesn't generate a C-level symbol.  It generates a
2327# automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2328AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2329AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2330  do {
2331      /*
2332       * Carry-less multiplication of xmm1 with xmm2 and store the result in
2333       * xmm3. The immediate is used to determine which quadwords of xmm1 and
2334       * xmm2 should be used.
2335       */
2336   __asm__ __volatile__(
2337      "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2338  } while (0)
2339]])], [
2340ac_have_as_vpclmulqdq=yes
2341AC_MSG_RESULT([yes])
2342], [
2343ac_have_as_vpclmulqdq=no
2344AC_MSG_RESULT([no])
2345])
2346
2347AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2348
2349
2350# does the x86/amd64 assembler understand the LZCNT instruction?
2351# Note, this doesn't generate a C-level symbol.  It generates a
2352# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2353AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2354
2355AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2356  do {
2357      __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2358  } while (0)
2359]])], [
2360  ac_have_as_lzcnt=yes
2361  AC_MSG_RESULT([yes])
2362], [
2363  ac_have_as_lzcnt=no
2364  AC_MSG_RESULT([no])
2365])
2366
2367AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2368
2369
2370# does the x86/amd64 assembler understand the LOOPNEL instruction?
2371# Note, this doesn't generate a C-level symbol.  It generates a
2372# automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2373AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2374
2375AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2376  do {
2377      __asm__ __volatile__("1:  loopnel 1b\n");
2378  } while (0)
2379]])], [
2380  ac_have_as_loopnel=yes
2381  AC_MSG_RESULT([yes])
2382], [
2383  ac_have_as_loopnel=no
2384  AC_MSG_RESULT([no])
2385])
2386
2387AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2388
2389
2390# does the x86/amd64 assembler understand ADDR32 ?
2391# Note, this doesn't generate a C-level symbol.  It generates a
2392# automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2393AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2394
2395AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2396  do {
2397      asm volatile ("addr32 rep movsb");
2398  } while (0)
2399]])], [
2400  ac_have_as_addr32=yes
2401  AC_MSG_RESULT([yes])
2402], [
2403  ac_have_as_addr32=no
2404  AC_MSG_RESULT([no])
2405])
2406
2407AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2408
2409
2410# does the x86/amd64 assembler understand SSE 4.2 instructions?
2411# Note, this doesn't generate a C-level symbol.  It generates a
2412# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2413AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2414
2415AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2416  do { long long int x;
2417   __asm__ __volatile__(
2418      "crc32q %%r15,%%r15" : : : "r15" );
2419   __asm__ __volatile__(
2420      "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2421   __asm__ __volatile__(
2422      "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2423  while (0)
2424]])], [
2425ac_have_as_sse42=yes
2426AC_MSG_RESULT([yes])
2427], [
2428ac_have_as_sse42=no
2429AC_MSG_RESULT([no])
2430])
2431
2432AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2433
2434
2435# does the x86/amd64 assembler understand AVX instructions?
2436# Note, this doesn't generate a C-level symbol.  It generates a
2437# automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2438AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2439
2440AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2441  do { long long int x;
2442   __asm__ __volatile__(
2443      "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2444   __asm__ __volatile__(
2445      "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2446  while (0)
2447]])], [
2448ac_have_as_avx=yes
2449AC_MSG_RESULT([yes])
2450], [
2451ac_have_as_avx=no
2452AC_MSG_RESULT([no])
2453])
2454
2455AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2456
2457
2458# does the x86/amd64 assembler understand AVX2 instructions?
2459# Note, this doesn't generate a C-level symbol.  It generates a
2460# automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2461AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2462
2463AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2464  do { long long int x;
2465   __asm__ __volatile__(
2466      "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2467   __asm__ __volatile__(
2468      "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2469  while (0)
2470]])], [
2471ac_have_as_avx2=yes
2472AC_MSG_RESULT([yes])
2473], [
2474ac_have_as_avx2=no
2475AC_MSG_RESULT([no])
2476])
2477
2478AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2479
2480
2481# does the x86/amd64 assembler understand TSX instructions and
2482# the XACQUIRE/XRELEASE prefixes?
2483# Note, this doesn't generate a C-level symbol.  It generates a
2484# automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2485AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2486
2487AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2488  do {
2489   __asm__ __volatile__(
2490      "       xbegin Lfoo  \n\t"
2491      "Lfoo:  xend         \n\t"
2492      "       xacquire lock incq 0(%rsp)     \n\t"
2493      "       xrelease lock incq 0(%rsp)     \n"
2494   );
2495  } while (0)
2496]])], [
2497ac_have_as_tsx=yes
2498AC_MSG_RESULT([yes])
2499], [
2500ac_have_as_tsx=no
2501AC_MSG_RESULT([no])
2502])
2503
2504AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2505
2506
2507# does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2508# Note, this doesn't generate a C-level symbol.  It generates a
2509# automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2510AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2511
2512AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2513  do { unsigned int h, l;
2514   __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2515   __asm__ __volatile__(
2516      "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2517   __asm__ __volatile__(
2518      "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2519  while (0)
2520]])], [
2521ac_have_as_bmi=yes
2522AC_MSG_RESULT([yes])
2523], [
2524ac_have_as_bmi=no
2525AC_MSG_RESULT([no])
2526])
2527
2528AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2529
2530
2531# does the x86/amd64 assembler understand FMA instructions?
2532# Note, this doesn't generate a C-level symbol.  It generates a
2533# automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2534AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2535
2536AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2537  do { unsigned int h, l;
2538   __asm__ __volatile__(
2539      "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2540   __asm__ __volatile__(
2541      "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2542   __asm__ __volatile__(
2543      "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2544  while (0)
2545]])], [
2546ac_have_as_fma=yes
2547AC_MSG_RESULT([yes])
2548], [
2549ac_have_as_fma=no
2550AC_MSG_RESULT([no])
2551])
2552
2553AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2554
2555
2556# does the amd64 assembler understand MPX instructions?
2557# Note, this doesn't generate a C-level symbol.  It generates a
2558# automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2559AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2560
2561AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2562  do {
2563    asm ("bndmov %bnd0,(%rsp)");
2564    asm ("bndldx 3(%rbx,%rdx), %bnd2");
2565    asm ("bnd call foo\n"
2566          bnd jmp  end\n"
2567          foo: bnd ret\n"
2568          end: nop");
2569  } while (0)
2570]])], [
2571ac_have_as_mpx=yes
2572AC_MSG_RESULT([yes])
2573], [
2574ac_have_as_mpx=no
2575AC_MSG_RESULT([no])
2576])
2577
2578AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2579
2580
2581# Does the C compiler support the "ifunc" attribute
2582# Note, this doesn't generate a C-level symbol.  It generates a
2583# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2584# does the x86/amd64 assembler understand MOVBE?
2585# Note, this doesn't generate a C-level symbol.  It generates a
2586# automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
2587AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
2588
2589AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2590  do { long long int x;
2591   __asm__ __volatile__(
2592      "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
2593  while (0)
2594]])], [
2595ac_have_as_movbe=yes
2596AC_MSG_RESULT([yes])
2597], [
2598ac_have_as_movbe=no
2599AC_MSG_RESULT([no])
2600])
2601
2602AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
2603
2604
2605# Does the C compiler support the "ifunc" attribute
2606# Note, this doesn't generate a C-level symbol.  It generates a
2607# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
2608AC_MSG_CHECKING([if gcc supports the ifunc attribute])
2609
2610AC_LINK_IFELSE([AC_LANG_SOURCE([[
2611static void mytest(void) {}
2612
2613static void (*resolve_test(void))(void)
2614{
2615    return (void (*)(void))&mytest;
2616}
2617
2618void test(void) __attribute__((ifunc("resolve_test")));
2619
2620int main()
2621{
2622    test();
2623    return 0;
2624}
2625]])], [
2626ac_have_ifunc_attr=yes
2627AC_MSG_RESULT([yes])
2628], [
2629ac_have_ifunc_attr=no
2630AC_MSG_RESULT([no])
2631])
2632
2633AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
2634
2635
2636# XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
2637# when building the tool executables.  I think we should get rid of it.
2638#
2639# Check for TLS support in the compiler and linker
2640AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2641                                [[return foo;]])],
2642                               [vg_cv_linktime_tls=yes],
2643                               [vg_cv_linktime_tls=no])
2644# Native compilation: check whether running a program using TLS succeeds.
2645# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
2646# succeeds but running programs using TLS fails.
2647# Cross-compiling: check whether linking a program using TLS succeeds.
2648AC_CACHE_CHECK([for TLS support], vg_cv_tls,
2649	       [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
2650		[vg_cv_tls=$enableval],
2651               	[AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
2652                                                [[return foo;]])],
2653                               [vg_cv_tls=yes],
2654                               [vg_cv_tls=no],
2655                               [vg_cv_tls=$vg_cv_linktime_tls])])])
2656
2657if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
2658AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
2659fi
2660
2661
2662#----------------------------------------------------------------------------
2663# Solaris-specific checks.
2664#----------------------------------------------------------------------------
2665
2666if test "$VGCONF_OS" = "solaris" ; then
2667# Solaris-specific check determining if the Sun Studio Assembler is used to
2668# build Valgrind.  The test checks if the x86/amd64 assembler understands the
2669# cmovl.l instruction, if yes then it's Sun Assembler.
2670#
2671# C-level symbol: none
2672# Automake-level symbol: SOLARIS_SUN_STUDIO_AS
2673#
2674AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
2675AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2676]], [[
2677  __asm__ __volatile__("cmovl.l %edx, %eax");
2678]])], [
2679solaris_have_sun_studio_as=yes
2680AC_MSG_RESULT([yes])
2681], [
2682solaris_have_sun_studio_as=no
2683AC_MSG_RESULT([no])
2684])
2685AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
2686
2687# Solaris-specific check determining if symbols __xpg4 and __xpg6
2688# are present in linked elfs when gcc is invoked with -std=gnu99.
2689# See solaris/vgpreload-solaris.mapfile for details.
2690# gcc on Solaris instructs linker to include these symbols,
2691# gcc on illumos does not.
2692#
2693# C-level symbol: none
2694# Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
2695#
2696save_CFLAGS="$CFLAGS"
2697CFLAGS="$CFLAGS -std=gnu99"
2698AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
2699AC_RUN_IFELSE([AC_LANG_SOURCE([[
2700#include <limits.h>
2701#include <stdio.h>
2702#include <stdlib.h>
2703
2704int main(int argc, const char *argv[]) {
2705    char command[PATH_MAX + 50];
2706    snprintf(command, sizeof(command), "nm %s | egrep '__xpg[4,6]'", argv[0]);
2707
2708    FILE *output = popen(command, "r");
2709    if (output == NULL) return -1;
2710
2711    char buf[100];
2712    if (fgets(buf, sizeof(buf), output) != NULL) {
2713        pclose(output);
2714        return 0;
2715    } else {
2716        pclose(output);
2717        return 1;
2718    }
2719}
2720]])], [
2721solaris_xpg_symbols_present=yes
2722AC_MSG_RESULT([yes])
2723], [
2724solaris_xpg_symbols_present=no
2725AC_MSG_RESULT([no])
2726])
2727AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
2728CFLAGS="$save_CFLAGS"
2729
2730
2731# Solaris-specific check determining if /proc/self/cmdline
2732# or /proc/<pid>/cmdline is supported.
2733#
2734# C-level symbol: SOLARIS_PROC_CMDLINE
2735# Automake-level symbol: SOLARIS_PROC_CMDLINE
2736#
2737AC_CHECK_FILE([/proc/self/cmdline],
2738[
2739solaris_proc_cmdline=yes
2740AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
2741          [Define to 1 if you have /proc/self/cmdline.])
2742], [
2743solaris_proc_cmdline=no
2744])
2745AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
2746
2747
2748# Solaris-specific check determining default platform for the Valgrind launcher.
2749# Used in case the launcher cannot select platform by looking at the client
2750# image (for example because the executable is a shell script).
2751#
2752# C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
2753# Automake-level symbol: none
2754#
2755AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
2756# Get the ELF class of /bin/sh first.
2757if ! test -f /bin/sh; then
2758  AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
2759fi
2760elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
2761case "$elf_class" in
2762  64)
2763    default_arch="$VGCONF_ARCH_PRI";
2764    ;;
2765  32)
2766    if test "x$VGCONF_ARCH_SEC" != "x"; then
2767      default_arch="$VGCONF_ARCH_SEC"
2768    else
2769      default_arch="$VGCONF_ARCH_PRI";
2770    fi
2771    ;;
2772  *)
2773    AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
2774    ;;
2775esac
2776default_platform="$default_arch-$VGCONF_OS"
2777AC_MSG_RESULT([$default_platform])
2778AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
2779                   [Default platform for Valgrind launcher.])
2780
2781
2782# Solaris-specific check determining if the old syscalls are available.
2783#
2784# C-level symbol: SOLARIS_OLD_SYSCALLS
2785# Automake-level symbol: SOLARIS_OLD_SYSCALLS
2786#
2787AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
2788AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2789#include <sys/syscall.h>
2790]], [[
2791  return !SYS_open;
2792]])], [
2793solaris_old_syscalls=yes
2794AC_MSG_RESULT([yes])
2795AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
2796          [Define to 1 if you have the old Solaris syscalls.])
2797], [
2798solaris_old_syscalls=no
2799AC_MSG_RESULT([no])
2800])
2801AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
2802
2803
2804# Solaris-specific check determining if the new accept() syscall is available.
2805#
2806# Old syscall:
2807# int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
2808#            int version);
2809#
2810# New syscall (available on illumos):
2811# int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
2812#            int version, int flags);
2813#
2814# If the old syscall is present then the following syscall will fail with
2815# ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
2816# available then it will fail with EINVAL (because the flags parameter is
2817# invalid).
2818#
2819# C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
2820# Automake-level symbol: none
2821#
2822AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
2823AC_RUN_IFELSE([AC_LANG_PROGRAM([[
2824#include <sys/syscall.h>
2825#include <errno.h>
2826]], [[
2827  errno = 0;
2828  syscall(SYS_accept, 0, 0, 0, 0, -1);
2829  return !(errno == EINVAL);
2830]])], [
2831AC_MSG_RESULT([yes])
2832AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
2833          [Define to 1 if you have the new `accept' syscall.])
2834], [
2835AC_MSG_RESULT([no])
2836])
2837
2838
2839# Solaris-specific check determining if the new illumos pipe() syscall is
2840# available.
2841#
2842# Old syscall:
2843# longlong_t pipe();
2844#
2845# New syscall (available on illumos):
2846# int pipe(intptr_t arg, int flags);
2847#
2848# If the old syscall is present then the following call will succeed, if the
2849# new syscall is available then it will fail with EFAULT (because address 0
2850# cannot be accessed).
2851#
2852# C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
2853# Automake-level symbol: none
2854#
2855AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
2856AC_RUN_IFELSE([AC_LANG_PROGRAM([[
2857#include <sys/syscall.h>
2858#include <errno.h>
2859]], [[
2860  errno = 0;
2861  syscall(SYS_pipe, 0, 0);
2862  return !(errno == EFAULT);
2863]])], [
2864AC_MSG_RESULT([yes])
2865AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
2866          [Define to 1 if you have the new `pipe' syscall.])
2867], [
2868AC_MSG_RESULT([no])
2869])
2870
2871
2872# Solaris-specific check determining if the new lwp_sigqueue() syscall is
2873# available.
2874#
2875# Old syscall:
2876# int lwp_kill(id_t lwpid, int sig);
2877#
2878# New syscall (available on Solaris 11):
2879# int lwp_sigqueue(id_t lwpid, int sig, void *value,
2880#                  int si_code, timespec_t *timeout);
2881#
2882# C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
2883# Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
2884#
2885AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
2886AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2887#include <sys/syscall.h>
2888]], [[
2889  return !SYS_lwp_sigqueue;
2890]])], [
2891solaris_lwp_sigqueue_syscall=yes
2892AC_MSG_RESULT([yes])
2893AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
2894          [Define to 1 if you have the new `lwp_sigqueue' syscall.])
2895], [
2896solaris_lwp_sigqueue_syscall=no
2897AC_MSG_RESULT([no])
2898])
2899AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
2900
2901
2902# Solaris-specific check determining if the lwp_sigqueue() syscall
2903# takes both pid and thread id arguments or just thread id.
2904#
2905# Old syscall (available on Solaris 11.x):
2906# int lwp_sigqueue(id_t lwpid, int sig, void *value,
2907#                  int si_code, timespec_t *timeout);
2908#
2909# New syscall (available on Solaris 12):
2910# int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
2911#                  int si_code, timespec_t *timeout);
2912#
2913# If the old syscall is present then the following syscall will fail with
2914# EINVAL (because signal is out of range); if the new syscall is available
2915# then it will fail with ESRCH (because it would not find such thread in the
2916# current process).
2917#
2918# C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
2919# Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
2920#
2921AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
2922AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
2923AC_RUN_IFELSE([AC_LANG_PROGRAM([[
2924#include <sys/syscall.h>
2925#include <errno.h>
2926]], [[
2927  errno = 0;
2928  syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
2929  return !(errno == ESRCH);
2930]])], [
2931solaris_lwp_sigqueue_syscall_takes_pid=yes
2932AC_MSG_RESULT([yes])
2933AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
2934          [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
2935], [
2936solaris_lwp_sigqueue_syscall_takes_pid=no
2937AC_MSG_RESULT([no])
2938])
2939AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
2940               test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
2941,
2942AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
2943)
2944
2945
2946# Solaris-specific check determining if the new lwp_name() syscall is
2947# available.
2948#
2949# New syscall (available on Solaris 11):
2950# int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
2951#
2952# C-level symbol: SOLARIS_LWP_NAME_SYSCALL
2953# Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
2954#
2955AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
2956AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2957#include <sys/syscall.h>
2958]], [[
2959  return !SYS_lwp_name;
2960]])], [
2961solaris_lwp_name_syscall=yes
2962AC_MSG_RESULT([yes])
2963AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
2964          [Define to 1 if you have the new `lwp_name' syscall.])
2965], [
2966solaris_lwp_name_syscall=no
2967AC_MSG_RESULT([no])
2968])
2969AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
2970
2971
2972# Solaris-specific check determining if the new zone() syscall subcodes
2973# ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
2974# were added in Solaris 11 but are missing on illumos.
2975#
2976# C-level symbol: SOLARIS_ZONE_DEFUNCT
2977# Automake-level symbol: SOLARIS_ZONE_DEFUNCT
2978#
2979AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
2980AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2981#include <sys/zone.h>
2982]], [[
2983  return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
2984]])], [
2985solaris_zone_defunct=yes
2986AC_MSG_RESULT([yes])
2987AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
2988          [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
2989], [
2990solaris_zone_defunct=no
2991AC_MSG_RESULT([no])
2992])
2993AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
2994
2995
2996# Solaris-specific check determining if the new shmsys() syscall subcodes
2997# IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
2998# These subcodes were added in Solaris 11 but are missing on illumos.
2999#
3000# C-level symbol: SOLARIS_SHM_NEW
3001# Automake-level symbol: SOLARIS_SHM_NEW
3002#
3003AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3004AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3005#include <sys/ipc_impl.h>
3006#include <sys/shm.h>
3007#include <sys/shm_impl.h>
3008]], [[
3009  return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3010]])], [
3011solaris_shm_new=yes
3012AC_MSG_RESULT([yes])
3013AC_DEFINE([SOLARIS_SHM_NEW], 1,
3014          [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3015], [
3016solaris_shm_new=no
3017AC_MSG_RESULT([no])
3018])
3019AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3020
3021
3022# Solaris-specific check determining if prxregset_t is available.  Illumos
3023# currently does not define it on the x86 platform.
3024#
3025# C-level symbol: SOLARIS_PRXREGSET_T
3026# Automake-level symbol: SOLARIS_PRXREGSET_T
3027#
3028AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3029AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3030#include <sys/procfs_isa.h>
3031]], [[
3032  return !sizeof(prxregset_t);
3033]])], [
3034solaris_prxregset_t=yes
3035AC_MSG_RESULT([yes])
3036AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3037          [Define to 1 if you have the `prxregset_t' type.])
3038], [
3039solaris_prxregset_t=no
3040AC_MSG_RESULT([no])
3041])
3042AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3043
3044
3045# Solaris-specific check determining if the new frealpathat() syscall is
3046# available.
3047#
3048# New syscall (available on Solaris 11.1):
3049# int frealpathat(int fd, char *path, char *buf, size_t buflen);
3050#
3051# C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3052# Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3053#
3054AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3055AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3056#include <sys/syscall.h>
3057]], [[
3058  return !SYS_frealpathat;
3059]])], [
3060solaris_frealpathat_syscall=yes
3061AC_MSG_RESULT([yes])
3062AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3063          [Define to 1 if you have the new `frealpathat' syscall.])
3064], [
3065solaris_frealpathat_syscall=no
3066AC_MSG_RESULT([no])
3067])
3068AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3069
3070
3071# Solaris-specific check determining if the new uuidsys() syscall is
3072# available.
3073#
3074# New syscall (available on newer Solaris):
3075# int uuidsys(struct uuid *uuid);
3076#
3077# C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3078# Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3079#
3080AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3081AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3082#include <sys/syscall.h>
3083]], [[
3084  return !SYS_uuidsys;
3085]])], [
3086solaris_uuidsys_syscall=yes
3087AC_MSG_RESULT([yes])
3088AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
3089          [Define to 1 if you have the new `uuidsys' syscall.])
3090], [
3091solaris_uuidsys_syscall=no
3092AC_MSG_RESULT([no])
3093])
3094AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
3095
3096
3097# Solaris-specific check determining if the new labelsys() syscall subcode
3098# TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
3099# missing on illumos.
3100#
3101# C-level symbol: SOLARIS_TNDB_GET_TNIP
3102# Automake-level symbol: SOLARIS_TNDB_GET_TNIP
3103#
3104AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
3105AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3106#include <sys/tsol/tndb.h>
3107]], [[
3108  return !TNDB_GET_TNIP;
3109]])], [
3110solaris_tndb_get_tnip=yes
3111AC_MSG_RESULT([yes])
3112AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
3113          [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
3114], [
3115solaris_tndb_get_tnip=no
3116AC_MSG_RESULT([no])
3117])
3118AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
3119
3120
3121# Solaris-specific check determining if the new labelsys() syscall opcodes
3122# TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
3123# added in Solaris 11 but are missing on illumos.
3124#
3125# C-level symbol: SOLARIS_TSOL_CLEARANCE
3126# Automake-level symbol: SOLARIS_TSOL_CLEARANCE
3127#
3128AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
3129AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3130#include <sys/tsol/tsyscall.h>
3131]], [[
3132  return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
3133]])], [
3134solaris_tsol_clearance=yes
3135AC_MSG_RESULT([yes])
3136AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
3137          [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
3138], [
3139solaris_tsol_clearance=no
3140AC_MSG_RESULT([no])
3141])
3142AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
3143
3144
3145# Solaris-specific check determining if the new pset() syscall subcode
3146# PSET_GET_NAME is available. This subcode was added in Solaris 12 but
3147# is missing on illumos and Solaris 11.
3148#
3149# C-level symbol: SOLARIS_PSET_GET_NAME
3150# Automake-level symbol: SOLARIS_PSET_GET_NAME
3151#
3152AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
3153AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3154#include <sys/pset.h>
3155]], [[
3156  return !(PSET_GET_NAME);
3157]])], [
3158solaris_pset_get_name=yes
3159AC_MSG_RESULT([yes])
3160AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
3161          [Define to 1 if you have the `PSET_GET_NAME' constants.])
3162], [
3163solaris_pset_get_name=no
3164AC_MSG_RESULT([no])
3165])
3166AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
3167
3168
3169# Solaris-specific check determining if the utimesys() syscall is
3170# available (on illumos and older Solaris).
3171#
3172# C-level symbol: SOLARIS_UTIMESYS_SYSCALL
3173# Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
3174#
3175AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
3176AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3177#include <sys/syscall.h>
3178]], [[
3179  return !SYS_utimesys;
3180]])], [
3181solaris_utimesys_syscall=yes
3182AC_MSG_RESULT([yes])
3183AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
3184          [Define to 1 if you have the `utimesys' syscall.])
3185], [
3186solaris_utimesys_syscall=no
3187AC_MSG_RESULT([no])
3188])
3189AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
3190
3191
3192# Solaris-specific check determining if the utimensat() syscall is
3193# available (on newer Solaris).
3194#
3195# C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3196# Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3197#
3198AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
3199AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3200#include <sys/syscall.h>
3201]], [[
3202  return !SYS_utimensat;
3203]])], [
3204solaris_utimensat_syscall=yes
3205AC_MSG_RESULT([yes])
3206AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
3207          [Define to 1 if you have the `utimensat' syscall.])
3208], [
3209solaris_utimensat_syscall=no
3210AC_MSG_RESULT([no])
3211])
3212AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
3213
3214
3215# Solaris-specific check determining if the spawn() syscall is available
3216# (on newer Solaris).
3217#
3218# C-level symbol: SOLARIS_SPAWN_SYSCALL
3219# Automake-level symbol: SOLARIS_SPAWN_SYSCALL
3220#
3221AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
3222AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3223#include <sys/syscall.h>
3224]], [[
3225  return !SYS_spawn;
3226]])], [
3227solaris_spawn_syscall=yes
3228AC_MSG_RESULT([yes])
3229AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
3230          [Define to 1 if you have the `spawn' syscall.])
3231], [
3232solaris_spawn_syscall=no
3233AC_MSG_RESULT([no])
3234])
3235AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
3236
3237
3238# Solaris-specific check determining whether nscd (name switch cache daemon)
3239# attaches its door at /system/volatile/name_service_door (Solaris)
3240# or at /var/run/name_service_door (illumos).
3241#
3242# Note that /var/run is a symlink to /system/volatile on Solaris
3243# but not vice versa on illumos.
3244#
3245# C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3246# Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3247#
3248AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
3249if test -e /system/volatile/name_service_door; then
3250    solaris_nscd_door_system_volatile=yes
3251    AC_MSG_RESULT([/system/volatile/name_service_door])
3252    AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
3253              [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
3254else
3255    solaris_nscd_door_system_volatile=no
3256    AC_MSG_RESULT([/var/run/name_service_door])
3257fi
3258AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
3259
3260
3261# Solaris-specific check determining if the new gethrt() fasttrap is available.
3262#
3263# New fasttrap (available on Solaris 11):
3264# hrt_t *gethrt(void);
3265#
3266# C-level symbol: SOLARIS_GETHRT_FASTTRAP
3267# Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
3268#
3269AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
3270AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3271#include <sys/trap.h>
3272]], [[
3273  return !T_GETHRT;
3274]])], [
3275solaris_gethrt_fasttrap=yes
3276AC_MSG_RESULT([yes])
3277AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
3278          [Define to 1 if you have the new `gethrt' fasttrap.])
3279], [
3280solaris_gethrt_fasttrap=no
3281AC_MSG_RESULT([no])
3282])
3283AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
3284
3285
3286# Solaris-specific check determining if the new get_zone_offset() fasttrap
3287# is available.
3288#
3289# New fasttrap (available on Solaris 11):
3290# zonehrtoffset_t *get_zone_offset(void);
3291#
3292# C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3293# Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3294#
3295AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
3296AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3297#include <sys/trap.h>
3298]], [[
3299  return !T_GETZONEOFFSET;
3300]])], [
3301solaris_getzoneoffset_fasttrap=yes
3302AC_MSG_RESULT([yes])
3303AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
3304          [Define to 1 if you have the new `get_zone_offset' fasttrap.])
3305], [
3306solaris_getzoneoffset_fasttrap=no
3307AC_MSG_RESULT([no])
3308])
3309AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
3310
3311
3312# Solaris-specific check determining if the execve() syscall
3313# takes fourth argument (flags) or not.
3314#
3315# Old syscall (available on illumos):
3316# int execve(const char *fname, const char **argv, const char **envp);
3317#
3318# New syscall (available on Solaris):
3319# int execve(uintptr_t file, const char **argv, const char **envp, int flags);
3320#
3321# If the new syscall is present then it will fail with EINVAL (because flags
3322# are invalid); if the old syscall is available then it will fail with ENOENT
3323# (because the file could not be found).
3324#
3325# C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3326# Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3327#
3328AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
3329AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3330#include <sys/syscall.h>
3331#include <errno.h>
3332]], [[
3333  errno = 0;
3334  syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
3335  return !(errno == EINVAL);
3336]])], [
3337solaris_execve_syscall_takes_flags=yes
3338AC_MSG_RESULT([yes])
3339AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
3340          [Define to 1 if you have the new `execve' syscall which accepts flags.])
3341], [
3342solaris_execve_syscall_takes_flags=no
3343AC_MSG_RESULT([no])
3344])
3345AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
3346               test x$solaris_execve_syscall_takes_flags = xyes)
3347
3348
3349# Solaris-specific check determining version of the repository cache protocol.
3350# Every Solaris version uses a different one, ranging from 21 to current 25.
3351# The check is very ugly, though.
3352#
3353# C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
3354# Automake-level symbol: none
3355#
3356AC_PATH_PROG(DIS_PATH, dis, false)
3357if test "x$DIS_PATH" = "xfalse"; then
3358  AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
3359fi
3360AC_CHECK_LIB(scf, scf_handle_bind, [], [
3361  AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
3362  AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3363])
3364
3365AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
3366if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
3367  libscf=/usr/lib/64/libscf.so.1
3368else
3369  libscf=/usr/lib/libscf.so.1
3370fi
3371if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
3372  AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
3373  AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3374fi
3375hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
3376if test -z "$hex"; then
3377  AC_MSG_WARN([Version of the repository cache protocol is empty?!])
3378  AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3379fi
3380version=$( printf "%d\n" 0x$hex )
3381AC_MSG_RESULT([$version])
3382AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
3383                   [Version number of the repository door cache protocol.])
3384
3385
3386# Solaris-specific check determining if "sysstat" segment reservation type
3387# is available.
3388#
3389# New "sysstat" segment reservation (available on Solaris 12):
3390# - program header type:    PT_SUNW_SYSSTAT
3391# - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
3392#
3393# C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
3394# Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
3395#
3396AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
3397AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3398#include <sys/auxv.h>
3399]], [[
3400  return !AT_SUN_SYSSTAT_ADDR;
3401]])], [
3402solaris_reserve_sysstat_addr=yes
3403AC_MSG_RESULT([yes])
3404AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
3405          [Define to 1 if you have the new `sysstat' segment reservation.])
3406], [
3407solaris_reserve_sysstat_addr=no
3408AC_MSG_RESULT([no])
3409])
3410AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
3411
3412
3413# Solaris-specific check determining if "sysstat_zone" segment reservation type
3414# is available.
3415#
3416# New "sysstat_zone" segment reservation (available on Solaris 12):
3417# - program header type:    PT_SUNW_SYSSTAT_ZONE
3418# - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
3419#
3420# C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
3421# Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
3422#
3423AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
3424AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3425#include <sys/auxv.h>
3426]], [[
3427  return !AT_SUN_SYSSTAT_ZONE_ADDR;
3428]])], [
3429solaris_reserve_sysstat_zone_addr=yes
3430AC_MSG_RESULT([yes])
3431AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
3432          [Define to 1 if you have the new `sysstat_zone' segment reservation.])
3433], [
3434solaris_reserve_sysstat_zone_addr=no
3435AC_MSG_RESULT([no])
3436])
3437AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
3438
3439
3440# Solaris-specific check determining if the system_stats() syscall is available
3441# (on newer Solaris).
3442#
3443# C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
3444# Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
3445#
3446AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
3447AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3448#include <sys/syscall.h>
3449]], [[
3450  return !SYS_system_stats;
3451]])], [
3452solaris_system_stats_syscall=yes
3453AC_MSG_RESULT([yes])
3454AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
3455          [Define to 1 if you have the `system_stats' syscall.])
3456], [
3457solaris_system_stats_syscall=no
3458AC_MSG_RESULT([no])
3459])
3460AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
3461
3462else
3463AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
3464AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
3465AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
3466AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
3467AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
3468AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
3469AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
3470AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
3471AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
3472AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
3473AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
3474AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
3475AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
3476AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
3477AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
3478AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
3479AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
3480AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
3481AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
3482AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
3483AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
3484AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
3485AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
3486AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
3487AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
3488fi # test "$VGCONF_OS" = "solaris"
3489
3490
3491#----------------------------------------------------------------------------
3492# Checks for C header files.
3493#----------------------------------------------------------------------------
3494
3495AC_HEADER_STDC
3496AC_CHECK_HEADERS([       \
3497        asm/unistd.h     \
3498        endian.h         \
3499        mqueue.h         \
3500        sys/endian.h     \
3501        sys/epoll.h      \
3502        sys/eventfd.h    \
3503        sys/klog.h       \
3504        sys/poll.h       \
3505        sys/prctl.h      \
3506        sys/signal.h     \
3507        sys/signalfd.h   \
3508        sys/syscall.h    \
3509        sys/time.h       \
3510        sys/types.h      \
3511        ])
3512
3513# Verify whether the <linux/futex.h> header is usable.
3514AC_MSG_CHECKING([if <linux/futex.h> is usable])
3515
3516save_CFLAGS="$CFLAGS"
3517CFLAGS="$CFLAGS -D__user="
3518AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3519#include <linux/futex.h>
3520]], [[
3521  return FUTEX_WAIT;
3522]])], [
3523ac_have_usable_linux_futex_h=yes
3524AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
3525          [Define to 1 if you have a usable <linux/futex.h> header file.])
3526AC_MSG_RESULT([yes])
3527], [
3528ac_have_usable_linux_futex_h=no
3529AC_MSG_RESULT([no])
3530])
3531CFLAGS="$save_CFLAGS"
3532
3533
3534#----------------------------------------------------------------------------
3535# Checks for typedefs, structures, and compiler characteristics.
3536#----------------------------------------------------------------------------
3537AC_TYPE_UID_T
3538AC_TYPE_OFF_T
3539AC_TYPE_SIZE_T
3540AC_HEADER_TIME
3541
3542
3543#----------------------------------------------------------------------------
3544# Checks for library functions.
3545#----------------------------------------------------------------------------
3546AC_FUNC_MEMCMP
3547AC_FUNC_MMAP
3548
3549AC_CHECK_LIB([pthread], [pthread_create])
3550AC_CHECK_LIB([rt], [clock_gettime])
3551
3552AC_CHECK_FUNCS([     \
3553        clock_gettime\
3554        epoll_create \
3555        epoll_pwait  \
3556        klogctl      \
3557        mallinfo     \
3558        memchr       \
3559        memset       \
3560        mkdir        \
3561        mremap       \
3562        ppoll        \
3563        pthread_barrier_init       \
3564        pthread_condattr_setclock  \
3565        pthread_mutex_timedlock    \
3566        pthread_rwlock_timedrdlock \
3567        pthread_rwlock_timedwrlock \
3568        pthread_spin_lock          \
3569        pthread_yield              \
3570        pthread_setname_np         \
3571        readlinkat   \
3572        semtimedop   \
3573        signalfd     \
3574        sigwaitinfo  \
3575        strchr       \
3576        strdup       \
3577        strpbrk      \
3578        strrchr      \
3579        strstr       \
3580        syscall      \
3581        utimensat    \
3582        process_vm_readv  \
3583        process_vm_writev \
3584        ])
3585
3586# AC_CHECK_LIB adds any library found to the variable LIBS, and links these
3587# libraries with any shared object and/or executable. This is NOT what we
3588# want for e.g. vgpreload_core-x86-linux.so
3589LIBS=""
3590
3591AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
3592               [test x$ac_cv_func_pthread_barrier_init = xyes])
3593AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
3594               [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
3595AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
3596               [test x$ac_cv_func_pthread_spin_lock = xyes])
3597AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
3598               [test x$ac_cv_func_pthread_setname_np = xyes])
3599
3600if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
3601     -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then
3602  AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
3603            [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.])
3604fi
3605
3606#----------------------------------------------------------------------------
3607# MPI checks
3608#----------------------------------------------------------------------------
3609# Do we have a useable MPI setup on the primary and/or secondary targets?
3610# On Linux, by default, assumes mpicc and -m32/-m64
3611# Note: this is a kludge in that it assumes the specified mpicc
3612# understands -m32/-m64 regardless of what is specified using
3613# --with-mpicc=.
3614AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
3615             [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
3616
3617mflag_primary=
3618if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
3619     -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
3620     -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
3621     -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
3622     -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
3623     -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
3624  mflag_primary=$FLAG_M32
3625elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
3626       -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
3627       -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
3628       -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
3629  mflag_primary=$FLAG_M64
3630elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
3631  mflag_primary="$FLAG_M32 -arch i386"
3632elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
3633  mflag_primary="$FLAG_M64 -arch x86_64"
3634fi
3635
3636mflag_secondary=
3637if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
3638     -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
3639     -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS ; then
3640  mflag_secondary=$FLAG_M32
3641elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
3642  mflag_secondary="$FLAG_M32 -arch i386"
3643fi
3644
3645
3646AC_ARG_WITH(mpicc,
3647   [  --with-mpicc=           Specify name of MPI2-ised C compiler],
3648   MPI_CC=$withval
3649)
3650AC_SUBST(MPI_CC)
3651
3652## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
3653## use these values in the check for a functioning mpicc.
3654##
3655## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
3656## mflag_primary/mflag_secondary are sufficient approximations of that behavior
3657AM_COND_IF([VGCONF_OS_IS_LINUX],
3658           [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
3659            LDFLAGS_MPI="-fpic -shared"])
3660AM_COND_IF([VGCONF_OS_IS_DARWIN],
3661           [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
3662            LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
3663AM_COND_IF([VGCONF_OS_IS_SOLARIS],
3664           [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
3665            LDFLAGS_MPI="-fpic -shared"])
3666
3667AC_SUBST([CFLAGS_MPI])
3668AC_SUBST([LDFLAGS_MPI])
3669
3670
3671## See if MPI_CC works for the primary target
3672##
3673AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
3674saved_CC=$CC
3675saved_CFLAGS=$CFLAGS
3676CC=$MPI_CC
3677CFLAGS="$CFLAGS_MPI $mflag_primary"
3678saved_LDFLAGS="$LDFLAGS"
3679LDFLAGS="$LDFLAGS_MPI $mflag_primary"
3680AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3681#include <mpi.h>
3682#include <stdio.h>
3683]], [[
3684  int ni, na, nd, comb;
3685  int r = MPI_Init(NULL,NULL);
3686  r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
3687  r |= MPI_Finalize();
3688  return r;
3689]])], [
3690ac_have_mpi2_pri=yes
3691AC_MSG_RESULT([yes, $MPI_CC])
3692], [
3693ac_have_mpi2_pri=no
3694AC_MSG_RESULT([no])
3695])
3696CC=$saved_CC
3697CFLAGS=$saved_CFLAGS
3698LDFLAGS="$saved_LDFLAGS"
3699AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
3700
3701## See if MPI_CC works for the secondary target.  Complication: what if
3702## there is no secondary target?  We need this to then fail.
3703## Kludge this by making MPI_CC something which will surely fail in
3704## such a case.
3705##
3706AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
3707saved_CC=$CC
3708saved_CFLAGS=$CFLAGS
3709saved_LDFLAGS="$LDFLAGS"
3710LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
3711if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
3712  CC="$MPI_CC this will surely fail"
3713else
3714  CC=$MPI_CC
3715fi
3716CFLAGS="$CFLAGS_MPI $mflag_secondary"
3717AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3718#include <mpi.h>
3719#include <stdio.h>
3720]], [[
3721  int ni, na, nd, comb;
3722  int r = MPI_Init(NULL,NULL);
3723  r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
3724  r |= MPI_Finalize();
3725  return r;
3726]])], [
3727ac_have_mpi2_sec=yes
3728AC_MSG_RESULT([yes, $MPI_CC])
3729], [
3730ac_have_mpi2_sec=no
3731AC_MSG_RESULT([no])
3732])
3733CC=$saved_CC
3734CFLAGS=$saved_CFLAGS
3735LDFLAGS="$saved_LDFLAGS"
3736AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
3737
3738
3739#----------------------------------------------------------------------------
3740# Other library checks
3741#----------------------------------------------------------------------------
3742# There now follow some tests for Boost, and OpenMP.  These
3743# tests are present because Drd has some regression tests that use
3744# these packages.  All regression test programs all compiled only
3745# for the primary target.  And so it is important that the configure
3746# checks that follow, use the correct -m32 or -m64 flag for the
3747# primary target (called $mflag_primary).  Otherwise, we can end up
3748# in a situation (eg) where, on amd64-linux, the test for Boost checks
3749# for usable 64-bit Boost facilities, but because we are doing a 32-bit
3750# only build (meaning, the primary target is x86-linux), the build
3751# of the regtest programs that use Boost fails, because they are
3752# build as 32-bit (IN THIS EXAMPLE).
3753#
3754# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
3755# NEEDED BY THE REGRESSION TEST PROGRAMS.
3756
3757
3758# Check whether the boost library 1.35 or later has been installed.
3759# The Boost.Threads library has undergone a major rewrite in version 1.35.0.
3760
3761AC_MSG_CHECKING([for boost])
3762
3763AC_LANG(C++)
3764safe_CXXFLAGS=$CXXFLAGS
3765CXXFLAGS="$mflag_primary"
3766safe_LIBS="$LIBS"
3767LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
3768
3769AC_LINK_IFELSE([AC_LANG_SOURCE([
3770#include <boost/thread.hpp>
3771static void thread_func(void)
3772{ }
3773int main(int argc, char** argv)
3774{
3775  boost::thread t(thread_func);
3776  return 0;
3777}
3778])],
3779[
3780ac_have_boost_1_35=yes
3781AC_SUBST([BOOST_CFLAGS], [])
3782AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
3783AC_MSG_RESULT([yes])
3784], [
3785ac_have_boost_1_35=no
3786AC_MSG_RESULT([no])
3787])
3788
3789LIBS="$safe_LIBS"
3790CXXFLAGS=$safe_CXXFLAGS
3791AC_LANG(C)
3792
3793AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
3794
3795
3796# does this compiler support -fopenmp, does it have the include file
3797# <omp.h> and does it have libgomp ?
3798
3799AC_MSG_CHECKING([for OpenMP])
3800
3801safe_CFLAGS=$CFLAGS
3802CFLAGS="-fopenmp $mflag_primary -Werror"
3803
3804AC_LINK_IFELSE([AC_LANG_SOURCE([
3805#include <omp.h>
3806int main(int argc, char** argv)
3807{
3808  omp_set_dynamic(0);
3809  return 0;
3810}
3811])],
3812[
3813ac_have_openmp=yes
3814AC_MSG_RESULT([yes])
3815], [
3816ac_have_openmp=no
3817AC_MSG_RESULT([no])
3818])
3819CFLAGS=$safe_CFLAGS
3820
3821AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
3822
3823
3824# Check for __builtin_popcount
3825AC_MSG_CHECKING([for __builtin_popcount()])
3826AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3827]], [[
3828  __builtin_popcount(2);
3829  return 0;
3830]])], [
3831AC_MSG_RESULT([yes])
3832AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
3833          [Define to 1 if compiler provides __builtin_popcount().])
3834], [
3835AC_MSG_RESULT([no])
3836])
3837
3838# Check for __builtin_clz
3839AC_MSG_CHECKING([for __builtin_clz()])
3840AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3841]], [[
3842  __builtin_clz(2);
3843  return 0;
3844]])], [
3845AC_MSG_RESULT([yes])
3846AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
3847          [Define to 1 if compiler provides __builtin_clz().])
3848], [
3849AC_MSG_RESULT([no])
3850])
3851
3852# Check for __builtin_ctz
3853AC_MSG_CHECKING([for __builtin_ctz()])
3854AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3855]], [[
3856  __builtin_ctz(2);
3857  return 0;
3858]])], [
3859AC_MSG_RESULT([yes])
3860AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
3861          [Define to 1 if compiler provides __builtin_ctz().])
3862], [
3863AC_MSG_RESULT([no])
3864])
3865
3866# does this compiler have built-in functions for atomic memory access for the
3867# primary target ?
3868AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
3869
3870safe_CFLAGS=$CFLAGS
3871CFLAGS="$mflag_primary"
3872
3873AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
3874  int variable = 1;
3875  return (__sync_bool_compare_and_swap(&variable, 1, 2)
3876          && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
3877]])], [
3878  ac_have_builtin_atomic_primary=yes
3879  AC_MSG_RESULT([yes])
3880  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])
3881], [
3882  ac_have_builtin_atomic_primary=no
3883  AC_MSG_RESULT([no])
3884])
3885
3886CFLAGS=$safe_CFLAGS
3887
3888AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
3889               [test x$ac_have_builtin_atomic_primary = xyes])
3890
3891
3892# does this compiler have built-in functions for atomic memory access for the
3893# secondary target ?
3894
3895if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
3896
3897AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
3898
3899safe_CFLAGS=$CFLAGS
3900CFLAGS="$mflag_secondary"
3901
3902AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
3903  int variable = 1;
3904  return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
3905]])], [
3906  ac_have_builtin_atomic_secondary=yes
3907  AC_MSG_RESULT([yes])
3908], [
3909  ac_have_builtin_atomic_secondary=no
3910  AC_MSG_RESULT([no])
3911])
3912
3913CFLAGS=$safe_CFLAGS
3914
3915fi
3916
3917AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
3918               [test x$ac_have_builtin_atomic_secondary = xyes])
3919
3920# does this compiler have built-in functions for atomic memory access on
3921# 64-bit integers for all targets ?
3922
3923AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
3924
3925AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3926  #include <stdint.h>
3927]], [[
3928  uint64_t variable = 1;
3929  return __sync_add_and_fetch(&variable, 1)
3930]])], [
3931  ac_have_builtin_atomic64_primary=yes
3932], [
3933  ac_have_builtin_atomic64_primary=no
3934])
3935
3936if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
3937
3938safe_CFLAGS=$CFLAGS
3939CFLAGS="$mflag_secondary"
3940
3941AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3942  #include <stdint.h>
3943]], [[
3944  uint64_t variable = 1;
3945  return __sync_add_and_fetch(&variable, 1)
3946]])], [
3947  ac_have_builtin_atomic64_secondary=yes
3948], [
3949  ac_have_builtin_atomic64_secondary=no
3950])
3951
3952CFLAGS=$safe_CFLAGS
3953
3954fi
3955
3956if test x$ac_have_builtin_atomic64_primary = xyes && \
3957   test x$VGCONF_PLATFORM_SEC_CAPS = x \
3958     -o x$ac_have_builtin_atomic64_secondary = xyes; then
3959  AC_MSG_RESULT([yes])
3960  ac_have_builtin_atomic64=yes
3961else
3962  AC_MSG_RESULT([no])
3963  ac_have_builtin_atomic64=no
3964fi
3965
3966AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
3967               [test x$ac_have_builtin_atomic64 = xyes])
3968
3969
3970# does g++ have built-in functions for atomic memory access ?
3971AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
3972
3973safe_CXXFLAGS=$CXXFLAGS
3974CXXFLAGS="$mflag_primary"
3975
3976AC_LANG_PUSH(C++)
3977AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
3978  int variable = 1;
3979  return (__sync_bool_compare_and_swap(&variable, 1, 2)
3980          && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
3981]])], [
3982  ac_have_builtin_atomic_cxx=yes
3983  AC_MSG_RESULT([yes])
3984  AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
3985], [
3986  ac_have_builtin_atomic_cxx=no
3987  AC_MSG_RESULT([no])
3988])
3989AC_LANG_POP(C++)
3990
3991CXXFLAGS=$safe_CXXFLAGS
3992
3993AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
3994
3995
3996if test x$ac_have_usable_linux_futex_h = xyes \
3997        -a x$ac_have_builtin_atomic_primary = xyes; then
3998  ac_enable_linux_ticket_lock_primary=yes
3999fi
4000AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
4001               [test x$ac_enable_linux_ticket_lock_primary = xyes])
4002
4003if test x$VGCONF_PLATFORM_SEC_CAPS != x \
4004        -a x$ac_have_usable_linux_futex_h = xyes \
4005        -a x$ac_have_builtin_atomic_secondary = xyes; then
4006  ac_enable_linux_ticket_lock_secondary=yes
4007fi
4008AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
4009               [test x$ac_enable_linux_ticket_lock_secondary = xyes])
4010
4011
4012# does libstdc++ support annotating shared pointers ?
4013AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
4014
4015safe_CXXFLAGS=$CXXFLAGS
4016CXXFLAGS="-std=c++0x"
4017
4018AC_LANG_PUSH(C++)
4019AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4020  #include <memory>
4021]], [[
4022  std::shared_ptr<int> p
4023]])], [
4024  ac_have_shared_ptr=yes
4025], [
4026  ac_have_shared_ptr=no
4027])
4028if test x$ac_have_shared_ptr = xyes; then
4029  # If compilation of the program below fails because of a syntax error
4030  # triggered by substituting one of the annotation macros then that
4031  # means that libstdc++ supports these macros.
4032  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4033    #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
4034    #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
4035    #include <memory>
4036  ]], [[
4037    std::shared_ptr<int> p
4038  ]])], [
4039    ac_have_shared_pointer_annotation=no
4040    AC_MSG_RESULT([no])
4041  ], [
4042    ac_have_shared_pointer_annotation=yes
4043    AC_MSG_RESULT([yes])
4044    AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
4045              [Define to 1 if libstd++ supports annotating shared pointers])
4046  ])
4047else
4048  ac_have_shared_pointer_annotation=no
4049  AC_MSG_RESULT([no])
4050fi
4051AC_LANG_POP(C++)
4052
4053CXXFLAGS=$safe_CXXFLAGS
4054
4055AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
4056               [test x$ac_have_shared_pointer_annotation = xyes])
4057
4058
4059#----------------------------------------------------------------------------
4060# Ok.  We're done checking.
4061#----------------------------------------------------------------------------
4062
4063# Nb: VEX/Makefile is generated from Makefile.vex.in.
4064AC_CONFIG_FILES([
4065   Makefile
4066   VEX/Makefile:Makefile.vex.in
4067   valgrind.spec
4068   valgrind.pc
4069   glibc-2.X.supp
4070   docs/Makefile
4071   tests/Makefile
4072   tests/vg_regtest
4073   perf/Makefile
4074   perf/vg_perf
4075   gdbserver_tests/Makefile
4076   gdbserver_tests/solaris/Makefile
4077   include/Makefile
4078   auxprogs/Makefile
4079   mpi/Makefile
4080   coregrind/Makefile
4081   memcheck/Makefile
4082   memcheck/tests/Makefile
4083   memcheck/tests/common/Makefile
4084   memcheck/tests/amd64/Makefile
4085   memcheck/tests/x86/Makefile
4086   memcheck/tests/linux/Makefile
4087   memcheck/tests/darwin/Makefile
4088   memcheck/tests/solaris/Makefile
4089   memcheck/tests/amd64-linux/Makefile
4090   memcheck/tests/x86-linux/Makefile
4091   memcheck/tests/amd64-solaris/Makefile
4092   memcheck/tests/x86-solaris/Makefile
4093   memcheck/tests/ppc32/Makefile
4094   memcheck/tests/ppc64/Makefile
4095   memcheck/tests/s390x/Makefile
4096   memcheck/tests/vbit-test/Makefile
4097   cachegrind/Makefile
4098   cachegrind/tests/Makefile
4099   cachegrind/tests/x86/Makefile
4100   cachegrind/cg_annotate
4101   cachegrind/cg_diff
4102   callgrind/Makefile
4103   callgrind/callgrind_annotate
4104   callgrind/callgrind_control
4105   callgrind/tests/Makefile
4106   helgrind/Makefile
4107   helgrind/tests/Makefile
4108   massif/Makefile
4109   massif/tests/Makefile
4110   massif/ms_print
4111   lackey/Makefile
4112   lackey/tests/Makefile
4113   none/Makefile
4114   none/tests/Makefile
4115   none/tests/scripts/Makefile
4116   none/tests/amd64/Makefile
4117   none/tests/ppc32/Makefile
4118   none/tests/ppc64/Makefile
4119   none/tests/x86/Makefile
4120   none/tests/arm/Makefile
4121   none/tests/arm64/Makefile
4122   none/tests/s390x/Makefile
4123   none/tests/mips32/Makefile
4124   none/tests/mips64/Makefile
4125   none/tests/tilegx/Makefile
4126   none/tests/linux/Makefile
4127   none/tests/darwin/Makefile
4128   none/tests/solaris/Makefile
4129   none/tests/amd64-linux/Makefile
4130   none/tests/x86-linux/Makefile
4131   none/tests/amd64-darwin/Makefile
4132   none/tests/x86-darwin/Makefile
4133   none/tests/amd64-solaris/Makefile
4134   none/tests/x86-solaris/Makefile
4135   exp-sgcheck/Makefile
4136   exp-sgcheck/tests/Makefile
4137   drd/Makefile
4138   drd/scripts/download-and-build-splash2
4139   drd/tests/Makefile
4140   exp-bbv/Makefile
4141   exp-bbv/tests/Makefile
4142   exp-bbv/tests/x86/Makefile
4143   exp-bbv/tests/x86-linux/Makefile
4144   exp-bbv/tests/amd64-linux/Makefile
4145   exp-bbv/tests/ppc32-linux/Makefile
4146   exp-bbv/tests/arm-linux/Makefile
4147   exp-dhat/Makefile
4148   exp-dhat/tests/Makefile
4149   shared/Makefile
4150   solaris/Makefile
4151])
4152AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
4153                [chmod +x coregrind/link_tool_exe_linux])
4154AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
4155                [chmod +x coregrind/link_tool_exe_darwin])
4156AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
4157                [chmod +x coregrind/link_tool_exe_solaris])
4158AC_OUTPUT
4159
4160cat<<EOF
4161
4162         Maximum build arch: ${ARCH_MAX}
4163         Primary build arch: ${VGCONF_ARCH_PRI}
4164       Secondary build arch: ${VGCONF_ARCH_SEC}
4165                   Build OS: ${VGCONF_OS}
4166       Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
4167     Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
4168           Platform variant: ${VGCONF_PLATVARIANT}
4169      Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
4170         Default supp files: ${DEFAULT_SUPP}
4171
4172EOF
4173