diff mbox series

[analyzer] Add -fno-semantic-interposition to PLUGIN_CFLAGS

Message ID 1574463633-24741-1-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series [analyzer] Add -fno-semantic-interposition to PLUGIN_CFLAGS | expand

Commit Message

David Malcolm Nov. 22, 2019, 11 p.m. UTC
An annoying wart with debugging the plugin is that attempts to set
a breakpoint on a function set two breakpoints: on the "funcname@plt",
and on the function itself, making stepping through the code more
awkward than it ought to be.

This patch detects for -fno-semantic-interposition at configure
time, and adds it to PLUGIN_CFLAGS if available, eliminating the
"funcname@plt" entries.

Presumably this also speeds up in-tree plugin code.

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

Pushed to branch "dmalcolm/analyzer" on the GCC git mirror,
along with the autogenerated changes to gcc/configure as a followup

gcc/ChangeLog:
	* Makefile.in (SEM_INTERPOS_FLAGS): New.
	(PLUGIN_CFLAGS): Flesh out comment.  Add SEM_INTERPOS_FLAGS.
	* configure.ac (sem_interpos_flags): Add this, testing for
	-fno-semantic-interposition.
---
 gcc/Makefile.in  | 16 ++++++++++++++--
 gcc/configure.ac | 12 ++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 0587447..224bd75 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -188,6 +188,8 @@  NOEXCEPTION_FLAGS = @noexception_flags@
 
 ALIASING_FLAGS = @aliasing_flags@
 
+SEM_INTERPOS_FLAGS = @sem_interpos_flags@
+
 # This is set by --disable-maintainer-mode (default) to "#"
 # FIXME: 'MAINT' will always be set to an empty string, no matter if
 # --disable-maintainer-mode is used or not.  This is because the
@@ -1786,8 +1788,18 @@  ifneq ($(PLUGIN_MAKEFRAGS),)
 include $(PLUGIN_MAKEFRAGS)
 endif
 
-# Add PLUGIN_CFLAGS to objects that belong to in-tree plugins
-PLUGIN_CFLAGS = -fPIC
+# Define PLUGIN_CFLAGS and add it to objects that belong to in-tree plugins
+#
+# .o files for plugins need to built as position-independent code, hence -fPIC
+#
+# We use -fno-semantic-interposition if available (via SEM_INTERPOS_FLAGS)
+# since it fixes an annoying wart when debugging the plugin, where every
+# attempt to set a breakpoint on a function sets two breakpoints: on the
+# "funcname@plt", and on the function itself, making stepping through the
+# code more awkward than it ought to be.  Presumably this also leads
+# to faster plugin code.
+
+PLUGIN_CFLAGS = -fPIC $(SEM_INTERPOS_FLAGS)
 $(foreach file,$(ALL_HOST_PLUGIN_OBJS),$(eval CFLAGS-$(file) += $(PLUGIN_CFLAGS)))
 
 #
diff --git a/gcc/configure.ac b/gcc/configure.ac
index ff6023e..eb30857 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -461,7 +461,19 @@  if test "$GCC" = yes; then
 fi
 AC_SUBST(aliasing_flags)
 
+sem_interpos_flags=
+if test "$GCC" = yes; then
+  saved_CXXFLAGS="$CXXFLAGS"
+
+  CXXFLAGS="$CXXFLAGS -fno-semantic-interposition"
+  AC_MSG_CHECKING(whether the compiler supports -fno-semantic-interposition)
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
+    [AC_MSG_RESULT([yes]); sem_interpos_flags='-fno-semantic-interposition'],
+    [AC_MSG_RESULT([no])])
 
+  CXXFLAGS="$saved_CXXFLAGS"
+fi
+AC_SUBST(sem_interpos_flags)
 
 # ---------------------
 # Warnings and checking