From patchwork Fri Mar 5 10:02:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 12118221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A847C433DB for ; Fri, 5 Mar 2021 10:02:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D41D464FE8 for ; Fri, 5 Mar 2021 10:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229716AbhCEKCS (ORCPT ); Fri, 5 Mar 2021 05:02:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbhCEKCR (ORCPT ); Fri, 5 Mar 2021 05:02:17 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4049EC061756 for ; Fri, 5 Mar 2021 02:02:17 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id ci14so2281371ejc.7 for ; Fri, 05 Mar 2021 02:02:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GRC2Y0yC42Y1EH5KbI50W2aWiq7kngTQEblGKY3SQmc=; b=GothC0fBH2XEicdmeOy5BlwIbxBo48V//n3KuOEKMVDhURBrKEn/1pxUN4qEWEBxVL VmRm+QJaoXGlEkFUEPwSTCYSZXnp7oS4PM6WDINCcivyN8nXan+UzaUjbdRAl0xabMLs /mFbFxoTbyRzi/zmsBkORqS/pvZLvfLxdpmIs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GRC2Y0yC42Y1EH5KbI50W2aWiq7kngTQEblGKY3SQmc=; b=qeUONYAwNQ+GbRqQExLLmM1R8IX/n/DToLVTQHmgt/rPsWlh3p2ts8Bp4pJlg1bD5i 8eOnqmYH/hy6kjb7+F62UhYBm901uNLg20U2ojI6+CRobF1jnWCV9DnaJtDWchmEYLv8 IksRlZyE/nBuGCu2b9l4NWEEsOWMl0q25u1nDMdx52N94lp1dXTdAFLLcGp7BBCv8WUp oZJi8AFCnVfx1cDQIqo/kEvaJQ4i8jp2Jhfg59j6GdCfwkO38Nh18F+srYjuXKElOwl5 l3Y2/FBwfNSbz49/pDrEIMk+mCecOqaYfVZcHfEIiZe4x2M/IOoQjm15qcna5yzXHIf2 4yOA== X-Gm-Message-State: AOAM531xuC5IBk1ii01wnrqc+AiN/IE22gY8Ji5trx0nlAZo+rP5MsO8 pOKYLNd7YRWMAeRtpAWf0ZTeFGselRk6GA== X-Google-Smtp-Source: ABdhPJzcocXQzKr/9kf3AnihZeBnSoVC3XwiNhCp06ZeOpkZhLYwKWQOtRRDmPzyUe8gyE9xRq/xEg== X-Received: by 2002:a17:906:7150:: with SMTP id z16mr1512151ejj.103.1614938536001; Fri, 05 Mar 2021 02:02:16 -0800 (PST) Received: from prevas-ravi.prevas.se ([80.208.71.141]) by smtp.gmail.com with ESMTPSA id y2sm1223419ejf.30.2021.03.05.02.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 02:02:15 -0800 (PST) From: Rasmus Villemoes To: Masahiro Yamada , Michal Marek Cc: Rasmus Villemoes , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: apply fixdep logic to link-vmlinux.sh Date: Fri, 5 Mar 2021 11:02:12 +0100 Message-Id: <20210305100212.818562-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org The patch adding CONFIG_VMLINUX_MAP revealed a small defect in the build system: link-vmlinux.sh takes decisions based on CONFIG_* options, but changing one of those does not always lead to vmlinux being linked again. For most of the CONFIG_* knobs referenced previously, this has probably been hidden by those knobs also affecting some object file, hence indirectly also vmlinux. But CONFIG_VMLINUX_MAP is only handled inside link-vmlinux.sh, and changing CONFIG_VMLINUX_MAP=n to CONFIG_VMLINUX_MAP=y does not cause the build system to re-link (and hence have vmlinux.map emitted). Since that map file is mostly a debugging aid, this is merely a nuisance which is easily worked around by just deleting vmlinux and building again. But one could imagine other (possibly future) CONFIG options that actually do affect the vmlinux binary but which are not captured through some object file dependency. To fix this, make link-vmlinux.sh emit a .vmlinux.d file in the same format as the dependency files generated by gcc, and apply the fixdep logic to that. I've tested that this correctly works with both in-tree and out-of-tree builds. Signed-off-by: Rasmus Villemoes --- Makefile | 2 +- scripts/link-vmlinux.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b18dbc634690..19d2f7fd088a 100644 --- a/Makefile +++ b/Makefile @@ -1192,7 +1192,7 @@ cmd_link-vmlinux = \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE - +$(call if_changed,link-vmlinux) + +$(call if_changed_dep,link-vmlinux) targets := vmlinux diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 855fd4e6f03e..7d4b7c6f01e8 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -312,6 +312,7 @@ cleanup() rm -f vmlinux rm -f vmlinux.map rm -f vmlinux.o + rm -f .vmlinux.d } on_exit() @@ -421,6 +422,7 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then fi vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} +echo "vmlinux: $0" > .vmlinux.d # fill in BTF IDs if [ -n "${CONFIG_DEBUG_INFO_BTF}" -a -n "${CONFIG_BPF}" ]; then