Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2028989pxb; Fri, 5 Mar 2021 05:54:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKOjlI2IIDz2nrfSk5ikNK6be8RoWuwtpg2yALgPNq1LhRmger2BlcYH71A+8zjOov3+aT X-Received: by 2002:a50:e1c4:: with SMTP id m4mr9103113edl.182.1614952476130; Fri, 05 Mar 2021 05:54:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614952476; cv=none; d=google.com; s=arc-20160816; b=vRapJ8ssSOXEbRLLprikx/fuSnDVWi7AzSR4xGCHcfndKwWU54sXbNT0WMkHjWEQiJ TJwFo9D5FK71zbTPtrPaofD5yJh1aIZLjgNS7anKPx5sDQqQQsmA/MkNuF8wmXt/CQrs YCS8n7xCRtOxNXL6XBOigY5PCLPs1L09Z6xL6452LoToquXG8g41y+uOg3qm+b0vgD2P 8NQS0ioJsEBqQmfjv7GYklF7whyXJoB6xW9ZLfS1Gv81zySHrxXjJX4irlhD/uJlAeIG JLxAaP/54z+8lJK3r/kE4ototOmPgdaHX9jrIihm1a9AXBlUKCMkHKDJOQpnYWQSsbbF dbqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=lKzscS/Tew+SOZceq8wryzAZUo4F0IRAiu21R0Zw2tk=; b=Yc7EH/7/2dUcLBWF7AmVn95jhVzhRfp44OE/Jgil586a8w1BBitMyhmcrtja34NGOl lXDeRYwnIxYqvsuCyGke7QAKu7w9FBW+KXwWVYOxDD+9IFp2RJd9nwnX1AQg4VP2XnTO EWVv8+Emy2j8FWeDpccLuqL/ljScA2PeIU22Hy0CbTWNC6u4cPzUvE2dArh3z6hNMZzu 7yklQZgRUvZscZBZmDn6EoiOPQgpgEGg8cwXVLNhiz5XjqhEFHRpL6oIzXnU6ERLY8/R 1Z21KleoRVQSvBf8ur9BVaHaxrLKUCQBmXYXzWYD344AxjfDfCBeqX47lw/t2jtTFli5 geCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=FkUPTUif; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si1437015edc.388.2021.03.05.05.54.12; Fri, 05 Mar 2021 05:54:36 -0800 (PST) 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=@nifty.com header.s=dec2015msa header.b=FkUPTUif; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230391AbhCENw3 (ORCPT + 99 others); Fri, 5 Mar 2021 08:52:29 -0500 Received: from conssluserg-01.nifty.com ([210.131.2.80]:54337 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbhCENv4 (ORCPT ); Fri, 5 Mar 2021 08:51:56 -0500 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (authenticated) by conssluserg-01.nifty.com with ESMTP id 125Dpbvr002368; Fri, 5 Mar 2021 22:51:37 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com 125Dpbvr002368 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1614952297; bh=lKzscS/Tew+SOZceq8wryzAZUo4F0IRAiu21R0Zw2tk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FkUPTUifK2/enBoJblOoSIiXIuH17lqUr3FZsfwgp9pXAZ2szGrDBReoPS9klJK4W ewnUPTYFYEj/5bdtuebZ2ZG6mNcSL9kF3X4YUmMeL7KuXv6rLQYmraQ6cYZ3Cuye74 H9/KxHtjg3AzQ1Nybh/XM5t2LLnsKcTk9Jc1bOJMJQAiR6skKkZc7XwzpYH0x4Ahil QRNVWDQUA2z9j6YUUy0M3nVuefNskA4WrFkRP47Xit1nUChX0bfVtqHC9OritiCH1/ QxanelQCR/0L7a9YtSXK7EgckmtxLP58GtsQMwg55NdDBjupy4Z4ZUHevYrztqOAaE WCScPq1YRNc4Q== X-Nifty-SrcIP: [209.85.214.176] Received: by mail-pl1-f176.google.com with SMTP id s7so1453426plg.5; Fri, 05 Mar 2021 05:51:37 -0800 (PST) X-Gm-Message-State: AOAM532a6dQ75d+ZQDXC+cqgPNQhIEJKgfhQVPc1u0uhcSp4oOX+SFVR tqiUoNxz3SO29iFeLcF38o38TeuS2MKsS5aO2pc= X-Received: by 2002:a17:90a:3b0e:: with SMTP id d14mr10698552pjc.198.1614952296694; Fri, 05 Mar 2021 05:51:36 -0800 (PST) MIME-Version: 1.0 References: <20210305100212.818562-1-linux@rasmusvillemoes.dk> In-Reply-To: <20210305100212.818562-1-linux@rasmusvillemoes.dk> From: Masahiro Yamada Date: Fri, 5 Mar 2021 22:50:59 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: apply fixdep logic to link-vmlinux.sh To: Rasmus Villemoes Cc: Michal Marek , Linux Kbuild mailing list , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 5, 2021 at 7:02 PM Rasmus Villemoes wrote: > > 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 > --- Another person finally noticed this long-standing bug! Actually, I had known about this bug some years before, and was wondering how to fix this, but your patch is much more elegant than my idea. My original idea was to grep (or sed) CONFIG_ in scripts/link-vmlinux.sh, and surround the output by /* ... */ (or prefix //) into init/dummy.c so that fixdep handles this as a usual C code case. (But, I did not send a patch) But, you are right. There is no reason to restrict fixdep only to C source files. I did not come up with the idea to make fixdep scan this shell script directly. Applied to linux-kbuild. Thanks! > 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 > -- > 2.29.2 > -- Best Regards Masahiro Yamada