Browse Source

gcc: Paper around broken compilers that pretend to be GCC.

* m4/gcc.m4 (STARPU_GCC_PLUGIN_SUPPORT): Paper around compilers that
  pretend to be GCC but aren't.
Ludovic Courtès 13 years ago
parent
commit
2eb3c7863b
1 changed files with 12 additions and 1 deletions
  1. 12 1
      m4/gcc.m4

+ 12 - 1
m4/gcc.m4

@@ -30,12 +30,23 @@ AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
   AC_REQUIRE([AC_PROG_CC])
   AC_CACHE_CHECK([whether GCC supports plug-ins], [ac_cv_have_gcc_plugins], [
     if test "x$GCC" = xyes; then
+      # ICC 12.1.0 and Clang 3.1 (among others) support `--version',
+      # define `__GNUC__', and provide a `-print-file-name=plugin'
+      # that returns GCC's valid header directory.  This makes them
+      # hardly distinguishable from GCC.  Actually, ICC 12.1.0 is able
+      # to compile our plug-in, so we can let it through...
       _STARPU_WITH_GCC_PLUGIN_API([
 	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gcc-plugin.h>
 	      #include <tree.h>
 	      #include <gimple.h>
 	      tree fndecl; gimple call;]],
-	    [[fndecl = lookup_name (get_identifier ("puts"));
+	    [[/* Clang 3.1 doesn't support nested functions, so try to
+	         discriminate it this way.  */
+	      tree foo (void)
+	      {
+	        return lookup_name (get_identifier ("puts"));
+              }
+	      fndecl = foo ();
 	      call = gimple_build_call (fndecl, 0);]])],
 	  [ac_cv_have_gcc_plugins="yes"],
 	  [ac_cv_have_gcc_plugins="no"])