Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp707833pxv; Wed, 14 Jul 2021 13:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylrbh44t1sO9OHKEHgMwW4gjSjL9rzyXW3M4byf1JKj4eTG/XxXKkI+kWa3qlrP1CniytG X-Received: by 2002:aa7:d8c1:: with SMTP id k1mr250070eds.28.1626294974981; Wed, 14 Jul 2021 13:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626294974; cv=none; d=google.com; s=arc-20160816; b=0NXSxOaLKljQe9rQRvVYdnfHXUqkvspF7cakUaM0cZ9/YyTjAygFhfB5Mdpyt8LGSR Q+2fFzKRw70aTG0GUDCZV2p2pkv+zRl6h93HbAs41bmcK5RDHcB+72Ve4bkek6H72Pp9 n0Y4PQ85xeeFWg3MszkVYW8XyebwVJBdqFd+0YNBqJpxocMEunyr7bZiLAOPX0seUnP1 us1gMae0kqwleqyRvMRf/qfRz7t65CBvaZEq51s4Mma6HJ00LDz5jgfP5rSa8AIES4QW D/0sqngahm9uaIIxyMkfOvPnwpGPSDoBQxbkttHk60E38qtQFfAlCjoonDU4IFwewQFD 6ZJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l7ftLlHMA8I/aCVlbzibDSCYFKrONq75ohoJSXjEqRQ=; b=U3fIuJVkhf0o7f9jnoYwZy1szuzU9GNK8TNGPXak3Vb54DyBujVn1SkA8VJdz+pk/7 W6dVwBVg6Q398Ha2z9ClxZntwhlKqo7vNDsyHJXQTUrp8kmo23vFK9V8hdvRzNsquGLw Ku2X0E5rn40aDyauXhIFV93W71tfjucTjCtGdUlijmVAAZzsqQfsRWdqyLwYw3zsbCW8 NdcxudhBCrerlp1K/O9WxXlM7B3+4YnK0VgEmb12DbY8E251dOwunvO9MMiAmIVBhREJ mgG7rTfn64p7fGp9Xw0PH+9rF8h3xC19JtJagOxQ65UytTWfc5CL+4+SO6+ai0qQ6Vmf dV1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VIRta9FQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id az1si3439512ejc.273.2021.07.14.13.35.51; Wed, 14 Jul 2021 13:36:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VIRta9FQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237931AbhGNUFi (ORCPT + 99 others); Wed, 14 Jul 2021 16:05:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:49708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233831AbhGNTvU (ORCPT ); Wed, 14 Jul 2021 15:51:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 39C10613D2; Wed, 14 Jul 2021 19:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626292106; bh=i06fPrBmFPd4Vw53yWquMo8pgHRq2PQGWRELFLr2wsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VIRta9FQDZkXs8RglUQLL6S3szTvRiSypJG5vGbBQ4L7GIPio4nzknM0ek1tDtjDT 4l78k+EWDLqaShyKC8Hpl+DwBoJiAIZCXeMe7vLmbETk0NllA+pmUVfZxHMbuT8CT2 f4vLnd3y3vVCRiXc5xSV+xYFTTMEi/7qTeCWWf4k9K27YEiaD1XwRTk4qakck6dLOj q4djyu+hfQ16+hJ5gqgRrlcB4ZVVcEtYq7fjO/+LYYSmMiLxXTj5OzvZl/djv3TVdV lx+O26CbZ/FdvdPw0fgktk9yXRhrgVW0JuuLjmKoo3/cKzQAJ1H9ZTWaTkGIalC3YA hX3PZ8kk9et5g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Matthias Maennich , Masahiro Yamada , Sasha Levin , linux-kbuild@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 14/18] kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set Date: Wed, 14 Jul 2021 15:48:02 -0400 Message-Id: <20210714194806.55962-14-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210714194806.55962-1-sashal@kernel.org> References: <20210714194806.55962-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthias Maennich [ Upstream commit a979522a1a88556e42a22ce61bccc58e304cb361 ] To avoid unnecessary recompilations, mkcompile_h does not regenerate compile.h if just the timestamp changed. Though, if KBUILD_BUILD_TIMESTAMP is set, an explicit timestamp for the build was requested, in which case we should not ignore it. If a user follows the documentation for reproducible builds [1] and defines KBUILD_BUILD_TIMESTAMP as the git commit timestamp, a clean build will have the correct timestamp. A subsequent cherry-pick (or amend) changes the commit timestamp and if an incremental build is done with a different KBUILD_BUILD_TIMESTAMP now, that new value is not taken into consideration. But it should for reproducibility. Hence, whenever KBUILD_BUILD_TIMESTAMP is explicitly set, do not ignore UTS_VERSION when making a decision about whether the regenerated version of compile.h should be moved into place. [1] https://www.kernel.org/doc/html/latest/kbuild/reproducible-builds.html Signed-off-by: Matthias Maennich Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/mkcompile_h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index 6fdc97ef6023..cb73747002ed 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -82,15 +82,23 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" # Only replace the real compile.h if the new one is different, # in order to preserve the timestamp and avoid unnecessary # recompilations. -# We don't consider the file changed if only the date/time changed. +# We don't consider the file changed if only the date/time changed, +# unless KBUILD_BUILD_TIMESTAMP was explicitly set (e.g. for +# reproducible builds with that value referring to a commit timestamp). # A kernel config change will increase the generation number, thus # causing compile.h to be updated (including date/time) due to the # changed comment in the # first line. +if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then + IGNORE_PATTERN="UTS_VERSION" +else + IGNORE_PATTERN="NOT_A_PATTERN_TO_BE_MATCHED" +fi + if [ -r $TARGET ] && \ - grep -v 'UTS_VERSION' $TARGET > .tmpver.1 && \ - grep -v 'UTS_VERSION' .tmpcompile > .tmpver.2 && \ + grep -v $IGNORE_PATTERN $TARGET > .tmpver.1 && \ + grep -v $IGNORE_PATTERN .tmpcompile > .tmpver.2 && \ cmp -s .tmpver.1 .tmpver.2; then rm -f .tmpcompile else -- 2.30.2