From patchwork Thu Mar 3 16:04:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12767712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80FFBC433EF for ; Thu, 3 Mar 2022 16:04:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232280AbiCCQF2 (ORCPT ); Thu, 3 Mar 2022 11:05:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbiCCQF2 (ORCPT ); Thu, 3 Mar 2022 11:05:28 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34B53197B47 for ; Thu, 3 Mar 2022 08:04:42 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id r10so8574507wrp.3 for ; Thu, 03 Mar 2022 08:04:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B5zXqhA9bTn/F6sYFAbG+nzimX/d7yNvejfWtMI5ZkM=; b=aHMXAxMtjzCIi3GYvUUrtdPeSYxRi7UH3Cgsa7fCXaAckcqvsBbOvc6/aSJ1aPVCQY lh7zVbQPYm6b720ajM7Ks1vOAXtXplzfClU8H/F/iXFOq9hinCasjKN2DOVIIPEfqGjs idutvssX+ZaBMiEu31eBg9W3VgLfBfNvxMf4YUknilDQIwVnM/q4YM1zdNWlY43ifiRT vcpMwbVcQQFUZOAGjXndK3maAqkZNzYUzdp9+IfE3108mlBNZt9liioTfVV/+ZQVpBIu LJduLu38ldcGhBONudM5JxsMkDfWawSxykJ4rNrN+Vuip6Vu5dVf6j25c7dvACugaERj 7CMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B5zXqhA9bTn/F6sYFAbG+nzimX/d7yNvejfWtMI5ZkM=; b=OtPy9Hk0SlLnKyQ8I0oxk66ADmfTWvq/rWLBapJAMV5b09QkYTT9NKM5x0qtzF2438 79dzR6EO7MlTV/H91ihieV5ldxav3IfOvQy/dhQT8QkHOSOx+n8jWC3GgzOC8G8qy+KZ rRCWWiZ/TNU9QRuoF3I9gg52fr9OjJdND7JQKYhWQy0AGIBSeTANpd65MOAw8lvQf5+t VXqAStKhsiSQeS6cSJVa7JykfHf2hoTnTcfDUq2g7aS/q8Cjym61fiaO4OndOrDZYe9s lPgA1Uqm3tFAAnscS4NBvCml1y1/pmMm3vx4YUWal/QbDMlxm71+lBSLj26oihzDuaQX XlaA== X-Gm-Message-State: AOAM531itKEwDPwX2Xhynhw/+sTYQvT/rN71IMKjfzGMHUP17U5tw4+c lorSfK0x32wrs1UI+qeL+L1zvDqoSVg7XA== X-Google-Smtp-Source: ABdhPJyElhK8Dcqfo9SrK/GlRssVHDe0F9EKmSSLYpAuC/DfO7zy2L6kj/Nz1aDzoa8emFdsvpiZ4w== X-Received: by 2002:adf:b1da:0:b0:1f0:1205:89c1 with SMTP id r26-20020adfb1da000000b001f0120589c1mr9697246wra.27.1646323480420; Thu, 03 Mar 2022 08:04:40 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm4040667wmq.35.2022.03.03.08.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:04:39 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood , Jeff King , Dan Jacques , Eric Wong , Jonathan Nieder , Mike Hommey , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Victoria Dye , Eric Sunshine , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v5 1/8] scalar Makefile: use "The default target of..." pattern Date: Thu, 3 Mar 2022 17:04:12 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1230.ga6e6579e98c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Make the "contrib/scalar/Makefile" be stylistically consistent with the top-level "Makefile" in first declaring "all" to be the default rule, followed by including other Makefile snippets. This adjusts code added in 0a43fb22026 (scalar: create a rudimentary executable, 2021-12-03), it further ensures that when we add another "include" file in a subsequent commit that the included file won't be the one to define our default target. Signed-off-by: Ævar Arnfjörð Bjarmason --- contrib/scalar/Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/contrib/scalar/Makefile b/contrib/scalar/Makefile index 231b1ee1796..1e9b969f3df 100644 --- a/contrib/scalar/Makefile +++ b/contrib/scalar/Makefile @@ -1,3 +1,10 @@ +# The default target of this Makefile is... +all:: + +include ../../config.mak.uname +-include ../../config.mak.autogen +-include ../../config.mak + QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir QUIET_SUBDIR1 = @@ -12,12 +19,6 @@ else endif endif -all: - -include ../../config.mak.uname --include ../../config.mak.autogen --include ../../config.mak - TARGETS = scalar$(X) scalar.o GITLIBS = ../../common-main.o ../../libgit.a ../../xdiff/lib.a From patchwork Thu Mar 3 16:04:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12767713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F8B9C433EF for ; Thu, 3 Mar 2022 16:04:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234788AbiCCQFc (ORCPT ); Thu, 3 Mar 2022 11:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234605AbiCCQFa (ORCPT ); Thu, 3 Mar 2022 11:05:30 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86193197B51 for ; Thu, 3 Mar 2022 08:04:43 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id t11so8574977wrm.5 for ; Thu, 03 Mar 2022 08:04:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7acIjbXzpj92RkaLSI9nMlsKODhwMrzC+xLXcEXEEnk=; b=BcEY6SniGvB7t4EbVeKwVVJOh+KB6lZtdiGkKkz5yfOjt0duvYqKQBe2yi1OoX9dnY AFtYFtKEUco1dzVZZGTkgfrtMPxu6UKYjWmHPnBXNl5XTmLwfKbgBw0MBp+fJYxfhkgo GASkt0YIaDBujwoXIsQemEy1bTWt6oxOR3deDwaOT8rE78CYNL/TBeyPIX6887i72UzK L2O67g7JK2BD1ri+iJ0nDi8hbZ9SiCfe91if9Fc5Dt0IndmU6EAVMODqaBjOF4+t47LJ mHKSr2Qc40/Tf8HHmF7hID5pITn4q38eiscIcvUhjy2DDpOemV6kuvoDG8B02rVoNarm SyUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7acIjbXzpj92RkaLSI9nMlsKODhwMrzC+xLXcEXEEnk=; b=cRKHUG0MaHKIerJL+W13km4krtgcODVS8FPu6yEKjOgCKkZSgnRik0ih0eHwSDQ8WQ 4BJRtiaTbJDWkAMANhbbdqUvFtr1bH35TdQM6WH7PR7DRZJ6GuGuvWkLliig1CmFVQBc Z8e9gQzwQSy2D1PkdD8QdCYXI6ZxdOAazq1FxyR/oVauRFHaYkc7XGyTglCRqaahDg2e 5gWhXZEcTTkIAp9RZ84hH6k2CUVK18bbMRJwUT/0XZ2XwH8BmEuTzUHEIRF6v06LiTuX DF2k4llIljMyQGOn1zIznY8nHuJNivVaOgfGJBT7oGp0QAIp/dl8hR9Y4bT5DG+V/DwS cb7w== X-Gm-Message-State: AOAM531hP1g7XCQtn8M+ZB2xbAOvVtvkYGByMPQhsOGNqybNsiWRbQb6 8v9V/Irp+jT7H3v1MdPU0Wi6oeLVS6nTNA== X-Google-Smtp-Source: ABdhPJw0zkLTyNVw1xbuGUIanLQdTFU7CeC9BsFgAdMngQFXRMwGcOGk+idDE/Aeu5Wi9fHfiqFK0g== X-Received: by 2002:a5d:534a:0:b0:1f0:48f2:5f7c with SMTP id t10-20020a5d534a000000b001f048f25f7cmr4256580wrv.138.1646323481746; Thu, 03 Mar 2022 08:04:41 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm4040667wmq.35.2022.03.03.08.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:04:41 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood , Jeff King , Dan Jacques , Eric Wong , Jonathan Nieder , Mike Hommey , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Victoria Dye , Eric Sunshine , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v5 2/8] Makefiles: add "shared.mak", move ".DELETE_ON_ERROR" to it Date: Thu, 3 Mar 2022 17:04:13 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1230.ga6e6579e98c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We have various behavior that's shared across our Makefiles, or that really should be (e.g. via defined templates). Let's create a top-level "shared.mak" to house those sorts of things, and start by adding the ".DELETE_ON_ERROR" flag to it. See my own 7b76d6bf221 (Makefile: add and use the ".DELETE_ON_ERROR" flag, 2021-06-29) and db10fc6c09f (doc: simplify Makefile using .DELETE_ON_ERROR, 2021-05-21) for the addition and use of the ".DELETE_ON_ERROR" flag. I.e. this changes the behavior of existing rules in the altered Makefiles (except "Makefile" & "Documentation/Makefile"). I'm confident that this is safe having read the relevant rules in those Makfiles, and as the GNU make manual notes that it isn't the default behavior is out of an abundance of backwards compatibility caution. From edition 0.75 of its manual, covering GNU make 4.3: [Enabling '.DELETE_ON_ERROR' is] almost always what you want 'make' to do, but it is not historical practice; so for compatibility, you must explicitly request it. This doesn't introduce a bug by e.g. having this ".DELETE_ON_ERROR" flag only apply to this new shared.mak, Makefiles have no such scoping semantics. It does increase the danger that any Makefile without an explicit "The default target of this Makefile is..." snippet to define the default target as "all" could have its default rule changed if our new shared.mak ever defines a "real" rule. In subsequent commits we'll be careful not to do that, and such breakage would be obvious e.g. in the case of "make -C t". We might want to make that less fragile still (e.g. by using ".DEFAULT_GOAL" as noted in the preceding commit), but for now let's simply include "shared.mak" without adding that boilerplate to all the Makefiles that don't have it already. Most of those are already exposed to that potential caveat e.g. due to including "config.mak*". Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/Makefile | 6 +++--- Makefile | 13 +++---------- contrib/scalar/Makefile | 3 +++ contrib/scalar/t/Makefile | 3 +++ shared.mak | 9 +++++++++ t/Makefile | 3 +++ t/interop/Makefile | 3 +++ t/perf/Makefile | 3 +++ templates/Makefile | 3 +++ 9 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 shared.mak diff --git a/Documentation/Makefile b/Documentation/Makefile index ed656db2ae9..ba27456c86a 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,3 +1,6 @@ +# Import tree-wide shared Makefile behavior and libraries +include ../shared.mak + # Guard against environment variables MAN1_TXT = MAN5_TXT = @@ -524,7 +527,4 @@ doc-l10n install-l10n:: $(MAKE) -C po $@ endif -# Delete the target file on error -.DELETE_ON_ERROR: - .PHONY: FORCE diff --git a/Makefile b/Makefile index 6f0b4b775fe..aa5ff001b6e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ # The default target of this Makefile is... all:: +# Import tree-wide shared Makefile behavior and libraries +include shared.mak + # Define V=1 to have a more verbose compile. # # Define SHELL_PATH to a POSIX shell if your /bin/sh is broken. @@ -2194,16 +2197,6 @@ shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell strip: $(PROGRAMS) git$X $(STRIP) $(STRIP_OPTS) $^ -### Flags affecting all rules - -# A GNU make extension since gmake 3.72 (released in late 1994) to -# remove the target of rules if commands in those rules fail. The -# default is to only do that if make itself receives a signal. Affects -# all targets, see: -# -# info make --index-search=.DELETE_ON_ERROR -.DELETE_ON_ERROR: - ### Target-specific flags and dependencies # The generic compilation pattern rule and automatically diff --git a/contrib/scalar/Makefile b/contrib/scalar/Makefile index 1e9b969f3df..d585b319edc 100644 --- a/contrib/scalar/Makefile +++ b/contrib/scalar/Makefile @@ -1,6 +1,9 @@ # The default target of this Makefile is... all:: +# Import tree-wide shared Makefile behavior and libraries +include ../../shared.mak + include ../../config.mak.uname -include ../../config.mak.autogen -include ../../config.mak diff --git a/contrib/scalar/t/Makefile b/contrib/scalar/t/Makefile index 6170672bb37..01e82e56d15 100644 --- a/contrib/scalar/t/Makefile +++ b/contrib/scalar/t/Makefile @@ -1,3 +1,6 @@ +# Import tree-wide shared Makefile behavior and libraries +include ../../../shared.mak + # Run scalar tests # # Copyright (c) 2005,2021 Junio C Hamano, Johannes Schindelin diff --git a/shared.mak b/shared.mak new file mode 100644 index 00000000000..0170bb397ae --- /dev/null +++ b/shared.mak @@ -0,0 +1,9 @@ +### Flags affecting all rules + +# A GNU make extension since gmake 3.72 (released in late 1994) to +# remove the target of rules if commands in those rules fail. The +# default is to only do that if make itself receives a signal. Affects +# all targets, see: +# +# info make --index-search=.DELETE_ON_ERROR +.DELETE_ON_ERROR: diff --git a/t/Makefile b/t/Makefile index 46cd5fc5273..056ce55dcc9 100644 --- a/t/Makefile +++ b/t/Makefile @@ -1,3 +1,6 @@ +# Import tree-wide shared Makefile behavior and libraries +include ../shared.mak + # Run tests # # Copyright (c) 2005 Junio C Hamano diff --git a/t/interop/Makefile b/t/interop/Makefile index 31a4bbc716a..6911c2915a7 100644 --- a/t/interop/Makefile +++ b/t/interop/Makefile @@ -1,3 +1,6 @@ +# Import tree-wide shared Makefile behavior and libraries +include ../../shared.mak + -include ../../config.mak export GIT_TEST_OPTIONS diff --git a/t/perf/Makefile b/t/perf/Makefile index 2465770a782..e4808aebed0 100644 --- a/t/perf/Makefile +++ b/t/perf/Makefile @@ -1,3 +1,6 @@ +# Import tree-wide shared Makefile behavior and libraries +include ../../shared.mak + -include ../../config.mak export GIT_TEST_OPTIONS diff --git a/templates/Makefile b/templates/Makefile index d22a71a3999..636cee52f51 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -1,3 +1,6 @@ +# Import tree-wide shared Makefile behavior and libraries +include ../shared.mak + # make and install sample templates ifndef V From patchwork Thu Mar 3 16:04:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12767715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E1A4C433FE for ; Thu, 3 Mar 2022 16:04:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234804AbiCCQFg (ORCPT ); Thu, 3 Mar 2022 11:05:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234785AbiCCQFc (ORCPT ); Thu, 3 Mar 2022 11:05:32 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBCE5197B73 for ; Thu, 3 Mar 2022 08:04:44 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id y5so3482870wmi.0 for ; Thu, 03 Mar 2022 08:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uEXe0nov1gHh5dELbny/Vmi9PzrTf0qeYMuKSF4SBsM=; b=DFbZrZ1oa7I9TJ+1b+nwz9bCutMS2eVu/E4HTM3ZKdXi9UDs91Iy1jVGS+JyhgiIjE AxSCMuFX1Oe+p9Ntswykn4H7kvLQSZCIN0QWVDnEBroRjyuouwr7z8w1jK9rT3tGQa38 loQlHTNp9aRq1tvfI9RCRJ0bUknKM0pO+aFaZ/Gtm8GCnEQXwaQSmB187wDnumKeJrNW 9LoEgPyeNx9QiYw7RsUAYy+6Xsa2LIZswnhkZJvC1+My9KQW0nrekVNAzALIjSLzm/qH PqDNbBY7G6Rk9JGYBOJYztJmmEevogUFLmHpqoHdbNgKG7ox4TljV1ZTdWskQtoDLjgA IQ+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uEXe0nov1gHh5dELbny/Vmi9PzrTf0qeYMuKSF4SBsM=; b=57Qa2aW5nGWIDcAFOIVr8y7TXt+qkgeC6Vn9OlXH8gHFhQVyaes8nnWkgNxbaMWXoY TXJPFOhpLQWpXH30YMNf5z9q6jYl4mY5Lk4AjtQXy2jH4Uasj2Zc47ez1wuBnHJeRPeL 5JywTTy6vOiW2Kk1MMwEoHcuY0MqqAX7Go/d5JE37AOalHEpSbkvBe99KGtNpObRDCCX 5CJ8rql4x7Ejq7Y7zBRtG+50AY4JSBbQwc9Qhc981sRZWD1V/c3w916aJMXd5r96+98y GvQLz9NI9wAQMQtnAODl+2ChNvS1k/yk7d9Au6yXsRTZ9AiJ7j7jOc80Sqw7qSmqkiEz jugg== X-Gm-Message-State: AOAM532IWyHeEJIDTZRi/AbO3/zvOvPE8fJk8pWJ+157yYgT1GTtF/A0 ukH/GsObrMwAkOI9ppDU4WXov+dkX+g5fA== X-Google-Smtp-Source: ABdhPJxWRPqyOn8Jizaxai3WLXkXAowDI/G5HyaG5kjhCRGr2HxAlSj4iG/NYwR3Tey+7u9L+1ETBw== X-Received: by 2002:a05:600c:22c9:b0:381:3b27:89be with SMTP id 9-20020a05600c22c900b003813b2789bemr4298733wmg.83.1646323483159; Thu, 03 Mar 2022 08:04:43 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm4040667wmq.35.2022.03.03.08.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:04:42 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood , Jeff King , Dan Jacques , Eric Wong , Jonathan Nieder , Mike Hommey , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Victoria Dye , Eric Sunshine , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v5 3/8] Makefile: disable GNU make built-in wildcard rules Date: Thu, 3 Mar 2022 17:04:14 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1230.ga6e6579e98c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Override built-in rules of GNU make that use a wildcard target. This can speeds things up significantly as we don't need to stat() so many files. GNU make does that by default to see if it can retrieve their contents from RCS or SCCS. See [1] for an old mailing list discussion about how to disable these. The speed-up may vary. I've seen 1-10% depending on the speed of the local disk, caches, -jN etc. Running: strace -f -c -S calls make -j1 NO_TCLTK=Y Shows that we reduce the number of syscalls we make, mostly in "stat" calls. We could also invoke make with "-r" by setting "MAKEFLAGS = -r" early. Doing so might make us a bit faster still. But doing so is a much bigger hammer, since it will disable all built-in rules, some (all?) of which can be seen with: make -f/dev/null -p | grep -v -e ^# -e ^$ We may have something that relies on them, so let's go for the more isolated optimization here that gives us most or all of the wins. 1. https://lists.gnu.org/archive/html/help-make/2002-11/msg00063.html Signed-off-by: Ævar Arnfjörð Bjarmason --- shared.mak | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/shared.mak b/shared.mak index 0170bb397ae..29f0e69ecb9 100644 --- a/shared.mak +++ b/shared.mak @@ -1,3 +1,14 @@ +### Remove GNU make implicit rules + +## This speeds things up since we don't need to look for and stat() a +## "foo.c,v" every time a rule referring to "foo.c" is in play. See +## "make -p -f/dev/null | grep ^%::'". +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% + ### Flags affecting all rules # A GNU make extension since gmake 3.72 (released in late 1994) to From patchwork Thu Mar 3 16:04:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12767716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9CCAC4332F for ; Thu, 3 Mar 2022 16:04:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234811AbiCCQFi (ORCPT ); Thu, 3 Mar 2022 11:05:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbiCCQFc (ORCPT ); Thu, 3 Mar 2022 11:05:32 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34B06197B43 for ; Thu, 3 Mar 2022 08:04:46 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 7-20020a05600c228700b00385fd860f49so2686834wmf.0 for ; Thu, 03 Mar 2022 08:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zducfQTH4wQrdohNjeNlff+31JqYmwpRVXIf/4QALlQ=; b=TFp7p95sKAhdGqXovINoExK4gMKaLZv9B63vFeFAK5CEs1Q3ZztFnDisTkgcVbObDS D6/rwtXluDKN9TIcQRSYs/FMYzJn2vSgDpIcWpozDJJk1/ETxIRTy2UZl4D0/i8mhF1k /sB9gly1/oStDAbSnHLhQb+ynTzdydbmQeEjKG6QWGMraxUwAFoF2tj4GKdZlpWGvlb3 W3yYe1qlDemO+Ml9iw8DcjkcEPlHmizv3SX2TNDB6pj37S9OK687yfBCLdPxEYQgRxz/ O3GSrgiY6h+2fO/LF0TUMgtF53MRtBSaaO0RRl1dWRZxrNj2ZyRmscaUWWgSkYTpC4Bf timg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zducfQTH4wQrdohNjeNlff+31JqYmwpRVXIf/4QALlQ=; b=65zuGyRoMrXcsf6rm4YpA9v+iV3At6Gs0SmCIgXPXnR9lc1kIfNnipbwyIzbCbmdI1 PJ9Rp7v4BPJivSCNnMA1OhSKxyIGLtIJ5pn3VER8HmxKJuj6ZCozIKyc1m/p+PF6/8ad botlrZMRbMcMPKL+Px1uj0oq1mwJg85AFMjmxeOWdcwmsN8hDyPnsErhXyVrrbeMo7zm MmoIY8dylZLLgsBr4G05aN5LC0AgwWPMJD/cMIv22i5fS5dI9z2IucpRZztJCHIvPDNR 32pOntNpK3lAxU0xHm28P2leMMBTzwkadhTAvBbTXr2hHd5Wb3ri0s/a6y4Jkfby4v5A houg== X-Gm-Message-State: AOAM530MOksr45Iu52rzaf3xWJLnvDZKAdaSxeCTvTzPg1lb/XZhD6Nq 00OcYs55+Ps0/Ylcyql0e+A8+zoxVj/LtA== X-Google-Smtp-Source: ABdhPJxXX+uxQJpuc1oev1TabKupkpa7VGqNKu4zMRKlZ3PR2ObtmjFgECwmHasuBvGAwXbu35pmWA== X-Received: by 2002:a1c:a595:0:b0:385:92a:a135 with SMTP id o143-20020a1ca595000000b00385092aa135mr4193878wme.182.1646323484349; Thu, 03 Mar 2022 08:04:44 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm4040667wmq.35.2022.03.03.08.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:04:43 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood , Jeff King , Dan Jacques , Eric Wong , Jonathan Nieder , Mike Hommey , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Victoria Dye , Eric Sunshine , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v5 4/8] Makefile: define $(LIB_H) in terms of $(FIND_SOURCE_FILES) Date: Thu, 3 Mar 2022 17:04:15 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1230.ga6e6579e98c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Combine the definitions of $(FIND_SOURCE_FILES) and $(LIB_H) to speed up the Makefile, as these are the two main expensive $(shell) commands that we execute unconditionally. When see what was in $(FOUND_SOURCE_FILES) that wasn't in $(LIB_H) via the ad-hoc test of: $(error $(filter-out $(LIB_H),$(filter %.h,$(ALL_SOURCE_FILES)))) $(error $(filter-out $(ALL_SOURCE_FILES),$(filter %.h,$(LIB_H)))) We'll get, respectively: Makefile:850: *** t/helper/test-tool.h. Stop. Makefile:850: *** . Stop. I.e. we only had a discrepancy when it came to t/helper/test-tool.h. In terms of correctness this was broken before, but now works: $ make t/helper/test-tool.hco HDR t/helper/test-tool.h This speeds things up a lot: $ git -c hyperfine.hook.setup= hyperfine -L rev HEAD~1,HEAD~0 -s 'make NO_TCLTK=Y' 'make -j1 NO_TCLTK=Y' --warmup 10 -M 10 Benchmark 1: make -j1 NO_TCLTK=Y' in 'HEAD~1 Time (mean ± σ): 159.9 ms ± 6.8 ms [User: 137.2 ms, System: 28.0 ms] Range (min … max): 154.6 ms … 175.9 ms 10 runs Benchmark 2: make -j1 NO_TCLTK=Y' in 'HEAD~0 Time (mean ± σ): 100.0 ms ± 1.3 ms [User: 84.2 ms, System: 20.2 ms] Range (min … max): 98.8 ms … 102.8 ms 10 runs Summary 'make -j1 NO_TCLTK=Y' in 'HEAD~0' ran 1.60 ± 0.07 times faster than 'make -j1 NO_TCLTK=Y' in 'HEAD~1' Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index aa5ff001b6e..1ac924bd844 100644 --- a/Makefile +++ b/Makefile @@ -833,12 +833,33 @@ GENERATED_H += hook-list.h .PHONY: generated-hdrs generated-hdrs: $(GENERATED_H) -LIB_H := $(sort $(patsubst ./%,%,$(shell git ls-files '*.h' ':!t/' ':!Documentation/' 2>/dev/null || \ +## Exhaustive lists of our source files, either dynamically generated, +## or hardcoded. +SOURCES_CMD = ( \ + git ls-files \ + '*.[hcS]' \ + '*.sh' \ + ':!*[tp][0-9][0-9][0-9][0-9]*' \ + ':!contrib' \ + 2>/dev/null || \ $(FIND) . \ - -name .git -prune -o \ - -name t -prune -o \ - -name Documentation -prune -o \ - -name '*.h' -print))) + \( -name .git -type d -prune \) \ + -o \( -name '[tp][0-9][0-9][0-9][0-9]*' -prune \) \ + -o \( -name contrib -type d -prune \) \ + -o \( -name build -type d -prune \) \ + -o \( -name 'trash*' -type d -prune \) \ + -o \( -name '*.[hcS]' -type f -print \) \ + -o \( -name '*.sh' -type f -print \) \ + | sed -e 's|^\./||' \ + ) +FOUND_SOURCE_FILES := $(shell $(SOURCES_CMD)) + +FOUND_C_SOURCES = $(filter %.c,$(FOUND_SOURCE_FILES)) +FOUND_H_SOURCES = $(filter %.h,$(FOUND_SOURCE_FILES)) + +COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) + +LIB_H = $(FOUND_H_SOURCES) LIB_OBJS += abspath.o LIB_OBJS += add-interactive.o @@ -2789,26 +2810,6 @@ perl/build/man/man3/Git.3pm: perl/Git.pm $(QUIET_GEN)mkdir -p $(dir $@) && \ pod2man $< $@ -FIND_SOURCE_FILES = ( \ - git ls-files \ - '*.[hcS]' \ - '*.sh' \ - ':!*[tp][0-9][0-9][0-9][0-9]*' \ - ':!contrib' \ - 2>/dev/null || \ - $(FIND) . \ - \( -name .git -type d -prune \) \ - -o \( -name '[tp][0-9][0-9][0-9][0-9]*' -prune \) \ - -o \( -name contrib -type d -prune \) \ - -o \( -name build -type d -prune \) \ - -o \( -name 'trash*' -type d -prune \) \ - -o \( -name '*.[hcS]' -type f -print \) \ - -o \( -name '*.sh' -type f -print \) \ - | sed -e 's|^\./||' \ - ) - -FOUND_SOURCE_FILES = $(shell $(FIND_SOURCE_FILES)) - $(ETAGS_TARGET): $(FOUND_SOURCE_FILES) $(QUIET_GEN)$(RM) $@+ && \ echo $(FOUND_SOURCE_FILES) | xargs etags -a -o $@+ && \ @@ -3018,9 +3019,6 @@ check: $(GENERATED_H) exit 1; \ fi -FOUND_C_SOURCES = $(filter %.c,$(FOUND_SOURCE_FILES)) -COCCI_SOURCES = $(filter-out $(THIRD_PARTY_SOURCES),$(FOUND_C_SOURCES)) - %.cocci.patch: %.cocci $(COCCI_SOURCES) $(QUIET_SPATCH) \ if test $(SPATCH_BATCH_SIZE) = 0; then \ From patchwork Thu Mar 3 16:04:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12767717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58864C433EF for ; Thu, 3 Mar 2022 16:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234813AbiCCQFi (ORCPT ); Thu, 3 Mar 2022 11:05:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234789AbiCCQFd (ORCPT ); Thu, 3 Mar 2022 11:05:33 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD6B197B78 for ; Thu, 3 Mar 2022 08:04:46 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id d3so8588545wrf.1 for ; Thu, 03 Mar 2022 08:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dSfaNHB9ocGs2+lwGPpPltKLUnQZPaMfGhAwyMrr7ec=; b=JRFqhCaesM47fVQh1g74IIevFJ5XMeKjDMfi01ZLHkm6ARw1LKceBqoRcybjMWJzYR 5lUXaWlzpAtbqsNhXWQ/Z4kP9Cac6M41hp3kQWz8mfuVHafEb2de74ilz+nJMczrFjg5 28l2rasj454jYfSKgEUldvrJqQf4bOc2JMHpdnAwOcgAu9aDWjVPEa+pH5CuTTIhhz3r 9QJ3iEf/E2YweQLDt22rOiGtyK0lc5qImEaExz/itJe9CIVsNPLG/TZTYbKbklzoZjh+ CtL+eRpJT3ApDcjXb9Aguqfp8zhzGLJZdMLQC94cJKx1M90oa06+jAVGbk5dEqGa6vsG o/pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dSfaNHB9ocGs2+lwGPpPltKLUnQZPaMfGhAwyMrr7ec=; b=41T6oWpP1jczlhXzJeg0nYRQlRXjyUbTzKmavxOQ/KJDhihNb+oNeZXTCQAAlTw7jX EvTBjU+QODy2HlHCxMUcIJKrO1w4ZIHl0ybMNiqLg+ofa9qcrMK3i5TA4EYOTxLOc7xl tkXc4XL+1RcWj1hjxD5IH1KsJXSXFQab0cmgaxiyG0ObSfON0zjaiv+RwogmcP38frsh Y8VTZIDBC//BsaSbODYiR1HUprPvgLzrK/+PsulErjRYpBafT15rfSZjIY2hMjtQxHRe xhuoYi+YIoqY4kR2/2i1hkB6TMVsmUD8vtAIddcwhpU0PPgYQtPnOQ2+iJ0/6OmOXHT/ 9+tg== X-Gm-Message-State: AOAM533PHMJv7v/vWxJlbPhsmuf+umOfhlj10QayDrUxondLCaVh/vO4 Ko6QsQBE1H4cKFwfV2V/Jjhj3tzTMg0UEA== X-Google-Smtp-Source: ABdhPJyebR9KKrNSd3l1O8JHzsnX8nLiHLRja+4TqLdawxpQ8XLSbZ+g0EiUm3MP2ImTIbEKCmcYMQ== X-Received: by 2002:a5d:4528:0:b0:1ee:ea7f:b97d with SMTP id j8-20020a5d4528000000b001eeea7fb97dmr25635309wra.593.1646323485310; Thu, 03 Mar 2022 08:04:45 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm4040667wmq.35.2022.03.03.08.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:04:44 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood , Jeff King , Dan Jacques , Eric Wong , Jonathan Nieder , Mike Hommey , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Victoria Dye , Eric Sunshine , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v5 5/8] Makefile: move ".SUFFIXES" rule to shared.mak Date: Thu, 3 Mar 2022 17:04:16 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1230.ga6e6579e98c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This was added in 30248886ce8 (Makefile: disable default implicit rules, 2010-01-26), let's move it to the top of "shared.mak" so it'll apply to all our Makefiles. This doesn't benefit the main Makefile at all, since it already had the rule, but since we're including shared.mak in other Makefiles starts to benefit them. E.g. running the 'man" target is now faster: $ git -c hyperfine.hook.setup= hyperfine -L rev HEAD~1,HEAD~0 -s 'make -C Documentation man' 'make -C Documentation -j1 man' Benchmark 1: make -C Documentation -j1 man' in 'HEAD~1 Time (mean ± σ): 121.7 ms ± 8.8 ms [User: 105.8 ms, System: 18.6 ms] Range (min … max): 112.8 ms … 148.4 ms 26 runs Benchmark 2: make -C Documentation -j1 man' in 'HEAD~0 Time (mean ± σ): 97.5 ms ± 8.0 ms [User: 80.1 ms, System: 20.1 ms] Range (min … max): 89.8 ms … 111.8 ms 32 runs Summary 'make -C Documentation -j1 man' in 'HEAD~0' ran 1.25 ± 0.14 times faster than 'make -C Documentation -j1 man' in 'HEAD~1' The reason for that can be seen when comparing that run with "--debug=a". Without this change making a target like "git-status.1" will cause "make" to consider not only "git-status.txt", but "git-status.txt.o", as well as numerous other implicit suffixes such as ".c", ".cc", ".cpp" etc. See [1] for a more detailed before/after example. So this is causing us to omit a bunch of work we didn't need to do. For making "git-status.1" the "--debug=a" output is reduced from ~140k lines to ~6k. 1. https://lore.kernel.org/git/220222.86bkyz875k.gmgdl@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 2 -- shared.mak | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1ac924bd844..ce362720947 100644 --- a/Makefile +++ b/Makefile @@ -2580,8 +2580,6 @@ ASM_SRC := $(wildcard $(OBJECTS:o=S)) ASM_OBJ := $(ASM_SRC:S=o) C_OBJ := $(filter-out $(ASM_OBJ),$(OBJECTS)) -.SUFFIXES: - $(C_OBJ): %.o: %.c GIT-CFLAGS $(missing_dep_dirs) $(missing_compdb_dir) $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(compdb_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $< $(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs) $(missing_compdb_dir) diff --git a/shared.mak b/shared.mak index 29f0e69ecb9..1dda948df09 100644 --- a/shared.mak +++ b/shared.mak @@ -9,6 +9,11 @@ %:: s.% %:: SCCS/s.% +## Likewise delete default $(SUFFIXES). See: +## +## info make --index-search=.SUFFIXES +.SUFFIXES: + ### Flags affecting all rules # A GNU make extension since gmake 3.72 (released in late 1994) to From patchwork Thu Mar 3 16:04:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12767719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95D44C433F5 for ; Thu, 3 Mar 2022 16:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234857AbiCCQFy (ORCPT ); Thu, 3 Mar 2022 11:05:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbiCCQFf (ORCPT ); Thu, 3 Mar 2022 11:05:35 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D461986CC for ; Thu, 3 Mar 2022 08:04:47 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id p9so8541187wra.12 for ; Thu, 03 Mar 2022 08:04:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0pz2XseBF4Xzz8NRFB2Itl1IwhFPCg4vqnJXl8ug9dA=; b=gI2emPg/5HoJc9KqHj8aM2p/MkAig9NA4KBTV48xdRLOU20fa0L6fWiW6pKY8dHM3p ZvqwxsQQKymjcPPErncV6J+AAaUp9UMr7bkDz/YHIwfGhlwsgETSaYge9UewnFQ6oCLD WBOB8H91ujeuMyCmkqs+ISpDaRYnlA0lz9nsWMVjfbQqfsiMvT4hXLdN6bLiu1FnkvEV 7++Q6jyl452vmmG7CNWQRkAT+cvuU6qKCCdtJVjFo4+z6wiXXbS4QKPJVwnSePSVLP9G Fso7xl8Y6AGF6r0N/PFcaOlDsIqN+sekARrDm4YNXix01LHqesQvZOFjSB7DrvE7mmJL xGtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0pz2XseBF4Xzz8NRFB2Itl1IwhFPCg4vqnJXl8ug9dA=; b=Y2SzpVQVA7+3U1y7U6EOVG/7zBFH+BSZm70N6Cnux2YMuvg7rgpvoqHg9VbGG+/IEC s1NjnT3zthkktqAgwTo3LHiO+4xxlgvvBNWSvxFhoom88mT/6cHihwbJQx8vummRjMKE ltA9EUwBqFEm0DKz7dAm4ZSi1Pvbhzd6Rc3Swn85cM+ax2BdiQKUT1Y8UFXIntbCfSar zi1dT0rhVxP36QMQ41sxL9auptnmDoFmNudKAYAr47qUBjX1BpZd6gXINxkFinigZUUL Z2NPo7VIZdNmKheZrByefDszJGN55Zc9KvSzBxjP49A4u/r4/Y5Zfhk1mn40keWz9+KK Ug9Q== X-Gm-Message-State: AOAM53117g3nEb10FFUnq19fw+rFtgm4zWPzb5TEYUnY1psMlVL6gHDd o6kIbrkxjcI+m61JGWvZ7H6o7sRRalOj4A== X-Google-Smtp-Source: ABdhPJxVtXEg3mzdXnwQpPP0E4X9V8JG7VG84wZmNa3n1gGc2bwBlOZWp/gsvBfiYqBgXqFjL8UEvQ== X-Received: by 2002:a5d:514e:0:b0:1f0:25a5:2d49 with SMTP id u14-20020a5d514e000000b001f025a52d49mr6787816wrt.154.1646323486309; Thu, 03 Mar 2022 08:04:46 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm4040667wmq.35.2022.03.03.08.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:04:45 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood , Jeff King , Dan Jacques , Eric Wong , Jonathan Nieder , Mike Hommey , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Victoria Dye , Eric Sunshine , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v5 6/8] Makefile: move $(comma), $(empty) and $(space) to shared.mak Date: Thu, 3 Mar 2022 17:04:17 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1230.ga6e6579e98c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move these variables over to the shared.mak, we'll make use of them in a subsequent commit. Note that there's reason for these to be "simply expanded variables", i.e. to use ":=" assignments instead of lazily expanded "=" assignments. We could use "=", but let's leave this as-is for now for ease of review. See 425ca6710b2 (Makefile: allow combining UBSan with other sanitizers, 2017-07-15) for the commit that introduced these. Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 4 ---- shared.mak | 8 ++++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ce362720947..1e7a1277ce9 100644 --- a/Makefile +++ b/Makefile @@ -1289,10 +1289,6 @@ endif ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS) -comma := , -empty := -space := $(empty) $(empty) - ifdef SANITIZE SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag)) BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE) diff --git a/shared.mak b/shared.mak index 1dda948df09..934bf428936 100644 --- a/shared.mak +++ b/shared.mak @@ -23,3 +23,11 @@ # # info make --index-search=.DELETE_ON_ERROR .DELETE_ON_ERROR: + +### Global variables + +## comma, empty, space: handy variables as these tokens are either +## special or can be hard to spot among other Makefile syntax. +comma := , +empty := +space := $(empty) $(empty) From patchwork Thu Mar 3 16:04:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12767718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4251DC4332F for ; Thu, 3 Mar 2022 16:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234819AbiCCQFx (ORCPT ); Thu, 3 Mar 2022 11:05:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234808AbiCCQFh (ORCPT ); Thu, 3 Mar 2022 11:05:37 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CC411986ED for ; Thu, 3 Mar 2022 08:04:49 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id q20so1106923wmq.1 for ; Thu, 03 Mar 2022 08:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=URGGrpNKk6KnFp1JnfnJW8w7TBd3bHGILoNvosl+MzA=; b=muxlyisXZkawPumKUs3VSubtUYGyUN/B8DoQZjHc7zHmjPMJ+6h5ZUTZi5Mi9lzujn bhRReCxn4BqJ2VQRyud0bT+Hhjy7/jVZyYT+HGqoIJlf89+37ha8pBZuRSzcg6tAP0nK ago5gLGBfCMyv9T3hYT5PrR5YJ3ZnoqP7z4vgRwaOi0ip1XsGg1nVZrFHKjiZ9NbTFJl dycj3rqTLGaipSSWJSBhgI6QX1eCD++lPatXaYZaeqi1FMwNMczIOafEJNNPbXEKZHkH InCmjUTjtkXGNlTDPoIt0JXuK1mrnOcssWVr88lMIU1vhtA7llXP9uq1eeBWqEjerLiY cMkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=URGGrpNKk6KnFp1JnfnJW8w7TBd3bHGILoNvosl+MzA=; b=vnH3jOPrnpMSyu6Z/Yde+nS0c2TlOMY90LBzWU5HQS/prlRE1dHdyE7dzeWvgX1ZkY qPF3mIMMkNwKBUv3kSBbCD7oaj77Vr3U6yXyFfLWmH8xy81VcakJ/AV57zDXY7LUvv+3 ImyAGoC95Y7XKTq14SSdG0LVPCkC7XbWHuifDg2OiQnEMaL6L9P5MtYE0TE/rP8FMDzl hoQAsKZwCs2/UHjL0Js4sUMkaTot3CW8idjLeZosH0NAVoJ57m6WeBcADpCW8ySlCzlc LqwOULqDdlYz5XUiqi8k7kVLIcgbIEOrE769hzpIE/Vs3MZFSpXqbon9zp4ikSH2PFpv NFaw== X-Gm-Message-State: AOAM533mTQ1BZnpZzb1UyzThPCN8lC/yOH093KeArgjok91zI9bYAnmn 0XcPBwIvCLD4wOoFDTZY5txd8DASDYPjHQ== X-Google-Smtp-Source: ABdhPJzpcPbzPVjald6elpiUQ7il0+MZJuFDGSYwM+9wqpZWYR4tVgB7vvoqcI1F/i3t6ASsOE3kZg== X-Received: by 2002:a05:600c:4e10:b0:381:a004:5855 with SMTP id b16-20020a05600c4e1000b00381a0045855mr4397228wmq.70.1646323487344; Thu, 03 Mar 2022 08:04:47 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm4040667wmq.35.2022.03.03.08.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:04:46 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood , Jeff King , Dan Jacques , Eric Wong , Jonathan Nieder , Mike Hommey , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Victoria Dye , Eric Sunshine , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v5 7/8] Makefile: add "$(QUIET)" boilerplate to shared.mak Date: Thu, 3 Mar 2022 17:04:18 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1230.ga6e6579e98c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The $(QUIET) variables we define are largely duplicated between our various Makefiles, let's define them in the new "shared.mak" instead. Since we're not using the environment to pass these around we don't need to export the "QUIET_GEN" and "QUIET_BUILT_IN" variables anymore. The "QUIET_GEN" variable is used in "git-gui/Makefile" and "gitweb/Makefile", but they've got their own definition for those. The "QUIET_BUILT_IN" variable is only used in the top-level "Makefile". We still need to export the "V" variable. Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/Makefile | 32 ------------------------- Makefile | 33 ------------------------- config.mak.uname | 1 - contrib/scalar/Makefile | 14 ----------- shared.mak | 53 +++++++++++++++++++++++++++++++++++++++++ templates/Makefile | 5 ---- 6 files changed, 53 insertions(+), 85 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index ba27456c86a..0f4ebdeda8a 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -218,38 +218,6 @@ DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR)) ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)' endif -QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir -QUIET_SUBDIR1 = - -ifneq ($(findstring $(MAKEFLAGS),w),w) -PRINT_DIR = --no-print-directory -else # "make -w" -NO_SUBDIR = : -endif - -ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V - QUIET = @ - QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@; - QUIET_XMLTO = @echo ' ' XMLTO $@; - QUIET_DB2TEXI = @echo ' ' DB2TEXI $@; - QUIET_MAKEINFO = @echo ' ' MAKEINFO $@; - QUIET_DBLATEX = @echo ' ' DBLATEX $@; - QUIET_XSLTPROC = @echo ' ' XSLTPROC $@; - QUIET_GEN = @echo ' ' GEN $@; - QUIET_STDERR = 2> /dev/null - QUIET_SUBDIR0 = +@subdir= - QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ - $(MAKE) $(PRINT_DIR) -C $$subdir - - QUIET_LINT_GITLINK = @echo ' ' LINT GITLINK $<; - QUIET_LINT_MANSEC = @echo ' ' LINT MAN SEC $<; - QUIET_LINT_MANEND = @echo ' ' LINT MAN END $<; - - export V -endif -endif - all: html man html: $(DOC_HTML) diff --git a/Makefile b/Makefile index 1e7a1277ce9..d4c0f4ca7b8 100644 --- a/Makefile +++ b/Makefile @@ -2001,39 +2001,6 @@ ifndef PAGER_ENV PAGER_ENV = LESS=FRX LV=-c endif -QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir -QUIET_SUBDIR1 = - -ifneq ($(findstring w,$(MAKEFLAGS)),w) -PRINT_DIR = --no-print-directory -else # "make -w" -NO_SUBDIR = : -endif - -ifneq ($(findstring s,$(MAKEFLAGS)),s) -ifndef V - QUIET_CC = @echo ' ' CC $@; - QUIET_AR = @echo ' ' AR $@; - QUIET_LINK = @echo ' ' LINK $@; - QUIET_BUILT_IN = @echo ' ' BUILTIN $@; - QUIET_GEN = @echo ' ' GEN $@; - QUIET_LNCP = @echo ' ' LN/CP $@; - QUIET_XGETTEXT = @echo ' ' XGETTEXT $@; - QUIET_MSGFMT = @echo ' ' MSGFMT $@; - QUIET_GCOV = @echo ' ' GCOV $@; - QUIET_SP = @echo ' ' SP $<; - QUIET_HDR = @echo ' ' HDR $(<:hcc=h); - QUIET_RC = @echo ' ' RC $@; - QUIET_SPATCH = @echo ' ' SPATCH $<; - QUIET_SUBDIR0 = +@subdir= - QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ - $(MAKE) $(PRINT_DIR) -C $$subdir - export V - export QUIET_GEN - export QUIET_BUILT_IN -endif -endif - ifdef NO_INSTALL_HARDLINKS export NO_INSTALL_HARDLINKS endif diff --git a/config.mak.uname b/config.mak.uname index 4352ea39e9b..7727b707b74 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -727,7 +727,6 @@ vcxproj: git diff-index --cached --quiet HEAD -- # Make .vcxproj files and add them - unset QUIET_GEN QUIET_BUILT_IN; \ perl contrib/buildsystems/generate -g Vcxproj git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj diff --git a/contrib/scalar/Makefile b/contrib/scalar/Makefile index d585b319edc..5e86d78e19b 100644 --- a/contrib/scalar/Makefile +++ b/contrib/scalar/Makefile @@ -8,20 +8,6 @@ include ../../config.mak.uname -include ../../config.mak.autogen -include ../../config.mak -QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir -QUIET_SUBDIR1 = - -ifneq ($(findstring s,$(MAKEFLAGS)),s) -ifndef V - QUIET_GEN = @echo ' ' GEN $@; - QUIET_SUBDIR0 = +@subdir= - QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ - $(MAKE) $(PRINT_DIR) -C $$subdir -else - export V -endif -endif - TARGETS = scalar$(X) scalar.o GITLIBS = ../../common-main.o ../../libgit.a ../../xdiff/lib.a diff --git a/shared.mak b/shared.mak index 934bf428936..c45b2812eb6 100644 --- a/shared.mak +++ b/shared.mak @@ -31,3 +31,56 @@ comma := , empty := space := $(empty) $(empty) + +### Quieting +## common +QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir +QUIET_SUBDIR1 = + +ifneq ($(findstring w,$(MAKEFLAGS)),w) +PRINT_DIR = --no-print-directory +else # "make -w" +NO_SUBDIR = : +endif + +ifneq ($(findstring s,$(MAKEFLAGS)),s) +ifndef V +## common + QUIET_SUBDIR0 = +@subdir= + QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ + $(MAKE) $(PRINT_DIR) -C $$subdir + + QUIET = @ + QUIET_GEN = @echo ' ' GEN $@; + +## Used in "Makefile" + QUIET_CC = @echo ' ' CC $@; + QUIET_AR = @echo ' ' AR $@; + QUIET_LINK = @echo ' ' LINK $@; + QUIET_BUILT_IN = @echo ' ' BUILTIN $@; + QUIET_LNCP = @echo ' ' LN/CP $@; + QUIET_XGETTEXT = @echo ' ' XGETTEXT $@; + QUIET_MSGFMT = @echo ' ' MSGFMT $@; + QUIET_GCOV = @echo ' ' GCOV $@; + QUIET_SP = @echo ' ' SP $<; + QUIET_HDR = @echo ' ' HDR $(<:hcc=h); + QUIET_RC = @echo ' ' RC $@; + QUIET_SPATCH = @echo ' ' SPATCH $<; + +## Used in "Documentation/Makefile" + QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@; + QUIET_XMLTO = @echo ' ' XMLTO $@; + QUIET_DB2TEXI = @echo ' ' DB2TEXI $@; + QUIET_MAKEINFO = @echo ' ' MAKEINFO $@; + QUIET_DBLATEX = @echo ' ' DBLATEX $@; + QUIET_XSLTPROC = @echo ' ' XSLTPROC $@; + QUIET_GEN = @echo ' ' GEN $@; + QUIET_STDERR = 2> /dev/null + + QUIET_LINT_GITLINK = @echo ' ' LINT GITLINK $<; + QUIET_LINT_MANSEC = @echo ' ' LINT MAN SEC $<; + QUIET_LINT_MANEND = @echo ' ' LINT MAN END $<; + + export V +endif +endif diff --git a/templates/Makefile b/templates/Makefile index 636cee52f51..367ad00c24c 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -2,11 +2,6 @@ include ../shared.mak # make and install sample templates - -ifndef V - QUIET = @ -endif - INSTALL ?= install TAR ?= tar RM ?= rm -f From patchwork Thu Mar 3 16:04:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12767720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF3B7C433EF for ; Thu, 3 Mar 2022 16:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234861AbiCCQF5 (ORCPT ); Thu, 3 Mar 2022 11:05:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233053AbiCCQFs (ORCPT ); Thu, 3 Mar 2022 11:05:48 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A227E1986FD for ; Thu, 3 Mar 2022 08:04:50 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id q7-20020a7bce87000000b00382255f4ca9so5101744wmj.2 for ; Thu, 03 Mar 2022 08:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T9pBIHMQlku2xowPuIJ28h+oqti7KhK+YEMs7gQe5/k=; b=JYnkj3epLc2oyknsiSwIEvk6BdWb6HqlG/KX46JPpB4PjWLoX2Fe7l57p6Q+KQ+pNF /qjwxP11BvDaEOewwKRp2yUhJEGfJb74eQDvT4/B4vzMtYeYwcnHWqK3kT/evYIBJf59 EgIQuF7p3uRazkRT7FnwX8EXOZzRxMSnMScdQ+dfuncxbqhHfsX0CdJjHWXSzIimaXyV nbd1bnyxGNA0ba4XQg47vscJS0HxVIMjCLgR5lD6kUSZf/tf2yLcie53dgjYxtjGHbb5 yXbomnJjkU0jRrRfNSnS3oQykdjFbwfkmUmvF+OBqW/KzJ6kkuFMsbm7KLfeSQjWRl5i HDAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T9pBIHMQlku2xowPuIJ28h+oqti7KhK+YEMs7gQe5/k=; b=hGTgi49aYC7otzZrt9g0opUfTHgGOUfyoyV/scq5LiQUtB2ycRMstrYPV7FcQw+5ZI w997/OSg33qcTGmjxnbkwyw8jiU+VUMi5aUvplUzpirU45ad5XMs4Zyv1pxHvmJNVvs/ IwSLAE1XncefUttoHXuLOoTnw7KmW9eSVIhreMOfGAZRjEEH75qXLtvQHpVTLi+7g9kq t+CM9l6HFiCH2RbrNJuFb+QgdkYlPFl1hx6IJvvPB87cpuczQVJLLe0UqcHw0vXxtgle wruElmt1yy810IcX2Tr+ff2J7Y5k5rl0kfe8rzSe5sCPropevcPtUJTA4pZ3wjSZhvlP ueMQ== X-Gm-Message-State: AOAM533SofIqLHgZS56NjOREzs/CLXBm8SU9BPrfZiK7o7bNvhn35W67 r2qmgFVEksQFRta7hEBwPTyeMMwXI+wK6g== X-Google-Smtp-Source: ABdhPJz1RmYGsqG7OwSKWdbgtG8HRDZKAw4MEBxVwrevL4OYhX49fjZRhxnmbNkrcJI2ATOJvdt1EA== X-Received: by 2002:a05:600c:3d13:b0:37b:b8e5:ed80 with SMTP id bh19-20020a05600c3d1300b0037bb8e5ed80mr4202493wmb.183.1646323488753; Thu, 03 Mar 2022 08:04:48 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm4040667wmq.35.2022.03.03.08.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 08:04:47 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Phillip Wood , Jeff King , Dan Jacques , Eric Wong , Jonathan Nieder , Mike Hommey , =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Victoria Dye , Eric Sunshine , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v5 8/8] Makefiles: add and use wildcard "mkdir -p" template Date: Thu, 3 Mar 2022 17:04:19 +0100 Message-Id: X-Mailer: git-send-email 2.35.1.1230.ga6e6579e98c In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a template to do the "mkdir -p" of $(@D) (the parent dir of $@) for us, and use it for the "make lint-docs" targets I added in 8650c6298c1 (doc lint: make "lint-docs" non-.PHONY, 2021-10-15). As seen in 4c64fb5aad9 (Documentation/Makefile: fix lint-docs mkdir dependency, 2021-10-26) maintaining these manual lists of parent directory dependencies is fragile, in addition to being obviously verbose. I used this pattern at the time because I couldn't find another method than "order-only" prerequisites to avoid doing a "mkdir -p $(@D)" for every file being created, which as noted in [1] would be significantly slower. But as it turns out we can use this neat trick of only doing a "mkdir -p" if the $(wildcard) macro tells us the path doesn't exist. A re-run of a performance test similar to that noted downthread of [1] in [2] shows that this is faster, in addition to being less verbose and more reliable (this uses my "git-hyperfine" thin wrapper for "hyperfine"[3]): $ git -c hyperfine.hook.setup= hyperfine -L rev HEAD~1,HEAD~0 -s 'make -C Documentation lint-docs' -p 'rm -rf Documentation/.build' 'make -C Documentation -j1 lint-docs' Benchmark 1: make -C Documentation -j1 lint-docs' in 'HEAD~1 Time (mean ± σ): 2.914 s ± 0.062 s [User: 2.449 s, System: 0.489 s] Range (min … max): 2.834 s … 3.020 s 10 runs Benchmark 2: make -C Documentation -j1 lint-docs' in 'HEAD~0 Time (mean ± σ): 2.315 s ± 0.062 s [User: 1.950 s, System: 0.386 s] Range (min … max): 2.229 s … 2.397 s 10 runs Summary 'make -C Documentation -j1 lint-docs' in 'HEAD~0' ran 1.26 ± 0.04 times faster than 'make -C Documentation -j1 lint-docs' in 'HEAD~1' So let's use that pattern both for the "lint-docs" target, and a few miscellaneous other targets. This method of creating parent directories is explicitly racy in that we don't know if we're going to say always create a "foo" followed by a "foo/bar" under parallelism, or skip the "foo" because we created "foo/bar" first. In this case it doesn't matter for anything except that we aren't guaranteed to get the same number of rules firing when running make in parallel. 1. https://lore.kernel.org/git/211028.861r45y3pt.gmgdl@evledraar.gmail.com/ 2. https://lore.kernel.org/git/211028.86o879vvtp.gmgdl@evledraar.gmail.com/ 3. https://gitlab.com/avar/git-hyperfine/ Signed-off-by: Ævar Arnfjörð Bjarmason --- Documentation/Makefile | 25 +++---------------------- Makefile | 12 +++++++----- shared.mak | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Documentation/Makefile b/Documentation/Makefile index 0f4ebdeda8a..1eb9192dae8 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -434,25 +434,11 @@ quick-install-html: require-htmlrepo print-man1: @for i in $(MAN1_TXT); do echo $$i; done -## Lint: Common -.build: - $(QUIET)mkdir $@ -.build/lint-docs: | .build - $(QUIET)mkdir $@ - ## Lint: gitlink -.build/lint-docs/gitlink: | .build/lint-docs - $(QUIET)mkdir $@ -.build/lint-docs/gitlink/howto: | .build/lint-docs/gitlink - $(QUIET)mkdir $@ -.build/lint-docs/gitlink/config: | .build/lint-docs/gitlink - $(QUIET)mkdir $@ LINT_DOCS_GITLINK = $(patsubst %.txt,.build/lint-docs/gitlink/%.ok,$(HOWTO_TXT) $(DOC_DEP_TXT)) -$(LINT_DOCS_GITLINK): | .build/lint-docs/gitlink -$(LINT_DOCS_GITLINK): | .build/lint-docs/gitlink/howto -$(LINT_DOCS_GITLINK): | .build/lint-docs/gitlink/config $(LINT_DOCS_GITLINK): lint-gitlink.perl $(LINT_DOCS_GITLINK): .build/lint-docs/gitlink/%.ok: %.txt + $(call mkdir_p_parent_template) $(QUIET_LINT_GITLINK)$(PERL_PATH) lint-gitlink.perl \ $< \ $(HOWTO_TXT) $(DOC_DEP_TXT) \ @@ -463,23 +449,18 @@ $(LINT_DOCS_GITLINK): .build/lint-docs/gitlink/%.ok: %.txt lint-docs-gitlink: $(LINT_DOCS_GITLINK) ## Lint: man-end-blurb -.build/lint-docs/man-end-blurb: | .build/lint-docs - $(QUIET)mkdir $@ LINT_DOCS_MAN_END_BLURB = $(patsubst %.txt,.build/lint-docs/man-end-blurb/%.ok,$(MAN_TXT)) -$(LINT_DOCS_MAN_END_BLURB): | .build/lint-docs/man-end-blurb $(LINT_DOCS_MAN_END_BLURB): lint-man-end-blurb.perl $(LINT_DOCS_MAN_END_BLURB): .build/lint-docs/man-end-blurb/%.ok: %.txt + $(call mkdir_p_parent_template) $(QUIET_LINT_MANEND)$(PERL_PATH) lint-man-end-blurb.perl $< >$@ .PHONY: lint-docs-man-end-blurb -lint-docs-man-end-blurb: $(LINT_DOCS_MAN_END_BLURB) ## Lint: man-section-order -.build/lint-docs/man-section-order: | .build/lint-docs - $(QUIET)mkdir $@ LINT_DOCS_MAN_SECTION_ORDER = $(patsubst %.txt,.build/lint-docs/man-section-order/%.ok,$(MAN_TXT)) -$(LINT_DOCS_MAN_SECTION_ORDER): | .build/lint-docs/man-section-order $(LINT_DOCS_MAN_SECTION_ORDER): lint-man-section-order.perl $(LINT_DOCS_MAN_SECTION_ORDER): .build/lint-docs/man-section-order/%.ok: %.txt + $(call mkdir_p_parent_template) $(QUIET_LINT_MANSEC)$(PERL_PATH) lint-man-section-order.perl $< >$@ .PHONY: lint-docs-man-section-order lint-docs-man-section-order: $(LINT_DOCS_MAN_SECTION_ORDER) diff --git a/Makefile b/Makefile index d4c0f4ca7b8..12f08411d2d 100644 --- a/Makefile +++ b/Makefile @@ -2745,7 +2745,8 @@ all:: $(MOFILES) endif po/build/locale/%/LC_MESSAGES/git.mo: po/%.po - $(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $< + $(call mkdir_p_parent_template) + $(QUIET_MSGFMT)$(MSGFMT) -o $@ $< LIB_PERL := $(wildcard perl/Git.pm perl/Git/*.pm perl/Git/*/*.pm perl/Git/*/*/*.pm) LIB_PERL_GEN := $(patsubst perl/%.pm,perl/build/lib/%.pm,$(LIB_PERL)) @@ -2761,15 +2762,16 @@ NO_PERL_CPAN_FALLBACKS_SQ = $(subst ','\'',$(NO_PERL_CPAN_FALLBACKS)) endif perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES - $(QUIET_GEN)mkdir -p $(dir $@) && \ + $(call mkdir_p_parent_template) + $(QUIET_GEN) \ sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \ -e 's|@@NO_GETTEXT@@|$(NO_GETTEXT_SQ)|g' \ -e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \ < $< > $@ perl/build/man/man3/Git.3pm: perl/Git.pm - $(QUIET_GEN)mkdir -p $(dir $@) && \ - pod2man $< $@ + $(call mkdir_p_parent_template) + $(QUIET_GEN)pod2man $< $@ $(ETAGS_TARGET): $(FOUND_SOURCE_FILES) $(QUIET_GEN)$(RM) $@+ && \ @@ -2903,7 +2905,7 @@ test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $( all:: $(TEST_PROGRAMS) $(test_bindir_programs) bin-wrappers/%: wrap-for-bin.sh - @mkdir -p bin-wrappers + $(call mkdir_p_parent_template) $(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's|@@BUILD_DIR@@|$(shell pwd)|' \ -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%$(X),$(@F))$(patsubst git%,$(X),$(filter $(@F),$(BINDIR_PROGRAMS_NEED_X)))|' < $< > $@ && \ diff --git a/shared.mak b/shared.mak index c45b2812eb6..4e1b62ee99e 100644 --- a/shared.mak +++ b/shared.mak @@ -53,6 +53,8 @@ ifndef V QUIET = @ QUIET_GEN = @echo ' ' GEN $@; + QUIET_MKDIR_P_PARENT = @echo $(wspfx_SQ) MKDIR -p $(@D); + ## Used in "Makefile" QUIET_CC = @echo ' ' CC $@; QUIET_AR = @echo ' ' AR $@; @@ -84,3 +86,18 @@ ifndef V export V endif endif + +### Templates + +## mkdir_p_parent: lazily "mkdir -p" the path needed for a $@ +## file. Uses $(wildcard) to avoid the "mkdir -p" if it's not +## needed. +## +## Is racy, but in a good way; we might redundantly (and safely) +## "mkdir -p" when running in parallel, but won't need to exhaustively create +## individual rules for "a" -> "prefix" -> "dir" -> "file" if given a +## "a/prefix/dir/file". This can instead be inserted at the start of +## the "a/prefix/dir/file" rule. +define mkdir_p_parent_template +$(if $(wildcard $(@D)),,$(QUIET_MKDIR_P_PARENT)$(shell mkdir -p $(@D))) +endef