On October 19, 2017 9:22:09 PM GMT+02:00, Jakub Jelinek <ja...@redhat.com> 
wrote:
>Hi!
>
>The PR claims a bootstrap failure because we link lsan_preinit.cc that
>contains .preinit_array section item into the liblsan shared library.
>
>Of course, this object isn't meant to be linked into the library, but
>rather handled like libasan_preinit.o - linked directly into
>executables.
>The point of these is to initialize the runtimes as early as possible.
>
>I've discovered that we install libtsan_preinit.o, but don't actually
>link it into executables, the patch fixes that too.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK. 

Richard. 

>For the release branches, I'd just go for removing lsan_preinit.cc from
>lsan_files and nothing else.
>
>2017-10-19  Jakub Jelinek  <ja...@redhat.com>
>
>       PR sanitizer/82595
>       * config/gnu-user.h (LIBTSAN_EARLY_SPEC): Add libtsan_preinit.o
>       for -fsanitize=thread link of executables.
>       (LIBLSAN_EARLY_SPEC): Add liblsan_preinit.o for -fsanitize=leak
>       link of executables.
>
>       * lsan/lsan.h (__lsan_init): Add SANITIZER_INTERFACE_ATTRIBUTE.
>       * lsan/Makefile.am (nodist_toolexeclib_HEADERS): Add
>       liblsan_preinit.o.
>       (lsan_files): Remove lsan_preinit.cc.
>       (liblsan_preinit.o): New rule.
>       * lsan/Makefile.in: Regenerated.
>
>--- gcc/config/gnu-user.h.jj   2017-09-13 16:22:13.000000000 +0200
>+++ gcc/config/gnu-user.h      2017-10-19 15:06:11.427688056 +0200
>@@ -162,11 +162,13 @@ see the files COPYING3 and COPYING.RUNTI
>   LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
>   LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
> #undef LIBTSAN_EARLY_SPEC
>-#define LIBTSAN_EARLY_SPEC "%{static-libtsan:%{!shared:" \
>+#define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
>+  "%{static-libtsan:%{!shared:" \
>   LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
>   LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
> #undef LIBLSAN_EARLY_SPEC
>-#define LIBLSAN_EARLY_SPEC "%{static-liblsan:%{!shared:" \
>+#define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
>+  "%{static-liblsan:%{!shared:" \
>   LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
>   LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
> #endif
>--- libsanitizer/lsan/lsan.h.jj        2017-10-19 18:59:17.000000000 +0200
>+++ libsanitizer/lsan/lsan.h   2017-10-19 21:16:09.313551127 +0200
>@@ -64,4 +64,4 @@ void GetStackTraceWithPcBpAndContext(__s
> extern bool lsan_inited;
> extern bool lsan_init_is_running;
> 
>-extern "C" void __lsan_init();
>+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __lsan_init();
>--- libsanitizer/lsan/Makefile.am.jj   2017-10-19 13:20:58.000000000
>+0200
>+++ libsanitizer/lsan/Makefile.am      2017-10-19 15:13:53.280015739 +0200
>@@ -12,6 +12,7 @@ ACLOCAL_AMFLAGS = -I m4
> noinst_LTLIBRARIES = libsanitizer_lsan.la
> if LSAN_SUPPORTED
> toolexeclib_LTLIBRARIES = liblsan.la
>+nodist_toolexeclib_HEADERS = liblsan_preinit.o
> endif
> 
> sanitizer_lsan_files = \
>@@ -27,7 +28,6 @@ lsan_files = \
>       lsan_malloc_mac.cc \
>       lsan_allocator.cc \
>       lsan_interceptors.cc \
>-      lsan_preinit.cc \
>       lsan_thread.cc
> 
> libsanitizer_lsan_la_SOURCES = $(sanitizer_lsan_files)
>@@ -40,6 +40,9 @@ endif
> liblsan_la_LIBADD += $(LIBSTDCXX_RAW_CXX_LDFLAGS)
>liblsan_la_LDFLAGS = -version-info `grep -v '^\#'
>$(srcdir)/libtool-version` $(link_liblsan)
> 
>+liblsan_preinit.o: lsan_preinit.o
>+      cp $< $@
>+
> # Work around what appears to be a GNU make bug handling MAKEFLAGS
> # values defined in terms of make variables, as is the case for CC and
> # friends when we are called from the top level Makefile.
>--- libsanitizer/lsan/Makefile.in.jj   2017-10-19 13:20:58.000000000
>+0200
>+++ libsanitizer/lsan/Makefile.in      2017-10-19 15:14:17.530717247 +0200
>@@ -15,6 +15,7 @@
> 
> @SET_MAKE@
> 
>+
> VPATH = @srcdir@
> am__make_dryrun = \
>   { \
>@@ -100,7 +101,8 @@ am__uninstall_files_from_dir = { \
>     || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
>          $(am__cd) "$$dir" && rm -f $$files; }; \
>   }
>-am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
>+am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \
>+      "$(DESTDIR)$(toolexeclibdir)"
> LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES)
> am__DEPENDENCIES_1 =
> liblsan_la_DEPENDENCIES =  \
>@@ -110,7 +112,7 @@ liblsan_la_DEPENDENCIES =  \
> am__objects_1 = lsan_common.lo lsan_common_linux.lo lsan_common_mac.lo
> am__objects_2 = $(am__objects_1) lsan.lo lsan_linux.lo lsan_mac.lo \
>       lsan_malloc_mac.lo lsan_allocator.lo lsan_interceptors.lo \
>-      lsan_preinit.lo lsan_thread.lo
>+      lsan_thread.lo
> am_liblsan_la_OBJECTS = $(am__objects_2)
> liblsan_la_OBJECTS = $(am_liblsan_la_OBJECTS)
> liblsan_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
>@@ -139,6 +141,7 @@ am__can_run_installinfo = \
>     n|no|NO) false;; \
>     *) (install-info --version) >/dev/null 2>&1;; \
>   esac
>+HEADERS = $(nodist_toolexeclib_HEADERS)
> ETAGS = etags
> CTAGS = ctags
> ACLOCAL = @ACLOCAL@
>@@ -298,6 +301,7 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-param
> ACLOCAL_AMFLAGS = -I m4
> noinst_LTLIBRARIES = libsanitizer_lsan.la
> @LSAN_SUPPORTED_TRUE@toolexeclib_LTLIBRARIES = liblsan.la
>+@LSAN_SUPPORTED_TRUE@nodist_toolexeclib_HEADERS = liblsan_preinit.o
> sanitizer_lsan_files = \
>       lsan_common.cc \
>       lsan_common_linux.cc \
>@@ -311,7 +315,6 @@ lsan_files = \
>       lsan_malloc_mac.cc \
>       lsan_allocator.cc \
>       lsan_interceptors.cc \
>-      lsan_preinit.cc \
>       lsan_thread.cc
> 
> libsanitizer_lsan_la_SOURCES = $(sanitizer_lsan_files)
>@@ -456,7 +459,6 @@ distclean-compile:
>@AMDEP_TRUE@@am__include@
>@am__quote@./$(DEPDIR)/lsan_linux.Plo@am__quote@
>@AMDEP_TRUE@@am__include@
>@am__quote@./$(DEPDIR)/lsan_mac.Plo@am__quote@
>@AMDEP_TRUE@@am__include@
>@am__quote@./$(DEPDIR)/lsan_malloc_mac.Plo@am__quote@
>-@AMDEP_TRUE@@am__include@
>@am__quote@./$(DEPDIR)/lsan_preinit.Plo@am__quote@
>@AMDEP_TRUE@@am__include@
>@am__quote@./$(DEPDIR)/lsan_thread.Plo@am__quote@
> 
> .cc.o:
>@@ -485,6 +487,27 @@ mostlyclean-libtool:
> 
> clean-libtool:
>       -rm -rf .libs _libs
>+install-nodist_toolexeclibHEADERS: $(nodist_toolexeclib_HEADERS)
>+      @$(NORMAL_INSTALL)
>+      @list='$(nodist_toolexeclib_HEADERS)'; test -n "$(toolexeclibdir)" ||
>list=; \
>+      if test -n "$$list"; then \
>+        echo " $(MKDIR_P) '$(DESTDIR)$(toolexeclibdir)'"; \
>+        $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" || exit 1; \
>+      fi; \
>+      for p in $$list; do \
>+        if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
>+        echo "$$d$$p"; \
>+      done | $(am__base_list) | \
>+      while read files; do \
>+        echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(toolexeclibdir)'"; \
>+        $(INSTALL_HEADER) $$files "$(DESTDIR)$(toolexeclibdir)" || exit
>$$?; \
>+      done
>+
>+uninstall-nodist_toolexeclibHEADERS:
>+      @$(NORMAL_UNINSTALL)
>+      @list='$(nodist_toolexeclib_HEADERS)'; test -n "$(toolexeclibdir)" ||
>list=; \
>+      files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
>+      dir='$(DESTDIR)$(toolexeclibdir)'; $(am__uninstall_files_from_dir)
> 
> ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
>       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
>@@ -539,9 +562,9 @@ distclean-tags:
>       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
> check-am: all-am
> check: check-am
>-all-am: Makefile $(LTLIBRARIES)
>+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
> installdirs:
>-      for dir in "$(DESTDIR)$(toolexeclibdir)"; do \
>+      for dir in "$(DESTDIR)$(toolexeclibdir)"
>"$(DESTDIR)$(toolexeclibdir)"; do \
>         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
>       done
> install: install-am
>@@ -603,7 +626,8 @@ install-dvi: install-dvi-am
> 
> install-dvi-am:
> 
>-install-exec-am: install-toolexeclibLTLIBRARIES
>+install-exec-am: install-nodist_toolexeclibHEADERS \
>+      install-toolexeclibLTLIBRARIES
> 
> install-html: install-html-am
> 
>@@ -643,7 +667,8 @@ ps: ps-am
> 
> ps-am:
> 
>-uninstall-am: uninstall-toolexeclibLTLIBRARIES
>+uninstall-am: uninstall-nodist_toolexeclibHEADERS \
>+      uninstall-toolexeclibLTLIBRARIES
> 
> .MAKE: install-am install-strip
> 
>@@ -654,14 +679,19 @@ uninstall-am: uninstall-toolexeclibLTLIB
>       html html-am info info-am install install-am install-data \
>       install-data-am install-dvi install-dvi-am install-exec \
>       install-exec-am install-html install-html-am install-info \
>-      install-info-am install-man install-pdf install-pdf-am \
>-      install-ps install-ps-am install-strip \
>-      install-toolexeclibLTLIBRARIES installcheck installcheck-am \
>-      installdirs maintainer-clean maintainer-clean-generic \
>-      mostlyclean mostlyclean-compile mostlyclean-generic \
>-      mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
>-      uninstall-am uninstall-toolexeclibLTLIBRARIES
>+      install-info-am install-man install-nodist_toolexeclibHEADERS \
>+      install-pdf install-pdf-am install-ps install-ps-am \
>+      install-strip install-toolexeclibLTLIBRARIES installcheck \
>+      installcheck-am installdirs maintainer-clean \
>+      maintainer-clean-generic mostlyclean mostlyclean-compile \
>+      mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
>+      tags uninstall uninstall-am \
>+      uninstall-nodist_toolexeclibHEADERS \
>+      uninstall-toolexeclibLTLIBRARIES
>+
> 
>+liblsan_preinit.o: lsan_preinit.o
>+      cp $< $@
> 
> # Tell versions [3.59,3.63) of GNU make to not export all variables.
> # Otherwise a system limit (for SysV at least) may be exceeded.
>
>       Jakub

Reply via email to