public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH Filter out -fsanitize=address if not in combined tree in lto-plugin
@ 2012-11-29 17:38 H.J. Lu
  2012-11-29 17:40 ` [PATCH] Filter out -fsanitize=address if not in combined tree in libiberty H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2012-11-29 17:38 UTC (permalink / raw)
  To: gcc-patches

Hi,

When GCC is configured with --with-build-config="bootstrap-asan", all
-flto tests will fail since -fsanitize=address is used to compile
liblto_plugin.so and linker isn't compiled with -fsanitize=address.
This patch filters out -fsanitize=address from CFLAGS if we aren't
in a combined tree with binutils.  OK to install?


H.J.
---
---
 lto-plugin/Makefile.am    |  7 +++++++
 lto-plugin/Makefile.in    |  5 +++++
 lto-plugin/configure      | 18 +++++++++++++++---
 lto-plugin/configure.ac   |  4 ++++
 5 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 lto-plugin/ChangeLog.asan

2012-11-21  H.J. Lu  <hongjiu.lu@intel.com>

	* Makefile.am (CFLAGS): Filter out -fsanitize=address if not
	in a combined tree of GCC and binutils.
	(LDFLAGS): Likewise.
	* configure.ac (COMBINED_TREE): New AM_CONDITIONAL.
	* Makefile.in: Regenerated.
	* configure: Likewise.

diff --git a/lto-plugin/Makefile.am b/lto-plugin/Makefile.am
index b24015e..d90c555 100644
--- a/lto-plugin/Makefile.am
+++ b/lto-plugin/Makefile.am
@@ -18,6 +18,13 @@ in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib))
 # Can be removed when libiberty becomes a normal convenience library
 Wc=-Wc,
 
+if !COMBINED_TREE
+# Filter out -fsanitize=address if we aren't in a combined tree with
+# GCC and binutils.
+override CFLAGS := $(filter-out -fsanitize=address,$(CFLAGS))
+override LDFLAGS := $(filter-out -fsanitize=address,$(LDFLAGS))
+endif
+
 liblto_plugin_la_SOURCES = lto-plugin.c
 liblto_plugin_la_LIBADD = \
 	$(if $(wildcard ../libiberty/pic/libiberty.a),$(Wc)../libiberty/pic/libiberty.a,)
diff --git a/lto-plugin/Makefile.in b/lto-plugin/Makefile.in
index 0c8d89f..14e6f67 100644
--- a/lto-plugin/Makefile.in
+++ b/lto-plugin/Makefile.in
@@ -535,6 +535,11 @@ uninstall-am: uninstall-libexecsubLTLIBRARIES
 	uninstall-libexecsubLTLIBRARIES
 
 
+# Filter out -fsanitize=address if we aren't in a combined tree with
+# GCC and binutils.
+@COMBINED_TREE_FALSE@override CFLAGS := $(filter-out -fsanitize=address,$(CFLAGS))
+@COMBINED_TREE_FALSE@override LDFLAGS := $(filter-out -fsanitize=address,$(LDFLAGS))
+
 all-local: $(in_gcc_libs)
 
 $(in_gcc_libs) : $(gcc_build_dir)/%: %
diff --git a/lto-plugin/configure b/lto-plugin/configure
index 4900d80..80f3ac6 100755
--- a/lto-plugin/configure
+++ b/lto-plugin/configure
@@ -597,7 +597,9 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='am__EXEEXT_FALSE
+ac_subst_vars='COMBINED_TREE_FALSE
+COMBINED_TREE_TRUE
+am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
@@ -10552,7 +10554,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10555 "configure"
+#line 10557 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10658,7 +10660,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10661 "configure"
+#line 10663 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13318,3 +13320,13 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
+
+# Check if this is a combined tree with GCC and binutils.
+ if test -e ${ac_top_srcdir}/ld/ldmain.c -o -e ${ac_top_srcdir}/gold/version.cc; then
+  COMBINED_TREE_TRUE=
+  COMBINED_TREE_FALSE='#'
+else
+  COMBINED_TREE_TRUE='#'
+  COMBINED_TREE_FALSE=
+fi
+
diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
index 9a418d2..526186a 100644
--- a/lto-plugin/configure.ac
+++ b/lto-plugin/configure.ac
@@ -16,3 +16,7 @@ AC_HEADER_SYS_WAIT
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_HEADERS(config.h)
 AC_OUTPUT
+
+# Check if this is a combined tree with GCC and binutils.
+AM_CONDITIONAL(COMBINED_TREE,
+  test -e ${ac_top_srcdir}/ld/ldmain.c -o -e ${ac_top_srcdir}/gold/version.cc)
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Filter out -fsanitize=address if not in combined tree in libiberty
  2012-11-29 17:38 [PATCH Filter out -fsanitize=address if not in combined tree in lto-plugin H.J. Lu
@ 2012-11-29 17:40 ` H.J. Lu
  2012-11-30  9:01   ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2012-11-29 17:40 UTC (permalink / raw)
  To: gcc-patches

