[analyzer] Introduce PLUGIN_CFLAGS

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

Commit Message

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

	* 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),)
+# Add PLUGIN_CFLAGS to objects that belong to in-tree plugins
+$(foreach file,$(ALL_HOST_PLUGIN_OBJS),$(eval CFLAGS-$(file) += $(PLUGIN_CFLAGS)))
 # -----------------------------