1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
|
#
# Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2001-2014. ALL RIGHTS RESERVED.
# Copyright (c) UT-Battelle, LLC. 2017. ALL RIGHTS RESERVED.
# Copyright (C) ARM Ltd. 2016-2020. ALL RIGHTS RESERVED.
# Copyright (C) NextSilicon Ltd. 2021. ALL RIGHTS RESERVED.
# See file LICENSE for terms.
#
#
# Initialize CFLAGS
#
BASE_CFLAGS="-g -Wall"
# Prevent libtool from suppression of warnings
LT_CFLAGS="-no-suppress"
#
# Check that C++ is functional.
#
# AC_PROG_CXX never fails but falls back on g++ as a default CXX compiler that
# always present. If g++ isn't installed, the macro doesn't detect this and
# compilation fails later on. CHECK_CXX_COMP compiles simple C++ code to
# verify that compiler is present and functional.
#
AC_DEFUN([CHECK_CXX_COMP],
[AC_MSG_CHECKING(if $CXX works)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifndef __cplusplus
#error "No C++ support, AC_PROG_CXX failed"
#endif
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([Cannot continue. Please install C++ compiler.])])
AC_LANG_POP([C++])
])
#
# Debug mode
#
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debug mode build]),
[],
[enable_debug=no])
AS_IF([test "x$enable_debug" = xyes],
[BASE_CFLAGS="-D_DEBUG $BASE_CFLAGS"
BASE_CXXFLAGS="-D_DEBUG" $BASE_CXXFLAGS],
[])
#
# Enable GCOV build
#
AC_ARG_ENABLE([gcov],
AS_HELP_STRING([--enable-gcov], [Enable code coverage instrumentation]),
[],
[enable_gcov=no])
AM_CONDITIONAL([HAVE_GCOV],[test "x$enable_gcov" = xyes])
#
# Optimization level
#
AC_ARG_ENABLE(compiler-opt,
AS_HELP_STRING([--enable-compiler-opt], [Set optimization level [0-3]]),
[],
[enable_compiler_opt="none"])
AS_IF([test "x$enable_compiler_opt" = "xyes"], [BASE_CFLAGS="-O3 $BASE_CFLAGS"],
[test "x$enable_compiler_opt" = "xnone"],
[AS_IF([test "x$enable_debug" = xyes -o "x$enable_gcov" = xyes],
[BASE_CFLAGS="-O0 $BASE_CFLAGS"
BASE_CXXFLAGS="-O0 $BASE_CXXFLAGS"],
[BASE_CFLAGS="-O3 $BASE_CFLAGS"
BASE_CXXFLAGS="-O0 $BASE_CXXFLAGS"])],
[test "x$enable_compiler_opt" = "xno"], [],
[BASE_CFLAGS="-O$enable_compiler_opt $BASE_CFLAGS"])
#
# CHECK_CROSS_COMP (program, true-action, false-action)
#
# The macro checks if it can run the program; it executes
# true action if the program can be executed, otherwise
# false action is executed.
# For cross-platform compilation we only check
# if we can compile and link the program.
AC_DEFUN([CHECK_CROSS_COMP], [
AC_RUN_IFELSE([$1], [$2], [$3],
[AC_LINK_IFELSE([$1], [$2], [$3])])
])
#
# Check for one specific attribute by compiling with C
# Usage: CHECK_SPECIFIC_ATTRIBUTE([name], [doc], [program])
#
AC_DEFUN([CHECK_SPECIFIC_ATTRIBUTE], [
AC_CACHE_VAL(ucx_cv_attribute_[$1], [
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$BASE_CFLAGS $CFLAGS"
#
# Try to compile using the C compiler
#
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]],[[]])],
[ucx_cv_attribute_[$1]=1],
[ucx_cv_attribute_[$1]=0])
CFLAGS="$SAVE_CFLAGS"
])
AC_MSG_CHECKING([for __attribute__([$1])])
AC_MSG_RESULT([$ucx_cv_attribute_[$1]])
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_[$2]], [$ucx_cv_attribute_[$1]], [Check attribute [$1]])
])
#
# Enable/disable turning on machine-specific optimizations
#
AC_ARG_ENABLE(optimizations,
AS_HELP_STRING([--enable-optimizations],
[Enable non-portable machine-specific CPU optimizations, default: NO]),
[],
[enable_optimizations=no])
#
# Check if compiler supports a given CPU optimization flag, and if yes - add it
# to BASE_CFLAGS substitution, and OPT_CFLAGS C define.
#
# Usage: COMPILER_CPU_OPTIMIZATION([name], [doc], [flag], [program])
#
AC_DEFUN([COMPILER_CPU_OPTIMIZATION],
[
AC_ARG_WITH([$1],
[AS_HELP_STRING([--with-$1], [Use $2 compiler option.])],
[],
[with_$1=$enable_optimizations])
AS_IF([test "x$with_$1" != "xno"],
[SAVE_CFLAGS="$CFLAGS"
CFLAGS="$BASE_CFLAGS $CFLAGS $3"
AC_MSG_CHECKING([$3])
CHECK_CROSS_COMP([AC_LANG_SOURCE([$4])],
[AC_MSG_RESULT([yes])
# TODO: Add CPU UARCH detector and validator in UCX init.
# As for now we will avoid passing this information to
# library.
BASE_CFLAGS="$BASE_CFLAGS $3"
AS_IF([test "x$1" != "xmcpu" -a "x$1" != "xmarch"],
[OPT_CFLAGS="$OPT_CFLAGS|$1"])],
[AC_MSG_RESULT([no])])
CFLAGS="$SAVE_CFLAGS"])
])
#
# Check platform uarch and apply micro-architecture specific optimizations
#
AC_DEFUN([DETECT_UARCH],
[
cpuimpl=`grep 'CPU implementer' /proc/cpuinfo 2> /dev/null | cut -d: -f2 | tr -d " " | head -n 1`
cpuarch=`grep 'CPU architecture' /proc/cpuinfo 2> /dev/null | cut -d: -f2 | tr -d " " | head -n 1`
cpuvar=`grep 'CPU variant' /proc/cpuinfo 2> /dev/null | cut -d: -f2 | tr -d " " | head -n 1`
cpupart=`grep 'CPU part' /proc/cpuinfo 2> /dev/null | cut -d: -f2 | tr -d " " | head -n 1`
ax_cpu=""
ax_arch=""
AC_MSG_NOTICE(Detected CPU implementation: ${cpuimpl})
AC_MSG_NOTICE(Detected CPU architecture: ${cpuarch})
AC_MSG_NOTICE(Detected CPU variant: ${cpuvar})
AC_MSG_NOTICE(Detected CPU part: ${cpupart})
case $cpuimpl in
0x42) case $cpupart in
0x516 | 0x0516)
AC_DEFINE([HAVE_AARCH64_THUNDERX2], 1, [Cavium ThunderX2])
ax_cpu="thunderx2t99"
ax_arch="armv8.1-a+lse" ;;
0xaf | 0x0af)
AC_DEFINE([HAVE_AARCH64_THUNDERX2], 1, [Cavium ThunderX2])
ax_cpu="thunderx2t99"
ax_arch="armv8.1-a+lse" ;;
esac
;;
0x43) case $cpupart in
0x516 | 0x0516)
AC_DEFINE([HAVE_AARCH64_THUNDERX2], 1, [Cavium ThunderX2])
ax_cpu="thunderx2t99"
ax_arch="armv8.1-a+lse" ;;
0xaf | 0x0af)
AC_DEFINE([HAVE_AARCH64_THUNDERX2], 1, [Cavium ThunderX2])
ax_cpu="thunderx2t99"
ax_arch="armv8.1-a+lse" ;;
0xa1 | 0x0a1)
AC_DEFINE([HAVE_AARCH64_THUNDERX1], 1, [Cavium ThunderX1])
ax_cpu="thunderxt88" ;;
esac
;;
0x48) case $cpupart in
0xd01 | 0x0d01)
AC_DEFINE([HAVE_AARCH64_HI1620], 1, [Huawei Kunpeng 920])
ax_cpu="tsv110"
ax_arch="armv8.2-a" ;;
esac
;;
*)
;;
esac
AM_CONDITIONAL([HAVE_AARCH64_THUNDERX2], [test x$ax_cpu = xthunderx2t99])
AM_CONDITIONAL([HAVE_AARCH64_THUNDERX1], [test x$ax_cpu = xthunderxt88])
AM_CONDITIONAL([HAVE_AARCH64_HI1620], [test x$ax_cpu = xtsv110])
])
#
# CHECK_COMPILER_FLAG
# Usage: CHECK_COMPILER_FLAG([name], [flag], [program], [if-true], [if-false])
#
# The macro checks if program may be compiled and linked using specified flag
#
AC_DEFUN([CHECK_COMPILER_FLAG],
[
AC_MSG_CHECKING([compiler flag $1])
SAVE_CFLAGS="$CFLAGS"
SAVE_CXXFLAGS="$CXXFLAGS"
CFLAGS="$BASE_CFLAGS $CFLAGS $2"
CXXFLAGS="$BASE_CXXFLAGS $CXXFLAGS $2"
AC_LINK_IFELSE([$3],
[AC_MSG_RESULT([yes])
CFLAGS="$SAVE_CFLAGS"
CXXFLAGS="$SAVE_CXXFLAGS"
$4],
[AC_MSG_RESULT([no])
CFLAGS="$SAVE_CFLAGS"
CXXFLAGS="$SAVE_CXXFLAGS"
$5])
])
#
# ADD_COMPILER_FLAG_IF_SUPPORTED
# Usage: ADD_COMPILER_FLAG_IF_SUPPORTED([name], [flag], [program], [if-true], [if-false])
#
# The macro checks if program may be compiled using specified flag and adds
# this flag if it is supported
#
AC_DEFUN([ADD_COMPILER_FLAG_IF_SUPPORTED],
[
CHECK_COMPILER_FLAG([$1], [$2], [$3],
[BASE_CFLAGS="$BASE_CFLAGS $2"
$4],
[$5])
])
#
# ADD_COMPILER_FLAGS_IF_SUPPORTED
# Usage: ADD_COMPILER_FLAGS_IF_SUPPORTED([[flag1], [flag2], [flag3]], [program])
#
# The macro checks multiple flags supported by compiler
#
AC_DEFUN([ADD_COMPILER_FLAGS_IF_SUPPORTED],
[
m4_foreach([_flag], [$1],
[ADD_COMPILER_FLAG_IF_SUPPORTED([_flag], [_flag], [$2], [], [])])
])
#
# CHECK_DEPRECATED_DECL_FLAG (flag, variable)
#
# The macro checks if the given compiler flag enables using deprecated declarations.
# If yes, it appends the flags to "variable".
#
AC_DEFUN([CHECK_DEPRECATED_DECL_FLAG],
[
AC_MSG_CHECKING([whether $1 overrides deprecated declarations])
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$BASE_CFLAGS $CFLAGS $1"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
int __attribute__ ((__deprecated__)) f() { return 0; }
int main(int argc, char** argv) { return f(); }
]])],
[AC_MSG_RESULT([yes])
$2="$1"],
[AC_MSG_RESULT([no])])
CFLAGS="$SAVE_CFLAGS"
])
#
# Force ICC treat command line warnings as errors.
# This evaluation should be called prior to all other compiler flags evals
#
ADD_COMPILER_FLAGS_IF_SUPPORTED([[-diag-error 10006],
[-diag-error 10148]],
[AC_LANG_SOURCE([[int main(int argc, char **argv){return 0;}]])])
#
# Disable all deprecations if a finer grained approach does not work
#
CFLAGS_NO_DEPRECATED="-Wno-deprecated"
CHECK_DEPRECATED_DECL_FLAG([-diag-disable 1478], CFLAGS_NO_DEPRECATED) # icc
CHECK_DEPRECATED_DECL_FLAG([-Wno-deprecated-declarations], CFLAGS_NO_DEPRECATED) # gcc
AC_SUBST([CFLAGS_NO_DEPRECATED], [$CFLAGS_NO_DEPRECATED])
#
# Disable format-string warning on ICC
#
ADD_COMPILER_FLAG_IF_SUPPORTED([-diag-disable 269],
[-diag-disable 269],
[AC_LANG_SOURCE([[#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv) {
char *p = NULL;
scanf("%m[^.]", &p);
free(p);
return 0;
}]])],
[],
[])
#
# Set default datatype alignment to 16 bytes.
# Some compilers (LLVM based, clang) expects allocation of datatypes by 32 bytes
# to optimize operations memset/memcpy/etc using vectorized processor instructions
# which requires alignment of memory buffer by 32 or higher bytes. Default malloc method
# guarantee alignment for 16 bytes only. Force using compiler 16-bytes alignment
# by default if option is supported.
#
UCX_ALLOC_ALIGN=16
ADD_COMPILER_FLAG_IF_SUPPORTED([-fmax-type-align=$UCX_ALLOC_ALIGN],
[-fmax-type-align=$UCX_ALLOC_ALIGN],
[AC_LANG_SOURCE([[int main(int argc, char** argv){return 0;}]])],
[AC_DEFINE_UNQUOTED([UCX_ALLOC_ALIGN], $UCX_ALLOC_ALIGN, [Set alignment assumption for compiler])],
[])
#
# SSE/AVX
#
COMPILER_CPU_OPTIMIZATION([avx], [AVX], [-mavx],
[#include <immintrin.h>
int main(int argc, char** argv) {
return _mm256_testz_si256(_mm256_set1_epi32(1), _mm256_set1_epi32(3));
}
])
AS_IF([test "x$with_avx" != xyes],
[COMPILER_CPU_OPTIMIZATION([sse41], [SSE 4.1], [-msse4.1],
[#include <smmintrin.h>
int main(int argc, char** argv) {
return _mm_testz_si128(_mm_set1_epi32(1), _mm_set1_epi32(3));
}
])
COMPILER_CPU_OPTIMIZATION([sse42], [SSE 4.2], [-msse4.2],
[#include <popcntintrin.h>
int main(int argc, char** argv) { return _mm_popcnt_u32(0x101) - 2;
}])
])
DETECT_UARCH()
#
# CPU tuning
#
AS_IF([test "x$ax_cpu" != "x"],
[COMPILER_CPU_OPTIMIZATION([mcpu], [CPU Model], [-mcpu=$ax_cpu],
[int main(int argc, char** argv) { return 0;}])
])
#
# Architecture tuning
#
AS_IF([test "x$ax_arch" != "x"],
[COMPILER_CPU_OPTIMIZATION([march], [architecture tuning], [-march=$ax_arch],
[int main(int argc, char** argv) { return 0;}])
])
#
# Check for compiler attribute which disables optimizations per-function.
#
CHECK_SPECIFIC_ATTRIBUTE([optimize], [NOOPTIMIZE],
[int foo (int arg) __attribute__ ((optimize("O0")));])
#
# Compile code with frame pointer. Optimizations usually omit the frame pointer,
# but if we are profiling the code with callgraph we need it.
# This option may affect perofrmance so it is off by default.
#
AC_ARG_ENABLE([frame-pointer],
AS_HELP_STRING([--enable-frame-pointer],
[Compile with frame pointer, useful for profiling, default: NO]),
[],
[enable_frame_pointer=no])
AS_IF([test "x$enable_frame_pointer" = xyes -o "x$enable_gcov" = xyes],
[ADD_COMPILER_FLAG_IF_SUPPORTED([-fno-omit-frame-pointer],
[-fno-omit-frame-pointer],
[AC_LANG_SOURCE([[int main(int argc, char** argv){return 0;}]])],
[AS_MESSAGE([compiling with frame pointer])],
[AS_MESSAGE([compiling with frame pointer is not supported])])],
[:])
ADD_COMPILER_FLAG_IF_SUPPORTED([-funwind-tables],
[-funwind-tables],
[AC_LANG_SOURCE([[int main(int argc, char** argv){return 0;}]])],
[AS_MESSAGE([compiling with unwind tables])],
[AS_MESSAGE([compiling without unwind tables])])
#
# ASAN support
#
AC_ARG_ENABLE([asan],
AS_HELP_STRING([--enable-asan], [Enable address sanitized check]),
[],
[enable_asan=no])
AM_CONDITIONAL([HAVE_ASAN], [test "x$enable_asan" = xyes])
AS_IF([test "x$enable_asan" = xyes],
[ADD_COMPILER_FLAG_IF_SUPPORTED([-fsanitize=address -fno-omit-frame-pointer],
[-fsanitize=address -fno-omit-frame-pointer],
[AC_LANG_SOURCE([[int main(int argc, char** argv){return 0;}]])],
[AS_MESSAGE([compiling with sanitizer])
BASE_CXXFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASE_CXXFLAGS"
LDFLAGS="-fsanitize=address -fno-omit-frame-pointer $LDFLAGS"],
[AC_MSG_ERROR([ASAN check is requested but not supported. Check libasan package existence])])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
[[void *p = malloc(7); return 0;]])],
[AC_MSG_ERROR([ASAN cannot detect simple memory leak, consider installing newer compiler version])],
[AS_MESSAGE([sanitizer runtime leak detection check passed])]
)],
[])
AS_IF([test "x$enable_gcov" = xyes],
[ADD_COMPILER_FLAGS_IF_SUPPORTED([[-ftest-coverage],
[-fprofile-arcs]],
[AC_LANG_SOURCE([[int main(int argc, char** argv){return 0;}]])])],
[:])
#
# Enable stack usage check
#
AC_ARG_ENABLE([stack-usage-check],
AS_HELP_STRING([--enable-stack-usage-check], [Enable stack usage check with -Wframe-larger-than=8192]),
[],
[enable_stack_usage_check=yes])
AS_IF([test "x$enable_stack_usage_check" = xyes],
[AS_IF([test "x$enable_asan" = xyes],
[AC_MSG_NOTICE([Stack usage check was not added because ASAN is enabled])],
[ADD_COMPILER_FLAG_IF_SUPPORTED([stack_usage_check],
[-Wframe-larger-than=8192],
[AC_LANG_SOURCE([[int main(int argc, char** argv) { return 0; }]])])])],
[AC_MSG_NOTICE([Stack usage check is disabled])])
#
# Check for C++ support
#
CHECK_CXX_COMP()
#
# Check for C++11 support
#
AC_MSG_CHECKING([c++11 support])
AC_LANG_PUSH([C++])
SAVE_CXXFLAGS="$CXXFLAGS"
CXX11FLAGS="-std=c++11"
CXXFLAGS="$CXXFLAGS $CXX11FLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <iostream>
#include <string>
int main(int argc, char** argv) {
std::to_string(1);
return 0;
} ]])],
[AC_MSG_RESULT([yes])
AC_SUBST([CXX11FLAGS])
cxx11_happy=yes],
[AC_MSG_RESULT([no])
cxx11_happy=no])
CXXFLAGS="$SAVE_CXXFLAGS"
AC_LANG_POP
AM_CONDITIONAL([HAVE_CXX11], [test "x$cxx11_happy" != xno])
#
# Check for GNU++11 support
#
AC_MSG_CHECKING([gnu++11 support])
AC_LANG_PUSH([C++])
SAVE_CXXFLAGS="$CXXFLAGS"
CXX11FLAGS="-std=gnu++11"
CXXFLAGS="$CXXFLAGS $CXX11FLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <iostream>
#include <string>
int main(int argc, char** argv) {
int a;
typeof(a) b = 0;
std::to_string(1);
return 0;
} ]])],
[AC_MSG_RESULT([yes])
AC_SUBST([CXX11FLAGS])
gnuxx11_happy=yes],
[AC_MSG_RESULT([no])
gnuxx11_happy=no])
CXXFLAGS="$SAVE_CXXFLAGS"
AM_CONDITIONAL([HAVE_GNUXX11], [test "x$gnuxx11_happy" != xno])
AC_CHECK_DECL(_GLIBCXX_NOTHROW, have_glibcxx_nothrow=yes,
have_glibcxx_nothrow=no, [[#include <exception>]])
AM_CONDITIONAL([HAVE_GLIBCXX_NOTHROW], [test "x$have_glibcxx_nothrow" = xyes])
AC_LANG_POP
#
# PGI specific switches
#
# --diag_suppress 1 - Suppress last line ends without a newline
# --diag_suppress 68 - Suppress integer conversion resulted in a change of sign
# --diag_suppress 111 - Suppress statement is unreachable
# --diag_suppress 167 - Suppress int* incompatible with unsigned int*
# --diag_suppress 181 - Suppress incorrect printf format for PGI18 compiler. TODO: remove it after compiler fix
# --diag_suppress 188 - Suppress enumerated type mixed with another type
# --diag_suppress 381 - Suppress extra ";" ignored
# --diag_suppress 1215 - Suppress deprecated API warning for PGI18 compiler
# --diag_suppress 1626 - Suppress routine is both "inline" and "noinline"
# --diag_suppress 1901 - Use of a const variable in a constant expression is nonstandard in C
# --diag_suppress 1902 - Use of a const variable in a constant expression is nonstandard in C (same as 1901)
ADD_COMPILER_FLAGS_IF_SUPPORTED([[--display_error_number],
[--diag_suppress 1],
[--diag_suppress 68],
[--diag_suppress 111],
[--diag_suppress 167],
[--diag_suppress 181],
[--diag_suppress 188],
[--diag_suppress 381],
[--diag_suppress 1215],
[--diag_suppress 1626],
[--diag_suppress 1901],
[--diag_suppress 1902]],
[AC_LANG_SOURCE([[int main(int argc, char **argv){return 0;}]])])
#
# Check if "-pedantic" flag is supported
#
CHECK_COMPILER_FLAG([-pedantic], [-pedantic],
[AC_LANG_SOURCE([[int main(int argc, char** argv){return 0;}]])],
[CFLAGS_PEDANTIC="$CFLAGS_PEDANTIC -pedantic"],
[])
#
# Check if "-dynamic-list-data" flag is supported
#
CHECK_COMPILER_FLAG([-Wl,-dynamic-list-data], [-Wl,-dynamic-list-data],
[AC_LANG_SOURCE([[int main(int argc, char** argv){return 0;}]])],
[LDFLAGS_DYNAMIC_LIST_DATA="-Wl,-dynamic-list-data"],
[LDFLAGS_DYNAMIC_LIST_DATA="-Wl,-export-dynamic"])
#
# Add strict compilation flags
#
ADD_COMPILER_FLAGS_IF_SUPPORTED([[-Wno-missing-field-initializers],
[-Wno-unused-parameter],
[-Wno-unused-label],
[-Wno-long-long],
[-Wno-endif-labels],
[-Wno-sign-compare],
[-Wno-multichar],
[-Wno-deprecated-declarations],
[-Winvalid-pch]],
[AC_LANG_SOURCE([[int main(int argc, char **argv){return 0;}]])])
#
# Intel Compiler specifics
#
if $CC --version 2>&1 | grep -q Intel; then
ADD_COMPILER_FLAGS_IF_SUPPORTED([[-Wno-language-extension-token],
[-fno-finite-math-only],
[-Wno-recommended-option],
[-Wno-c99-extensions]],
[AC_LANG_SOURCE([[int main(int argc, char **argv){return 0;}]])])
fi
#
# Set C++ optimization/debug flags to be the same as for C
#
BASE_CXXFLAGS="$BASE_CFLAGS"
#
# Add strict flags supported by C compiler only
# NOTE: This must be done after setting BASE_CXXFLAGS
#
ADD_COMPILER_FLAGS_IF_SUPPORTED([[-Wno-pointer-sign],
[-Werror-implicit-function-declaration],
[-Wno-format-zero-length],
[-Wnested-externs],
[-Wshadow],
[-Werror=declaration-after-statement]],
[AC_LANG_SOURCE([[int main(int argc, char **argv){return 0;}]])])
AC_SUBST([BASE_CFLAGS])
AC_SUBST(LT_CFLAGS)
AC_SUBST([BASE_CXXFLAGS])
AC_SUBST([CFLAGS_PEDANTIC])
AC_SUBST([LDFLAGS_DYNAMIC_LIST_DATA])
#
# Set common C preprocessor flags
#
BASE_CPPFLAGS="-DCPU_FLAGS=\"$OPT_CFLAGS\""
BASE_CPPFLAGS="$BASE_CPPFLAGS -I\${abs_top_srcdir}/src"
BASE_CPPFLAGS="$BASE_CPPFLAGS -I\${abs_top_builddir}"
BASE_CPPFLAGS="$BASE_CPPFLAGS -I\${abs_top_builddir}/src"
AC_SUBST([BASE_CPPFLAGS], [$BASE_CPPFLAGS])
|