Hi,

When GCC is configured with --with-build-config="bootstrap-asan", all
-flto tests will fail since -fsanitize=address is used to compile host
libiberty, which is used to create liblto_plugin.so, and linker isn't
compiled with -fsanitize=address.  This patch filters out
-fsanitize=address from CFLAGS if we aren't in a combined tree with
binutils.  OK to install?

Thanks.

H.J.
---
2012-11-21  H.J. Lu  <hongjiu.lu@intel.com>

	* Makefile.in (CFLAGS): Filter out -fsanitize=address if in GCC
	tree, but not in a combined tree with binutils.
	* configure.ac (COMBINED_TREE_FALSE): New AC_SUBST.
	* configure: Regenerated.

diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 1ba8cf1..2d357d7 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -63,6 +63,10 @@ PERL = @PERL@
 
 PICFLAG = @PICFLAG@
 
+# Filter out -fsanitize=address if we are in GCC tree, but aren't in a
+# combined tree with binutils.
+@COMBINED_TREE_FALSE@override CFLAGS := $(filter-out -fsanitize=address,$(CFLAGS))
+
 MAKEOVERRIDES =
 
 TARGETLIB = ./libiberty.a
diff --git a/libiberty/configure b/libiberty/configure
index 5367027..4869cd5 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -590,6 +590,7 @@ ac_includes_default="\
 
 ac_subst_vars='LTLIBOBJS
 INSTALL_DEST
+COMBINED_TREE_FALSE
 pexecute
 target_header_dir
 CHECK
@@ -6917,6 +6918,20 @@ esac
 fi
 
 
+# Check if this is in GCC tree, but aren't in a combined tree with
+# binutils.
+if test -e ${srcdir}/../gcc/gcc.c; then
+  if test -e ${srcdir}/../ld/ldmain.c -o \
+	  -e ${top_srcdir}/../gold/version.cc; then
+    COMBINED_TREE_FALSE='#'
+  else
+    COMBINED_TREE_FALSE=''
+  fi
+else
+  COMBINED_TREE_FALSE='#'
+fi
+
+
 # Install a library built with a cross compiler in $(tooldir) rather
 # than $(libdir).
 if test -z "${with_cross_host}"; then
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index c763894..7661752 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -670,6 +670,20 @@ AC_SUBST(pexecute)
 
 libiberty_AC_FUNC_STRNCMP
 
+# Check if this is in GCC tree, but aren't in a combined tree with
+# binutils.
+if test -e ${srcdir}/../gcc/gcc.c; then
+  if test -e ${srcdir}/../ld/ldmain.c -o \
+	  -e ${top_srcdir}/../gold/version.cc; then
+    COMBINED_TREE_FALSE='#'
+  else
+    COMBINED_TREE_FALSE=''
+  fi
+else
+  COMBINED_TREE_FALSE='#'
+fi
+AC_SUBST(COMBINED_TREE_FALSE)
+
 # Install a library built with a cross compiler in $(tooldir) rather
 # than $(libdir).
 if test -z "${with_cross_host}"; then
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Filter out -fsanitize=address if not in combined tree in libiberty
  2012-11-29 17:40 ` [PATCH] Filter out -fsanitize=address if not in combined tree in libiberty H.J. Lu
@ 2012-11-30  9:01   ` Richard Biener
  2012-11-30 13:17     ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Biener @ 2012-11-30  9:01 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches

On Thu, Nov 29, 2012 at 6:40 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Hi,
>
> When GCC is configured with --with-build-config="bootstrap-asan", all
> -flto tests will fail since -fsanitize=address is used to compile host
> libiberty, which is used to create liblto_plugin.so, and linker isn't
> compiled with -fsanitize=address.  This patch filters out
> -fsanitize=address from CFLAGS if we aren't in a combined tree with
> binutils.  OK to install?

Why not simply ensure that only host _executables_ are sanitized?

Richard.

> Thanks.
>
> H.J.
> ---
> 2012-11-21  H.J. Lu  <hongjiu.lu@intel.com>
>
>         * Makefile.in (CFLAGS): Filter out -fsanitize=address if in GCC
>         tree, but not in a combined tree with binutils.
>         * configure.ac (COMBINED_TREE_FALSE): New AC_SUBST.
>         * configure: Regenerated.
>
> diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
> index 1ba8cf1..2d357d7 100644
> --- a/libiberty/Makefile.in
> +++ b/libiberty/Makefile.in
> @@ -63,6 +63,10 @@ PERL = @PERL@
>
>  PICFLAG = @PICFLAG@
>
> +# Filter out -fsanitize=address if we are in GCC tree, but aren't in a
> +# combined tree with binutils.
> +@COMBINED_TREE_FALSE@override CFLAGS := $(filter-out -fsanitize=address,$(CFLAGS))
> +
>  MAKEOVERRIDES =
>
>  TARGETLIB = ./libiberty.a
> diff --git a/libiberty/configure b/libiberty/configure
> index 5367027..4869cd5 100755
> --- a/libiberty/configure
> +++ b/libiberty/configure
> @@ -590,6 +590,7 @@ ac_includes_default="\
>
>  ac_subst_vars='LTLIBOBJS
>  INSTALL_DEST
> +COMBINED_TREE_FALSE
>  pexecute
>  target_header_dir
>  CHECK
> @@ -6917,6 +6918,20 @@ esac
>  fi
>
>
> +# Check if this is in GCC tree, but aren't in a combined tree with
> +# binutils.
> +if test -e ${srcdir}/../gcc/gcc.c; then
> +  if test -e ${srcdir}/../ld/ldmain.c -o \
> +         -e ${top_srcdir}/../gold/version.cc; then
> +    COMBINED_TREE_FALSE='#'
> +  else
> +    COMBINED_TREE_FALSE=''
> +  fi
> +else
> +  COMBINED_TREE_FALSE='#'
> +fi
> +
> +
>  # Install a library built with a cross compiler in $(tooldir) rather
>  # than $(libdir).
>  if test -z "${with_cross_host}"; then
> diff --git a/libiberty/configure.ac b/libiberty/configure.ac
> index c763894..7661752 100644
> --- a/libiberty/configure.ac
> +++ b/libiberty/configure.ac
> @@ -670,6 +670,20 @@ AC_SUBST(pexecute)
>
>  libiberty_AC_FUNC_STRNCMP
>
> +# Check if this is in GCC tree, but aren't in a combined tree with
> +# binutils.
> +if test -e ${srcdir}/../gcc/gcc.c; then
> +  if test -e ${srcdir}/../ld/ldmain.c -o \
> +         -e ${top_srcdir}/../gold/version.cc; then
> +    COMBINED_TREE_FALSE='#'
> +  else
> +    COMBINED_TREE_FALSE=''
> +  fi
> +else
> +  COMBINED_TREE_FALSE='#'
> +fi
> +AC_SUBST(COMBINED_TREE_FALSE)
> +
>  # Install a library built with a cross compiler in $(tooldir) rather
>  # than $(libdir).
>  if test -z "${with_cross_host}"; then
> --
> 1.7.11.7
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Filter out -fsanitize=address if not in combined tree in libiberty
  2012-11-30  9:01   ` Richard Biener
@ 2012-11-30 13:17     ` H.J. Lu
  2012-11-30 13:33       ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2012-11-30 13:17 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Fri, Nov 30, 2012 at 12:45 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Thu, Nov 29, 2012 at 6:40 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> Hi,
