Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1396282pxj; Sat, 12 Jun 2021 07:21:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTAPzzPegCGq6K+fV/cI6rJ+WVy6EHuGWsRPii6gTqMxq2uV48TdjJnl1ZeytFqGDl/9Je X-Received: by 2002:a05:6402:685:: with SMTP id f5mr8686069edy.178.1623507710198; Sat, 12 Jun 2021 07:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623507710; cv=none; d=google.com; s=arc-20160816; b=PLXzxkW6hliAvLbvbTB+6TvxSqpjNjXmmKT412UjQ69rmfb+JhUnGWAPdmbUqhSLbu XtatDB4lKbk5rXEj09RQlV2gJbzyiYcJR2wK2r+gJZ3Riat8TNNCBBardUVHmIhJaQnz majpM605AG2wORte/glTuIlA+3Oq0Ixwjc+A7ykqmn9TAKOHs+Yl7WqFXiUcuc7MwhSB 5YTbOYSHp5YwE9ZXhNAV+WTkVd41t6q8E4vFTCWUILhK5ESCPz7KWY18P4ACTlJgyK/t RsGx/p6PiIQkTsh55NDCOdleaoMGoRiofbeEWGjhe01isgX8TBwSwRpNA8ELkwzJMLsT /Dow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=xb2QAx7zepAh/lQE/CJVc+d/CGuwmfQ6M6AYYspdx1I=; b=j672yyD2FxAyFhEJnZf4HqdnWiQpVsGTkcEfs4iSLlgJGaS+4QyaB3IKG3MEQFjp1D abzZnb2UPYHy1YGgzcexcwBGSiNWoNn0O3ePo2ycZJr71ud9zoz84IuYMTRSPM0P63Dr NC/g0j8nHXVo/8VVTIczkTGKhc3kshUhlNWjSl7DyhgakmSqAJFwdbqzZGZD1g6VX5k2 fnsfnlsM5NCg4B+f5kmL3kA4fXGcBrB5YsoE+YIkYW7E9xO1WtEHxOwh67erF4gnYs05 DHQRmEIQwbIqgMQoVBEU59eP89hGNV1rX4Ctp6weGa23xrcNcTOEPG3stNnTMLWHXh9c qwvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Pn1g/j4Q"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z21si6861441eja.498.2021.06.12.07.21.26; Sat, 12 Jun 2021 07:21:50 -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=@google.com header.s=20161025 header.b="Pn1g/j4Q"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231158AbhFLOU7 (ORCPT + 99 others); Sat, 12 Jun 2021 10:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbhFLOU6 (ORCPT ); Sat, 12 Jun 2021 10:20:58 -0400 Received: from mail-ed1-x549.google.com (mail-ed1-x549.google.com [IPv6:2a00:1450:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91F4BC061574 for ; Sat, 12 Jun 2021 07:18:47 -0700 (PDT) Received: by mail-ed1-x549.google.com with SMTP id f12-20020a056402150cb029038fdcfb6ea2so17313283edw.14 for ; Sat, 12 Jun 2021 07:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=xb2QAx7zepAh/lQE/CJVc+d/CGuwmfQ6M6AYYspdx1I=; b=Pn1g/j4Q/Ps8hO/Wv4OvCFaicBjrttTarkv+9pOFkNnWNh42V8bddGeTBrO7Vlw5cg 4Re/hLQOA9OFtL8OPulFNerctA3fi6rLZzfhwueqHLWuSSMio0KiWvt527JC1LgSqsb2 0BGa8BtMC9LNQROvUh4K4i3i8r4C1wLe3tGLLQZbGZvaVLEyjSIUSe0t+qtRBffeeF7d kfctmL+xofvpBMsrn7fJkFCk7I4CIOn2L3ofNk9TRXWSYNS8is69W9dcKsEkIRQAK7FU 5Nr9P35dYmK7LOYSRj8fb1RokC30zVaHTZQ5vy0hjLOghItjI4u9ECqBDv2AxmgW5+3h +T0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=xb2QAx7zepAh/lQE/CJVc+d/CGuwmfQ6M6AYYspdx1I=; b=QYOUSOK9C9JR4cf3pMknENEqFgGdE0Vy+8OMm9zr2RIsLS+pylrJ9rDj39KypF7wau cXekpiA1VLtWGUjq/Wpf2SOKRK4+l9uIsYhCEVgjzcpnNdDFWN+EqoZKr1f9Wsp9dEMe DfVf+iGw+ZtRghv2MUp8HunE2SF42DaAHvBppx3H9GhrJ8Tg1FYB9obUTpfyG9rJxfe4 VVR7sOcLcd1m1SoVCqaL6QV7Qq1oZX0SckpT7efHHoWnZlIGjdRhMofsGdp0G7FDZzr0 gsfumtFjyzbWMQ0Yly+bHiglkYi6N/Lx2Yr4urj5i2nhRvovh8niBZEC4fSiQvfjabL7 zlrQ== X-Gm-Message-State: AOAM531pPwLscBv2WOFpeioiPTiCUsbJtidnpgjzBnZCdAmYq2sIrQun GunjNprhhBOpZVtuF6a4GKieg3BANWw4NV8Nfd6htWW0xsX6d7YCGffv3wBQMt+bjQSwW142CC2 L+wJgVdDt27QuF1BzvAIbHwF0FZVXXzWeVhd3re4ZJfscd01WWVQR+UHE6mVBMW4ntZkknQd/76 s= X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:f276:1917:882e:b90d]) (user=maennich job=sendgmr) by 2002:a05:6402:1458:: with SMTP id d24mr8742698edx.85.1623507525727; Sat, 12 Jun 2021 07:18:45 -0700 (PDT) Date: Sat, 12 Jun 2021 15:18:38 +0100 Message-Id: <20210612141838.1073085-1-maennich@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.272.g935e593368-goog Subject: [PATCH] kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, Masahiro Yamada , linux-kbuild@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org Signed-off-by: Matthias Maennich --- 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.32.0.272.g935e593368-goog