gcc.m4 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. dnl -*- Autoconf -*-
  2. dnl
  3. dnl Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
  4. dnl
  5. dnl StarPU is free software; you can redistribute it and/or modify
  6. dnl it under the terms of the GNU Lesser General Public License as published by
  7. dnl the Free Software Foundation; either version 2.1 of the License, or (at
  8. dnl your option) any later version.
  9. dnl
  10. dnl StarPU is distributed in the hope that it will be useful, but
  11. dnl WITHOUT ANY WARRANTY; without even the implied warranty of
  12. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. dnl
  14. dnl See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. dnl Run its argument with CPPFLAGS pointing to GCC's plug-in API.
  16. AC_DEFUN([_STARPU_WITH_GCC_PLUGIN_API], [
  17. GCC_PLUGIN_INCLUDE_DIR="`"$CC" -print-file-name=plugin`/include"
  18. save_CPPFLAGS="$CPPFLAGS"
  19. CPPFLAGS="-I$GCC_PLUGIN_INCLUDE_DIR"
  20. $1
  21. CPPFLAGS="$save_CPPFLAGS"
  22. ])
  23. dnl Check whether GCC plug-in support is available (GCC 4.5+).
  24. AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
  25. AC_REQUIRE([AC_PROG_CC])
  26. AC_CACHE_CHECK([whether GCC supports plug-ins], [ac_cv_have_gcc_plugins], [
  27. if test "x$GCC" = xyes; then
  28. # ICC 12.1.0 and Clang 3.1 (among others) support `--version',
  29. # define `__GNUC__', and provide a `-print-file-name=plugin'
  30. # that returns GCC's valid header directory. This makes them
  31. # hardly distinguishable from GCC. Actually, ICC 12.1.0 is able
  32. # to compile our plug-in, but silently ignores `-fplugin', leading
  33. # to obvious build failures; thus, it is explicitly excluded below.
  34. _STARPU_WITH_GCC_PLUGIN_API([
  35. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gcc-plugin.h>
  36. #include <tree.h>
  37. #include <gimple.h>
  38. #if defined __INTEL_COMPILER || defined __ICC
  39. Beware, this compiler is a fake. Don't use it.
  40. #endif
  41. tree fndecl; gimple call;]],
  42. [[/* Clang 3.1 doesn't support nested functions, so try to
  43. discriminate it this way. */
  44. tree foo (void)
  45. {
  46. return lookup_name (get_identifier ("puts"));
  47. }
  48. fndecl = foo ();
  49. call = gimple_build_call (fndecl, 0);]])],
  50. [ac_cv_have_gcc_plugins="yes"],
  51. [ac_cv_have_gcc_plugins="no"])
  52. ])
  53. else
  54. ac_cv_have_gcc_plugins="no"
  55. fi
  56. ])
  57. if test "x$ac_cv_have_gcc_plugins" = "xyes"; then
  58. dnl Check for specific features.
  59. dnl
  60. dnl Reason:
  61. dnl build_call_expr_loc_array -- not in GCC 4.5.x; appears in 4.6
  62. dnl build_call_expr_loc_vec -- likewise
  63. dnl build_array_ref -- present but undeclared in 4.6.1
  64. dnl build_zero_cst -- not in GCC 4.5.x; appears in 4.6
  65. _STARPU_WITH_GCC_PLUGIN_API([
  66. AC_CHECK_DECLS([build_call_expr_loc_array, build_call_expr_loc_vec,
  67. build_array_ref, build_zero_cst],
  68. [], [], [#include <gcc-plugin.h>
  69. #include <tree.h>])
  70. dnl Work around header naming issues introduced upstream and in Debian
  71. dnl (see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631082>).
  72. AC_CHECK_HEADERS([c-common.h c-pragma.h c-family/c-common.h c-family/c-pragma.h],
  73. [], [], [#include <gcc-plugin.h>
  74. #include <tree.h>])
  75. AC_DEFINE_UNQUOTED([STARPU_INCLUDE_DIR],
  76. ["`eval "echo $includedir"`/starpu/$STARPU_EFFECTIVE_VERSION"],
  77. [Define to the directory where StarPU's headers are installed.])
  78. ])
  79. fi
  80. AC_SUBST([GCC_PLUGIN_INCLUDE_DIR])
  81. ])
  82. dnl Substitute `STARPU_GCC_VERSION_MAJOR' and `STARPU_GCC_VERSION_MINOR'.
  83. AC_DEFUN([STARPU_GCC_VERSION], [
  84. AC_COMPUTE_INT([STARPU_GCC_VERSION_MAJOR], [__GNUC__])
  85. AC_COMPUTE_INT([STARPU_GCC_VERSION_MINOR], [__GNUC_MINOR__])
  86. AC_SUBST([STARPU_GCC_VERSION_MAJOR])
  87. AC_SUBST([STARPU_GCC_VERSION_MINOR])
  88. ])