Message ID | 20211030205350.35085-1-hjl.tools@gmail.com |
---|---|
State | New |
Headers | show |
Series | libsanitizer: Disable libbacktrace on sanitizer_platform_limits_freebsd.cpp | expand |
On Sat, Oct 30, 2021 at 10:54 PM H.J. Lu via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > sanitizer_platform_limits_freebsd.cpp must include <md5.h> from the OS, > not include/md5.h in GCC source tree which is included by libbacktrace > support. Disable libbacktrace on sanitizer_platform_limits_freebsd.cpp > to avoid include/md5.h to restore bootstrap on FreeBSD. Err, but that will just get complaints about disabled libbacktrace backtracking (from within the sanitizer?)? > PR bootstrap/102675 > * sanitizer_common/Makefile.am (AM_CXXFLAGS): Extract libbacktrace > CXXFLAGS to ... > (LIBBACKTRACE_CXXFLAGS): Here. New. > (sanitizer_common_files): Move sanitizer_platform_limits_freebsd.cpp > to ... > (sanitizer_common_files_no_libbacktrace): Here. New. > (AM_CXXFLAGS): Add $(LIBBACKTRACE_CXXFLAGS) for > $(sanitizer_common_files). > (libsanitizer_common_la_SOURCES): Add > $(sanitizer_common_files_no_libbacktrace). > * sanitizer_common/Makefile.in: Regenerate. > --- > libsanitizer/sanitizer_common/Makefile.am | 24 +++++++++++----- > libsanitizer/sanitizer_common/Makefile.in | 35 ++++++++++++++++------- > 2 files changed, 41 insertions(+), 18 deletions(-) > > diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am > index d04f2d8bd16..0ea459c2b3a 100644 > --- a/libsanitizer/sanitizer_common/Makefile.am > +++ b/libsanitizer/sanitizer_common/Makefile.am > @@ -9,11 +9,12 @@ AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) > AM_CXXFLAGS += -std=gnu++14 > AM_CXXFLAGS += $(EXTRA_CXXFLAGS) > if LIBBACKTRACE_SUPPORTED > -AM_CXXFLAGS += -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ > - -I $(top_srcdir)/../libbacktrace \ > - -I $(top_builddir)/libbacktrace \ > - -I $(top_srcdir)/../include \ > - -include $(top_srcdir)/libbacktrace/backtrace-rename.h > +LIBBACKTRACE_CXXFLAGS = \ > + -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ > + -I $(top_srcdir)/../libbacktrace \ > + -I $(top_builddir)/libbacktrace \ > + -I $(top_srcdir)/../include \ > + -include $(top_srcdir)/libbacktrace/backtrace-rename.h > endif > AM_CCASFLAGS = $(EXTRA_ASFLAGS) > ACLOCAL_AMFLAGS = -I m4 > @@ -45,7 +46,6 @@ sanitizer_common_files = \ > sanitizer_netbsd.cpp \ > sanitizer_openbsd.cpp \ > sanitizer_persistent_allocator.cpp \ > - sanitizer_platform_limits_freebsd.cpp \ > sanitizer_platform_limits_linux.cpp \ > sanitizer_platform_limits_openbsd.cpp \ > sanitizer_platform_limits_posix.cpp \ > @@ -81,8 +81,18 @@ sanitizer_common_files = \ > sanitizer_unwind_win.cpp \ > sanitizer_win.cpp > > +# Don't add $(LIBBACKTRACE_CXXFLAGS) for the following files: > +# 1. sanitizer_platform_limits_freebsd.cpp must include <md5.h> from > +# the OS, not include/md5.h in GCC source tree. > +sanitizer_common_files_no_libbacktrace = \ > + sanitizer_platform_limits_freebsd.cpp > > -libsanitizer_common_la_SOURCES = $(sanitizer_common_files) > +$(sanitizer_common_files:.cpp=.lo) \ > + $(sanitizer_common_files:.cpp=.$(OBJEXT)): AM_CXXFLAGS += $(LIBBACKTRACE_CXXFLAGS) > + > +libsanitizer_common_la_SOURCES = \ > + $(sanitizer_common_files) \ > + $(sanitizer_common_files_no_libbacktrace) > libsanitizer_common_la_LIBADD = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) > libsanitizer_common_la_DEPENDENCIES = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) > > diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in > index 2856894d62b..1433db2238b 100644 > --- a/libsanitizer/sanitizer_common/Makefile.in > +++ b/libsanitizer/sanitizer_common/Makefile.in > @@ -89,12 +89,6 @@ POST_UNINSTALL = : > build_triplet = @build@ > host_triplet = @host@ > target_triplet = @target@ > -@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ > -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../libbacktrace \ > -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_builddir)/libbacktrace \ > -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../include \ > -@LIBBACKTRACE_SUPPORTED_TRUE@ -include $(top_srcdir)/libbacktrace/backtrace-rename.h > - > subdir = sanitizer_common > ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 > am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ > @@ -131,7 +125,6 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \ > sanitizer_mac.lo sanitizer_mac_libcdep.lo sanitizer_mutex.lo \ > sanitizer_netbsd.lo sanitizer_openbsd.lo \ > sanitizer_persistent_allocator.lo \ > - sanitizer_platform_limits_freebsd.lo \ > sanitizer_platform_limits_linux.lo \ > sanitizer_platform_limits_openbsd.lo \ > sanitizer_platform_limits_posix.lo \ > @@ -153,7 +146,8 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \ > sanitizer_thread_registry.lo sanitizer_tls_get_addr.lo \ > sanitizer_unwind_linux_libcdep.lo sanitizer_unwind_win.lo \ > sanitizer_win.lo > -am_libsanitizer_common_la_OBJECTS = $(am__objects_1) > +am__objects_2 = sanitizer_platform_limits_freebsd.lo > +am_libsanitizer_common_la_OBJECTS = $(am__objects_1) $(am__objects_2) > libsanitizer_common_la_OBJECTS = $(am_libsanitizer_common_la_OBJECTS) > AM_V_lt = $(am__v_lt_@AM_V@) > am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) > @@ -376,7 +370,14 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ > -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ > -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ > -Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \ > - -std=gnu++14 $(EXTRA_CXXFLAGS) $(am__append_1) > + -std=gnu++14 $(EXTRA_CXXFLAGS) > +@LIBBACKTRACE_SUPPORTED_TRUE@LIBBACKTRACE_CXXFLAGS = \ > +@LIBBACKTRACE_SUPPORTED_TRUE@ -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ > +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../libbacktrace \ > +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_builddir)/libbacktrace \ > +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../include \ > +@LIBBACKTRACE_SUPPORTED_TRUE@ -include $(top_srcdir)/libbacktrace/backtrace-rename.h > + > AM_CCASFLAGS = $(EXTRA_ASFLAGS) > ACLOCAL_AMFLAGS = -I m4 > noinst_LTLIBRARIES = libsanitizer_common.la > @@ -405,7 +406,6 @@ sanitizer_common_files = \ > sanitizer_netbsd.cpp \ > sanitizer_openbsd.cpp \ > sanitizer_persistent_allocator.cpp \ > - sanitizer_platform_limits_freebsd.cpp \ > sanitizer_platform_limits_linux.cpp \ > sanitizer_platform_limits_openbsd.cpp \ > sanitizer_platform_limits_posix.cpp \ > @@ -441,7 +441,17 @@ sanitizer_common_files = \ > sanitizer_unwind_win.cpp \ > sanitizer_win.cpp > > -libsanitizer_common_la_SOURCES = $(sanitizer_common_files) > + > +# Don't add $(LIBBACKTRACE_CXXFLAGS) for the following files: > +# 1. sanitizer_platform_limits_freebsd.cpp must include <md5.h> from > +# the OS, not include/md5.h in GCC source tree. > +sanitizer_common_files_no_libbacktrace = \ > + sanitizer_platform_limits_freebsd.cpp > + > +libsanitizer_common_la_SOURCES = \ > + $(sanitizer_common_files) \ > + $(sanitizer_common_files_no_libbacktrace) > + > libsanitizer_common_la_LIBADD = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) > libsanitizer_common_la_DEPENDENCIES = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) > > @@ -800,6 +810,9 @@ uninstall-am: > .PRECIOUS: Makefile > > > +$(sanitizer_common_files:.cpp=.lo) \ > + $(sanitizer_common_files:.cpp=.$(OBJEXT)): AM_CXXFLAGS += $(LIBBACKTRACE_CXXFLAGS) > + > # 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. > .NOEXPORT: > -- > 2.33.0 >
On Tue, Nov 2, 2021 at 2:14 AM Richard Biener <richard.guenther@gmail.com> wrote: > > On Sat, Oct 30, 2021 at 10:54 PM H.J. Lu via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > sanitizer_platform_limits_freebsd.cpp must include <md5.h> from the OS, > > not include/md5.h in GCC source tree which is included by libbacktrace > > support. Disable libbacktrace on sanitizer_platform_limits_freebsd.cpp > > to avoid include/md5.h to restore bootstrap on FreeBSD. > > Err, but that will just get complaints about disabled libbacktrace backtracking > (from within the sanitizer?)? It disables libbacktrace backtracking only on one file, sanitizer_platform_limits_freebsd.cpp, which contains only data on FreeBSD. I highly doubt that libbacktrace backtracking is used in it. > > PR bootstrap/102675 > > * sanitizer_common/Makefile.am (AM_CXXFLAGS): Extract libbacktrace > > CXXFLAGS to ... > > (LIBBACKTRACE_CXXFLAGS): Here. New. > > (sanitizer_common_files): Move sanitizer_platform_limits_freebsd.cpp > > to ... > > (sanitizer_common_files_no_libbacktrace): Here. New. > > (AM_CXXFLAGS): Add $(LIBBACKTRACE_CXXFLAGS) for > > $(sanitizer_common_files). > > (libsanitizer_common_la_SOURCES): Add > > $(sanitizer_common_files_no_libbacktrace). > > * sanitizer_common/Makefile.in: Regenerate. > > --- > > libsanitizer/sanitizer_common/Makefile.am | 24 +++++++++++----- > > libsanitizer/sanitizer_common/Makefile.in | 35 ++++++++++++++++------- > > 2 files changed, 41 insertions(+), 18 deletions(-) > > > > diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am > > index d04f2d8bd16..0ea459c2b3a 100644 > > --- a/libsanitizer/sanitizer_common/Makefile.am > > +++ b/libsanitizer/sanitizer_common/Makefile.am > > @@ -9,11 +9,12 @@ AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) > > AM_CXXFLAGS += -std=gnu++14 > > AM_CXXFLAGS += $(EXTRA_CXXFLAGS) > > if LIBBACKTRACE_SUPPORTED > > -AM_CXXFLAGS += -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ > > - -I $(top_srcdir)/../libbacktrace \ > > - -I $(top_builddir)/libbacktrace \ > > - -I $(top_srcdir)/../include \ > > - -include $(top_srcdir)/libbacktrace/backtrace-rename.h > > +LIBBACKTRACE_CXXFLAGS = \ > > + -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ > > + -I $(top_srcdir)/../libbacktrace \ > > + -I $(top_builddir)/libbacktrace \ > > + -I $(top_srcdir)/../include \ > > + -include $(top_srcdir)/libbacktrace/backtrace-rename.h > > endif > > AM_CCASFLAGS = $(EXTRA_ASFLAGS) > > ACLOCAL_AMFLAGS = -I m4 > > @@ -45,7 +46,6 @@ sanitizer_common_files = \ > > sanitizer_netbsd.cpp \ > > sanitizer_openbsd.cpp \ > > sanitizer_persistent_allocator.cpp \ > > - sanitizer_platform_limits_freebsd.cpp \ > > sanitizer_platform_limits_linux.cpp \ > > sanitizer_platform_limits_openbsd.cpp \ > > sanitizer_platform_limits_posix.cpp \ > > @@ -81,8 +81,18 @@ sanitizer_common_files = \ > > sanitizer_unwind_win.cpp \ > > sanitizer_win.cpp > > > > +# Don't add $(LIBBACKTRACE_CXXFLAGS) for the following files: > > +# 1. sanitizer_platform_limits_freebsd.cpp must include <md5.h> from > > +# the OS, not include/md5.h in GCC source tree. > > +sanitizer_common_files_no_libbacktrace = \ > > + sanitizer_platform_limits_freebsd.cpp > > > > -libsanitizer_common_la_SOURCES = $(sanitizer_common_files) > > +$(sanitizer_common_files:.cpp=.lo) \ > > + $(sanitizer_common_files:.cpp=.$(OBJEXT)): AM_CXXFLAGS += $(LIBBACKTRACE_CXXFLAGS) > > + > > +libsanitizer_common_la_SOURCES = \ > > + $(sanitizer_common_files) \ > > + $(sanitizer_common_files_no_libbacktrace) > > libsanitizer_common_la_LIBADD = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) > > libsanitizer_common_la_DEPENDENCIES = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) > > > > diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in > > index 2856894d62b..1433db2238b 100644 > > --- a/libsanitizer/sanitizer_common/Makefile.in > > +++ b/libsanitizer/sanitizer_common/Makefile.in > > @@ -89,12 +89,6 @@ POST_UNINSTALL = : > > build_triplet = @build@ > > host_triplet = @host@ > > target_triplet = @target@ > > -@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ > > -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../libbacktrace \ > > -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_builddir)/libbacktrace \ > > -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../include \ > > -@LIBBACKTRACE_SUPPORTED_TRUE@ -include $(top_srcdir)/libbacktrace/backtrace-rename.h > > - > > subdir = sanitizer_common > > ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 > > am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ > > @@ -131,7 +125,6 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \ > > sanitizer_mac.lo sanitizer_mac_libcdep.lo sanitizer_mutex.lo \ > > sanitizer_netbsd.lo sanitizer_openbsd.lo \ > > sanitizer_persistent_allocator.lo \ > > - sanitizer_platform_limits_freebsd.lo \ > > sanitizer_platform_limits_linux.lo \ > > sanitizer_platform_limits_openbsd.lo \ > > sanitizer_platform_limits_posix.lo \ > > @@ -153,7 +146,8 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \ > > sanitizer_thread_registry.lo sanitizer_tls_get_addr.lo \ > > sanitizer_unwind_linux_libcdep.lo sanitizer_unwind_win.lo \ > > sanitizer_win.lo > > -am_libsanitizer_common_la_OBJECTS = $(am__objects_1) > > +am__objects_2 = sanitizer_platform_limits_freebsd.lo > > +am_libsanitizer_common_la_OBJECTS = $(am__objects_1) $(am__objects_2) > > libsanitizer_common_la_OBJECTS = $(am_libsanitizer_common_la_OBJECTS) > > AM_V_lt = $(am__v_lt_@AM_V@) > > am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) > > @@ -376,7 +370,14 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ > > -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ > > -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ > > -Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \ > > - -std=gnu++14 $(EXTRA_CXXFLAGS) $(am__append_1) > > + -std=gnu++14 $(EXTRA_CXXFLAGS) > > +@LIBBACKTRACE_SUPPORTED_TRUE@LIBBACKTRACE_CXXFLAGS = \ > > +@LIBBACKTRACE_SUPPORTED_TRUE@ -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ > > +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../libbacktrace \ > > +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_builddir)/libbacktrace \ > > +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../include \ > > +@LIBBACKTRACE_SUPPORTED_TRUE@ -include $(top_srcdir)/libbacktrace/backtrace-rename.h > > + > > AM_CCASFLAGS = $(EXTRA_ASFLAGS) > > ACLOCAL_AMFLAGS = -I m4 > > noinst_LTLIBRARIES = libsanitizer_common.la > > @@ -405,7 +406,6 @@ sanitizer_common_files = \ > > sanitizer_netbsd.cpp \ > > sanitizer_openbsd.cpp \ > > sanitizer_persistent_allocator.cpp \ > > - sanitizer_platform_limits_freebsd.cpp \ > > sanitizer_platform_limits_linux.cpp \ > > sanitizer_platform_limits_openbsd.cpp \ > > sanitizer_platform_limits_posix.cpp \ > > @@ -441,7 +441,17 @@ sanitizer_common_files = \ > > sanitizer_unwind_win.cpp \ > > sanitizer_win.cpp > > > > -libsanitizer_common_la_SOURCES = $(sanitizer_common_files) > > + > > +# Don't add $(LIBBACKTRACE_CXXFLAGS) for the following files: > > +# 1. sanitizer_platform_limits_freebsd.cpp must include <md5.h> from > > +# the OS, not include/md5.h in GCC source tree. > > +sanitizer_common_files_no_libbacktrace = \ > > + sanitizer_platform_limits_freebsd.cpp > > + > > +libsanitizer_common_la_SOURCES = \ > > + $(sanitizer_common_files) \ > > + $(sanitizer_common_files_no_libbacktrace) > > + > > libsanitizer_common_la_LIBADD = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) > > libsanitizer_common_la_DEPENDENCIES = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) > > > > @@ -800,6 +810,9 @@ uninstall-am: > > .PRECIOUS: Makefile > > > > > > +$(sanitizer_common_files:.cpp=.lo) \ > > + $(sanitizer_common_files:.cpp=.$(OBJEXT)): AM_CXXFLAGS += $(LIBBACKTRACE_CXXFLAGS) > > + > > # 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. > > .NOEXPORT: > > -- > > 2.33.0 > >
On Tue, Nov 02, 2021 at 05:02:12AM -0700, H.J. Lu wrote: > > On Sat, Oct 30, 2021 at 10:54 PM H.J. Lu via Gcc-patches > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > sanitizer_platform_limits_freebsd.cpp must include <md5.h> from the OS, > > > not include/md5.h in GCC source tree which is included by libbacktrace > > > support. Disable libbacktrace on sanitizer_platform_limits_freebsd.cpp > > > to avoid include/md5.h to restore bootstrap on FreeBSD. > > > > Err, but that will just get complaints about disabled libbacktrace backtracking > > (from within the sanitizer?)? > > It disables libbacktrace backtracking only on one file, > sanitizer_platform_limits_freebsd.cpp, > which contains only data on FreeBSD. I highly doubt that libbacktrace > backtracking is > used in it. include/md5.h is a header we have control over, can't we just add to it something like: #ifdef USE_SYSTEM_MD5 #include_next <md5.h> #else Current header content #endif and arrange for that macro to be -DUSE_SYSTEM_MD5 when building that libsanitizer source file? Jakub
On Tue, Nov 2, 2021 at 5:11 AM Jakub Jelinek <jakub@redhat.com> wrote: > > On Tue, Nov 02, 2021 at 05:02:12AM -0700, H.J. Lu wrote: > > > On Sat, Oct 30, 2021 at 10:54 PM H.J. Lu via Gcc-patches > > > <gcc-patches@gcc.gnu.org> wrote: > > > > > > > > sanitizer_platform_limits_freebsd.cpp must include <md5.h> from the OS, > > > > not include/md5.h in GCC source tree which is included by libbacktrace > > > > support. Disable libbacktrace on sanitizer_platform_limits_freebsd.cpp > > > > to avoid include/md5.h to restore bootstrap on FreeBSD. > > > > > > Err, but that will just get complaints about disabled libbacktrace backtracking > > > (from within the sanitizer?)? > > > > It disables libbacktrace backtracking only on one file, > > sanitizer_platform_limits_freebsd.cpp, > > which contains only data on FreeBSD. I highly doubt that libbacktrace > > backtracking is > > used in it. > > include/md5.h is a header we have control over, can't we just add to it > something like: > #ifdef USE_SYSTEM_MD5 > #include_next <md5.h> > #else > Current header content > #endif > and arrange for that macro to be -DUSE_SYSTEM_MD5 when building that > libsanitizer source file? > Gerald, can you try this suggestion? You can add "#define USE_SYSTEM_MD5" in sanitizer_platform_limits_freebsd.cpp for testing.
On Tue, 2 Nov 2021, H.J. Lu wrote: > On Tue, Nov 2, 2021 at 5:11 AM Jakub Jelinek <jakub@redhat.com> wrote: >> include/md5.h is a header we have control over, can't we just add to it >> something like: >> #ifdef USE_SYSTEM_MD5 >> #include_next <md5.h> >> #else >> Current header content >> #endif >> and arrange for that macro to be -DUSE_SYSTEM_MD5 when building that >> libsanitizer source file? > Gerald, can you try this suggestion? You can add "#define > USE_SYSTEM_MD5" in sanitizer_platform_limits_freebsd.cpp for testing. Yes, the patch below restores bootstrap on x86_64-unkown-freebsd12. Okay for now (or does anyone want to / can anyone help with Makefile trickery to -Define USE_SYSTEM_MD5 there)? Thanks, Gerald include: * md5.h (USE_SYSTEM_MD5): Introduce. libsanitizer: * sanitizer_common/sanitizer_platform_limits_freebsd.cpp (USE_SYSTEM_MD5): Define. diff --git a/include/md5.h b/include/md5.h index 03f7d29afc7..c5bb6076969 100644 --- a/include/md5.h +++ b/include/md5.h @@ -21,6 +21,10 @@ #ifndef _MD5_H #define _MD5_H 1 +#ifdef USE_SYSTEM_MD5 +#include_next <md5.h> +#else + #include <stdio.h> #if defined HAVE_LIMITS_H || _LIBC @@ -151,4 +155,6 @@ extern void *md5_buffer (const char *buffer, size_t len, void *resblock); } #endif +#endif // USE_SYSTEM_MD5 + #endif diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_freebsd.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_freebsd.cpp index 64535805e40..a549734efc5 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_freebsd.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_freebsd.cpp @@ -15,6 +15,8 @@ #if SANITIZER_FREEBSD +#define USE_SYSTEM_MD5 + #include <sys/capsicum.h> #include <sys/consio.h> #include <sys/filio.h>
On Thu, Nov 04, 2021 at 06:43:26AM +0100, Gerald Pfeifer wrote: > On Tue, 2 Nov 2021, H.J. Lu wrote: > > On Tue, Nov 2, 2021 at 5:11 AM Jakub Jelinek <jakub@redhat.com> wrote: > >> include/md5.h is a header we have control over, can't we just add to it > >> something like: > >> #ifdef USE_SYSTEM_MD5 > >> #include_next <md5.h> > >> #else > >> Current header content > >> #endif > >> and arrange for that macro to be -DUSE_SYSTEM_MD5 when building that > >> libsanitizer source file? > > Gerald, can you try this suggestion? You can add "#define > > USE_SYSTEM_MD5" in sanitizer_platform_limits_freebsd.cpp for testing. > > Yes, the patch below restores bootstrap on x86_64-unkown-freebsd12. > > Okay for now (or does anyone want to / can anyone help with Makefile > trickery to -Define USE_SYSTEM_MD5 there)? > > Thanks, > Gerald > > > include: > * md5.h (USE_SYSTEM_MD5): Introduce. > > libsanitizer: > * sanitizer_common/sanitizer_platform_limits_freebsd.cpp > (USE_SYSTEM_MD5): Define. Ok. But please after committing mention the revision in libsanitizer/LOCAL_PATCHES. Jakub
On Thu, Nov 4, 2021 at 1:20 AM Jakub Jelinek <jakub@redhat.com> wrote: > > On Thu, Nov 04, 2021 at 06:43:26AM +0100, Gerald Pfeifer wrote: > > On Tue, 2 Nov 2021, H.J. Lu wrote: > > > On Tue, Nov 2, 2021 at 5:11 AM Jakub Jelinek <jakub@redhat.com> wrote: > > >> include/md5.h is a header we have control over, can't we just add to it > > >> something like: > > >> #ifdef USE_SYSTEM_MD5 > > >> #include_next <md5.h> > > >> #else > > >> Current header content > > >> #endif > > >> and arrange for that macro to be -DUSE_SYSTEM_MD5 when building that > > >> libsanitizer source file? > > > Gerald, can you try this suggestion? You can add "#define > > > USE_SYSTEM_MD5" in sanitizer_platform_limits_freebsd.cpp for testing. > > > > Yes, the patch below restores bootstrap on x86_64-unkown-freebsd12. > > > > Okay for now (or does anyone want to / can anyone help with Makefile > > trickery to -Define USE_SYSTEM_MD5 there)? > > > > Thanks, > > Gerald > > > > > > include: > > * md5.h (USE_SYSTEM_MD5): Introduce. > > > > libsanitizer: > > * sanitizer_common/sanitizer_platform_limits_freebsd.cpp > > (USE_SYSTEM_MD5): Define. > > Ok. But please after committing mention the revision in > libsanitizer/LOCAL_PATCHES. > > Jakub > include and libsanitizer should use 2 separate patches. The libsanitizer patch should be in libsanitizer/LOCAL_PATCHES.
On Thu, 4 Nov 2021, H.J. Lu wrote: >> Ok. But please after committing mention the revision in >> libsanitizer/LOCAL_PATCHES. > include and libsanitizer should use 2 separate patches. The > libsanitizer patch should be in libsanitizer/LOCAL_PATCHES. Okay, thanks. This is the first part I committed on Friday, the second will follow today. Gerald commit 44d9d55c6d0e3a1e26427662d30f350a80282634 Author: Gerald Pfeifer <gerald@pfeifer.com> Date: Fri Nov 5 12:56:07 2021 +0100 include: Allow for our md5.h to defer to the system header This came up in the context of libsanitizer, where platform-specific support for FreeBSD relies on aspects provided by FreeBSD's own md5.h. Address this by allowing GCC's md5.h to pull in the system header instead, controlled by a new macro USE_SYSTEM_MD5. 2021-11-05 Gerald Pfeifer <gerald@pfeifer.com> Jakub Jelinek <jakub@redhat.com> include/ * md5.h (USE_SYSTEM_MD5): Introduce. diff --git a/include/md5.h b/include/md5.h index 03f7d29afc7..c5bb6076969 100644 --- a/include/md5.h +++ b/include/md5.h @@ -21,6 +21,10 @@ #ifndef _MD5_H #define _MD5_H 1 +#ifdef USE_SYSTEM_MD5 +#include_next <md5.h> +#else + #include <stdio.h> #if defined HAVE_LIMITS_H || _LIBC @@ -151,4 +155,6 @@ extern void *md5_buffer (const char *buffer, size_t len, void *resblock); } #endif +#endif // USE_SYSTEM_MD5 + #endif
diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am index d04f2d8bd16..0ea459c2b3a 100644 --- a/libsanitizer/sanitizer_common/Makefile.am +++ b/libsanitizer/sanitizer_common/Makefile.am @@ -9,11 +9,12 @@ AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) AM_CXXFLAGS += -std=gnu++14 AM_CXXFLAGS += $(EXTRA_CXXFLAGS) if LIBBACKTRACE_SUPPORTED -AM_CXXFLAGS += -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ - -I $(top_srcdir)/../libbacktrace \ - -I $(top_builddir)/libbacktrace \ - -I $(top_srcdir)/../include \ - -include $(top_srcdir)/libbacktrace/backtrace-rename.h +LIBBACKTRACE_CXXFLAGS = \ + -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ + -I $(top_srcdir)/../libbacktrace \ + -I $(top_builddir)/libbacktrace \ + -I $(top_srcdir)/../include \ + -include $(top_srcdir)/libbacktrace/backtrace-rename.h endif AM_CCASFLAGS = $(EXTRA_ASFLAGS) ACLOCAL_AMFLAGS = -I m4 @@ -45,7 +46,6 @@ sanitizer_common_files = \ sanitizer_netbsd.cpp \ sanitizer_openbsd.cpp \ sanitizer_persistent_allocator.cpp \ - sanitizer_platform_limits_freebsd.cpp \ sanitizer_platform_limits_linux.cpp \ sanitizer_platform_limits_openbsd.cpp \ sanitizer_platform_limits_posix.cpp \ @@ -81,8 +81,18 @@ sanitizer_common_files = \ sanitizer_unwind_win.cpp \ sanitizer_win.cpp +# Don't add $(LIBBACKTRACE_CXXFLAGS) for the following files: +# 1. sanitizer_platform_limits_freebsd.cpp must include <md5.h> from +# the OS, not include/md5.h in GCC source tree. +sanitizer_common_files_no_libbacktrace = \ + sanitizer_platform_limits_freebsd.cpp -libsanitizer_common_la_SOURCES = $(sanitizer_common_files) +$(sanitizer_common_files:.cpp=.lo) \ + $(sanitizer_common_files:.cpp=.$(OBJEXT)): AM_CXXFLAGS += $(LIBBACKTRACE_CXXFLAGS) + +libsanitizer_common_la_SOURCES = \ + $(sanitizer_common_files) \ + $(sanitizer_common_files_no_libbacktrace) libsanitizer_common_la_LIBADD = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) libsanitizer_common_la_DEPENDENCIES = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in index 2856894d62b..1433db2238b 100644 --- a/libsanitizer/sanitizer_common/Makefile.in +++ b/libsanitizer/sanitizer_common/Makefile.in @@ -89,12 +89,6 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ -@LIBBACKTRACE_SUPPORTED_TRUE@am__append_1 = -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../libbacktrace \ -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_builddir)/libbacktrace \ -@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../include \ -@LIBBACKTRACE_SUPPORTED_TRUE@ -include $(top_srcdir)/libbacktrace/backtrace-rename.h - subdir = sanitizer_common ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ @@ -131,7 +125,6 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \ sanitizer_mac.lo sanitizer_mac_libcdep.lo sanitizer_mutex.lo \ sanitizer_netbsd.lo sanitizer_openbsd.lo \ sanitizer_persistent_allocator.lo \ - sanitizer_platform_limits_freebsd.lo \ sanitizer_platform_limits_linux.lo \ sanitizer_platform_limits_openbsd.lo \ sanitizer_platform_limits_posix.lo \ @@ -153,7 +146,8 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \ sanitizer_thread_registry.lo sanitizer_tls_get_addr.lo \ sanitizer_unwind_linux_libcdep.lo sanitizer_unwind_win.lo \ sanitizer_win.lo -am_libsanitizer_common_la_OBJECTS = $(am__objects_1) +am__objects_2 = sanitizer_platform_limits_freebsd.lo +am_libsanitizer_common_la_OBJECTS = $(am__objects_1) $(am__objects_2) libsanitizer_common_la_OBJECTS = $(am_libsanitizer_common_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -376,7 +370,14 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ -Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \ - -std=gnu++14 $(EXTRA_CXXFLAGS) $(am__append_1) + -std=gnu++14 $(EXTRA_CXXFLAGS) +@LIBBACKTRACE_SUPPORTED_TRUE@LIBBACKTRACE_CXXFLAGS = \ +@LIBBACKTRACE_SUPPORTED_TRUE@ -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../libbacktrace \ +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_builddir)/libbacktrace \ +@LIBBACKTRACE_SUPPORTED_TRUE@ -I $(top_srcdir)/../include \ +@LIBBACKTRACE_SUPPORTED_TRUE@ -include $(top_srcdir)/libbacktrace/backtrace-rename.h + AM_CCASFLAGS = $(EXTRA_ASFLAGS) ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libsanitizer_common.la @@ -405,7 +406,6 @@ sanitizer_common_files = \ sanitizer_netbsd.cpp \ sanitizer_openbsd.cpp \ sanitizer_persistent_allocator.cpp \ - sanitizer_platform_limits_freebsd.cpp \ sanitizer_platform_limits_linux.cpp \ sanitizer_platform_limits_openbsd.cpp \ sanitizer_platform_limits_posix.cpp \ @@ -441,7 +441,17 @@ sanitizer_common_files = \ sanitizer_unwind_win.cpp \ sanitizer_win.cpp -libsanitizer_common_la_SOURCES = $(sanitizer_common_files) + +# Don't add $(LIBBACKTRACE_CXXFLAGS) for the following files: +# 1. sanitizer_platform_limits_freebsd.cpp must include <md5.h> from +# the OS, not include/md5.h in GCC source tree. +sanitizer_common_files_no_libbacktrace = \ + sanitizer_platform_limits_freebsd.cpp + +libsanitizer_common_la_SOURCES = \ + $(sanitizer_common_files) \ + $(sanitizer_common_files_no_libbacktrace) + libsanitizer_common_la_LIBADD = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) libsanitizer_common_la_DEPENDENCIES = $(SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS) @@ -800,6 +810,9 @@ uninstall-am: .PRECIOUS: Makefile +$(sanitizer_common_files:.cpp=.lo) \ + $(sanitizer_common_files:.cpp=.$(OBJEXT)): AM_CXXFLAGS += $(LIBBACKTRACE_CXXFLAGS) + # 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. .NOEXPORT: