Patchwork [asan] migrate runtime from llvm

login
register
mail settings
Submitter Wei Mi
Date Oct. 18, 2012, 4:46 p.m.
Message ID <CA+4CFy4U7+FFUzobOS8vypVGSSm97LxvoZ1G7RV4V0ifUDJ2aA@mail.gmail.com>
Download mbox | patch
Permalink /patch/192386/
State New
Headers show

Comments

Wei Mi - Oct. 18, 2012, 4:46 p.m.
Thanks for the comments. I create a dynamic linking libasan and update
the patch.

Thanks,
Wei.

ChangeLog:
2012-10-18   Wei Mi  <wmi@google.com>

migrate llvm runtime to asan branch
* configure.ac: Add libasan to target_libraries
* Makefile.def: Ditto
* configure: Regenerate
* Makefile.in: Regenerate
* libasan: New directory for asan runtime

gcc/ChangeLog:
2012-10-18   Wei Mi  <wmi@google.com>

link pthread and dynamic load library
* gcc/gcc.c: Add -lasan -lpthread -ldl to link command if -fasan is on

On Tue, Oct 16, 2012 at 12:27 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, Oct 15, 2012 at 11:39:52PM -0700, Wei Mi wrote:
>> --- gcc/gcc.c (revision 192487)
>> +++ gcc/gcc.c (working copy)
>> @@ -679,6 +679,7 @@ proper position among the other output f
>>      %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
>>      %(mflib) " STACK_SPLIT_SPEC "\
>>      %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
>> +    %{fasan|coverage:-lasan -lpthread -ldl -lstdc++}\
>>      %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
>>      %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}"
>
> Why the |coverage there?  It isn't related to asan in any way.
> Also, why -lstdc++ in there?  I could understand %{static:-lstdc++}, but
> given that libasan doesn't support static linking, I find it hardly useful.
>
>> --- Makefile.def      (revision 192487)
>> +++ Makefile.def      (working copy)
>> @@ -119,6 +119,7 @@ target_modules = { module= libstdc++-v3;
>>                  lib_path=src/.libs;
>>                  raw_cxx=true; };
>>  target_modules = { module= libmudflap; lib_path=.libs; };
>> +target_modules = { module= libasan; lib_path=.libs; };
>>  target_modules = { module= libssp; lib_path=.libs; };
>>  target_modules = { module= newlib; };
>>  target_modules = { module= libgcc; bootstrap=true; no_check=true; };
>
> Shouldn't libasan, given it is a C++ shared library, depend on libstdc++-v3?
>
>         Jakub
Jakub Jelinek - Oct. 18, 2012, 6:16 p.m.
On Thu, Oct 18, 2012 at 09:46:36AM -0700, Wei Mi wrote:
> --- gcc/gcc.c	(revision 192567)
> +++ gcc/gcc.c	(working copy)
> @@ -679,6 +679,7 @@ proper position among the other output f
>      %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
>      %(mflib) " STACK_SPLIT_SPEC "\
>      %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
> +    %{fasan:-lasan -lpthread -ldl}\
>      %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
>      %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}"
>  #endif

Sorry for not mentioning it earlier at once, but -lpthread -ldl shouldn't
be there either, the -fasan compiled code makes no direct calls to
-lpthread nor -ldl, just libasan.

	Jakub
Wei Mi - Oct. 18, 2012, 8:12 p.m.
On Thu, Oct 18, 2012 at 11:16 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Oct 18, 2012 at 09:46:36AM -0700, Wei Mi wrote:
>> --- gcc/gcc.c (revision 192567)
>> +++ gcc/gcc.c (working copy)
>> @@ -679,6 +679,7 @@ proper position among the other output f
>>      %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
>>      %(mflib) " STACK_SPLIT_SPEC "\
>>      %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
>> +    %{fasan:-lasan -lpthread -ldl}\
>>      %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
>>      %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}"
>>  #endif
>
> Sorry for not mentioning it earlier at once, but -lpthread -ldl shouldn't
> be there either, the -fasan compiled code makes no direct calls to
> -lpthread nor -ldl, just libasan.
>
>         Jakub

Thanks, I move those options to libasan LDFLAGS.

Wei.
Wei Mi - Oct. 19, 2012, 3:04 a.m.
Hi,

David cought a problem in the last patch when he tries to built
libasan. The problem was that an incomplete libtool under libasan
build directory was generated. The cause is that the old patch used an
old ltmain.sh to generate libtool. I fix it and attach a new patch.
And the new patch move -lpthread and -ldl to libasan LDFLAGS.

