From patchwork Sat Nov 12 01:44:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 19068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1061708wru; Fri, 11 Nov 2022 17:46:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf59YjyL9Ou6V/IrNT+3RSC3rysEhcXguIozyWP4ZPAFkjYleZA2rH2seG95tbEjXJx4AQ+t X-Received: by 2002:a17:906:4ad1:b0:78d:a3ca:586c with SMTP id u17-20020a1709064ad100b0078da3ca586cmr4000919ejt.287.1668217599776; Fri, 11 Nov 2022 17:46:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668217599; cv=none; d=google.com; s=arc-20160816; b=MaVwCskH9wj/5yye28V2QlWSkcpP2h8cays6tjK/E5BWFRVb5Qmq3ci2zF7dl/+WiM 8L3fyo7iPLVyMVkqxJtOJhu6xiuZ7rJkPPhmdunMyjB7ddrfIIh0///QFxdx99JUo7z1 gW9Yr1FwZrOREdZCM8C1yCPuaZDksZMEwy2HOmiBdTYCJkL1fyapUUiWDIoUalakcAox EIH22CzmP4KLDB4sPhyWUyTTgAGhs/GaVXFs+HAH0oPmR80WbMV1rjPo3ykszHgir2OZ bUhvmnBkLzfEIOznZdiBl47Yxknull8gKfhh7JNLGfIqbdR3eRxAJWajmPjiOPgFqW5O 2eYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=/T76hWmcVv0gReBD0MG0RtM3WWjh5iv8NJcWeCcK6IQ=; b=sExlzOsLdmSuvRoVRb9rsaXxbZOqOMDrIyrkzx81cXL1hbZsL+JgrnocIvs5DpxqgJ htssIWXuXYEVC1fGLD9geL8FbJm1hUiq7JecP4ZvDzrImfClFvMIioH1iCbKvxl+Ja9U +yNMrofLDfCwTPwAlhcGbyyV4rWFiuCjWIPktnSEiCUxBbepSrVG1NSl1TT2YSzyJ/yQ VjK1YtJRmU4RH8oLc1bdybaNylmZgayxri3BDEA/k1dOKUsAsvJSTcA7d2MPX6/YepVl 7h2FppqDUttLxbMKgX0hIwZzZk69uD5/srxDerk4D4lfSpOCYGJ51DyWGZzUJ/WQENaA UG5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oaJ3TSoQ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z5-20020a056402274500b00461d6a4afd1si4198971edd.8.2022.11.11.17.46.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 17:46:39 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oaJ3TSoQ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BBE53894C3B for ; Sat, 12 Nov 2022 01:45:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BBE53894C3B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668217545; bh=/T76hWmcVv0gReBD0MG0RtM3WWjh5iv8NJcWeCcK6IQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oaJ3TSoQ30CuskK0GR5/qwOn1oFsp6L0jdrYWY6ILV0+xxiXx5hEI1IYnES7zgWld XfhdhXgzcxddnXLVjbBMva3o7CA81MHWa9ulxezGXK+QxvEotg8+9xAOjiNXjnsIt9 Gzs/+euV/GylXcImR5U8vcacMev92oKLw3B50wX8= 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 09DE33836025 for ; Sat, 12 Nov 2022 01:44:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 09DE33836025 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-140-Sau3DszwPiiNxTDRql3pdA-1; Fri, 11 Nov 2022 20:44:35 -0500 X-MC-Unique: Sau3DszwPiiNxTDRql3pdA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 84F00800B23; Sat, 12 Nov 2022 01:44:34 +0000 (UTC) Received: from localhost (unknown [10.33.36.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BA7D477F5D; Sat, 12 Nov 2022 01:44:34 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Simplify build targets for debug library Date: Sat, 12 Nov 2022 01:44:33 +0000 Message-Id: <20221112014433.814465-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749252937715921055?= X-GMAIL-MSGID: =?utf-8?q?1749252937715921055?= I posted this at the start of the year while we were in stage 3. Tested x86_64-linux. Pushed to trunk. -- >8 -- 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 b83c222d51d..b545ebf0dcf 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. @@ -370,7 +368,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 @@ -386,50 +384,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