From patchwork Wed Mar 11 10:01:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Marek X-Patchwork-Id: 5983061 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 05BC4BF6C3 for ; Wed, 11 Mar 2015 10:01:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2465F2041D for ; Wed, 11 Mar 2015 10:01:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 327C82041A for ; Wed, 11 Mar 2015 10:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751359AbbCKKBF (ORCPT ); Wed, 11 Mar 2015 06:01:05 -0400 Received: from cantor2.suse.de ([195.135.220.15]:41861 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbbCKKBE (ORCPT ); Wed, 11 Mar 2015 06:01:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CE188AAC9; Wed, 11 Mar 2015 10:01:01 +0000 (UTC) Received: by sepie.suse.cz (Postfix, from userid 10020) id 408BA40888; Wed, 11 Mar 2015 11:01:01 +0100 (CET) Date: Wed, 11 Mar 2015 11:01:01 +0100 From: Michal Marek To: Linus Torvalds Cc: Valdis Kletnieks , Andrew Morton , Linux Kernel Mailing List , Linux Kbuild mailing list Subject: Re: [RFC PATCH] Don't reset timestamps in include/generated if not needed Message-ID: <20150311100101.GA30787@sepie.suse.cz> References: <15447.1425431256@turing-police.cc.vt.edu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sun, Mar 08, 2015 at 04:08:06PM -0700, Linus Torvalds wrote: > On Tue, Mar 3, 2015 at 5:07 PM, Valdis Kletnieks > wrote: > > > > Kbuild regenerates bounds.h and asm-offsets.h, resetting the timestamps > > and forcing rebuilds even if the contents haven't changed. Add a bit of > > shell magic to only replace the file if the contents have in fact changed, > > which should speed up git bisects and similar. > > ... > > RFC because I can't wrap my head around why this wasn't done ages ago. > > If I'm missing something something obvious, please apply a cluestick. :) We do not regenerate the files *always*, but only if bounds.c / asm-offsets.c or one of the headers they include change. So the rule is not any worse than the rule for compiling a regular .c file into an .o file. You can use ccache to avoid repeated rebuilds. However, I can see that especially bounds.h ends up being included in many places, so cutting its dependencies helps in some cases. > > Lightly tested - if I rm one of those two files, it gets rebuilt. If I > > insert some whitespace, it gets replaced. If I don't touch it, the datestamp > > doesn't change. > > I don't think this is wrong, but I'd really prefer to do the whole > move-if-changed thing as a separate rule, and a separate command. > > IOW, could we please have something that generates the "build.h" file > by separately creating a new temporary file, and then having the > traditional kind of move-if-changed definition > > define move-if-changed > if ! cmp -s $(1) $(2); then mv -f $(1) $(2); else rm -f $(1); fi > endef We already have it and it is called "filechk." Valdis, can you check if the below patch works equally well for you? --- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Kbuild b/Kbuild index ab8ded9..47d0630 100644 --- a/Kbuild +++ b/Kbuild @@ -13,8 +13,9 @@ define sed-y s:->::; p;}" endef -quiet_cmd_offsets = GEN $@ -define cmd_offsets +# Use filechk to avoid rebuilds when a header changes, but the resulting file +# does not +define filechk_offsets (set -e; \ echo "#ifndef $2"; \ echo "#define $2"; \ @@ -24,9 +25,9 @@ define cmd_offsets echo " * This file was generated by Kbuild"; \ echo " */"; \ echo ""; \ - sed -ne $(sed-y) $<; \ + sed -ne $(sed-y); \ echo ""; \ - echo "#endif" ) > $@ + echo "#endif" ) endef ##### @@ -44,7 +45,7 @@ kernel/bounds.s: kernel/bounds.c FORCE $(obj)/$(bounds-file): kernel/bounds.s Kbuild $(Q)mkdir -p $(dir $@) - $(call cmd,offsets,__LINUX_BOUNDS_H__) + $(call filechk,offsets,__LINUX_BOUNDS_H__) ##### # 2) Generate asm-offsets.h @@ -63,7 +64,7 @@ arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ $(call if_changed_dep,cc_s_c) $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild - $(call cmd,offsets,__ASM_OFFSETS_H__) + $(call filechk,offsets,__ASM_OFFSETS_H__) ##### # 3) Check for missing system calls