FreeBSD: Helgrind suppression for std::__1::__thread_local_data on FreeBSD 13.2
[valgrind.git] / configure.ac
bloba8d9b95138aa9f5c4518529a49dddf55541b2ea6
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], [21])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [GIT])
21 m4_define([v_rel_date], ["?? Apr 2023"])
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 m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
54 # Make sure we can compile in C99 mode.
55 if test "$ac_cv_prog_cc_c99" = "no"; then
56     AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
58 AC_PROG_CPP
59 AC_PROG_CXX
60 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
61 # autoconf 2.59).  If we ever have any Objective-C code in the Valgrind code
62 # base (eg. most likely as Darwin-specific tests) we'll need one of the
63 # following:
64 # - put AC_PROG_OBJC in a Darwin-specific part of this file
65 # - Use AC_PROG_OBJC here and up the minimum autoconf version
66 # - Use the following, which is apparently equivalent:
67 #     m4_ifdef([AC_PROG_OBJC],
68 #        [AC_PROG_OBJC],
69 #        [AC_CHECK_TOOL([OBJC], [gcc])
70 #         AC_SUBST([OBJC])
71 #         AC_SUBST([OBJCFLAGS])
72 #        ])
73 AC_PROG_RANLIB
74 # Set LTO_RANLIB variable to an lto enabled ranlib
75 if test "x$LTO_RANLIB" = "x"; then
76   AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
78 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
80 # provide a very basic definition for AC_PROG_SED if it's not provided by
81 # autoconf (as e.g. in autoconf 2.59).
82 m4_ifndef([AC_PROG_SED],
83           [AC_DEFUN([AC_PROG_SED],
84                     [AC_ARG_VAR([SED])
85                      AC_CHECK_PROGS([SED],[gsed sed])])])
86 AC_PROG_SED
88 AC_DEFUN([AC_PROG_SHA256SUM],
89           [AC_ARG_VAR([SHA256SUM])
90           AC_CHECK_PROGS([SHA256SUM],[gsha256sum sha256sum])])
91 AC_PROG_SHA256SUM
93 # If no AR variable was specified, look up the name of the archiver. Otherwise
94 # do not touch the AR variable.
95 if test "x$AR" = "x"; then
96   AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
98 AC_ARG_VAR([AR],[Archiver command])
100 # same for LTO_AR variable for lto enabled archiver
101 if test "x$LTO_AR" = "x"; then
102   AC_PATH_PROGS([LTO_AR], [gcc-ar])
104 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
107 # Check for the compiler support
108 if test "${GCC}" != "yes" ; then
109    AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
112 # figure out where perl lives
113 AC_PATH_PROG(PERL, perl)
115 # figure out where gdb lives
116 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
117 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
119 # some older automake's don't have it so try something on our own
120 ifdef([AM_PROG_AS],[AM_PROG_AS],
122 AS="${CC}"
123 AC_SUBST(AS)
125 ASFLAGS=""
126 AC_SUBST(ASFLAGS)
130 # Check if 'diff' supports -u (universal diffs) and use it if possible.
132 AC_MSG_CHECKING([for diff -u])
133 AC_SUBST(DIFF)
135 # Comparing two identical files results in 0.
136 tmpfile="tmp-xxx-yyy-zzz"
137 touch $tmpfile;
138 if diff -u $tmpfile $tmpfile ; then
139     AC_MSG_RESULT([yes])
140     DIFF="diff -u"
141 else
142     AC_MSG_RESULT([no])
143     DIFF="diff"
145 rm $tmpfile
147 # We don't want gcc < 3.0
148 AC_MSG_CHECKING([for a supported version of gcc])
150 # Obtain the compiler version.
152 # A few examples of how the ${CC} --version output looks like:
154 # ######## gcc variants ########
155 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
156 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
157 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
158 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
159 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
160 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
161 # 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)
163 # ######## clang variants ########
164 # Clang: clang version 2.9 (tags/RELEASE_29/final)
165 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
166 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
168 # ######## Apple LLVM variants ########
169 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
170 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
173 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
174 then
175     is_clang="applellvm"
176     gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
177 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
178 then
179     is_clang="clang"
180     # Don't use -dumpversion with clang: it will always produce "4.2.1".
181     gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
182 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 
183 then
184     is_clang="icc"
185     gcc_version=`${CC} -dumpversion 2>/dev/null`
186 else
187     is_clang="notclang"
188     gcc_version=`${CC} -dumpversion 2>/dev/null`
189     if test "x$gcc_version" = x; then
190         gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
191     fi
194 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
195 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
197 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
198 # statements have to be quoted.
199 case "${is_clang}-${gcc_version}" in
200      applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
201         AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
202         ;;
203      icc-1[[3-9]].*|icc-202[[0-9]].*)
204         AC_MSG_RESULT([ok (ICC version ${gcc_version})])
205         ;;
206      notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
207         AC_MSG_RESULT([ok (${gcc_version})])
208         ;;
209      clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
210         AC_MSG_RESULT([ok (clang-${gcc_version})])
211         ;;
212      *)
213         AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
214         AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
215         ;;
216 esac
218 #----------------------------------------------------------------------------
219 # Arch/OS/platform tests.
220 #----------------------------------------------------------------------------
221 # We create a number of arch/OS/platform-related variables.  We prefix them
222 # all with "VGCONF_" which indicates that they are defined at
223 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
224 # variables used when compiling C files.
226 AC_CANONICAL_HOST
228 AC_MSG_CHECKING([for a supported CPU])
230 # ARCH_MAX reflects the most that this CPU can do: for example if it
231 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
232 # Ditto for amd64.  It is used for more configuration below, but is not used
233 # outside this file.
235 # Power PC returns powerpc for Big Endian.  This was not changed when Little
236 # Endian support was added to the 64-bit architecture.  The 64-bit Little
237 # Endian systems explicitly state le in the host_cpu.  For clarity in the
238 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
239 # the 64-bit system.  Big Endian is the only mode supported on 32-bit Power PC.
240 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
241 # Endianness.  The name PPC64 or ppc64 to 64-bit systems of either Endianness.
242 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
243 # Endian.  Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
244 # Little Endian.
246 case "${host_cpu}" in
247      i?86) 
248         AC_MSG_RESULT([ok (${host_cpu})])
249         ARCH_MAX="x86"
250         ;;
252      x86_64|amd64) 
253         AC_MSG_RESULT([ok (${host_cpu})])
254         ARCH_MAX="amd64"
255         ;;
257      powerpc64)
258      # this only referrs to 64-bit Big Endian
259         AC_MSG_RESULT([ok (${host_cpu})])
260         ARCH_MAX="ppc64be"
261         ;;
263      powerpc64le)
264      # this only referrs to 64-bit Little Endian
265         AC_MSG_RESULT([ok (${host_cpu})])
266         ARCH_MAX="ppc64le"
267         ;;
269      powerpc)
270         # On Linux this means only a 32-bit capable CPU.
271         AC_MSG_RESULT([ok (${host_cpu})])
272         ARCH_MAX="ppc32"
273         ;;
275      s390x)
276         AC_MSG_RESULT([ok (${host_cpu})])
277         ARCH_MAX="s390x"
278         ;;
280      armv7*)
281         AC_MSG_RESULT([ok (${host_cpu})])
282         ARCH_MAX="arm"
283         ;;
285      aarch64*)
286        AC_MSG_RESULT([ok (${host_cpu})])
287        ARCH_MAX="arm64"
288        ;;
290      mips)
291         AC_MSG_RESULT([ok (${host_cpu})])
292         ARCH_MAX="mips32"
293         ;;
295      mipsel)
296         AC_MSG_RESULT([ok (${host_cpu})])
297         ARCH_MAX="mips32"
298         ;;
300      mipsisa32r2)
301         AC_MSG_RESULT([ok (${host_cpu})])
302         ARCH_MAX="mips32"
303         ;;
305      mips64*)
306         AC_MSG_RESULT([ok (${host_cpu})])
307         ARCH_MAX="mips64"
308         ;;
310      mipsisa64*)
311         AC_MSG_RESULT([ok (${host_cpu})])
312         ARCH_MAX="mips64"
313         ;;
314      nanomips)
315         AC_MSG_RESULT([ok (${host_cpu})])
316         ARCH_MAX="nanomips"
317         ;;
319      *) 
320         AC_MSG_RESULT([no (${host_cpu})])
321         AC_MSG_ERROR([Unsupported host architecture. Sorry])
322         ;;
323 esac
325 #----------------------------------------------------------------------------
327 # Sometimes it's convenient to subvert the bi-arch build system and
328 # just have a single build even though the underlying platform is
329 # capable of both.  Hence handle --enable-only64bit and
330 # --enable-only32bit.  Complain if both are issued :-)
331 # [Actually, if either of these options are used, I think both get built,
332 # but only one gets installed.  So if you use an in-place build, both can be
333 # used. --njn]
335 # Check if a 64-bit only build has been requested
336 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
337    [AC_ARG_ENABLE(only64bit, 
338       [  --enable-only64bit      do a 64-bit only build],
339       [vg_cv_only64bit=$enableval],
340       [vg_cv_only64bit=no])])
342 # Check if a 32-bit only build has been requested
343 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
344    [AC_ARG_ENABLE(only32bit, 
345       [  --enable-only32bit      do a 32-bit only build],
346       [vg_cv_only32bit=$enableval],
347       [vg_cv_only32bit=no])])
349 # Stay sane
350 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
351    AC_MSG_ERROR(
352       [Nonsensical: both --enable-only64bit and --enable-only32bit.])
355 #----------------------------------------------------------------------------
357 # VGCONF_OS is the primary build OS, eg. "linux".  It is passed in to
358 # compilation of many C files via -VGO_$(VGCONF_OS) and
359 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
360 AC_MSG_CHECKING([for a supported OS])
361 AC_SUBST(VGCONF_OS)
363 DEFAULT_SUPP=""
365 case "${host_os}" in
366      *linux*)
367         AC_MSG_RESULT([ok (${host_os})])
368         VGCONF_OS="linux"
370         # Ok, this is linux. Check the kernel version
371         AC_MSG_CHECKING([for the kernel version])
373         kernel=`uname -r`
375         case "${kernel}" in
376              0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 
377                     AC_MSG_RESULT([unsupported (${kernel})])
378                     AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
379                     ;;
381              *)
382                     AC_MSG_RESULT([2.6 or later (${kernel})])
383                     ;;
384         esac
386         ;;
388      *freebsd*)
389         AC_MSG_RESULT([ok (${host_os})])
390         VGCONF_OS="freebsd"
391         AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
392         freebsd_10=1000
393         AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
394         freebsd_11=1100
395         AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
396         freebsd_12=1200
397         AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
398         freebsd_12_2=1220
399         AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
400         freebsd_13_0=1300
401         AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1+])
402         freebsd_13_1=1310
403         AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
404         freebsd_14=1400
406         AC_MSG_CHECKING([for the kernel version])
407         kernel=`uname -r`
409         case "${kernel}" in
410         10.*)
411            AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
412            AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
413            freebsd_vers=$freebsd_10
414            ;;
415         11.*)
416            AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
417            AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
418            freebsd_vers=$freebsd_11
419            ;;
420         12.*)
421            case "${kernel}" in
422            12.[[0-1]]-*)
423               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
424               AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
425               freebsd_vers=$freebsd_12
426               ;;
427            *)
428               AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
429               AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
430               freebsd_vers=$freebsd_12_2
431               ;;
432            esac
433            ;;
434         13.*)
435            case "${kernel}" in
436            13.0-*)
437               AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
438               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
439               freebsd_vers=$freebsd_13_0
440               ;;
441            *)
442               AC_MSG_RESULT([FreeBSD 13.1+ (${kernel})])
443               AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
444               freebsd_vers=$freebsd_13_1
445               ;;
446            esac
447            ;;
448         14.*)
449            AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
450            AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
451            freebsd_vers=$freebsd_14
452            ;;
453         *)
454            AC_MSG_RESULT([unsupported (${kernel})])
455            AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x])
456            ;;
457         esac
459         DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
460         ;;
462      *darwin*)
463         AC_MSG_RESULT([ok (${host_os})])
464         VGCONF_OS="darwin"
465         AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
466         AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
467         AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
468         AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
469         AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
470         AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
471         AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
472         AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
473         AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
475         AC_MSG_CHECKING([for the kernel version])
476         kernel=`uname -r`
478         # Nb: for Darwin we set DEFAULT_SUPP here.  That's because Darwin
479         # has only one relevant version, the OS version. The `uname` check
480         # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
481         # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
482         # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 
483         # and we don't know of an macros similar to __GLIBC__ to get that info.
484         #
485         # XXX: `uname -r` won't do the right thing for cross-compiles, but
486         # that's not a problem yet.
487         #
488         # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
489         # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
490         # on 10.6.8 and 10.7.1.  Although tempted to delete the configure
491         # time support for 10.5 (the 9.* pattern just below), I'll leave it
492         # in for now, just in case anybody wants to give it a try.  But I'm
493         # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
494         case "${kernel}" in
495              9.*)
496                   AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
497                   AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
498                   DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
499                   DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
500                   ;;
501              10.*)
502                   AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
503                   AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
504                   DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
505                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
506                   ;;
507              11.*)
508                   AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
509                   AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
510                   DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
511                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
512                   ;;
513              12.*)
514                   AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
515                   AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
516                   DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
517                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
518                   ;;
519              13.*)
520                   AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
521                   AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
522                   DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
523                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
524                   ;;
525              14.*)
526                   AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
527                   AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
528                   DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
529                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
530                   ;;
531              15.*)
532                   AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
533                   AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
534                   DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
535                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
536                   ;;
537              16.*)
538                   AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
539                   AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
540                   DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
541                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
542                   ;;
543              17.*)
544                   AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
545                   AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
546                   DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
547                   DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
548                   ;;
549              *) 
550                   AC_MSG_RESULT([unsupported (${kernel})])
551                   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)])
552                   ;;
553         esac
554         ;;
556      solaris2.11*)
557         AC_MSG_RESULT([ok (${host_os})])
558         VGCONF_OS="solaris"
560         uname_v=$( uname -v )
561         case "$uname_v" in
562              11.4.*)
563                  DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
564                  ;;
565              *)
566                  DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
567                  ;;
568         esac
569         ;;
571      solaris2.12*)
572         AC_MSG_RESULT([ok (${host_os})])
573         VGCONF_OS="solaris"
574         DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
575         ;;
577      *) 
578         AC_MSG_RESULT([no (${host_os})])
579         AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
580         ;;
581 esac
583 #----------------------------------------------------------------------------
585 # If we are building on a 64 bit platform test to see if the system
586 # supports building 32 bit programs and disable 32 bit support if it
587 # does not support building 32 bit programs
589 case "$ARCH_MAX-$VGCONF_OS" in
590      amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
591         AC_MSG_CHECKING([for 32 bit build support])
592         safe_CFLAGS=$CFLAGS
593         CFLAGS="-m32"
594         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
595           return 0;
596         ]])], [
597         AC_MSG_RESULT([yes])
598         ], [
599         vg_cv_only64bit="yes"
600         AC_MSG_RESULT([no])
601         ])
602         CFLAGS=$safe_CFLAGS;;
603     mips64-linux)
604         AC_MSG_CHECKING([for 32 bit build support])
605         safe_CFLAGS=$CFLAGS
606         CFLAGS="$CFLAGS -mips32 -mabi=32"
607         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
608           #include <sys/prctl.h>
609         ]], [[]])], [
610         AC_MSG_RESULT([yes])
611         ], [
612         vg_cv_only64bit="yes"
613         AC_MSG_RESULT([no])
614         ])
615         CFLAGS=$safe_CFLAGS;;
616 esac
618 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
619    AC_MSG_ERROR(
620       [--enable-only32bit was specified but system does not support 32 bit builds])
623 #----------------------------------------------------------------------------
625 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64".  By
626 # default it's the same as ARCH_MAX.  But if, say, we do a build on an amd64
627 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
628 # above) will be "amd64" since that reflects the most that this cpu can do,
629 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
630 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS).  It is
631 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
632 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
633 AC_SUBST(VGCONF_ARCH_PRI)
635 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
636 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
637 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
638 # It is empty if there is no secondary target.
639 AC_SUBST(VGCONF_ARCH_SEC)
641 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
642 # The entire system, including regression and performance tests, will be
643 # built for this target.  The "_CAPS" indicates that the name is in capital
644 # letters, and it also uses '_' rather than '-' as a separator, because it's
645 # used to create various Makefile variables, which are all in caps by
646 # convention and cannot contain '-' characters.  This is in contrast to
647 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
648 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
650 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
651 # Valgrind and tools will also be built for this target, but not the
652 # regression or performance tests.
654 # By default, the primary arch is the same as the "max" arch, as commented
655 # above (at the definition of ARCH_MAX).  We may choose to downgrade it in
656 # the big case statement just below here, in the case where we're building
657 # on a 64 bit machine but have been requested only to do a 32 bit build.
658 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
660 AC_MSG_CHECKING([for a supported CPU/OS combination])
662 # NB.  The load address for a given platform may be specified in more 
663 # than one place, in some cases, depending on whether we're doing a biarch,
664 # 32-bit only or 64-bit only build.  eg see case for amd64-linux below.
665 # Be careful to give consistent values in all subcases.  Also, all four
666 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
667 # even if it is to "0xUNSET".
669 case "$ARCH_MAX-$VGCONF_OS" in
670      x86-linux)
671         VGCONF_ARCH_PRI="x86"
672         VGCONF_ARCH_SEC=""
673         VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
674         VGCONF_PLATFORM_SEC_CAPS=""
675         valt_load_address_pri_norml="0x58000000"
676         valt_load_address_pri_inner="0x38000000"
677         valt_load_address_sec_norml="0xUNSET"
678         valt_load_address_sec_inner="0xUNSET"
679         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
680         ;;
681      amd64-linux)
682         valt_load_address_sec_norml="0xUNSET"
683         valt_load_address_sec_inner="0xUNSET"
684         if test x$vg_cv_only64bit = xyes; then
685            VGCONF_ARCH_PRI="amd64"
686            VGCONF_ARCH_SEC=""
687            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
688            VGCONF_PLATFORM_SEC_CAPS=""
689            valt_load_address_pri_norml="0x58000000"
690            valt_load_address_pri_inner="0x38000000"
691         elif test x$vg_cv_only32bit = xyes; then
692            VGCONF_ARCH_PRI="x86"
693            VGCONF_ARCH_SEC=""
694            VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
695            VGCONF_PLATFORM_SEC_CAPS=""
696            valt_load_address_pri_norml="0x58000000"
697            valt_load_address_pri_inner="0x38000000"
698         else
699            VGCONF_ARCH_PRI="amd64"
700            VGCONF_ARCH_SEC="x86"
701            VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
702            VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
703            valt_load_address_pri_norml="0x58000000"
704            valt_load_address_pri_inner="0x38000000"
705            valt_load_address_sec_norml="0x58000000"
706            valt_load_address_sec_inner="0x38000000"
707         fi
708         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
709         ;;
710      ppc32-linux)
711         VGCONF_ARCH_PRI="ppc32"
712         VGCONF_ARCH_SEC=""
713         VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
714         VGCONF_PLATFORM_SEC_CAPS=""
715         valt_load_address_pri_norml="0x58000000"
716         valt_load_address_pri_inner="0x38000000"
717         valt_load_address_sec_norml="0xUNSET"
718         valt_load_address_sec_inner="0xUNSET"
719         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
720         ;;
721      ppc64be-linux)
722         valt_load_address_sec_norml="0xUNSET"
723         valt_load_address_sec_inner="0xUNSET"
724         if test x$vg_cv_only64bit = xyes; then
725            VGCONF_ARCH_PRI="ppc64be"
726            VGCONF_ARCH_SEC=""
727            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
728            VGCONF_PLATFORM_SEC_CAPS=""
729            valt_load_address_pri_norml="0x58000000"
730            valt_load_address_pri_inner="0x38000000"
731         elif test x$vg_cv_only32bit = xyes; then
732            VGCONF_ARCH_PRI="ppc32"
733            VGCONF_ARCH_SEC=""
734            VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
735            VGCONF_PLATFORM_SEC_CAPS=""
736            valt_load_address_pri_norml="0x58000000"
737            valt_load_address_pri_inner="0x38000000"
738         else
739            VGCONF_ARCH_PRI="ppc64be"
740            VGCONF_ARCH_SEC="ppc32"
741            VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
742            VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
743            valt_load_address_pri_norml="0x58000000"
744            valt_load_address_pri_inner="0x38000000"
745            valt_load_address_sec_norml="0x58000000"
746            valt_load_address_sec_inner="0x38000000"
747         fi
748         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
749         ;;
750      ppc64le-linux)
751         # Little Endian is only supported on PPC64
752         valt_load_address_sec_norml="0xUNSET"
753         valt_load_address_sec_inner="0xUNSET"
754         VGCONF_ARCH_PRI="ppc64le"
755         VGCONF_ARCH_SEC=""
756         VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
757         VGCONF_PLATFORM_SEC_CAPS=""
758         valt_load_address_pri_norml="0x58000000"
759         valt_load_address_pri_inner="0x38000000"
760         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
761        ;;
762      x86-freebsd)
763         VGCONF_ARCH_PRI="x86"
764         VGCONF_ARCH_SEC=""
765         VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
766         VGCONF_PLATFORM_SEC_CAPS=""
767         valt_load_address_pri_norml="0x38000000"
768         valt_load_address_pri_inner="0x28000000"
769         valt_load_address_sec_norml="0xUNSET"
770         valt_load_address_sec_inner="0xUNSET"
771         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
772         ;;
773      amd64-freebsd)
774         if test x$vg_cv_only64bit = xyes; then
775            VGCONF_ARCH_PRI="amd64"
776            VGCONF_ARCH_SEC=""
777            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
778            VGCONF_PLATFORM_SEC_CAPS=""
779         elif test x$vg_cv_only32bit = xyes; then
780            VGCONF_ARCH_PRI="x86"
781            VGCONF_ARCH_SEC=""
782            VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
783            VGCONF_PLATFORM_SEC_CAPS=""
784         else
785            VGCONF_ARCH_PRI="amd64"
786            VGCONF_ARCH_SEC="x86"
787            VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
788            VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
789         fi
790         # These work with either base clang or ports installed gcc
791         # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
792         if test x$is_clang = xclang ; then
793            FLAG_32ON64="-B/usr/lib32"
794         else
795            GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
796            FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
797         fi
798         valt_load_address_pri_norml="0x38000000"
799         valt_load_address_pri_inner="0x28000000"
800         valt_load_address_sec_norml="0x38000000"
801         valt_load_address_sec_inner="0x28000000"
802         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
803         ;;
804      # Darwin gets identified as 32-bit even when it supports 64-bit.
805      # (Not sure why, possibly because 'uname' returns "i386"?)  Just about
806      # all Macs support both 32-bit and 64-bit, so we just build both.  If
807      # someone has a really old 32-bit only machine they can (hopefully?)
808      # build with --enable-only32bit.  See bug 243362.
809      x86-darwin|amd64-darwin)
810         ARCH_MAX="amd64"
811         valt_load_address_sec_norml="0xUNSET"
812         valt_load_address_sec_inner="0xUNSET"
813         if test x$vg_cv_only64bit = xyes; then
814            VGCONF_ARCH_PRI="amd64"
815            VGCONF_ARCH_SEC=""
816            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
817            VGCONF_PLATFORM_SEC_CAPS=""
818            valt_load_address_pri_norml="0x158000000"
819            valt_load_address_pri_inner="0x138000000"
820         elif test x$vg_cv_only32bit = xyes; then
821            VGCONF_ARCH_PRI="x86"
822            VGCONF_ARCH_SEC=""
823            VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
824            VGCONF_PLATFORM_SEC_CAPS=""
825            VGCONF_ARCH_PRI_CAPS="x86"
826            valt_load_address_pri_norml="0x58000000"
827            valt_load_address_pri_inner="0x38000000"
828         else
829            VGCONF_ARCH_PRI="amd64"
830            VGCONF_ARCH_SEC="x86"
831            VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
832            VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
833            valt_load_address_pri_norml="0x158000000"
834            valt_load_address_pri_inner="0x138000000"
835            valt_load_address_sec_norml="0x58000000"
836            valt_load_address_sec_inner="0x38000000"
837         fi
838         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
839         ;;
840      arm-linux) 
841         VGCONF_ARCH_PRI="arm"
842         VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
843         VGCONF_PLATFORM_SEC_CAPS=""
844         valt_load_address_pri_norml="0x58000000"
845         valt_load_address_pri_inner="0x38000000"
846         valt_load_address_sec_norml="0xUNSET"
847         valt_load_address_sec_inner="0xUNSET"
848         AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
849         ;;
850      arm64-linux)
851         valt_load_address_sec_norml="0xUNSET"
852         valt_load_address_sec_inner="0xUNSET"
853         if test x$vg_cv_only64bit = xyes; then
854            VGCONF_ARCH_PRI="arm64"
855            VGCONF_ARCH_SEC=""
856            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
857            VGCONF_PLATFORM_SEC_CAPS=""
858            valt_load_address_pri_norml="0x58000000"
859            valt_load_address_pri_inner="0x38000000"
860         elif test x$vg_cv_only32bit = xyes; then
861            VGCONF_ARCH_PRI="arm"
862            VGCONF_ARCH_SEC=""
863            VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
864            VGCONF_PLATFORM_SEC_CAPS=""
865            valt_load_address_pri_norml="0x58000000"
866            valt_load_address_pri_inner="0x38000000"
867         else
868            VGCONF_ARCH_PRI="arm64"
869            VGCONF_ARCH_SEC="arm"
870            VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
871            VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
872            valt_load_address_pri_norml="0x58000000"
873            valt_load_address_pri_inner="0x38000000"
874            valt_load_address_sec_norml="0x58000000"
875            valt_load_address_sec_inner="0x38000000"
876         fi
877         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
878         ;;
879      s390x-linux)
880         VGCONF_ARCH_PRI="s390x"
881         VGCONF_ARCH_SEC=""
882         VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
883         VGCONF_PLATFORM_SEC_CAPS=""
884         # To improve branch prediction hit rate we want to have
885         # the generated code close to valgrind (host) code
886         valt_load_address_pri_norml="0x800000000"
887         valt_load_address_pri_inner="0x810000000"
888         valt_load_address_sec_norml="0xUNSET"
889         valt_load_address_sec_inner="0xUNSET"
890         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
891         ;;
892      mips32-linux) 
893         VGCONF_ARCH_PRI="mips32"
894         VGCONF_ARCH_SEC=""
895         VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
896         VGCONF_PLATFORM_SEC_CAPS=""
897         valt_load_address_pri_norml="0x58000000"
898         valt_load_address_pri_inner="0x38000000"
899         valt_load_address_sec_norml="0xUNSET"
900         valt_load_address_sec_inner="0xUNSET"
901         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
902         ;;
903      mips64-linux)
904         valt_load_address_sec_norml="0xUNSET"
905         valt_load_address_sec_inner="0xUNSET"
906         if test x$vg_cv_only64bit = xyes; then
907             VGCONF_ARCH_PRI="mips64"
908             VGCONF_PLATFORM_SEC_CAPS=""
909             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
910             VGCONF_PLATFORM_SEC_CAPS=""
911             valt_load_address_pri_norml="0x58000000"
912             valt_load_address_pri_inner="0x38000000"
913         elif test x$vg_cv_only32bit = xyes; then
914             VGCONF_ARCH_PRI="mips32"
915             VGCONF_ARCH_SEC=""
916             VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
917             VGCONF_PLATFORM_SEC_CAPS=""
918             valt_load_address_pri_norml="0x58000000"
919             valt_load_address_pri_inner="0x38000000"
920         else
921             VGCONF_ARCH_PRI="mips64"
922             VGCONF_ARCH_SEC="mips32"
923             VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
924             VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
925             valt_load_address_pri_norml="0x58000000"
926             valt_load_address_pri_inner="0x38000000"
927             valt_load_address_sec_norml="0x58000000"
928             valt_load_address_sec_inner="0x38000000"
929         fi
930         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
931         ;;
932      nanomips-linux)
933         VGCONF_ARCH_PRI="nanomips"
934         VGCONF_ARCH_SEC=""
935         VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
936         VGCONF_PLATFORM_SEC_CAPS=""
937         valt_load_address_pri_norml="0x58000000"
938         valt_load_address_pri_inner="0x38000000"
939         valt_load_address_sec_norml="0xUNSET"
940         valt_load_address_sec_inner="0xUNSET"
941         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
942         ;;
943      x86-solaris)
944         VGCONF_ARCH_PRI="x86"
945         VGCONF_ARCH_SEC=""
946         VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
947         VGCONF_PLATFORM_SEC_CAPS=""
948         valt_load_address_pri_norml="0x58000000"
949         valt_load_address_pri_inner="0x38000000"
950         valt_load_address_sec_norml="0xUNSET"
951         valt_load_address_sec_inner="0xUNSET"
952         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
953         ;;
954      amd64-solaris)
955         valt_load_address_sec_norml="0xUNSET"
956         valt_load_address_sec_inner="0xUNSET"
957         if test x$vg_cv_only64bit = xyes; then
958            VGCONF_ARCH_PRI="amd64"
959            VGCONF_ARCH_SEC=""
960            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
961            VGCONF_PLATFORM_SEC_CAPS=""
962            valt_load_address_pri_norml="0x58000000"
963            valt_load_address_pri_inner="0x38000000"
964         elif test x$vg_cv_only32bit = xyes; then
965            VGCONF_ARCH_PRI="x86"
966            VGCONF_ARCH_SEC=""
967            VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
968            VGCONF_PLATFORM_SEC_CAPS=""
969            valt_load_address_pri_norml="0x58000000"
970            valt_load_address_pri_inner="0x38000000"
971         else
972            VGCONF_ARCH_PRI="amd64"
973            VGCONF_ARCH_SEC="x86"
974            VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
975            VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
976            valt_load_address_pri_norml="0x58000000"
977            valt_load_address_pri_inner="0x38000000"
978            valt_load_address_sec_norml="0x58000000"
979            valt_load_address_sec_inner="0x38000000"
980         fi
981         AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
982         ;;
983     *)
984         VGCONF_ARCH_PRI="unknown"
985         VGCONF_ARCH_SEC="unknown"
986         VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
987         VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
988         valt_load_address_pri_norml="0xUNSET"
989         valt_load_address_pri_inner="0xUNSET"
990         valt_load_address_sec_norml="0xUNSET"
991         valt_load_address_sec_inner="0xUNSET"
992         AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
993         AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
994         ;;
995 esac
997 #----------------------------------------------------------------------------
999 # Set up VGCONF_ARCHS_INCLUDE_<arch>.  Either one or two of these become
1000 # defined.
1001 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,   
1002                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1003                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1004                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1005                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1006                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1007                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1008                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1009                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1010 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 
1011                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1012                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1013                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1014                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1015 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 
1016                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1017                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1018 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 
1019                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1020                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1021 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,   
1022                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1023                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1024 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 
1025                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1026 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1027                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1028 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1029                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1030                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1031 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1032                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 
1033 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1034                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1036 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>.  Either one or two of these
1037 # become defined.
1038 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,   
1039                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1040                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1041 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 
1042                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1043 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 
1044                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 
1045                  -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1046 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1047                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1048 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1049                test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1050 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 
1051                test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1052                  -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1053 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 
1054                test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1055 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1056                test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1057                  -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1058 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1059                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1060                  -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1061 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1062                test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1063 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1064                test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1065 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1066                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1067                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1068 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD, 
1069                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1070 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1071                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1072                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1073 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 
1074                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1075 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1076                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1077                  -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1078 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1079                test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1082 # Similarly, set up VGCONF_OS_IS_<os>.  Exactly one of these becomes defined.
1083 # Relies on the assumption that the primary and secondary targets are 
1084 # for the same OS, so therefore only necessary to test the primary.
1085 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1086                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1087                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1088                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1089                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1090                  -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1091                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1092                  -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1093                  -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1094                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1095                  -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1096                  -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1097 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1098                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1099                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1100 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1101                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1102                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1103 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1104                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1105                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1106 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1107                test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1108                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1109                  -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1110                  -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1113 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1114 # there is a secondary target.
1115 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1116                test x$VGCONF_PLATFORM_SEC_CAPS != x)
1118 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1119 dnl fallback definition
1120 dnl The macro is courtesy of Dave Hart:
1121 dnl   https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1122 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1123 if test -z "$$1_TRUE"; then :
1124   m4_n([$2])[]dnl
1125 m4_ifval([$3],
1126 [else
1127   $3
1128 ])dnl
1129 fi[]dnl
1130 ])])
1132 #----------------------------------------------------------------------------
1133 # Inner Valgrind?
1134 #----------------------------------------------------------------------------
1136 # Check if this should be built as an inner Valgrind, to be run within
1137 # another Valgrind.  Choose the load address accordingly.
1138 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1139 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1140 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1141    [AC_ARG_ENABLE(inner, 
1142       [  --enable-inner          enables self-hosting],
1143       [vg_cv_inner=$enableval],
1144       [vg_cv_inner=no])])
1145 if test "$vg_cv_inner" = yes; then
1146     AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1147     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1148     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1149 else
1150     VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1151     VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1154 #----------------------------------------------------------------------------
1155 # Undefined behaviour sanitiser
1156 #----------------------------------------------------------------------------
1157 # Check whether we should build with the undefined beahviour sanitiser.
1159 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1160    [AC_ARG_ENABLE(ubsan, 
1161       [  --enable-ubsan          enables the undefined behaviour sanitiser],
1162       [vg_cv_ubsan=$enableval],
1163       [vg_cv_ubsan=no])])
1165 #----------------------------------------------------------------------------
1166 # Extra fine-tuning of installation directories
1167 #----------------------------------------------------------------------------
1168 AC_ARG_WITH(tmpdir,
1169    [  --with-tmpdir=PATH      Specify path for temporary files],
1170    tmpdir="$withval",
1171    tmpdir="/tmp")
1172 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1173 AC_SUBST(VG_TMPDIR, [$tmpdir])
1175 #----------------------------------------------------------------------------
1176 # Detect xcode path
1177 #----------------------------------------------------------------------------
1178 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1179 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1180 AC_MSG_CHECKING([for xcode sdk include path])
1181 AC_ARG_WITH(xcodedir,
1182    [  --with-xcode-path=PATH      Specify path for xcode sdk includes],
1183    [xcodedir="$withval"],
1184    [
1185       if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1186          xcrundir=`xcrun --sdk macosx --show-sdk-path`
1187          if test -z "$xcrundir"; then
1188             xcodedir="/usr/include"
1189          else
1190             xcodedir="$xcrundir/usr/include"
1191          fi
1192       else
1193          xcodedir="/usr/include"
1194       fi
1195    ])
1196 AC_MSG_RESULT([$xcodedir])
1197 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1198 AC_SUBST(XCODE_DIR, [$xcodedir])])
1200 #----------------------------------------------------------------------------
1201 # Libc and suppressions
1202 #----------------------------------------------------------------------------
1203 # This variable will collect the suppression files to be used.
1204 AC_SUBST(DEFAULT_SUPP)
1206 AC_CHECK_HEADER([features.h])
1208 if test x$ac_cv_header_features_h = xyes; then
1209   AC_DEFINE([HAVE_HEADER_FEATURES_H], 1,
1210           [Define to 1 if you have the `features.h' header.])
1211   rm -f conftest.$ac_ext
1212   cat <<_ACEOF >conftest.$ac_ext
1213 #include <features.h>
1214 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1215 glibc version is: __GLIBC__ __GLIBC_MINOR__
1216 #endif
1217 _ACEOF
1218   GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1221 # not really a version check
1222 AC_EGREP_CPP([DARWIN_LIBC], [
1223 #include <sys/cdefs.h>
1224 #if defined(__DARWIN_VERS_1050)
1225   DARWIN_LIBC
1226 #endif
1228 GLIBC_VERSION="darwin")
1230 AC_EGREP_CPP([FREEBSD_LIBC], [
1231 #include <sys/cdefs.h>
1232 #if defined(__FreeBSD__)
1233   FREEBSD_LIBC
1234 #endif
1236 GLIBC_VERSION="freebsd")
1238 # not really a version check
1239 AC_EGREP_CPP([BIONIC_LIBC], [
1240 #if defined(__ANDROID__)
1241   BIONIC_LIBC
1242 #endif
1244 GLIBC_VERSION="bionic")
1246 # there is only one version of libc on Solaris
1247 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1248      -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1249     GLIBC_VERSION="solaris"
1252 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1253 # in this case.
1254 if test x$GLIBC_VERSION = x; then
1255     if $CC -dumpmachine | grep -q musl; then
1256         GLIBC_VERSION=musl
1257     fi
1260 # If this is glibc then figure out the generic (in file) libc.so and
1261 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1262 # was a separate library, afterwards it was merged into libc.so and
1263 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1264 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1265 case ${GLIBC_VERSION} in
1267   AC_MSG_CHECKING([whether pthread_create needs libpthread])
1268   AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1269   [
1270     AC_MSG_RESULT([no])
1271     GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1272     GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1273   ], [
1274     AC_MSG_RESULT([yes])
1275     GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1276     GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1277   ])
1278   ;;
1280   AC_MSG_CHECKING([not glibc...])
1281   AC_MSG_RESULT([${GLIBC_VERSION}])
1282   ;;
1283 esac
1285 AC_MSG_CHECKING([the glibc version])
1287 case "${GLIBC_VERSION}" in
1288      2.2)
1289         AC_MSG_RESULT(${GLIBC_VERSION} family)
1290         DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1291         DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1292         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1293         ;;
1294      2.[[3-6]])
1295         AC_MSG_RESULT(${GLIBC_VERSION} family)
1296         DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1297         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1298         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1299         ;;
1300      2.[[7-9]])
1301         AC_MSG_RESULT(${GLIBC_VERSION} family)
1302         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1303         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1304         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1305         ;;
1306      2.10|2.11)
1307         AC_MSG_RESULT(${GLIBC_VERSION} family)
1308         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1309                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1310         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1311         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1312         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1313         ;;
1314      2.*)
1315         AC_MSG_RESULT(${GLIBC_VERSION} family)
1316         AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1317                   [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1318         AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1319                   [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1320         DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1321         DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1322         DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1323         ;;
1324      darwin)
1325         AC_MSG_RESULT(Darwin)
1326         AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1327         # DEFAULT_SUPP set by kernel version check above.
1328         ;;
1329      freebsd)
1330         AC_MSG_RESULT(FreeBSD)
1331         AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1332         # DEFAULT_SUPP set by kernel version check above.
1333         ;;
1334      bionic)
1335         AC_MSG_RESULT(Bionic)
1336         AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1337         DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1338         ;;
1339      solaris)
1340         AC_MSG_RESULT(Solaris)
1341         # DEFAULT_SUPP set in host_os switch-case above.
1342         # No other suppression file is used.
1343         ;;
1344      musl)
1345         AC_MSG_RESULT(Musl)
1346         AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1347         DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1348         ;;
1349      2.0|2.1|*)
1350         AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1351         AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1352         AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1353         ;;
1354 esac
1356 AC_SUBST(GLIBC_VERSION)
1357 AC_SUBST(GLIBC_LIBC_PATH)
1358 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1361 if test "$VGCONF_OS" != "solaris"; then
1362     # Add default suppressions for the X client libraries.  Make no
1363     # attempt to detect whether such libraries are installed on the
1364     # build machine (or even if any X facilities are present); just
1365     # add the suppressions antidisirregardless.
1366     DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1367     DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1371 #----------------------------------------------------------------------------
1372 # Platform variants?
1373 #----------------------------------------------------------------------------
1375 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1376 # But there are times where we need a bit more control.  The motivating
1377 # and currently only case is Android: this is almost identical to
1378 # {x86,arm,mips}-linux, but not quite.  So this introduces the concept of
1379 # platform variant tags, which get passed in the compile as
1380 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1382 # In almost all cases, the <variant> bit is "vanilla".  But for Android
1383 # it is "android" instead.
1385 # Consequently (eg), plain arm-linux would build with
1387 #   -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1389 # whilst an Android build would have
1391 #   -DVGP_arm_linux -DVGPV_arm_linux_android
1393 # Same for x86. The setup of the platform variant is pushed relatively far
1394 # down this file in order that we can inspect any of the variables set above.
1396 # In the normal case ..
1397 VGCONF_PLATVARIANT="vanilla"
1399 # Android ?
1400 if test "$GLIBC_VERSION" = "bionic";
1401 then
1402    VGCONF_PLATVARIANT="android"
1405 AC_SUBST(VGCONF_PLATVARIANT)
1408 # FIXME: do we also want to define automake variables
1409 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1410 # VANILLA or ANDROID ?  This would be in the style of VGCONF_ARCHS_INCLUDE,
1411 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above?  Could easily enough
1412 # do that.  Problem is that we can't do and-ing in Makefile.am's, but
1413 # that's what we'd need to do to use this, since what we'd want to write
1414 # is something like
1416 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1418 # Hmm.  Can't think of a nice clean solution to this.
1420 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1421                test x$VGCONF_PLATVARIANT = xvanilla)
1422 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1423                test x$VGCONF_PLATVARIANT = xandroid)
1426 #----------------------------------------------------------------------------
1427 # Checking for various library functions and other definitions
1428 #----------------------------------------------------------------------------
1430 # Check for AT_FDCWD
1432 AC_MSG_CHECKING([for AT_FDCWD])
1433 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1434 #define _GNU_SOURCE
1435 #include <fcntl.h>
1436 #include <unistd.h>
1437 ]], [[
1438   int a = AT_FDCWD;
1439 ]])], [
1440 ac_have_at_fdcwd=yes
1441 AC_MSG_RESULT([yes])
1442 ], [
1443 ac_have_at_fdcwd=no
1444 AC_MSG_RESULT([no])
1447 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1449 # Check for stpncpy function definition in string.h
1450 # This explicitly checks with _GNU_SOURCE defined since that is also
1451 # used in the test case (some systems might define it without anyway
1452 # since stpncpy is part of The Open Group Base Specifications Issue 7
1453 # IEEE Std 1003.1-2008.
1454 AC_MSG_CHECKING([for stpncpy])
1455 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1456 #define _GNU_SOURCE
1457 #include <string.h>
1458 ]], [[
1459   char *d;
1460   char *s;
1461   size_t n = 0;
1462   char *r = stpncpy(d, s, n);
1463 ]])], [
1464 ac_have_gnu_stpncpy=yes
1465 AC_MSG_RESULT([yes])
1466 ], [
1467 ac_have_gnu_stpncpy=no
1468 AC_MSG_RESULT([no])
1471 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1473 # Check for PTRACE_GETREGS
1475 AC_MSG_CHECKING([for PTRACE_GETREGS])
1476 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1477 #include <stdlib.h>
1478 #include <stddef.h>
1479 #include <sys/ptrace.h>
1480 #include <sys/user.h>
1481 ]], [[
1482   void *p;
1483   long res = ptrace (PTRACE_GETREGS, 0, p, p);
1484 ]])], [
1485 AC_MSG_RESULT([yes])
1486 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1487           [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1488 ], [
1489 AC_MSG_RESULT([no])
1493 # Check for CLOCK_MONOTONIC
1495 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1497 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1498 #include <time.h>
1499 ]], [[
1500   struct timespec t;
1501   clock_gettime(CLOCK_MONOTONIC, &t);
1502   return 0;
1503 ]])], [
1504 AC_MSG_RESULT([yes])
1505 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1506           [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1507 ], [
1508 AC_MSG_RESULT([no])
1512 # Check for ELF32/64_CHDR
1514 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1517 # Check for PTHREAD_RWLOCK_T
1519 AC_MSG_CHECKING([for pthread_rwlock_t])
1521 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1522 #define _GNU_SOURCE
1523 #include <pthread.h>
1524 ]], [[
1525   pthread_rwlock_t rwl;
1526 ]])], [
1527 AC_MSG_RESULT([yes])
1528 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1529           [Define to 1 if you have the `pthread_rwlock_t' type.])
1530 ], [
1531 AC_MSG_RESULT([no])
1534 # Check for CLOCKID_T
1536 AC_MSG_CHECKING([for clockid_t])
1538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1539 #include <time.h>
1540 ]], [[
1541   clockid_t c;
1542 ]])], [
1543 AC_MSG_RESULT([yes])
1544 AC_DEFINE([HAVE_CLOCKID_T], 1,
1545           [Define to 1 if you have the `clockid_t' type.])
1546 ], [
1547 AC_MSG_RESULT([no])
1550 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1552 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1554 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1555 #define _GNU_SOURCE
1556 #include <pthread.h>
1557 ]], [[
1558   return (PTHREAD_MUTEX_ADAPTIVE_NP);
1559 ]])], [
1560 AC_MSG_RESULT([yes])
1561 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1562           [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1563 ], [
1564 AC_MSG_RESULT([no])
1568 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1570 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1572 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1573 #define _GNU_SOURCE
1574 #include <pthread.h>
1575 ]], [[
1576   return (PTHREAD_MUTEX_ERRORCHECK_NP);
1577 ]])], [
1578 AC_MSG_RESULT([yes])
1579 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1580           [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1581 ], [
1582 AC_MSG_RESULT([no])
1586 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1588 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1590 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1591 #define _GNU_SOURCE
1592 #include <pthread.h>
1593 ]], [[
1594   return (PTHREAD_MUTEX_RECURSIVE_NP);
1595 ]])], [
1596 AC_MSG_RESULT([yes])
1597 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1598           [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1599 ], [
1600 AC_MSG_RESULT([no])
1604 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1606 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1608 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1609 #define _GNU_SOURCE
1610 #include <pthread.h>
1611 ]], [[
1612   pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1613   return 0;
1614 ]])], [
1615 AC_MSG_RESULT([yes])
1616 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1617           [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1618 ], [
1619 AC_MSG_RESULT([no])
1623 # Check whether pthread_mutex_t has a member called __m_kind.
1625 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1626                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1627                            1,                                   
1628                            [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1629                 ],
1630                 [],
1631                 [#include <pthread.h>])
1634 # Check whether pthread_mutex_t has a member called __data.__kind.
1636 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1637                 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1638                           1,
1639                           [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1640                 ],
1641                 [],
1642                 [#include <pthread.h>])
1644 # Convenience function.  Set flags based on the existing HWCAP entries.
1645 # The AT_HWCAP entries are generated by glibc, and are based on
1646 # functions supported by the hardware/system/libc.
1647 # Subsequent support for whether the capability will actually be utilized
1648 # will also be checked against the compiler capabilities.
1649 # called as
1650 #      AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1651 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1652   AUXV_CHECK_FOR=$1
1653   AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1654   if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1655   then
1656     AC_MSG_RESULT([yes])
1657     AC_SUBST([$2],[yes])
1658   else
1659     AC_MSG_RESULT([no])
1660     AC_SUBST([$2],[])
1661   fi
1664 # gather hardware capabilities. (hardware/kernel/libc)
1665 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1666 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1667 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1668 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1669 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1670 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1671 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1672 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1673 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1674 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1676 # ISA Levels
1677 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1678 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1679 # compiler support for isa 2.07 level instructions
1680 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1682 ]], [[
1683   __asm__ __volatile__("mtvsrd 1,2 ");
1684 ]])], [
1685 ac_asm_have_isa_2_07=yes
1686 AC_MSG_RESULT([yes])
1687 ], [
1688 ac_asm_have_isa_2_07=no
1689 AC_MSG_RESULT([no])
1691 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1692                                -a x$HWCAP_HAS_ISA_2_07 = xyes])
1694 # altivec (vsx) support.
1695 # does this compiler support -maltivec and does it have the include file
1696 # <altivec.h> ?
1697 AC_MSG_CHECKING([for Altivec support in the compiler ])
1698 safe_CFLAGS=$CFLAGS
1699 CFLAGS="-maltivec -Werror"
1700 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1701 #include <altivec.h>
1702 ]], [[
1703   vector unsigned int v;
1704 ]])], [
1705 ac_have_altivec=yes
1706 AC_MSG_RESULT([yes])
1707 ], [
1708 ac_have_altivec=no
1709 AC_MSG_RESULT([no])
1711 CFLAGS=$safe_CFLAGS
1712 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1713                                  -a x$HWCAP_HAS_ALTIVEC = xyes])
1715 # Check that both: the compiler supports -mvsx and that the assembler
1716 # understands VSX instructions.  If either of those doesn't work,
1717 # conclude that we can't do VSX.
1718 AC_MSG_CHECKING([for VSX compiler flag support])
1719 safe_CFLAGS=$CFLAGS
1720 CFLAGS="-mvsx -Werror"
1721 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1722 ]], [[
1723 ]])], [
1724 ac_compiler_supports_vsx_flag=yes
1725 AC_MSG_RESULT([yes])
1726 ], [
1727 ac_compiler_supports_vsx_flag=no
1728 AC_MSG_RESULT([no])
1730 CFLAGS=$safe_CFLAGS
1732 AC_MSG_CHECKING([for VSX support in the assembler ])
1733 safe_CFLAGS=$CFLAGS
1734 CFLAGS="-mvsx -Werror"
1735 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1736 #include <altivec.h>
1737 ]], [[
1738   vector unsigned int v;
1739   __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1740 ]])], [
1741 ac_compiler_supports_vsx=yes
1742 AC_MSG_RESULT([yes])
1743 ], [
1744 ac_compiler_supports_vsx=no
1745 AC_MSG_RESULT([no])
1747 CFLAGS=$safe_CFLAGS
1748 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1749                              -a x$ac_compiler_supports_vsx = xyes \
1750                              -a x$HWCAP_HAS_VSX = xyes ])
1752 # DFP (Decimal Float)
1753 # The initial DFP support was added in Power 6.  The dcffix instruction
1754 # support was added in Power 7.
1755 AC_MSG_CHECKING([that assembler knows DFP])
1756 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1757 ]], [[
1758   #ifdef __s390__
1759   __asm__ __volatile__("adtr 1, 2, 3")
1760   #else
1761 __asm__ __volatile__(".machine power7;\n" \
1762   "dadd 1, 2, 3;\n" \
1763   "dcffix 1, 2");
1764   #endif
1765 ]])], [
1766 ac_asm_have_dfp=yes
1767 AC_MSG_RESULT([yes])
1768 ], [
1769 ac_asm_have_dfp=no
1770 AC_MSG_RESULT([no])
1772 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1773 safe_CFLAGS=$CFLAGS
1774 CFLAGS="-mhard-dfp -Werror"
1776 # The dcffix instruction is Power 7
1777 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1778 ]], [[
1779   #ifdef __s390__
1780   __asm__ __volatile__("adtr 1, 2, 3")
1781   #else
1782   __asm__ __volatile__(".machine power7;\n" \
1783   "dadd 1, 2, 3;\n" \
1784   "dcffix 1, 2");
1785   #endif
1786 ]])], [
1787 ac_compiler_have_dfp=yes
1788 AC_MSG_RESULT([yes])
1789 ], [
1790 ac_compiler_have_dfp=no
1791 AC_MSG_RESULT([no])
1793 CFLAGS=$safe_CFLAGS
1794 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1795                           -a x$ac_compiler_have_dfp = xyes \
1796                           -a x$HWCAP_HAS_DFP = xyes )
1798 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1799 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1800 ]], [[
1801   _Decimal64 x = 0.0DD;
1802 ]])], [
1803 ac_compiler_have_dfp_type=yes
1804 AC_MSG_RESULT([yes])
1805 ], [
1806 ac_compiler_have_dfp_type=no
1807 AC_MSG_RESULT([no])
1809 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1810                                   -a x$HWCAP_HAS_DFP = xyes )
1813 # HTM (Hardware Transactional Memory)
1814 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1815 safe_CFLAGS=$CFLAGS
1816 CFLAGS="-mhtm -Werror"
1817 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1818 ]], [[
1819   return 0;
1820 ]])], [
1821 AC_MSG_RESULT([yes])
1822 ac_compiler_supports_htm=yes
1823 ], [
1824 AC_MSG_RESULT([no])
1825 ac_compiler_supports_htm=no
1827 CFLAGS=$safe_CFLAGS
1829 AC_MSG_CHECKING([if compiler can find the htm builtins])
1830 safe_CFLAGS=$CFLAGS
1831 CFLAGS="-mhtm -Werror"
1832  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1833  ]], [[
1834    if (__builtin_tbegin (0))
1835       __builtin_tend (0);
1836  ]])], [
1837  AC_MSG_RESULT([yes])
1838 ac_compiler_sees_htm_builtins=yes
1839  ], [
1840  AC_MSG_RESULT([no])
1841 ac_compiler_sees_htm_builtins=no
1842  ])
1843 CFLAGS=$safe_CFLAGS
1845 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1846                                -a x$ac_compiler_sees_htm_builtins = xyes \
1847                                -a x$HWCAP_HAS_HTM = xyes )
1849 # isa 3.0 checking. (actually 3.0 or newer)
1850 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1852 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1853 ]], [[
1854 __asm__ __volatile__ (".machine power9;\n" \
1855         "cnttzw   1,3; \n" );
1856 ]])], [
1857 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1858 # cpabort support
1859 safe_CFLAGS=$CFLAGS
1860 CFLAGS="-DHAS_ISA_3_00"
1861 ac_asm_have_isa_3_00=yes
1862 AC_MSG_RESULT([yes])
1863 ], [
1864 ac_asm_have_isa_3_00=no
1865 AC_MSG_RESULT([no])
1867 CFLAGS=$safe_CFLAGS
1869 # xscvhpdp checking
1870 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1872 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1873 ]], [[
1874 __asm__ __volatile__ (".machine power9;\n" \
1875         "xscvhpdp 1,2;\n" );
1876 ]])], [
1877 ac_asm_have_xscvhpdp=yes
1878 AC_MSG_RESULT([yes])
1879 ], [
1880 ac_asm_have_xscvhpdp=no
1881 AC_MSG_RESULT([no])
1884 # darn instruction checking
1885 AC_MSG_CHECKING([that assembler knows darn instruction ])
1887 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1888 ]], [[
1889   __asm__ __volatile__(".machine power9; darn 1,0 ");
1890 ]])], [
1891 ac_asm_have_darn_inst=yes
1892 AC_MSG_RESULT([yes])
1893 ], [
1894 ac_asm_have_darn_inst=no
1895 AC_MSG_RESULT([no])
1898 # isa 3.01 checking
1899 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1900 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1901 ]], [[
1902 __asm__ __volatile__ (".machine power10;\n" \
1903         "brh 1,2;\n ");
1904 ]])], [
1905 ac_asm_have_isa_3_1=yes
1906 AC_MSG_RESULT([yes])
1907 ], [
1908 ac_asm_have_isa_3_1=no
1909 AC_MSG_RESULT([no])
1913 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1914                              -a x$HWCAP_HAS_ISA_3_00 = xyes])
1916 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1917 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1919 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1920                              -a x$HWCAP_HAS_ISA_3_1 = xyes])
1922 # Check for pthread_create@GLIBC2.0
1923 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1925 safe_CFLAGS=$CFLAGS
1926 CFLAGS="-lpthread -Werror"
1927 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1928 extern int pthread_create_glibc_2_0(void*, const void*,
1929                                     void *(*)(void*), void*);
1930 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1931 ]], [[
1932 #ifdef __powerpc__
1934  * Apparently on PowerPC linking this program succeeds and generates an
1935  * executable with the undefined symbol pthread_create@GLIBC_2.0.
1936  */
1937 #error This test does not work properly on PowerPC.
1938 #else
1939   pthread_create_glibc_2_0(0, 0, 0, 0);
1940 #endif
1941   return 0;
1942 ]])], [
1943 ac_have_pthread_create_glibc_2_0=yes
1944 AC_MSG_RESULT([yes])
1945 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1946           [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1947 ], [
1948 ac_have_pthread_create_glibc_2_0=no
1949 AC_MSG_RESULT([no])
1951 CFLAGS=$safe_CFLAGS
1953 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1954                test x$ac_have_pthread_create_glibc_2_0 = xyes)
1957 # Check for dlinfo RTLD_DI_TLS_MODID
1958 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1960 safe_LIBS="$LIBS"
1961 LIBS="-ldl"
1962 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1963 #ifndef _GNU_SOURCE
1964 #define _GNU_SOURCE
1965 #endif
1966 #include <link.h>
1967 #include <dlfcn.h>
1968 ]], [[
1969   size_t sizes[10000];
1970   size_t modid_offset;
1971   (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1972   return 0;
1973 ]])], [
1974 ac_have_dlinfo_rtld_di_tls_modid=yes
1975 AC_MSG_RESULT([yes])
1976 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1977           [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1978 ], [
1979 ac_have_dlinfo_rtld_di_tls_modid=no
1980 AC_MSG_RESULT([no])
1982 LIBS=$safe_LIBS
1984 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1985                test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1988 # Check for eventfd_t, eventfd() and eventfd_read()
1989 AC_MSG_CHECKING([for eventfd()])
1991 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1992 #include <sys/eventfd.h>
1993 ]], [[
1994   eventfd_t ev;
1995   int fd;
1997   fd = eventfd(5, 0);
1998   eventfd_read(fd, &ev);
1999   return 0;
2000 ]])], [
2001 AC_MSG_RESULT([yes])
2002 AC_DEFINE([HAVE_EVENTFD], 1,
2003           [Define to 1 if you have the `eventfd' function.])
2004 AC_DEFINE([HAVE_EVENTFD_READ], 1,
2005           [Define to 1 if you have the `eventfd_read' function.])
2006 ], [
2007 AC_MSG_RESULT([no])
2010 # Check whether compiler can process #include <thread> without errors
2011 # clang 3.3 cannot process <thread> from e.g.
2012 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
2014 AC_MSG_CHECKING([that C++ compiler can compile C++17 code])
2015 AC_LANG(C++)
2016 safe_CXXFLAGS=$CXXFLAGS
2017 CXXFLAGS=-std=c++17
2019 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2020 int x;
2021 ])],
2023 ac_have_cxx_17=yes
2024 AC_MSG_RESULT([yes])
2025 ], [
2026 ac_have_cxx_17=no
2027 AC_MSG_RESULT([no])
2029 CXXFLAGS=$safe_CXXFLAGS
2030 AC_LANG(C)
2032 AM_CONDITIONAL(HAVE_CXX17, test x$ac_have_cxx_17 = xyes)
2034 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
2035 AC_LANG(C++)
2036 safe_CXXFLAGS=$CXXFLAGS
2037 CXXFLAGS=-std=c++0x
2039 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2040 #include <thread> 
2041 ])],
2043 ac_cxx_can_include_thread_header=yes
2044 AC_MSG_RESULT([yes])
2045 ], [
2046 ac_cxx_can_include_thread_header=no
2047 AC_MSG_RESULT([no])
2049 CXXFLAGS=$safe_CXXFLAGS
2050 AC_LANG(C)
2052 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2054 # Check whether compiler can process #include <condition_variable> without errors
2056 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2057 AC_LANG(C++)
2058 safe_CXXFLAGS=$CXXFLAGS
2059 CXXFLAGS=-std=c++0x
2061 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2062 #include <condition_variable> 
2063 ])],
2065 ac_cxx_can_include_condition_variable_header=yes
2066 AC_MSG_RESULT([yes])
2067 ], [
2068 ac_cxx_can_include_condition_variable_header=no
2069 AC_MSG_RESULT([no])
2071 CXXFLAGS=$safe_CXXFLAGS
2072 AC_LANG(C)
2074 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2076 # check for std::shared_timed_mutex, this is a C++ 14 feature
2078 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2079 AC_LANG(C++)
2080 safe_CXXFLAGS=$CXXFLAGS
2081 CXXFLAGS="-std=c++1y -pthread"
2083 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2084 #include <shared_mutex>
2085 std::shared_timed_mutex test_mutex;
2086 ])],
2088 ac_cxx_can_use_shared_timed_mutex=yes
2089 AC_MSG_RESULT([yes])
2090 ], [
2091 ac_cxx_can_use_shared_timed_mutex=no
2092 AC_MSG_RESULT([no])
2094 CXXFLAGS=$safe_CXXFLAGS
2095 AC_LANG(C)
2097 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2099 # check for std::shared_mutex, this is a C++ 11 feature
2101 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2102 AC_LANG(C++)
2103 safe_CXXFLAGS=$CXXFLAGS
2104 CXXFLAGS="-std=c++0x -pthread"
2106 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2107 #include <mutex>
2108 std::timed_mutex test_mutex;
2109 ])],
2111 ac_cxx_can_use_timed_mutex=yes
2112 AC_MSG_RESULT([yes])
2113 ], [
2114 ac_cxx_can_use_timed_mutex=no
2115 AC_MSG_RESULT([no])
2117 CXXFLAGS=$safe_CXXFLAGS
2118 AC_LANG(C)
2120 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2122 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2123 # of the user_regs_struct from sys/user.h. They are structurally the same
2124 # but we get either one or the other.
2126 AC_CHECK_TYPE([struct user_regs_struct],
2127               [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2128               [[#include <sys/ptrace.h>]
2129                [#include <sys/time.h>]
2130                [#include <sys/user.h>]])
2131 if test "$sys_user_has_user_regs" = "yes"; then
2132   AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2133             [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2136 AC_MSG_CHECKING([for __NR_membarrier])
2137 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2138 #include <linux/unistd.h>
2139 ]], [[
2140 return __NR_membarrier
2141 ]])], [
2142 ac_have_nr_membarrier=yes
2143 AC_MSG_RESULT([yes])
2144 ], [
2145 ac_have_nr_membarrier=no
2146 AC_MSG_RESULT([no])
2149 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2151 #----------------------------------------------------------------------------
2152 # Checking for supported compiler flags.
2153 #----------------------------------------------------------------------------
2155 case "${host_cpu}" in
2156     mips*)
2157         ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2158         if test -z "$ARCH"; then
2159           # does this compiler support -march=mips32 (mips32 default) ?
2160           AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2162           safe_CFLAGS=$CFLAGS
2163           CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2165           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2166             return 0;
2167           ]])], [
2168           FLAG_M32="-mips32 -mabi=32"
2169           AC_MSG_RESULT([yes])
2170           ], [
2171           FLAG_M32=""
2172           AC_MSG_RESULT([no])
2173           ])
2174           CFLAGS=$safe_CFLAGS
2176           AC_SUBST(FLAG_M32)
2179           # does this compiler support -march=mips64r2 (mips64r2 default) ?
2180           AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2182           safe_CFLAGS=$CFLAGS
2183           CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2185           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2186             return 0;
2187           ]])], [
2188           FLAG_M64="-march=mips64r2 -mabi=64"
2189           AC_MSG_RESULT([yes])
2190           ], [
2191           FLAG_M64=""
2192           AC_MSG_RESULT([no])
2193           ])
2194           CFLAGS=$safe_CFLAGS
2196           AC_SUBST(FLAG_M64)
2197         fi
2198         ;;
2199     nanomips*)
2200         ;;
2201     *)
2202         # does this compiler support -m32 ?
2203         AC_MSG_CHECKING([if gcc accepts -m32])
2205         safe_CFLAGS=$CFLAGS
2206         CFLAGS="${FLAG_32ON64} -m32 -Werror"
2208         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2209           return 0;
2210         ]])], [
2211         FLAG_M32="${FLAG_32ON64} -m32"
2212         AC_MSG_RESULT([yes])
2213         ], [
2214         FLAG_M32=""
2215         AC_MSG_RESULT([no])
2216         ])
2217         CFLAGS=$safe_CFLAGS
2219         AC_SUBST(FLAG_M32)
2222         # does this compiler support -m64 ?
2223         AC_MSG_CHECKING([if gcc accepts -m64])
2225         safe_CFLAGS=$CFLAGS
2226         CFLAGS="-m64 -Werror"
2228         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2229           return 0;
2230         ]])], [
2231         FLAG_M64="-m64"
2232         AC_MSG_RESULT([yes])
2233         ], [
2234         FLAG_M64=""
2235         AC_MSG_RESULT([no])
2236         ])
2237         CFLAGS=$safe_CFLAGS
2239         AC_SUBST(FLAG_M64)
2240         ;;
2241 esac
2244 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2245 if test -z "$ARCH"; then
2246   # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2247   AC_MSG_CHECKING([if gcc accepts -march=octeon])
2249   safe_CFLAGS=$CFLAGS
2250   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2252   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2253     return 0;
2254   ]])], [
2255   FLAG_OCTEON="-march=octeon"
2256   AC_MSG_RESULT([yes])
2257   ], [
2258   FLAG_OCTEON=""
2259   AC_MSG_RESULT([no])
2260   ])
2261   CFLAGS=$safe_CFLAGS
2263   AC_SUBST(FLAG_OCTEON)
2266   # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2267   AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2269   safe_CFLAGS=$CFLAGS
2270   CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2272   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2273     return 0;
2274   ]])], [
2275   FLAG_OCTEON2="-march=octeon2"
2276   AC_MSG_RESULT([yes])
2277   ], [
2278   FLAG_OCTEON2=""
2279   AC_MSG_RESULT([no])
2280   ])
2281   CFLAGS=$safe_CFLAGS
2283   AC_SUBST(FLAG_OCTEON2)
2287 # does this compiler support -mmsa (MIPS MSA ASE) ?
2288 AC_MSG_CHECKING([if gcc accepts -mmsa])
2290 safe_CFLAGS=$CFLAGS
2291 CFLAGS="$CFLAGS -mmsa -Werror"
2293 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2294     return 0;
2295 ]])], [
2296 FLAG_MSA="-mmsa"
2297 AC_MSG_RESULT([yes])
2298 ], [
2299 FLAG_MSA=""
2300 AC_MSG_RESULT([no])
2302 CFLAGS=$safe_CFLAGS
2304 AC_SUBST(FLAG_MSA)
2306 # Are we compiling for the MIPS64 n32 ABI?
2307 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2308 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2309 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2310 #error NO
2311 #endif
2312 ]])], [
2313 VGCONF_ABI=N32
2314 FLAG_M64="-march=mips64r2 -mabi=n32"
2315 AC_MSG_RESULT([yes])
2316 ], [
2317 AC_MSG_RESULT([no])
2320 # Are we compiling for the MIPS64 n64 ABI?
2321 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2322 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2323 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2324 #error NO
2325 #endif
2326 ]])], [
2327 VGCONF_ABI=64
2328 AC_MSG_RESULT([yes])
2329 ], [
2330 AC_MSG_RESULT([no])
2333 # We enter the code block below in the following case:
2334 # Target architecture is set to mips64, the desired abi
2335 # was not specified and the compiler's default abi setting
2336 # is neither n32 nor n64.
2337 # Probe for and set the abi to either n64 or n32, in that order,
2338 # which is required for a mips64 build of valgrind.
2339 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2340   safe_CFLAGS=$CFLAGS
2341   CFLAGS="$CFLAGS -mabi=64 -Werror"
2342   AC_MSG_CHECKING([if gcc is n64 capable])
2343   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2344       return 0;
2345   ]])], [
2346   VGCONF_ABI=64
2347   AC_MSG_RESULT([yes])
2348   ], [
2349   AC_MSG_RESULT([no])
2350   ])
2351   CFLAGS=$safe_CFLAGS
2353   if test "x$VGCONF_ABI" = "x"; then
2354     safe_CFLAGS=$CFLAGS
2355     CFLAGS="$CFLAGS -mabi=n32 -Werror"
2356     AC_MSG_CHECKING([if gcc is n32 capable])
2357     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2358         return 0;
2359     ]])], [
2360     VGCONF_ABI=N32
2361     FLAG_M64="-march=mips64r2 -mabi=n32"
2362     AC_MSG_RESULT([yes])
2363     ], [
2364     AC_MSG_RESULT([no])
2365     ])
2366     CFLAGS=$safe_CFLAGS
2367   fi
2370 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2371                [test x$VGCONF_ABI != x])
2372 AC_SUBST(VGCONF_ABI)
2375 # does this compiler support -mmmx ?
2376 AC_MSG_CHECKING([if gcc accepts -mmmx])
2378 safe_CFLAGS=$CFLAGS
2379 CFLAGS="-mmmx -Werror"
2381 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2382   return 0;
2383 ]])], [
2384 FLAG_MMMX="-mmmx"
2385 AC_MSG_RESULT([yes])
2386 ], [
2387 FLAG_MMMX=""
2388 AC_MSG_RESULT([no])
2390 CFLAGS=$safe_CFLAGS
2392 AC_SUBST(FLAG_MMMX)
2395 # does this compiler support -msse ?
2396 AC_MSG_CHECKING([if gcc accepts -msse])
2398 safe_CFLAGS=$CFLAGS
2399 CFLAGS="-msse -Werror"
2401 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2402   return 0;
2403 ]])], [
2404 FLAG_MSSE="-msse"
2405 AC_MSG_RESULT([yes])
2406 ], [
2407 FLAG_MSSE=""
2408 AC_MSG_RESULT([no])
2410 CFLAGS=$safe_CFLAGS
2412 AC_SUBST(FLAG_MSSE)
2415 # does this compiler support -mpreferred-stack-boundary=2 when
2416 # generating code for a 32-bit target?  Note that we only care about
2417 # this when generating code for (32-bit) x86, so if the compiler
2418 # doesn't recognise -m32 it's no big deal.  We'll just get code for
2419 # the Memcheck and other helper functions, that is a bit slower than
2420 # it could be, on x86; and no difference at all on any other platform.
2421 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2423 safe_CFLAGS=$CFLAGS
2424 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2426 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2427   return 0;
2428 ]])], [
2429 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2430 AC_MSG_RESULT([yes])
2431 ], [
2432 PREFERRED_STACK_BOUNDARY_2=""
2433 AC_MSG_RESULT([no])
2435 CFLAGS=$safe_CFLAGS
2437 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2440 # does this compiler support -mlong-double-128 ?
2441 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2442 safe_CFLAGS=$CFLAGS
2443 CFLAGS="-mlong-double-128 -Werror"
2444 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2445   return 0;
2446 ]])], [
2447 ac_compiler_supports_mlong_double_128=yes
2448 AC_MSG_RESULT([yes])
2449 ], [
2450 ac_compiler_supports_mlong_double_128=no
2451 AC_MSG_RESULT([no])
2453 CFLAGS=$safe_CFLAGS
2454 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2455 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2456 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2458 # does this toolchain support lto ?
2459 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2460 # are not defined
2461 # If not enable-lto=* arg is provided, default to no, as  lto builds are
2462 # a lot slower, and so not appropriate for Valgrind developments.
2463 # --enable-lto=yes should be used by distro packagers.
2464 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2465    [AC_ARG_ENABLE(lto,
2466       [  --enable-lto          enables building with link time optimisation],
2467       [vg_cv_lto=$enableval],
2468       [vg_cv_lto=no])])
2470 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2471 AC_MSG_CHECKING([if toolchain accepts lto])
2472 safe_CFLAGS=$CFLAGS
2473 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2474 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2475 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2476 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2478 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2479   extern void somefun(void);
2480   somefun();
2481   return 0;
2482 ]])], [
2483 LTO_CFLAGS=$TEST_LTO_CFLAGS
2484 AC_MSG_RESULT([yes])
2485 ], [
2486 LTO_CFLAGS=""
2487 AC_MSG_RESULT([no])
2489 CFLAGS=$safe_CFLAGS
2492 AC_SUBST(LTO_CFLAGS)
2494 # if we could not compile with lto args, or lto was disabled,
2495 # then set LTO_AR/LTO_RANLIB to the non lto values
2496 # define in config.h ENABLE_LTO (not needed by the code currently, but
2497 # this guarantees we recompile everything if we re-configure and rebuild
2498 # in a build dir previously build with another value of --enable-lto
2499 if test "x${LTO_CFLAGS}" = "x"; then
2500    LTO_AR=${AR}
2501    LTO_RANLIB=${RANLIB}
2502    vg_cv_lto=no
2503 else
2504    vg_cv_lto=yes
2505    AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2508 # Convenience function to check whether GCC supports a particular
2509 # warning option. Takes two arguments,
2510 # first the warning flag name to check (without -W), then the
2511 # substitution name to set with -Wno-warning-flag if the flag exists,
2512 # or the empty string if the compiler doesn't accept the flag. Note
2513 # that checking is done against the warning flag itself, but the
2514 # substitution is then done to cancel the warning flag.
2515 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2516   AC_MSG_CHECKING([if gcc accepts -W$1])
2517   safe_CFLAGS=$CFLAGS
2518   CFLAGS="-W$1 -Werror"
2519   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2520   AC_SUBST([$2], [-Wno-$1])
2521   AC_MSG_RESULT([yes])], [
2522   AC_SUBST([$2], [])
2523   AC_MSG_RESULT([no])])
2524   CFLAGS=$safe_CFLAGS
2527 # A variation of the above for arguments that
2528 # take a value
2529 AC_DEFUN([AC_GCC_WARNING_SUBST_NO_VAL],[
2530   AC_MSG_CHECKING([if gcc accepts -W$1=$2])
2531   safe_CFLAGS=$CFLAGS
2532   CFLAGS="-W$1=$2 -Werror"
2533   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2534   AC_SUBST([$3], [-Wno-$1])
2535   AC_MSG_RESULT([yes])], [
2536   AC_SUBST([$3], [])
2537   AC_MSG_RESULT([no])])
2538   CFLAGS=$safe_CFLAGS
2541 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2542 # -W$1  (instead of -Wno-$1).
2543 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2544   AC_MSG_CHECKING([if gcc accepts -W$1])
2545   safe_CFLAGS=$CFLAGS
2546   CFLAGS="-W$1 -Werror"
2547   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2548   AC_SUBST([$2], [-W$1])
2549   AC_MSG_RESULT([yes])], [
2550   AC_SUBST([$2], [])
2551   AC_MSG_RESULT([no])])
2552   CFLAGS=$safe_CFLAGS
2555 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2556 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2557 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2558 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2559 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2560 AC_GCC_WARNING_SUBST_NO([maybe-uninitialized], [FLAG_W_NO_MAYBE_UNINITIALIZED])
2561 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2562 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2563 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2564 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2565 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2566 AC_GCC_WARNING_SUBST_NO([unused-but-set-variable], [FLAG_W_NO_UNUSED_BUT_SET_VARIABLE])
2567 AC_GCC_WARNING_SUBST_NO([non-power-of-two-alignment], [FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT])
2568 AC_GCC_WARNING_SUBST_NO([sign-compare], [FLAG_W_NO_SIGN_COMPARE])
2569 AC_GCC_WARNING_SUBST_NO([stringop-overflow], [FLAG_W_NO_STRINGOP_OVERFLOW])
2570 AC_GCC_WARNING_SUBST_NO([stringop-overread], [FLAG_W_NO_STRINGOP_OVERREAD])
2571 AC_GCC_WARNING_SUBST_NO([stringop-truncation], [FLAG_W_NO_STRINGOP_TRUNCATION])
2572 AC_GCC_WARNING_SUBST_NO([format-overflow], [FLAG_W_NO_FORMAT_OVERFLOW])
2573 AC_GCC_WARNING_SUBST_NO([use-after-free], [FLAG_W_NO_USE_AFTER_FREE])
2574 AC_GCC_WARNING_SUBST_NO([free-nonheap-object], [FLAG_W_NO_FREE_NONHEAP_OBJECT])
2575 AC_GCC_WARNING_SUBST_NO([fortify-source], [FLAG_W_NO_FORTIFY_SOURCE])
2576 AC_GCC_WARNING_SUBST_NO([builtin-memcpy-chk-size], [FLAG_W_NO_BUILTIN_MEMCPY_CHK_SIZE])
2577 AC_GCC_WARNING_SUBST_NO([incompatible-pointer-types-discards-qualifiers], [FLAG_W_NO_INCOMPATIBLE_POINTER_TYPES_DISCARDS_QUALIFIERS])
2578 AC_GCC_WARNING_SUBST_NO([suspicious-bzero], [FLAG_W_NO_SUSPICIOUS_BZERO])
2580 AC_GCC_WARNING_SUBST_NO_VAL([alloc-size-larger-than], [1677216], [FLAG_W_NO_ALLOC_SIZE_LARGER_THAN])
2582 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2583 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2584 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2585 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2586 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2587 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2588 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2589 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2590 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2591 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2592 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2594 # Does this compiler support -Wformat-security ?
2595 # Special handling is needed, because certain GCC versions require -Wformat
2596 # being present if -Wformat-security is given. Otherwise a warning is issued.
2597 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2598 # And with that the warning will be turned into an error with the result
2599 # that -Wformat-security is believed to be unsupported when in fact it is.
2600 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2601 safe_CFLAGS=$CFLAGS
2602 CFLAGS="-Wformat -Wformat-security -Werror"
2603 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2604 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2605 AC_MSG_RESULT([yes])], [
2606 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2607 AC_MSG_RESULT([no])])
2608 CFLAGS=$safe_CFLAGS
2610 # does this compiler support -Wextra or the older -W ?
2612 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2614 safe_CFLAGS=$CFLAGS
2615 CFLAGS="-Wextra -Werror"
2617 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2618   return 0;
2619 ]])], [
2620 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2621 AC_MSG_RESULT([-Wextra])
2622 ], [
2623   CFLAGS="-W -Werror"
2624   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2625     return 0;
2626   ]])], [
2627   AC_SUBST([FLAG_W_EXTRA], [-W])
2628   AC_MSG_RESULT([-W])
2629   ], [
2630   AC_SUBST([FLAG_W_EXTRA], [])
2631   AC_MSG_RESULT([not supported])
2632   ])
2634 CFLAGS=$safe_CFLAGS
2636 # On ARM we do not want to pass -Wcast-align as that produces loads
2637 # of warnings. GCC is just being conservative. See here:
2638 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2639 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2640   AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2641 else
2642   AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2645 # does this compiler support -faligned-new ?
2646 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2648 safe_CXXFLAGS=$CXXFLAGS
2649 CXXFLAGS="-faligned-new -Werror"
2651 AC_LANG(C++)
2652 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2653   return 0;
2654 ]])], [
2655 FLAG_FALIGNED_NEW="-faligned-new"
2656 AC_MSG_RESULT([yes])
2657 ], [
2658 FLAG_FALIGNED_NEW=""
2659 AC_MSG_RESULT([no])
2661 CXXFLAGS=$safe_CXXFLAGS
2662 AC_LANG(C)
2664 AC_SUBST(FLAG_FALIGNED_NEW)
2666 # does this compiler support -fsized-deallocation ?
2667 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2669 safe_CXXFLAGS=$CXXFLAGS
2670 CXXFLAGS="-fsized-deallocation -Werror"
2672 AC_LANG(C++)
2673 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2674   return 0;
2675 ]])], [
2676 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2677 ac_have_sized_deallocation=yes
2678 AC_MSG_RESULT([yes])
2679 ], [
2680 FLAG_FSIZED_DEALLOCATION=""
2681 ac_have_sized_deallocation=no
2682 AC_MSG_RESULT([no])
2684 CXXFLAGS=$safe_CXXFLAGS
2685 AC_LANG(C)
2687 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2688 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2690 # does this compiler support C++17 aligned new/delete?
2691 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2693 safe_CXXFLAGS=$CXXFLAGS
2694 CXXFLAGS="-std=c++17"
2696 AC_LANG(C++)
2697 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2698 #include <cstdlib>
2699 #include <new>
2700 ]], [[
2701   operator delete(nullptr, std::align_val_t(64U));
2702 ]])], [
2703 ac_have_aligned_cxx_alloc=yes
2704 AC_MSG_RESULT([yes])
2705 ], [
2706 ac_have_aligned_cxx_alloc=no
2707 AC_MSG_RESULT([no])
2709 CXXFLAGS=$safe_CXXFLAGS
2710 AC_LANG(C)
2712 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2714 # does this compiler support -fno-stack-protector ?
2715 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2717 safe_CFLAGS=$CFLAGS
2718 CFLAGS="-fno-stack-protector -Werror"
2720 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2721   return 0;
2722 ]])], [
2723 no_stack_protector=yes
2724 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2725 AC_MSG_RESULT([yes])
2726 ], [
2727 no_stack_protector=no
2728 FLAG_FNO_STACK_PROTECTOR=""
2729 AC_MSG_RESULT([no])
2731 CFLAGS=$safe_CFLAGS
2733 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2735 # does this compiler support -finline-functions ?
2736 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2738 safe_CFLAGS=$CFLAGS
2739 CFLAGS="-finline-functions -Werror"
2741 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2742   return 0;
2743 ]])], [
2744 inline_functions=yes
2745 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2746 AC_MSG_RESULT([yes])
2747 ], [
2748 inline_functions=no
2749 FLAG_FINLINE_FUNCTIONS=""
2750 AC_MSG_RESULT([no])
2752 CFLAGS=$safe_CFLAGS
2754 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2756 # Does GCC support disabling Identical Code Folding?
2757 # We want to disabled Identical Code Folding for the
2758 # tools preload shared objects to get better backraces.
2759 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2760 # "The optimization reduces code size and may disturb
2761 #  unwind stacks by replacing a function by equivalent
2762 #  one with a different name."
2763 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2765 safe_CFLAGS=$CFLAGS
2766 CFLAGS="-fno-ipa-icf -Werror"
2768 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2769   return 0;
2770 ]])], [
2771 no_ipa_icf=yes
2772 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2773 AC_MSG_RESULT([yes])
2774 ], [
2775 no_ipa_icf=no
2776 FLAG_FNO_IPA_ICF=""
2777 AC_MSG_RESULT([no])
2779 CFLAGS=$safe_CFLAGS
2781 AC_SUBST(FLAG_FNO_IPA_ICF)
2784 # Does this compiler support -fsanitize=undefined. This is true for
2785 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2786 # also checks for alignment violations on memory accesses which the valgrind
2787 # code base is sprinkled (if not littered) with. As those alignment issues
2788 # don't pose a problem we want to suppress warnings about them.
2789 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2790 # GCCs do not support that.
2792 # Only checked for if --enable-ubsan was given.
2793 if test "x${vg_cv_ubsan}" = "xyes"; then
2794 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2795 safe_CFLAGS=$CFLAGS
2796 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2797 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2798   return 0;
2799 ]])], [
2800 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2801 LIB_UBSAN="-static-libubsan"
2802 AC_MSG_RESULT([yes])
2803 ], [
2804 CFLAGS="-fsanitize=undefined -Werror"
2805 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2806   return 0;
2807 ]])], [
2808 FLAG_FSANITIZE="-fsanitize=undefined"
2809 LIB_UBSAN="-static-libubsan"
2810 AC_MSG_RESULT([yes])
2811 ], [
2812 FLAG_FSANITIZE=""
2813 LIB_UBSAN=""
2814 AC_MSG_RESULT([no])
2817 CFLAGS=$safe_CFLAGS
2818 AC_SUBST(FLAG_FSANITIZE)
2819 AC_SUBST(LIB_UBSAN)
2821 # does this compiler support --param inline-unit-growth=... ?
2823 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2825 safe_CFLAGS=$CFLAGS
2826 CFLAGS="--param inline-unit-growth=900 -Werror"
2828 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2829   return 0;
2830 ]])], [
2831 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2832          ["--param inline-unit-growth=900"])
2833 AC_MSG_RESULT([yes])
2834 ], [
2835 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2836 AC_MSG_RESULT([no])
2838 CFLAGS=$safe_CFLAGS
2841 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2843 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2845 safe_CFLAGS=$CFLAGS
2846 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2848 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2849   return 0;
2850 ]])], [
2851 ac_have_dwarf4=yes
2852 AC_MSG_RESULT([yes])
2853 ], [
2854 ac_have_dwarf4=no
2855 AC_MSG_RESULT([no])
2857 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2858 CFLAGS=$safe_CFLAGS
2861 # does this compiler support -g -gz=zlib ?
2863 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2865 safe_CFLAGS=$CFLAGS
2866 CFLAGS="-g -gz=zlib"
2868 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2869   return 0;
2870 ]])], [
2871 ac_have_gz_zlib=yes
2872 AC_MSG_RESULT([yes])
2873 ], [
2874 ac_have_gz_zlib=no
2875 AC_MSG_RESULT([no])
2877 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2878 CFLAGS=$safe_CFLAGS
2881 # does this compiler support -g -gz=zlib-gnu ?
2883 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2885 safe_CFLAGS=$CFLAGS
2886 CFLAGS="-g -gz=zlib-gnu"
2888 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2889   return 0;
2890 ]])], [
2891 ac_have_gz_zlib_gnu=yes
2892 AC_MSG_RESULT([yes])
2893 ], [
2894 ac_have_gz_zlib_gnu=no
2895 AC_MSG_RESULT([no])
2897 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2898 CFLAGS=$safe_CFLAGS
2901 # does this compiler support nested functions ?
2903 AC_MSG_CHECKING([if gcc accepts nested functions])
2905 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2906   int foo() { return 1; }
2907   return foo();
2908 ]])], [
2909 ac_have_nested_functions=yes
2910 AC_MSG_RESULT([yes])
2911 ], [
2912 ac_have_nested_functions=no
2913 AC_MSG_RESULT([no])
2915 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2918 # does this compiler support the 'p' constraint in ASM statements ?
2920 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2922 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2923    char *p;
2924    __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2925 ]])], [
2926 ac_have_asm_constraint_p=yes
2927 AC_MSG_RESULT([yes])
2928 ], [
2929 ac_have_asm_constraint_p=no
2930 AC_MSG_RESULT([no])
2932 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2935 # Does this compiler and linker support -pie?
2936 # Some compilers actually do not support -pie and report its usage
2937 # as an error. We need to check if it is safe to use it first.
2939 AC_MSG_CHECKING([if gcc accepts -pie])
2941 safe_CFLAGS=$CFLAGS
2942 CFLAGS="-pie"
2944 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2945   return 0;
2946 ]])], [
2947 AC_SUBST([FLAG_PIE], ["-pie"])
2948 AC_MSG_RESULT([yes])
2949 ], [
2950 AC_SUBST([FLAG_PIE], [""])
2951 AC_MSG_RESULT([no])
2953 CFLAGS=$safe_CFLAGS
2955 AC_MSG_CHECKING([if gcc accepts -ansi])
2957 safe_CFLAGS=$CFLAGS
2958 CFLAGS="-ansi"
2960 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2961    return 0;
2962 ]])], [
2963 ac_have_ansi=yes
2964 AC_MSG_RESULT([yes])
2965 ], [
2966 ac_have_ansi=no
2967 AC_MSG_RESULT([no])
2969 AM_CONDITIONAL([HAVE_ANSI], [test x$ac_have_ansi = xyes])
2971 CFLAGS=$safe_CFLAGS
2974 # Does this compiler support -no-pie?
2975 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2976 # default. However this gets in the way with some tests, we use -no-pie
2977 # for these.
2979 AC_MSG_CHECKING([if gcc accepts -no-pie])
2981 safe_CFLAGS=$CFLAGS
2982 CFLAGS="-no-pie -Werror"
2984 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2985   return 0;
2986 ]])], [
2987 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2988 AC_MSG_RESULT([yes])
2989 ], [
2990 AC_SUBST([FLAG_NO_PIE], [""])
2991 AC_MSG_RESULT([no])
2993 CFLAGS=$safe_CFLAGS
2996 # We want to use use the -Ttext-segment option to the linker.
2997 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2998 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2999 # semantics are NOT what we want (GNU gold -Ttext is fine).
3001 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
3002 # will reside. -Ttext aligns just the .text section start (but not any
3003 # other section).
3005 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
3006 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
3007 # The --image-base option (since version 6.0?) provides the semantics needed.
3008 # -Ttext-segment generates an error, but -Ttext now more closely
3009 # follows the GNU (bfd) ld's -Ttext.
3011 # So test first for --image-base support, and if that fails then
3012 # for -Ttext-segment which is supported by all bfd ld versions
3013 # and use that if it exists. If it doesn't exist it must be an older
3014 # version of gold and we can fall back to using -Ttext which has the
3015 # right semantics.
3017 safe_CFLAGS=$CFLAGS
3018 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
3020 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
3022 AC_LINK_IFELSE(
3023 [AC_LANG_SOURCE([int _start () { return 0; }])],
3025   linker_using_t_text="no"
3026   AC_SUBST([FLAG_T_TEXT], ["--image-base"])
3027   AC_MSG_RESULT([yes])
3028 ], [
3029   AC_MSG_RESULT([no])
3031   AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
3033   CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
3035   AC_LINK_IFELSE(
3036   [AC_LANG_SOURCE([int _start () { return 0; }])],
3037   [
3038     linker_using_t_text="no"
3039     AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
3040     AC_MSG_RESULT([yes])
3041   ], [
3042     linker_using_t_text="yes"
3043     AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
3044     AC_MSG_RESULT([no])
3045   ])
3048 CFLAGS=$safe_CFLAGS
3050 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
3051 # have to strip any build-id ELF NOTEs from the statically linked tools.
3052 # Otherwise the build-id NOTE might end up at the default load address.
3053 # (Pedantically if the linker is gold then -Ttext is fine, but newer
3054 # gold versions also support -Ttext-segment. So just assume that unless
3055 # we can use -Ttext-segment we need to strip the build-id NOTEs.
3056 if test "x${linker_using_t_text}" = "xyes"; then
3057 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
3058 # does the linker support -Wl,--build-id=none ?  Note, it's
3059 # important that we test indirectly via whichever C compiler
3060 # is selected, rather than testing /usr/bin/ld or whatever
3061 # directly.
3062 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
3063 safe_CFLAGS=$CFLAGS
3064 CFLAGS="-Wl,--build-id=none -Werror"
3066 AC_LINK_IFELSE(
3067 [AC_LANG_PROGRAM([ ], [return 0;])],
3069   AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
3070   AC_MSG_RESULT([yes])
3071 ], [
3072   AC_SUBST([FLAG_NO_BUILD_ID], [""])
3073   AC_MSG_RESULT([no])
3075 else
3076 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
3077 AC_SUBST([FLAG_NO_BUILD_ID], [""])
3079 CFLAGS=$safe_CFLAGS
3081 # does the ppc assembler support "mtocrf" et al?
3082 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
3084 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3085 __asm__ __volatile__("mtocrf 4,0");
3086 __asm__ __volatile__("mfocrf 0,4");
3087 ]])], [
3088 ac_have_as_ppc_mftocrf=yes
3089 AC_MSG_RESULT([yes])
3090 ], [
3091 ac_have_as_ppc_mftocrf=no
3092 AC_MSG_RESULT([no])
3094 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3095   AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3099 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3100 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3102 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3103   do { typedef struct {
3104       double hi;
3105       double lo;
3106      } dbl_pair_t;
3107      dbl_pair_t dbl_pair[3];
3108      __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3109    } while (0)
3110 ]])], [
3111 ac_have_as_ppc_fpPO=yes
3112 AC_MSG_RESULT([yes])
3113 ], [
3114 ac_have_as_ppc_fpPO=no
3115 AC_MSG_RESULT([no])
3117 if test x$ac_have_as_ppc_fpPO = xyes ; then
3118   AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3122 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3123 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3125 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3126 void* p;
3127 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3128 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3129 ]])], [
3130 ac_have_as_amd64_fxsave64=yes
3131 AC_MSG_RESULT([yes])
3132 ], [
3133 ac_have_as_amd64_fxsave64=no
3134 AC_MSG_RESULT([no])
3136 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3137   AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3140 # does the x86/amd64 assembler understand SSE3 instructions?
3141 # Note, this doesn't generate a C-level symbol.  It generates a
3142 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3143 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3145 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3146   do { long long int x; 
3147      __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 
3148   while (0)
3149 ]])], [
3150 ac_have_as_sse3=yes
3151 AC_MSG_RESULT([yes])
3152 ], [
3153 ac_have_as_sse3=no
3154 AC_MSG_RESULT([no])
3157 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3160 # Ditto for SSSE3 instructions (note extra S)
3161 # Note, this doesn't generate a C-level symbol.  It generates a
3162 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3163 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3165 save_CFLAGS="$CFLAGS"
3166 CFLAGS="$CFLAGS -msse -Werror"
3167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3168   do { long long int x; 
3169    __asm__ __volatile__(
3170       "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3171   while (0)
3172 ]])], [
3173 ac_have_as_ssse3=yes
3174 AC_MSG_RESULT([yes])
3175 ], [
3176 ac_have_as_ssse3=no
3177 AC_MSG_RESULT([no])
3179 CFLAGS="$save_CFLAGS"
3181 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3184 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3185 # Note, this doesn't generate a C-level symbol.  It generates a
3186 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3187 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3189   do {
3190    __asm__ __volatile__(
3191       "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3192   while (0)
3193 ]])], [
3194 ac_have_as_pclmulqdq=yes
3195 AC_MSG_RESULT([yes])
3196 ], [
3197 ac_have_as_pclmulqdq=no
3198 AC_MSG_RESULT([no])
3201 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3204 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3205 # Note, this doesn't generate a C-level symbol.  It generates a
3206 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3207 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3208 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3209   do {
3210       /*
3211        * Carry-less multiplication of xmm1 with xmm2 and store the result in
3212        * xmm3. The immediate is used to determine which quadwords of xmm1 and
3213        * xmm2 should be used.
3214        */
3215    __asm__ __volatile__(
3216       "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3217   } while (0)
3218 ]])], [
3219 ac_have_as_vpclmulqdq=yes
3220 AC_MSG_RESULT([yes])
3221 ], [
3222 ac_have_as_vpclmulqdq=no
3223 AC_MSG_RESULT([no])
3226 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3229 # does the x86/amd64 assembler understand FMA4 instructions?
3230 # Note, this doesn't generate a C-level symbol.  It generates a
3231 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3232 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3233 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3234   do {
3235    __asm__ __volatile__(
3236       "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3237   } while (0)
3238 ]])], [
3239 ac_have_as_vfmaddpd=yes
3240 AC_MSG_RESULT([yes])
3241 ], [
3242 ac_have_as_vfmaddpd=no
3243 AC_MSG_RESULT([no])
3246 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3249 # does the x86/amd64 assembler understand the LZCNT instruction?
3250 # Note, this doesn't generate a C-level symbol.  It generates a
3251 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3252 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3254 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3255   do {           
3256       __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3257   } while (0)
3258 ]])], [
3259   ac_have_as_lzcnt=yes
3260   AC_MSG_RESULT([yes])
3261 ], [
3262   ac_have_as_lzcnt=no
3263   AC_MSG_RESULT([no])
3266 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3269 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3270 # Note, this doesn't generate a C-level symbol.  It generates a
3271 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3272 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3274 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3275   do {           
3276       __asm__ __volatile__("1:  loopnel 1b\n");
3277   } while (0)
3278 ]])], [
3279   ac_have_as_loopnel=yes
3280   AC_MSG_RESULT([yes])
3281 ], [
3282   ac_have_as_loopnel=no
3283   AC_MSG_RESULT([no])
3286 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3289 # does the x86/amd64 assembler understand ADDR32 ?
3290 # Note, this doesn't generate a C-level symbol.  It generates a
3291 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3292 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3294 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3295   do {           
3296       asm volatile ("addr32 rep movsb");
3297   } while (0)
3298 ]])], [
3299   ac_have_as_addr32=yes
3300   AC_MSG_RESULT([yes])
3301 ], [
3302   ac_have_as_addr32=no
3303   AC_MSG_RESULT([no])
3306 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3309 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3310 # Note, this doesn't generate a C-level symbol.  It generates a
3311 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3312 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3314 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3315   do { long long int x; 
3316    __asm__ __volatile__(
3317       "crc32q %%r15,%%r15" : : : "r15" );
3318    __asm__ __volatile__(
3319       "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
3320    __asm__ __volatile__(
3321       "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3322   while (0)
3323 ]])], [
3324 ac_have_as_sse42=yes
3325 AC_MSG_RESULT([yes])
3326 ], [
3327 ac_have_as_sse42=no
3328 AC_MSG_RESULT([no])
3331 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3334 # does the x86/amd64 assembler understand AVX instructions?
3335 # Note, this doesn't generate a C-level symbol.  It generates a
3336 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3337 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3339 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3340   do { long long int x; 
3341    __asm__ __volatile__(
3342       "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3343    __asm__ __volatile__(
3344       "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3345   while (0)
3346 ]])], [
3347 ac_have_as_avx=yes
3348 AC_MSG_RESULT([yes])
3349 ], [
3350 ac_have_as_avx=no
3351 AC_MSG_RESULT([no])
3354 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3357 # does the x86/amd64 assembler understand AVX2 instructions?
3358 # Note, this doesn't generate a C-level symbol.  It generates a
3359 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3360 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3363   do { long long int x; 
3364    __asm__ __volatile__(
3365       "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3366    __asm__ __volatile__(
3367       "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3368   while (0)
3369 ]])], [
3370 ac_have_as_avx2=yes
3371 AC_MSG_RESULT([yes])
3372 ], [
3373 ac_have_as_avx2=no
3374 AC_MSG_RESULT([no])
3377 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3380 # does the x86/amd64 assembler understand TSX instructions and
3381 # the XACQUIRE/XRELEASE prefixes?
3382 # Note, this doesn't generate a C-level symbol.  It generates a
3383 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3384 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3386 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3387   do {
3388    __asm__ __volatile__(
3389       "       xbegin Lfoo  \n\t"
3390       "Lfoo:  xend         \n\t"
3391       "       xacquire lock incq 0(%rsp)     \n\t"
3392       "       xrelease lock incq 0(%rsp)     \n"
3393    );
3394   } while (0)
3395 ]])], [
3396 ac_have_as_tsx=yes
3397 AC_MSG_RESULT([yes])
3398 ], [
3399 ac_have_as_tsx=no
3400 AC_MSG_RESULT([no])
3403 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3406 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3407 # Note, this doesn't generate a C-level symbol.  It generates a
3408 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3409 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3411 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3412   do { unsigned int h, l;
3413    __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3414    __asm__ __volatile__(
3415       "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3416    __asm__ __volatile__(
3417       "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3418   while (0)
3419 ]])], [
3420 ac_have_as_bmi=yes
3421 AC_MSG_RESULT([yes])
3422 ], [
3423 ac_have_as_bmi=no
3424 AC_MSG_RESULT([no])
3427 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3430 # does the x86/amd64 assembler understand FMA instructions?
3431 # Note, this doesn't generate a C-level symbol.  It generates a
3432 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3433 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3435 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3436   do { unsigned int h, l;
3437    __asm__ __volatile__(
3438       "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3439    __asm__ __volatile__(
3440       "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3441    __asm__ __volatile__(
3442       "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3443   while (0)
3444 ]])], [
3445 ac_have_as_fma=yes
3446 AC_MSG_RESULT([yes])
3447 ], [
3448 ac_have_as_fma=no
3449 AC_MSG_RESULT([no])
3452 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3455 # does the amd64 assembler understand MPX instructions?
3456 # Note, this doesn't generate a C-level symbol.  It generates a
3457 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3458 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3460 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3461   do {
3462     asm ("bndmov %bnd0,(%rsp)");
3463     asm ("bndldx 3(%rbx,%rdx), %bnd2");
3464     asm ("bnd call foo\n"
3465          "bnd jmp  end\n"
3466          "foo: bnd ret\n"
3467          "end: nop");
3468   } while (0)
3469 ]])], [
3470 ac_have_as_mpx=yes
3471 AC_MSG_RESULT([yes])
3472 ], [
3473 ac_have_as_mpx=no
3474 AC_MSG_RESULT([no])
3477 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3480 # does the amd64 assembler understand ADX instructions?
3481 # Note, this doesn't generate a C-level symbol.  It generates a
3482 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3483 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3485 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3486   do {
3487     asm ("adcxq %r14,%r8");
3488   } while (0)
3489 ]])], [
3490 ac_have_as_adx=yes
3491 AC_MSG_RESULT([yes])
3492 ], [
3493 ac_have_as_adx=no
3494 AC_MSG_RESULT([no])
3497 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3500 # does the amd64 assembler understand the RDRAND instruction?
3501 # Note, this doesn't generate a C-level symbol.  It generates a
3502 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3503 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3505 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3506   do {
3507     asm ("rdrand %r14");
3508     asm ("rdrand %r14d");
3509     asm ("rdrand %r14w");
3510   } while (0)
3511 ]])], [
3512 ac_have_as_rdrand=yes
3513 AC_MSG_RESULT([yes])
3514 ], [
3515 ac_have_as_rdrand=no
3516 AC_MSG_RESULT([no])
3519 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3521 # does the amd64 assembler understand the RDSEED instruction?
3522 # Note, this doesn't generate a C-level symbol.  It generates a
3523 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3524 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3527   do {
3528     asm ("rdseed %r14");
3529     asm ("rdseed %r14d");
3530     asm ("rdseed %r14w");
3531   } while (0)
3532 ]])], [
3533 ac_have_as_rdseed=yes
3534 AC_MSG_RESULT([yes])
3535 ], [
3536 ac_have_as_rdseed=no
3537 AC_MSG_RESULT([no])
3540 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3542 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3543 # VCVTPS2PH) ?
3544 # Note, this doesn't generate a C-level symbol.  It generates a
3545 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3546 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3548 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3549   do {
3550     asm ("vcvtph2ps %xmm5, %ymm10");
3551     // If we put the dollar sign and zero together, the shell processing
3552     // this configure.ac script substitutes the command name in.  Sigh.
3553     asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3554   } while (0)
3555 ]])], [
3556 ac_have_as_f16c=yes
3557 AC_MSG_RESULT([yes])
3558 ], [
3559 ac_have_as_f16c=no
3560 AC_MSG_RESULT([no])
3563 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3566 # does the x86/amd64 assembler understand MOVBE?
3567 # Note, this doesn't generate a C-level symbol.  It generates a
3568 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3569 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3571 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3572   do { long long int x; 
3573    __asm__ __volatile__(
3574       "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3575   while (0)
3576 ]])], [
3577 ac_have_as_movbe=yes
3578 AC_MSG_RESULT([yes])
3579 ], [
3580 ac_have_as_movbe=no
3581 AC_MSG_RESULT([no])
3584 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3587 # Does the C compiler support the "ifunc" attribute
3588 # Note, this doesn't generate a C-level symbol.  It generates a
3589 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3590 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3592 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3593 static void mytest(void) {}
3595 static void (*resolve_test(void))(void)
3597     return (void (*)(void))&mytest;
3600 void test(void) __attribute__((ifunc("resolve_test")));
3602 int main()
3604     test();
3605     return 0;
3607 ]])], [
3608 ac_have_ifunc_attr=yes
3609 AC_MSG_RESULT([yes])
3610 ], [
3611 ac_have_ifunc_attr=no
3612 AC_MSG_RESULT([no])
3615 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3617 # Does the C compiler support the armv8 crc feature flag
3618 # Note, this doesn't generate a C-level symbol.  It generates a
3619 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3620 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3622 save_CFLAGS="$CFLAGS"
3623 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3624 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3625 int main()
3627     return 0;
3629 ]])], [
3630 ac_have_armv8_crc_feature=yes
3631 AC_MSG_RESULT([yes])
3632 ], [
3633 ac_have_armv8_crc_feature=no
3634 AC_MSG_RESULT([no])
3636 CFLAGS="$save_CFLAGS"
3638 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3641 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3642 # Note, this doesn't generate a C-level symbol.  It generates a
3643 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3644 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3646 save_CFLAGS="$CFLAGS"
3647 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3648 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3649 int main()
3651     __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3652     return 0;
3654 ]])], [
3655 ac_have_armv81_feature=yes
3656 AC_MSG_RESULT([yes])
3657 ], [
3658 ac_have_armv81_feature=no
3659 AC_MSG_RESULT([no])
3661 CFLAGS="$save_CFLAGS"
3663 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3666 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3667 # Note, this doesn't generate a C-level symbol.  It generates a
3668 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3669 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3671 save_CFLAGS="$CFLAGS"
3672 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3673 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3674 int main()
3676     __asm__ __volatile__("faddp h0, v1.2h");
3677     return 0;
3679 ]])], [
3680 ac_have_armv82_feature=yes
3681 AC_MSG_RESULT([yes])
3682 ], [
3683 ac_have_armv82_feature=no
3684 AC_MSG_RESULT([no])
3686 CFLAGS="$save_CFLAGS"
3688 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3691 # XXX JRS 2010 Oct 13: what is this for?  For sure, we don't need this
3692 # when building the tool executables.  I think we should get rid of it.
3694 # Check for TLS support in the compiler and linker
3695 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3696                                 [[return foo;]])],
3697                                [vg_cv_linktime_tls=yes],
3698                                [vg_cv_linktime_tls=no])
3699 # Native compilation: check whether running a program using TLS succeeds.
3700 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3701 # succeeds but running programs using TLS fails.
3702 # Cross-compiling: check whether linking a program using TLS succeeds.
3703 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3704                [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
3705                 [vg_cv_tls=$enableval],
3706                 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3707                                                 [[return foo;]])],
3708                                [vg_cv_tls=yes],
3709                                [vg_cv_tls=no],
3710                                [vg_cv_tls=$vg_cv_linktime_tls])])])
3712 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3713 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3717 #----------------------------------------------------------------------------
3718 # Solaris-specific checks.
3719 #----------------------------------------------------------------------------
3721 if test "$VGCONF_OS" = "solaris" ; then
3722 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3724 # Solaris-specific check determining if the Sun Studio Assembler is used to
3725 # build Valgrind.  The test checks if the x86/amd64 assembler understands the
3726 # cmovl.l instruction, if yes then it's Sun Assembler.
3728 # C-level symbol: none
3729 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3731 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3732 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3733 ]], [[
3734   __asm__ __volatile__("cmovl.l %edx, %eax");
3735 ]])], [
3736 solaris_have_sun_studio_as=yes
3737 AC_MSG_RESULT([yes])
3738 ], [
3739 solaris_have_sun_studio_as=no
3740 AC_MSG_RESULT([no])
3742 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3744 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3745 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3746 # See solaris/vgpreload-solaris.mapfile for details.
3747 # gcc on older Solaris instructs linker to include these symbols,
3748 # gcc on illumos and newer Solaris does not.
3750 # C-level symbol: none
3751 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3753 save_CFLAGS="$CFLAGS"
3754 CFLAGS="$CFLAGS -std=gnu99"
3755 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3756 temp_dir=$( /usr/bin/mktemp -d )
3757 cat <<_ACEOF >${temp_dir}/mylib.c
3758 #include <stdio.h>
3759 int myfunc(void) { printf("LaPutyka\n"); }
3760 _ACEOF
3761 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3762 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3763 if test "x${xpg_present}" = "x" ; then
3764     solaris_xpg_symbols_present=no
3765     AC_MSG_RESULT([no])
3766 else
3767     solaris_xpg_symbols_present=yes
3768     AC_MSG_RESULT([yes])
3770 rm -rf ${temp_dir}
3771 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3772 CFLAGS="$save_CFLAGS"
3775 # Solaris-specific check determining if gcc enables largefile support by
3776 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3777 # variable with gcc flags which disable it.
3779 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3780 save_CFLAGS="$CFLAGS"
3781 CFLAGS="$CFLAGS -m32"
3782 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3783   return _LARGEFILE_SOURCE;
3784 ]])], [
3785 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3786 AC_MSG_RESULT([yes])
3787 ], [
3788 SOLARIS_UNDEF_LARGESOURCE=""
3789 AC_MSG_RESULT([no])
3791 CFLAGS=$safe_CFLAGS
3792 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3795 # Solaris-specific check determining if /proc/self/cmdline
3796 # or /proc/<pid>/cmdline is supported.
3798 # C-level symbol: SOLARIS_PROC_CMDLINE
3799 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3801 AC_CHECK_FILE([/proc/self/cmdline],
3803 solaris_proc_cmdline=yes
3804 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3805           [Define to 1 if you have /proc/self/cmdline.])
3806 ], [
3807 solaris_proc_cmdline=no
3809 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3812 # Solaris-specific check determining default platform for the Valgrind launcher.
3813 # Used in case the launcher cannot select platform by looking at the client
3814 # image (for example because the executable is a shell script).
3816 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3817 # Automake-level symbol: none
3819 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3820 # Get the ELF class of /bin/sh first.
3821 if ! test -f /bin/sh; then
3822   AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3824 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3825 case "$elf_class" in
3826   64)
3827     default_arch="$VGCONF_ARCH_PRI";
3828     ;;
3829   32)
3830     if test "x$VGCONF_ARCH_SEC" != "x"; then
3831       default_arch="$VGCONF_ARCH_SEC"
3832     else
3833       default_arch="$VGCONF_ARCH_PRI";
3834     fi
3835     ;;
3836   *)
3837     AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3838     ;;
3839 esac
3840 default_platform="$default_arch-$VGCONF_OS"
3841 AC_MSG_RESULT([$default_platform])
3842 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3843                    [Default platform for Valgrind launcher.])
3846 # Solaris-specific check determining if the old syscalls are available.
3848 # C-level symbol: SOLARIS_OLD_SYSCALLS
3849 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3851 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3852 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3853 #include <sys/syscall.h>
3854 ]], [[
3855   return !SYS_open;
3856 ]])], [
3857 solaris_old_syscalls=yes
3858 AC_MSG_RESULT([yes])
3859 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3860           [Define to 1 if you have the old Solaris syscalls.])
3861 ], [
3862 solaris_old_syscalls=no
3863 AC_MSG_RESULT([no])
3865 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3868 # Solaris-specific check determining if the new accept() syscall is available.
3870 # Old syscall:
3871 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3872 #            int version);
3874 # New syscall (available on illumos):
3875 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3876 #            int version, int flags);
3878 # If the old syscall is present then the following syscall will fail with
3879 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3880 # available then it will fail with EINVAL (because the flags parameter is
3881 # invalid).
3883 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3884 # Automake-level symbol: none
3886 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3887 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3888 #include <sys/syscall.h>
3889 #include <errno.h>
3890 ]], [[
3891   errno = 0;
3892   syscall(SYS_accept, 0, 0, 0, 0, -1);
3893   return !(errno == EINVAL);
3894 ]])], [
3895 AC_MSG_RESULT([yes])
3896 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3897           [Define to 1 if you have the new `accept' syscall.])
3898 ], [
3899 AC_MSG_RESULT([no])
3903 # Solaris-specific check determining if the new illumos pipe() syscall is
3904 # available.
3906 # Old syscall:
3907 # longlong_t pipe();
3909 # New syscall (available on illumos):
3910 # int pipe(intptr_t arg, int flags);
3912 # If the old syscall is present then the following call will succeed, if the
3913 # new syscall is available then it will fail with EFAULT (because address 0
3914 # cannot be accessed).
3916 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3917 # Automake-level symbol: none
3919 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3920 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3921 #include <sys/syscall.h>
3922 #include <errno.h>
3923 ]], [[
3924   errno = 0;
3925   syscall(SYS_pipe, 0, 0);
3926   return !(errno == EFAULT);
3927 ]])], [
3928 AC_MSG_RESULT([yes])
3929 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3930           [Define to 1 if you have the new `pipe' syscall.])
3931 ], [
3932 AC_MSG_RESULT([no])
3936 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3937 # available.
3939 # Old syscall:
3940 # int lwp_kill(id_t lwpid, int sig);
3942 # New syscall (available on Solaris 11):
3943 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3944 #                  int si_code, timespec_t *timeout);
3946 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3947 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3949 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3950 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3951 #include <sys/syscall.h> 
3952 ]], [[
3953   return !SYS_lwp_sigqueue;
3954 ]])], [
3955 solaris_lwp_sigqueue_syscall=yes
3956 AC_MSG_RESULT([yes])
3957 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3958           [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3959 ], [
3960 solaris_lwp_sigqueue_syscall=no
3961 AC_MSG_RESULT([no])
3963 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3966 # Solaris-specific check determining if the lwp_sigqueue() syscall
3967 # takes both pid and thread id arguments or just thread id.
3969 # Old syscall (available up to Solaris 11.3):
3970 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3971 #                  int si_code, timespec_t *timeout);
3973 # New syscall (available since Solaris 11.4):
3974 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3975 #                  int si_code, timespec_t *timeout);
3977 # If the old syscall is present then the following syscall will fail with
3978 # EINVAL (because signal is out of range); if the new syscall is available
3979 # then it will fail with ESRCH (because it would not find such thread in the
3980 # current process).
3982 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3983 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3985 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3986 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3987 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3988 #include <sys/syscall.h>
3989 #include <errno.h>
3990 ]], [[
3991   errno = 0;
3992   syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3993   return !(errno == ESRCH);
3994 ]])], [
3995 solaris_lwp_sigqueue_syscall_takes_pid=yes
3996 AC_MSG_RESULT([yes])
3997 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3998           [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3999 ], [
4000 solaris_lwp_sigqueue_syscall_takes_pid=no
4001 AC_MSG_RESULT([no])
4003 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
4004                test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
4006 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
4010 # Solaris-specific check determining if the new lwp_name() syscall is
4011 # available.
4013 # New syscall (available on Solaris 11):
4014 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
4016 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
4017 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
4019 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
4020 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4021 #include <sys/syscall.h>
4022 ]], [[
4023   return !SYS_lwp_name;
4024 ]])], [
4025 solaris_lwp_name_syscall=yes
4026 AC_MSG_RESULT([yes])
4027 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
4028           [Define to 1 if you have the new `lwp_name' syscall.])
4029 ], [
4030 solaris_lwp_name_syscall=no
4031 AC_MSG_RESULT([no])
4033 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
4036 # Solaris-specific check determining if the new getrandom() syscall is
4037 # available.
4039 # New syscall (available on Solaris 11):
4040 # int getrandom(void *buf, size_t buflen, uint_t flags);
4042 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
4043 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
4045 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
4046 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4047 #include <sys/syscall.h>
4048 ]], [[
4049   return !SYS_getrandom;
4050 ]])], [
4051 solaris_getrandom_syscall=yes
4052 AC_MSG_RESULT([yes])
4053 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
4054           [Define to 1 if you have the new `getrandom' syscall.])
4055 ], [
4056 solaris_getrandom_syscall=no
4057 AC_MSG_RESULT([no])
4059 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
4062 # Solaris-specific check determining if the new zone() syscall subcodes
4063 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available.  These subcodes
4064 # were added in Solaris 11 but are missing on illumos.
4066 # C-level symbol: SOLARIS_ZONE_DEFUNCT
4067 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
4069 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
4070 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4071 #include <sys/zone.h>
4072 ]], [[
4073   return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
4074 ]])], [
4075 solaris_zone_defunct=yes
4076 AC_MSG_RESULT([yes])
4077 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
4078           [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
4079 ], [
4080 solaris_zone_defunct=no
4081 AC_MSG_RESULT([no])
4083 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
4086 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4087 # for auditon(2) subcode of the auditsys() syscall are available.
4088 # These commands are available in Solaris 11 and illumos but were removed
4089 # in Solaris 11.4.
4091 # C-level symbol: SOLARIS_AUDITON_STAT
4092 # Automake-level symbol: SOLARIS_AUDITON_STAT
4094 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4095 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4096 #include <bsm/audit.h>
4097 ]], [[
4098   return !(A_GETSTAT && A_SETSTAT);
4099 ]])], [
4100 solaris_auditon_stat=yes
4101 AC_MSG_RESULT([yes])
4102 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4103           [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4104 ], [
4105 solaris_auditon_stat=no
4106 AC_MSG_RESULT([no])
4108 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4111 # Solaris-specific check determining if the new shmsys() syscall subcodes
4112 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4113 # These subcodes were added in Solaris 11 but are missing on illumos.
4115 # C-level symbol: SOLARIS_SHM_NEW
4116 # Automake-level symbol: SOLARIS_SHM_NEW
4118 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4119 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4120 #include <sys/ipc_impl.h>
4121 #include <sys/shm.h>
4122 #include <sys/shm_impl.h>
4123 ]], [[
4124   return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4125 ]])], [
4126 solaris_shm_new=yes
4127 AC_MSG_RESULT([yes])
4128 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4129           [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4130 ], [
4131 solaris_shm_new=no
4132 AC_MSG_RESULT([no])
4134 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4137 # Solaris-specific check determining if prxregset_t is available.  Illumos
4138 # currently does not define it on the x86 platform.
4140 # C-level symbol: SOLARIS_PRXREGSET_T
4141 # Automake-level symbol: SOLARIS_PRXREGSET_T
4143 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4144 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4145 #include <sys/procfs_isa.h>
4146 ]], [[
4147   return !sizeof(prxregset_t);
4148 ]])], [
4149 solaris_prxregset_t=yes
4150 AC_MSG_RESULT([yes])
4151 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4152           [Define to 1 if you have the `prxregset_t' type.])
4153 ], [
4154 solaris_prxregset_t=no
4155 AC_MSG_RESULT([no])
4157 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4160 # Solaris-specific check determining if the new frealpathat() syscall is
4161 # available.
4163 # New syscall (available on Solaris 11.1):
4164 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4166 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4167 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4169 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4170 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4171 #include <sys/syscall.h>
4172 ]], [[
4173   return !SYS_frealpathat;
4174 ]])], [
4175 solaris_frealpathat_syscall=yes
4176 AC_MSG_RESULT([yes])
4177 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4178           [Define to 1 if you have the new `frealpathat' syscall.])
4179 ], [
4180 solaris_frealpathat_syscall=no
4181 AC_MSG_RESULT([no])
4183 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4186 # Solaris-specific check determining if the new uuidsys() syscall is
4187 # available.
4189 # New syscall (available on newer Solaris):
4190 # int uuidsys(struct uuid *uuid);
4192 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4193 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4195 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4196 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4197 #include <sys/syscall.h>
4198 ]], [[
4199   return !SYS_uuidsys;
4200 ]])], [
4201 solaris_uuidsys_syscall=yes
4202 AC_MSG_RESULT([yes])
4203 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4204           [Define to 1 if you have the new `uuidsys' syscall.])
4205 ], [
4206 solaris_uuidsys_syscall=no
4207 AC_MSG_RESULT([no])
4209 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4212 # Solaris-specific check determining if the new labelsys() syscall subcode
4213 # TNDB_GET_TNIP is available.  This subcode was added in Solaris 11 but is
4214 # missing on illumos.
4216 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4217 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4219 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4220 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4221 #include <sys/tsol/tndb.h>
4222 ]], [[
4223   return !TNDB_GET_TNIP;
4224 ]])], [
4225 solaris_tndb_get_tnip=yes
4226 AC_MSG_RESULT([yes])
4227 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4228           [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4229 ], [
4230 solaris_tndb_get_tnip=no
4231 AC_MSG_RESULT([no])
4233 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4236 # Solaris-specific check determining if the new labelsys() syscall opcodes
4237 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4238 # added in Solaris 11 but are missing on illumos.
4240 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4241 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4243 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4244 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4245 #include <sys/tsol/tsyscall.h>
4246 ]], [[
4247   return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4248 ]])], [
4249 solaris_tsol_clearance=yes
4250 AC_MSG_RESULT([yes])
4251 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4252           [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4253 ], [
4254 solaris_tsol_clearance=no
4255 AC_MSG_RESULT([no])
4257 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4260 # Solaris-specific check determining if the new pset() syscall subcode
4261 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4262 # is missing on illumos and Solaris 11.3.
4264 # C-level symbol: SOLARIS_PSET_GET_NAME
4265 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4267 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4268 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4269 #include <sys/pset.h>
4270 ]], [[
4271   return !(PSET_GET_NAME);
4272 ]])], [
4273 solaris_pset_get_name=yes
4274 AC_MSG_RESULT([yes])
4275 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4276           [Define to 1 if you have the `PSET_GET_NAME' constants.])
4277 ], [
4278 solaris_pset_get_name=no
4279 AC_MSG_RESULT([no])
4281 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4284 # Solaris-specific check determining if the utimesys() syscall is
4285 # available (on illumos and older Solaris).
4287 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4288 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4290 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4291 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4292 #include <sys/syscall.h>
4293 ]], [[
4294   return !SYS_utimesys;
4295 ]])], [
4296 solaris_utimesys_syscall=yes
4297 AC_MSG_RESULT([yes])
4298 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4299           [Define to 1 if you have the `utimesys' syscall.])
4300 ], [
4301 solaris_utimesys_syscall=no
4302 AC_MSG_RESULT([no])
4304 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4307 # Solaris-specific check determining if the utimensat() syscall is
4308 # available (on newer Solaris).
4310 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4311 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4313 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4314 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4315 #include <sys/syscall.h>
4316 ]], [[
4317   return !SYS_utimensat;
4318 ]])], [
4319 solaris_utimensat_syscall=yes
4320 AC_MSG_RESULT([yes])
4321 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4322           [Define to 1 if you have the `utimensat' syscall.])
4323 ], [
4324 solaris_utimensat_syscall=no
4325 AC_MSG_RESULT([no])
4327 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4330 # Solaris-specific check determining if the spawn() syscall is available
4331 # (on newer Solaris).
4333 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4334 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4336 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4337 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4338 #include <sys/syscall.h>
4339 ]], [[
4340   return !SYS_spawn;
4341 ]])], [
4342 solaris_spawn_syscall=yes
4343 AC_MSG_RESULT([yes])
4344 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4345           [Define to 1 if you have the `spawn' syscall.])
4346 ], [
4347 solaris_spawn_syscall=no
4348 AC_MSG_RESULT([no])
4350 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4353 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4354 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4356 # C-level symbol: SOLARIS_MODCTL_MODNVL
4357 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4359 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4360 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4361 #include <sys/modctl.h>
4362 ]], [[
4363   return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4364 ]])], [
4365 solaris_modctl_modnvl=yes
4366 AC_MSG_RESULT([yes])
4367 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4368           [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4369 ], [
4370 solaris_modctl_modnvl=no
4371 AC_MSG_RESULT([no])
4373 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4376 # Solaris-specific check determining whether nscd (name switch cache daemon)
4377 # attaches its door at /system/volatile/name_service_door (Solaris)
4378 # or at /var/run/name_service_door (illumos).
4380 # Note that /var/run is a symlink to /system/volatile on Solaris
4381 # but not vice versa on illumos.
4383 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4384 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4386 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4387 if test -e /system/volatile/name_service_door; then
4388     solaris_nscd_door_system_volatile=yes
4389     AC_MSG_RESULT([/system/volatile/name_service_door])
4390     AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4391               [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4392 else
4393     solaris_nscd_door_system_volatile=no
4394     AC_MSG_RESULT([/var/run/name_service_door])
4396 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4399 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4401 # New fasttrap (available on Solaris 11):
4402 # hrt_t *gethrt(void);
4404 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4405 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4407 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4408 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4409 #include <sys/trap.h>
4410 ]], [[
4411   return !T_GETHRT;
4412 ]])], [
4413 solaris_gethrt_fasttrap=yes
4414 AC_MSG_RESULT([yes])
4415 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4416           [Define to 1 if you have the new `gethrt' fasttrap.])
4417 ], [
4418 solaris_gethrt_fasttrap=no
4419 AC_MSG_RESULT([no])
4421 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4424 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4425 # is available.
4427 # New fasttrap (available on Solaris 11):
4428 # zonehrtoffset_t *get_zone_offset(void);
4430 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4431 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4433 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4434 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4435 #include <sys/trap.h>
4436 ]], [[
4437   return !T_GETZONEOFFSET;
4438 ]])], [
4439 solaris_getzoneoffset_fasttrap=yes
4440 AC_MSG_RESULT([yes])
4441 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4442           [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4443 ], [
4444 solaris_getzoneoffset_fasttrap=no
4445 AC_MSG_RESULT([no])
4447 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4450 # Solaris-specific check determining if the execve() syscall
4451 # takes fourth argument (flags) or not.
4453 # Old syscall (available on illumos):
4454 # int execve(const char *fname, const char **argv, const char **envp);
4456 # New syscall (available on Solaris):
4457 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4459 # If the new syscall is present then it will fail with EINVAL (because flags
4460 # are invalid); if the old syscall is available then it will fail with ENOENT
4461 # (because the file could not be found).
4463 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4464 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4466 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4467 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4468 #include <sys/syscall.h>
4469 #include <errno.h>
4470 ]], [[
4471   errno = 0;
4472   syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4473   return !(errno == EINVAL);
4474 ]])], [
4475 solaris_execve_syscall_takes_flags=yes
4476 AC_MSG_RESULT([yes])
4477 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4478           [Define to 1 if you have the new `execve' syscall which accepts flags.])
4479 ], [
4480 solaris_execve_syscall_takes_flags=no
4481 AC_MSG_RESULT([no])
4483 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4484                test x$solaris_execve_syscall_takes_flags = xyes)
4487 # Solaris-specific check determining version of the repository cache protocol.
4488 # Every Solaris version uses a different one, ranging from 21 to current 25.
4489 # The check is very ugly, though.
4491 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4492 # Automake-level symbol: none
4494 AC_PATH_PROG(DIS_PATH, dis, false)
4495 if test "x$DIS_PATH" = "xfalse"; then
4496   AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4498 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4499   AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4500   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4503 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4504 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4505   libscf=/usr/lib/64/libscf.so.1
4506 else
4507   libscf=/usr/lib/libscf.so.1
4509 if ! $DIS_PATH -F scf_handle_bind $libscf  | grep -q 0x526570; then
4510   AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4511   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4513 hex=$( $DIS_PATH -F scf_handle_bind $libscf  | sed -n 's/.*0x526570\(..\).*/\1/p' )
4514 if test -z "$hex"; then
4515   AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4516   AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4518 version=$( printf "%d\n" 0x$hex )
4519 AC_MSG_RESULT([$version])
4520 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4521                    [Version number of the repository door cache protocol.])
4524 # Solaris-specific check determining if "sysstat" segment reservation type
4525 # is available.
4527 # New "sysstat" segment reservation (available on Solaris 11.4):
4528 # - program header type:    PT_SUNW_SYSSTAT
4529 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4531 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4532 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4534 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4535 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4536 #include <sys/auxv.h>
4537 ]], [[
4538   return !AT_SUN_SYSSTAT_ADDR;
4539 ]])], [
4540 solaris_reserve_sysstat_addr=yes
4541 AC_MSG_RESULT([yes])
4542 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4543           [Define to 1 if you have the new `sysstat' segment reservation.])
4544 ], [
4545 solaris_reserve_sysstat_addr=no
4546 AC_MSG_RESULT([no])
4548 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4551 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4552 # is available.
4554 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4555 # - program header type:    PT_SUNW_SYSSTAT_ZONE
4556 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4558 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4559 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4561 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4563 #include <sys/auxv.h>
4564 ]], [[
4565   return !AT_SUN_SYSSTAT_ZONE_ADDR;
4566 ]])], [
4567 solaris_reserve_sysstat_zone_addr=yes
4568 AC_MSG_RESULT([yes])
4569 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4570           [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4571 ], [
4572 solaris_reserve_sysstat_zone_addr=no
4573 AC_MSG_RESULT([no])
4575 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4578 # Solaris-specific check determining if the system_stats() syscall is available
4579 # (on newer Solaris).
4581 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4582 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4584 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4586 #include <sys/syscall.h>
4587 ]], [[
4588   return !SYS_system_stats;
4589 ]])], [
4590 solaris_system_stats_syscall=yes
4591 AC_MSG_RESULT([yes])
4592 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4593           [Define to 1 if you have the `system_stats' syscall.])
4594 ], [
4595 solaris_system_stats_syscall=no
4596 AC_MSG_RESULT([no])
4598 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4601 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4602 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4604 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4605 # Automake-level symbol: none
4607 AC_CHECK_TYPE([struct _fpchip_state],
4608               [solaris_fpchip_state_takes_underscore=yes],
4609               [solaris_fpchip_state_takes_underscore=no],
4610               [[#include <sys/regset.h>]])
4611 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4612   AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4613             [Define to 1 if fpregset_t defines struct _fpchip_state])
4617 # Solaris-specific check determining if schedctl page shared between kernel
4618 # and userspace program is executable (illumos, older Solaris) or not (newer
4619 # Solaris).
4621 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4622 # Automake-level symbol: none
4624 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4625 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4626 #include <assert.h>
4627 #include <fcntl.h>
4628 #include <procfs.h>
4629 #include <schedctl.h>
4630 #include <stdio.h>
4631 #include <unistd.h>
4632 ]], [[
4633     schedctl_t *scp = schedctl_init();
4634     if (scp == NULL)
4635         return 1;
4637     int fd = open("/proc/self/map", O_RDONLY);
4638     assert(fd >= 0);
4640     prmap_t map;
4641     ssize_t rd;
4642     while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4643         if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4644             fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4645                     (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4646             return (map.pr_mflags & MA_EXEC);
4647         }
4648     }
4650     return 1;
4651 ]])], [
4652 solaris_schedctl_page_exec=no
4653 AC_MSG_RESULT([no])
4654 ], [
4655 solaris_schedctl_page_exec=yes
4656 AC_MSG_RESULT([yes])
4657 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4658           [Define to 1 if you have the schedctl page executable.])
4662 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4663 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4664 # an initial thread pointer for libc (newer Solaris).
4666 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4667 # Automake-level symbol: none
4669 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4670 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4671 #include <sys/fasttrap_isa.h>
4672 ]], [[
4673     return !FT_SCRATCHSIZE;
4674 ]])], [
4675 solaris_pt_sunwdtrace_thrp=yes
4676 AC_MSG_RESULT([yes])
4677 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4678           [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4679 ], [
4680 solaris_pt_sunwdtrace_thrp=no
4681 AC_MSG_RESULT([no])
4684 else
4685 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4686 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4687 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4688 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4689 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4690 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4691 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4692 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4693 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4694 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4695 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4696 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4697 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4698 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4699 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4700 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4701 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4702 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4703 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4704 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4705 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4706 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4707 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4708 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4709 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4710 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4711 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4712 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4713 fi # test "$VGCONF_OS" = "solaris"
4715 #----------------------------------------------------------------------------
4716 # FreeBSD-specific checks.
4717 #----------------------------------------------------------------------------
4719 # Rather than having a large number of feature test as above with Solaris
4720 # these tests are per-version. This may not be entirely relialable for
4721 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4722 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4724 if test "$VGCONF_OS" = "freebsd" ; then
4726 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4728 else
4730 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4732 fi # test "$VGCONF_OS" = "freebsd"
4735 #----------------------------------------------------------------------------
4736 # Checks for C header files.
4737 #----------------------------------------------------------------------------
4739 AC_CHECK_HEADERS([       \
4740         asm/unistd.h     \
4741         endian.h         \
4742         mqueue.h         \
4743         sys/endian.h     \
4744         sys/epoll.h      \
4745         sys/eventfd.h    \
4746         sys/klog.h       \
4747         sys/poll.h       \
4748         sys/prctl.h      \
4749         sys/signal.h     \
4750         sys/signalfd.h   \
4751         sys/syscall.h    \
4752         sys/sysnvl.h     \
4753         sys/time.h       \
4754         sys/types.h      \
4755         ])
4757 # Verify whether the <linux/futex.h> header is usable.
4758 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4760 save_CFLAGS="$CFLAGS"
4761 CFLAGS="$CFLAGS -D__user="
4762 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4763 #include <linux/futex.h>
4764 ]], [[
4765   return FUTEX_WAIT;
4766 ]])], [
4767 ac_have_usable_linux_futex_h=yes
4768 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4769           [Define to 1 if you have a usable <linux/futex.h> header file.])
4770 AC_MSG_RESULT([yes])
4771 ], [
4772 ac_have_usable_linux_futex_h=no
4773 AC_MSG_RESULT([no])
4775 CFLAGS="$save_CFLAGS"
4778 #----------------------------------------------------------------------------
4779 # Checks for typedefs, structures, and compiler characteristics.
4780 #----------------------------------------------------------------------------
4781 AC_TYPE_UID_T
4782 AC_TYPE_OFF_T
4783 AC_TYPE_SIZE_T
4784 AC_CHECK_HEADERS_ONCE([sys/time.h])
4786 AC_CHECK_TYPE([struct statx], [
4787   AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4788             [Define to 1 if <sys/stat.h> declares struct statx.])
4789 ], [], [
4790   #define _GNU_SOURCE
4791   #include <sys/stat.h>
4795 #----------------------------------------------------------------------------
4796 # Checks for library functions.
4797 #----------------------------------------------------------------------------
4798 AC_FUNC_MEMCMP
4799 AC_FUNC_MMAP
4801 AC_CHECK_LIB([pthread], [pthread_create])
4802 AC_CHECK_LIB([rt], [clock_gettime])
4804 AC_CHECK_FUNCS([     \
4805         clock_gettime\
4806         copy_file_range \
4807         epoll_create \
4808         epoll_pwait  \
4809         klogctl      \
4810         mallinfo     \
4811         memchr       \
4812         memfd_create \
4813         memset       \
4814         mkdir        \
4815         mremap       \
4816         ppoll        \
4817         preadv       \
4818         preadv2      \
4819         process_vm_readv  \
4820         process_vm_writev \
4821         pthread_barrier_init       \
4822         pthread_condattr_setclock  \
4823         pthread_mutex_timedlock    \
4824         pthread_rwlock_timedrdlock \
4825         pthread_rwlock_timedwrlock \
4826         pthread_setname_np         \
4827         pthread_spin_lock          \
4828         pthread_yield              \
4829         pwritev      \
4830         pwritev2     \
4831         rawmemchr    \
4832         readlinkat   \
4833         semtimedop   \
4834         setcontext   \
4835         signalfd     \
4836         sigwaitinfo  \
4837         strchr       \
4838         strdup       \
4839         strpbrk      \
4840         strrchr      \
4841         strstr       \
4842         swapcontext  \
4843         syscall      \
4844         utimensat    \
4845         mempcpy      \
4846         stpncpy      \
4847         strchrnul    \
4848         memrchr      \
4849         strndup      \
4850         ])
4852 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4853 # libraries with any shared object and/or executable. This is NOT what we
4854 # want for e.g. vgpreload_core-x86-linux.so
4855 LIBS=""
4857 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4858                [test x$ac_cv_func_pthread_barrier_init = xyes])
4859 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4860                [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4861 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4862                [test x$ac_cv_func_pthread_spin_lock = xyes])
4863 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4864                [test x$ac_cv_func_pthread_setname_np = xyes])
4865 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4866                [test x$ac_cv_func_copy_file_range = xyes])
4867 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4868                [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4869 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4870                [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4871 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4872 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4873 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4874                [test x$ac_cv_func_memfd_create = xyes])
4876 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4877      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4878      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4879   AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4880             [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4883 #----------------------------------------------------------------------------
4884 # MPI checks
4885 #----------------------------------------------------------------------------
4886 # Do we have a useable MPI setup on the primary and/or secondary targets?
4887 # On Linux, by default, assumes mpicc and -m32/-m64
4888 # Note: this is a kludge in that it assumes the specified mpicc 
4889 # understands -m32/-m64 regardless of what is specified using
4890 # --with-mpicc=.
4891 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4892              [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4894 mflag_primary=
4895 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4896      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4897      -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4898      -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4899      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4900      -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4901      -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4902   mflag_primary=$FLAG_M32
4903 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4904        -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4905        -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4906        -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4907        -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4908        -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4909   mflag_primary=$FLAG_M64
4910 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4911   mflag_primary="$FLAG_M32 -arch i386"
4912 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4913   mflag_primary="$FLAG_M64 -arch x86_64"
4916 mflag_secondary=
4917 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4918      -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4919      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4920      -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4921      -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4922   mflag_secondary=$FLAG_M32
4923 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4924   mflag_secondary="$FLAG_M32 -arch i386"
4928 AC_ARG_WITH(mpicc,
4929    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
4930    MPI_CC=$withval
4932 AC_SUBST(MPI_CC)
4934 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4935 ## use these values in the check for a functioning mpicc.
4937 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4938 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4939 AM_COND_IF([VGCONF_OS_IS_LINUX],
4940            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4941             LDFLAGS_MPI="-fpic -shared"])
4942 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
4943            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4944             LDFLAGS_MPI="-fpic -shared"])
4945 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4946            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4947             LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4948 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4949            [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4950             LDFLAGS_MPI="-fpic -shared"])
4952 AC_SUBST([CFLAGS_MPI])
4953 AC_SUBST([LDFLAGS_MPI])
4956 ## See if MPI_CC works for the primary target
4958 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4959 saved_CC=$CC
4960 saved_CFLAGS=$CFLAGS
4961 CC=$MPI_CC
4962 CFLAGS="$CFLAGS_MPI $mflag_primary"
4963 saved_LDFLAGS="$LDFLAGS"
4964 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4965 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4966 #include <mpi.h>
4967 #include <stdio.h>
4968 ]], [[
4969   int ni, na, nd, comb;
4970   int r = MPI_Init(NULL,NULL);
4971   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4972   r |= MPI_Finalize();
4973   return r; 
4974 ]])], [
4975 ac_have_mpi2_pri=yes
4976 AC_MSG_RESULT([yes, $MPI_CC])
4977 ], [
4978 ac_have_mpi2_pri=no
4979 AC_MSG_RESULT([no])
4981 CC=$saved_CC
4982 CFLAGS=$saved_CFLAGS
4983 LDFLAGS="$saved_LDFLAGS"
4984 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4986 ## See if MPI_CC works for the secondary target.  Complication: what if
4987 ## there is no secondary target?  We need this to then fail.
4988 ## Kludge this by making MPI_CC something which will surely fail in
4989 ## such a case.
4991 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4992 saved_CC=$CC
4993 saved_CFLAGS=$CFLAGS
4994 saved_LDFLAGS="$LDFLAGS"
4995 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4996 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4997   CC="$MPI_CC this will surely fail"
4998 else
4999   CC=$MPI_CC
5001 CFLAGS="$CFLAGS_MPI $mflag_secondary"
5002 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5003 #include <mpi.h>
5004 #include <stdio.h>
5005 ]], [[
5006   int ni, na, nd, comb;
5007   int r = MPI_Init(NULL,NULL);
5008   r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
5009   r |= MPI_Finalize();
5010   return r; 
5011 ]])], [
5012 ac_have_mpi2_sec=yes
5013 AC_MSG_RESULT([yes, $MPI_CC])
5014 ], [
5015 ac_have_mpi2_sec=no
5016 AC_MSG_RESULT([no])
5018 CC=$saved_CC
5019 CFLAGS=$saved_CFLAGS
5020 LDFLAGS="$saved_LDFLAGS"
5021 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
5024 #----------------------------------------------------------------------------
5025 # Other library checks
5026 #----------------------------------------------------------------------------
5027 # There now follow some tests for Boost, and OpenMP.  These
5028 # tests are present because Drd has some regression tests that use
5029 # these packages.  All regression test programs all compiled only
5030 # for the primary target.  And so it is important that the configure
5031 # checks that follow, use the correct -m32 or -m64 flag for the
5032 # primary target (called $mflag_primary).  Otherwise, we can end up
5033 # in a situation (eg) where, on amd64-linux, the test for Boost checks
5034 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
5035 # only build (meaning, the primary target is x86-linux), the build
5036 # of the regtest programs that use Boost fails, because they are 
5037 # build as 32-bit (IN THIS EXAMPLE).
5039 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
5040 # NEEDED BY THE REGRESSION TEST PROGRAMS.
5043 # Check whether the boost library 1.35 or later has been installed.
5044 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
5046 AC_MSG_CHECKING([for boost])
5048 AC_LANG(C++)
5049 safe_CXXFLAGS=$CXXFLAGS
5050 CXXFLAGS="$mflag_primary"
5051 safe_LIBS="$LIBS"
5052 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
5054 AC_LINK_IFELSE([AC_LANG_SOURCE([
5055 #include <boost/thread.hpp>
5056 static void thread_func(void)
5057 { }
5058 int main(int argc, char** argv)
5060   boost::thread t(thread_func);
5061   return 0;
5063 ])],
5065 ac_have_boost_1_35=yes
5066 AC_SUBST([BOOST_CFLAGS], [])
5067 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
5068 AC_MSG_RESULT([yes])
5069 ], [
5070 ac_have_boost_1_35=no
5071 AC_MSG_RESULT([no])
5074 LIBS="$safe_LIBS"
5075 CXXFLAGS=$safe_CXXFLAGS
5076 AC_LANG(C)
5078 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
5081 # does this compiler support -fopenmp, does it have the include file
5082 # <omp.h> and does it have libgomp ?
5084 AC_MSG_CHECKING([for OpenMP])
5086 safe_CFLAGS=$CFLAGS
5087 CFLAGS="-fopenmp $mflag_primary -Werror"
5089 AC_LINK_IFELSE([AC_LANG_SOURCE([
5090 #include <omp.h> 
5091 int main(int argc, char** argv)
5093   omp_set_dynamic(0);
5094   return 0;
5096 ])],
5098 ac_have_openmp=yes
5099 AC_MSG_RESULT([yes])
5100 ], [
5101 ac_have_openmp=no
5102 AC_MSG_RESULT([no])
5104 CFLAGS=$safe_CFLAGS
5106 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5109 # Check for __builtin_popcount
5110 AC_MSG_CHECKING([for __builtin_popcount()])
5111 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5112 ]], [[
5113   __builtin_popcount(2);
5114   return 0;
5115 ]])], [
5116 AC_MSG_RESULT([yes])
5117 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5118           [Define to 1 if compiler provides __builtin_popcount().])
5119 ], [
5120 AC_MSG_RESULT([no])
5123 # Check for __builtin_clz
5124 AC_MSG_CHECKING([for __builtin_clz()])
5125 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5126 ]], [[
5127   __builtin_clz(2);
5128   return 0;
5129 ]])], [
5130 AC_MSG_RESULT([yes])
5131 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5132           [Define to 1 if compiler provides __builtin_clz().])
5133 ], [
5134 AC_MSG_RESULT([no])
5137 # Check for __builtin_ctz
5138 AC_MSG_CHECKING([for __builtin_ctz()])
5139 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5140 ]], [[
5141   __builtin_ctz(2);
5142   return 0;
5143 ]])], [
5144 AC_MSG_RESULT([yes])
5145 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5146           [Define to 1 if compiler provides __builtin_ctz().])
5147 ], [
5148 AC_MSG_RESULT([no])
5151 # does this compiler have built-in functions for atomic memory access for the
5152 # primary target ?
5153 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5155 safe_CFLAGS=$CFLAGS
5156 CFLAGS="$mflag_primary"
5158 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5159   int variable = 1;
5160   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5161           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5162 ]])], [
5163   ac_have_builtin_atomic_primary=yes
5164   AC_MSG_RESULT([yes])
5165   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])
5166 ], [
5167   ac_have_builtin_atomic_primary=no
5168   AC_MSG_RESULT([no])
5171 CFLAGS=$safe_CFLAGS
5173 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5174                [test x$ac_have_builtin_atomic_primary = xyes])
5177 # does this compiler have built-in functions for atomic memory access for the
5178 # secondary target ?
5180 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5182 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5184 safe_CFLAGS=$CFLAGS
5185 CFLAGS="$mflag_secondary"
5187 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5188   int variable = 1;
5189   return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5190 ]])], [
5191   ac_have_builtin_atomic_secondary=yes
5192   AC_MSG_RESULT([yes])
5193 ], [
5194   ac_have_builtin_atomic_secondary=no
5195   AC_MSG_RESULT([no])
5198 CFLAGS=$safe_CFLAGS
5202 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5203                [test x$ac_have_builtin_atomic_secondary = xyes])
5205 # does this compiler have built-in functions for atomic memory access on
5206 # 64-bit integers for all targets ?
5208 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5210 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5211   #include <stdint.h>
5212 ]], [[
5213   uint64_t variable = 1;
5214   return __sync_add_and_fetch(&variable, 1)
5215 ]])], [
5216   ac_have_builtin_atomic64_primary=yes
5217 ], [
5218   ac_have_builtin_atomic64_primary=no
5221 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5223 safe_CFLAGS=$CFLAGS
5224 CFLAGS="$mflag_secondary"
5226 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5227   #include <stdint.h>
5228 ]], [[
5229   uint64_t variable = 1;
5230   return __sync_add_and_fetch(&variable, 1)
5231 ]])], [
5232   ac_have_builtin_atomic64_secondary=yes
5233 ], [
5234   ac_have_builtin_atomic64_secondary=no
5237 CFLAGS=$safe_CFLAGS
5241 if test x$ac_have_builtin_atomic64_primary = xyes && \
5242    test x$VGCONF_PLATFORM_SEC_CAPS = x \
5243      -o x$ac_have_builtin_atomic64_secondary = xyes; then
5244   AC_MSG_RESULT([yes])
5245   ac_have_builtin_atomic64=yes
5246 else
5247   AC_MSG_RESULT([no])
5248   ac_have_builtin_atomic64=no
5251 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5252                [test x$ac_have_builtin_atomic64 = xyes])
5254                
5255 AC_MSG_CHECKING([if platform has openat2 syscall])
5257 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5258   #include <sys/syscall.h>
5259 ]], [[
5260   return __NR_openat2
5261 ]])], [
5262   ac_have_openat2=yes
5263 ], [
5264   ac_have_openat2=no
5267 AM_CONDITIONAL([HAVE_OPENAT2],
5268                [test x$ac_have_openat2 = xyes])
5270 # does g++ have built-in functions for atomic memory access ?
5271 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5273 safe_CXXFLAGS=$CXXFLAGS
5274 CXXFLAGS="$mflag_primary"
5276 AC_LANG_PUSH(C++)
5277 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5278   int variable = 1;
5279   return (__sync_bool_compare_and_swap(&variable, 1, 2)
5280           && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5281 ]])], [
5282   ac_have_builtin_atomic_cxx=yes
5283   AC_MSG_RESULT([yes])
5284   AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5285 ], [
5286   ac_have_builtin_atomic_cxx=no
5287   AC_MSG_RESULT([no])
5289 AC_LANG_POP(C++)
5291 CXXFLAGS=$safe_CXXFLAGS
5293 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5296 if test x$ac_have_usable_linux_futex_h = xyes \
5297         -a x$ac_have_builtin_atomic_primary = xyes; then
5298   ac_enable_linux_ticket_lock_primary=yes
5300 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5301                [test x$ac_enable_linux_ticket_lock_primary = xyes])
5303 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5304         -a x$ac_have_usable_linux_futex_h = xyes \
5305         -a x$ac_have_builtin_atomic_secondary = xyes; then
5306   ac_enable_linux_ticket_lock_secondary=yes
5308 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5309                [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5312 # does libstdc++ support annotating shared pointers ?
5313 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5315 safe_CXXFLAGS=$CXXFLAGS
5316 CXXFLAGS="-std=c++0x"
5318 AC_LANG_PUSH(C++)
5319 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5320   #include <memory>
5321 ]], [[
5322   std::shared_ptr<int> p
5323 ]])], [
5324   ac_have_shared_ptr=yes
5325 ], [
5326   ac_have_shared_ptr=no
5328 if test x$ac_have_shared_ptr = xyes; then
5329   # If compilation of the program below fails because of a syntax error
5330   # triggered by substituting one of the annotation macros then that
5331   # means that libstdc++ supports these macros.
5332   AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5333     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5334     #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5335     #include <memory>
5336   ]], [[
5337     std::shared_ptr<int> p
5338   ]])], [
5339     ac_have_shared_pointer_annotation=no
5340     AC_MSG_RESULT([no])
5341   ], [
5342     ac_have_shared_pointer_annotation=yes
5343     AC_MSG_RESULT([yes])
5344     AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5345               [Define to 1 if libstd++ supports annotating shared pointers])
5346   ])
5347 else
5348   ac_have_shared_pointer_annotation=no
5349   AC_MSG_RESULT([no])
5351 AC_LANG_POP(C++)
5353 CXXFLAGS=$safe_CXXFLAGS
5355 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5356                [test x$ac_have_shared_pointer_annotation = xyes])
5359 #----------------------------------------------------------------------------
5360 # Ok.  We're done checking.
5361 #----------------------------------------------------------------------------
5363 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5364 AC_CONFIG_FILES([
5365    Makefile 
5366    VEX/Makefile:Makefile.vex.in
5367    valgrind.spec
5368    valgrind.pc
5369    glibc-2.X.supp
5370    glibc-2.X-helgrind.supp
5371    glibc-2.X-drd.supp
5372    include/valgrind.h
5373    docs/Makefile 
5374    docs/xml/vg-entities.xml
5375    tests/Makefile 
5376    tests/vg_regtest 
5377    perf/Makefile 
5378    perf/vg_perf
5379    gdbserver_tests/Makefile
5380    gdbserver_tests/solaris/Makefile
5381    include/Makefile 
5382    auxprogs/Makefile
5383    mpi/Makefile
5384    coregrind/Makefile 
5385    memcheck/Makefile
5386    memcheck/tests/Makefile
5387    memcheck/tests/common/Makefile
5388    memcheck/tests/amd64/Makefile
5389    memcheck/tests/x86/Makefile
5390    memcheck/tests/linux/Makefile
5391    memcheck/tests/linux/debuginfod-check.vgtest
5392    memcheck/tests/darwin/Makefile
5393    memcheck/tests/solaris/Makefile
5394    memcheck/tests/freebsd/Makefile
5395    memcheck/tests/amd64-linux/Makefile
5396    memcheck/tests/arm64-linux/Makefile
5397    memcheck/tests/x86-linux/Makefile
5398    memcheck/tests/amd64-solaris/Makefile
5399    memcheck/tests/x86-solaris/Makefile
5400    memcheck/tests/amd64-freebsd/Makefile
5401    memcheck/tests/x86-freebsd/Makefile
5402    memcheck/tests/ppc32/Makefile
5403    memcheck/tests/ppc64/Makefile
5404    memcheck/tests/s390x/Makefile
5405    memcheck/tests/mips32/Makefile
5406    memcheck/tests/mips64/Makefile
5407    memcheck/tests/vbit-test/Makefile
5408    cachegrind/Makefile
5409    cachegrind/tests/Makefile
5410    cachegrind/tests/x86/Makefile
5411    cachegrind/cg_annotate
5412    cachegrind/cg_diff
5413    cachegrind/cg_merge
5414    callgrind/Makefile
5415    callgrind/callgrind_annotate
5416    callgrind/callgrind_control
5417    callgrind/tests/Makefile
5418    helgrind/Makefile
5419    helgrind/tests/Makefile
5420    drd/Makefile
5421    drd/scripts/download-and-build-splash2
5422    drd/tests/Makefile
5423    massif/Makefile
5424    massif/tests/Makefile
5425    massif/ms_print
5426    dhat/Makefile
5427    dhat/tests/Makefile
5428    lackey/Makefile
5429    lackey/tests/Makefile
5430    none/Makefile
5431    none/tests/Makefile
5432    none/tests/scripts/Makefile
5433    none/tests/amd64/Makefile
5434    none/tests/ppc32/Makefile
5435    none/tests/ppc64/Makefile
5436    none/tests/x86/Makefile
5437    none/tests/arm/Makefile
5438    none/tests/arm64/Makefile
5439    none/tests/s390x/Makefile
5440    none/tests/mips32/Makefile
5441    none/tests/mips64/Makefile
5442    none/tests/nanomips/Makefile
5443    none/tests/linux/Makefile
5444    none/tests/darwin/Makefile
5445    none/tests/solaris/Makefile
5446    none/tests/freebsd/Makefile
5447    none/tests/amd64-linux/Makefile
5448    none/tests/x86-linux/Makefile
5449    none/tests/amd64-darwin/Makefile
5450    none/tests/x86-darwin/Makefile
5451    none/tests/amd64-solaris/Makefile
5452    none/tests/x86-solaris/Makefile
5453    none/tests/x86-freebsd/Makefile
5454    exp-bbv/Makefile
5455    exp-bbv/tests/Makefile
5456    exp-bbv/tests/x86/Makefile
5457    exp-bbv/tests/x86-linux/Makefile
5458    exp-bbv/tests/amd64-linux/Makefile
5459    exp-bbv/tests/ppc32-linux/Makefile
5460    exp-bbv/tests/arm-linux/Makefile
5461    shared/Makefile
5462    solaris/Makefile
5464 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5465                 [chmod +x coregrind/link_tool_exe_linux])
5466 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5467                 [chmod +x coregrind/link_tool_exe_freebsd])
5468 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5469                 [chmod +x coregrind/link_tool_exe_darwin])
5470 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5471                 [chmod +x coregrind/link_tool_exe_solaris])
5472 AC_CONFIG_FILES([tests/filter_stderr_basic],
5473                 [chmod +x tests/filter_stderr_basic])
5474 AC_CONFIG_FILES([tests/filter_discards],
5475                 [chmod +x tests/filter_discards])
5476 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5477                 [chmod +x memcheck/tests/filter_stderr])
5478 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5479                 [chmod +x memcheck/tests/filter_dw4])
5480 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5481                 [chmod +x memcheck/tests/filter_overlaperror])
5482 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5483                 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5484 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5485                 [chmod +x gdbserver_tests/filter_gdb])
5486 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5487                 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5488 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5489                 [chmod +x gdbserver_tests/filter_stderr])
5490 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5491                 [chmod +x gdbserver_tests/filter_vgdb])
5492 AC_CONFIG_FILES([drd/tests/filter_stderr],
5493                 [chmod +x drd/tests/filter_stderr])
5494 AC_CONFIG_FILES([drd/tests/filter_error_count],
5495                 [chmod +x drd/tests/filter_error_count])
5496 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5497                 [chmod +x drd/tests/filter_error_summary])
5498 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5499                 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5500 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5501                 [chmod +x drd/tests/filter_thread_no])
5502 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5503                 [chmod +x drd/tests/filter_xml_and_thread_no])
5504 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5505                 [chmod +x helgrind/tests/filter_stderr])
5506 AC_OUTPUT
5508 cat<<EOF
5510                     Version: ${VERSION}
5511          Maximum build arch: ${ARCH_MAX}
5512          Primary build arch: ${VGCONF_ARCH_PRI}
5513        Secondary build arch: ${VGCONF_ARCH_SEC}
5514                    Build OS: ${VGCONF_OS}
5515      Link Time Optimisation: ${vg_cv_lto}
5516        Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5517      Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5518            Platform variant: ${VGCONF_PLATVARIANT}
5519       Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5520          Default supp files: ${DEFAULT_SUPP}