1 2##------------------------------------------------------------## 3# 4# The multiple-architecture stuff in this file is pretty 5# cryptic. Read docs/internals/multiple-architectures.txt 6# for at least a partial explanation of what is going on. 7# 8##------------------------------------------------------------## 9 10# Process this file with autoconf to produce a configure script. 11AC_INIT([Valgrind],[3.11.0.SVN],[valgrind-users@lists.sourceforge.net]) 12AC_CONFIG_SRCDIR(coregrind/m_main.c) 13AC_CONFIG_HEADERS([config.h]) 14AM_INIT_AUTOMAKE([foreign subdir-objects]) 15 16AM_MAINTAINER_MODE 17 18#---------------------------------------------------------------------------- 19# Do NOT modify these flags here. Except in feature tests in which case 20# the original values must be properly restored. 21#---------------------------------------------------------------------------- 22CFLAGS="$CFLAGS" 23CXXFLAGS="$CXXFLAGS" 24 25#---------------------------------------------------------------------------- 26# Checks for various programs. 27#---------------------------------------------------------------------------- 28 29AC_PROG_LN_S 30AC_PROG_CC 31AM_PROG_CC_C_O 32AC_PROG_CPP 33AC_PROG_CXX 34# AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with 35# autoconf 2.59). If we ever have any Objective-C code in the Valgrind code 36# base (eg. most likely as Darwin-specific tests) we'll need one of the 37# following: 38# - put AC_PROG_OBJC in a Darwin-specific part of this file 39# - Use AC_PROG_OBJC here and up the minimum autoconf version 40# - Use the following, which is apparently equivalent: 41# m4_ifdef([AC_PROG_OBJC], 42# [AC_PROG_OBJC], 43# [AC_CHECK_TOOL([OBJC], [gcc]) 44# AC_SUBST([OBJC]) 45# AC_SUBST([OBJCFLAGS]) 46# ]) 47AC_PROG_RANLIB 48# provide a very basic definition for AC_PROG_SED if it's not provided by 49# autoconf (as e.g. in autoconf 2.59). 50m4_ifndef([AC_PROG_SED], 51 [AC_DEFUN([AC_PROG_SED], 52 [AC_ARG_VAR([SED]) 53 AC_CHECK_PROGS([SED],[gsed sed])])]) 54AC_PROG_SED 55 56# If no AR variable was specified, look up the name of the archiver. Otherwise 57# do not touch the AR variable. 58if test "x$AR" = "x"; then 59 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar]) 60fi 61AC_ARG_VAR([AR],[Archiver command]) 62 63# Check for the compiler support 64if test "${GCC}" != "yes" ; then 65 AC_MSG_ERROR([Valgrind relies on GCC to be compiled]) 66fi 67 68# figure out where perl lives 69AC_PATH_PROG(PERL, perl) 70 71# figure out where gdb lives 72AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time") 73AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB]) 74 75# some older automake's don't have it so try something on our own 76ifdef([AM_PROG_AS],[AM_PROG_AS], 77[ 78AS="${CC}" 79AC_SUBST(AS) 80 81ASFLAGS="" 82AC_SUBST(ASFLAGS) 83]) 84 85 86# Check if 'diff' supports -u (universal diffs) and use it if possible. 87 88AC_MSG_CHECKING([for diff -u]) 89AC_SUBST(DIFF) 90 91# Comparing two identical files results in 0. 92tmpfile="tmp-xxx-yyy-zzz" 93touch $tmpfile; 94if diff -u $tmpfile $tmpfile ; then 95 AC_MSG_RESULT([yes]) 96 DIFF="diff -u" 97else 98 AC_MSG_RESULT([no]) 99 DIFF="diff" 100fi 101rm $tmpfile 102 103 104# We don't want gcc < 3.0 105AC_MSG_CHECKING([for a supported version of gcc]) 106 107# Obtain the compiler version. 108# 109# A few examples of how the ${CC} --version output looks like: 110# 111# ######## gcc variants ######## 112# Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2 113# Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2 114# openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585] 115# Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2 116# MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3 117# OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) 118# OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00) 119# 120# ######## clang variants ######## 121# Clang: clang version 2.9 (tags/RELEASE_29/final) 122# Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn) 123# FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523 124# 125# ######## Apple LLVM variants ######## 126# Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) 127# Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn) 128# 129[ 130if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ; 131then 132 is_clang="applellvm" 133 gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'` 134elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ; 135then 136 is_clang="clang" 137 # Don't use -dumpversion with clang: it will always produce "4.2.1". 138 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'` 139elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ; 140then 141 is_clang="icc" 142 gcc_version=`${CC} -dumpversion 2>/dev/null` 143else 144 is_clang="notclang" 145 gcc_version=`${CC} -dumpversion 2>/dev/null` 146 if test "x$gcc_version" = x; then 147 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'` 148 fi 149fi 150] 151AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm) 152AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc) 153 154# Note: m4 arguments are quoted with [ and ] so square brackets in shell 155# statements have to be quoted. 156case "${is_clang}-${gcc_version}" in 157 applellvm-5.1|applellvm-6.*) 158 AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})]) 159 ;; 160 icc-1[[3-9]].*) 161 AC_MSG_RESULT([ok (ICC version ${gcc_version})]) 162 ;; 163 notclang-[[3-9]].*|notclang-[[1-9][0-9]]*) 164 AC_MSG_RESULT([ok (${gcc_version})]) 165 ;; 166 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*) 167 AC_MSG_RESULT([ok (clang-${gcc_version})]) 168 ;; 169 *) 170 AC_MSG_RESULT([no (${gcc_version})]) 171 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0]) 172 ;; 173esac 174 175#---------------------------------------------------------------------------- 176# Arch/OS/platform tests. 177#---------------------------------------------------------------------------- 178# We create a number of arch/OS/platform-related variables. We prefix them 179# all with "VGCONF_" which indicates that they are defined at 180# configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_* 181# variables used when compiling C files. 182 183AC_CANONICAL_HOST 184 185AC_MSG_CHECKING([for a supported CPU]) 186 187# ARCH_MAX reflects the most that this CPU can do: for example if it 188# is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32. 189# Ditto for amd64. It is used for more configuration below, but is not used 190# outside this file. 191# 192# Power PC returns powerpc for Big Endian. This was not changed when Little 193# Endian support was added to the 64-bit architecture. The 64-bit Little 194# Endian systems explicitly state le in the host_cpu. For clarity in the 195# Valgrind code, the ARCH_MAX name will state LE or BE for the endianess of 196# the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC. 197# The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either 198# Endianess. The name PPC64 or ppc64 to 64-bit systems of either Endianess. 199# The names ppc64be or PPC64BE refer to only 64-bit systems that are Big 200# Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are 201# Little Endian. 202 203case "${host_cpu}" in 204 i?86) 205 AC_MSG_RESULT([ok (${host_cpu})]) 206 ARCH_MAX="x86" 207 ;; 208 209 x86_64) 210 AC_MSG_RESULT([ok (${host_cpu})]) 211 ARCH_MAX="amd64" 212 ;; 213 214 powerpc64) 215 # this only referrs to 64-bit Big Endian 216 AC_MSG_RESULT([ok (${host_cpu})]) 217 ARCH_MAX="ppc64be" 218 ;; 219 220 powerpc64le) 221 # this only referrs to 64-bit Little Endian 222 AC_MSG_RESULT([ok (${host_cpu})]) 223 ARCH_MAX="ppc64le" 224 ;; 225 226 powerpc) 227 # On Linux this means only a 32-bit capable CPU. 228 AC_MSG_RESULT([ok (${host_cpu})]) 229 ARCH_MAX="ppc32" 230 ;; 231 232 s390x) 233 AC_MSG_RESULT([ok (${host_cpu})]) 234 ARCH_MAX="s390x" 235 ;; 236 237 armv7*) 238 AC_MSG_RESULT([ok (${host_cpu})]) 239 ARCH_MAX="arm" 240 ;; 241 242 aarch64*) 243 AC_MSG_RESULT([ok (${host_cpu})]) 244 ARCH_MAX="arm64" 245 ;; 246 247 mips) 248 AC_MSG_RESULT([ok (${host_cpu})]) 249 ARCH_MAX="mips32" 250 ;; 251 252 mipsel) 253 AC_MSG_RESULT([ok (${host_cpu})]) 254 ARCH_MAX="mips32" 255 ;; 256 257 mipsisa32r2) 258 AC_MSG_RESULT([ok (${host_cpu})]) 259 ARCH_MAX="mips32" 260 ;; 261 262 mips64*) 263 AC_MSG_RESULT([ok (${host_cpu})]) 264 ARCH_MAX="mips64" 265 ;; 266 267 mipsisa64*) 268 AC_MSG_RESULT([ok (${host_cpu})]) 269 ARCH_MAX="mips64" 270 ;; 271 272 tilegx) 273 AC_MSG_RESULT([ok (${host_cpu})]) 274 ARCH_MAX="tilegx" 275 ;; 276 277 *) 278 AC_MSG_RESULT([no (${host_cpu})]) 279 AC_MSG_ERROR([Unsupported host architecture. Sorry]) 280 ;; 281esac 282 283#---------------------------------------------------------------------------- 284 285# Sometimes it's convenient to subvert the bi-arch build system and 286# just have a single build even though the underlying platform is 287# capable of both. Hence handle --enable-only64bit and 288# --enable-only32bit. Complain if both are issued :-) 289# [Actually, if either of these options are used, I think both get built, 290# but only one gets installed. So if you use an in-place build, both can be 291# used. --njn] 292 293# Check if a 64-bit only build has been requested 294AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit, 295 [AC_ARG_ENABLE(only64bit, 296 [ --enable-only64bit do a 64-bit only build], 297 [vg_cv_only64bit=$enableval], 298 [vg_cv_only64bit=no])]) 299 300# Check if a 32-bit only build has been requested 301AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit, 302 [AC_ARG_ENABLE(only32bit, 303 [ --enable-only32bit do a 32-bit only build], 304 [vg_cv_only32bit=$enableval], 305 [vg_cv_only32bit=no])]) 306 307# Stay sane 308if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then 309 AC_MSG_ERROR( 310 [Nonsensical: both --enable-only64bit and --enable-only32bit.]) 311fi 312 313#---------------------------------------------------------------------------- 314 315# VGCONF_OS is the primary build OS, eg. "linux". It is passed in to 316# compilation of many C files via -VGO_$(VGCONF_OS) and 317# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS). 318AC_MSG_CHECKING([for a supported OS]) 319AC_SUBST(VGCONF_OS) 320 321DEFAULT_SUPP="" 322 323case "${host_os}" in 324 *linux*) 325 AC_MSG_RESULT([ok (${host_os})]) 326 VGCONF_OS="linux" 327 328 # Ok, this is linux. Check the kernel version 329 AC_MSG_CHECKING([for the kernel version]) 330 331 kernel=`uname -r` 332 333 case "${kernel}" in 334 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*) 335 AC_MSG_RESULT([unsupported (${kernel})]) 336 AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6]) 337 ;; 338 339 *) 340 AC_MSG_RESULT([2.6 or later (${kernel})]) 341 ;; 342 esac 343 344 ;; 345 346 *darwin*) 347 AC_MSG_RESULT([ok (${host_os})]) 348 VGCONF_OS="darwin" 349 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5]) 350 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6]) 351 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7]) 352 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8]) 353 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9]) 354 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10]) 355 356 AC_MSG_CHECKING([for the kernel version]) 357 kernel=`uname -r` 358 359 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin 360 # has only one relevant version, the OS version. The `uname` check 361 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS 362 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard, 363 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion), 364 # and we don't know of an macros similar to __GLIBC__ to get that info. 365 # 366 # XXX: `uname -r` won't do the right thing for cross-compiles, but 367 # that's not a problem yet. 368 # 369 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work 370 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0 371 # on 10.6.8 and 10.7.1. Although tempted to delete the configure 372 # time support for 10.5 (the 9.* pattern just below), I'll leave it 373 # in for now, just in case anybody wants to give it a try. But I'm 374 # assuming that 3.7.0 is a Snow Leopard and Lion-only release. 375 case "${kernel}" in 376 9.*) 377 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard]) 378 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version]) 379 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}" 380 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}" 381 ;; 382 10.*) 383 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard]) 384 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version]) 385 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}" 386 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}" 387 ;; 388 11.*) 389 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion]) 390 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version]) 391 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}" 392 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}" 393 ;; 394 12.*) 395 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion]) 396 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version]) 397 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}" 398 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}" 399 ;; 400 13.*) 401 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks]) 402 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version]) 403 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}" 404 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}" 405 ;; 406 14.*) 407 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite]) 408 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version]) 409 DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}" 410 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}" 411 ;; 412 *) 413 AC_MSG_RESULT([unsupported (${kernel})]) 414 AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x and 14.x (Mac OS X 10.6/7/8/9/10)]) 415 ;; 416 esac 417 ;; 418 419 *) 420 AC_MSG_RESULT([no (${host_os})]) 421 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.]) 422 ;; 423esac 424 425#---------------------------------------------------------------------------- 426 427# If we are building on a 64 bit platform test to see if the system 428# supports building 32 bit programs and disable 32 bit support if it 429# does not support building 32 bit programs 430 431case "$ARCH_MAX-$VGCONF_OS" in 432 amd64-linux|ppc64be-linux|arm64-linux) 433 AC_MSG_CHECKING([for 32 bit build support]) 434 safe_CFLAGS=$CFLAGS 435 CFLAGS="-m32" 436 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 437 return 0; 438 ]])], [ 439 AC_MSG_RESULT([yes]) 440 ], [ 441 vg_cv_only64bit="yes" 442 AC_MSG_RESULT([no]) 443 ]) 444 CFLAGS=$safe_CFLAGS;; 445esac 446 447if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then 448 AC_MSG_ERROR( 449 [--enable-only32bit was specified but system does not support 32 bit builds]) 450fi 451 452#---------------------------------------------------------------------------- 453 454# VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By 455# default it's the same as ARCH_MAX. But if, say, we do a build on an amd64 456# machine, but --enable-only32bit has been requested, then ARCH_MAX (see 457# above) will be "amd64" since that reflects the most that this cpu can do, 458# but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the 459# arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is 460# passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and 461# -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS). 462AC_SUBST(VGCONF_ARCH_PRI) 463 464# VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86". 465# It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC) 466# and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target. 467# It is empty if there is no secondary target. 468AC_SUBST(VGCONF_ARCH_SEC) 469 470# VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX". 471# The entire system, including regression and performance tests, will be 472# built for this target. The "_CAPS" indicates that the name is in capital 473# letters, and it also uses '_' rather than '-' as a separator, because it's 474# used to create various Makefile variables, which are all in caps by 475# convention and cannot contain '-' characters. This is in contrast to 476# VGCONF_ARCH_PRI and VGCONF_OS which are not in caps. 477AC_SUBST(VGCONF_PLATFORM_PRI_CAPS) 478 479# VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one. 480# Valgrind and tools will also be built for this target, but not the 481# regression or performance tests. 482# 483# By default, the primary arch is the same as the "max" arch, as commented 484# above (at the definition of ARCH_MAX). We may choose to downgrade it in 485# the big case statement just below here, in the case where we're building 486# on a 64 bit machine but have been requested only to do a 32 bit build. 487AC_SUBST(VGCONF_PLATFORM_SEC_CAPS) 488 489AC_MSG_CHECKING([for a supported CPU/OS combination]) 490 491# NB. The load address for a given platform may be specified in more 492# than one place, in some cases, depending on whether we're doing a biarch, 493# 32-bit only or 64-bit only build. eg see case for amd64-linux below. 494# Be careful to give consistent values in all subcases. Also, all four 495# valt_load_addres_{pri,sec}_{norml,inner} values must always be set, 496# even if it is to "0xUNSET". 497# 498case "$ARCH_MAX-$VGCONF_OS" in 499 x86-linux) 500 VGCONF_ARCH_PRI="x86" 501 VGCONF_ARCH_SEC="" 502 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX" 503 VGCONF_PLATFORM_SEC_CAPS="" 504 valt_load_address_pri_norml="0x38000000" 505 valt_load_address_pri_inner="0x28000000" 506 valt_load_address_sec_norml="0xUNSET" 507 valt_load_address_sec_inner="0xUNSET" 508 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 509 ;; 510 amd64-linux) 511 valt_load_address_sec_norml="0xUNSET" 512 valt_load_address_sec_inner="0xUNSET" 513 if test x$vg_cv_only64bit = xyes; then 514 VGCONF_ARCH_PRI="amd64" 515 VGCONF_ARCH_SEC="" 516 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX" 517 VGCONF_PLATFORM_SEC_CAPS="" 518 valt_load_address_pri_norml="0x38000000" 519 valt_load_address_pri_inner="0x28000000" 520 elif test x$vg_cv_only32bit = xyes; then 521 VGCONF_ARCH_PRI="x86" 522 VGCONF_ARCH_SEC="" 523 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX" 524 VGCONF_PLATFORM_SEC_CAPS="" 525 valt_load_address_pri_norml="0x38000000" 526 valt_load_address_pri_inner="0x28000000" 527 else 528 VGCONF_ARCH_PRI="amd64" 529 VGCONF_ARCH_SEC="x86" 530 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX" 531 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX" 532 valt_load_address_pri_norml="0x38000000" 533 valt_load_address_pri_inner="0x28000000" 534 valt_load_address_sec_norml="0x38000000" 535 valt_load_address_sec_inner="0x28000000" 536 fi 537 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 538 ;; 539 ppc32-linux) 540 VGCONF_ARCH_PRI="ppc32" 541 VGCONF_ARCH_SEC="" 542 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX" 543 VGCONF_PLATFORM_SEC_CAPS="" 544 valt_load_address_pri_norml="0x38000000" 545 valt_load_address_pri_inner="0x28000000" 546 valt_load_address_sec_norml="0xUNSET" 547 valt_load_address_sec_inner="0xUNSET" 548 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 549 ;; 550 ppc64be-linux) 551 valt_load_address_sec_norml="0xUNSET" 552 valt_load_address_sec_inner="0xUNSET" 553 if test x$vg_cv_only64bit = xyes; then 554 VGCONF_ARCH_PRI="ppc64be" 555 VGCONF_ARCH_SEC="" 556 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX" 557 VGCONF_PLATFORM_SEC_CAPS="" 558 valt_load_address_pri_norml="0x38000000" 559 valt_load_address_pri_inner="0x28000000" 560 elif test x$vg_cv_only32bit = xyes; then 561 VGCONF_ARCH_PRI="ppc32" 562 VGCONF_ARCH_SEC="" 563 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX" 564 VGCONF_PLATFORM_SEC_CAPS="" 565 valt_load_address_pri_norml="0x38000000" 566 valt_load_address_pri_inner="0x28000000" 567 else 568 VGCONF_ARCH_PRI="ppc64be" 569 VGCONF_ARCH_SEC="ppc32" 570 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX" 571 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX" 572 valt_load_address_pri_norml="0x38000000" 573 valt_load_address_pri_inner="0x28000000" 574 valt_load_address_sec_norml="0x38000000" 575 valt_load_address_sec_inner="0x28000000" 576 fi 577 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 578 ;; 579 ppc64le-linux) 580 # Little Endian is only supported on PPC64 581 valt_load_address_sec_norml="0xUNSET" 582 valt_load_address_sec_inner="0xUNSET" 583 VGCONF_ARCH_PRI="ppc64le" 584 VGCONF_ARCH_SEC="" 585 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX" 586 VGCONF_PLATFORM_SEC_CAPS="" 587 valt_load_address_pri_norml="0x38000000" 588 valt_load_address_pri_inner="0x28000000" 589 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 590 ;; 591 # Darwin gets identified as 32-bit even when it supports 64-bit. 592 # (Not sure why, possibly because 'uname' returns "i386"?) Just about 593 # all Macs support both 32-bit and 64-bit, so we just build both. If 594 # someone has a really old 32-bit only machine they can (hopefully?) 595 # build with --enable-only32bit. See bug 243362. 596 x86-darwin|amd64-darwin) 597 ARCH_MAX="amd64" 598 valt_load_address_sec_norml="0xUNSET" 599 valt_load_address_sec_inner="0xUNSET" 600 if test x$vg_cv_only64bit = xyes; then 601 VGCONF_ARCH_PRI="amd64" 602 VGCONF_ARCH_SEC="" 603 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN" 604 VGCONF_PLATFORM_SEC_CAPS="" 605 valt_load_address_pri_norml="0x138000000" 606 valt_load_address_pri_inner="0x128000000" 607 elif test x$vg_cv_only32bit = xyes; then 608 VGCONF_ARCH_PRI="x86" 609 VGCONF_ARCH_SEC="" 610 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN" 611 VGCONF_PLATFORM_SEC_CAPS="" 612 VGCONF_ARCH_PRI_CAPS="x86" 613 valt_load_address_pri_norml="0x38000000" 614 valt_load_address_pri_inner="0x28000000" 615 else 616 VGCONF_ARCH_PRI="amd64" 617 VGCONF_ARCH_SEC="x86" 618 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN" 619 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN" 620 valt_load_address_pri_norml="0x138000000" 621 valt_load_address_pri_inner="0x128000000" 622 valt_load_address_sec_norml="0x38000000" 623 valt_load_address_sec_inner="0x28000000" 624 fi 625 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 626 ;; 627 arm-linux) 628 VGCONF_ARCH_PRI="arm" 629 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX" 630 VGCONF_PLATFORM_SEC_CAPS="" 631 valt_load_address_pri_norml="0x38000000" 632 valt_load_address_pri_inner="0x28000000" 633 valt_load_address_sec_norml="0xUNSET" 634 valt_load_address_sec_inner="0xUNSET" 635 AC_MSG_RESULT([ok (${host_cpu}-${host_os})]) 636 ;; 637 arm64-linux) 638 valt_load_address_sec_norml="0xUNSET" 639 valt_load_address_sec_inner="0xUNSET" 640 if test x$vg_cv_only64bit = xyes; then 641 VGCONF_ARCH_PRI="arm64" 642 VGCONF_ARCH_SEC="" 643 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX" 644 VGCONF_PLATFORM_SEC_CAPS="" 645 valt_load_address_pri_norml="0x38000000" 646 valt_load_address_pri_inner="0x28000000" 647 elif test x$vg_cv_only32bit = xyes; then 648 VGCONF_ARCH_PRI="arm" 649 VGCONF_ARCH_SEC="" 650 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX" 651 VGCONF_PLATFORM_SEC_CAPS="" 652 valt_load_address_pri_norml="0x38000000" 653 valt_load_address_pri_inner="0x28000000" 654 else 655 VGCONF_ARCH_PRI="arm64" 656 VGCONF_ARCH_SEC="arm" 657 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX" 658 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX" 659 valt_load_address_pri_norml="0x38000000" 660 valt_load_address_pri_inner="0x28000000" 661 valt_load_address_sec_norml="0x38000000" 662 valt_load_address_sec_inner="0x28000000" 663 fi 664 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 665 ;; 666 s390x-linux) 667 VGCONF_ARCH_PRI="s390x" 668 VGCONF_ARCH_SEC="" 669 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX" 670 VGCONF_PLATFORM_SEC_CAPS="" 671 # To improve branch prediction hit rate we want to have 672 # the generated code close to valgrind (host) code 673 valt_load_address_pri_norml="0x800000000" 674 valt_load_address_pri_inner="0x810000000" 675 valt_load_address_sec_norml="0xUNSET" 676 valt_load_address_sec_inner="0xUNSET" 677 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 678 ;; 679 mips32-linux) 680 VGCONF_ARCH_PRI="mips32" 681 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX" 682 VGCONF_PLATFORM_SEC_CAPS="" 683 valt_load_address_pri_norml="0x38000000" 684 valt_load_address_pri_inner="0x28000000" 685 valt_load_address_sec_norml="0xUNSET" 686 valt_load_address_sec_inner="0xUNSET" 687 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 688 ;; 689 mips64-linux) 690 VGCONF_ARCH_PRI="mips64" 691 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX" 692 VGCONF_PLATFORM_SEC_CAPS="" 693 valt_load_address_pri_norml="0x38000000" 694 valt_load_address_pri_inner="0x28000000" 695 valt_load_address_sec_norml="0xUNSET" 696 valt_load_address_sec_inner="0xUNSET" 697 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 698 ;; 699 tilegx-linux) 700 VGCONF_ARCH_PRI="tilegx" 701 VGCONF_ARCH_SEC="" 702 VGCONF_PLATFORM_PRI_CAPS="TILEGX_LINUX" 703 VGCONF_PLATFORM_SEC_CAPS="" 704 valt_load_address_pri_norml="0x38000000" 705 valt_load_address_pri_inner="0x28000000" 706 valt_load_address_sec_norml="0xUNSET" 707 valt_load_address_sec_inner="0xUNSET" 708 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})]) 709 ;; 710 *) 711 VGCONF_ARCH_PRI="unknown" 712 VGCONF_ARCH_SEC="unknown" 713 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN" 714 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN" 715 valt_load_address_pri_norml="0xUNSET" 716 valt_load_address_pri_inner="0xUNSET" 717 valt_load_address_sec_norml="0xUNSET" 718 valt_load_address_sec_inner="0xUNSET" 719 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})]) 720 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.]) 721 ;; 722esac 723 724#---------------------------------------------------------------------------- 725 726# Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become 727# defined. 728AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86, 729 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \ 730 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \ 731 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \ 732 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ) 733AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64, 734 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \ 735 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ) 736AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32, 737 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 738 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ) 739AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64, 740 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \ 741 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX ) 742AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM, 743 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \ 744 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX ) 745AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64, 746 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX ) 747AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X, 748 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ) 749AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32, 750 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX ) 751AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64, 752 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ) 753AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_TILEGX, 754 test x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX ) 755 756# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these 757# become defined. 758AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX, 759 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \ 760 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX) 761AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX, 762 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX) 763AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX, 764 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 765 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX) 766AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX, 767 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX) 768AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX, 769 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX) 770AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX, 771 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \ 772 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX) 773AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX, 774 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX) 775AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX, 776 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \ 777 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX) 778AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX, 779 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX) 780AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX, 781 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX) 782AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_TILEGX_LINUX, 783 test x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX) 784AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN, 785 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \ 786 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN) 787AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN, 788 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN) 789 790 791# Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined. 792# Relies on the assumption that the primary and secondary targets are 793# for the same OS, so therefore only necessary to test the primary. 794AM_CONDITIONAL(VGCONF_OS_IS_LINUX, 795 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \ 796 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \ 797 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 798 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \ 799 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \ 800 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \ 801 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \ 802 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \ 803 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ 804 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \ 805 -o x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX) 806AM_CONDITIONAL(VGCONF_OS_IS_DARWIN, 807 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \ 808 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN) 809 810 811# Sometimes, in the Makefile.am files, it's useful to know whether or not 812# there is a secondary target. 813AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC, 814 test x$VGCONF_PLATFORM_SEC_CAPS != x) 815 816dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a 817dnl fallback definition 818dnl The macro is courtesy of Dave Hart: 819dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html 820m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [ 821if test -z "$$1_TRUE"; then : 822 m4_n([$2])[]dnl 823m4_ifval([$3], 824[else 825 $3 826])dnl 827fi[]dnl 828])]) 829 830#---------------------------------------------------------------------------- 831# Inner Valgrind? 832#---------------------------------------------------------------------------- 833 834# Check if this should be built as an inner Valgrind, to be run within 835# another Valgrind. Choose the load address accordingly. 836AC_SUBST(VALT_LOAD_ADDRESS_PRI) 837AC_SUBST(VALT_LOAD_ADDRESS_SEC) 838AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner, 839 [AC_ARG_ENABLE(inner, 840 [ --enable-inner enables self-hosting], 841 [vg_cv_inner=$enableval], 842 [vg_cv_inner=no])]) 843if test "$vg_cv_inner" = yes; then 844 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind]) 845 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner 846 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner 847else 848 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml 849 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml 850fi 851 852#---------------------------------------------------------------------------- 853# Undefined behaviour sanitiser 854#---------------------------------------------------------------------------- 855# Check whether we should build with the undefined beahviour sanitiser. 856 857AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan, 858 [AC_ARG_ENABLE(ubsan, 859 [ --enable-ubsan enables the undefined behaviour sanitiser], 860 [vg_cv_ubsan=$enableval], 861 [vg_cv_ubsan=no])]) 862 863#---------------------------------------------------------------------------- 864# Define MIPS_PAGE_SHIFT (--with-pagesize) 865#---------------------------------------------------------------------------- 866AC_ARG_WITH(pagesize, 867 [ --with-pagesize= override detected page size (4, 16 or 64)], 868 [psize=$withval], 869 [psize=0] 870) 871 872if test "$psize" = "0"; then 873 psizer=`getconf PAGESIZE` 874 psize=$((${psizer}/1024)) 875fi 876 877if test "$psize" = "4"; then 878 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured page size 4k]) 879elif test "$psize" = "16"; then 880 AC_DEFINE([MIPS_PAGE_SHIFT], 14, [configured page size 16k]) 881elif test "$psize" = "64"; then 882 AC_DEFINE([MIPS_PAGE_SHIFT], 16, [configured page size 64k]) 883else 884 AC_DEFINE([MIPS_PAGE_SHIFT], 12, [configured default page size 4k]) 885fi 886AC_MSG_RESULT([checking for Pagesize... ${psize}k]) 887 888 889#---------------------------------------------------------------------------- 890# Extra fine-tuning of installation directories 891#---------------------------------------------------------------------------- 892AC_ARG_WITH(tmpdir, 893 [ --with-tmpdir=PATH Specify path for temporary files], 894 tmpdir="$withval", 895 tmpdir="/tmp") 896AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory]) 897AC_SUBST(VG_TMPDIR, [$tmpdir]) 898 899 900#---------------------------------------------------------------------------- 901# Libc and suppressions 902#---------------------------------------------------------------------------- 903# This variable will collect the suppression files to be used. 904AC_SUBST(DEFAULT_SUPP) 905 906AC_CHECK_HEADER([features.h]) 907 908if test x$ac_cv_header_features_h = xyes; then 909 rm -f conftest.$ac_ext 910 cat <<_ACEOF >conftest.$ac_ext 911#include <features.h> 912#if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) 913glibc version is: __GLIBC__ __GLIBC_MINOR__ 914#endif 915_ACEOF 916 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`" 917fi 918 919# not really a version check 920AC_EGREP_CPP([DARWIN_LIBC], [ 921#include <sys/cdefs.h> 922#if defined(__DARWIN_VERS_1050) 923 DARWIN_LIBC 924#endif 925], 926GLIBC_VERSION="darwin") 927 928# not really a version check 929AC_EGREP_CPP([BIONIC_LIBC], [ 930#if defined(__ANDROID__) 931 BIONIC_LIBC 932#endif 933], 934GLIBC_VERSION="bionic") 935 936 937AC_MSG_CHECKING([the glibc version]) 938 939case "${GLIBC_VERSION}" in 940 2.2) 941 AC_MSG_RESULT(${GLIBC_VERSION} family) 942 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}" 943 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}" 944 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}" 945 ;; 946 2.[[3-6]]) 947 AC_MSG_RESULT(${GLIBC_VERSION} family) 948 DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}" 949 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}" 950 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}" 951 ;; 952 2.[[7-9]]) 953 AC_MSG_RESULT(${GLIBC_VERSION} family) 954 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}" 955 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}" 956 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}" 957 ;; 958 2.10|2.11) 959 AC_MSG_RESULT(${GLIBC_VERSION} family) 960 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1, 961 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)]) 962 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}" 963 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}" 964 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}" 965 ;; 966 2.*) 967 AC_MSG_RESULT(${GLIBC_VERSION} family) 968 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1, 969 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)]) 970 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1, 971 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)]) 972 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}" 973 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}" 974 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}" 975 ;; 976 darwin) 977 AC_MSG_RESULT(Darwin) 978 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin]) 979 # DEFAULT_SUPP set by kernel version check above. 980 ;; 981 bionic) 982 AC_MSG_RESULT(Bionic) 983 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic]) 984 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}" 985 ;; 986 2.0|2.1|*) 987 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}]) 988 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later]) 989 AC_MSG_ERROR([or Darwin or Bionic libc]) 990 ;; 991esac 992 993AC_SUBST(GLIBC_VERSION) 994 995 996# Add default suppressions for the X client libraries. Make no 997# attempt to detect whether such libraries are installed on the 998# build machine (or even if any X facilities are present); just 999# add the suppressions antidisirregardless. 1000DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}" 1001DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}" 1002 1003# Add glibc and X11 suppressions for exp-sgcheck 1004DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}" 1005 1006 1007#---------------------------------------------------------------------------- 1008# Platform variants? 1009#---------------------------------------------------------------------------- 1010 1011# Normally the PLAT = (ARCH, OS) characterisation of the platform is enough. 1012# But there are times where we need a bit more control. The motivating 1013# and currently only case is Android: this is almost identical to 1014# {x86,arm,mips}-linux, but not quite. So this introduces the concept of 1015# platform variant tags, which get passed in the compile as 1016# -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition. 1017# 1018# In almost all cases, the <variant> bit is "vanilla". But for Android 1019# it is "android" instead. 1020# 1021# Consequently (eg), plain arm-linux would build with 1022# 1023# -DVGP_arm_linux -DVGPV_arm_linux_vanilla 1024# 1025# whilst an Android build would have 1026# 1027# -DVGP_arm_linux -DVGPV_arm_linux_android 1028# 1029# Same for x86. The setup of the platform variant is pushed relatively far 1030# down this file in order that we can inspect any of the variables set above. 1031 1032# In the normal case .. 1033VGCONF_PLATVARIANT="vanilla" 1034 1035# Android ? 1036if test "$GLIBC_VERSION" = "bionic"; 1037then 1038 VGCONF_PLATVARIANT="android" 1039fi 1040 1041AC_SUBST(VGCONF_PLATVARIANT) 1042 1043 1044# FIXME: do we also want to define automake variables 1045# VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently) 1046# VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE, 1047# VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough 1048# do that. Problem is that we can't do and-ing in Makefile.am's, but 1049# that's what we'd need to do to use this, since what we'd want to write 1050# is something like 1051# 1052# VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID 1053# 1054# Hmm. Can't think of a nice clean solution to this. 1055 1056AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA, 1057 test x$VGCONF_PLATVARIANT = xvanilla) 1058AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID, 1059 test x$VGCONF_PLATVARIANT = xandroid) 1060 1061 1062#---------------------------------------------------------------------------- 1063# Checking for various library functions and other definitions 1064#---------------------------------------------------------------------------- 1065 1066# Check for AT_FDCWD 1067 1068AC_MSG_CHECKING([for AT_FDCWD]) 1069AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1070#define _GNU_SOURCE 1071#include <fcntl.h> 1072#include <unistd.h> 1073]], [[ 1074 int a = AT_FDCWD; 1075]])], [ 1076ac_have_at_fdcwd=yes 1077AC_MSG_RESULT([yes]) 1078], [ 1079ac_have_at_fdcwd=no 1080AC_MSG_RESULT([no]) 1081]) 1082 1083AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes]) 1084 1085# Check for stpncpy function definition in string.h 1086# This explicitly checks with _GNU_SOURCE defined since that is also 1087# used in the test case (some systems might define it without anyway 1088# since stpncpy is part of The Open Group Base Specifications Issue 7 1089# IEEE Std 1003.1-2008. 1090AC_MSG_CHECKING([for stpncpy]) 1091AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 1092#define _GNU_SOURCE 1093#include <string.h> 1094]], [[ 1095 char *d; 1096 char *s; 1097 size_t n = 0; 1098 char *r = stpncpy(d, s, n); 1099]])], [ 1100ac_have_gnu_stpncpy=yes 1101AC_MSG_RESULT([yes]) 1102], [ 1103ac_have_gnu_stpncpy=no 1104AC_MSG_RESULT([no]) 1105]) 1106 1107AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes]) 1108 1109# Check for PTRACE_GETREGS 1110 1111AC_MSG_CHECKING([for PTRACE_GETREGS]) 1112AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1113#include <stdlib.h> 1114#include <stddef.h> 1115#include <sys/ptrace.h> 1116#include <sys/user.h> 1117]], [[ 1118 void *p; 1119 long res = ptrace (PTRACE_GETREGS, 0, p, p); 1120]])], [ 1121AC_MSG_RESULT([yes]) 1122AC_DEFINE([HAVE_PTRACE_GETREGS], 1, 1123 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.]) 1124], [ 1125AC_MSG_RESULT([no]) 1126]) 1127 1128 1129# Check for CLOCK_MONOTONIC 1130 1131AC_MSG_CHECKING([for CLOCK_MONOTONIC]) 1132 1133AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1134#include <time.h> 1135]], [[ 1136 struct timespec t; 1137 clock_gettime(CLOCK_MONOTONIC, &t); 1138 return 0; 1139]])], [ 1140AC_MSG_RESULT([yes]) 1141AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1, 1142 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.]) 1143], [ 1144AC_MSG_RESULT([no]) 1145]) 1146 1147 1148# Check for PTHREAD_RWLOCK_T 1149 1150AC_MSG_CHECKING([for pthread_rwlock_t]) 1151 1152AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1153#define _GNU_SOURCE 1154#include <pthread.h> 1155]], [[ 1156 pthread_rwlock_t rwl; 1157]])], [ 1158AC_MSG_RESULT([yes]) 1159AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1, 1160 [Define to 1 if you have the `pthread_rwlock_t' type.]) 1161], [ 1162AC_MSG_RESULT([no]) 1163]) 1164 1165 1166# Check for PTHREAD_MUTEX_ADAPTIVE_NP 1167 1168AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP]) 1169 1170AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1171#define _GNU_SOURCE 1172#include <pthread.h> 1173]], [[ 1174 return (PTHREAD_MUTEX_ADAPTIVE_NP); 1175]])], [ 1176AC_MSG_RESULT([yes]) 1177AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1, 1178 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.]) 1179], [ 1180AC_MSG_RESULT([no]) 1181]) 1182 1183 1184# Check for PTHREAD_MUTEX_ERRORCHECK_NP 1185 1186AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP]) 1187 1188AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1189#define _GNU_SOURCE 1190#include <pthread.h> 1191]], [[ 1192 return (PTHREAD_MUTEX_ERRORCHECK_NP); 1193]])], [ 1194AC_MSG_RESULT([yes]) 1195AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1, 1196 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.]) 1197], [ 1198AC_MSG_RESULT([no]) 1199]) 1200 1201 1202# Check for PTHREAD_MUTEX_RECURSIVE_NP 1203 1204AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP]) 1205 1206AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1207#define _GNU_SOURCE 1208#include <pthread.h> 1209]], [[ 1210 return (PTHREAD_MUTEX_RECURSIVE_NP); 1211]])], [ 1212AC_MSG_RESULT([yes]) 1213AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1, 1214 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.]) 1215], [ 1216AC_MSG_RESULT([no]) 1217]) 1218 1219 1220# Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP 1221 1222AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP]) 1223 1224AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1225#define _GNU_SOURCE 1226#include <pthread.h> 1227]], [[ 1228 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; 1229 return 0; 1230]])], [ 1231AC_MSG_RESULT([yes]) 1232AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1, 1233 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.]) 1234], [ 1235AC_MSG_RESULT([no]) 1236]) 1237 1238 1239# Check whether pthread_mutex_t has a member called __m_kind. 1240 1241AC_CHECK_MEMBER([pthread_mutex_t.__m_kind], 1242 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND], 1243 1, 1244 [Define to 1 if pthread_mutex_t has a member called __m_kind.]) 1245 ], 1246 [], 1247 [#include <pthread.h>]) 1248 1249 1250# Check whether pthread_mutex_t has a member called __data.__kind. 1251 1252AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind], 1253 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND], 1254 1, 1255 [Define to 1 if pthread_mutex_t has a member __data.__kind.]) 1256 ], 1257 [], 1258 [#include <pthread.h>]) 1259 1260 1261# does this compiler support -maltivec and does it have the include file 1262# <altivec.h> ? 1263 1264AC_MSG_CHECKING([for Altivec]) 1265 1266safe_CFLAGS=$CFLAGS 1267CFLAGS="-maltivec" 1268 1269AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1270#include <altivec.h> 1271]], [[ 1272 vector unsigned int v; 1273]])], [ 1274ac_have_altivec=yes 1275AC_MSG_RESULT([yes]) 1276AC_DEFINE([HAS_ALTIVEC], 1, 1277 [Define to 1 if gcc/as can do Altivec.]) 1278], [ 1279ac_have_altivec=no 1280AC_MSG_RESULT([no]) 1281]) 1282CFLAGS=$safe_CFLAGS 1283 1284AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes]) 1285 1286 1287# Check that both: the compiler supports -mvsx and that the assembler 1288# understands VSX instructions. If either of those doesn't work, 1289# conclude that we can't do VSX. NOTE: basically this is a kludge 1290# in that it conflates two things that should be separate -- whether 1291# the compiler understands the flag vs whether the assembler 1292# understands the opcodes. This really ought to be cleaned up 1293# and done properly, like it is for x86/x86_64. 1294 1295AC_MSG_CHECKING([for VSX]) 1296 1297safe_CFLAGS=$CFLAGS 1298CFLAGS="-mvsx" 1299 1300AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1301#include <altivec.h> 1302]], [[ 1303 vector unsigned int v; 1304 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc"); 1305]])], [ 1306ac_have_vsx=yes 1307AC_MSG_RESULT([yes]) 1308], [ 1309ac_have_vsx=no 1310AC_MSG_RESULT([no]) 1311]) 1312CFLAGS=$safe_CFLAGS 1313 1314AM_CONDITIONAL(HAS_VSX, test x$ac_have_vsx = xyes) 1315 1316 1317AC_MSG_CHECKING([that assembler knows DFP]) 1318 1319AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1320]], [[ 1321 __asm__ __volatile__("dadd 1, 2, 3"); 1322 __asm__ __volatile__("dcffix 1, 2"); 1323]])], [ 1324ac_asm_have_dfp=yes 1325AC_MSG_RESULT([yes]) 1326], [ 1327ac_asm_have_dfp=no 1328AC_MSG_RESULT([no]) 1329]) 1330 1331 1332AC_MSG_CHECKING([that compiler knows -mhard-dfp switch]) 1333safe_CFLAGS=$CFLAGS 1334CFLAGS="-mhard-dfp" 1335AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1336]], [[ 1337 __asm__ __volatile__("dadd 1, 2, 3"); 1338 __asm__ __volatile__("dcffix 1, 2"); 1339]])], [ 1340ac_gcc_have_dfp=yes 1341AC_MSG_RESULT([yes]) 1342], [ 1343ac_gcc_have_dfp=no 1344AC_MSG_RESULT([no]) 1345]) 1346 1347CFLAGS=$safe_CFLAGS 1348 1349AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes -a x$ac_gcc_have_dfp = xyes) 1350 1351 1352AC_MSG_CHECKING([that compiler knows DFP datatypes]) 1353AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1354]], [[ 1355 _Decimal64 x = 0.0DD; 1356]])], [ 1357ac_gcc_have_dfp_type=yes 1358AC_MSG_RESULT([yes]) 1359], [ 1360ac_gcc_have_dfp_type=no 1361AC_MSG_RESULT([no]) 1362]) 1363 1364AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_gcc_have_dfp_type = xyes) 1365 1366# isa 2.07 checking 1367AC_MSG_CHECKING([that assembler knows ISA 2.07 ]) 1368 1369AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1370]], [[ 1371 __asm__ __volatile__("mtvsrd 1,2 "); 1372]])], [ 1373ac_asm_have_isa_2_07=yes 1374AC_MSG_RESULT([yes]) 1375], [ 1376ac_asm_have_isa_2_07=no 1377AC_MSG_RESULT([no]) 1378]) 1379 1380AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes) 1381 1382# Check for pthread_create@GLIBC2.0 1383AC_MSG_CHECKING([for pthread_create@GLIBC2.0()]) 1384 1385safe_CFLAGS=$CFLAGS 1386CFLAGS="-lpthread" 1387AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 1388extern int pthread_create_glibc_2_0(void*, const void*, 1389 void *(*)(void*), void*); 1390__asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0"); 1391]], [[ 1392#ifdef __powerpc__ 1393/* 1394 * Apparently on PowerPC linking this program succeeds and generates an 1395 * executable with the undefined symbol pthread_create@GLIBC_2.0. 1396 */ 1397#error This test does not work properly on PowerPC. 1398#else 1399 pthread_create_glibc_2_0(0, 0, 0, 0); 1400#endif 1401 return 0; 1402]])], [ 1403ac_have_pthread_create_glibc_2_0=yes 1404AC_MSG_RESULT([yes]) 1405AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1, 1406 [Define to 1 if you have the `pthread_create@glibc2.0' function.]) 1407], [ 1408ac_have_pthread_create_glibc_2_0=no 1409AC_MSG_RESULT([no]) 1410]) 1411CFLAGS=$safe_CFLAGS 1412 1413AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0, 1414 test x$ac_have_pthread_create_glibc_2_0 = xyes) 1415 1416 1417# Check for dlinfo RTLD_DI_TLS_MODID 1418AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID]) 1419 1420safe_LIBS="$LIBS" 1421LIBS="-ldl" 1422AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 1423#ifndef _GNU_SOURCE 1424#define _GNU_SOURCE 1425#endif 1426#include <link.h> 1427#include <dlfcn.h> 1428]], [[ 1429 size_t sizes[10000]; 1430 size_t modid_offset; 1431 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset); 1432 return 0; 1433]])], [ 1434ac_have_dlinfo_rtld_di_tls_modid=yes 1435AC_MSG_RESULT([yes]) 1436AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1, 1437 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.]) 1438], [ 1439ac_have_dlinfo_rtld_di_tls_modid=no 1440AC_MSG_RESULT([no]) 1441]) 1442LIBS=$safe_LIBS 1443 1444AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID, 1445 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes) 1446 1447 1448# Check for eventfd_t, eventfd() and eventfd_read() 1449AC_MSG_CHECKING([for eventfd()]) 1450 1451AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 1452#include <sys/eventfd.h> 1453]], [[ 1454 eventfd_t ev; 1455 int fd; 1456 1457 fd = eventfd(5, 0); 1458 eventfd_read(fd, &ev); 1459 return 0; 1460]])], [ 1461AC_MSG_RESULT([yes]) 1462AC_DEFINE([HAVE_EVENTFD], 1, 1463 [Define to 1 if you have the `eventfd' function.]) 1464AC_DEFINE([HAVE_EVENTFD_READ], 1, 1465 [Define to 1 if you have the `eventfd_read' function.]) 1466], [ 1467AC_MSG_RESULT([no]) 1468]) 1469 1470# Check whether compiler can process #include <thread> without errors 1471# clang 3.3 cannot process <thread> from e.g. 1472# gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 1473 1474AC_MSG_CHECKING([that C++ compiler can include <thread> header file]) 1475AC_LANG(C++) 1476safe_CXXFLAGS=$CXXFLAGS 1477CXXFLAGS=-std=c++0x 1478 1479AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 1480#include <thread> 1481])], 1482[ 1483ac_cxx_can_include_thread_header=yes 1484AC_MSG_RESULT([yes]) 1485], [ 1486ac_cxx_can_include_thread_header=no 1487AC_MSG_RESULT([no]) 1488]) 1489CXXFLAGS=$safe_CXXFLAGS 1490AC_LANG(C) 1491 1492AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes) 1493 1494 1495# On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead 1496# of the user_regs_struct from sys/user.h. They are structurally the same 1497# but we get either one or the other. 1498 1499AC_CHECK_TYPE([struct user_regs_struct], 1500 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no], 1501 [[#include <sys/ptrace.h>] 1502 [#include <sys/time.h>] 1503 [#include <sys/user.h>]]) 1504if test "$sys_user_has_user_regs" = "yes"; then 1505 AC_DEFINE(HAVE_SYS_USER_REGS, 1, 1506 [Define to 1 if <sys/user.h> defines struct user_regs_struct]) 1507fi 1508 1509 1510#---------------------------------------------------------------------------- 1511# Checking for supported compiler flags. 1512#---------------------------------------------------------------------------- 1513 1514# does this compiler support -m32 ? 1515AC_MSG_CHECKING([if gcc accepts -m32]) 1516 1517safe_CFLAGS=$CFLAGS 1518CFLAGS="-m32" 1519 1520AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1521 return 0; 1522]])], [ 1523FLAG_M32="-m32" 1524AC_MSG_RESULT([yes]) 1525], [ 1526FLAG_M32="" 1527AC_MSG_RESULT([no]) 1528]) 1529CFLAGS=$safe_CFLAGS 1530 1531AC_SUBST(FLAG_M32) 1532 1533 1534# does this compiler support -m64 ? 1535AC_MSG_CHECKING([if gcc accepts -m64]) 1536 1537safe_CFLAGS=$CFLAGS 1538CFLAGS="-m64" 1539 1540AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1541 return 0; 1542]])], [ 1543FLAG_M64="-m64" 1544AC_MSG_RESULT([yes]) 1545], [ 1546FLAG_M64="" 1547AC_MSG_RESULT([no]) 1548]) 1549CFLAGS=$safe_CFLAGS 1550 1551AC_SUBST(FLAG_M64) 1552 1553 1554# does this compiler support -march=mips32 (mips32 default) ? 1555AC_MSG_CHECKING([if gcc accepts -march=mips32]) 1556 1557safe_CFLAGS=$CFLAGS 1558CFLAGS="$CFLAGS -march=mips32" 1559 1560AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1561 return 0; 1562]])], [ 1563FLAG_MIPS32="-march=mips32" 1564AC_MSG_RESULT([yes]) 1565], [ 1566FLAG_MIPS32="" 1567AC_MSG_RESULT([no]) 1568]) 1569CFLAGS=$safe_CFLAGS 1570 1571AC_SUBST(FLAG_MIPS32) 1572 1573 1574# does this compiler support -march=mips64 (mips64 default) ? 1575AC_MSG_CHECKING([if gcc accepts -march=mips64]) 1576 1577safe_CFLAGS=$CFLAGS 1578CFLAGS="$CFLAGS -march=mips64" 1579 1580AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1581 return 0; 1582]])], [ 1583FLAG_MIPS64="-march=mips64" 1584AC_MSG_RESULT([yes]) 1585], [ 1586FLAG_MIPS64="" 1587AC_MSG_RESULT([no]) 1588]) 1589CFLAGS=$safe_CFLAGS 1590 1591AC_SUBST(FLAG_MIPS64) 1592 1593 1594# does this compiler support -march=octeon (Cavium OCTEON I Specific) ? 1595AC_MSG_CHECKING([if gcc accepts -march=octeon]) 1596 1597safe_CFLAGS=$CFLAGS 1598CFLAGS="$CFLAGS -march=octeon" 1599 1600AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1601 return 0; 1602]])], [ 1603FLAG_OCTEON="-march=octeon" 1604AC_MSG_RESULT([yes]) 1605], [ 1606FLAG_OCTEON="" 1607AC_MSG_RESULT([no]) 1608]) 1609CFLAGS=$safe_CFLAGS 1610 1611AC_SUBST(FLAG_OCTEON) 1612 1613 1614# does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ? 1615AC_MSG_CHECKING([if gcc accepts -march=octeon2]) 1616 1617safe_CFLAGS=$CFLAGS 1618CFLAGS="$CFLAGS -march=octeon2" 1619 1620AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1621 return 0; 1622]])], [ 1623FLAG_OCTEON2="-march=octeon2" 1624AC_MSG_RESULT([yes]) 1625], [ 1626FLAG_OCTEON2="" 1627AC_MSG_RESULT([no]) 1628]) 1629CFLAGS=$safe_CFLAGS 1630 1631AC_SUBST(FLAG_OCTEON2) 1632 1633 1634# does this compiler support -mmmx ? 1635AC_MSG_CHECKING([if gcc accepts -mmmx]) 1636 1637safe_CFLAGS=$CFLAGS 1638CFLAGS="-mmmx" 1639 1640AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1641 return 0; 1642]])], [ 1643FLAG_MMMX="-mmmx" 1644AC_MSG_RESULT([yes]) 1645], [ 1646FLAG_MMMX="" 1647AC_MSG_RESULT([no]) 1648]) 1649CFLAGS=$safe_CFLAGS 1650 1651AC_SUBST(FLAG_MMMX) 1652 1653 1654# does this compiler support -msse ? 1655AC_MSG_CHECKING([if gcc accepts -msse]) 1656 1657safe_CFLAGS=$CFLAGS 1658CFLAGS="-msse" 1659 1660AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1661 return 0; 1662]])], [ 1663FLAG_MSSE="-msse" 1664AC_MSG_RESULT([yes]) 1665], [ 1666FLAG_MSSE="" 1667AC_MSG_RESULT([no]) 1668]) 1669CFLAGS=$safe_CFLAGS 1670 1671AC_SUBST(FLAG_MSSE) 1672 1673 1674# does this compiler support -mpreferred-stack-boundary=2 when 1675# generating code for a 32-bit target? Note that we only care about 1676# this when generating code for (32-bit) x86, so if the compiler 1677# doesn't recognise -m32 it's no big deal. We'll just get code for 1678# the Memcheck and other helper functions, that is a bit slower than 1679# it could be, on x86; and no difference at all on any other platform. 1680AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32]) 1681 1682safe_CFLAGS=$CFLAGS 1683CFLAGS="-mpreferred-stack-boundary=2 -m32" 1684 1685AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1686 return 0; 1687]])], [ 1688PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2" 1689AC_MSG_RESULT([yes]) 1690], [ 1691PREFERRED_STACK_BOUNDARY_2="" 1692AC_MSG_RESULT([no]) 1693]) 1694CFLAGS=$safe_CFLAGS 1695 1696AC_SUBST(PREFERRED_STACK_BOUNDARY_2) 1697 1698 1699# Convenience function to check whether GCC supports a particular 1700# warning option. Takes two arguments, first the warning flag name 1701# to check (without -W), then the conditional name to set if that 1702# warning flag is supported. 1703AC_DEFUN([AC_GCC_WARNING_COND],[ 1704 AC_MSG_CHECKING([if gcc accepts -W$1]) 1705 safe_CFLAGS=$CFLAGS 1706 CFLAGS="-W$1" 1707 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [ 1708 has_warning_flag=yes 1709 AC_MSG_RESULT([yes])], [ 1710 has_warning_flag=no 1711 AC_MSG_RESULT([no])]) 1712 CFLAGS=$safe_CFLAGS 1713 AM_CONDITIONAL([$2], test x$has_warning_flag = xyes) 1714]) 1715 1716AC_GCC_WARNING_COND([pointer-sign], [HAS_POINTER_SIGN_WARNING]) 1717 1718# Convenience function to check whether GCC supports a particular 1719# warning option. Similar to AC_GCC_WARNING_COND, but does a 1720# substitution instead of setting an conditional. Takes two arguments, 1721# first the warning flag name to check (without -W), then the 1722# substitution name to set with -Wno-warning-flag if the flag exists, 1723# or the empty string if the compiler doesn't accept the flag. Note 1724# that checking is done against the warning flag itself, but the 1725# substitution is then done to cancel the warning flag. 1726AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[ 1727 AC_MSG_CHECKING([if gcc accepts -W$1]) 1728 safe_CFLAGS=$CFLAGS 1729 CFLAGS="-W$1" 1730 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [ 1731 AC_SUBST([$2], [-Wno-$1]) 1732 AC_MSG_RESULT([yes])], [ 1733 AC_SUBST([$2], []) 1734 AC_MSG_RESULT([no])]) 1735 CFLAGS=$safe_CFLAGS 1736]) 1737 1738# Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes 1739# -W$1 (instead of -Wno-$1). 1740AC_DEFUN([AC_GCC_WARNING_SUBST],[ 1741 AC_MSG_CHECKING([if gcc accepts -W$1]) 1742 safe_CFLAGS=$CFLAGS 1743 CFLAGS="-W$1" 1744 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [ 1745 AC_SUBST([$2], [-W$1]) 1746 AC_MSG_RESULT([yes])], [ 1747 AC_SUBST([$2], []) 1748 AC_MSG_RESULT([no])]) 1749 CFLAGS=$safe_CFLAGS 1750]) 1751 1752AC_GCC_WARNING_SUBST_NO([empty-body], [FLAG_W_NO_EMPTY_BODY]) 1753AC_GCC_WARNING_SUBST_NO([format-zero-length], [FLAG_W_NO_FORMAT_ZERO_LENGTH]) 1754AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL]) 1755AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW]) 1756AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED]) 1757AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION]) 1758AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE]) 1759AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS]) 1760AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT]) 1761AC_GCC_WARNING_SUBST([format-security], [FLAG_W_FORMAT_SECURITY]) 1762AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL]) 1763AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION]) 1764AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS]) 1765AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE]) 1766 1767# does this compiler support -Wextra or the older -W ? 1768 1769AC_MSG_CHECKING([if gcc accepts -Wextra or -W]) 1770 1771safe_CFLAGS=$CFLAGS 1772CFLAGS="-Wextra" 1773 1774AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ 1775 return 0; 1776]])], [ 1777AC_SUBST([FLAG_W_EXTRA], [-Wextra]) 1778AC_MSG_RESULT([-Wextra]) 1779], [ 1780 CFLAGS="-W" 1781 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ 1782 return 0; 1783 ]])], [ 1784 AC_SUBST([FLAG_W_EXTRA], [-W]) 1785 AC_MSG_RESULT([-W]) 1786 ], [ 1787 AC_SUBST([FLAG_W_EXTRA], []) 1788 AC_MSG_RESULT([not supported]) 1789 ]) 1790]) 1791CFLAGS=$safe_CFLAGS 1792 1793# does this compiler support -fno-stack-protector ? 1794AC_MSG_CHECKING([if gcc accepts -fno-stack-protector]) 1795 1796safe_CFLAGS=$CFLAGS 1797CFLAGS="-fno-stack-protector" 1798 1799AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1800 return 0; 1801]])], [ 1802no_stack_protector=yes 1803FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector" 1804AC_MSG_RESULT([yes]) 1805], [ 1806no_stack_protector=no 1807FLAG_FNO_STACK_PROTECTOR="" 1808AC_MSG_RESULT([no]) 1809]) 1810CFLAGS=$safe_CFLAGS 1811 1812AC_SUBST(FLAG_FNO_STACK_PROTECTOR) 1813 1814 1815# Does this compiler support -fsanitize=undefined? 1816# Only checked for if --enable-ubsan was given. 1817if test "x${vg_cv_ubsan}" = "xyes"; then 1818AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined]) 1819safe_CFLAGS=$CFLAGS 1820CFLAGS="-fsanitize=undefined" 1821AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1822 return 0; 1823]])], [ 1824FLAG_FSANITIZE="-fsanitize=undefined" 1825LIB_UBSAN="-static-libubsan" 1826AC_MSG_RESULT([yes]) 1827], [ 1828FLAG_FSANITIZE="" 1829LIB_UBSAN="" 1830AC_MSG_RESULT([no]) 1831]) 1832CFLAGS=$safe_CFLAGS 1833AC_SUBST(FLAG_FSANITIZE) 1834AC_SUBST(LIB_UBSAN) 1835fi 1836# does this compiler support --param inline-unit-growth=... ? 1837 1838AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth]) 1839 1840safe_CFLAGS=$CFLAGS 1841CFLAGS="--param inline-unit-growth=900" 1842 1843AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ 1844 return 0; 1845]])], [ 1846AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], 1847 ["--param inline-unit-growth=900"]) 1848AC_MSG_RESULT([yes]) 1849], [ 1850AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""]) 1851AC_MSG_RESULT([no]) 1852]) 1853CFLAGS=$safe_CFLAGS 1854 1855 1856# does this compiler support -gdwarf-4 -fdebug-types-section ? 1857 1858AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section]) 1859 1860safe_CFLAGS=$CFLAGS 1861CFLAGS="-gdwarf-4 -fdebug-types-section" 1862 1863AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ 1864 return 0; 1865]])], [ 1866ac_have_dwarf4=yes 1867AC_MSG_RESULT([yes]) 1868], [ 1869ac_have_dwarf4=no 1870AC_MSG_RESULT([no]) 1871]) 1872AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes) 1873CFLAGS=$safe_CFLAGS 1874 1875 1876# does this compiler support nested functions ? 1877 1878AC_MSG_CHECKING([if gcc accepts nested functions]) 1879 1880AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1881 int foo() { return 1; } 1882 return foo(); 1883]])], [ 1884ac_have_nested_functions=yes 1885AC_MSG_RESULT([yes]) 1886], [ 1887ac_have_nested_functions=no 1888AC_MSG_RESULT([no]) 1889]) 1890AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes]) 1891 1892 1893# does this compiler support the 'p' constraint in ASM statements ? 1894 1895AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements]) 1896 1897AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1898 char *p; 1899 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p)); 1900]])], [ 1901ac_have_asm_constraint_p=yes 1902AC_MSG_RESULT([yes]) 1903], [ 1904ac_have_asm_constraint_p=no 1905AC_MSG_RESULT([no]) 1906]) 1907AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes]) 1908 1909 1910# We want to use use the -Ttext-segment option to the linker. 1911# GNU (bfd) ld supports this directly. Newer GNU gold linkers 1912# support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext 1913# semantics are NOT what we want (GNU gold -Ttext is fine). 1914# 1915# For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers 1916# will reside. -Ttext aligns just the .text section start (but not any 1917# other section). 1918# 1919# So test for -Ttext-segment which is supported by all bfd ld versions 1920# and use that if it exists. If it doesn't exist it must be an older 1921# version of gold and we can fall back to using -Ttext which has the 1922# right semantics. 1923 1924AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment]) 1925 1926safe_CFLAGS=$CFLAGS 1927CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml" 1928 1929AC_LINK_IFELSE( 1930[AC_LANG_SOURCE([int _start () { return 0; }])], 1931[ 1932 linker_using_t_text="no" 1933 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"]) 1934 AC_MSG_RESULT([yes]) 1935], [ 1936 linker_using_t_text="yes" 1937 AC_SUBST([FLAG_T_TEXT], ["-Ttext"]) 1938 AC_MSG_RESULT([no]) 1939]) 1940CFLAGS=$safe_CFLAGS 1941 1942# If the linker only supports -Ttext (not -Ttext-segment) then we will 1943# have to strip any build-id ELF NOTEs from the staticly linked tools. 1944# Otherwise the build-id NOTE might end up at the default load address. 1945# (Pedantically if the linker is gold then -Ttext is fine, but newer 1946# gold versions also support -Ttext-segment. So just assume that unless 1947# we can use -Ttext-segment we need to strip the build-id NOTEs. 1948if test "x${linker_using_t_text}" = "xyes"; then 1949AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.]) 1950# does the linker support -Wl,--build-id=none ? Note, it's 1951# important that we test indirectly via whichever C compiler 1952# is selected, rather than testing /usr/bin/ld or whatever 1953# directly. 1954AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none]) 1955safe_CFLAGS=$CFLAGS 1956CFLAGS="-Wl,--build-id=none" 1957 1958AC_LINK_IFELSE( 1959[AC_LANG_PROGRAM([ ], [return 0;])], 1960[ 1961 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"]) 1962 AC_MSG_RESULT([yes]) 1963], [ 1964 AC_SUBST([FLAG_NO_BUILD_ID], [""]) 1965 AC_MSG_RESULT([no]) 1966]) 1967else 1968AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.]) 1969AC_SUBST([FLAG_NO_BUILD_ID], [""]) 1970fi 1971CFLAGS=$safe_CFLAGS 1972 1973# does the ppc assembler support "mtocrf" et al? 1974AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf]) 1975 1976AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1977__asm__ __volatile__("mtocrf 4,0"); 1978__asm__ __volatile__("mfocrf 0,4"); 1979]])], [ 1980ac_have_as_ppc_mftocrf=yes 1981AC_MSG_RESULT([yes]) 1982], [ 1983ac_have_as_ppc_mftocrf=no 1984AC_MSG_RESULT([no]) 1985]) 1986if test x$ac_have_as_ppc_mftocrf = xyes ; then 1987 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.]) 1988fi 1989 1990 1991# does the ppc assembler support "lfdp" and other phased out floating point insns? 1992AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions]) 1993 1994AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 1995 do { typedef struct { 1996 double hi; 1997 double lo; 1998 } dbl_pair_t; 1999 dbl_pair_t dbl_pair[3]; 2000 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0])); 2001 } while (0) 2002]])], [ 2003ac_have_as_ppc_fpPO=yes 2004AC_MSG_RESULT([yes]) 2005], [ 2006ac_have_as_ppc_fpPO=no 2007AC_MSG_RESULT([no]) 2008]) 2009if test x$ac_have_as_ppc_fpPO = xyes ; then 2010 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.]) 2011fi 2012 2013 2014# does the x86/amd64 assembler understand SSE3 instructions? 2015# Note, this doesn't generate a C-level symbol. It generates a 2016# automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's 2017AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3]) 2018 2019AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2020 do { long long int x; 2021 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); } 2022 while (0) 2023]])], [ 2024ac_have_as_sse3=yes 2025AC_MSG_RESULT([yes]) 2026], [ 2027ac_have_as_sse3=no 2028AC_MSG_RESULT([no]) 2029]) 2030 2031AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes) 2032 2033 2034# Ditto for SSSE3 instructions (note extra S) 2035# Note, this doesn't generate a C-level symbol. It generates a 2036# automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's 2037AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3]) 2038 2039save_CFLAGS="$CFLAGS" 2040CFLAGS="$CFLAGS -msse" 2041AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2042 do { long long int x; 2043 __asm__ __volatile__( 2044 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); } 2045 while (0) 2046]])], [ 2047ac_have_as_ssse3=yes 2048AC_MSG_RESULT([yes]) 2049], [ 2050ac_have_as_ssse3=no 2051AC_MSG_RESULT([no]) 2052]) 2053CFLAGS="$save_CFLAGS" 2054 2055AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes) 2056 2057 2058# does the x86/amd64 assembler understand the PCLMULQDQ instruction? 2059# Note, this doesn't generate a C-level symbol. It generates a 2060# automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's 2061AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq']) 2062AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2063 do { 2064 __asm__ __volatile__( 2065 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); } 2066 while (0) 2067]])], [ 2068ac_have_as_pclmulqdq=yes 2069AC_MSG_RESULT([yes]) 2070], [ 2071ac_have_as_pclmulqdq=no 2072AC_MSG_RESULT([no]) 2073]) 2074 2075AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes) 2076 2077 2078# does the x86/amd64 assembler understand the VPCLMULQDQ instruction? 2079# Note, this doesn't generate a C-level symbol. It generates a 2080# automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's 2081AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq']) 2082AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2083 do { 2084 /* 2085 * Carry-less multiplication of xmm1 with xmm2 and store the result in 2086 * xmm3. The immediate is used to determine which quadwords of xmm1 and 2087 * xmm2 should be used. 2088 */ 2089 __asm__ __volatile__( 2090 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : ); 2091 } while (0) 2092]])], [ 2093ac_have_as_vpclmulqdq=yes 2094AC_MSG_RESULT([yes]) 2095], [ 2096ac_have_as_vpclmulqdq=no 2097AC_MSG_RESULT([no]) 2098]) 2099 2100AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes) 2101 2102 2103# does the x86/amd64 assembler understand the LZCNT instruction? 2104# Note, this doesn't generate a C-level symbol. It generates a 2105# automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's 2106AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt']) 2107 2108AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2109 do { 2110 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax"); 2111 } while (0) 2112]])], [ 2113 ac_have_as_lzcnt=yes 2114 AC_MSG_RESULT([yes]) 2115], [ 2116 ac_have_as_lzcnt=no 2117 AC_MSG_RESULT([no]) 2118]) 2119 2120AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes]) 2121 2122 2123# does the x86/amd64 assembler understand the LOOPNEL instruction? 2124# Note, this doesn't generate a C-level symbol. It generates a 2125# automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's 2126AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel']) 2127 2128AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2129 do { 2130 __asm__ __volatile__("1: loopnel 1b\n"); 2131 } while (0) 2132]])], [ 2133 ac_have_as_loopnel=yes 2134 AC_MSG_RESULT([yes]) 2135], [ 2136 ac_have_as_loopnel=no 2137 AC_MSG_RESULT([no]) 2138]) 2139 2140AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes]) 2141 2142 2143# does the x86/amd64 assembler understand ADDR32 ? 2144# Note, this doesn't generate a C-level symbol. It generates a 2145# automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's 2146AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32']) 2147 2148AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2149 do { 2150 asm volatile ("addr32 rep movsb"); 2151 } while (0) 2152]])], [ 2153 ac_have_as_addr32=yes 2154 AC_MSG_RESULT([yes]) 2155], [ 2156 ac_have_as_addr32=no 2157 AC_MSG_RESULT([no]) 2158]) 2159 2160AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes]) 2161 2162 2163# does the x86/amd64 assembler understand SSE 4.2 instructions? 2164# Note, this doesn't generate a C-level symbol. It generates a 2165# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's 2166AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2]) 2167 2168AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2169 do { long long int x; 2170 __asm__ __volatile__( 2171 "crc32q %%r15,%%r15" : : : "r15" ); 2172 __asm__ __volatile__( 2173 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 2174 __asm__ __volatile__( 2175 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); } 2176 while (0) 2177]])], [ 2178ac_have_as_sse42=yes 2179AC_MSG_RESULT([yes]) 2180], [ 2181ac_have_as_sse42=no 2182AC_MSG_RESULT([no]) 2183]) 2184 2185AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes) 2186 2187 2188# does the x86/amd64 assembler understand AVX instructions? 2189# Note, this doesn't generate a C-level symbol. It generates a 2190# automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's 2191AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX]) 2192 2193AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2194 do { long long int x; 2195 __asm__ __volatile__( 2196 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" ); 2197 __asm__ __volatile__( 2198 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); } 2199 while (0) 2200]])], [ 2201ac_have_as_avx=yes 2202AC_MSG_RESULT([yes]) 2203], [ 2204ac_have_as_avx=no 2205AC_MSG_RESULT([no]) 2206]) 2207 2208AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes) 2209 2210 2211# does the x86/amd64 assembler understand AVX2 instructions? 2212# Note, this doesn't generate a C-level symbol. It generates a 2213# automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's 2214AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2]) 2215 2216AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2217 do { long long int x; 2218 __asm__ __volatile__( 2219 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" ); 2220 __asm__ __volatile__( 2221 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); } 2222 while (0) 2223]])], [ 2224ac_have_as_avx2=yes 2225AC_MSG_RESULT([yes]) 2226], [ 2227ac_have_as_avx2=no 2228AC_MSG_RESULT([no]) 2229]) 2230 2231AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes) 2232 2233 2234# does the x86/amd64 assembler understand TSX instructions and 2235# the XACQUIRE/XRELEASE prefixes? 2236# Note, this doesn't generate a C-level symbol. It generates a 2237# automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's 2238AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX]) 2239 2240AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2241 do { 2242 __asm__ __volatile__( 2243 " xbegin Lfoo \n\t" 2244 "Lfoo: xend \n\t" 2245 " xacquire lock incq 0(%rsp) \n\t" 2246 " xrelease lock incq 0(%rsp) \n" 2247 ); 2248 } while (0) 2249]])], [ 2250ac_have_as_tsx=yes 2251AC_MSG_RESULT([yes]) 2252], [ 2253ac_have_as_tsx=no 2254AC_MSG_RESULT([no]) 2255]) 2256 2257AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes) 2258 2259 2260# does the x86/amd64 assembler understand BMI1 and BMI2 instructions? 2261# Note, this doesn't generate a C-level symbol. It generates a 2262# automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's 2263AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2]) 2264 2265AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2266 do { unsigned int h, l; 2267 __asm__ __volatile__( "mulx %rax,%rcx,%r8" ); 2268 __asm__ __volatile__( 2269 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) ); 2270 __asm__ __volatile__( 2271 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); } 2272 while (0) 2273]])], [ 2274ac_have_as_bmi=yes 2275AC_MSG_RESULT([yes]) 2276], [ 2277ac_have_as_bmi=no 2278AC_MSG_RESULT([no]) 2279]) 2280 2281AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes) 2282 2283 2284# does the x86/amd64 assembler understand FMA instructions? 2285# Note, this doesn't generate a C-level symbol. It generates a 2286# automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's 2287AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA]) 2288 2289AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2290 do { unsigned int h, l; 2291 __asm__ __volatile__( 2292 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" ); 2293 __asm__ __volatile__( 2294 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); 2295 __asm__ __volatile__( 2296 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); } 2297 while (0) 2298]])], [ 2299ac_have_as_fma=yes 2300AC_MSG_RESULT([yes]) 2301], [ 2302ac_have_as_fma=no 2303AC_MSG_RESULT([no]) 2304]) 2305 2306AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes) 2307 2308 2309# does the amd64 assembler understand MPX instructions? 2310# Note, this doesn't generate a C-level symbol. It generates a 2311# automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's 2312AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions]) 2313 2314AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2315 do { 2316 asm ("bndmov %bnd0,(%rsp)"); 2317 asm ("bndldx 3(%rbx,%rdx), %bnd2"); 2318 } while (0) 2319]])], [ 2320ac_have_as_mpx=yes 2321AC_MSG_RESULT([yes]) 2322], [ 2323ac_have_as_mpx=no 2324AC_MSG_RESULT([no]) 2325]) 2326 2327AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes) 2328 2329 2330# Does the C compiler support the "ifunc" attribute 2331# Note, this doesn't generate a C-level symbol. It generates a 2332# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's 2333# does the x86/amd64 assembler understand MOVBE? 2334# Note, this doesn't generate a C-level symbol. It generates a 2335# automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's 2336AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn]) 2337 2338AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ 2339 do { long long int x; 2340 __asm__ __volatile__( 2341 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); } 2342 while (0) 2343]])], [ 2344ac_have_as_movbe=yes 2345AC_MSG_RESULT([yes]) 2346], [ 2347ac_have_as_movbe=no 2348AC_MSG_RESULT([no]) 2349]) 2350 2351AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes) 2352 2353 2354# Does the C compiler support the "ifunc" attribute 2355# Note, this doesn't generate a C-level symbol. It generates a 2356# automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's 2357AC_MSG_CHECKING([if gcc supports the ifunc attribute]) 2358 2359AC_LINK_IFELSE([AC_LANG_SOURCE([[ 2360static void mytest(void) {} 2361 2362static void (*resolve_test(void))(void) 2363{ 2364 return (void (*)(void))&mytest; 2365} 2366 2367void test(void) __attribute__((ifunc("resolve_test"))); 2368 2369int main() 2370{ 2371 test(); 2372 return 0; 2373} 2374]])], [ 2375ac_have_ifunc_attr=yes 2376AC_MSG_RESULT([yes]) 2377], [ 2378ac_have_ifunc_attr=no 2379AC_MSG_RESULT([no]) 2380]) 2381 2382AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes) 2383 2384 2385# XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this 2386# when building the tool executables. I think we should get rid of it. 2387# 2388# Check for TLS support in the compiler and linker 2389AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]], 2390 [[return foo;]])], 2391 [vg_cv_linktime_tls=yes], 2392 [vg_cv_linktime_tls=no]) 2393# Native compilation: check whether running a program using TLS succeeds. 2394# Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs 2395# succeeds but running programs using TLS fails. 2396# Cross-compiling: check whether linking a program using TLS succeeds. 2397AC_CACHE_CHECK([for TLS support], vg_cv_tls, 2398 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS], 2399 [vg_cv_tls=$enableval], 2400 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]], 2401 [[return foo;]])], 2402 [vg_cv_tls=yes], 2403 [vg_cv_tls=no], 2404 [vg_cv_tls=$vg_cv_linktime_tls])])]) 2405 2406if test "$vg_cv_tls" = yes; then 2407AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables]) 2408fi 2409 2410 2411#---------------------------------------------------------------------------- 2412# Checks for C header files. 2413#---------------------------------------------------------------------------- 2414 2415AC_HEADER_STDC 2416AC_CHECK_HEADERS([ \ 2417 asm/unistd.h \ 2418 endian.h \ 2419 mqueue.h \ 2420 sys/endian.h \ 2421 sys/epoll.h \ 2422 sys/eventfd.h \ 2423 sys/klog.h \ 2424 sys/poll.h \ 2425 sys/signal.h \ 2426 sys/signalfd.h \ 2427 sys/syscall.h \ 2428 sys/time.h \ 2429 sys/types.h \ 2430 ]) 2431 2432# Verify whether the <linux/futex.h> header is usable. 2433AC_MSG_CHECKING([if <linux/futex.h> is usable]) 2434 2435save_CFLAGS="$CFLAGS" 2436CFLAGS="$CFLAGS -D__user=" 2437AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2438#include <linux/futex.h> 2439]], [[ 2440 return FUTEX_WAIT; 2441]])], [ 2442ac_have_usable_linux_futex_h=yes 2443AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1, 2444 [Define to 1 if you have a usable <linux/futex.h> header file.]) 2445AC_MSG_RESULT([yes]) 2446], [ 2447ac_have_usable_linux_futex_h=no 2448AC_MSG_RESULT([no]) 2449]) 2450CFLAGS="$save_CFLAGS" 2451 2452 2453#---------------------------------------------------------------------------- 2454# Checks for typedefs, structures, and compiler characteristics. 2455#---------------------------------------------------------------------------- 2456AC_TYPE_UID_T 2457AC_TYPE_OFF_T 2458AC_TYPE_SIZE_T 2459AC_HEADER_TIME 2460 2461 2462#---------------------------------------------------------------------------- 2463# Checks for library functions. 2464#---------------------------------------------------------------------------- 2465AC_FUNC_MEMCMP 2466AC_FUNC_MMAP 2467 2468AC_CHECK_LIB([pthread], [pthread_create]) 2469AC_CHECK_LIB([rt], [clock_gettime]) 2470 2471AC_CHECK_FUNCS([ \ 2472 clock_gettime\ 2473 epoll_create \ 2474 epoll_pwait \ 2475 klogctl \ 2476 mallinfo \ 2477 memchr \ 2478 memset \ 2479 mkdir \ 2480 mremap \ 2481 ppoll \ 2482 pthread_barrier_init \ 2483 pthread_condattr_setclock \ 2484 pthread_mutex_timedlock \ 2485 pthread_rwlock_timedrdlock \ 2486 pthread_rwlock_timedwrlock \ 2487 pthread_spin_lock \ 2488 pthread_yield \ 2489 pthread_setname_np \ 2490 readlinkat \ 2491 semtimedop \ 2492 signalfd \ 2493 sigwaitinfo \ 2494 strchr \ 2495 strdup \ 2496 strpbrk \ 2497 strrchr \ 2498 strstr \ 2499 syscall \ 2500 utimensat \ 2501 process_vm_readv \ 2502 process_vm_writev \ 2503 ]) 2504 2505# AC_CHECK_LIB adds any library found to the variable LIBS, and links these 2506# libraries with any shared object and/or executable. This is NOT what we 2507# want for e.g. vgpreload_core-x86-linux.so 2508LIBS="" 2509 2510AM_CONDITIONAL([HAVE_PTHREAD_BARRIER], 2511 [test x$ac_cv_func_pthread_barrier_init = xyes]) 2512AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK], 2513 [test x$ac_cv_func_pthread_mutex_timedlock = xyes]) 2514AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK], 2515 [test x$ac_cv_func_pthread_spin_lock = xyes]) 2516AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP], 2517 [test x$ac_cv_func_pthread_setname_np = xyes]) 2518 2519if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ 2520 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then 2521 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1, 2522 [Disable intercept pthread_spin_lock() on MIPS32 and MIPS64.]) 2523fi 2524 2525#---------------------------------------------------------------------------- 2526# MPI checks 2527#---------------------------------------------------------------------------- 2528# Do we have a useable MPI setup on the primary and/or secondary targets? 2529# On Linux, by default, assumes mpicc and -m32/-m64 2530# Note: this is a kludge in that it assumes the specified mpicc 2531# understands -m32/-m64 regardless of what is specified using 2532# --with-mpicc=. 2533AC_PATH_PROG([MPI_CC], [mpicc], [mpicc], 2534 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin]) 2535 2536mflag_primary= 2537if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \ 2538 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \ 2539 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \ 2540 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \ 2541 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX ; then 2542 mflag_primary=$FLAG_M32 2543elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \ 2544 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \ 2545 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \ 2546 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then 2547 mflag_primary=$FLAG_M64 2548elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then 2549 mflag_primary="$FLAG_M32 -arch i386" 2550elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then 2551 mflag_primary="$FLAG_M64 -arch x86_64" 2552fi 2553 2554mflag_secondary= 2555if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \ 2556 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX ; then 2557 mflag_secondary=$FLAG_M32 2558elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then 2559 mflag_secondary="$FLAG_M32 -arch i386" 2560fi 2561 2562 2563AC_ARG_WITH(mpicc, 2564 [ --with-mpicc= Specify name of MPI2-ised C compiler], 2565 MPI_CC=$withval 2566) 2567AC_SUBST(MPI_CC) 2568 2569## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can 2570## use these values in the check for a functioning mpicc. 2571## 2572## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that 2573## mflag_primary/mflag_secondary are sufficient approximations of that behavior 2574AM_COND_IF([VGCONF_OS_IS_LINUX], 2575 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic" 2576 LDFLAGS_MPI="-fpic -shared"]) 2577AM_COND_IF([VGCONF_OS_IS_DARWIN], 2578 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic" 2579 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"]) 2580 2581AC_SUBST([CFLAGS_MPI]) 2582AC_SUBST([LDFLAGS_MPI]) 2583 2584 2585## See if MPI_CC works for the primary target 2586## 2587AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h]) 2588saved_CC=$CC 2589saved_CFLAGS=$CFLAGS 2590CC=$MPI_CC 2591CFLAGS="$CFLAGS_MPI $mflag_primary" 2592saved_LDFLAGS="$LDFLAGS" 2593LDFLAGS="$LDFLAGS_MPI $mflag_primary" 2594AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2595#include <mpi.h> 2596#include <stdio.h> 2597]], [[ 2598 int ni, na, nd, comb; 2599 int r = MPI_Init(NULL,NULL); 2600 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb ); 2601 r |= MPI_Finalize(); 2602 return r; 2603]])], [ 2604ac_have_mpi2_pri=yes 2605AC_MSG_RESULT([yes, $MPI_CC]) 2606], [ 2607ac_have_mpi2_pri=no 2608AC_MSG_RESULT([no]) 2609]) 2610CC=$saved_CC 2611CFLAGS=$saved_CFLAGS 2612LDFLAGS="$saved_LDFLAGS" 2613AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes) 2614 2615## See if MPI_CC works for the secondary target. Complication: what if 2616## there is no secondary target? We need this to then fail. 2617## Kludge this by making MPI_CC something which will surely fail in 2618## such a case. 2619## 2620AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h]) 2621saved_CC=$CC 2622saved_CFLAGS=$CFLAGS 2623saved_LDFLAGS="$LDFLAGS" 2624LDFLAGS="$LDFLAGS_MPI $mflag_secondary" 2625if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then 2626 CC="$MPI_CC this will surely fail" 2627else 2628 CC=$MPI_CC 2629fi 2630CFLAGS="$CFLAGS_MPI $mflag_secondary" 2631AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2632#include <mpi.h> 2633#include <stdio.h> 2634]], [[ 2635 int ni, na, nd, comb; 2636 int r = MPI_Init(NULL,NULL); 2637 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb ); 2638 r |= MPI_Finalize(); 2639 return r; 2640]])], [ 2641ac_have_mpi2_sec=yes 2642AC_MSG_RESULT([yes, $MPI_CC]) 2643], [ 2644ac_have_mpi2_sec=no 2645AC_MSG_RESULT([no]) 2646]) 2647CC=$saved_CC 2648CFLAGS=$saved_CFLAGS 2649LDFLAGS="$saved_LDFLAGS" 2650AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes) 2651 2652 2653#---------------------------------------------------------------------------- 2654# Other library checks 2655#---------------------------------------------------------------------------- 2656# There now follow some tests for Boost, and OpenMP. These 2657# tests are present because Drd has some regression tests that use 2658# these packages. All regression test programs all compiled only 2659# for the primary target. And so it is important that the configure 2660# checks that follow, use the correct -m32 or -m64 flag for the 2661# primary target (called $mflag_primary). Otherwise, we can end up 2662# in a situation (eg) where, on amd64-linux, the test for Boost checks 2663# for usable 64-bit Boost facilities, but because we are doing a 32-bit 2664# only build (meaning, the primary target is x86-linux), the build 2665# of the regtest programs that use Boost fails, because they are 2666# build as 32-bit (IN THIS EXAMPLE). 2667# 2668# Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES 2669# NEEDED BY THE REGRESSION TEST PROGRAMS. 2670 2671 2672# Check whether the boost library 1.35 or later has been installed. 2673# The Boost.Threads library has undergone a major rewrite in version 1.35.0. 2674 2675AC_MSG_CHECKING([for boost]) 2676 2677AC_LANG(C++) 2678safe_CXXFLAGS=$CXXFLAGS 2679CXXFLAGS="$mflag_primary" 2680safe_LIBS="$LIBS" 2681LIBS="-lboost_thread-mt -lboost_system-mt $LIBS" 2682 2683AC_LINK_IFELSE([AC_LANG_SOURCE([ 2684#include <boost/thread.hpp> 2685static void thread_func(void) 2686{ } 2687int main(int argc, char** argv) 2688{ 2689 boost::thread t(thread_func); 2690 return 0; 2691} 2692])], 2693[ 2694ac_have_boost_1_35=yes 2695AC_SUBST([BOOST_CFLAGS], []) 2696AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"]) 2697AC_MSG_RESULT([yes]) 2698], [ 2699ac_have_boost_1_35=no 2700AC_MSG_RESULT([no]) 2701]) 2702 2703LIBS="$safe_LIBS" 2704CXXFLAGS=$safe_CXXFLAGS 2705AC_LANG(C) 2706 2707AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes]) 2708 2709 2710# does this compiler support -fopenmp, does it have the include file 2711# <omp.h> and does it have libgomp ? 2712 2713AC_MSG_CHECKING([for OpenMP]) 2714 2715safe_CFLAGS=$CFLAGS 2716CFLAGS="-fopenmp $mflag_primary" 2717 2718AC_LINK_IFELSE([AC_LANG_SOURCE([ 2719#include <omp.h> 2720int main(int argc, char** argv) 2721{ 2722 omp_set_dynamic(0); 2723 return 0; 2724} 2725])], 2726[ 2727ac_have_openmp=yes 2728AC_MSG_RESULT([yes]) 2729], [ 2730ac_have_openmp=no 2731AC_MSG_RESULT([no]) 2732]) 2733CFLAGS=$safe_CFLAGS 2734 2735AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes]) 2736 2737 2738# Check for __builtin_popcount 2739AC_MSG_CHECKING([for __builtin_popcount()]) 2740AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2741]], [[ 2742 __builtin_popcount(2); 2743 return 0; 2744]])], [ 2745AC_MSG_RESULT([yes]) 2746AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1, 2747 [Define to 1 if compiler provides __builtin_popcount().]) 2748], [ 2749AC_MSG_RESULT([no]) 2750]) 2751 2752# Check for __builtin_clz 2753AC_MSG_CHECKING([for __builtin_clz()]) 2754AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2755]], [[ 2756 __builtin_clz(2); 2757 return 0; 2758]])], [ 2759AC_MSG_RESULT([yes]) 2760AC_DEFINE([HAVE_BUILTIN_CLZ], 1, 2761 [Define to 1 if compiler provides __builtin_clz().]) 2762], [ 2763AC_MSG_RESULT([no]) 2764]) 2765 2766# Check for __builtin_ctz 2767AC_MSG_CHECKING([for __builtin_ctz()]) 2768AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2769]], [[ 2770 __builtin_ctz(2); 2771 return 0; 2772]])], [ 2773AC_MSG_RESULT([yes]) 2774AC_DEFINE([HAVE_BUILTIN_CTZ], 1, 2775 [Define to 1 if compiler provides __builtin_ctz().]) 2776], [ 2777AC_MSG_RESULT([no]) 2778]) 2779 2780# does this compiler have built-in functions for atomic memory access for the 2781# primary target ? 2782AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target]) 2783 2784safe_CFLAGS=$CFLAGS 2785CFLAGS="$mflag_primary" 2786 2787AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 2788 int variable = 1; 2789 return (__sync_bool_compare_and_swap(&variable, 1, 2) 2790 && __sync_add_and_fetch(&variable, 1) ? 1 : 0) 2791]])], [ 2792 ac_have_builtin_atomic_primary=yes 2793 AC_MSG_RESULT([yes]) 2794 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]) 2795], [ 2796 ac_have_builtin_atomic_primary=no 2797 AC_MSG_RESULT([no]) 2798]) 2799 2800CFLAGS=$safe_CFLAGS 2801 2802AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC], 2803 [test x$ac_have_builtin_atomic_primary = xyes]) 2804 2805 2806# does this compiler have built-in functions for atomic memory access for the 2807# secondary target ? 2808 2809if test x$VGCONF_PLATFORM_SEC_CAPS != x; then 2810 2811AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target]) 2812 2813safe_CFLAGS=$CFLAGS 2814CFLAGS="$mflag_secondary" 2815 2816AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 2817 int variable = 1; 2818 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0) 2819]])], [ 2820 ac_have_builtin_atomic_secondary=yes 2821 AC_MSG_RESULT([yes]) 2822], [ 2823 ac_have_builtin_atomic_secondary=no 2824 AC_MSG_RESULT([no]) 2825]) 2826 2827CFLAGS=$safe_CFLAGS 2828 2829fi 2830 2831AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY], 2832 [test x$ac_have_builtin_atomic_secondary = xyes]) 2833 2834# does this compiler have built-in functions for atomic memory access on 2835# 64-bit integers for all targets ? 2836 2837AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets]) 2838 2839AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2840 #include <stdint.h> 2841]], [[ 2842 uint64_t variable = 1; 2843 return __sync_add_and_fetch(&variable, 1) 2844]])], [ 2845 ac_have_builtin_atomic64_primary=yes 2846], [ 2847 ac_have_builtin_atomic64_primary=no 2848]) 2849 2850if test x$VGCONF_PLATFORM_SEC_CAPS != x; then 2851 2852safe_CFLAGS=$CFLAGS 2853CFLAGS="$mflag_secondary" 2854 2855AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2856 #include <stdint.h> 2857]], [[ 2858 uint64_t variable = 1; 2859 return __sync_add_and_fetch(&variable, 1) 2860]])], [ 2861 ac_have_builtin_atomic64_secondary=yes 2862], [ 2863 ac_have_builtin_atomic64_secondary=no 2864]) 2865 2866CFLAGS=$safe_CFLAGS 2867 2868fi 2869 2870if test x$ac_have_builtin_atomic64_primary = xyes && \ 2871 test x$VGCONF_PLATFORM_SEC_CAPS = x \ 2872 -o x$ac_have_builtin_atomic64_secondary = xyes; then 2873 AC_MSG_RESULT([yes]) 2874 ac_have_builtin_atomic64=yes 2875else 2876 AC_MSG_RESULT([no]) 2877 ac_have_builtin_atomic64=no 2878fi 2879 2880AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64], 2881 [test x$ac_have_builtin_atomic64 = xyes]) 2882 2883 2884# does g++ have built-in functions for atomic memory access ? 2885AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch]) 2886 2887safe_CXXFLAGS=$CXXFLAGS 2888CXXFLAGS="$mflag_primary" 2889 2890AC_LANG_PUSH(C++) 2891AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 2892 int variable = 1; 2893 return (__sync_bool_compare_and_swap(&variable, 1, 2) 2894 && __sync_add_and_fetch(&variable, 1) ? 1 : 0) 2895]])], [ 2896 ac_have_builtin_atomic_cxx=yes 2897 AC_MSG_RESULT([yes]) 2898 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()]) 2899], [ 2900 ac_have_builtin_atomic_cxx=no 2901 AC_MSG_RESULT([no]) 2902]) 2903AC_LANG_POP(C++) 2904 2905CXXFLAGS=$safe_CXXFLAGS 2906 2907AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes]) 2908 2909 2910if test x$ac_have_usable_linux_futex_h = xyes \ 2911 -a x$ac_have_builtin_atomic_primary = xyes; then 2912 ac_enable_linux_ticket_lock_primary=yes 2913fi 2914AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY], 2915 [test x$ac_enable_linux_ticket_lock_primary = xyes]) 2916 2917if test x$VGCONF_PLATFORM_SEC_CAPS != x \ 2918 -a x$ac_have_usable_linux_futex_h = xyes \ 2919 -a x$ac_have_builtin_atomic_secondary = xyes; then 2920 ac_enable_linux_ticket_lock_secondary=yes 2921fi 2922AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY], 2923 [test x$ac_enable_linux_ticket_lock_secondary = xyes]) 2924 2925 2926# does libstdc++ support annotating shared pointers ? 2927AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers]) 2928 2929safe_CXXFLAGS=$CXXFLAGS 2930CXXFLAGS="-std=c++0x" 2931 2932AC_LANG_PUSH(C++) 2933AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2934 #include <memory> 2935]], [[ 2936 std::shared_ptr<int> p 2937]])], [ 2938 ac_have_shared_ptr=yes 2939], [ 2940 ac_have_shared_ptr=no 2941]) 2942if test x$ac_have_shared_ptr = xyes; then 2943 # If compilation of the program below fails because of a syntax error 2944 # triggered by substituting one of the annotation macros then that 2945 # means that libstdc++ supports these macros. 2946 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2947 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)---- 2948 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)---- 2949 #include <memory> 2950 ]], [[ 2951 std::shared_ptr<int> p 2952 ]])], [ 2953 ac_have_shared_pointer_annotation=no 2954 AC_MSG_RESULT([no]) 2955 ], [ 2956 ac_have_shared_pointer_annotation=yes 2957 AC_MSG_RESULT([yes]) 2958 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1, 2959 [Define to 1 if libstd++ supports annotating shared pointers]) 2960 ]) 2961else 2962 ac_have_shared_pointer_annotation=no 2963 AC_MSG_RESULT([no]) 2964fi 2965AC_LANG_POP(C++) 2966 2967CXXFLAGS=$safe_CXXFLAGS 2968 2969AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION], 2970 [test x$ac_have_shared_pointer_annotation = xyes]) 2971 2972 2973#---------------------------------------------------------------------------- 2974# Ok. We're done checking. 2975#---------------------------------------------------------------------------- 2976 2977# Nb: VEX/Makefile is generated from Makefile.vex.in. 2978AC_CONFIG_FILES([ 2979 Makefile 2980 VEX/Makefile:Makefile.vex.in 2981 valgrind.spec 2982 valgrind.pc 2983 glibc-2.X.supp 2984 docs/Makefile 2985 tests/Makefile 2986 tests/vg_regtest 2987 perf/Makefile 2988 perf/vg_perf 2989 gdbserver_tests/Makefile 2990 include/Makefile 2991 auxprogs/Makefile 2992 mpi/Makefile 2993 coregrind/Makefile 2994 memcheck/Makefile 2995 memcheck/tests/Makefile 2996 memcheck/tests/common/Makefile 2997 memcheck/tests/amd64/Makefile 2998 memcheck/tests/x86/Makefile 2999 memcheck/tests/linux/Makefile 3000 memcheck/tests/darwin/Makefile 3001 memcheck/tests/amd64-linux/Makefile 3002 memcheck/tests/x86-linux/Makefile 3003 memcheck/tests/ppc32/Makefile 3004 memcheck/tests/ppc64/Makefile 3005 memcheck/tests/s390x/Makefile 3006 memcheck/tests/vbit-test/Makefile 3007 cachegrind/Makefile 3008 cachegrind/tests/Makefile 3009 cachegrind/tests/x86/Makefile 3010 cachegrind/cg_annotate 3011 cachegrind/cg_diff 3012 callgrind/Makefile 3013 callgrind/callgrind_annotate 3014 callgrind/callgrind_control 3015 callgrind/tests/Makefile 3016 helgrind/Makefile 3017 helgrind/tests/Makefile 3018 massif/Makefile 3019 massif/tests/Makefile 3020 massif/ms_print 3021 lackey/Makefile 3022 lackey/tests/Makefile 3023 none/Makefile 3024 none/tests/Makefile 3025 none/tests/scripts/Makefile 3026 none/tests/amd64/Makefile 3027 none/tests/ppc32/Makefile 3028 none/tests/ppc64/Makefile 3029 none/tests/x86/Makefile 3030 none/tests/arm/Makefile 3031 none/tests/arm64/Makefile 3032 none/tests/s390x/Makefile 3033 none/tests/mips32/Makefile 3034 none/tests/mips64/Makefile 3035 none/tests/tilegx/Makefile 3036 none/tests/linux/Makefile 3037 none/tests/darwin/Makefile 3038 none/tests/amd64-linux/Makefile 3039 none/tests/x86-linux/Makefile 3040 exp-sgcheck/Makefile 3041 exp-sgcheck/tests/Makefile 3042 drd/Makefile 3043 drd/scripts/download-and-build-splash2 3044 drd/tests/Makefile 3045 exp-bbv/Makefile 3046 exp-bbv/tests/Makefile 3047 exp-bbv/tests/x86/Makefile 3048 exp-bbv/tests/x86-linux/Makefile 3049 exp-bbv/tests/amd64-linux/Makefile 3050 exp-bbv/tests/ppc32-linux/Makefile 3051 exp-bbv/tests/arm-linux/Makefile 3052 exp-dhat/Makefile 3053 exp-dhat/tests/Makefile 3054 shared/Makefile 3055]) 3056AC_CONFIG_FILES([coregrind/link_tool_exe_linux], 3057 [chmod +x coregrind/link_tool_exe_linux]) 3058AC_CONFIG_FILES([coregrind/link_tool_exe_darwin], 3059 [chmod +x coregrind/link_tool_exe_darwin]) 3060AC_OUTPUT 3061 3062cat<<EOF 3063 3064 Maximum build arch: ${ARCH_MAX} 3065 Primary build arch: ${VGCONF_ARCH_PRI} 3066 Secondary build arch: ${VGCONF_ARCH_SEC} 3067 Build OS: ${VGCONF_OS} 3068 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS} 3069 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS} 3070 Platform variant: ${VGCONF_PLATVARIANT} 3071 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1 3072 Default supp files: ${DEFAULT_SUPP} 3073 3074EOF 3075