Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp684745pxv; Thu, 22 Jul 2021 09:41:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYtu4wvzwQ5tnoqqKZBNl47vGT2nnnn+1IXfu82mdOG0uFcr/Vy7VtqPzaaK9nhSixEeAN X-Received: by 2002:a5d:8358:: with SMTP id q24mr462657ior.168.1626972079840; Thu, 22 Jul 2021 09:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626972079; cv=none; d=google.com; s=arc-20160816; b=DTQ+25DM63zo26vvqudsRgGAUeZaXHRmJTzQ7B204iGeGD0kpGF7CswsI0iRJrmVN/ DL4vpYh/4X8Qx6e3cXpHqkq0GaMRxDOaGb7U6xea6diLaRE3MBGg0nqlUJwSa4uBz/gA bq0MVhqRhjnHoCFpKjoc91ic+R5oJfChnzDzKrG3dCs4+LVi/7Qr9arsFO5GneVoMxvN vjhuIppbJNxtAHr6m5llffTejxkR3luHF1qFgNfp+8HQ30I0eJUay+eAvqi+OnX66kLQ uV5dVNYFm1YNdwLAnJqW5jK/0C9Gs5uARy6w3oyRBg+Q8TNZ+Nv8eZPlB5d8iFeS2t7z XNYA== 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=LewXBVucLUM+dxQilDPkoNgcICcQnSCcjrp0PHri+kJTqGx2A/BOmZ9ETiBMWj2DQL HPi5C/tP1UFkeRBGv9bM6Ulax1l0IS6jilBm8aAnSIZtgvit4fhydvmzxS++MRtZb7/m nxCA9XheI/CnpMOyoGJ3j6Cf+AQIElxUJggUtwXxaakNbzEgesYpXUetSebttF+Hbiay 523oktSWCWqve/KlPEKe+rOD0OfU+LCOX5RWucKeQbfPvEiSYvCtpnw0GcDQRuS7usfX 19QU4E5r2xHx7SutZpHsEFrOqKAk3ehJwH+j4TZyQtSgrlDXYF2BDsq7GcrdC68RGLNr vRGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Sj6cHogy; 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 16si18802348ioe.32.2021.07.22.09.41.08; Thu, 22 Jul 2021 09:41:19 -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=Sj6cHogy; 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 S232637AbhGVP7v (ORCPT + 99 others); Thu, 22 Jul 2021 11:59:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:33882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232795AbhGVP5p (ORCPT ); Thu, 22 Jul 2021 11:57:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1D1CA60FDA; Thu, 22 Jul 2021 16:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626971900; bh=0DfvojDQtsTjKzPBJI6fP0XKs1/zGyGKKVN5ampn9VE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sj6cHogyp5Q8nPskzmSfU0c5fNeRoTCtlC/MHFG7rdUYbglyLbq9nBgBkBzRYJPxr EqDRi8xgAb2jTOUai805wnitIIBmawZEtploh0fzLhQSS88sD+vxdTURBntjVV4CJT 6uuzSZVMHARtriY6qU7KwO8TVuiTY0cI5WrtkEdU= 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.10 068/125] kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set Date: Thu, 22 Jul 2021 18:30:59 +0200 Message-Id: <20210722155626.950408359@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210722155624.672583740@linuxfoundation.org> References: <20210722155624.672583740@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