It turns out that all of my testing of the analyzer has been with
--enable-host-shared; on building without it, the link of the plugin
failed with messages like this for all of the .o file:
  /usr/bin/ld: analyzer/analysis-plan.o: relocation R_X86_64_32 against 
`.rodata' can not be used when making a shared object; recompile with -fPIC

This patch adds a PLUGIN_CFLAGS to the Makefile.in and automatically
adds it to the CFLAGS of all .o files for in-tree plugins.

PLUGIN_CFLAGS has -fPIC, fixing the link error.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

Pushed to branch "dmalcolm/analyzer" on the GCC git mirror.

gcc/ChangeLog:
        * Makefile.in (PLUGIN_CFLAGS): New.  Add it to CFLAGS of
        all .o files for in-tree plugins.
---
 gcc/Makefile.in | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 9d398fe..0587447 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1786,6 +1786,10 @@ ifneq ($(PLUGIN_MAKEFRAGS),)
 include $(PLUGIN_MAKEFRAGS)
 endif
 
+# Add PLUGIN_CFLAGS to objects that belong to in-tree plugins
+PLUGIN_CFLAGS = -fPIC
+$(foreach file,$(ALL_HOST_PLUGIN_OBJS),$(eval CFLAGS-$(file) += 
$(PLUGIN_CFLAGS)))
+
 #
 
 # -----------------------------
-- 
1.8.5.3

Reply via email to