From patchwork Wed Jan 19 20:42:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 50250 X-Patchwork-Delegate: jwakely.gcc@gmail.com 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 A263F3857C7B for ; Wed, 19 Jan 2022 20:43:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A263F3857C7B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642624998; bh=w6JWpoPdRzu1NNOwGeqb19BibHRW4reGVcIm0DdPGZs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=N6HTjG/6owN4Ta3Hc9T9JqVeoUq8dpou6p1oHbSwy0gmFfdALf9ftc2Ep9S/fqHW3 pjElWfzZ2eJjjaDZUWsvfdi1rT7UpYlnc4Z0AWU/kyf8xHxVgaQkPlVpr/QB1mGL6/ R5UQ4oVsGRCk6P48uUgOntUkyU6ojGjjLJZexn2A= 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 9CCD3385841B for ; Wed, 19 Jan 2022 20:42:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9CCD3385841B 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-192-D6x31RhXOzu8VvaHzYu5Ug-1; Wed, 19 Jan 2022 15:42:46 -0500 X-MC-Unique: D6x31RhXOzu8VvaHzYu5Ug-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 04E8A1937FC0; Wed, 19 Jan 2022 20:42:46 +0000 (UTC) Received: from localhost (unknown [10.33.37.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6CDBB1894; Wed, 19 Jan 2022 20:42:45 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Simplify build targets for debug library Date: Wed, 19 Jan 2022 20:42:44 +0000 Message-Id: <20220119204244.80540-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Posting for review now, but I will wait until stage 1 to push this. This rewrites the stamp-debug and build-debug targets in src/Makefile so that each generated Makefile in the debug/$(SUBDIRS) directories is a make target, instead of being created by a loop in the stamp-debug recipe. The final adjustments to debug/Makefile are done as part of the stamp-debug target instead of the build-debug target. The advantage is that each $(SUBDIRS)/debug/Makefile now has the corresponding $(SUBDIRS)/Makefile as a prerequisite, so they will be regenerated if needed. Generating those can also be parallelized by make, although those steps are very fast so that doesn't really matter. This also removes the duplication in the stamp-debug recipe, which was using exactly the same sed command for debug/Makefile and each debug/$(SUBDIRS)/Makefile. That is done by adding "." to the list of subdirectories to process. The recipes can also be simplified to use separate shell commands per line, instead of using backslashes to join the whole recipe into a single shell command. Also replace 'echo `date` > stamp-xxx' with just 'date > stamp-xxx' which is equivalent but simpler. libstdc++-v3/ChangeLog: * src/Makefile.am: Simplify debug build targets. * src/Makefile.in: Regenerate. --- libstdc++-v3/src/Makefile.am | 65 ++++++++++++++------------------- libstdc++-v3/src/Makefile.in | 70 +++++++++++++++--------------------- 2 files changed, 56 insertions(+), 79 deletions(-) diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index 18f57632c3d..2a9f7c157fa 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/src/Makefile.am @@ -30,10 +30,8 @@ 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. @@ -362,7 +360,7 @@ libstdc++convenience.la: $(toolexeclib_LTLIBRARIES) if test ! -f .libs/libstdc++.a; then \ cp .libs/libstdc++convenience.a .libs/libstdc++.a; \ fi; \ - echo `date` > stamp-libstdc++convenience; + date > stamp-libstdc++convenience; # Added rules. # 1 debug library @@ -378,50 +376,41 @@ CLEAN_DEBUG = endif # Build a debug variant. + # Take care to fix all possibly-relative paths. -debugdir = ${glibcxx_builddir}/src/debug -stamp-debug: Makefile $(foreach dir,$(SUBDIRS),$(dir)/Makefile) - if test ! -d ${debugdir} || test ! -f ${debugdir}/Makefile ; then \ - mkdir -p ${debugdir}; \ - for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \ - (cd ${debugdir}; \ - sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \ - -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \ - -e 's/srcdir = \.\./srcdir = ..\/../' \ - -e 's/VPATH = \.\./VPATH = ..\/../' \ - -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \ - -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \ - < ../Makefile > Makefile ; \ - for d in . $(SUBDIRS); do \ - sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \ - -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \ - -e 's/srcdir = \.\./srcdir = ..\/../' \ - -e 's/VPATH = \.\./VPATH = ..\/../' \ - -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \ - -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \ - < ../$$d/Makefile > $$d/Makefile ; \ - done) ; \ - fi; \ - echo `date` > stamp-debug; +debug/%/Makefile: %/Makefile + $(MKDIR_P) $(dir $@) + sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \ + -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \ + -e 's/srcdir = \.\./srcdir = ..\/../' \ + -e 's/VPATH = \.\./VPATH = ..\/../' \ + -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \ + -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \ + < $< > $@ + +stamp-debug: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile) + mv debug/Makefile debug/Makefile.tmp + sed -e 's,all-local: all-once,all-local:,' \ + -e 's,install-data-local: install-data-once,install-data-local:,' \ + -e '/vpath/!s,src/c,src/debug/c,' \ + < debug/Makefile.tmp > debug/Makefile + rm -f debug/Makefile.tmp + date > stamp-debug; + +.SECONDARY: $(foreach dir,. $(SUBDIRS),debug/$(dir)/Makefile) if ENABLE_BACKTRACE -${debugdir}/$(backtrace_supported_h): $(backtrace_supported_h) stamp-debug +backtrace_supported_h = $(backtrace_dir)/backtrace-supported.h +debug_backtrace_supported_h = debug/$(backtrace_supported_h) +$(debug_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:,' \ - -e 's,install-data-local: install-data-once,install-data-local:,' \ - -e '/vpath/!s,src/c,src/debug/c,' \ - < Makefile.tmp > Makefile ; \ - rm -f Makefile.tmp ; \ - $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \ - toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all) ; + $(MAKE) -C debug CXXFLAGS='$(DEBUG_FLAGS)' \ + toolexeclibdir=$(glibcxx_toolexeclibdir)/debug all # Install debug library. install-debug: build-debug