Thanks,
Wei.
Xinliang David Li - Oct. 19, 2012, 5:16 p.m.
I tried it, and this version works for me.

Your probably do not need to add the m4 subdir under libasan.  The
required m4 files are either in .. or ../config dir. See how
libmudflap does it.

Other than that, if there are no other comments, the change is good to
check into the branch. Remaining bugs can always be found and fixed
later.

thanks,

David



On Thu, Oct 18, 2012 at 8:04 PM, Wei Mi <wmi@google.com> wrote:
> Hi,
>
> David cought a problem in the last patch when he tries to built
> libasan. The problem was that an incomplete libtool under libasan
> build directory was generated. The cause is that the old patch used an
> old ltmain.sh to generate libtool. I fix it and attach a new patch.
> And the new patch move -lpthread and -ldl to libasan LDFLAGS.
>
> Thanks,
> Wei.
Diego Novillo - Oct. 19, 2012, 5:43 p.m.
On 2012-10-19 13:16 , Xinliang David Li wrote:

> Other than that, if there are no other comments, the change is good to
> check into the branch. Remaining bugs can always be found and fixed
> later.

Agreed.  David, could you commit the patch after Wei has addressed your 
feedback?  I have just committed a merge from trunk.

Once the runtime is in, please test patches against it.  We still don't 
have dejagnu glue, so testing will need to be manual at first.


Diego.
Wei Mi - Oct. 19, 2012, 6:02 p.m.
David, I put the m4 subdir under libasan because once I use the .m4
files (libtool.m4  lt~obsolete.m4  ltoptions.m4  ltsugar.m4
ltversion.m4) and ltmain.sh under $topsrcdir, the problem that a bad
libtool was generated under
$topbuilddir/x86_64-unknown-linux-gnu/libasan you met yesterday
appeared.  That is why I had to generate the new libtool m4 files and
ltmain.sh using libtoolize.

Thanks,
Wei.

On Fri, Oct 19, 2012 at 10:16 AM, Xinliang David Li <davidxl@google.com> wrote:
> I tried it, and this version works for me.
>
> Your probably do not need to add the m4 subdir under libasan.  The
> required m4 files are either in .. or ../config dir. See how
> libmudflap does it.
>
> Other than that, if there are no other comments, the change is good to
> check into the branch. Remaining bugs can always be found and fixed
> later.
>
> thanks,
>
> David
>
>
>
> On Thu, Oct 18, 2012 at 8:04 PM, Wei Mi <wmi@google.com> wrote:
>> Hi,
>>
>> David cought a problem in the last patch when he tries to built
>> libasan. The problem was that an incomplete libtool under libasan
>> build directory was generated. The cause is that the old patch used an
>> old ltmain.sh to generate libtool. I fix it and attach a new patch.
>> And the new patch move -lpthread and -ldl to libasan LDFLAGS.
>>
>> Thanks,
>> Wei.

Patch

Index: Makefile.in
===================================================================
--- Makefile.in	(revision 192567)
+++ Makefile.in	(working copy)
@@ -575,7 +575,7 @@  all:
 
 # This is the list of directories that may be needed in RPATH_ENVVAR
 # so that programs built for the target machine work.
-TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libmudflap)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(TARGET_LIB_PATH_libitm)$(TARGET_LIB_PATH_libatomic)$(HOST_LIB_PATH_gcc)
+TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libmudflap)$(TARGET_LIB_PATH_libasan)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(TARGET_LIB_PATH_libitm)$(TARGET_LIB_PATH_libatomic)$(HOST_LIB_PATH_gcc)
 
 @if target-libstdc++-v3
 TARGET_LIB_PATH_libstdc++-v3 = $$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs:
@@ -585,6 +585,10 @@  TARGET_LIB_PATH_libstdc++-v3 = $$r/$(TAR
 TARGET_LIB_PATH_libmudflap = $$r/$(TARGET_SUBDIR)/libmudflap/.libs:
 @endif target-libmudflap
 
+@if target-libasan
+TARGET_LIB_PATH_libasan = $$r/$(TARGET_SUBDIR)/libasan/.libs:
+@endif target-libasan
+
 @if target-libssp
 TARGET_LIB_PATH_libssp = $$r/$(TARGET_SUBDIR)/libssp/.libs:
 @endif target-libssp
@@ -914,6 +918,7 @@  configure-host:  \
 configure-target:  \
     maybe-configure-target-libstdc++-v3 \
     maybe-configure-target-libmudflap \
+    maybe-configure-target-libasan \
     maybe-configure-target-libssp \
     maybe-configure-target-newlib \
     maybe-configure-target-libgcc \
@@ -1062,6 +1067,7 @@  all-host: maybe-all-lto-plugin
 all-target: maybe-all-target-libstdc++-v3
 @endif target-libstdc++-v3-no-bootstrap
 all-target: maybe-all-target-libmudflap
+all-target: maybe-all-target-libasan
 all-target: maybe-all-target-libssp
 all-target: maybe-all-target-newlib
 @if target-libgcc-no-bootstrap
@@ -1152,6 +1158,7 @@  info-host: maybe-info-lto-plugin
 
 info-target: maybe-info-target-libstdc++-v3
 info-target: maybe-info-target-libmudflap
+info-target: maybe-info-target-libasan
 info-target: maybe-info-target-libssp
 info-target: maybe-info-target-newlib
 info-target: maybe-info-target-libgcc
@@ -1233,6 +1240,7 @@  dvi-host: maybe-dvi-lto-plugin
 
 dvi-target: maybe-dvi-target-libstdc++-v3
 dvi-target: maybe-dvi-target-libmudflap
+dvi-target: maybe-dvi-target-libasan
 dvi-target: maybe-dvi-target-libssp
 dvi-target: maybe-dvi-target-newlib
 dvi-target: maybe-dvi-target-libgcc
@@ -1314,6 +1322,7 @@  pdf-host: maybe-pdf-lto-plugin
 
 pdf-target: maybe-pdf-target-libstdc++-v3
 pdf-target: maybe-pdf-target-libmudflap
+pdf-target: maybe-pdf-target-libasan
 pdf-target: maybe-pdf-target-libssp
 pdf-target: maybe-pdf-target-newlib
 pdf-target: maybe-pdf-target-libgcc
@@ -1395,6 +1404,7 @@  html-host: maybe-html-lto-plugin
 
 html-target: maybe-html-target-libstdc++-v3
 html-target: maybe-html-target-libmudflap
+html-target: maybe-html-target-libasan
 html-target: maybe-html-target-libssp
 html-target: maybe-html-target-newlib
 html-target: maybe-html-target-libgcc
@@ -1476,6 +1486,7 @@  TAGS-host: maybe-TAGS-lto-plugin
 
 TAGS-target: maybe-TAGS-target-libstdc++-v3
 TAGS-target: maybe-TAGS-target-libmudflap
+TAGS-target: maybe-TAGS-target-libasan
 TAGS-target: maybe-TAGS-target-libssp
 TAGS-target: maybe-TAGS-target-newlib
 TAGS-target: maybe-TAGS-target-libgcc
@@ -1557,6 +1568,7 @@  install-info-host: maybe-install-info-lt
 
 install-info-target: maybe-install-info-target-libstdc++-v3
 install-info-target: maybe-install-info-target-libmudflap
+install-info-target: maybe-install-info-target-libasan
 install-info-target: maybe-install-info-target-libssp
 install-info-target: maybe-install-info-target-newlib
 install-info-target: maybe-install-info-target-libgcc
@@ -1638,6 +1650,7 @@  install-pdf-host: maybe-install-pdf-lto-
 
 install-pdf-target: maybe-install-pdf-target-libstdc++-v3
 install-pdf-target: maybe-install-pdf-target-libmudflap
+install-pdf-target: maybe-install-pdf-target-libasan
 install-pdf-target: maybe-install-pdf-target-libssp
 install-pdf-target: maybe-install-pdf-target-newlib
 install-pdf-target: maybe-install-pdf-target-libgcc
@@ -1719,6 +1732,7 @@  install-html-host: maybe-install-html-lt
 
 install-html-target: maybe-install-html-target-libstdc++-v3
 install-html-target: maybe-install-html-target-libmudflap
+install-html-target: maybe-install-html-target-libasan
 install-html-target: maybe-install-html-target-libssp
 install-html-target: maybe-install-html-target-newlib
 install-html-target: maybe-install-html-target-libgcc
@@ -1800,6 +1814,7 @@  installcheck-host: maybe-installcheck-lt
 
 installcheck-target: maybe-installcheck-target-libstdc++-v3
 installcheck-target: maybe-installcheck-target-libmudflap
+installcheck-target: maybe-installcheck-target-libasan
 installcheck-target: maybe-installcheck-target-libssp
 installcheck-target: maybe-installcheck-target-newlib
 installcheck-target: maybe-installcheck-target-libgcc
@@ -1881,6 +1896,7 @@  mostlyclean-host: maybe-mostlyclean-lto-
 
 mostlyclean-target: maybe-mostlyclean-target-libstdc++-v3
 mostlyclean-target: maybe-mostlyclean-target-libmudflap
+mostlyclean-target: maybe-mostlyclean-target-libasan
 mostlyclean-target: maybe-mostlyclean-target-libssp
 mostlyclean-target: maybe-mostlyclean-target-newlib
 mostlyclean-target: maybe-mostlyclean-target-libgcc
@@ -1962,6 +1978,7 @@  clean-host: maybe-clean-lto-plugin
 
 clean-target: maybe-clean-target-libstdc++-v3
 clean-target: maybe-clean-target-libmudflap
+clean-target: maybe-clean-target-libasan
 clean-target: maybe-clean-target-libssp
 clean-target: maybe-clean-target-newlib
 clean-target: maybe-clean-target-libgcc
@@ -2043,6 +2060,7 @@  distclean-host: maybe-distclean-lto-plug
 
 distclean-target: maybe-distclean-target-libstdc++-v3
 distclean-target: maybe-distclean-target-libmudflap
+distclean-target: maybe-distclean-target-libasan
 distclean-target: maybe-distclean-target-libssp
 distclean-target: maybe-distclean-target-newlib
 distclean-target: maybe-distclean-target-libgcc
@@ -2124,6 +2142,7 @@  maintainer-clean-host: maybe-maintainer-
 
 maintainer-clean-target: maybe-maintainer-clean-target-libstdc++-v3
 maintainer-clean-target: maybe-maintainer-clean-target-libmudflap
+maintainer-clean-target: maybe-maintainer-clean-target-libasan
 maintainer-clean-target: maybe-maintainer-clean-target-libssp
 maintainer-clean-target: maybe-maintainer-clean-target-newlib
 maintainer-clean-target: maybe-maintainer-clean-target-libgcc
@@ -2260,6 +2279,7 @@  check-host:  \
 check-target:  \
     maybe-check-target-libstdc++-v3 \
     maybe-check-target-libmudflap \
+    maybe-check-target-libasan \
     maybe-check-target-libssp \
     maybe-check-target-newlib \
     maybe-check-target-libgcc \
@@ -2414,6 +2434,7 @@  install-host:  \
 install-target:  \
     maybe-install-target-libstdc++-v3 \
     maybe-install-target-libmudflap \
+    maybe-install-target-libasan \
     maybe-install-target-libssp \
     maybe-install-target-newlib \
     maybe-install-target-libgcc \
@@ -2515,6 +2536,7 @@  install-strip-host:  \
 install-strip-target:  \
     maybe-install-strip-target-libstdc++-v3 \
     maybe-install-strip-target-libmudflap \
+    maybe-install-strip-target-libasan \
     maybe-install-strip-target-libssp \
     maybe-install-strip-target-newlib \
     maybe-install-strip-target-libgcc \
@@ -32337,6 +32359,463 @@  maintainer-clean-target-libmudflap:
 
 
 
+.PHONY: configure-target-libasan maybe-configure-target-libasan
+maybe-configure-target-libasan:
+@if gcc-bootstrap
+configure-target-libasan: stage_current
+@endif gcc-bootstrap
+@if target-libasan
+maybe-configure-target-libasan: configure-target-libasan
+configure-target-libasan: 
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	echo "Checking multilib configuration for libasan..."; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libasan ; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libasan/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libasan/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libasan/multilib.tmp $(TARGET_SUBDIR)/libasan/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libasan/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libasan/Makefile; \
+	    mv $(TARGET_SUBDIR)/libasan/multilib.tmp $(TARGET_SUBDIR)/libasan/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libasan/multilib.tmp $(TARGET_SUBDIR)/libasan/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libasan/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libasan ; \
+	$(NORMAL_TARGET_EXPORTS)  \
+	echo Configuring in $(TARGET_SUBDIR)/libasan; \
+	cd "$(TARGET_SUBDIR)/libasan" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libasan/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libasan"; \
+	libsrcdir="$$s/libasan"; \
+	rm -f no-such-file || : ; \
+	CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption}  \
+	  || exit 1
+@endif target-libasan
+
+
+
+
+
+.PHONY: all-target-libasan maybe-all-target-libasan
+maybe-all-target-libasan:
+@if gcc-bootstrap
+all-target-libasan: stage_current
+@endif gcc-bootstrap
+@if target-libasan
+TARGET-target-libasan=all
+maybe-all-target-libasan: all-target-libasan
+all-target-libasan: configure-target-libasan
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS)  \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+		$(TARGET-target-libasan))
+@endif target-libasan
+
+
+
+
+
+.PHONY: check-target-libasan maybe-check-target-libasan
+maybe-check-target-libasan:
+@if target-libasan
+maybe-check-target-libasan: check-target-libasan
+
+check-target-libasan:
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)   check)
+
+@endif target-libasan
+
+.PHONY: install-target-libasan maybe-install-target-libasan
+maybe-install-target-libasan:
+@if target-libasan
+maybe-install-target-libasan: install-target-libasan
+
+install-target-libasan: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install)
+
+@endif target-libasan
+
+.PHONY: install-strip-target-libasan maybe-install-strip-target-libasan
+maybe-install-strip-target-libasan:
+@if target-libasan
+maybe-install-strip-target-libasan: install-strip-target-libasan
+
+install-strip-target-libasan: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install-strip)
+
+@endif target-libasan
+
+# Other targets (info, dvi, pdf, etc.)
+
+.PHONY: maybe-info-target-libasan info-target-libasan
+maybe-info-target-libasan:
+@if target-libasan
+maybe-info-target-libasan: info-target-libasan
+
+info-target-libasan: \
+    configure-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing info in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           info) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-dvi-target-libasan dvi-target-libasan
+maybe-dvi-target-libasan:
+@if target-libasan
+maybe-dvi-target-libasan: dvi-target-libasan
+
+dvi-target-libasan: \
+    configure-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing dvi in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           dvi) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-pdf-target-libasan pdf-target-libasan
+maybe-pdf-target-libasan:
+@if target-libasan
+maybe-pdf-target-libasan: pdf-target-libasan
+
+pdf-target-libasan: \
+    configure-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing pdf in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           pdf) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-html-target-libasan html-target-libasan
+maybe-html-target-libasan:
+@if target-libasan
+maybe-html-target-libasan: html-target-libasan
+
+html-target-libasan: \
+    configure-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing html in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           html) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-TAGS-target-libasan TAGS-target-libasan
+maybe-TAGS-target-libasan:
+@if target-libasan
+maybe-TAGS-target-libasan: TAGS-target-libasan
+
+TAGS-target-libasan: \
+    configure-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing TAGS in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           TAGS) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-install-info-target-libasan install-info-target-libasan
+maybe-install-info-target-libasan:
+@if target-libasan
+maybe-install-info-target-libasan: install-info-target-libasan
+
+install-info-target-libasan: \
+    configure-target-libasan \
+    info-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-info in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-info) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-install-pdf-target-libasan install-pdf-target-libasan
+maybe-install-pdf-target-libasan:
+@if target-libasan
+maybe-install-pdf-target-libasan: install-pdf-target-libasan
+
+install-pdf-target-libasan: \
+    configure-target-libasan \
+    pdf-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-pdf in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-pdf) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-install-html-target-libasan install-html-target-libasan
+maybe-install-html-target-libasan:
+@if target-libasan
+maybe-install-html-target-libasan: install-html-target-libasan
+
+install-html-target-libasan: \
+    configure-target-libasan \
+    html-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-html in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-html) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-installcheck-target-libasan installcheck-target-libasan
+maybe-installcheck-target-libasan:
+@if target-libasan
+maybe-installcheck-target-libasan: installcheck-target-libasan
+
+installcheck-target-libasan: \
+    configure-target-libasan 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing installcheck in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           installcheck) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-mostlyclean-target-libasan mostlyclean-target-libasan
+maybe-mostlyclean-target-libasan:
+@if target-libasan
+maybe-mostlyclean-target-libasan: mostlyclean-target-libasan
+
+mostlyclean-target-libasan: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing mostlyclean in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           mostlyclean) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-clean-target-libasan clean-target-libasan
+maybe-clean-target-libasan:
+@if target-libasan
+maybe-clean-target-libasan: clean-target-libasan
+
+clean-target-libasan: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing clean in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           clean) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-distclean-target-libasan distclean-target-libasan
+maybe-distclean-target-libasan:
+@if target-libasan
+maybe-distclean-target-libasan: distclean-target-libasan
+
+distclean-target-libasan: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing distclean in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           distclean) \
+	  || exit 1
+
+@endif target-libasan
+
+.PHONY: maybe-maintainer-clean-target-libasan maintainer-clean-target-libasan
+maybe-maintainer-clean-target-libasan:
+@if target-libasan
+maybe-maintainer-clean-target-libasan: maintainer-clean-target-libasan
+
+maintainer-clean-target-libasan: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libasan/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing maintainer-clean in $(TARGET_SUBDIR)/libasan" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libasan && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           maintainer-clean) \
+	  || exit 1
+
+@endif target-libasan
+
+
+
+
+
 .PHONY: configure-target-libssp maybe-configure-target-libssp
 maybe-configure-target-libssp:
 @if gcc-bootstrap
