-> 3.19.0 final.
[valgrind.git] / configure.ac
blobe02dd0bcba67142d257eeb9bde450dd9641ab440
2 ##------------------------------------------------------------##
3
4 # The multiple-architecture stuff in this file is pretty
5 # cryptic.  Read docs/internals/multiple-architectures.txt
6 # for at least a partial explanation of what is going on.
8 ##------------------------------------------------------------##
10 # Process this file with autoconf to produce a configure script.
12 # Define major, minor, micro and suffix here once, then reuse them
13 # for version number in valgrind.h and vg-entities (documentation).
14 # suffix must be empty for a release, otherwise it is GIT or RC1, etc.
15 # Also set the (expected/last) release date here.
16 # Do not forget to rerun ./autogen.sh
17 m4_define([v_major_ver], [3])
18 m4_define([v_minor_ver], [19])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [])
21 m4_define([v_rel_date], ["11 Apr 2022"])
22 m4_define([v_version],
23           m4_if(v_suffix_ver, [],
24                 [v_major_ver.v_minor_ver.v_micro_ver],
25                 [v_major_ver.v_minor_ver.v_micro_ver.v_suffix_ver]))
26 AC_INIT([Valgrind],[v_version],[valgrind-users@lists.sourceforge.net])
28 # For valgrind.h
29 AC_SUBST(VG_VER_MAJOR, v_major_ver)
30 AC_SUBST(VG_VER_MINOR, v_minor_ver)
32 # For docs/xml/vg-entities.xml
33 AC_SUBST(VG_DATE, v_rel_date)
35 AC_CONFIG_SRCDIR(coregrind/m_main.c)
36 AC_CONFIG_HEADERS([config.h])
37 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
39 AM_MAINTAINER_MODE
41 #----------------------------------------------------------------------------
42 # Do NOT modify these flags here. Except in feature tests in which case
43 # the original values must be properly restored.
44 #----------------------------------------------------------------------------
45 CFLAGS="$CFLAGS"
46 CXXFLAGS="$CXXFLAGS"
48 #----------------------------------------------------------------------------
49 # Checks for various programs.
50 #----------------------------------------------------------------------------
52 AC_PROG_LN_S
53 AC_PROG_CC
54 AM_PROG_CC_C_O
55 AC_PROG_CPP
56 AC_PROG_CXX
57 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
58 # autoconf 2.59).  If we ever have any Objective-C code in the Valgrind code
59 # base (eg. most likely as Darwin-specific tests) we'll need one of the
60 # following:
61 # - put AC_PROG_OBJC in a Darwin-specific part of this file
62 # - Use AC_PROG_OBJC here and up the minimum autoconf version
63 # - Use the following, which is apparently equivalent:
64 #     m4_ifdef([AC_PROG_OBJC],
65 #        [AC_PROG_OBJC],
66 #        [AC_CHECK_TOOL([OBJC], [gcc])
67 #         AC_SUBST([OBJC])
68 #         AC_SUBST([OBJCFLAGS])
69 #        ])
70 AC_PROG_RANLIB
71 # Set LTO_RANLIB variable to an lto enabled ranlib
72 if test "x$LTO_RANLIB" = "x"; then
73   AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
75 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
77 # provide a very basic definition for AC_PROG_SED if it's not provided by
78 # autoconf (as e.g. in autoconf 2.59).
79 m4_ifndef([AC_PROG_SED],
80           [AC_DEFUN([AC_PROG_SED],
81                     [AC_ARG_VAR([SED])
82                      AC_CHECK_PROGS([SED],[gsed sed])])])
83 AC_PROG_SED
85 # If no AR variable was specified, look up the name of the archiver. Otherwise
86 # do not touch the AR variable.
87 if test "x$AR" = "x"; then
88   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
90 AC_ARG_VAR([AR],[Archiver command])
92 # same for LTO_AR variable for lto enabled archiver
93 if test "x$LTO_AR" = "x"; then
94   AC_PATH_PROGS([LTO_AR], [gcc-ar])
96 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
99 # Check for the compiler support
100 if test "${GCC}" != "yes" ; then
101    AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
104 # figure out where perl lives
105 AC_PATH_PROG(PERL, perl)
107 # figure out where gdb lives
108 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
109 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
111 # some older automake's don't have it so try something on our own
112 ifdef([AM_PROG_AS],[AM_PROG_AS],
114 AS="${CC}"
115 AC_SUBST(AS)
117 ASFLAGS=""
118 AC_SUBST(ASFLAGS)
122 # Check if 'diff' supports -u (universal diffs) and use it if possible.
124 AC_MSG_CHECKING([for diff -u])
125 AC_SUBST(DIFF)
127 # Comparing two identical files results in 0.
128 tmpfile="tmp-xxx-yyy-zzz"
129 touch $tmpfile;
130 if diff -u $tmpfile $tmpfile ; then
131     AC_MSG_RESULT([yes])
132     DIFF="diff -u"
133 else
134     AC_MSG_RESULT([no])
135     DIFF="diff"
137 rm $tmpfile
139 # Make sure we can compile in C99 mode.
140 AC_PROG_CC_C99
141 if test "$ac_cv_prog_cc_c99" = "no"; then
142     AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
145 # We don't want gcc < 3.0
146 AC_MSG_CHECKING([for a supported version of gcc])
148 # Obtain the compiler version.
150 # A few examples of how the ${CC} --version output looks like:
152 # ######## gcc variants ########
153 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
154 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
155 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
156 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
157 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
158 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
159 # 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)
161 # ######## clang variants ########
162 # Clang: clang version 2.9 (tags/RELEASE_29/final)
163 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
164 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
166 # ######## Apple LLVM variants ########
167 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
168 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
171 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
172 then
173     is_clang="applellvm"
174     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
175 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
176 then
177     is_clang="clang"
178     # Don't use -dumpversion with clang: it will always produce "4.2.1".
179     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
180 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
181 then
182     is_clang="icc"
183     gcc_version=`${CC} -dumpversion 2>/dev/null`
184 else
185     is_clang="notclang"
186     gcc_version=`${CC} -dumpversion 2>/dev/null`
187     if test "x$gcc_version" = x; then
188         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
189     fi
192 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
193 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
195 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
196 # statements have to be quoted.
197 case "${is_clang}-${gcc_version}" in
198      applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
199         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
200         ;;
201      icc-1[[3-9]].*|icc-202[[0-9]].*)
202         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
203         ;;
204      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
205         AC_MSG_RESULT([ok (${gcc_version})])
206         ;;
207      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
208         AC_MSG_RESULT([ok (clang-${gcc_version})])
209         ;;
210      *)
211         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
212         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
213         ;;
214 esac
216 #----------------------------------------------------------------------------
217 # Arch/OS/platform tests.
218 #----------------------------------------------------------------------------
219 # We create a number of arch/OS/platform-related variables.  We prefix them
220 # all with "VGCONF_" which indicates that they are defined at
221 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
222 # variables used when compiling C files.
224 AC_CANONICAL_HOST
226 AC_MSG_CHECKING([for a supported CPU])
228 # ARCH_MAX reflects the most that this CPU can do: for example if it
229 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
230 # Ditto for amd64.  It is used for more configuration below, but is not used
231 # outside this file.
233 # Power PC returns powerpc for Big Endian.  This was not changed when Little
234 # Endian support was added to the 64-bit architecture.  The 64-bit Little
235 # Endian systems explicitly state le in the host_cpu.  For clarity in the
236 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
237 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
238 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
239 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
240 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
241 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
242 # Little Endian.
244 case "${host_cpu}" in
245      i?86) 
246         AC_MSG_RESULT([ok (${host_cpu})])
247         ARCH_MAX="x86"
248         ;;
250      x86_64|amd64) 
251         AC_MSG_RESULT([ok (${host_cpu})])
252         ARCH_MAX="amd64"
253         ;;
255      powerpc64)
256      # this only referrs to 64-bit Big Endian
257         AC_MSG_RESULT([ok (${host_cpu})])
258         ARCH_MAX="ppc64be"
259         ;;
261      powerpc64le)
262      # this only referrs to 64-bit Little Endian
263         AC_MSG_RESULT([ok (${host_cpu})])
264         ARCH_MAX="ppc64le"
265         ;;
267      powerpc)
268         # On Linux this means only a 32-bit capable CPU.
269         AC_MSG_RESULT([ok (${host_cpu})])
270         ARCH_MAX="ppc32"
271         ;;
273      s390x)
274         AC_MSG_RESULT([ok (${host_cpu})])
275         ARCH_MAX="s390x"
276         ;;
278      armv7*)
279         AC_MSG_RESULT([ok (${host_cpu})])
280         ARCH_MAX="arm"
281         ;;
283      aarch64*)
284        AC_MSG_RESULT([ok (${host_cpu})])
285        ARCH_MAX="arm64"
286        ;;
288      mips)
289         AC_MSG_RESULT([ok (${host_cpu})])
290         ARCH_MAX="mips32"
291         ;;
293      mipsel)
294         AC_MSG_RESULT([ok (${host_cpu})])
295         ARCH_MAX="mips32"
296         ;;
298      mipsisa32r2)
299         AC_MSG_RESULT([ok (${host_cpu})])
300         ARCH_MAX="mips32"
301         ;;
303      mips64*)
304         AC_MSG_RESULT([ok (${host_cpu})])
305         ARCH_MAX="mips64"
306         ;;
308      mipsisa64*)
309         AC_MSG_RESULT([ok (${host_cpu})])
310         ARCH_MAX="mips64"
311         ;;
312      nanomips)
313         AC_MSG_RESULT([ok (${host_cpu})])
314         ARCH_MAX="nanomips"
315         ;;
317      *) 
318         AC_MSG_RESULT([no (${host_cpu})])
319         AC_MSG_ERROR([Unsupported host architecture. Sorry])
320         ;;
321 esac
323 #----------------------------------------------------------------------------
325 # Sometimes it's convenient to subvert the bi-arch build system and
326 # just have a single build even though the underlying platform is
327 # capable of both.  Hence handle --enable-only64bit and
328 # --enable-only32bit.  Complain if both are issued :-)
329 # [Actually, if either of these options are used, I think both get built,
330 # but only one gets installed.  So if you use an in-place build, both can be
331 # used. --njn]
333 # Check if a 64-bit only build has been requested
334 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
335    [AC_ARG_ENABLE(only64bit, 
336       [  --enable-only64bit      do a 64-bit only build],
337       [vg_cv_only64bit=$enableval],
338       [vg_cv_only64bit=no])])
340 # Check if a 32-bit only build has been requested
341 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
342    [AC_ARG_ENABLE(only32bit, 
343       [  --enable-only32bit      do a 32-bit only build],
344       [vg_cv_only32bit=$enableval],
345       [vg_cv_only32bit=no])])
347 # Stay sane
348 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
349    AC_MSG_ERROR(
350       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
353 #----------------------------------------------------------------------------
355 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
356 # compilation of many C files via -VGO_$(VGCONF_OS) and
357 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
358 AC_MSG_CHECKING([for a supported OS])
359 AC_SUBST(VGCONF_OS)
361 DEFAULT_SUPP=""
363 case "${host_os}" in
364      *linux*)
365         AC_MSG_RESULT([ok (${host_os})])
366         VGCONF_OS="linux"
368         # Ok, this is linux. Check the kernel version
369         AC_MSG_CHECKING([for the kernel version])
371         kernel=`uname -r`
373         case "${kernel}" in
374              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
375                     AC_MSG_RESULT([unsupported (${kernel})])
376                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
377                     ;;
379              *)
380                     AC_MSG_RESULT([2.6 or later (${kernel})])
381                     ;;
382         esac
384         ;;
386      *freebsd*)
387         AC_MSG_RESULT([ok (${host_os})])
388         VGCONF_OS="freebsd"
389         AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
390         freebsd_10=1000
391         AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
392         freebsd_11=1100
393         AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
394         freebsd_12=1200
395         AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
396         freebsd_12_2=1220
397         AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
398         freebsd_13_0=1300
399         AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1+])
400         freebsd_13_1=1310
401         AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
402         freebsd_14=1400
404         AC_MSG_CHECKING([for the kernel version])
405         kernel=`uname -r`
407         case "${kernel}" in
408         10.*)
409            AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
410            AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
411            freebsd_vers=$freebsd_10
412            ;;
413         11.*)
414            AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
415            AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
416            freebsd_vers=$freebsd_11
417            ;;
418         12.*)
419            case "${kernel}" in
420            12.[[0-1]]-*)
421               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
422               AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
423               freebsd_vers=$freebsd_12
424               ;;
425            *)
426               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
427               AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
428               freebsd_vers=$freebsd_12_2
429               ;;
430            esac
431            ;;
432         13.*)
433            case "${kernel}" in
434            13.0-*)
435               AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
436               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
437               freebsd_vers=$freebsd_13_0
438               ;;
439            *)
440               AC_MSG_RESULT([FreeBSD 13.1+ (${kernel})])
441               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
442               freebsd_vers=$freebsd_13_1
443               ;;
444            esac
445            ;;
446         14.*)
447            AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
448            AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
449            freebsd_vers=$freebsd_14
450            ;;
451         *)
452            AC_MSG_RESULT([unsupported (${kernel})])
453            AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x])
454            ;;
455         esac
457         DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
458         ;;
460      *darwin*)
461         AC_MSG_RESULT([ok (${host_os})])
462         VGCONF_OS="darwin"
463         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
464         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
465         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
466         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
467         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
468         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
469         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
470         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
471         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
473         AC_MSG_CHECKING([for the kernel version])
474         kernel=`uname -r`
476         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
477         # has only one relevant version, the OS version. The `uname` check
478         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
479         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
480         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
481         # and we don't know of an macros similar to __GLIBC__ to get that info.
482         #
483         # XXX: `uname -r` won't do the right thing for cross-compiles, but
484         # that's not a problem yet.
485         #
486         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
487         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
488         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
489         # time support for 10.5 (the 9.* pattern just below), I'll leave it
490         # in for now, just in case anybody wants to give it a try.  But I'm
491         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
492         case "${kernel}" in
493              9.*)
494                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
495                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
496                   DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
497                   DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
498                   ;;
499              10.*)
500                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
501                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
502                   DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
503                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
504                   ;;
505              11.*)
506                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
507                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
508                   DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
509                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
510                   ;;
511              12.*)
512                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
513                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
514                   DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
515                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
516                   ;;
517              13.*)
518                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
519                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
520                   DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
521                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
522                   ;;
523              14.*)
524                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
525                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
526                   DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
527                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
528                   ;;
529              15.*)
530                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
531                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
532                   DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
533                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
534                   ;;
535              16.*)
536                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
537                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
538                   DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
539                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
540                   ;;
541              17.*)
542                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
543                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
544                   DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
545                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
546                   ;;
547              *) 
548                   AC_MSG_RESULT([unsupported (${kernel})])
549                   AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x and 17.x (Mac OS X 10.6/7/8/9/10/11 and macOS 10.12/13)])
550                   ;;
551         esac
552         ;;
554      solaris2.11*)
555         AC_MSG_RESULT([ok (${host_os})])
556         VGCONF_OS="solaris"
558         uname_v=$( uname -v )
559         case "$uname_v" in
560              11.4.*)
561                  DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
562                  ;;
563              *)
564                  DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
565                  ;;
566         esac
567         ;;
569      solaris2.12*)
570         AC_MSG_RESULT([ok (${host_os})])
571         VGCONF_OS="solaris"
572         DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
573         ;;
575      *) 
576         AC_MSG_RESULT([no (${host_os})])
577         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
578         ;;
579 esac
581 #----------------------------------------------------------------------------
583 # If we are building on a 64 bit platform test to see if the system
584 # supports building 32 bit programs and disable 32 bit support if it
585 # does not support building 32 bit programs
587 case "$ARCH_MAX-$VGCONF_OS" in
588      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
589         AC_MSG_CHECKING([for 32 bit build support])
590         safe_CFLAGS=$CFLAGS
591         CFLAGS="-m32"
592         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
593           return 0;
594         ]])], [
595         AC_MSG_RESULT([yes])
596         ], [
597         vg_cv_only64bit="yes"
598         AC_MSG_RESULT([no])
599         ])
600         CFLAGS=$safe_CFLAGS;;
601     mips64-linux)
602         AC_MSG_CHECKING([for 32 bit build support])
603         safe_CFLAGS=$CFLAGS
604         CFLAGS="$CFLAGS -mips32 -mabi=32"
605         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
606           #include <sys/prctl.h>
607         ]], [[]])], [
608         AC_MSG_RESULT([yes])
609         ], [
610         vg_cv_only64bit="yes"
611         AC_MSG_RESULT([no])
612         ])
613         CFLAGS=$safe_CFLAGS;;
614 esac
616 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
617    AC_MSG_ERROR(
618       [--enable-only32bit was specified but system does not support 32 bit builds])
621 #----------------------------------------------------------------------------
623 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
624 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
625 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
626 # above) will be "amd64" since that reflects the most that this cpu can do,
627 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
628 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
629 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
630 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
631 AC_SUBST(VGCONF_ARCH_PRI)
633 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
634 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
635 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
636 # It is empty if there is no secondary target.
637 AC_SUBST(VGCONF_ARCH_SEC)
639 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
640 # The entire system, including regression and performance tests, will be
641 # built for this target.  The "_CAPS" indicates that the name is in capital
642 # letters, and it also uses '_' rather than '-' as a separator, because it's
643 # used to create various Makefile variables, which are all in caps by
644 # convention and cannot contain '-' characters.  This is in contrast to
645 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
646 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
648 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
649 # Valgrind and tools will also be built for this target, but not the
650 # regression or performance tests.
652 # By default, the primary arch is the same as the "max" arch, as commented
653 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
654 # the big case statement just below here, in the case where we're building
655 # on a 64 bit machine but have been requested only to do a 32 bit build.
656 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
658 AC_MSG_CHECKING([for a supported CPU/OS combination])
660 # NB.  The load address for a given platform may be specified in more 
661 # than one place, in some cases, depending on whether we're doing a biarch,
662 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
663 # Be careful to give consistent values in all subcases.  Also, all four
664 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
665 # even if it is to "0xUNSET".
667 case "$ARCH_MAX-$VGCONF_OS" in
668      x86-linux)
669         VGCONF_ARCH_PRI="x86"
670         VGCONF_ARCH_SEC=""
671         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
672         VGCONF_PLATFORM_SEC_CAPS=""
673         valt_load_address_pri_norml="0x58000000"
674         valt_load_address_pri_inner="0x38000000"
675         valt_load_address_sec_norml="0xUNSET"
676         valt_load_address_sec_inner="0xUNSET"
677         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
678         ;;
679      amd64-linux)
680         valt_load_address_sec_norml="0xUNSET"
681         valt_load_address_sec_inner="0xUNSET"
682         if test x$vg_cv_only64bit = xyes; then
683            VGCONF_ARCH_PRI="amd64"
684            VGCONF_ARCH_SEC=""
685            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
686            VGCONF_PLATFORM_SEC_CAPS=""
687            valt_load_address_pri_norml="0x58000000"
688            valt_load_address_pri_inner="0x38000000"
689         elif test x$vg_cv_only32bit = xyes; then
690            VGCONF_ARCH_PRI="x86"
691            VGCONF_ARCH_SEC=""
692            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
693            VGCONF_PLATFORM_SEC_CAPS=""
694            valt_load_address_pri_norml="0x58000000"
695            valt_load_address_pri_inner="0x38000000"
696         else
697            VGCONF_ARCH_PRI="amd64"
698            VGCONF_ARCH_SEC="x86"
699            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
700            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
701            valt_load_address_pri_norml="0x58000000"
702            valt_load_address_pri_inner="0x38000000"
703            valt_load_address_sec_norml="0x58000000"
704            valt_load_address_sec_inner="0x38000000"
705         fi
706         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
707         ;;
708      ppc32-linux)
709         VGCONF_ARCH_PRI="ppc32"
710         VGCONF_ARCH_SEC=""
711         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
712         VGCONF_PLATFORM_SEC_CAPS=""
713         valt_load_address_pri_norml="0x58000000"
714         valt_load_address_pri_inner="0x38000000"
715         valt_load_address_sec_norml="0xUNSET"
716         valt_load_address_sec_inner="0xUNSET"
717         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
718         ;;
719      ppc64be-linux)
720         valt_load_address_sec_norml="0xUNSET"
721         valt_load_address_sec_inner="0xUNSET"
722         if test x$vg_cv_only64bit = xyes; then
723            VGCONF_ARCH_PRI="ppc64be"
724            VGCONF_ARCH_SEC=""
725            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
726            VGCONF_PLATFORM_SEC_CAPS=""
727            valt_load_address_pri_norml="0x58000000"
728            valt_load_address_pri_inner="0x38000000"
729         elif test x$vg_cv_only32bit = xyes; then
730            VGCONF_ARCH_PRI="ppc32"
731            VGCONF_ARCH_SEC=""
732            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
733            VGCONF_PLATFORM_SEC_CAPS=""
734            valt_load_address_pri_norml="0x58000000"
735            valt_load_address_pri_inner="0x38000000"
736         else
737            VGCONF_ARCH_PRI="ppc64be"
738            VGCONF_ARCH_SEC="ppc32"
739            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
740            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
741            valt_load_address_pri_norml="0x58000000"
742            valt_load_address_pri_inner="0x38000000"
743            valt_load_address_sec_norml="0x58000000"
744            valt_load_address_sec_inner="0x38000000"
745         fi
746         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
747         ;;
748      ppc64le-linux)
749         # Little Endian is only supported on PPC64
750         valt_load_address_sec_norml="0xUNSET"
751         valt_load_address_sec_inner="0xUNSET"
752         VGCONF_ARCH_PRI="ppc64le"
753         VGCONF_ARCH_SEC=""
754         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
755         VGCONF_PLATFORM_SEC_CAPS=""
756         valt_load_address_pri_norml="0x58000000"
757         valt_load_address_pri_inner="0x38000000"
758         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
759        ;;
760      x86-freebsd)
761         VGCONF_ARCH_PRI="x86"
762         VGCONF_ARCH_SEC=""
763         VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
764         VGCONF_PLATFORM_SEC_CAPS=""
765         valt_load_address_pri_norml="0x38000000"
766         valt_load_address_pri_inner="0x28000000"
767         valt_load_address_sec_norml="0xUNSET"
768         valt_load_address_sec_inner="0xUNSET"
769         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
770         ;;
771      amd64-freebsd)
772         if test x$vg_cv_only64bit = xyes; then
773            VGCONF_ARCH_PRI="amd64"
774            VGCONF_ARCH_SEC=""
775            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
776            VGCONF_PLATFORM_SEC_CAPS=""
777         elif test x$vg_cv_only32bit = xyes; then
778            VGCONF_ARCH_PRI="x86"
779            VGCONF_ARCH_SEC=""
780            VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
781            VGCONF_PLATFORM_SEC_CAPS=""
782         else
783            VGCONF_ARCH_PRI="amd64"
784            VGCONF_ARCH_SEC="x86"
785            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
786            VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
787         fi
788         # These work with either base clang or ports installed gcc
789         # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
790         if test x$is_clang = xclang ; then
791            FLAG_32ON64="-B/usr/lib32"
792         else
793            GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
794            FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
795         fi
796         valt_load_address_pri_norml="0x38000000"
797         valt_load_address_pri_inner="0x28000000"
798         valt_load_address_sec_norml="0x38000000"
799         valt_load_address_sec_inner="0x28000000"
800         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
801         ;;
802      # Darwin gets identified as 32-bit even when it supports 64-bit.
803      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
804      # all Macs support both 32-bit and 64-bit, so we just build both.  If
805      # someone has a really old 32-bit only machine they can (hopefully?)
806      # build with --enable-only32bit.  See bug 243362.
807      x86-darwin|amd64-darwin)
808         ARCH_MAX="amd64"
809         valt_load_address_sec_norml="0xUNSET"
810         valt_load_address_sec_inner="0xUNSET"
811         if test x$vg_cv_only64bit = xyes; then
812            VGCONF_ARCH_PRI="amd64"
813            VGCONF_ARCH_SEC=""
814            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
815            VGCONF_PLATFORM_SEC_CAPS=""
816            valt_load_address_pri_norml="0x158000000"
817            valt_load_address_pri_inner="0x138000000"
818         elif test x$vg_cv_only32bit = xyes; then
819            VGCONF_ARCH_PRI="x86"
820            VGCONF_ARCH_SEC=""
821            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
822            VGCONF_PLATFORM_SEC_CAPS=""
823            VGCONF_ARCH_PRI_CAPS="x86"
824            valt_load_address_pri_norml="0x58000000"
825            valt_load_address_pri_inner="0x38000000"
826         else
827            VGCONF_ARCH_PRI="amd64"
828            VGCONF_ARCH_SEC="x86"
829            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
830            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
831            valt_load_address_pri_norml="0x158000000"
832            valt_load_address_pri_inner="0x138000000"
833            valt_load_address_sec_norml="0x58000000"
834            valt_load_address_sec_inner="0x38000000"
835         fi
836         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
837         ;;
838      arm-linux) 
839         VGCONF_ARCH_PRI="arm"
840         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
841         VGCONF_PLATFORM_SEC_CAPS=""
842         valt_load_address_pri_norml="0x58000000"
843         valt_load_address_pri_inner="0x38000000"
844         valt_load_address_sec_norml="0xUNSET"
845         valt_load_address_sec_inner="0xUNSET"
846         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
847         ;;
848      arm64-linux)
849         valt_load_address_sec_norml="0xUNSET"
850         valt_load_address_sec_inner="0xUNSET"
851         if test x$vg_cv_only64bit = xyes; then
852            VGCONF_ARCH_PRI="arm64"
853            VGCONF_ARCH_SEC=""
854            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
855            VGCONF_PLATFORM_SEC_CAPS=""
856            valt_load_address_pri_norml="0x58000000"
857            valt_load_address_pri_inner="0x38000000"
858         elif test x$vg_cv_only32bit = xyes; then
859            VGCONF_ARCH_PRI="arm"
860            VGCONF_ARCH_SEC=""
861            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
862            VGCONF_PLATFORM_SEC_CAPS=""
863            valt_load_address_pri_norml="0x58000000"
864            valt_load_address_pri_inner="0x38000000"
865         else
866            VGCONF_ARCH_PRI="arm64"
867            VGCONF_ARCH_SEC="arm"
868            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
869            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
870            valt_load_address_pri_norml="0x58000000"
871            valt_load_address_pri_inner="0x38000000"
872            valt_load_address_sec_norml="0x58000000"
873            valt_load_address_sec_inner="0x38000000"
874         fi
875         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
876         ;;
877      s390x-linux)
878         VGCONF_ARCH_PRI="s390x"
879         VGCONF_ARCH_SEC=""
880         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
881         VGCONF_PLATFORM_SEC_CAPS=""
882         # To improve branch prediction hit rate we want to have
883         # the generated code close to valgrind (host) code
884         valt_load_address_pri_norml="0x800000000"
885         valt_load_address_pri_inner="0x810000000"
886         valt_load_address_sec_norml="0xUNSET"
887         valt_load_address_sec_inner="0xUNSET"
888         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
889         ;;
890      mips32-linux) 
891         VGCONF_ARCH_PRI="mips32"
892         VGCONF_ARCH_SEC=""
893         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
894         VGCONF_PLATFORM_SEC_CAPS=""
895         valt_load_address_pri_norml="0x58000000"
896         valt_load_address_pri_inner="0x38000000"
897         valt_load_address_sec_norml="0xUNSET"
898         valt_load_address_sec_inner="0xUNSET"
899         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
900         ;;
901      mips64-linux)
902         valt_load_address_sec_norml="0xUNSET"
903         valt_load_address_sec_inner="0xUNSET"
904         if test x$vg_cv_only64bit = xyes; then
905             VGCONF_ARCH_PRI="mips64"
906             VGCONF_PLATFORM_SEC_CAPS=""
907             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
908             VGCONF_PLATFORM_SEC_CAPS=""
909             valt_load_address_pri_norml="0x58000000"
910             valt_load_address_pri_inner="0x38000000"
911         elif test x$vg_cv_only32bit = xyes; then
912             VGCONF_ARCH_PRI="mips32"
913             VGCONF_ARCH_SEC=""
914             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
915             VGCONF_PLATFORM_SEC_CAPS=""
916             valt_load_address_pri_norml="0x58000000"
917             valt_load_address_pri_inner="0x38000000"
918         else
919             VGCONF_ARCH_PRI="mips64"
920             VGCONF_ARCH_SEC="mips32"
921             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
922             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
923             valt_load_address_pri_norml="0x58000000"
924             valt_load_address_pri_inner="0x38000000"
925             valt_load_address_sec_norml="0x58000000"
926             valt_load_address_sec_inner="0x38000000"
927         fi
928         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
929         ;;
930      nanomips-linux)
931         VGCONF_ARCH_PRI="nanomips"
932         VGCONF_ARCH_SEC=""
933         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
934         VGCONF_PLATFORM_SEC_CAPS=""
935         valt_load_address_pri_norml="0x58000000"
936         valt_load_address_pri_inner="0x38000000"
937         valt_load_address_sec_norml="0xUNSET"
938         valt_load_address_sec_inner="0xUNSET"
939         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
940         ;;
941      x86-solaris)
942         VGCONF_ARCH_PRI="x86"
943         VGCONF_ARCH_SEC=""
944         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
945         VGCONF_PLATFORM_SEC_CAPS=""
946         valt_load_address_pri_norml="0x58000000"
947         valt_load_address_pri_inner="0x38000000"
948         valt_load_address_sec_norml="0xUNSET"
949         valt_load_address_sec_inner="0xUNSET"
950         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
951         ;;
952      amd64-solaris)
953         valt_load_address_sec_norml="0xUNSET"
954         valt_load_address_sec_inner="0xUNSET"
955         if test x$vg_cv_only64bit = xyes; then
956            VGCONF_ARCH_PRI="amd64"
957            VGCONF_ARCH_SEC=""
958            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
959            VGCONF_PLATFORM_SEC_CAPS=""
960            valt_load_address_pri_norml="0x58000000"
961            valt_load_address_pri_inner="0x38000000"
962         elif test x$vg_cv_only32bit = xyes; then
963            VGCONF_ARCH_PRI="x86"
964            VGCONF_ARCH_SEC=""
965            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
966            VGCONF_PLATFORM_SEC_CAPS=""
967            valt_load_address_pri_norml="0x58000000"
968            valt_load_address_pri_inner="0x38000000"
969         else
970            VGCONF_ARCH_PRI="amd64"
971            VGCONF_ARCH_SEC="x86"
972            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
973            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
974            valt_load_address_pri_norml="0x58000000"
975            valt_load_address_pri_inner="0x38000000"
976            valt_load_address_sec_norml="0x58000000"
977            valt_load_address_sec_inner="0x38000000"
978         fi
979         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
980         ;;
981     *)
982         VGCONF_ARCH_PRI="unknown"
983         VGCONF_ARCH_SEC="unknown"
984         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
985         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
986         valt_load_address_pri_norml="0xUNSET"
987         valt_load_address_pri_inner="0xUNSET"
988         valt_load_address_sec_norml="0xUNSET"
989         valt_load_address_sec_inner="0xUNSET"
990         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
991         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
992         ;;
993 esac
995 #----------------------------------------------------------------------------
997 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
998 # defined.
999 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
1000                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1001                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1002                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1003                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1004                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1005                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1006                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1007                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1008 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
1009                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1010                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1011                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1012                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1013 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
1014                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1015                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1016 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
1017                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1018                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1019 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
1020                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1021                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1022 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
1023                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1024 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1025                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1026 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1027                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1028                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1029 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1030                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
1031 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1032                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1034 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
1035 # become defined.
1036 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
1037                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1038                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1039 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
1040                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1041 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
1042                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1043                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1044 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1045                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1046 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1047                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1048 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1049                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1050                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1051 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1052                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1053 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1054                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1055                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1056 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1057                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1058                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1059 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1060                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1061 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1062                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1063 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1064                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1065                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1066 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1067                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1068 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1069                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1070                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1071 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1072                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1073 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1074                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1075                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1076 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1077                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1080 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1081 # Relies on the assumption that the primary and secondary targets are 
1082 # for the same OS, so therefore only necessary to test the primary.
1083 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1084                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1085                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1086                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1087                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1088                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1089                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1090                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1091                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1092                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1093                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1094                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1095 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1096                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1097                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1098 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1099                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1100                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1101 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1102                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1103                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1104 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1105                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1106                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1107                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1108                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1111 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1112 # there is a secondary target.
1113 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1114                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1116 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1117 dnl fallback definition
1118 dnl The macro is courtesy of Dave Hart:
1119 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1120 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1121 if test -z "$$1_TRUE"; then :
1122   m4_n([$2])[]dnl
1123 m4_ifval([$3],
1124 [else
1125   $3
1126 ])dnl
1127 fi[]dnl
1128 ])])
1130 #----------------------------------------------------------------------------
1131 # Inner Valgrind?
1132 #----------------------------------------------------------------------------
1134 # Check if this should be built as an inner Valgrind, to be run within
1135 # another Valgrind.  Choose the load address accordingly.
1136 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1137 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1138 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1139    [AC_ARG_ENABLE(inner, 
1140       [  --enable-inner          enables self-hosting],
1141       [vg_cv_inner=$enableval],
1142       [vg_cv_inner=no])])
1143 if test "$vg_cv_inner" = yes; then
1144     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1145     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1146     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1147 else
1148     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1149     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1152 #----------------------------------------------------------------------------
1153 # Undefined behaviour sanitiser
1154 #----------------------------------------------------------------------------
1155 # Check whether we should build with the undefined beahviour sanitiser.
1157 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1158    [AC_ARG_ENABLE(ubsan, 
1159       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1160       [vg_cv_ubsan=$enableval],
1161       [vg_cv_ubsan=no])])
1163 #----------------------------------------------------------------------------
1164 # Extra fine-tuning of installation directories
1165 #----------------------------------------------------------------------------
1166 AC_ARG_WITH(tmpdir,
1167    [  --with-tmpdir=PATH      Specify path for temporary files],
1168    tmpdir="$withval",
1169    tmpdir="/tmp")
1170 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1171 AC_SUBST(VG_TMPDIR, [$tmpdir])
1173 #----------------------------------------------------------------------------
1174 # Detect xcode path
1175 #----------------------------------------------------------------------------
1176 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1177 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1178 AC_MSG_CHECKING([for xcode sdk include path])
1179 AC_ARG_WITH(xcodedir,
1180    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1181    [xcodedir="$withval"],
1182    [
1183       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1184          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1185          if test -z "$xcrundir"; then
1186             xcodedir="/usr/include"
1187          else
1188             xcodedir="$xcrundir/usr/include"
1189          fi
1190       else
1191          xcodedir="/usr/include"
1192       fi
1193    ])
1194 AC_MSG_RESULT([$xcodedir])
1195 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1196 AC_SUBST(XCODE_DIR, [$xcodedir])])
1198 #----------------------------------------------------------------------------
1199 # Libc and suppressions
1200 #----------------------------------------------------------------------------
1201 # This variable will collect the suppression files to be used.
1202 AC_SUBST(DEFAULT_SUPP)
1204 AC_CHECK_HEADER([features.h])
1206 if test x$ac_cv_header_features_h = xyes; then
1207   rm -f conftest.$ac_ext
1208   cat <<_ACEOF >conftest.$ac_ext
1209 #include <features.h>
1210 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1211 glibc version is: __GLIBC__ __GLIBC_MINOR__
1212 #endif
1213 _ACEOF
1214   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1217 # not really a version check
1218 AC_EGREP_CPP([DARWIN_LIBC], [
1219 #include <sys/cdefs.h>
1220 #if defined(__DARWIN_VERS_1050)
1221   DARWIN_LIBC
1222 #endif
1224 GLIBC_VERSION="darwin")
1226 AC_EGREP_CPP([FREEBSD_LIBC], [
1227 #include <sys/cdefs.h>
1228 #if defined(__FreeBSD__)
1229   FREEBSD_LIBC
1230 #endif
1232 GLIBC_VERSION="freebsd")
1234 # not really a version check
1235 AC_EGREP_CPP([BIONIC_LIBC], [
1236 #if defined(__ANDROID__)
1237   BIONIC_LIBC
1238 #endif
1240 GLIBC_VERSION="bionic")
1242 # there is only one version of libc on Solaris
1243 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1244      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1245     GLIBC_VERSION="solaris"
1248 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1249 # in this case.
1250 if test x$GLIBC_VERSION = x; then
1251     if $CC -dumpmachine | grep -q musl; then
1252         GLIBC_VERSION=musl
1253     fi
1256 # If this is glibc then figure out the generic (in file) libc.so and
1257 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1258 # was a separate library, afterwards it was merged into libc.so and
1259 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1260 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1261 case ${GLIBC_VERSION} in
1263   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1264   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1265   [
1266     AC_MSG_RESULT([no])
1267     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1268     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1269   ], [
1270     AC_MSG_RESULT([yes])
1271     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1272     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1273   ])
1274   ;;
1276   AC_MSG_CHECKING([not glibc...])
1277   AC_MSG_RESULT([${GLIBC_VERSION}])
1278   ;;
1279 esac
1281 AC_MSG_CHECKING([the glibc version])
1283 case "${GLIBC_VERSION}" in
1284      2.2)
1285         AC_MSG_RESULT(${GLIBC_VERSION} family)
1286         DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1287         DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1288         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1289         ;;
1290      2.[[3-6]])
1291         AC_MSG_RESULT(${GLIBC_VERSION} family)
1292         DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1293         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1294         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1295         ;;
1296      2.[[7-9]])
1297         AC_MSG_RESULT(${GLIBC_VERSION} family)
1298         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1299         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1300         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1301         ;;
1302      2.10|2.11)
1303         AC_MSG_RESULT(${GLIBC_VERSION} family)
1304         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1305                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1306         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1307         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1308         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1309         ;;
1310      2.*)
1311         AC_MSG_RESULT(${GLIBC_VERSION} family)
1312         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1313                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1314         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1315                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1316         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1317         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1318         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1319         ;;
1320      darwin)
1321         AC_MSG_RESULT(Darwin)
1322         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1323         # DEFAULT_SUPP set by kernel version check above.
1324         ;;
1325      freebsd)
1326         AC_MSG_RESULT(FreeBSD)
1327         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1328         # DEFAULT_SUPP set by kernel version check above.
1329         ;;
1330      bionic)
1331         AC_MSG_RESULT(Bionic)
1332         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1333         DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1334         ;;
1335      solaris)
1336         AC_MSG_RESULT(Solaris)
1337         # DEFAULT_SUPP set in host_os switch-case above.
1338         # No other suppression file is used.
1339         ;;
1340      musl)
1341         AC_MSG_RESULT(Musl)
1342         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1343         DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1344         ;;
1345      2.0|2.1|*)
1346         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1347         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1348         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1349         ;;
1350 esac
1352 AC_SUBST(GLIBC_VERSION)
1353 AC_SUBST(GLIBC_LIBC_PATH)
1354 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1357 if test "$VGCONF_OS" != "solaris"; then
1358     # Add default suppressions for the X client libraries.  Make no
1359     # attempt to detect whether such libraries are installed on the
1360     # build machine (or even if any X facilities are present); just
1361     # add the suppressions antidisirregardless.
1362     DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1363     DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1367 #----------------------------------------------------------------------------
1368 # Platform variants?
1369 #----------------------------------------------------------------------------
1371 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1372 # But there are times where we need a bit more control.  The motivating
1373 # and currently only case is Android: this is almost identical to
1374 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1375 # platform variant tags, which get passed in the compile as
1376 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1378 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1379 # it is "android" instead.
1381 # Consequently (eg), plain arm-linux would build with
1383 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1385 # whilst an Android build would have
1387 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1389 # Same for x86. The setup of the platform variant is pushed relatively far
1390 # down this file in order that we can inspect any of the variables set above.
1392 # In the normal case ..
1393 VGCONF_PLATVARIANT="vanilla"
1395 # Android ?
1396 if test "$GLIBC_VERSION" = "bionic";
1397 then
1398    VGCONF_PLATVARIANT="android"
1401 AC_SUBST(VGCONF_PLATVARIANT)
1404 # FIXME: do we also want to define automake variables
1405 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1406 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1407 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1408 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1409 # that's what we'd need to do to use this, since what we'd want to write
1410 # is something like
1412 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1414 # Hmm.  Can't think of a nice clean solution to this.
1416 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1417                test x$VGCONF_PLATVARIANT = xvanilla)
1418 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1419                test x$VGCONF_PLATVARIANT = xandroid)
1422 #----------------------------------------------------------------------------
1423 # Checking for various library functions and other definitions
1424 #----------------------------------------------------------------------------
1426 # Check for AT_FDCWD
1428 AC_MSG_CHECKING([for AT_FDCWD])
1429 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1430 #define _GNU_SOURCE
1431 #include <fcntl.h>
1432 #include <unistd.h>
1433 ]], [[
1434   int a = AT_FDCWD;
1435 ]])], [
1436 ac_have_at_fdcwd=yes
1437 AC_MSG_RESULT([yes])
1438 ], [
1439 ac_have_at_fdcwd=no
1440 AC_MSG_RESULT([no])
1443 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1445 # Check for stpncpy function definition in string.h
1446 # This explicitly checks with _GNU_SOURCE defined since that is also
1447 # used in the test case (some systems might define it without anyway
1448 # since stpncpy is part of The Open Group Base Specifications Issue 7
1449 # IEEE Std 1003.1-2008.
1450 AC_MSG_CHECKING([for stpncpy])
1451 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1452 #define _GNU_SOURCE
1453 #include <string.h>
1454 ]], [[
1455   char *d;
1456   char *s;
1457   size_t n = 0;
1458   char *r = stpncpy(d, s, n);
1459 ]])], [
1460 ac_have_gnu_stpncpy=yes
1461 AC_MSG_RESULT([yes])
1462 ], [
1463 ac_have_gnu_stpncpy=no
1464 AC_MSG_RESULT([no])
1467 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1469 # Check for PTRACE_GETREGS
1471 AC_MSG_CHECKING([for PTRACE_GETREGS])
1472 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1473 #include <stdlib.h>
1474 #include <stddef.h>
1475 #include <sys/ptrace.h>
1476 #include <sys/user.h>
1477 ]], [[
1478   void *p;
1479   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1480 ]])], [
1481 AC_MSG_RESULT([yes])
1482 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1483           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1484 ], [
1485 AC_MSG_RESULT([no])
1489 # Check for CLOCK_MONOTONIC
1491 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1493 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1494 #include <time.h>
1495 ]], [[
1496   struct timespec t;
1497   clock_gettime(CLOCK_MONOTONIC, &t);
1498   return 0;
1499 ]])], [
1500 AC_MSG_RESULT([yes])
1501 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1502           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1503 ], [
1504 AC_MSG_RESULT([no])
1508 # Check for ELF32/64_CHDR
1510 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1513 # Check for PTHREAD_RWLOCK_T
1515 AC_MSG_CHECKING([for pthread_rwlock_t])
1517 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1518 #define _GNU_SOURCE
1519 #include <pthread.h>
1520 ]], [[
1521   pthread_rwlock_t rwl;
1522 ]])], [
1523 AC_MSG_RESULT([yes])
1524 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1525           [Define to 1 if you have the `pthread_rwlock_t' type.])
1526 ], [
1527 AC_MSG_RESULT([no])
1531 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1533 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1535 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1536 #define _GNU_SOURCE
1537 #include <pthread.h>
1538 ]], [[
1539   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1540 ]])], [
1541 AC_MSG_RESULT([yes])
1542 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1543           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1544 ], [
1545 AC_MSG_RESULT([no])
1549 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1551 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1553 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1554 #define _GNU_SOURCE
1555 #include <pthread.h>
1556 ]], [[
1557   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1558 ]])], [
1559 AC_MSG_RESULT([yes])
1560 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1561           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1562 ], [
1563 AC_MSG_RESULT([no])
1567 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1569 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1571 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1572 #define _GNU_SOURCE
1573 #include <pthread.h>
1574 ]], [[
1575   return (PTHREAD_MUTEX_RECURSIVE_NP);
1576 ]])], [
1577 AC_MSG_RESULT([yes])
1578 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1579           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1580 ], [
1581 AC_MSG_RESULT([no])
1585 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1587 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1589 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1590 #define _GNU_SOURCE
1591 #include <pthread.h>
1592 ]], [[
1593   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1594   return 0;
1595 ]])], [
1596 AC_MSG_RESULT([yes])
1597 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1598           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1599 ], [
1600 AC_MSG_RESULT([no])
1604 # Check whether pthread_mutex_t has a member called __m_kind.
1606 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1607                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1608                            1,                                   
1609                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1610                 ],
1611                 [],
1612                 [#include <pthread.h>])
1615 # Check whether pthread_mutex_t has a member called __data.__kind.
1617 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1618                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1619                           1,
1620                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1621                 ],
1622                 [],
1623                 [#include <pthread.h>])
1625 # Convenience function.  Set flags based on the existing HWCAP entries.
1626 # The AT_HWCAP entries are generated by glibc, and are based on
1627 # functions supported by the hardware/system/libc.
1628 # Subsequent support for whether the capability will actually be utilized
1629 # will also be checked against the compiler capabilities.
1630 # called as
1631 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1632 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1633   AUXV_CHECK_FOR=$1
1634   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1635   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1636   then
1637     AC_MSG_RESULT([yes])
1638     AC_SUBST([$2],[yes])
1639   else
1640     AC_MSG_RESULT([no])
1641     AC_SUBST([$2],[])
1642   fi
1645 # gather hardware capabilities. (hardware/kernel/libc)
1646 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1647 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1648 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1649 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1650 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1651 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1652 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1653 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1654 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1655 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1657 # ISA Levels
1658 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1659 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1660 # compiler support for isa 2.07 level instructions
1661 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1662 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1663 ]], [[
1664   __asm__ __volatile__("mtvsrd 1,2 ");
1665 ]])], [
1666 ac_asm_have_isa_2_07=yes
1667 AC_MSG_RESULT([yes])
1668 ], [
1669 ac_asm_have_isa_2_07=no
1670 AC_MSG_RESULT([no])
1672 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1673                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1675 # altivec (vsx) support.
1676 # does this compiler support -maltivec and does it have the include file
1677 # <altivec.h> ?
1678 AC_MSG_CHECKING([for Altivec support in the compiler ])
1679 safe_CFLAGS=$CFLAGS
1680 CFLAGS="-maltivec -Werror"
1681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1682 #include <altivec.h>
1683 ]], [[
1684   vector unsigned int v;
1685 ]])], [
1686 ac_have_altivec=yes
1687 AC_MSG_RESULT([yes])
1688 ], [
1689 ac_have_altivec=no
1690 AC_MSG_RESULT([no])
1692 CFLAGS=$safe_CFLAGS
1693 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1694                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1696 # Check that both: the compiler supports -mvsx and that the assembler
1697 # understands VSX instructions.  If either of those doesn't work,
1698 # conclude that we can't do VSX.
1699 AC_MSG_CHECKING([for VSX compiler flag support])
1700 safe_CFLAGS=$CFLAGS
1701 CFLAGS="-mvsx -Werror"
1702 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1703 ]], [[
1704 ]])], [
1705 ac_compiler_supports_vsx_flag=yes
1706 AC_MSG_RESULT([yes])
1707 ], [
1708 ac_compiler_supports_vsx_flag=no
1709 AC_MSG_RESULT([no])
1711 CFLAGS=$safe_CFLAGS
1713 AC_MSG_CHECKING([for VSX support in the assembler ])
1714 safe_CFLAGS=$CFLAGS
1715 CFLAGS="-mvsx -Werror"
1716 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1717 #include <altivec.h>
1718 ]], [[
1719   vector unsigned int v;
1720   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1721 ]])], [
1722 ac_compiler_supports_vsx=yes
1723 AC_MSG_RESULT([yes])
1724 ], [
1725 ac_compiler_supports_vsx=no
1726 AC_MSG_RESULT([no])
1728 CFLAGS=$safe_CFLAGS
1729 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1730                              -a x$ac_compiler_supports_vsx = xyes \
1731                              -a x$HWCAP_HAS_VSX = xyes ])
1733 # DFP (Decimal Float)
1734 # The initial DFP support was added in Power 6.  The dcffix instruction
1735 # support was added in Power 7.
1736 AC_MSG_CHECKING([that assembler knows DFP])
1737 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1738 ]], [[
1739   #ifdef __s390__
1740   __asm__ __volatile__("adtr 1, 2, 3")
1741   #else
1742 __asm__ __volatile__(".machine power7;\n" \
1743   "dadd 1, 2, 3;\n" \
1744   "dcffix 1, 2");
1745   #endif
1746 ]])], [
1747 ac_asm_have_dfp=yes
1748 AC_MSG_RESULT([yes])
1749 ], [
1750 ac_asm_have_dfp=no
1751 AC_MSG_RESULT([no])
1753 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1754 safe_CFLAGS=$CFLAGS
1755 CFLAGS="-mhard-dfp -Werror"
1757 # The dcffix instruction is Power 7
1758 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1759 ]], [[
1760   #ifdef __s390__
1761   __asm__ __volatile__("adtr 1, 2, 3")
1762   #else
1763   __asm__ __volatile__(".machine power7;\n" \
1764   "dadd 1, 2, 3;\n" \
1765   "dcffix 1, 2");
1766   #endif
1767 ]])], [
1768 ac_compiler_have_dfp=yes
1769 AC_MSG_RESULT([yes])
1770 ], [
1771 ac_compiler_have_dfp=no
1772 AC_MSG_RESULT([no])
1774 CFLAGS=$safe_CFLAGS
1775 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1776                           -a x$ac_compiler_have_dfp = xyes \
1777                           -a x$HWCAP_HAS_DFP = xyes )
1779 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1780 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1781 ]], [[
1782   _Decimal64 x = 0.0DD;
1783 ]])], [
1784 ac_compiler_have_dfp_type=yes
1785 AC_MSG_RESULT([yes])
1786 ], [
1787 ac_compiler_have_dfp_type=no
1788 AC_MSG_RESULT([no])
1790 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1791                                   -a x$HWCAP_HAS_DFP = xyes )
1794 # HTM (Hardware Transactional Memory)
1795 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1796 safe_CFLAGS=$CFLAGS
1797 CFLAGS="-mhtm -Werror"
1798 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1799 ]], [[
1800   return 0;
1801 ]])], [
1802 AC_MSG_RESULT([yes])
1803 ac_compiler_supports_htm=yes
1804 ], [
1805 AC_MSG_RESULT([no])
1806 ac_compiler_supports_htm=no
1808 CFLAGS=$safe_CFLAGS
1810 AC_MSG_CHECKING([if compiler can find the htm builtins])
1811 safe_CFLAGS=$CFLAGS
1812 CFLAGS="-mhtm -Werror"
1813  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1814  ]], [[
1815    if (__builtin_tbegin (0))
1816       __builtin_tend (0);
1817  ]])], [
1818  AC_MSG_RESULT([yes])
1819 ac_compiler_sees_htm_builtins=yes
1820  ], [
1821  AC_MSG_RESULT([no])
1822 ac_compiler_sees_htm_builtins=no
1823  ])
1824 CFLAGS=$safe_CFLAGS
1826 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1827                                -a x$ac_compiler_sees_htm_builtins = xyes \
1828                                -a x$HWCAP_HAS_HTM = xyes )
1830 # isa 3.0 checking. (actually 3.0 or newer)
1831 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1833 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1834 ]], [[
1835 __asm__ __volatile__ (".machine power9;\n" \
1836         "cnttzw   1,3; \n" );
1837 ]])], [
1838 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1839 # cpabort support
1840 safe_CFLAGS=$CFLAGS
1841 CFLAGS="-DHAS_ISA_3_00"
1842 ac_asm_have_isa_3_00=yes
1843 AC_MSG_RESULT([yes])
1844 ], [
1845 ac_asm_have_isa_3_00=no
1846 AC_MSG_RESULT([no])
1848 CFLAGS=$safe_CFLAGS
1850 # xscvhpdp checking
1851 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1854 ]], [[
1855 __asm__ __volatile__ (".machine power9;\n" \
1856         "xscvhpdp 1,2;\n" );
1857 ]])], [
1858 ac_asm_have_xscvhpdp=yes
1859 AC_MSG_RESULT([yes])
1860 ], [
1861 ac_asm_have_xscvhpdp=no
1862 AC_MSG_RESULT([no])
1865 # darn instruction checking
1866 AC_MSG_CHECKING([that assembler knows darn instruction ])
1868 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1869 ]], [[
1870   __asm__ __volatile__(".machine power9; darn 1,0 ");
1871 ]])], [
1872 ac_asm_have_darn_inst=yes
1873 AC_MSG_RESULT([yes])
1874 ], [
1875 ac_asm_have_darn_inst=no
1876 AC_MSG_RESULT([no])
1879 # isa 3.01 checking
1880 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1881 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1882 ]], [[
1883 __asm__ __volatile__ (".machine power10;\n" \
1884         "brh 1,2;\n ");
1885 ]])], [
1886 ac_asm_have_isa_3_1=yes
1887 AC_MSG_RESULT([yes])
1888 ], [
1889 ac_asm_have_isa_3_1=no
1890 AC_MSG_RESULT([no])
1894 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1895                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1897 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1898 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1900 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1901                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1903 # Check for pthread_create@GLIBC2.0
1904 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1906 safe_CFLAGS=$CFLAGS
1907 CFLAGS="-lpthread -Werror"
1908 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1909 extern int pthread_create_glibc_2_0(void*, const void*,
1910                                     void *(*)(void*), void*);
1911 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1912 ]], [[
1913 #ifdef __powerpc__
1915  * Apparently on PowerPC linking this program succeeds and generates an
1916  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1917  */
1918 #error This test does not work properly on PowerPC.
1919 #else
1920   pthread_create_glibc_2_0(0, 0, 0, 0);
1921 #endif
1922   return 0;
1923 ]])], [
1924 ac_have_pthread_create_glibc_2_0=yes
1925 AC_MSG_RESULT([yes])
1926 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1927           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1928 ], [
1929 ac_have_pthread_create_glibc_2_0=no
1930 AC_MSG_RESULT([no])
1932 CFLAGS=$safe_CFLAGS
1934 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1935                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1938 # Check for dlinfo RTLD_DI_TLS_MODID
1939 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1941 safe_LIBS="$LIBS"
1942 LIBS="-ldl"
1943 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1944 #ifndef _GNU_SOURCE
1945 #define _GNU_SOURCE
1946 #endif
1947 #include <link.h>
1948 #include <dlfcn.h>
1949 ]], [[
1950   size_t sizes[10000];
1951   size_t modid_offset;
1952   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1953   return 0;
1954 ]])], [
1955 ac_have_dlinfo_rtld_di_tls_modid=yes
1956 AC_MSG_RESULT([yes])
1957 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1958           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1959 ], [
1960 ac_have_dlinfo_rtld_di_tls_modid=no
1961 AC_MSG_RESULT([no])
1963 LIBS=$safe_LIBS
1965 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1966                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1969 # Check for eventfd_t, eventfd() and eventfd_read()
1970 AC_MSG_CHECKING([for eventfd()])
1972 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1973 #include <sys/eventfd.h>
1974 ]], [[
1975   eventfd_t ev;
1976   int fd;
1978   fd = eventfd(5, 0);
1979   eventfd_read(fd, &ev);
1980   return 0;
1981 ]])], [
1982 AC_MSG_RESULT([yes])
1983 AC_DEFINE([HAVE_EVENTFD], 1,
1984           [Define to 1 if you have the `eventfd' function.])
1985 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1986           [Define to 1 if you have the `eventfd_read' function.])
1987 ], [
1988 AC_MSG_RESULT([no])
1991 # Check whether compiler can process #include <thread> without errors
1992 # clang 3.3 cannot process <thread> from e.g.
1993 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1995 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1996 AC_LANG(C++)
1997 safe_CXXFLAGS=$CXXFLAGS
1998 CXXFLAGS=-std=c++0x
2000 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2001 #include <thread> 
2002 ])],
2004 ac_cxx_can_include_thread_header=yes
2005 AC_MSG_RESULT([yes])
2006 ], [
2007 ac_cxx_can_include_thread_header=no
2008 AC_MSG_RESULT([no])
2010 CXXFLAGS=$safe_CXXFLAGS
2011 AC_LANG(C)
2013 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2015 # Check whether compiler can process #include <condition_variable> without errors
2017 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2018 AC_LANG(C++)
2019 safe_CXXFLAGS=$CXXFLAGS
2020 CXXFLAGS=-std=c++0x
2022 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2023 #include <condition_variable> 
2024 ])],
2026 ac_cxx_can_include_condition_variable_header=yes
2027 AC_MSG_RESULT([yes])
2028 ], [
2029 ac_cxx_can_include_condition_variable_header=no
2030 AC_MSG_RESULT([no])
2032 CXXFLAGS=$safe_CXXFLAGS
2033 AC_LANG(C)
2035 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2037 # check for std::shared_timed_mutex, this is a C++ 14 feature
2039 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2040 AC_LANG(C++)
2041 safe_CXXFLAGS=$CXXFLAGS
2042 CXXFLAGS="-std=c++1y -pthread"
2044 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2045 #include <shared_mutex>
2046 std::shared_timed_mutex test_mutex;
2047 ])],
2049 ac_cxx_can_use_shared_timed_mutex=yes
2050 AC_MSG_RESULT([yes])
2051 ], [
2052 ac_cxx_can_use_shared_timed_mutex=no
2053 AC_MSG_RESULT([no])
2055 CXXFLAGS=$safe_CXXFLAGS
2056 AC_LANG(C)
2058 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2060 # check for std::shared_mutex, this is a C++ 11 feature
2062 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2063 AC_LANG(C++)
2064 safe_CXXFLAGS=$CXXFLAGS
2065 CXXFLAGS="-std=c++0x -pthread"
2067 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2068 #include <mutex>
2069 std::timed_mutex test_mutex;
2070 ])],
2072 ac_cxx_can_use_timed_mutex=yes
2073 AC_MSG_RESULT([yes])
2074 ], [
2075 ac_cxx_can_use_timed_mutex=no
2076 AC_MSG_RESULT([no])
2078 CXXFLAGS=$safe_CXXFLAGS
2079 AC_LANG(C)
2081 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2083 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2084 # of the user_regs_struct from sys/user.h. They are structurally the same
2085 # but we get either one or the other.
2087 AC_CHECK_TYPE([struct user_regs_struct],
2088               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2089               [[#include <sys/ptrace.h>]
2090                [#include <sys/time.h>]
2091                [#include <sys/user.h>]])
2092 if test "$sys_user_has_user_regs" = "yes"; then
2093   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2094             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2097 AC_MSG_CHECKING([for __NR_membarrier])
2098 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2099 #include <linux/unistd.h>
2100 ]], [[
2101 return __NR_membarrier
2102 ]])], [
2103 ac_have_nr_membarrier=yes
2104 AC_MSG_RESULT([yes])
2105 ], [
2106 ac_have_nr_membarrier=no
2107 AC_MSG_RESULT([no])
2110 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2112 #----------------------------------------------------------------------------
2113 # Checking for supported compiler flags.
2114 #----------------------------------------------------------------------------
2116 case "${host_cpu}" in
2117     mips*)
2118         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2119         if test -z "$ARCH"; then
2120           # does this compiler support -march=mips32 (mips32 default) ?
2121           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2123           safe_CFLAGS=$CFLAGS
2124           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2126           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2127             return 0;
2128           ]])], [
2129           FLAG_M32="-mips32 -mabi=32"
2130           AC_MSG_RESULT([yes])
2131           ], [
2132           FLAG_M32=""
2133           AC_MSG_RESULT([no])
2134           ])
2135           CFLAGS=$safe_CFLAGS
2137           AC_SUBST(FLAG_M32)
2140           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2141           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2143           safe_CFLAGS=$CFLAGS
2144           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2146           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2147             return 0;
2148           ]])], [
2149           FLAG_M64="-march=mips64r2 -mabi=64"
2150           AC_MSG_RESULT([yes])
2151           ], [
2152           FLAG_M64=""
2153           AC_MSG_RESULT([no])
2154           ])
2155           CFLAGS=$safe_CFLAGS
2157           AC_SUBST(FLAG_M64)
2158         fi
2159         ;;
2160     nanomips*)
2161         ;;
2162     *)
2163         # does this compiler support -m32 ?
2164         AC_MSG_CHECKING([if gcc accepts -m32])
2166         safe_CFLAGS=$CFLAGS
2167         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2169         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2170           return 0;
2171         ]])], [
2172         FLAG_M32="${FLAG_32ON64} -m32"
2173         AC_MSG_RESULT([yes])
2174         ], [
2175         FLAG_M32=""
2176         AC_MSG_RESULT([no])
2177         ])
2178         CFLAGS=$safe_CFLAGS
2180         AC_SUBST(FLAG_M32)
2183         # does this compiler support -m64 ?
2184         AC_MSG_CHECKING([if gcc accepts -m64])
2186         safe_CFLAGS=$CFLAGS
2187         CFLAGS="-m64 -Werror"
2189         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2190           return 0;
2191         ]])], [
2192         FLAG_M64="-m64"
2193         AC_MSG_RESULT([yes])
2194         ], [
2195         FLAG_M64=""
2196         AC_MSG_RESULT([no])
2197         ])
2198         CFLAGS=$safe_CFLAGS
2200         AC_SUBST(FLAG_M64)
2201         ;;
2202 esac
2205 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2206 if test -z "$ARCH"; then
2207   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2208   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2210   safe_CFLAGS=$CFLAGS
2211   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2213   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2214     return 0;
2215   ]])], [
2216   FLAG_OCTEON="-march=octeon"
2217   AC_MSG_RESULT([yes])
2218   ], [
2219   FLAG_OCTEON=""
2220   AC_MSG_RESULT([no])
2221   ])
2222   CFLAGS=$safe_CFLAGS
2224   AC_SUBST(FLAG_OCTEON)
2227   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2228   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2230   safe_CFLAGS=$CFLAGS
2231   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2233   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2234     return 0;
2235   ]])], [
2236   FLAG_OCTEON2="-march=octeon2"
2237   AC_MSG_RESULT([yes])
2238   ], [
2239   FLAG_OCTEON2=""
2240   AC_MSG_RESULT([no])
2241   ])
2242   CFLAGS=$safe_CFLAGS
2244   AC_SUBST(FLAG_OCTEON2)
2248 # does this compiler support -mmsa (MIPS MSA ASE) ?
2249 AC_MSG_CHECKING([if gcc accepts -mmsa])
2251 safe_CFLAGS=$CFLAGS
2252 CFLAGS="$CFLAGS -mmsa -Werror"
2254 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2255     return 0;
2256 ]])], [
2257 FLAG_MSA="-mmsa"
2258 AC_MSG_RESULT([yes])
2259 ], [
2260 FLAG_MSA=""
2261 AC_MSG_RESULT([no])
2263 CFLAGS=$safe_CFLAGS
2265 AC_SUBST(FLAG_MSA)
2267 # Are we compiling for the MIPS64 n32 ABI?
2268 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2269 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2270 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2271 #error NO
2272 #endif
2273 ]])], [
2274 VGCONF_ABI=N32
2275 FLAG_M64="-march=mips64r2 -mabi=n32"
2276 AC_MSG_RESULT([yes])
2277 ], [
2278 AC_MSG_RESULT([no])
2281 # Are we compiling for the MIPS64 n64 ABI?
2282 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2283 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2284 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2285 #error NO
2286 #endif
2287 ]])], [
2288 VGCONF_ABI=64
2289 AC_MSG_RESULT([yes])
2290 ], [
2291 AC_MSG_RESULT([no])
2294 # We enter the code block below in the following case:
2295 # Target architecture is set to mips64, the desired abi
2296 # was not specified and the compiler's default abi setting
2297 # is neither n32 nor n64.
2298 # Probe for and set the abi to either n64 or n32, in that order,
2299 # which is required for a mips64 build of valgrind.
2300 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2301   safe_CFLAGS=$CFLAGS
2302   CFLAGS="$CFLAGS -mabi=64 -Werror"
2303   AC_MSG_CHECKING([if gcc is n64 capable])
2304   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2305       return 0;
2306   ]])], [
2307   VGCONF_ABI=64
2308   AC_MSG_RESULT([yes])
2309   ], [
2310   AC_MSG_RESULT([no])
2311   ])
2312   CFLAGS=$safe_CFLAGS
2314   if test "x$VGCONF_ABI" = "x"; then
2315     safe_CFLAGS=$CFLAGS
2316     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2317     AC_MSG_CHECKING([if gcc is n32 capable])
2318     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2319         return 0;
2320     ]])], [
2321     VGCONF_ABI=N32
2322     FLAG_M64="-march=mips64r2 -mabi=n32"
2323     AC_MSG_RESULT([yes])
2324     ], [
2325     AC_MSG_RESULT([no])
2326     ])
2327     CFLAGS=$safe_CFLAGS
2328   fi
2331 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2332                [test x$VGCONF_ABI != x])
2333 AC_SUBST(VGCONF_ABI)
2336 # does this compiler support -mmmx ?
2337 AC_MSG_CHECKING([if gcc accepts -mmmx])
2339 safe_CFLAGS=$CFLAGS
2340 CFLAGS="-mmmx -Werror"
2342 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2343   return 0;
2344 ]])], [
2345 FLAG_MMMX="-mmmx"
2346 AC_MSG_RESULT([yes])
2347 ], [
2348 FLAG_MMMX=""
2349 AC_MSG_RESULT([no])
2351 CFLAGS=$safe_CFLAGS
2353 AC_SUBST(FLAG_MMMX)
2356 # does this compiler support -msse ?
2357 AC_MSG_CHECKING([if gcc accepts -msse])
2359 safe_CFLAGS=$CFLAGS
2360 CFLAGS="-msse -Werror"
2362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2363   return 0;
2364 ]])], [
2365 FLAG_MSSE="-msse"
2366 AC_MSG_RESULT([yes])
2367 ], [
2368 FLAG_MSSE=""
2369 AC_MSG_RESULT([no])
2371 CFLAGS=$safe_CFLAGS
2373 AC_SUBST(FLAG_MSSE)
2376 # does this compiler support -mpreferred-stack-boundary=2 when
2377 # generating code for a 32-bit target?  Note that we only care about
2378 # this when generating code for (32-bit) x86, so if the compiler
2379 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2380 # the Memcheck and other helper functions, that is a bit slower than
2381 # it could be, on x86; and no difference at all on any other platform.
2382 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2384 safe_CFLAGS=$CFLAGS
2385 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2387 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2388   return 0;
2389 ]])], [
2390 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2391 AC_MSG_RESULT([yes])
2392 ], [
2393 PREFERRED_STACK_BOUNDARY_2=""
2394 AC_MSG_RESULT([no])
2396 CFLAGS=$safe_CFLAGS
2398 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2401 # does this compiler support -mlong-double-128 ?
2402 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2403 safe_CFLAGS=$CFLAGS
2404 CFLAGS="-mlong-double-128 -Werror"
2405 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2406   return 0;
2407 ]])], [
2408 ac_compiler_supports_mlong_double_128=yes
2409 AC_MSG_RESULT([yes])
2410 ], [
2411 ac_compiler_supports_mlong_double_128=no
2412 AC_MSG_RESULT([no])
2414 CFLAGS=$safe_CFLAGS
2415 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2416 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2417 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2419 # does this toolchain support lto ?
2420 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2421 # are not defined
2422 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2423 # a lot slower, and so not appropriate for Valgrind developments.
2424 # --enable-lto=yes should be used by distro packagers.
2425 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2426    [AC_ARG_ENABLE(lto,
2427       [  --enable-lto          enables building with link time optimisation],
2428       [vg_cv_lto=$enableval],
2429       [vg_cv_lto=no])])
2431 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2432 AC_MSG_CHECKING([if toolchain accepts lto])
2433 safe_CFLAGS=$CFLAGS
2434 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2435 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2436 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2437 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2440   extern void somefun(void);
2441   somefun();
2442   return 0;
2443 ]])], [
2444 LTO_CFLAGS=$TEST_LTO_CFLAGS
2445 AC_MSG_RESULT([yes])
2446 ], [
2447 LTO_CFLAGS=""
2448 AC_MSG_RESULT([no])
2450 CFLAGS=$safe_CFLAGS
2453 AC_SUBST(LTO_CFLAGS)
2455 # if we could not compile with lto args, or lto was disabled,
2456 # then set LTO_AR/LTO_RANLIB to the non lto values
2457 # define in config.h ENABLE_LTO (not needed by the code currently, but
2458 # this guarantees we recompile everything if we re-configure and rebuild
2459 # in a build dir previously build with another value of --enable-lto
2460 if test "x${LTO_CFLAGS}" = "x"; then
2461    LTO_AR=${AR}
2462    LTO_RANLIB=${RANLIB}
2463    vg_cv_lto=no
2464 else
2465    vg_cv_lto=yes
2466    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2469 # Convenience function to check whether GCC supports a particular
2470 # warning option. Takes two arguments,
2471 # first the warning flag name to check (without -W), then the
2472 # substitution name to set with -Wno-warning-flag if the flag exists,
2473 # or the empty string if the compiler doesn't accept the flag. Note
2474 # that checking is done against the warning flag itself, but the
2475 # substitution is then done to cancel the warning flag.
2476 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2477   AC_MSG_CHECKING([if gcc accepts -W$1])
2478   safe_CFLAGS=$CFLAGS
2479   CFLAGS="-W$1 -Werror"
2480   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2481   AC_SUBST([$2], [-Wno-$1])
2482   AC_MSG_RESULT([yes])], [
2483   AC_SUBST([$2], [])
2484   AC_MSG_RESULT([no])])
2485   CFLAGS=$safe_CFLAGS
2488 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2489 # -W$1  (instead of -Wno-$1).
2490 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2491   AC_MSG_CHECKING([if gcc accepts -W$1])
2492   safe_CFLAGS=$CFLAGS
2493   CFLAGS="-W$1 -Werror"
2494   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2495   AC_SUBST([$2], [-W$1])
2496   AC_MSG_RESULT([yes])], [
2497   AC_SUBST([$2], [])
2498   AC_MSG_RESULT([no])])
2499   CFLAGS=$safe_CFLAGS
2502 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2503 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2504 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2505 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2506 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2507 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2508 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2509 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2510 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2511 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2513 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2514 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2515 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2516 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2517 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2518 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2519 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2520 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2521 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2522 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2523 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2525 # Does this compiler support -Wformat-security ?
2526 # Special handling is needed, because certain GCC versions require -Wformat
2527 # being present if -Wformat-security is given. Otherwise a warning is issued.
2528 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2529 # And with that the warning will be turned into an error with the result
2530 # that -Wformat-security is believed to be unsupported when in fact it is.
2531 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2532 safe_CFLAGS=$CFLAGS
2533 CFLAGS="-Wformat -Wformat-security -Werror"
2534 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2535 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2536 AC_MSG_RESULT([yes])], [
2537 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2538 AC_MSG_RESULT([no])])
2539 CFLAGS=$safe_CFLAGS
2541 # does this compiler support -Wextra or the older -W ?
2543 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2545 safe_CFLAGS=$CFLAGS
2546 CFLAGS="-Wextra -Werror"
2548 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2549   return 0;
2550 ]])], [
2551 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2552 AC_MSG_RESULT([-Wextra])
2553 ], [
2554   CFLAGS="-W -Werror"
2555   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2556     return 0;
2557   ]])], [
2558   AC_SUBST([FLAG_W_EXTRA], [-W])
2559   AC_MSG_RESULT([-W])
2560   ], [
2561   AC_SUBST([FLAG_W_EXTRA], [])
2562   AC_MSG_RESULT([not supported])
2563   ])
2565 CFLAGS=$safe_CFLAGS
2567 # On ARM we do not want to pass -Wcast-align as that produces loads
2568 # of warnings. GCC is just being conservative. See here:
2569 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2570 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2571   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2572 else
2573   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2576 # does this compiler support -faligned-new ?
2577 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2579 safe_CXXFLAGS=$CXXFLAGS
2580 CXXFLAGS="-faligned-new -Werror"
2582 AC_LANG(C++)
2583 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2584   return 0;
2585 ]])], [
2586 FLAG_FALIGNED_NEW="-faligned-new"
2587 AC_MSG_RESULT([yes])
2588 ], [
2589 FLAG_FALIGNED_NEW=""
2590 AC_MSG_RESULT([no])
2592 CXXFLAGS=$safe_CXXFLAGS
2593 AC_LANG(C)
2595 AC_SUBST(FLAG_FALIGNED_NEW)
2597 # does this compiler support -fsized-deallocation ?
2598 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2600 safe_CXXFLAGS=$CXXFLAGS
2601 CXXFLAGS="-fsized-deallocation -Werror"
2603 AC_LANG(C++)
2604 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2605   return 0;
2606 ]])], [
2607 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2608 ac_have_sized_deallocation=yes
2609 AC_MSG_RESULT([yes])
2610 ], [
2611 FLAG_FSIZED_DEALLOCATION=""
2612 ac_have_sized_deallocation=no
2613 AC_MSG_RESULT([no])
2615 CXXFLAGS=$safe_CXXFLAGS
2616 AC_LANG(C)
2618 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2619 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2621 # does this compiler support C++17 aligned new/delete?
2622 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2624 safe_CXXFLAGS=$CXXFLAGS
2625 CXXFLAGS="-std=c++17"
2627 AC_LANG(C++)
2628 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2629 #include <cstdlib>
2630 #include <new>
2631 ]], [[
2632   operator delete(nullptr, std::align_val_t(64U));
2633 ]])], [
2634 ac_have_aligned_cxx_alloc=yes
2635 AC_MSG_RESULT([yes])
2636 ], [
2637 ac_have_aligned_cxx_alloc=no
2638 AC_MSG_RESULT([no])
2640 CXXFLAGS=$safe_CXXFLAGS
2641 AC_LANG(C)
2643 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2645 # does this compiler support -fno-stack-protector ?
2646 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2648 safe_CFLAGS=$CFLAGS
2649 CFLAGS="-fno-stack-protector -Werror"
2651 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2652   return 0;
2653 ]])], [
2654 no_stack_protector=yes
2655 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2656 AC_MSG_RESULT([yes])
2657 ], [
2658 no_stack_protector=no
2659 FLAG_FNO_STACK_PROTECTOR=""
2660 AC_MSG_RESULT([no])
2662 CFLAGS=$safe_CFLAGS
2664 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2666 # does this compiler support -finline-functions ?
2667 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2669 safe_CFLAGS=$CFLAGS
2670 CFLAGS="-finline-functions -Werror"
2672 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2673   return 0;
2674 ]])], [
2675 inline_functions=yes
2676 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2677 AC_MSG_RESULT([yes])
2678 ], [
2679 inline_functions=no
2680 FLAG_FINLINE_FUNCTIONS=""
2681 AC_MSG_RESULT([no])
2683 CFLAGS=$safe_CFLAGS
2685 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2687 # Does GCC support disabling Identical Code Folding?
2688 # We want to disabled Identical Code Folding for the
2689 # tools preload shared objects to get better backraces.
2690 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2691 # "The optimization reduces code size and may disturb
2692 #  unwind stacks by replacing a function by equivalent
2693 #  one with a different name."
2694 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2696 safe_CFLAGS=$CFLAGS
2697 CFLAGS="-fno-ipa-icf -Werror"
2699 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2700   return 0;
2701 ]])], [
2702 no_ipa_icf=yes
2703 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2704 AC_MSG_RESULT([yes])
2705 ], [
2706 no_ipa_icf=no
2707 FLAG_FNO_IPA_ICF=""
2708 AC_MSG_RESULT([no])
2710 CFLAGS=$safe_CFLAGS
2712 AC_SUBST(FLAG_FNO_IPA_ICF)
2715 # Does this compiler support -fsanitize=undefined. This is true for
2716 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2717 # also checks for alignment violations on memory accesses which the valgrind
2718 # code base is sprinkled (if not littered) with. As those alignment issues
2719 # don't pose a problem we want to suppress warnings about them.
2720 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2721 # GCCs do not support that.
2723 # Only checked for if --enable-ubsan was given.
2724 if test "x${vg_cv_ubsan}" = "xyes"; then
2725 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2726 safe_CFLAGS=$CFLAGS
2727 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2728 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2729   return 0;
2730 ]])], [
2731 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2732 LIB_UBSAN="-static-libubsan"
2733 AC_MSG_RESULT([yes])
2734 ], [
2735 CFLAGS="-fsanitize=undefined -Werror"
2736 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2737   return 0;
2738 ]])], [
2739 FLAG_FSANITIZE="-fsanitize=undefined"
2740 LIB_UBSAN="-static-libubsan"
2741 AC_MSG_RESULT([yes])
2742 ], [
2743 FLAG_FSANITIZE=""
2744 LIB_UBSAN=""
2745 AC_MSG_RESULT([no])
2748 CFLAGS=$safe_CFLAGS
2749 AC_SUBST(FLAG_FSANITIZE)
2750 AC_SUBST(LIB_UBSAN)
2752 # does this compiler support --param inline-unit-growth=... ?
2754 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2756 safe_CFLAGS=$CFLAGS
2757 CFLAGS="--param inline-unit-growth=900 -Werror"
2759 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2760   return 0;
2761 ]])], [
2762 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2763          ["--param inline-unit-growth=900"])
2764 AC_MSG_RESULT([yes])
2765 ], [
2766 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2767 AC_MSG_RESULT([no])
2769 CFLAGS=$safe_CFLAGS
2772 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2774 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2776 safe_CFLAGS=$CFLAGS
2777 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2779 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2780   return 0;
2781 ]])], [
2782 ac_have_dwarf4=yes
2783 AC_MSG_RESULT([yes])
2784 ], [
2785 ac_have_dwarf4=no
2786 AC_MSG_RESULT([no])
2788 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2789 CFLAGS=$safe_CFLAGS
2792 # does this compiler support -g -gz=zlib ?
2794 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2796 safe_CFLAGS=$CFLAGS
2797 CFLAGS="-g -gz=zlib"
2799 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2800   return 0;
2801 ]])], [
2802 ac_have_gz_zlib=yes
2803 AC_MSG_RESULT([yes])
2804 ], [
2805 ac_have_gz_zlib=no
2806 AC_MSG_RESULT([no])
2808 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2809 CFLAGS=$safe_CFLAGS
2812 # does this compiler support -g -gz=zlib-gnu ?
2814 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2816 safe_CFLAGS=$CFLAGS
2817 CFLAGS="-g -gz=zlib-gnu"
2819 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2820   return 0;
2821 ]])], [
2822 ac_have_gz_zlib_gnu=yes
2823 AC_MSG_RESULT([yes])
2824 ], [
2825 ac_have_gz_zlib_gnu=no
2826 AC_MSG_RESULT([no])
2828 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2829 CFLAGS=$safe_CFLAGS
2832 # does this compiler support nested functions ?
2834 AC_MSG_CHECKING([if gcc accepts nested functions])
2836 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2837   int foo() { return 1; }
2838   return foo();
2839 ]])], [
2840 ac_have_nested_functions=yes
2841 AC_MSG_RESULT([yes])
2842 ], [
2843 ac_have_nested_functions=no
2844 AC_MSG_RESULT([no])
2846 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2849 # does this compiler support the 'p' constraint in ASM statements ?
2851 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2854    char *p;
2855    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2856 ]])], [
2857 ac_have_asm_constraint_p=yes
2858 AC_MSG_RESULT([yes])
2859 ], [
2860 ac_have_asm_constraint_p=no
2861 AC_MSG_RESULT([no])
2863 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2866 # Does this compiler and linker support -pie?
2867 # Some compilers actually do not support -pie and report its usage
2868 # as an error. We need to check if it is safe to use it first.
2870 AC_MSG_CHECKING([if gcc accepts -pie])
2872 safe_CFLAGS=$CFLAGS
2873 CFLAGS="-pie"
2875 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2876   return 0;
2877 ]])], [
2878 AC_SUBST([FLAG_PIE], ["-pie"])
2879 AC_MSG_RESULT([yes])
2880 ], [
2881 AC_SUBST([FLAG_PIE], [""])
2882 AC_MSG_RESULT([no])
2884 CFLAGS=$safe_CFLAGS
2887 # Does this compiler support -no-pie?
2888 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2889 # default. However this gets in the way with some tests, we use -no-pie
2890 # for these.
2892 AC_MSG_CHECKING([if gcc accepts -no-pie])
2894 safe_CFLAGS=$CFLAGS
2895 CFLAGS="-no-pie -Werror"
2897 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2898   return 0;
2899 ]])], [
2900 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2901 AC_MSG_RESULT([yes])
2902 ], [
2903 AC_SUBST([FLAG_NO_PIE], [""])
2904 AC_MSG_RESULT([no])
2906 CFLAGS=$safe_CFLAGS
2909 # We want to use use the -Ttext-segment option to the linker.
2910 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2911 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2912 # semantics are NOT what we want (GNU gold -Ttext is fine).
2914 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2915 # will reside. -Ttext aligns just the .text section start (but not any
2916 # other section).
2918 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
2919 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
2920 # The --image-base option (since version 6.0?) provides the semantics needed.
2921 # -Ttext-segment generates an error, but -Ttext now more closely
2922 # follows the GNU (bfd) ld's -Ttext.
2924 # So test first for --image-base support, and if that fails then
2925 # for -Ttext-segment which is supported by all bfd ld versions
2926 # and use that if it exists. If it doesn't exist it must be an older
2927 # version of gold and we can fall back to using -Ttext which has the
2928 # right semantics.
2930 safe_CFLAGS=$CFLAGS
2931 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
2933 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
2935 AC_LINK_IFELSE(
2936 [AC_LANG_SOURCE([int _start () { return 0; }])],
2938   linker_using_t_text="no"
2939   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
2940   AC_MSG_RESULT([yes])
2941 ], [
2942   AC_MSG_RESULT([no])
2944   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2946   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2948   AC_LINK_IFELSE(
2949   [AC_LANG_SOURCE([int _start () { return 0; }])],
2950   [
2951     linker_using_t_text="no"
2952     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2953     AC_MSG_RESULT([yes])
2954   ], [
2955     linker_using_t_text="yes"
2956     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2957     AC_MSG_RESULT([no])
2958   ])
2961 CFLAGS=$safe_CFLAGS
2963 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
2964 # have to strip any build-id ELF NOTEs from the statically linked tools.
2965 # Otherwise the build-id NOTE might end up at the default load address.
2966 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2967 # gold versions also support -Ttext-segment. So just assume that unless
2968 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2969 if test "x${linker_using_t_text}" = "xyes"; then
2970 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2971 # does the linker support -Wl,--build-id=none ?  Note, it's
2972 # important that we test indirectly via whichever C compiler
2973 # is selected, rather than testing /usr/bin/ld or whatever
2974 # directly.
2975 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2976 safe_CFLAGS=$CFLAGS
2977 CFLAGS="-Wl,--build-id=none -Werror"
2979 AC_LINK_IFELSE(
2980 [AC_LANG_PROGRAM([ ], [return 0;])],
2982   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2983   AC_MSG_RESULT([yes])
2984 ], [
2985   AC_SUBST([FLAG_NO_BUILD_ID], [""])
2986   AC_MSG_RESULT([no])
2988 else
2989 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
2990 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2992 CFLAGS=$safe_CFLAGS
2994 # does the ppc assembler support "mtocrf" et al?
2995 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2997 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2998 __asm__ __volatile__("mtocrf 4,0");
2999 __asm__ __volatile__("mfocrf 0,4");
3000 ]])], [
3001 ac_have_as_ppc_mftocrf=yes
3002 AC_MSG_RESULT([yes])
3003 ], [
3004 ac_have_as_ppc_mftocrf=no
3005 AC_MSG_RESULT([no])
3007 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3008   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3012 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3013 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3015 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3016   do { typedef struct {
3017       double hi;
3018       double lo;
3019      } dbl_pair_t;
3020      dbl_pair_t dbl_pair[3];
3021      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3022    } while (0)
3023 ]])], [
3024 ac_have_as_ppc_fpPO=yes
3025 AC_MSG_RESULT([yes])
3026 ], [
3027 ac_have_as_ppc_fpPO=no
3028 AC_MSG_RESULT([no])
3030 if test x$ac_have_as_ppc_fpPO = xyes ; then
3031   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3035 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3036 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3038 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3039 void* p;
3040 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3041 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3042 ]])], [
3043 ac_have_as_amd64_fxsave64=yes
3044 AC_MSG_RESULT([yes])
3045 ], [
3046 ac_have_as_amd64_fxsave64=no
3047 AC_MSG_RESULT([no])
3049 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3050   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3053 # does the x86/amd64 assembler understand SSE3 instructions?
3054 # Note, this doesn't generate a C-level symbol.  It generates a
3055 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3056 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3058 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3059   do { long long int x; 
3060      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
3061   while (0)
3062 ]])], [
3063 ac_have_as_sse3=yes
3064 AC_MSG_RESULT([yes])
3065 ], [
3066 ac_have_as_sse3=no
3067 AC_MSG_RESULT([no])
3070 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3073 # Ditto for SSSE3 instructions (note extra S)
3074 # Note, this doesn't generate a C-level symbol.  It generates a
3075 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3076 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3078 save_CFLAGS="$CFLAGS"
3079 CFLAGS="$CFLAGS -msse -Werror"
3080 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3081   do { long long int x; 
3082    __asm__ __volatile__(
3083       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3084   while (0)
3085 ]])], [
3086 ac_have_as_ssse3=yes
3087 AC_MSG_RESULT([yes])
3088 ], [
3089 ac_have_as_ssse3=no
3090 AC_MSG_RESULT([no])
3092 CFLAGS="$save_CFLAGS"
3094 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3097 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3098 # Note, this doesn't generate a C-level symbol.  It generates a
3099 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3100 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3101 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3102   do {
3103    __asm__ __volatile__(
3104       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3105   while (0)
3106 ]])], [
3107 ac_have_as_pclmulqdq=yes
3108 AC_MSG_RESULT([yes])
3109 ], [
3110 ac_have_as_pclmulqdq=no
3111 AC_MSG_RESULT([no])
3114 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3117 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3118 # Note, this doesn't generate a C-level symbol.  It generates a
3119 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3120 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3121 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3122   do {
3123       /*
3124        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3125        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3126        * xmm2 should be used.
3127        */
3128    __asm__ __volatile__(
3129       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3130   } while (0)
3131 ]])], [
3132 ac_have_as_vpclmulqdq=yes
3133 AC_MSG_RESULT([yes])
3134 ], [
3135 ac_have_as_vpclmulqdq=no
3136 AC_MSG_RESULT([no])
3139 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3142 # does the x86/amd64 assembler understand FMA4 instructions?
3143 # Note, this doesn't generate a C-level symbol.  It generates a
3144 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3145 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3147   do {
3148    __asm__ __volatile__(
3149       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3150   } while (0)
3151 ]])], [
3152 ac_have_as_vfmaddpd=yes
3153 AC_MSG_RESULT([yes])
3154 ], [
3155 ac_have_as_vfmaddpd=no
3156 AC_MSG_RESULT([no])
3159 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3162 # does the x86/amd64 assembler understand the LZCNT instruction?
3163 # Note, this doesn't generate a C-level symbol.  It generates a
3164 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3165 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3168   do {           
3169       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3170   } while (0)
3171 ]])], [
3172   ac_have_as_lzcnt=yes
3173   AC_MSG_RESULT([yes])
3174 ], [
3175   ac_have_as_lzcnt=no
3176   AC_MSG_RESULT([no])
3179 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3182 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3183 # Note, this doesn't generate a C-level symbol.  It generates a
3184 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3185 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3187 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3188   do {           
3189       __asm__ __volatile__("1:  loopnel 1b\n");
3190   } while (0)
3191 ]])], [
3192   ac_have_as_loopnel=yes
3193   AC_MSG_RESULT([yes])
3194 ], [
3195   ac_have_as_loopnel=no
3196   AC_MSG_RESULT([no])
3199 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3202 # does the x86/amd64 assembler understand ADDR32 ?
3203 # Note, this doesn't generate a C-level symbol.  It generates a
3204 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3205 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3208   do {           
3209       asm volatile ("addr32 rep movsb");
3210   } while (0)
3211 ]])], [
3212   ac_have_as_addr32=yes
3213   AC_MSG_RESULT([yes])
3214 ], [
3215   ac_have_as_addr32=no
3216   AC_MSG_RESULT([no])
3219 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3222 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3223 # Note, this doesn't generate a C-level symbol.  It generates a
3224 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3225 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3227 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3228   do { long long int x; 
3229    __asm__ __volatile__(
3230       "crc32q %%r15,%%r15" : : : "r15" );
3231    __asm__ __volatile__(
3232       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3233    __asm__ __volatile__(
3234       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3235   while (0)
3236 ]])], [
3237 ac_have_as_sse42=yes
3238 AC_MSG_RESULT([yes])
3239 ], [
3240 ac_have_as_sse42=no
3241 AC_MSG_RESULT([no])
3244 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3247 # does the x86/amd64 assembler understand AVX instructions?
3248 # Note, this doesn't generate a C-level symbol.  It generates a
3249 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3250 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3252 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3253   do { long long int x; 
3254    __asm__ __volatile__(
3255       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3256    __asm__ __volatile__(
3257       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3258   while (0)
3259 ]])], [
3260 ac_have_as_avx=yes
3261 AC_MSG_RESULT([yes])
3262 ], [
3263 ac_have_as_avx=no
3264 AC_MSG_RESULT([no])
3267 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3270 # does the x86/amd64 assembler understand AVX2 instructions?
3271 # Note, this doesn't generate a C-level symbol.  It generates a
3272 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3273 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3275 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3276   do { long long int x; 
3277    __asm__ __volatile__(
3278       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3279    __asm__ __volatile__(
3280       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3281   while (0)
3282 ]])], [
3283 ac_have_as_avx2=yes
3284 AC_MSG_RESULT([yes])
3285 ], [
3286 ac_have_as_avx2=no
3287 AC_MSG_RESULT([no])
3290 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3293 # does the x86/amd64 assembler understand TSX instructions and
3294 # the XACQUIRE/XRELEASE prefixes?
3295 # Note, this doesn't generate a C-level symbol.  It generates a
3296 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3297 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3299 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3300   do {
3301    __asm__ __volatile__(
3302       "       xbegin Lfoo  \n\t"
3303       "Lfoo:  xend         \n\t"
3304       "       xacquire lock incq 0(%rsp)     \n\t"
3305       "       xrelease lock incq 0(%rsp)     \n"
3306    );
3307   } while (0)
3308 ]])], [
3309 ac_have_as_tsx=yes
3310 AC_MSG_RESULT([yes])
3311 ], [
3312 ac_have_as_tsx=no
3313 AC_MSG_RESULT([no])
3316 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3319 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3320 # Note, this doesn't generate a C-level symbol.  It generates a
3321 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3322 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3325   do { unsigned int h, l;
3326    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3327    __asm__ __volatile__(
3328       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3329    __asm__ __volatile__(
3330       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3331   while (0)
3332 ]])], [
3333 ac_have_as_bmi=yes
3334 AC_MSG_RESULT([yes])
3335 ], [
3336 ac_have_as_bmi=no
3337 AC_MSG_RESULT([no])
3340 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3343 # does the x86/amd64 assembler understand FMA instructions?
3344 # Note, this doesn't generate a C-level symbol.  It generates a
3345 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3346 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3348 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3349   do { unsigned int h, l;
3350    __asm__ __volatile__(
3351       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3352    __asm__ __volatile__(
3353       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3354    __asm__ __volatile__(
3355       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3356   while (0)
3357 ]])], [
3358 ac_have_as_fma=yes
3359 AC_MSG_RESULT([yes])
3360 ], [
3361 ac_have_as_fma=no
3362 AC_MSG_RESULT([no])
3365 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3368 # does the amd64 assembler understand MPX instructions?
3369 # Note, this doesn't generate a C-level symbol.  It generates a
3370 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3371 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3373 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3374   do {
3375     asm ("bndmov %bnd0,(%rsp)");
3376     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3377     asm ("bnd call foo\n"
3378           bnd jmp  end\n"
3379           foo: bnd ret\n"
3380           end: nop");
3381   } while (0)
3382 ]])], [
3383 ac_have_as_mpx=yes
3384 AC_MSG_RESULT([yes])
3385 ], [
3386 ac_have_as_mpx=no
3387 AC_MSG_RESULT([no])
3390 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3393 # does the amd64 assembler understand ADX instructions?
3394 # Note, this doesn't generate a C-level symbol.  It generates a
3395 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3396 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3398 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3399   do {
3400     asm ("adcxq %r14,%r8");
3401   } while (0)
3402 ]])], [
3403 ac_have_as_adx=yes
3404 AC_MSG_RESULT([yes])
3405 ], [
3406 ac_have_as_adx=no
3407 AC_MSG_RESULT([no])
3410 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3413 # does the amd64 assembler understand the RDRAND instruction?
3414 # Note, this doesn't generate a C-level symbol.  It generates a
3415 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3416 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3418 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3419   do {
3420     asm ("rdrand %r14");
3421     asm ("rdrand %r14d");
3422     asm ("rdrand %r14w");
3423   } while (0)
3424 ]])], [
3425 ac_have_as_rdrand=yes
3426 AC_MSG_RESULT([yes])
3427 ], [
3428 ac_have_as_rdrand=no
3429 AC_MSG_RESULT([no])
3432 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3434 # does the amd64 assembler understand the RDSEED instruction?
3435 # Note, this doesn't generate a C-level symbol.  It generates a
3436 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3437 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3440   do {
3441     asm ("rdseed %r14");
3442     asm ("rdseed %r14d");
3443     asm ("rdseed %r14w");
3444   } while (0)
3445 ]])], [
3446 ac_have_as_rdseed=yes
3447 AC_MSG_RESULT([yes])
3448 ], [
3449 ac_have_as_rdseed=no
3450 AC_MSG_RESULT([no])
3453 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3455 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3456 # VCVTPS2PH) ?
3457 # Note, this doesn't generate a C-level symbol.  It generates a
3458 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3459 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3462   do {
3463     asm ("vcvtph2ps %xmm5, %ymm10");
3464     // If we put the dollar sign and zero together, the shell processing
3465     // this configure.ac script substitutes the command name in.  Sigh.
3466     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3467   } while (0)
3468 ]])], [
3469 ac_have_as_f16c=yes
3470 AC_MSG_RESULT([yes])
3471 ], [
3472 ac_have_as_f16c=no
3473 AC_MSG_RESULT([no])
3476 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3479 # does the x86/amd64 assembler understand MOVBE?
3480 # Note, this doesn't generate a C-level symbol.  It generates a
3481 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3482 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3484 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3485   do { long long int x; 
3486    __asm__ __volatile__(
3487       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3488   while (0)
3489 ]])], [
3490 ac_have_as_movbe=yes
3491 AC_MSG_RESULT([yes])
3492 ], [
3493 ac_have_as_movbe=no
3494 AC_MSG_RESULT([no])
3497 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3500 # Does the C compiler support the "ifunc" attribute
3501 # Note, this doesn't generate a C-level symbol.  It generates a
3502 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3503 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3505 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3506 static void mytest(void) {}
3508 static void (*resolve_test(void))(void)
3510     return (void (*)(void))&mytest;
3513 void test(void) __attribute__((ifunc("resolve_test")));
3515 int main()
3517     test();
3518     return 0;
3520 ]])], [
3521 ac_have_ifunc_attr=yes
3522 AC_MSG_RESULT([yes])
3523 ], [
3524 ac_have_ifunc_attr=no
3525 AC_MSG_RESULT([no])
3528 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3530 # Does the C compiler support the armv8 crc feature flag
3531 # Note, this doesn't generate a C-level symbol.  It generates a
3532 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3533 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3535 save_CFLAGS="$CFLAGS"
3536 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3537 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3538 int main()
3540     return 0;
3542 ]])], [
3543 ac_have_armv8_crc_feature=yes
3544 AC_MSG_RESULT([yes])
3545 ], [
3546 ac_have_armv8_crc_feature=no
3547 AC_MSG_RESULT([no])
3549 CFLAGS="$save_CFLAGS"
3551 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3554 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3555 # Note, this doesn't generate a C-level symbol.  It generates a
3556 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3557 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3559 save_CFLAGS="$CFLAGS"
3560 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3561 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3562 int main()
3564     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3565     return 0;
3567 ]])], [
3568 ac_have_armv81_feature=yes
3569 AC_MSG_RESULT([yes])
3570 ], [
3571 ac_have_armv81_feature=no
3572 AC_MSG_RESULT([no])
3574 CFLAGS="$save_CFLAGS"
3576 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3579 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3580 # Note, this doesn't generate a C-level symbol.  It generates a
3581 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3582 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3584 save_CFLAGS="$CFLAGS"
3585 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3586 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3587 int main()
3589     __asm__ __volatile__("faddp h0, v1.2h");
3590     return 0;
3592 ]])], [
3593 ac_have_armv82_feature=yes
3594 AC_MSG_RESULT([yes])
3595 ], [
3596 ac_have_armv82_feature=no
3597 AC_MSG_RESULT([no])
3599 CFLAGS="$save_CFLAGS"
3601 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3604 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3605 # when building the tool executables.  I think we should get rid of it.
3607 # Check for TLS support in the compiler and linker
3608 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3609                                 [[return foo;]])],
3610                                [vg_cv_linktime_tls=yes],
3611                                [vg_cv_linktime_tls=no])
3612 # Native compilation: check whether running a program using TLS succeeds.
3613 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3614 # succeeds but running programs using TLS fails.
3615 # Cross-compiling: check whether linking a program using TLS succeeds.
3616 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3617                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3618                 [vg_cv_tls=$enableval],
3619                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3620                                                 [[return foo;]])],
3621                                [vg_cv_tls=yes],
3622                                [vg_cv_tls=no],
3623                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3625 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3626 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3630 #----------------------------------------------------------------------------
3631 # Solaris-specific checks.
3632 #----------------------------------------------------------------------------
3634 if test "$VGCONF_OS" = "solaris" ; then
3635 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3637 # Solaris-specific check determining if the Sun Studio Assembler is used to
3638 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3639 # cmovl.l instruction, if yes then it's Sun Assembler.
3641 # C-level symbol: none
3642 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3644 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3645 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3646 ]], [[
3647   __asm__ __volatile__("cmovl.l %edx, %eax");
3648 ]])], [
3649 solaris_have_sun_studio_as=yes
3650 AC_MSG_RESULT([yes])
3651 ], [
3652 solaris_have_sun_studio_as=no
3653 AC_MSG_RESULT([no])
3655 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3657 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3658 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3659 # See solaris/vgpreload-solaris.mapfile for details.
3660 # gcc on older Solaris instructs linker to include these symbols,
3661 # gcc on illumos and newer Solaris does not.
3663 # C-level symbol: none
3664 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3666 save_CFLAGS="$CFLAGS"
3667 CFLAGS="$CFLAGS -std=gnu99"
3668 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3669 temp_dir=$( /usr/bin/mktemp -d )
3670 cat <<_ACEOF >${temp_dir}/mylib.c
3671 #include <stdio.h>
3672 int myfunc(void) { printf("LaPutyka\n"); }
3673 _ACEOF
3674 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3675 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3676 if test "x${xpg_present}" = "x" ; then
3677     solaris_xpg_symbols_present=no
3678     AC_MSG_RESULT([no])
3679 else
3680     solaris_xpg_symbols_present=yes
3681     AC_MSG_RESULT([yes])
3683 rm -rf ${temp_dir}
3684 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3685 CFLAGS="$save_CFLAGS"
3688 # Solaris-specific check determining if gcc enables largefile support by
3689 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3690 # variable with gcc flags which disable it.
3692 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3693 save_CFLAGS="$CFLAGS"
3694 CFLAGS="$CFLAGS -m32"
3695 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3696   return _LARGEFILE_SOURCE;
3697 ]])], [
3698 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3699 AC_MSG_RESULT([yes])
3700 ], [
3701 SOLARIS_UNDEF_LARGESOURCE=""
3702 AC_MSG_RESULT([no])
3704 CFLAGS=$safe_CFLAGS
3705 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3708 # Solaris-specific check determining if /proc/self/cmdline
3709 # or /proc/<pid>/cmdline is supported.
3711 # C-level symbol: SOLARIS_PROC_CMDLINE
3712 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3714 AC_CHECK_FILE([/proc/self/cmdline],
3716 solaris_proc_cmdline=yes
3717 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3718           [Define to 1 if you have /proc/self/cmdline.])
3719 ], [
3720 solaris_proc_cmdline=no
3722 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3725 # Solaris-specific check determining default platform for the Valgrind launcher.
3726 # Used in case the launcher cannot select platform by looking at the client
3727 # image (for example because the executable is a shell script).
3729 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3730 # Automake-level symbol: none
3732 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3733 # Get the ELF class of /bin/sh first.
3734 if ! test -f /bin/sh; then
3735   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3737 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3738 case "$elf_class" in
3739   64)
3740     default_arch="$VGCONF_ARCH_PRI";
3741     ;;
3742   32)
3743     if test "x$VGCONF_ARCH_SEC" != "x"; then
3744       default_arch="$VGCONF_ARCH_SEC"
3745     else
3746       default_arch="$VGCONF_ARCH_PRI";
3747     fi
3748     ;;
3749   *)
3750     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3751     ;;
3752 esac
3753 default_platform="$default_arch-$VGCONF_OS"
3754 AC_MSG_RESULT([$default_platform])
3755 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3756                    [Default platform for Valgrind launcher.])
3759 # Solaris-specific check determining if the old syscalls are available.
3761 # C-level symbol: SOLARIS_OLD_SYSCALLS
3762 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3764 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3765 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3766 #include <sys/syscall.h>
3767 ]], [[
3768   return !SYS_open;
3769 ]])], [
3770 solaris_old_syscalls=yes
3771 AC_MSG_RESULT([yes])
3772 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3773           [Define to 1 if you have the old Solaris syscalls.])
3774 ], [
3775 solaris_old_syscalls=no
3776 AC_MSG_RESULT([no])
3778 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3781 # Solaris-specific check determining if the new accept() syscall is available.
3783 # Old syscall:
3784 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3785 #            int version);
3787 # New syscall (available on illumos):
3788 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3789 #            int version, int flags);
3791 # If the old syscall is present then the following syscall will fail with
3792 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3793 # available then it will fail with EINVAL (because the flags parameter is
3794 # invalid).
3796 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3797 # Automake-level symbol: none
3799 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3800 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3801 #include <sys/syscall.h>
3802 #include <errno.h>
3803 ]], [[
3804   errno = 0;
3805   syscall(SYS_accept, 0, 0, 0, 0, -1);
3806   return !(errno == EINVAL);
3807 ]])], [
3808 AC_MSG_RESULT([yes])
3809 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3810           [Define to 1 if you have the new `accept' syscall.])
3811 ], [
3812 AC_MSG_RESULT([no])
3816 # Solaris-specific check determining if the new illumos pipe() syscall is
3817 # available.
3819 # Old syscall:
3820 # longlong_t pipe();
3822 # New syscall (available on illumos):
3823 # int pipe(intptr_t arg, int flags);
3825 # If the old syscall is present then the following call will succeed, if the
3826 # new syscall is available then it will fail with EFAULT (because address 0
3827 # cannot be accessed).
3829 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3830 # Automake-level symbol: none
3832 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3833 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3834 #include <sys/syscall.h>
3835 #include <errno.h>
3836 ]], [[
3837   errno = 0;
3838   syscall(SYS_pipe, 0, 0);
3839   return !(errno == EFAULT);
3840 ]])], [
3841 AC_MSG_RESULT([yes])
3842 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3843           [Define to 1 if you have the new `pipe' syscall.])
3844 ], [
3845 AC_MSG_RESULT([no])
3849 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3850 # available.
3852 # Old syscall:
3853 # int lwp_kill(id_t lwpid, int sig);
3855 # New syscall (available on Solaris 11):
3856 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3857 #                  int si_code, timespec_t *timeout);
3859 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3860 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3862 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3863 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3864 #include <sys/syscall.h> 
3865 ]], [[
3866   return !SYS_lwp_sigqueue;
3867 ]])], [
3868 solaris_lwp_sigqueue_syscall=yes
3869 AC_MSG_RESULT([yes])
3870 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3871           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3872 ], [
3873 solaris_lwp_sigqueue_syscall=no
3874 AC_MSG_RESULT([no])
3876 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3879 # Solaris-specific check determining if the lwp_sigqueue() syscall
3880 # takes both pid and thread id arguments or just thread id.
3882 # Old syscall (available up to Solaris 11.3):
3883 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3884 #                  int si_code, timespec_t *timeout);
3886 # New syscall (available since Solaris 11.4):
3887 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3888 #                  int si_code, timespec_t *timeout);
3890 # If the old syscall is present then the following syscall will fail with
3891 # EINVAL (because signal is out of range); if the new syscall is available
3892 # then it will fail with ESRCH (because it would not find such thread in the
3893 # current process).
3895 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3896 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3898 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3899 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3900 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3901 #include <sys/syscall.h>
3902 #include <errno.h>
3903 ]], [[
3904   errno = 0;
3905   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3906   return !(errno == ESRCH);
3907 ]])], [
3908 solaris_lwp_sigqueue_syscall_takes_pid=yes
3909 AC_MSG_RESULT([yes])
3910 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3911           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3912 ], [
3913 solaris_lwp_sigqueue_syscall_takes_pid=no
3914 AC_MSG_RESULT([no])
3916 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3917                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3919 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3923 # Solaris-specific check determining if the new lwp_name() syscall is
3924 # available.
3926 # New syscall (available on Solaris 11):
3927 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3929 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3930 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3932 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3933 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3934 #include <sys/syscall.h>
3935 ]], [[
3936   return !SYS_lwp_name;
3937 ]])], [
3938 solaris_lwp_name_syscall=yes
3939 AC_MSG_RESULT([yes])
3940 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3941           [Define to 1 if you have the new `lwp_name' syscall.])
3942 ], [
3943 solaris_lwp_name_syscall=no
3944 AC_MSG_RESULT([no])
3946 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3949 # Solaris-specific check determining if the new getrandom() syscall is
3950 # available.
3952 # New syscall (available on Solaris 11):
3953 # int getrandom(void *buf, size_t buflen, uint_t flags);
3955 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3956 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3958 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3959 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3960 #include <sys/syscall.h>
3961 ]], [[
3962   return !SYS_getrandom;
3963 ]])], [
3964 solaris_getrandom_syscall=yes
3965 AC_MSG_RESULT([yes])
3966 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3967           [Define to 1 if you have the new `getrandom' syscall.])
3968 ], [
3969 solaris_getrandom_syscall=no
3970 AC_MSG_RESULT([no])
3972 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3975 # Solaris-specific check determining if the new zone() syscall subcodes
3976 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
3977 # were added in Solaris 11 but are missing on illumos.
3979 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3980 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3982 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3983 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3984 #include <sys/zone.h>
3985 ]], [[
3986   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3987 ]])], [
3988 solaris_zone_defunct=yes
3989 AC_MSG_RESULT([yes])
3990 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3991           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3992 ], [
3993 solaris_zone_defunct=no
3994 AC_MSG_RESULT([no])
3996 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3999 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4000 # for auditon(2) subcode of the auditsys() syscall are available.
4001 # These commands are available in Solaris 11 and illumos but were removed
4002 # in Solaris 11.4.
4004 # C-level symbol: SOLARIS_AUDITON_STAT
4005 # Automake-level symbol: SOLARIS_AUDITON_STAT
4007 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4008 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4009 #include <bsm/audit.h>
4010 ]], [[
4011   return !(A_GETSTAT && A_SETSTAT);
4012 ]])], [
4013 solaris_auditon_stat=yes
4014 AC_MSG_RESULT([yes])
4015 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4016           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4017 ], [
4018 solaris_auditon_stat=no
4019 AC_MSG_RESULT([no])
4021 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4024 # Solaris-specific check determining if the new shmsys() syscall subcodes
4025 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4026 # These subcodes were added in Solaris 11 but are missing on illumos.
4028 # C-level symbol: SOLARIS_SHM_NEW
4029 # Automake-level symbol: SOLARIS_SHM_NEW
4031 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4032 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4033 #include <sys/ipc_impl.h>
4034 #include <sys/shm.h>
4035 #include <sys/shm_impl.h>
4036 ]], [[
4037   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4038 ]])], [
4039 solaris_shm_new=yes
4040 AC_MSG_RESULT([yes])
4041 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4042           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4043 ], [
4044 solaris_shm_new=no
4045 AC_MSG_RESULT([no])
4047 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4050 # Solaris-specific check determining if prxregset_t is available.  Illumos
4051 # currently does not define it on the x86 platform.
4053 # C-level symbol: SOLARIS_PRXREGSET_T
4054 # Automake-level symbol: SOLARIS_PRXREGSET_T
4056 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4058 #include <sys/procfs_isa.h>
4059 ]], [[
4060   return !sizeof(prxregset_t);
4061 ]])], [
4062 solaris_prxregset_t=yes
4063 AC_MSG_RESULT([yes])
4064 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4065           [Define to 1 if you have the `prxregset_t' type.])
4066 ], [
4067 solaris_prxregset_t=no
4068 AC_MSG_RESULT([no])
4070 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4073 # Solaris-specific check determining if the new frealpathat() syscall is
4074 # available.
4076 # New syscall (available on Solaris 11.1):
4077 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4079 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4080 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4082 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4083 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4084 #include <sys/syscall.h>
4085 ]], [[
4086   return !SYS_frealpathat;
4087 ]])], [
4088 solaris_frealpathat_syscall=yes
4089 AC_MSG_RESULT([yes])
4090 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4091           [Define to 1 if you have the new `frealpathat' syscall.])
4092 ], [
4093 solaris_frealpathat_syscall=no
4094 AC_MSG_RESULT([no])
4096 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4099 # Solaris-specific check determining if the new uuidsys() syscall is
4100 # available.
4102 # New syscall (available on newer Solaris):
4103 # int uuidsys(struct uuid *uuid);
4105 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4106 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4108 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4109 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4110 #include <sys/syscall.h>
4111 ]], [[
4112   return !SYS_uuidsys;
4113 ]])], [
4114 solaris_uuidsys_syscall=yes
4115 AC_MSG_RESULT([yes])
4116 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4117           [Define to 1 if you have the new `uuidsys' syscall.])
4118 ], [
4119 solaris_uuidsys_syscall=no
4120 AC_MSG_RESULT([no])
4122 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4125 # Solaris-specific check determining if the new labelsys() syscall subcode
4126 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4127 # missing on illumos.
4129 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4130 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4132 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4133 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4134 #include <sys/tsol/tndb.h>
4135 ]], [[
4136   return !TNDB_GET_TNIP;
4137 ]])], [
4138 solaris_tndb_get_tnip=yes
4139 AC_MSG_RESULT([yes])
4140 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4141           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4142 ], [
4143 solaris_tndb_get_tnip=no
4144 AC_MSG_RESULT([no])
4146 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4149 # Solaris-specific check determining if the new labelsys() syscall opcodes
4150 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4151 # added in Solaris 11 but are missing on illumos.
4153 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4154 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4156 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4157 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4158 #include <sys/tsol/tsyscall.h>
4159 ]], [[
4160   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4161 ]])], [
4162 solaris_tsol_clearance=yes
4163 AC_MSG_RESULT([yes])
4164 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4165           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4166 ], [
4167 solaris_tsol_clearance=no
4168 AC_MSG_RESULT([no])
4170 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4173 # Solaris-specific check determining if the new pset() syscall subcode
4174 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4175 # is missing on illumos and Solaris 11.3.
4177 # C-level symbol: SOLARIS_PSET_GET_NAME
4178 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4180 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4181 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4182 #include <sys/pset.h>
4183 ]], [[
4184   return !(PSET_GET_NAME);
4185 ]])], [
4186 solaris_pset_get_name=yes
4187 AC_MSG_RESULT([yes])
4188 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4189           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4190 ], [
4191 solaris_pset_get_name=no
4192 AC_MSG_RESULT([no])
4194 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4197 # Solaris-specific check determining if the utimesys() syscall is
4198 # available (on illumos and older Solaris).
4200 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4201 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4203 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4204 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4205 #include <sys/syscall.h>
4206 ]], [[
4207   return !SYS_utimesys;
4208 ]])], [
4209 solaris_utimesys_syscall=yes
4210 AC_MSG_RESULT([yes])
4211 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4212           [Define to 1 if you have the `utimesys' syscall.])
4213 ], [
4214 solaris_utimesys_syscall=no
4215 AC_MSG_RESULT([no])
4217 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4220 # Solaris-specific check determining if the utimensat() syscall is
4221 # available (on newer Solaris).
4223 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4224 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4226 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4227 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4228 #include <sys/syscall.h>
4229 ]], [[
4230   return !SYS_utimensat;
4231 ]])], [
4232 solaris_utimensat_syscall=yes
4233 AC_MSG_RESULT([yes])
4234 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4235           [Define to 1 if you have the `utimensat' syscall.])
4236 ], [
4237 solaris_utimensat_syscall=no
4238 AC_MSG_RESULT([no])
4240 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4243 # Solaris-specific check determining if the spawn() syscall is available
4244 # (on newer Solaris).
4246 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4247 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4249 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4250 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4251 #include <sys/syscall.h>
4252 ]], [[
4253   return !SYS_spawn;
4254 ]])], [
4255 solaris_spawn_syscall=yes
4256 AC_MSG_RESULT([yes])
4257 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4258           [Define to 1 if you have the `spawn' syscall.])
4259 ], [
4260 solaris_spawn_syscall=no
4261 AC_MSG_RESULT([no])
4263 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4266 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4267 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4269 # C-level symbol: SOLARIS_MODCTL_MODNVL
4270 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4272 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4273 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4274 #include <sys/modctl.h>
4275 ]], [[
4276   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4277 ]])], [
4278 solaris_modctl_modnvl=yes
4279 AC_MSG_RESULT([yes])
4280 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4281           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4282 ], [
4283 solaris_modctl_modnvl=no
4284 AC_MSG_RESULT([no])
4286 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4289 # Solaris-specific check determining whether nscd (name switch cache daemon)
4290 # attaches its door at /system/volatile/name_service_door (Solaris)
4291 # or at /var/run/name_service_door (illumos).
4293 # Note that /var/run is a symlink to /system/volatile on Solaris
4294 # but not vice versa on illumos.
4296 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4297 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4299 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4300 if test -e /system/volatile/name_service_door; then
4301     solaris_nscd_door_system_volatile=yes
4302     AC_MSG_RESULT([/system/volatile/name_service_door])
4303     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4304               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4305 else
4306     solaris_nscd_door_system_volatile=no
4307     AC_MSG_RESULT([/var/run/name_service_door])
4309 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4312 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4314 # New fasttrap (available on Solaris 11):
4315 # hrt_t *gethrt(void);
4317 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4318 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4320 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4321 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4322 #include <sys/trap.h>
4323 ]], [[
4324   return !T_GETHRT;
4325 ]])], [
4326 solaris_gethrt_fasttrap=yes
4327 AC_MSG_RESULT([yes])
4328 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4329           [Define to 1 if you have the new `gethrt' fasttrap.])
4330 ], [
4331 solaris_gethrt_fasttrap=no
4332 AC_MSG_RESULT([no])
4334 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4337 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4338 # is available.
4340 # New fasttrap (available on Solaris 11):
4341 # zonehrtoffset_t *get_zone_offset(void);
4343 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4344 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4346 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4347 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4348 #include <sys/trap.h>
4349 ]], [[
4350   return !T_GETZONEOFFSET;
4351 ]])], [
4352 solaris_getzoneoffset_fasttrap=yes
4353 AC_MSG_RESULT([yes])
4354 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4355           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4356 ], [
4357 solaris_getzoneoffset_fasttrap=no
4358 AC_MSG_RESULT([no])
4360 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4363 # Solaris-specific check determining if the execve() syscall
4364 # takes fourth argument (flags) or not.
4366 # Old syscall (available on illumos):
4367 # int execve(const char *fname, const char **argv, const char **envp);
4369 # New syscall (available on Solaris):
4370 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4372 # If the new syscall is present then it will fail with EINVAL (because flags
4373 # are invalid); if the old syscall is available then it will fail with ENOENT
4374 # (because the file could not be found).
4376 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4377 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4379 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4380 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4381 #include <sys/syscall.h>
4382 #include <errno.h>
4383 ]], [[
4384   errno = 0;
4385   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4386   return !(errno == EINVAL);
4387 ]])], [
4388 solaris_execve_syscall_takes_flags=yes
4389 AC_MSG_RESULT([yes])
4390 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4391           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4392 ], [
4393 solaris_execve_syscall_takes_flags=no
4394 AC_MSG_RESULT([no])
4396 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4397                test x$solaris_execve_syscall_takes_flags = xyes)
4400 # Solaris-specific check determining version of the repository cache protocol.
4401 # Every Solaris version uses a different one, ranging from 21 to current 25.
4402 # The check is very ugly, though.
4404 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4405 # Automake-level symbol: none
4407 AC_PATH_PROG(DIS_PATH, dis, false)
4408 if test "x$DIS_PATH" = "xfalse"; then
4409   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4411 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4412   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4413   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4416 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4417 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4418   libscf=/usr/lib/64/libscf.so.1
4419 else
4420   libscf=/usr/lib/libscf.so.1
4422 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
4423   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4424   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4426 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
4427 if test -z "$hex"; then
4428   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4429   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4431 version=$( printf "%d\n" 0x$hex )
4432 AC_MSG_RESULT([$version])
4433 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4434                    [Version number of the repository door cache protocol.])
4437 # Solaris-specific check determining if "sysstat" segment reservation type
4438 # is available.
4440 # New "sysstat" segment reservation (available on Solaris 11.4):
4441 # - program header type:    PT_SUNW_SYSSTAT
4442 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4444 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4445 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4447 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4448 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4449 #include <sys/auxv.h>
4450 ]], [[
4451   return !AT_SUN_SYSSTAT_ADDR;
4452 ]])], [
4453 solaris_reserve_sysstat_addr=yes
4454 AC_MSG_RESULT([yes])
4455 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4456           [Define to 1 if you have the new `sysstat' segment reservation.])
4457 ], [
4458 solaris_reserve_sysstat_addr=no
4459 AC_MSG_RESULT([no])
4461 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4464 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4465 # is available.
4467 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4468 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4469 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4471 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4472 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4474 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4475 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4476 #include <sys/auxv.h>
4477 ]], [[
4478   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4479 ]])], [
4480 solaris_reserve_sysstat_zone_addr=yes
4481 AC_MSG_RESULT([yes])
4482 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4483           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4484 ], [
4485 solaris_reserve_sysstat_zone_addr=no
4486 AC_MSG_RESULT([no])
4488 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4491 # Solaris-specific check determining if the system_stats() syscall is available
4492 # (on newer Solaris).
4494 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4495 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4497 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4498 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4499 #include <sys/syscall.h>
4500 ]], [[
4501   return !SYS_system_stats;
4502 ]])], [
4503 solaris_system_stats_syscall=yes
4504 AC_MSG_RESULT([yes])
4505 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4506           [Define to 1 if you have the `system_stats' syscall.])
4507 ], [
4508 solaris_system_stats_syscall=no
4509 AC_MSG_RESULT([no])
4511 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4514 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4515 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4517 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4518 # Automake-level symbol: none
4520 AC_CHECK_TYPE([struct _fpchip_state],
4521               [solaris_fpchip_state_takes_underscore=yes],
4522               [solaris_fpchip_state_takes_underscore=no],
4523               [[#include <sys/regset.h>]])
4524 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4525   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4526             [Define to 1 if fpregset_t defines struct _fpchip_state])
4530 # Solaris-specific check determining if schedctl page shared between kernel
4531 # and userspace program is executable (illumos, older Solaris) or not (newer
4532 # Solaris).
4534 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4535 # Automake-level symbol: none
4537 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4538 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4539 #include <assert.h>
4540 #include <fcntl.h>
4541 #include <procfs.h>
4542 #include <schedctl.h>
4543 #include <stdio.h>
4544 #include <unistd.h>
4545 ]], [[
4546     schedctl_t *scp = schedctl_init();
4547     if (scp == NULL)
4548         return 1;
4550     int fd = open("/proc/self/map", O_RDONLY);
4551     assert(fd >= 0);
4553     prmap_t map;
4554     ssize_t rd;
4555     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4556         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4557             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4558                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4559             return (map.pr_mflags & MA_EXEC);
4560         }
4561     }
4563     return 1;
4564 ]])], [
4565 solaris_schedctl_page_exec=no
4566 AC_MSG_RESULT([no])
4567 ], [
4568 solaris_schedctl_page_exec=yes
4569 AC_MSG_RESULT([yes])
4570 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4571           [Define to 1 if you have the schedctl page executable.])
4575 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4576 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4577 # an initial thread pointer for libc (newer Solaris).
4579 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4580 # Automake-level symbol: none
4582 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4583 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4584 #include <sys/fasttrap_isa.h>
4585 ]], [[
4586     return !FT_SCRATCHSIZE;
4587 ]])], [
4588 solaris_pt_sunwdtrace_thrp=yes
4589 AC_MSG_RESULT([yes])
4590 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4591           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4592 ], [
4593 solaris_pt_sunwdtrace_thrp=no
4594 AC_MSG_RESULT([no])
4597 else
4598 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4599 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4600 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4601 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4602 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4603 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4604 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4605 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4606 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4607 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4608 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4609 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4610 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4611 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4612 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4613 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4614 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4615 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4616 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4617 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4618 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4619 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4620 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4621 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4622 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4623 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4624 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4625 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4626 fi # test "$VGCONF_OS" = "solaris"
4628 #----------------------------------------------------------------------------
4629 # FreeBSD-specific checks.
4630 #----------------------------------------------------------------------------
4632 # Rather than having a large number of feature test as above with Solaris
4633 # these tests are per-version. This may not be entirely relialable for
4634 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4635 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4637 if test "$VGCONF_OS" = "freebsd" ; then
4639 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4641 else
4643 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4645 fi # test "$VGCONF_OS" = "freebsd"
4648 #----------------------------------------------------------------------------
4649 # Checks for C header files.
4650 #----------------------------------------------------------------------------
4652 AC_CHECK_HEADERS([       \
4653         asm/unistd.h     \
4654         endian.h         \
4655         mqueue.h         \
4656         sys/endian.h     \
4657         sys/epoll.h      \
4658         sys/eventfd.h    \
4659         sys/klog.h       \
4660         sys/poll.h       \
4661         sys/prctl.h      \
4662         sys/signal.h     \
4663         sys/signalfd.h   \
4664         sys/syscall.h    \
4665         sys/sysnvl.h     \
4666         sys/time.h       \
4667         sys/types.h      \
4668         ])
4670 # Verify whether the <linux/futex.h> header is usable.
4671 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4673 save_CFLAGS="$CFLAGS"
4674 CFLAGS="$CFLAGS -D__user="
4675 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4676 #include <linux/futex.h>
4677 ]], [[
4678   return FUTEX_WAIT;
4679 ]])], [
4680 ac_have_usable_linux_futex_h=yes
4681 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4682           [Define to 1 if you have a usable <linux/futex.h> header file.])
4683 AC_MSG_RESULT([yes])
4684 ], [
4685 ac_have_usable_linux_futex_h=no
4686 AC_MSG_RESULT([no])
4688 CFLAGS="$save_CFLAGS"
4691 #----------------------------------------------------------------------------
4692 # Checks for typedefs, structures, and compiler characteristics.
4693 #----------------------------------------------------------------------------
4694 AC_TYPE_UID_T
4695 AC_TYPE_OFF_T
4696 AC_TYPE_SIZE_T
4697 AC_CHECK_HEADERS_ONCE([sys/time.h])
4699 AC_CHECK_TYPE([struct statx], [
4700   AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4701             [Define to 1 if <sys/stat.h> declares struct statx.])
4702 ], [], [
4703   #define _GNU_SOURCE
4704   #include <sys/stat.h>
4708 #----------------------------------------------------------------------------
4709 # Checks for library functions.
4710 #----------------------------------------------------------------------------
4711 AC_FUNC_MEMCMP
4712 AC_FUNC_MMAP
4714 AC_CHECK_LIB([pthread], [pthread_create])
4715 AC_CHECK_LIB([rt], [clock_gettime])
4717 AC_CHECK_FUNCS([     \
4718         clock_gettime\
4719         copy_file_range \
4720         epoll_create \
4721         epoll_pwait  \
4722         klogctl      \
4723         mallinfo     \
4724         memchr       \
4725         memfd_create \
4726         memset       \
4727         mkdir        \
4728         mremap       \
4729         ppoll        \
4730         preadv       \
4731         preadv2      \
4732         process_vm_readv  \
4733         process_vm_writev \
4734         pthread_barrier_init       \
4735         pthread_condattr_setclock  \
4736         pthread_mutex_timedlock    \
4737         pthread_rwlock_timedrdlock \
4738         pthread_rwlock_timedwrlock \
4739         pthread_setname_np         \
4740         pthread_spin_lock          \
4741         pthread_yield              \
4742         pwritev      \
4743         pwritev2     \
4744         rawmemchr    \
4745         readlinkat   \
4746         semtimedop   \
4747         setcontext   \
4748         signalfd     \
4749         sigwaitinfo  \
4750         strchr       \
4751         strdup       \
4752         strpbrk      \
4753         strrchr      \
4754         strstr       \
4755         swapcontext  \
4756         syscall      \
4757         utimensat    \
4758         ])
4760 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4761 # libraries with any shared object and/or executable. This is NOT what we
4762 # want for e.g. vgpreload_core-x86-linux.so
4763 LIBS=""
4765 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4766                [test x$ac_cv_func_pthread_barrier_init = xyes])
4767 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4768                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4769 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4770                [test x$ac_cv_func_pthread_spin_lock = xyes])
4771 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4772                [test x$ac_cv_func_pthread_setname_np = xyes])
4773 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4774                [test x$ac_cv_func_copy_file_range = xyes])
4775 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4776                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4777 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4778                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4779 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4780 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4781 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4782                [test x$ac_cv_func_memfd_create = xyes])
4784 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4785      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4786      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4787   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4788             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4791 #----------------------------------------------------------------------------
4792 # MPI checks
4793 #----------------------------------------------------------------------------
4794 # Do we have a useable MPI setup on the primary and/or secondary targets?
4795 # On Linux, by default, assumes mpicc and -m32/-m64
4796 # Note: this is a kludge in that it assumes the specified mpicc 
4797 # understands -m32/-m64 regardless of what is specified using
4798 # --with-mpicc=.
4799 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4800              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4802 mflag_primary=
4803 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4804      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4805      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4806      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4807      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4808      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4809      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4810   mflag_primary=$FLAG_M32
4811 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4812        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4813        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4814        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4815        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4816        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4817   mflag_primary=$FLAG_M64
4818 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4819   mflag_primary="$FLAG_M32 -arch i386"
4820 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4821   mflag_primary="$FLAG_M64 -arch x86_64"
4824 mflag_secondary=
4825 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4826      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4827      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4828      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4829      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4830   mflag_secondary=$FLAG_M32
4831 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4832   mflag_secondary="$FLAG_M32 -arch i386"
4836 AC_ARG_WITH(mpicc,
4837    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4838    MPI_CC=$withval
4840 AC_SUBST(MPI_CC)
4842 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4843 ## use these values in the check for a functioning mpicc.
4845 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4846 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4847 AM_COND_IF([VGCONF_OS_IS_LINUX],
4848            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4849             LDFLAGS_MPI="-fpic -shared"])
4850 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
4851            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4852             LDFLAGS_MPI="-fpic -shared"])
4853 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4854            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4855             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4856 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4857            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4858             LDFLAGS_MPI="-fpic -shared"])
4860 AC_SUBST([CFLAGS_MPI])
4861 AC_SUBST([LDFLAGS_MPI])
4864 ## See if MPI_CC works for the primary target
4866 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4867 saved_CC=$CC
4868 saved_CFLAGS=$CFLAGS
4869 CC=$MPI_CC
4870 CFLAGS="$CFLAGS_MPI $mflag_primary"
4871 saved_LDFLAGS="$LDFLAGS"
4872 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4873 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4874 #include <mpi.h>
4875 #include <stdio.h>
4876 ]], [[
4877   int ni, na, nd, comb;
4878   int r = MPI_Init(NULL,NULL);
4879   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4880   r |= MPI_Finalize();
4881   return r; 
4882 ]])], [
4883 ac_have_mpi2_pri=yes
4884 AC_MSG_RESULT([yes, $MPI_CC])
4885 ], [
4886 ac_have_mpi2_pri=no
4887 AC_MSG_RESULT([no])
4889 CC=$saved_CC
4890 CFLAGS=$saved_CFLAGS
4891 LDFLAGS="$saved_LDFLAGS"
4892 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4894 ## See if MPI_CC works for the secondary target.  Complication: what if
4895 ## there is no secondary target?  We need this to then fail.
4896 ## Kludge this by making MPI_CC something which will surely fail in
4897 ## such a case.
4899 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4900 saved_CC=$CC
4901 saved_CFLAGS=$CFLAGS
4902 saved_LDFLAGS="$LDFLAGS"
4903 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4904 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4905   CC="$MPI_CC this will surely fail"
4906 else
4907   CC=$MPI_CC
4909 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4910 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4911 #include <mpi.h>
4912 #include <stdio.h>
4913 ]], [[
4914   int ni, na, nd, comb;
4915   int r = MPI_Init(NULL,NULL);
4916   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4917   r |= MPI_Finalize();
4918   return r; 
4919 ]])], [
4920 ac_have_mpi2_sec=yes
4921 AC_MSG_RESULT([yes, $MPI_CC])
4922 ], [
4923 ac_have_mpi2_sec=no
4924 AC_MSG_RESULT([no])
4926 CC=$saved_CC
4927 CFLAGS=$saved_CFLAGS
4928 LDFLAGS="$saved_LDFLAGS"
4929 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4932 #----------------------------------------------------------------------------
4933 # Other library checks
4934 #----------------------------------------------------------------------------
4935 # There now follow some tests for Boost, and OpenMP.  These
4936 # tests are present because Drd has some regression tests that use
4937 # these packages.  All regression test programs all compiled only
4938 # for the primary target.  And so it is important that the configure
4939 # checks that follow, use the correct -m32 or -m64 flag for the
4940 # primary target (called $mflag_primary).  Otherwise, we can end up
4941 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4942 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4943 # only build (meaning, the primary target is x86-linux), the build
4944 # of the regtest programs that use Boost fails, because they are 
4945 # build as 32-bit (IN THIS EXAMPLE).
4947 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4948 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4951 # Check whether the boost library 1.35 or later has been installed.
4952 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4954 AC_MSG_CHECKING([for boost])
4956 AC_LANG(C++)
4957 safe_CXXFLAGS=$CXXFLAGS
4958 CXXFLAGS="$mflag_primary"
4959 safe_LIBS="$LIBS"
4960 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4962 AC_LINK_IFELSE([AC_LANG_SOURCE([
4963 #include <boost/thread.hpp>
4964 static void thread_func(void)
4965 { }
4966 int main(int argc, char** argv)
4968   boost::thread t(thread_func);
4969   return 0;
4971 ])],
4973 ac_have_boost_1_35=yes
4974 AC_SUBST([BOOST_CFLAGS], [])
4975 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4976 AC_MSG_RESULT([yes])
4977 ], [
4978 ac_have_boost_1_35=no
4979 AC_MSG_RESULT([no])
4982 LIBS="$safe_LIBS"
4983 CXXFLAGS=$safe_CXXFLAGS
4984 AC_LANG(C)
4986 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4989 # does this compiler support -fopenmp, does it have the include file
4990 # <omp.h> and does it have libgomp ?
4992 AC_MSG_CHECKING([for OpenMP])
4994 safe_CFLAGS=$CFLAGS
4995 CFLAGS="-fopenmp $mflag_primary -Werror"
4997 AC_LINK_IFELSE([AC_LANG_SOURCE([
4998 #include <omp.h> 
4999 int main(int argc, char** argv)
5001   omp_set_dynamic(0);
5002   return 0;
5004 ])],
5006 ac_have_openmp=yes
5007 AC_MSG_RESULT([yes])
5008 ], [
5009 ac_have_openmp=no
5010 AC_MSG_RESULT([no])
5012 CFLAGS=$safe_CFLAGS
5014 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5017 # Check for __builtin_popcount
5018 AC_MSG_CHECKING([for __builtin_popcount()])
5019 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5020 ]], [[
5021   __builtin_popcount(2);
5022   return 0;
5023 ]])], [
5024 AC_MSG_RESULT([yes])
5025 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5026           [Define to 1 if compiler provides __builtin_popcount().])
5027 ], [
5028 AC_MSG_RESULT([no])
5031 # Check for __builtin_clz
5032 AC_MSG_CHECKING([for __builtin_clz()])
5033 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5034 ]], [[
5035   __builtin_clz(2);
5036   return 0;
5037 ]])], [
5038 AC_MSG_RESULT([yes])
5039 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5040           [Define to 1 if compiler provides __builtin_clz().])
5041 ], [
5042 AC_MSG_RESULT([no])
5045 # Check for __builtin_ctz
5046 AC_MSG_CHECKING([for __builtin_ctz()])
5047 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5048 ]], [[
5049   __builtin_ctz(2);
5050   return 0;
5051 ]])], [
5052 AC_MSG_RESULT([yes])
5053 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5054           [Define to 1 if compiler provides __builtin_ctz().])
5055 ], [
5056 AC_MSG_RESULT([no])
5059 # does this compiler have built-in functions for atomic memory access for the
5060 # primary target ?
5061 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5063 safe_CFLAGS=$CFLAGS
5064 CFLAGS="$mflag_primary"
5066 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5067   int variable = 1;
5068   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5069           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5070 ]])], [
5071   ac_have_builtin_atomic_primary=yes
5072   AC_MSG_RESULT([yes])
5073   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])
5074 ], [
5075   ac_have_builtin_atomic_primary=no
5076   AC_MSG_RESULT([no])
5079 CFLAGS=$safe_CFLAGS
5081 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5082                [test x$ac_have_builtin_atomic_primary = xyes])
5085 # does this compiler have built-in functions for atomic memory access for the
5086 # secondary target ?
5088 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5090 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5092 safe_CFLAGS=$CFLAGS
5093 CFLAGS="$mflag_secondary"
5095 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5096   int variable = 1;
5097   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5098 ]])], [
5099   ac_have_builtin_atomic_secondary=yes
5100   AC_MSG_RESULT([yes])
5101 ], [
5102   ac_have_builtin_atomic_secondary=no
5103   AC_MSG_RESULT([no])
5106 CFLAGS=$safe_CFLAGS
5110 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5111                [test x$ac_have_builtin_atomic_secondary = xyes])
5113 # does this compiler have built-in functions for atomic memory access on
5114 # 64-bit integers for all targets ?
5116 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5118 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5119   #include <stdint.h>
5120 ]], [[
5121   uint64_t variable = 1;
5122   return __sync_add_and_fetch(&variable, 1)
5123 ]])], [
5124   ac_have_builtin_atomic64_primary=yes
5125 ], [
5126   ac_have_builtin_atomic64_primary=no
5129 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5131 safe_CFLAGS=$CFLAGS
5132 CFLAGS="$mflag_secondary"
5134 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5135   #include <stdint.h>
5136 ]], [[
5137   uint64_t variable = 1;
5138   return __sync_add_and_fetch(&variable, 1)
5139 ]])], [
5140   ac_have_builtin_atomic64_secondary=yes
5141 ], [
5142   ac_have_builtin_atomic64_secondary=no
5145 CFLAGS=$safe_CFLAGS
5149 if test x$ac_have_builtin_atomic64_primary = xyes && \
5150    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5151      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5152   AC_MSG_RESULT([yes])
5153   ac_have_builtin_atomic64=yes
5154 else
5155   AC_MSG_RESULT([no])
5156   ac_have_builtin_atomic64=no
5159 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5160                [test x$ac_have_builtin_atomic64 = xyes])
5163 # does g++ have built-in functions for atomic memory access ?
5164 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5166 safe_CXXFLAGS=$CXXFLAGS
5167 CXXFLAGS="$mflag_primary"
5169 AC_LANG_PUSH(C++)
5170 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5171   int variable = 1;
5172   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5173           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5174 ]])], [
5175   ac_have_builtin_atomic_cxx=yes
5176   AC_MSG_RESULT([yes])
5177   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5178 ], [
5179   ac_have_builtin_atomic_cxx=no
5180   AC_MSG_RESULT([no])
5182 AC_LANG_POP(C++)
5184 CXXFLAGS=$safe_CXXFLAGS
5186 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5189 if test x$ac_have_usable_linux_futex_h = xyes \
5190         -a x$ac_have_builtin_atomic_primary = xyes; then
5191   ac_enable_linux_ticket_lock_primary=yes
5193 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5194                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5196 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5197         -a x$ac_have_usable_linux_futex_h = xyes \
5198         -a x$ac_have_builtin_atomic_secondary = xyes; then
5199   ac_enable_linux_ticket_lock_secondary=yes
5201 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5202                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5205 # does libstdc++ support annotating shared pointers ?
5206 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5208 safe_CXXFLAGS=$CXXFLAGS
5209 CXXFLAGS="-std=c++0x"
5211 AC_LANG_PUSH(C++)
5212 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5213   #include <memory>
5214 ]], [[
5215   std::shared_ptr<int> p
5216 ]])], [
5217   ac_have_shared_ptr=yes
5218 ], [
5219   ac_have_shared_ptr=no
5221 if test x$ac_have_shared_ptr = xyes; then
5222   # If compilation of the program below fails because of a syntax error
5223   # triggered by substituting one of the annotation macros then that
5224   # means that libstdc++ supports these macros.
5225   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5226     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5227     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5228     #include <memory>
5229   ]], [[
5230     std::shared_ptr<int> p
5231   ]])], [
5232     ac_have_shared_pointer_annotation=no
5233     AC_MSG_RESULT([no])
5234   ], [
5235     ac_have_shared_pointer_annotation=yes
5236     AC_MSG_RESULT([yes])
5237     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5238               [Define to 1 if libstd++ supports annotating shared pointers])
5239   ])
5240 else
5241   ac_have_shared_pointer_annotation=no
5242   AC_MSG_RESULT([no])
5244 AC_LANG_POP(C++)
5246 CXXFLAGS=$safe_CXXFLAGS
5248 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5249                [test x$ac_have_shared_pointer_annotation = xyes])
5252 #----------------------------------------------------------------------------
5253 # Ok.  We're done checking.
5254 #----------------------------------------------------------------------------
5256 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5257 AC_CONFIG_FILES([
5258    Makefile 
5259    VEX/Makefile:Makefile.vex.in
5260    valgrind.spec
5261    valgrind.pc
5262    glibc-2.X.supp
5263    glibc-2.X-helgrind.supp
5264    glibc-2.X-drd.supp
5265    include/valgrind.h
5266    docs/Makefile 
5267    docs/xml/vg-entities.xml
5268    tests/Makefile 
5269    tests/vg_regtest 
5270    perf/Makefile 
5271    perf/vg_perf
5272    gdbserver_tests/Makefile
5273    gdbserver_tests/solaris/Makefile
5274    include/Makefile 
5275    auxprogs/Makefile
5276    mpi/Makefile
5277    coregrind/Makefile 
5278    memcheck/Makefile
5279    memcheck/tests/Makefile
5280    memcheck/tests/common/Makefile
5281    memcheck/tests/amd64/Makefile
5282    memcheck/tests/x86/Makefile
5283    memcheck/tests/linux/Makefile
5284    memcheck/tests/linux/debuginfod-check.vgtest
5285    memcheck/tests/darwin/Makefile
5286    memcheck/tests/solaris/Makefile
5287    memcheck/tests/freebsd/Makefile
5288    memcheck/tests/amd64-linux/Makefile
5289    memcheck/tests/arm64-linux/Makefile
5290    memcheck/tests/x86-linux/Makefile
5291    memcheck/tests/amd64-solaris/Makefile
5292    memcheck/tests/x86-solaris/Makefile
5293    memcheck/tests/amd64-freebsd/Makefile
5294    memcheck/tests/x86-freebsd/Makefile
5295    memcheck/tests/ppc32/Makefile
5296    memcheck/tests/ppc64/Makefile
5297    memcheck/tests/s390x/Makefile
5298    memcheck/tests/mips32/Makefile
5299    memcheck/tests/mips64/Makefile
5300    memcheck/tests/vbit-test/Makefile
5301    cachegrind/Makefile
5302    cachegrind/tests/Makefile
5303    cachegrind/tests/x86/Makefile
5304    cachegrind/cg_annotate
5305    cachegrind/cg_diff
5306    callgrind/Makefile
5307    callgrind/callgrind_annotate
5308    callgrind/callgrind_control
5309    callgrind/tests/Makefile
5310    helgrind/Makefile
5311    helgrind/tests/Makefile
5312    drd/Makefile
5313    drd/scripts/download-and-build-splash2
5314    drd/tests/Makefile
5315    massif/Makefile
5316    massif/tests/Makefile
5317    massif/ms_print
5318    dhat/Makefile
5319    dhat/tests/Makefile
5320    lackey/Makefile
5321    lackey/tests/Makefile
5322    none/Makefile
5323    none/tests/Makefile
5324    none/tests/scripts/Makefile
5325    none/tests/amd64/Makefile
5326    none/tests/ppc32/Makefile
5327    none/tests/ppc64/Makefile
5328    none/tests/x86/Makefile
5329    none/tests/arm/Makefile
5330    none/tests/arm64/Makefile
5331    none/tests/s390x/Makefile
5332    none/tests/mips32/Makefile
5333    none/tests/mips64/Makefile
5334    none/tests/nanomips/Makefile
5335    none/tests/linux/Makefile
5336    none/tests/darwin/Makefile
5337    none/tests/solaris/Makefile
5338    none/tests/freebsd/Makefile
5339    none/tests/amd64-linux/Makefile
5340    none/tests/x86-linux/Makefile
5341    none/tests/amd64-darwin/Makefile
5342    none/tests/x86-darwin/Makefile
5343    none/tests/amd64-solaris/Makefile
5344    none/tests/x86-solaris/Makefile
5345    exp-bbv/Makefile
5346    exp-bbv/tests/Makefile
5347    exp-bbv/tests/x86/Makefile
5348    exp-bbv/tests/x86-linux/Makefile
5349    exp-bbv/tests/amd64-linux/Makefile
5350    exp-bbv/tests/ppc32-linux/Makefile
5351    exp-bbv/tests/arm-linux/Makefile
5352    shared/Makefile
5353    solaris/Makefile
5355 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5356                 [chmod +x coregrind/link_tool_exe_linux])
5357 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5358                 [chmod +x coregrind/link_tool_exe_freebsd])
5359 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5360                 [chmod +x coregrind/link_tool_exe_darwin])
5361 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5362                 [chmod +x coregrind/link_tool_exe_solaris])
5363 AC_CONFIG_FILES([tests/filter_stderr_basic],
5364                 [chmod +x tests/filter_stderr_basic])
5365 AC_CONFIG_FILES([tests/filter_discards],
5366                 [chmod +x tests/filter_discards])
5367 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5368                 [chmod +x memcheck/tests/filter_stderr])
5369 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5370                 [chmod +x memcheck/tests/filter_dw4])
5371 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5372                 [chmod +x memcheck/tests/filter_overlaperror])
5373 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5374                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5375 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5376                 [chmod +x gdbserver_tests/filter_gdb])
5377 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5378                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5379 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5380                 [chmod +x gdbserver_tests/filter_stderr])
5381 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5382                 [chmod +x gdbserver_tests/filter_vgdb])
5383 AC_CONFIG_FILES([drd/tests/filter_stderr],
5384                 [chmod +x drd/tests/filter_stderr])
5385 AC_CONFIG_FILES([drd/tests/filter_error_count],
5386                 [chmod +x drd/tests/filter_error_count])
5387 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5388                 [chmod +x drd/tests/filter_error_summary])
5389 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5390                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5391 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5392                 [chmod +x drd/tests/filter_thread_no])
5393 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5394                 [chmod +x drd/tests/filter_xml_and_thread_no])
5395 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5396                 [chmod +x helgrind/tests/filter_stderr])
5397 AC_OUTPUT
5399 cat<<EOF
5401                     Version: ${VERSION}
5402          Maximum build arch: ${ARCH_MAX}
5403          Primary build arch: ${VGCONF_ARCH_PRI}
5404        Secondary build arch: ${VGCONF_ARCH_SEC}
5405                    Build OS: ${VGCONF_OS}
5406      Link Time Optimisation: ${vg_cv_lto}
5407        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5408      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5409            Platform variant: ${VGCONF_PLATVARIANT}
5410       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5411          Default supp files: ${DEFAULT_SUPP}