From patchwork Wed Jan 19 14:59:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 50236 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBA243858401 for ; Wed, 19 Jan 2022 15:00:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBA243858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642604405; bh=pgT9+nVHn9Hz1MHl9JpnG/ZTlSn8N/3KUx2y9MEXNaw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=n8IBGYuChFQVHgbwTU+v4ELzS6nuDRJaLhVfssUsVUNygJKoFkK7FSD3baEPpfm38 FtJZQr2lRE4co8jFJvzwgJBMnDCzr6ickYLkS9UgYgzjZ6xY064Au/T4dnOaMtVoxb KIm+1saudIU3hUdBBjLlGFJEUTomZli8XDKc8nr8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4E2DD3858401 for ; Wed, 19 Jan 2022 14:59:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E2DD3858401 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-bY5a1RFwPhavF398sF04IQ-1; Wed, 19 Jan 2022 09:59:33 -0500 X-MC-Unique: bY5a1RFwPhavF398sF04IQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8D2D1091DA2; Wed, 19 Jan 2022 14:59:32 +0000 (UTC) Received: from localhost (unknown [10.33.37.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 424FC84D1A; Wed, 19 Jan 2022 14:59:32 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix libbacktrace build files Date: Wed, 19 Jan 2022 14:59:30 +0000 Message-Id: <20220119145930.40216-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-linux, pushed to trunk. This makes it possible to combine --enable-libstdcxx-debug with --enable-libstdcxx-backtrace, by adding a rule to src/Makefile to copy the backtrace-supported.h header into the src/debug/libbacktrace directory. Add libbacktrace path to testsuite flags so the tests can link without having the library installed. Also fix some warnings when running automake for the libbacktrace makefile. Use a per-library CPPFLAGS variable to fix: src/libbacktrace/Makefile.am:38: warning: AM_CPPFLAGS multiply defined in condition TRUE ... fragment.am:43: ... 'AM_CPPFLAGS' previously defined here src/libbacktrace/Makefile.am:32: 'fragment.am' included from here Create symlinks to the libbacktrace sources to fix: src/libbacktrace/Makefile.am:55: warning: source file '../../../libbacktrace/atomic.c' is in a subdirectory, src/libbacktrace/Makefile.am:55: but option 'subdir-objects' is disabled libstdc++-v3/ChangeLog: * scripts/testsuite_flags.in: Add src/libbacktrace/.libs to linker search paths. * src/Makefile.am: Fix src/debug/libbacktrace build. * src/Makefile.in: Regenerate. * src/libbacktrace/Makefile.am: Use per-library CPPFLAGS variable. Use symlinks for the source files. * src/libbacktrace/Makefile.in: Regenerate. --- libstdc++-v3/scripts/testsuite_flags.in | 3 +- libstdc++-v3/src/Makefile.am | 12 +- libstdc++-v3/src/Makefile.in | 9 +- libstdc++-v3/src/libbacktrace/Makefile.am | 56 ++++++---- libstdc++-v3/src/libbacktrace/Makefile.in | 128 +++++++++++++--------- 5 files changed, 132 insertions(+), 76 deletions(-) diff --git a/libstdc++-v3/scripts/testsuite_flags.in b/libstdc++-v3/scripts/testsuite_flags.in index cf7f0f7411e..40dd3d3465e 100755 --- a/libstdc++-v3/scripts/testsuite_flags.in +++ b/libstdc++-v3/scripts/testsuite_flags.in @@ -78,7 +78,8 @@ case ${query} in ;; --cxxldflags) SECTIONLDFLAGS="@SECTION_LDFLAGS@ @LIBICONV@ - -L${BUILD_DIR}/src/filesystem/.libs" + -L${BUILD_DIR}/src/filesystem/.libs + -L${BUILD_DIR}/src/libbacktrace/.libs" echo ${SECTIONLDFLAGS} ;; *) diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index 71a0da2cd93..18f57632c3d 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/src/Makefile.am @@ -30,8 +30,10 @@ endif if ENABLE_BACKTRACE backtrace_dir = libbacktrace +backtrace_supported_h = $(backtrace_dir)/backtrace-supported.h else backtrace_dir = +backtrace_supported_h = endif ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE. @@ -402,7 +404,15 @@ stamp-debug: Makefile $(foreach dir,$(SUBDIRS),$(dir)/Makefile) fi; \ echo `date` > stamp-debug; -build-debug: stamp-debug +if ENABLE_BACKTRACE +${debugdir}/$(backtrace_supported_h): $(backtrace_supported_h) stamp-debug + cp $< $@ +debug_backtrace_supported_h = ${debugdir}/$(backtrace_supported_h) +else +debug_backtrace_supported_h = +endif + +build-debug: stamp-debug $(debug_backtrace_supported_h) (cd ${debugdir}; \ mv Makefile Makefile.tmp; \ sed -e 's,all-local: all-once,all-local:,' \ diff --git a/libstdc++-v3/src/libbacktrace/Makefile.am b/libstdc++-v3/src/libbacktrace/Makefile.am index 3a3195167b2..0f1143507f3 100644 --- a/libstdc++-v3/src/libbacktrace/Makefile.am +++ b/libstdc++-v3/src/libbacktrace/Makefile.am @@ -35,9 +35,12 @@ toolexeclib_LTLIBRARIES = libstdc++_libbacktrace.la ACLOCAL_AMFLAGS = -I ../.. -I ../../config -AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \ +# This will be used instead of the common AM_CPPFLAGS from fragment.am +libstdc___libbacktrace_la_CPPFLAGS = \ + -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \ -I ../../../libgcc -I .. -I $(top_srcdir) \ -I $(top_srcdir)/../libbacktrace \ + -I $(top_srcdir)/../libiberty \ -include $(top_srcdir)/src/libbacktrace/backtrace-rename.h \ $(BACKTRACE_CPPFLAGS) @@ -50,42 +53,55 @@ AM_CFLAGS += $(EXTRA_CFLAGS) AM_CXXFLAGS = $(CXX_WARN_FLAGS) -fno-rtti -fno-exceptions AM_CXXFLAGS += $(EXTRA_CXXFLAGS) +obj_prefix = std_stacktrace + +# Each FILE.c in SOURCES will be compiled to SHORTNAME-FILE.o +libstdc___libbacktrace_la_SHORTNAME = $(obj_prefix) + libstdc___libbacktrace_la_SOURCES = \ - ../../../libbacktrace/backtrace.h \ - ../../../libbacktrace/atomic.c \ - ../../../libbacktrace/dwarf.c \ - ../../../libbacktrace/fileline.c \ - ../../../libbacktrace/internal.h \ - ../../../libbacktrace/posix.c \ - ../../../libbacktrace/sort.c \ - ../../../libbacktrace/simple.c \ - ../../../libbacktrace/state.c \ - ../../../libiberty/cp-demangle.c + atomic.c \ + dwarf.c \ + fileline.c \ + posix.c \ + sort.c \ + simple.c \ + state.c \ + cp-demangle.c FORMAT_FILES = \ - ../../../libbacktrace/elf.c \ - ../../../libbacktrace/unknown.c + elf.c \ + unknown.c VIEW_FILES = \ - ../../../libbacktrace/read.c \ - ../../../libbacktrace/mmapio.c + read.c \ + mmapio.c ALLOC_FILES = \ - ../../../libbacktrace/alloc.c \ - ../../../libbacktrace/mmap.c + alloc.c \ + mmap.c EXTRA_libstdc___libbacktrace_la_SOURCES = \ $(FORMAT_FILES) \ $(VIEW_FILES) \ $(ALLOC_FILES) +# These three files are chosen by configure and added to the link. +# We need the SHORTNAME- prefix so that they use the custom CPPFLAGS above. libstdc___libbacktrace_la_LIBADD = \ - $(FORMAT_FILE) \ - $(VIEW_FILE) \ - $(ALLOC_FILE) + $(obj_prefix)-$(FORMAT_FILE) \ + $(obj_prefix)-$(VIEW_FILE) \ + $(obj_prefix)-$(ALLOC_FILE) libstdc___libbacktrace_la_DEPENDENCIES = $(libstdc___libbacktrace_la_LIBADD) +# Use symlinks for the sources + +%.c: ../../../libbacktrace/%.c + $(LN_S) $< $@ + +cp-demangle.c: ../../../libiberty/cp-demangle.c + $(LN_S) $< $@ + LTCOMPILE = \ $(LIBTOOL) --tag CC --tag disable-shared \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \