[analyzer] Introduce PLUGIN_CFLAGS
diff mbox series

Message ID 1574366043-20716-1-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series
  • [analyzer] Introduce PLUGIN_CFLAGS
Related show

Commit Message

David Malcolm Nov. 21, 2019, 7:54 p.m. UTC
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(+)

Patch
diff mbox series

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)))
+
 #
 
 # -----------------------------