gcc.m4 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 This file taken from StarPU, <http://runtime.bordeaux.inria.fr/StarPU>.
  16. dnl Run its argument with CPPFLAGS pointing to GCC's plug-in API.
  17. AC_DEFUN([_GGCC_WITH_GCC_PLUGIN_API], [
  18. GCC_PLUGIN_INCLUDE_DIR="`"$CC" -print-file-name=plugin`/include"
  19. save_CPPFLAGS="$CPPFLAGS"
  20. CPPFLAGS="-I$GCC_PLUGIN_INCLUDE_DIR"
  21. $1
  22. CPPFLAGS="$save_CPPFLAGS"
  23. ])
  24. dnl Check whether GCC plug-in support is available (GCC 4.5+).
  25. AC_DEFUN([GGCC_GCC_PLUGIN_SUPPORT], [
  26. AC_REQUIRE([AC_PROG_CC])
  27. AC_CACHE_CHECK([whether GCC supports plug-ins], [ac_cv_have_gcc_plugins], [
  28. if test "x$GCC" = xyes; then
  29. # ICC 12.1.0 and Clang 3.1 (among others) support `--version',
  30. # define `__GNUC__', and provide a `-print-file-name=plugin'
  31. # that returns GCC's valid header directory. This makes them
  32. # hardly distinguishable from GCC. Actually, ICC 12.1.0 is able
  33. # to compile our plug-in, but silently ignores `-fplugin', leading
  34. # to obvious build failures; thus, it is explicitly excluded below.
  35. _GGCC_WITH_GCC_PLUGIN_API([
  36. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gcc-plugin.h>
  37. #include <tree.h>
  38. #include <gimple.h>
  39. #if defined __INTEL_COMPILER || defined __ICC
  40. Beware, this compiler is a fake. Don't use it.
  41. #endif
  42. tree fndecl; gimple call;]],
  43. [[/* Clang 3.1 doesn't support nested functions, so try to
  44. discriminate it this way. */
  45. tree foo (void)
  46. {
  47. return lookup_name (get_identifier ("puts"));
  48. }
  49. fndecl = foo ();
  50. call = gimple_build_call (fndecl, 0);]])],
  51. [ac_cv_have_gcc_plugins="yes"],
  52. [ac_cv_have_gcc_plugins="no"])
  53. ])
  54. else
  55. ac_cv_have_gcc_plugins="no"
  56. fi
  57. ])
  58. if test "x$ac_cv_have_gcc_plugins" = "xyes"; then
  59. dnl Check for specific features.
  60. dnl
  61. dnl Reason:
  62. dnl build_call_expr_loc_array -- not in GCC 4.5.x; appears in 4.6
  63. dnl build_call_expr_loc_vec -- likewise
  64. dnl build_array_ref -- present but undeclared in 4.6.1
  65. dnl build_zero_cst -- not in GCC 4.5.x; appears in 4.6
  66. _GGCC_WITH_GCC_PLUGIN_API([
  67. AC_CHECK_DECLS([build_call_expr_loc_array, build_call_expr_loc_vec,
  68. build_array_ref, build_zero_cst],
  69. [], [], [#include <gcc-plugin.h>
  70. #include <tree.h>])
  71. dnl Work around header naming issues introduced upstream and in Debian
  72. dnl (see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631082>).
  73. AC_CHECK_HEADERS([c-common.h c-pragma.h c-family/c-common.h c-family/c-pragma.h],
  74. [], [], [#include <gcc-plugin.h>
  75. #include <tree.h>])
  76. ])
  77. fi
  78. AC_SUBST([GCC_PLUGIN_INCLUDE_DIR])
  79. ])
  80. dnl Substitute `GGCC_GCC_VERSION_MAJOR' and `GGCC_GCC_VERSION_MINOR'.
  81. AC_DEFUN([GGCC_GCC_VERSION], [
  82. AC_COMPUTE_INT([GGCC_GCC_VERSION_MAJOR], [__GNUC__])
  83. AC_COMPUTE_INT([GGCC_GCC_VERSION_MINOR], [__GNUC_MINOR__])
  84. AC_SUBST([GGCC_GCC_VERSION_MAJOR])
  85. AC_SUBST([GGCC_GCC_VERSION_MINOR])
  86. ])