瀏覽代碼

gcc: Refer to <starpu.h> by its absolute file name.

* gcc-plugin/src/starpu-gcc-config.h.in (STARPU_INCLUDE_DIR): New macro.
* m4/gcc.m4 (STARPU_GCC_PLUGIN_SUPPORT): Define it.

* gcc-plugin/src/starpu.c (include_dir): New variable.
  (define_cpp_macros): Provide an absolute path
  to <starpu.h>, taking INCLUDE_DIR into account.
  (plugin_init): Check for $STARPU_GCC_INCLUDE_DIR.  Parse plug-in
  command-line arguments.

* gcc-plugin/tests/run-test.in (%default-cflags): Add
  `-fplugin-arg-starpu-include-dir'.
* gcc-plugin/examples/Makefile.am (AM_CFLAGS): Likewise.
Ludovic Courtès 13 年之前
父節點
當前提交
333fdfc70e
共有 5 個文件被更改,包括 51 次插入6 次删除
  1. 5 2
      gcc-plugin/examples/Makefile.am
  2. 3 1
      gcc-plugin/src/starpu-gcc-config.h.in
  3. 34 1
      gcc-plugin/src/starpu.c
  4. 4 1
      gcc-plugin/tests/run-test.in
  5. 5 1
      m4/gcc.m4

+ 5 - 2
gcc-plugin/examples/Makefile.am

@@ -1,6 +1,6 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
-# Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
+# Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
 #
 # StarPU is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
@@ -28,7 +28,10 @@ AM_CPPFLAGS =						\
   -I$(top_srcdir)/examples				\
   $(STARPU_OPENCL_CPPFLAGS) $(STARPU_CUDA_CPPFLAGS)
 
-AM_CFLAGS = -fplugin="$(builddir)/../src/.libs/starpu.so" -Wall
+AM_CFLAGS =							\
+  -fplugin="$(builddir)/../src/.libs/starpu.so"			\
+  -fplugin-arg-starpu-include-dir="$(top_srcdir)/include"	\
+  -Wall
 
 noinst_HEADERS =				\
   cholesky/cholesky.h				\

+ 3 - 1
gcc-plugin/src/starpu-gcc-config.h.in

@@ -1,5 +1,5 @@
 /* GCC-StarPU
-   Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
+   Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
 
    GCC-StarPU is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -29,3 +29,5 @@
 
 #undef HAVE_C_FAMILY_C_PRAGMA_H
 #undef HAVE_C_PRAGMA_H
+
+#undef STARPU_INCLUDE_DIR

+ 34 - 1
gcc-plugin/src/starpu.c

@@ -1909,11 +1909,25 @@ static struct opt_pass pass_lower_starpu =
 
 /* Initialization.  */
 
+/* Directory where to look up <starpu.h> instead of `STARPU_INCLUDE_DIR'.  */
+static const char *include_dir;
+
 static void
 define_cpp_macros (void *gcc_data, void *user_data)
 {
   cpp_define (parse_in, "STARPU_GCC_PLUGIN=0");
-  cpp_push_include (parse_in, "starpu.h");
+
+  if (include_dir)
+    {
+      /* Get the header from the user-specified directory.  This is useful
+	 when running the test suite, before StarPU is installed.  */
+      char header[strlen (include_dir) + sizeof ("/starpu.h")];
+      strcpy (header, include_dir);
+      strcat (header, "/starpu.h");
+      cpp_push_include (parse_in, header);
+    }
+  else
+    cpp_push_include (parse_in, STARPU_INCLUDE_DIR "/starpu.h");
 }
 
 int
@@ -1946,5 +1960,24 @@ plugin_init (struct plugin_name_args *plugin_info,
   register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP,
 		     NULL, &pass_info);
 
+  include_dir = getenv ("STARPU_GCC_INCLUDE_DIR");
+
+  size_t arg;
+  for (arg = 0; arg < plugin_info->argc; arg++)
+    {
+      if (strcmp (plugin_info->argv[arg].key, "include-dir") == 0)
+	{
+	  if (plugin_info->argv[arg].value == NULL)
+	    error_at (UNKNOWN_LOCATION, "missing directory name for option "
+		      "%<-fplugin-arg-starpu-include-dir%>");
+	  else
+	    /* XXX: We assume that `value' has an infinite lifetime.  */
+	    include_dir = plugin_info->argv[arg].value;
+	}
+      else
+	error_at (UNKNOWN_LOCATION, "invalid StarPU plug-in argument %qs",
+		  plugin_info->argv[arg].key);
+    }
+
   return 0;
 }

+ 4 - 1
gcc-plugin/tests/run-test.in

@@ -7,7 +7,7 @@ exec "${GUILE-@GUILE@}" -l "$0"    \
          -c "(apply $main (cdr (command-line)))" "$@"
 !#
 ;;; GCC-StarPU
-;;; Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
+;;; Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
 ;;;
 ;;; GCC-StarPU is free software: you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -85,6 +85,9 @@ exec "${GUILE-@GUILE@}" -l "$0"    \
     ;; the real file name.
     ,(string-append "-fplugin=" %builddir "/../src/.libs/starpu.so")
 
+    ;; Use the non-installed headers.
+    ,(string-append "-fplugin-arg-starpu-include-dir=@top_srcdir@/include")
+
     "-g"
     "-fdump-tree-gimple" "-Wall"))
 

+ 5 - 1
m4/gcc.m4

@@ -1,6 +1,6 @@
 dnl -*- Autoconf -*-
 dnl
-dnl Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
+dnl Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
 dnl
 dnl StarPU is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU Lesser General Public License as published by
@@ -63,6 +63,10 @@ AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
       AC_CHECK_HEADERS([c-common.h c-pragma.h c-family/c-common.h c-family/c-pragma.h],
         [], [], [#include <gcc-plugin.h>
 	         #include <tree.h>])
+
+      AC_DEFINE_UNQUOTED([STARPU_INCLUDE_DIR],
+        ["`eval "echo $includedir"`/starpu/$STARPU_EFFECTIVE_VERSION"],
+        [Define to the directory where StarPU's headers are installed.])
     ])
   fi