@@ -44591,6 +45070,7 @@  configure-stage4-target-libstdc++-v3: ma
 configure-stageprofile-target-libstdc++-v3: maybe-all-stageprofile-gcc
 configure-stagefeedback-target-libstdc++-v3: maybe-all-stagefeedback-gcc
 configure-target-libmudflap: stage_last
+configure-target-libasan: stage_last
 configure-target-libssp: stage_last
 configure-target-newlib: stage_last
 configure-stage1-target-libgcc: maybe-all-stage1-gcc
@@ -44626,6 +45106,7 @@  configure-target-libatomic: stage_last
 @if gcc-no-bootstrap
 configure-target-libstdc++-v3: maybe-all-gcc
 configure-target-libmudflap: maybe-all-gcc
+configure-target-libasan: maybe-all-gcc
 configure-target-libssp: maybe-all-gcc
 configure-target-newlib: maybe-all-gcc
 configure-target-libgcc: maybe-all-gcc
@@ -45405,6 +45886,7 @@  configure-stagefeedback-target-libgomp:
 @if gcc-no-bootstrap
 configure-target-libstdc++-v3: maybe-all-target-libgcc
 configure-target-libmudflap: maybe-all-target-libgcc
+configure-target-libasan: maybe-all-target-libgcc
 configure-target-libssp: maybe-all-target-libgcc
 configure-target-newlib: maybe-all-target-libgcc
 configure-target-libbacktrace: maybe-all-target-libgcc
