summaryrefslogtreecommitdiff
path: root/binary/mingw-w64/patches/gcc-4.9-20150204-static-plugin.patch
blob: 4230d5fa75dd30513a4f8183f55efd276e6d82f4 (plain)
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
diff -ru gcc-4.9-20150204/gcc/config.in gcc/gcc/config.in
--- gcc-4.9-20150204/gcc/config.in	2015-02-05 00:32:56.000000000 +0200
+++ gcc/gcc/config.in	2015-02-08 19:58:45.215372260 +0200
@@ -137,6 +137,10 @@
 #undef ENABLE_PLUGIN
 #endif
 
+/* Define to enable static plugin support. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_STATIC_PLUGIN
+#endif
 
 /* Define if you want all operations on RTL (the basic data structure of the
    optimizer and back end) to be checked for dynamic type safety at runtime.
diff -ru gcc-4.9-20150204/gcc/configure.ac gcc/gcc/configure.ac
--- gcc-4.9-20150204/gcc/configure.ac	2014-12-04 20:25:37.000000000 +0200
+++ gcc/gcc/configure.ac	2015-02-08 19:58:45.219372260 +0200
@@ -5519,6 +5519,14 @@
   fi
 fi
 
+AC_ARG_ENABLE(static-plugin,
+[  --enable-static-plugin         enable static plugin support],
+enable_static_plugin=$enableval,
+enable_static_plugin==no)
+
+if test x"$enable_static_plugin" = x"yes"; then
+  AC_DEFINE(ENABLE_STATIC_PLUGIN, 1, [Define to enable static plugin support.])
+fi
 
 # Check for plugin support
 AC_ARG_ENABLE(plugin,
diff -ru gcc-4.9-20150204/gcc/cp/Make-lang.in gcc/gcc/cp/Make-lang.in
--- gcc-4.9-20150204/gcc/cp/Make-lang.in	2014-04-15 10:04:17.000000000 +0200
+++ gcc/gcc/cp/Make-lang.in	2015-02-08 20:01:21.479374174 +0200
@@ -90,14 +90,14 @@
 
 # compute checksum over all object files and the options
 cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
-	$(CXX_OBJS) $(BACKEND) $(LIBDEPS) 
+	$(CXX_OBJS) $(BACKEND) $(LIBDEPS)
 	build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
                      checksum-options > cc1plus-checksum.c.tmp &&	   \
 	$(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c
 
 cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
 	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
-	      $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
+	      $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(STATIC_PLUGIN_LIBS) $(LIBS) $(BACKENDLIBS)
 
 ifeq ($(ENABLE_MAINTAINER_RULES), true)
 # Special build rule.  This is a maintainer rule, that is only
diff -ru gcc-4.9-20150204/gcc/opts-global.c gcc/gcc/opts-global.c
--- gcc-4.9-20150204/gcc/opts-global.c	2014-01-03 00:23:26.000000000 +0200
+++ gcc/gcc/opts-global.c	2015-02-08 19:58:45.223372260 +0200
@@ -381,7 +381,7 @@
 	  break;
 
 	case OPT_fplugin_:
-#ifdef ENABLE_PLUGIN
+#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN)
 	  add_new_plugin (opt->arg);
 #else
 	  error ("plugin support is disabled; configure with --enable-plugin");
@@ -389,7 +389,7 @@
 	  break;
 
 	case OPT_fplugin_arg_:
-#ifdef ENABLE_PLUGIN
+#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN)
 	  parse_plugin_arg_opt (opt->arg);
 #else
 	  error ("plugin support is disabled; configure with --enable-plugin");
diff -ru gcc-4.9-20150204/gcc/plugin.c gcc/gcc/plugin.c
--- gcc-4.9-20150204/gcc/plugin.c	2014-01-03 00:23:26.000000000 +0200
+++ gcc/gcc/plugin.c	2015-02-09 12:40:04.956108359 +0200
@@ -31,7 +31,7 @@
 #include "plugin.h"
 #include "ggc.h"
 
-#ifdef ENABLE_PLUGIN
+#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN)
 #include "plugin-version.h"
 #endif
 
@@ -159,6 +159,7 @@
 
   flag_plugin_added = true;
 
+#ifdef ENABLE_PLUGIN
   /* Replace short names by their full path when relevant.  */
   name_is_short  = !IS_ABSOLUTE_PATH (plugin_name);
   for (pc = plugin_name; name_is_short && *pc; pc++)
@@ -180,6 +181,7 @@
 	   plugin_name, base_name);
     }
   else
+#endif
     base_name = get_plugin_base_name (plugin_name);
 
   /* If this is the first -fplugin= option we encounter, create
@@ -634,6 +636,26 @@
   return 1;
 }
 
+#elif defined(ENABLE_STATIC_PLUGIN)
+
+extern "C" int
+plugin_init (struct plugin_name_args*, struct plugin_gcc_version*);
+
+static int
+init_one_plugin (void **slot, void * ARG_UNUSED (info))
+{
+  struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
+
+  /* Call the plugin-provided initialization routine with the arguments.  */
+  if (plugin_init (plugin, &gcc_version))
+    {
+      error ("Fail to initialize plugin %s", plugin->full_name);
+      htab_remove_elt (plugin_name_args_tab, plugin->base_name);
+      XDELETE (plugin);
+    }
+  return 1;
+}
+
 #endif	/* ENABLE_PLUGIN  */
 
 /* Main plugin initialization function.  Called from compile_file() in
@@ -648,7 +670,7 @@
 
   timevar_push (TV_PLUGIN_INIT);
 
-#ifdef ENABLE_PLUGIN
+#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN)
   /* Traverse and initialize each plugin specified in the command-line.  */
   htab_traverse_noresize (plugin_name_args_tab, init_one_plugin, NULL);
 #endif
diff -ru gcc-4.9-20150204/gcc/plugin.h gcc/gcc/plugin.h
--- gcc-4.9-20150204/gcc/plugin.h	2014-01-03 00:23:26.000000000 +0200
+++ gcc/gcc/plugin.h	2015-02-08 19:58:45.227372260 +0200
@@ -53,7 +53,7 @@
 invoke_plugin_callbacks (int event ATTRIBUTE_UNUSED,
 			 void *gcc_data ATTRIBUTE_UNUSED)
 {
-#ifdef ENABLE_PLUGIN
+#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN)
   /* True iff at least one plugin has been added.  */
   if (flag_plugin_added)
     return invoke_plugin_callbacks_full (event, gcc_data);