>>
>> When GCC is configured with --with-build-config="bootstrap-asan", all
>> -flto tests will fail since -fsanitize=address is used to compile host
>> libiberty, which is used to create liblto_plugin.so, and linker isn't
>> compiled with -fsanitize=address.  This patch filters out
>> -fsanitize=address from CFLAGS if we aren't in a combined tree with
>> binutils.  OK to install?
>
> Why not simply ensure that only host _executables_ are sanitized?
>

Host libiberty library is used to create both host executables and
host plugins. We don't have separate host libiberty libraries for them.


-- 
H.J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Filter out -fsanitize=address if not in combined tree in libiberty
  2012-11-30 13:17     ` H.J. Lu
@ 2012-11-30 13:33       ` Richard Biener
  2012-11-30 14:21         ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Biener @ 2012-11-30 13:33 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches

On Fri, Nov 30, 2012 at 2:17 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Nov 30, 2012 at 12:45 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Thu, Nov 29, 2012 at 6:40 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>> Hi,
>>>
>>> When GCC is configured with --with-build-config="bootstrap-asan", all
>>> -flto tests will fail since -fsanitize=address is used to compile host
>>> libiberty, which is used to create liblto_plugin.so, and linker isn't
>>> compiled with -fsanitize=address.  This patch filters out
>>> -fsanitize=address from CFLAGS if we aren't in a combined tree with
>>> binutils.  OK to install?
>>
>> Why not simply ensure that only host _executables_ are sanitized?
>>
>
> Host libiberty library is used to create both host executables and
> host plugins. We don't have separate host libiberty libraries for them.

So don't instrument libiberty then.

Richard.

>
> --
> H.J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Filter out -fsanitize=address if not in combined tree in libiberty
  2012-11-30 13:33       ` Richard Biener
@ 2012-11-30 14:21         ` H.J. Lu
  0 siblings, 0 replies; 6+ messages in thread
From: H.J. Lu @ 2012-11-30 14:21 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Fri, Nov 30, 2012 at 5:30 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Fri, Nov 30, 2012 at 2:17 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Fri, Nov 30, 2012 at 12:45 AM, Richard Biener
>> <richard.guenther@gmail.com> wrote:
>>> On Thu, Nov 29, 2012 at 6:40 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>>> Hi,
>>>>
>>>> When GCC is configured with --with-build-config="bootstrap-asan", all
>>>> -flto tests will fail since -fsanitize=address is used to compile host
>>>> libiberty, which is used to create liblto_plugin.so, and linker isn't
>>>> compiled with -fsanitize=address.  This patch filters out
>>>> -fsanitize=address from CFLAGS if we aren't in a combined tree with
>>>> binutils.  OK to install?
>>>
>>> Why not simply ensure that only host _executables_ are sanitized?
>>>
>>
>> Host libiberty library is used to create both host executables and
>> host plugins. We don't have separate host libiberty libraries for them.
>
> So don't instrument libiberty then.
>

When you bootstrap, all host libraries are compiled with the
same CFLAGS as gcc itself in 3 stages.  That means stage2
and stage3 libiberty are compiled with -fsanitize=address if
it is added to stage2/stage3 CFLAGS for gcc.  My patch filters it
out when compiling stage2/stage3 libiberty.

-- 
H.J.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-30 13:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-29 17:38 [PATCH Filter out -fsanitize=address if not in combined tree in lto-plugin H.J. Lu
2012-11-29 17:40 ` [PATCH] Filter out -fsanitize=address if not in combined tree in libiberty H.J. Lu
2012-11-30  9:01   ` Richard Biener
2012-11-30 13:17     ` H.J. Lu
2012-11-30 13:33       ` Richard Biener
2012-11-30 14:21         ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).