@@ -45431,6 +45913,8 @@  configure-target-libstdc++-v3: maybe-all
 
 configure-target-libmudflap: maybe-all-target-newlib maybe-all-target-libgloss
 
+configure-target-libasan: maybe-all-target-newlib maybe-all-target-libgloss
+
 configure-target-libssp: maybe-all-target-newlib maybe-all-target-libgloss
 
 
Index: Makefile.def
===================================================================
--- Makefile.def	(revision 192567)
+++ Makefile.def	(working copy)
@@ -119,6 +119,7 @@  target_modules = { module= libstdc++-v3;
 		   lib_path=src/.libs;
 		   raw_cxx=true; };
 target_modules = { module= libmudflap; lib_path=.libs; };
+target_modules = { module= libasan; lib_path=.libs; };
 target_modules = { module= libssp; lib_path=.libs; };
 target_modules = { module= newlib; };
 target_modules = { module= libgcc; bootstrap=true; no_check=true; };
Index: configure
===================================================================
--- configure	(revision 192567)
+++ configure	(working copy)
@@ -2725,6 +2725,7 @@  target_libraries="target-libgcc \
 		target-libitm \
 		target-libstdc++-v3 \
 		target-libmudflap \
+		target-libasan \
 		target-libssp \
 		target-libquadmath \
 		target-libgfortran \
Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c	(revision 192567)
+++ gcc/gcc.c	(working copy)
@@ -679,6 +679,7 @@  proper position among the other output f
     %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
     %(mflib) " STACK_SPLIT_SPEC "\
     %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
+    %{fasan:-lasan -lpthread -ldl}\
     %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}\
     %{!nostdlib:%{!nostartfiles:%E}} %{T*} }}}}}}"
 #endif
Index: configure.ac
===================================================================
--- configure.ac	(revision 192567)
+++ configure.ac	(working copy)
@@ -160,6 +160,7 @@  target_libraries="target-libgcc \
 		target-libitm \
 		target-libstdc++-v3 \
 		target-libmudflap \
+		target-libasan \
 		target-libssp \
 		target-libquadmath \
 		target-libgfortran \