From patchwork Fri Mar 23 13:04:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132335 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp572459ljb; Fri, 23 Mar 2018 06:07:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELsANIzT/igXmOX0yr/mX6hLs2oW/P1eS6rkiQarktooaN36RKN9RVyYz3L+xqmjY57kGY1F X-Received: by 10.99.109.142 with SMTP id i136mr20953931pgc.306.1521810443288; Fri, 23 Mar 2018 06:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521810443; cv=none; d=google.com; s=arc-20160816; b=TjwfEN8ckqRX9CG/MMwZc0bbci8smyGGxtp0UNZhC8byWPnUJdJGDmicdxIDTxzYyv LPAnXP7EOAA3DsWSyySt1qNQHx9145lrbeav3SmOeaTSBtn5uYxhg+DTw55rMB4LWWDn PffhxS1VlgscCxRIqzq3OZgh+1QRWdNsel5FvMZCCeiRTYN3OkO9/nVjunJI57so5Mrz epw9d7F7gHpbT+inneM04pC6muZn2NovBPX/713GOoQXW+jxRNF/6BOwNiHnHpR7La+A 8Yhd362XqPbWm3YxMPKV4fIxYdBfbtxdHOrWpBoEnq1y1eUlaaN2MVH4fbfE4OICaLF1 Dbeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=BMtc8wVlM6hbOTnDh8j/r54s+Kqgy4bjylMbPDxjgOs=; b=KGLX6E0WgasSCBAShl55ogb8YWuuhOZT4FvPJYzEhahoJYO2aHFDf+N7TTD5zwD8jB YtEAVSK7VPjn40A8jKGF9BCPGlxb8S4Ei88hZUguwaSwGvmoTo3k1TCKz9u+GJclxC5A EWENDKAEY47qFEJPI7m6+njQfWe4vtQir6O7QPDO6P9MoYHCfkemZfT1dLPV8BxG4uE8 qWdPN8AdOlcA8ueJhaJbxUikCLixZmEQ8ySu+m8G+1n5FBTbpmfoFgkiXbocbq6Uw12N VbaOOT3UW3A6lRuBfzPY0qbxllEig7DDpf3oDIqb13TqVTcRsevG7hvuUcNV1C3K68AQ +8Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ewzsHuEE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si6131677pgn.366.2018.03.23.06.06.58; Fri, 23 Mar 2018 06:07:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ewzsHuEE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753349AbeCWNG4 (ORCPT + 28 others); Fri, 23 Mar 2018 09:06:56 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:54082 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752681AbeCWNGy (ORCPT ); Fri, 23 Mar 2018 09:06:54 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id w2ND4mgg011418; Fri, 23 Mar 2018 22:05:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w2ND4mgg011418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521810332; bh=BMtc8wVlM6hbOTnDh8j/r54s+Kqgy4bjylMbPDxjgOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ewzsHuEE09y4JYEK6T+OzFhKmj7rRuQDlJ8Tn+ao9/4IEsQQkaPK6TqBrpmNEWRpY Bfj6NZem0jCYLqk8COOWhCXLpSPiJBJ/KOeoGfUGnyTGtkuc6gYGt8FVd7qouATfQu T4c2NNVGBlwFyZ6YhTjkg1PtHuJOT7S7eVrFOuOC5WnAqJMIkpjz+mm5IDO3a/zgxZ tAUq1Ji3s/ghWFa8zLvGXuM1jJTEk0hSx5i2NXLbKWoJihKBBJy7AIP4J+X3IZoXHA TQ7eb+ABpPbek8HYv2hTW/OuJrx2yqEmOKELBQZl61KmNP2LeA00O8AkpRKjEk0azU dKsEPVS4loT5A== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , linux-kernel@vger.kernel.org, Arnd Bergmann , Laurent Pinchart , Frank Rowand , Geert Uytterhoeven , Masahiro Yamada Subject: [PATCH 10/10] kbuild: mark $(targets) as .SECONDARY and remove .PRECIOUS specifier Date: Fri, 23 Mar 2018 22:04:39 +0900 Message-Id: <1521810279-6282-10-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521810279-6282-1-git-send-email-yamada.masahiro@socionext.com> References: <1521810279-6282-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GNU Make automatically deletes intermediate files that are updated in a chain of pattern rules. Example 1) %.dtb.o <- %.dtb.S <- %.dtb.S <- %.dts Example 2) %.o <- %.c <- %.c_shipped A couple of makefiles mark such targets as .PRECIOUS to prevent Make from deleting them, but the correct way is to use .SECONDARY. .SECONDARY Prerequisites of this special target are treated as intermediate files but are never automatically deleted. .PRECIOUS When make is interrupted during execution, it may delete the target file it is updating if the file was modified since make started. If you mark the file as precious, make will never delete the file if interrupted. Both can avoid deletion of intermediate files, but the difference is the behavior when Make is interrupted; .SECONDARY deletes the target, but .PRECIOUS does not. The use of .PRECIOUS is relatively rare since we do not want to keep partially constructed (possibly corrupted) targets. Another difference is that .PRECIOUS works with pattern rules whereas .SECONDARY does not. .PRECIOUS: $(obj)/%.lex.c works, but .SECONDARY: $(obj)/%.lex.c has no effect. However, for the reason above, I do not want to use .PRECIOUS to avoid obscure build breakage. The targets specified as .SECONDARY must be explicit. $(targets) contains all targets that need to include .*.cmd files. So, the intermediates you want to keep are likely to be contained in $(targets). So, mark it as .SECONDARY. The exception is when they are created by $(call cmd,...) instead of $(call if_changed,...) since the former does not need to include .*.cmd file. In this case, makefiles need to mark them .SECONDARY by themselves, like arch/arm(64)/crypto/Makefile. Signed-off-by: Masahiro Yamada --- arch/arc/boot/dts/Makefile | 2 -- arch/arm/crypto/Makefile | 2 +- arch/arm64/crypto/Makefile | 2 +- arch/metag/boot/dts/Makefile | 2 -- drivers/of/unittest-data/Makefile | 4 ---- scripts/Makefile.build | 6 ++++-- scripts/Makefile.lib | 3 --- 7 files changed, 6 insertions(+), 15 deletions(-) -- 2.7.4 Acked-by: Frank Rowand diff --git a/arch/arc/boot/dts/Makefile b/arch/arc/boot/dts/Makefile index 22a4c5d..a83c4f5 100644 --- a/arch/arc/boot/dts/Makefile +++ b/arch/arc/boot/dts/Makefile @@ -9,8 +9,6 @@ endif obj-y += $(builtindtb-y).dtb.o dtb-y := $(builtindtb-y).dtb -.SECONDARY: $(obj)/$(builtindtb-y).dtb.S - # for CONFIG_OF_ALL_DTBS test dtstree := $(srctree)/$(src) dtb- := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts)) diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile index 30ef8e2..3d59567 100644 --- a/arch/arm/crypto/Makefile +++ b/arch/arm/crypto/Makefile @@ -63,4 +63,4 @@ $(src)/sha256-core.S_shipped: $(src)/sha256-armv4.pl $(src)/sha512-core.S_shipped: $(src)/sha512-armv4.pl $(call cmd,perl) -.PRECIOUS: $(obj)/sha256-core.S $(obj)/sha512-core.S +.SECONDARY: $(obj)/sha256-core.S $(obj)/sha512-core.S diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile index cee9b8d9..fceb638 100644 --- a/arch/arm64/crypto/Makefile +++ b/arch/arm64/crypto/Makefile @@ -76,4 +76,4 @@ $(src)/sha256-core.S_shipped: $(src)/sha512-armv8.pl $(src)/sha512-core.S_shipped: $(src)/sha512-armv8.pl $(call cmd,perlasm) -.PRECIOUS: $(obj)/sha256-core.S $(obj)/sha512-core.S +.SECONDARY: $(obj)/sha256-core.S $(obj)/sha512-core.S diff --git a/arch/metag/boot/dts/Makefile b/arch/metag/boot/dts/Makefile index f0a180f..16505aa 100644 --- a/arch/metag/boot/dts/Makefile +++ b/arch/metag/boot/dts/Makefile @@ -12,5 +12,3 @@ endif dtb-$(CONFIG_METAG_BUILTIN_DTB) += $(builtindtb-y).dtb obj-$(CONFIG_METAG_BUILTIN_DTB) += $(builtindtb-y).dtb.o - -.SECONDARY: $(obj)/$(builtindtb-y).dtb.S diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile index 333bc4c..0fb87cb 100644 --- a/drivers/of/unittest-data/Makefile +++ b/drivers/of/unittest-data/Makefile @@ -12,7 +12,3 @@ DTC_FLAGS_overlay := -@ DTC_FLAGS_overlay_bad_phandle := -@ DTC_FLAGS_overlay_bad_symbol := -@ DTC_FLAGS_overlay_base := -@ - -.PRECIOUS: \ - $(obj)/%.dtb.S \ - $(obj)/%.dtb diff --git a/scripts/Makefile.build b/scripts/Makefile.build index cc081af..4397adb 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -430,8 +430,6 @@ quiet_cmd_asn1_compiler = ASN.1 $@ cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \ $(subst .h,.c,$@) $(subst .c,.h,$@) -.PRECIOUS: $(objtree)/$(obj)/%.asn1.c $(objtree)/$(obj)/%.asn1.h - $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 \ $(objtree)/scripts/asn1_compiler FORCE $(call if_changed,asn1_compiler) @@ -590,6 +588,10 @@ $(shell mkdir -p $(obj-dirs)) endif endif +# Some contained in $(targets) are intermediate artifacts. +# We never want them to be removed automatically. +.SECONDARY: $(targets) + # Declare the contents of the .PHONY variable as phony. We keep that # information in a variable se we can use it in if_changed and friends. diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7a1fa92..c114ce5 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -183,7 +183,6 @@ endef quiet_cmd_flex = LEX $@ cmd_flex = $(LEX) -o$@ -L $< -.PRECIOUS: $(obj)/%.lex.c $(obj)/%.lex.c: $(src)/%.l FORCE $(call if_changed,flex) @@ -192,14 +191,12 @@ $(obj)/%.lex.c: $(src)/%.l FORCE quiet_cmd_bison = YACC $@ cmd_bison = $(YACC) -o$@ -t -l $< -.PRECIOUS: $(obj)/%.tab.c $(obj)/%.tab.c: $(src)/%.y FORCE $(call if_changed,bison) quiet_cmd_bison_h = YACC $@ cmd_bison_h = bison -o/dev/null --defines=$@ -t -l $< -.PRECIOUS: $(obj)/%.tab.h $(obj)/%.tab.h: $(src)/%.y FORCE $(call if_changed,bison_h)