Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp694164pxv; Thu, 22 Jul 2021 09:52:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl7VN84eJn2FZpZi6SAofAdsEfBqZDn9ThUpg2SSHxlICS14GZsdUT1hu+LrqGYCYJPSV/ X-Received: by 2002:a92:3207:: with SMTP id z7mr511333ile.288.1626972775303; Thu, 22 Jul 2021 09:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972775; cv=none; d=google.com; s=arc-20160816; b=HwXtYza7vivybjmHhIqzUtDzcnfgAwDZBat4ezGiJ83YjvrIlqdzi2tjrhBNGP0wWz LgGputhIcnPjfMlVXzDRs/cfyBv7fNi9bxVv7oXiHVccTxtQjLCOKEgSohO6tIpAx27k mLCyGoYwfkZeP7Ahz6/KFWp0K7hgOhkRMzpr6yXsBhawmhZEg28L/L2htrvOYRoXPZvC q8rIl2CR2f+44rOqP5erJixjzLJPAdAP92FyBUDu3/xj3lfqZpa6febNHD4NuaE65cbt Hga1mbCJ4+EicRYOWUgi/qJXEJr5tbq4bxKV9c3viVqB/pMvuwXNpLQYWuUgq0TjmedE W47A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gZjnW3huXj6mMPlV5kwFxLlgSDskA+TYunTMiIZ2SY8=; b=Q2D+8S+FxLjIqlFYAeQNeG2bwGJ3YQ9rTSBqX9F5kUAUYhwZzJK/CgHkXMJ4StJkIA kFudK9+mFO/l1BKrF6B+maskLQKtHGy58vqXlwxsRFXqWAAt6HDdS9yY/7ioE4+Q5XV7 svVX7+A4lbY68fgaWmJY6YF1znGX+14wmubv5+z7HJE7bJw4XZPCua4VQap9cM7/dboC M991P6BVCx4mEcJmJzcECTbNGA/GbMuJ+S/fMECcuen/CHlI5eyrkGif1OyzQKq6SjVC UOitbxngRjjflBoBxOR4RQdZ03YSTlkUmysIkSPLLLdong3FG1bO60TdZ+w0o/32wdHy cwqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FJTpUKyd; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i186si34081179ioa.76.2021.07.22.09.52.43; Thu, 22 Jul 2021 09:52:55 -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=@linuxfoundation.org header.s=korg header.b=FJTpUKyd; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235433AbhGVQJT (ORCPT + 99 others); Thu, 22 Jul 2021 12:09:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:43148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234947AbhGVQFg (ORCPT ); Thu, 22 Jul 2021 12:05:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F0A361CBF; Thu, 22 Jul 2021 16:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626972369; bh=0DfvojDQtsTjKzPBJI6fP0XKs1/zGyGKKVN5ampn9VE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FJTpUKydcRKnQ74UR6E/zwpy4VEmkZ5c9mTRTILAPZD7x8xh82qoA5e5K7LLVl0qU F299+W56EntsF29Q3IQcOGTwKEJ6p8u+bLtf54ONHSzWSooJOf7lr07kbeqfT/eyHP xYJZkTNvamO2gfs8M5SvR4jUH60AYBP1mW16eWrw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias Maennich , Masahiro Yamada , Sasha Levin Subject: [PATCH 5.13 088/156] kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set Date: Thu, 22 Jul 2021 18:31:03 +0200 Message-Id: <20210722155631.229329270@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155628.371356843@linuxfoundation.org> References: <20210722155628.371356843@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 4ae735039daf..a72b154de7b0 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -70,15 +70,23 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | 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