Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1524893pxy; Fri, 23 Apr 2021 10:03:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1OCtglM9cM/SRPb+gCJHD3SLxvEI1HtguzJ5mtR8aloQL+tUbqyJh2ib/E9NsrHMlKq5l X-Received: by 2002:a63:d14b:: with SMTP id c11mr4875886pgj.290.1619197418157; Fri, 23 Apr 2021 10:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619197418; cv=none; d=google.com; s=arc-20160816; b=A1sOOA+4Cz7wlid+hIgQPuYd+lJXu0X2sNnYU9gGC1S9TsfiuKxdipNQB5cWUjEoMy 8tu9gswmFl3FZzbnBqKa+ABIIW2J9mZOSJxCHTtG8KIaCZyTItQ5SWSXJRA/+aV+6vLi WxVhMikUWevKY81F0xBC7/zGSG+szu63BT2jg73qU6m06lC0w4yogICMG1z9Ket3QB1Q ilklcy1KoQhcY0NrwL94ZzcPhPYU+UOlD/Y8+Cier9FxRSG63eqQMcwLbr4l1K8vT5E4 +tu3MC8rq35zP+uKd6hsZYn3mwRY0NW7ixn7Sx9uITpug0BtWp/Tu504XalGsx1U6jN/ KSsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:sender:dkim-signature; bh=OYnNE7Dy5EU3OXyOzCgjnJg//0G4V/ieE3hirIKZBnQ=; b=PH5vscpInuF7V0l/nOJeoBCd2ErxwqLfxFIWvLc33SLUTYnWy8hqGFDEifrPkHRlNf wi7ekCHmmbZijyZAt2SzLIS100YG3IpC0dmOE3kGk8AYlL5zw8a9AJfm+c5kbuTLlvld f+d124U7ArR368l0KfqJMVNgiZE2KuKalz9NIpta+/bU8Y8CccW4wKyFivi/LjTowOOy m7j3WA6WNNSrh1sZ1gsPTKxe8kdxByQia6SUGKcgDnAzHrPsafZu6RNklXnpPQLMsRJi 8FISLGXsbKrPlJuv6ZBhNo54RJzf8xjd/ebdHIOffBw2LfJckBInFNmrVST8ZZFljgzj zycA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=SjpwpMWu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si7512411pld.53.2021.04.23.10.03.25; Fri, 23 Apr 2021 10:03:38 -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=@mg.codeaurora.org header.s=smtp header.b=SjpwpMWu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243337AbhDWRDZ (ORCPT + 99 others); Fri, 23 Apr 2021 13:03:25 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:18128 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243324AbhDWRDU (ORCPT ); Fri, 23 Apr 2021 13:03:20 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1619197364; h=In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=OYnNE7Dy5EU3OXyOzCgjnJg//0G4V/ieE3hirIKZBnQ=; b=SjpwpMWu6iJ4UW+KJ4J4xwcujKJR3fy7cq489ifR3vgcCeKgMjzEAvHI223Oi0Xjr/zB3chS GfNmQ0QorRZPSz1PLARBIJujtlA3rBduCE8hT4Pcc03ttL6Z62dvIKpVI138gkES7Dd7dhtm PWhd/mf3a/szm/nGUGcGiuTNQz0= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-east-1.postgun.com with SMTP id 6082fd8aa817abd39a2e319e (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 23 Apr 2021 17:02:02 GMT Sender: eberman=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8039FC0453F; Fri, 23 Apr 2021 17:02:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from eberman-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: eberman) by smtp.codeaurora.org (Postfix) with ESMTPSA id 14DE2C43217; Fri, 23 Apr 2021 17:01:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 14DE2C43217 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=eberman@codeaurora.org From: Elliot Berman To: Masahiro Yamada , Michal Marek Cc: Elliot Berman , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Matthias Maennich , Trilok Soni Subject: [RESEND v2] Kbuild: Update config_data.gz only if KCONFIG_CONFIG materially changed Date: Fri, 23 Apr 2021 10:00:35 -0700 Message-Id: <1619197235-13860-1-git-send-email-eberman@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: 1617317072-26770-1-git-send-email-eberman@codeaurora.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If you update the timestamp of KCONFIG_CONFIG without actually changing anything, config_data.gz is re-generated and causes vmlinux to re-link. When Link Time Optimization is enabled, unnecessary re-linking of vmlinux is highly desirable since it adds several minutes to build time. Avoid touching config_data.gz by using a script to compare the existing config_data.gz, KCONFIG_CONFIG, or script itself to update only if any is mismatched. The script follows gen_kheaders.sh approach for determing in update is needed. The script intentionally avoids re-compressing KCONFIG_CONFIG. The .config can be touched, for instance, by a build script which installs the default defconfig and then applies a defconfig fragment on top. For a simple example on my x86 machine, I modified x86 default defconfig to set CONFIG_IKCONFIG=y and run: make -j50 defconfig tiny.config vmlinux make -j50 defconfig tiny.config vmlinux With this patch, vmlinux is not re-built as a result of config_data.gz change. Changes in v2: - Use md5 checksum to compare .config instead of gzip'ing again Signed-off-by: Elliot Berman --- kernel/.gitignore | 1 + kernel/Makefile | 4 +++- kernel/gen_config_data.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 kernel/gen_config_data.sh diff --git a/kernel/.gitignore b/kernel/.gitignore index 78701ea..a191136 100644 --- a/kernel/.gitignore +++ b/kernel/.gitignore @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +config_data.gz.md5 kheaders.md5 timeconst.h hz.bc diff --git a/kernel/Makefile b/kernel/Makefile index 320f1f3..0784bf3d 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -139,8 +139,10 @@ obj-$(CONFIG_SCF_TORTURE_TEST) += scftorture.o $(obj)/configs.o: $(obj)/config_data.gz targets += config_data.gz +quiet_cmd_genicfg = CHK $(obj)/config_data.gz + cmd_genicfg = $(CONFIG_SHELL) $(srctree)/kernel/gen_config_data.sh $@ $< $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE - $(call if_changed,gzip) + $(call cmd,genicfg) $(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz diff --git a/kernel/gen_config_data.sh b/kernel/gen_config_data.sh new file mode 100755 index 00000000..e9ff193 --- /dev/null +++ b/kernel/gen_config_data.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +# This script generates a compressed version of .config, if its checksum has changed +set -e + +this_file="$(readlink -f "$0")" +outfile=$1 +infile=$2 + +config_md5="$(md5sum $infile | cut -d ' ' -f1)" +# Any changes to this script will also cause a rebuild of config_data. +this_file_md5="$(md5sum $sfile | cut -d ' ' -f1)" +if [ -f $outfile ]; then outfile_md5="$(md5sum $outfile | cut -d ' ' -f1)"; fi + +if [ -f $outfile.md5 ] && + [ "$(head -n 1 $outfile.md5)" = "$config_md5" ] && + [ "$(head -n 2 $outfile.md5 | tail -n 1)" = "$this_file_md5" ] && + [ "$(tail -n 1 $outfile.md5)" = "$outfile_md5" ]; then + exit +fi + +if [ "${quiet}" != "silent_" ]; then + echo " GEN $outfile" +fi + +${KGZIP} -c -n -f -9 $infile > $outfile + +echo "$config_md5" > $outfile.md5 +echo "$this_file_md5" >> $outfile.md5 +echo "$(md5sum $outfile | cut -d ' ' -f1)" >> $outfile.md5 -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project