Message ID | 20230123052653.711899-1-masahiroy@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1440899wrn; Sun, 22 Jan 2023 21:32:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXuW7dgtGsJ0imrHKLOxy+ZrArtN2OECjLrTeKF45AcXI7p913Gx+rw0kf59N9B0WiE1MGJ1 X-Received: by 2002:a05:6402:3214:b0:49d:bc8c:c3eb with SMTP id g20-20020a056402321400b0049dbc8cc3ebmr29068876eda.15.1674451941740; Sun, 22 Jan 2023 21:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674451941; cv=none; d=google.com; s=arc-20160816; b=DCSj90vhyYNatzvOG9I4ZqPqoUBTYrFbqIPZ+mtUfGWOdDosNP6Ewhj2qwRn72gyZl 1Zse3mTaNIzJA0t+XtH4jlIY2jnMrdmNYopGaPcDty0Bt+p6SCBw3cs5BHK8q69UUyWC kEwRHe9JzoPQazZw50TI2hhMMRpPbxFs4Z+Ja3gujBgFOnw7UrB7DCUiHbtQta2k9m/v D1tm57AvuzHgf9O9mbHSU9ZnGbhPDABk6i1jYFe39HEM+nce6ey0UdfHRkIB9b6bwuLq 3ReSooz9+Mt2BYrgbRMKX27DM+IB3x5W+/Ujy38R2ZWKthZu2GTM8XEymldJA7p88/Ge a/fw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8d2giGIBFZDH8bEbM2DU96gGH30dFgDtZgLfpSmbBQQ=; b=0NjvSff0JDSDlP0G6rLZGWO8pohAnOfnvy/3OPcynQ0HDWvO8w/oTZaY7vRWyW2GW+ wPm9NkC1ED+vJKnh3NDdDyHSAcAB7w02lOBzaKopE5a4YQI61g6y6kWi1viSqlnpltav UiktrcS/rZUDxmd2wlHerywduC57Q+yjmATn3uPHN3oNJnNI9aJVZXH70LNVrLm+m+Di 4zqoEc9ocNNiHk8u/8gxd6ipjeC4+jDPrrqNJtCyxV8efjIypjq8R2q+O821gV0cu6Ja DRD6nCe5XPzco4jDnDSHKv/1W9dGDGmLoeVrnOOxEfxeZl7Wq/CAQLOcnYXtD8XhiEqQ FfVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E5TbpuaX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dk26-20020a0564021d9a00b0049e28b4294dsi21131009edb.251.2023.01.22.21.31.57; Sun, 22 Jan 2023 21:32:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E5TbpuaX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230106AbjAWF1L (ORCPT <rfc822;forouhar.linux@gmail.com> + 99 others); Mon, 23 Jan 2023 00:27:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbjAWF1I (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 23 Jan 2023 00:27:08 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0C854C22; Sun, 22 Jan 2023 21:27:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 22145CE09E5; Mon, 23 Jan 2023 05:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C27AC433D2; Mon, 23 Jan 2023 05:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674451624; bh=yynphTf6Y0jKiK1WTidS6B6p4zKQd9mPx6Rft7mEXeQ=; h=From:To:Cc:Subject:Date:From; b=E5TbpuaXhEvg/Z7Z3NqXMjvrIAk3Va3jdsNFySiaLAJzHjSR3wMLVs5tz1lVe/fqe lTt0/u/5J5q7k5xgP6wLt1lEA87iT7RXGnE/RF9l3qqfqvhacd9ZXzGleW+PHdzq6I pctEqflGeJ6vGdH+GakYhIz+gMiJENHG02gJ7/K7azFREgPaXyL1Z6ugWflda+TzVz Ylj63T6j2bov5Nugk7fD+m8uMCotDCtBu9B3ggf3rqb+pLRTd+8pFISFhjPpkEm7DT TTcyeR1sAElDH5ULuQxXgMOcu9r1jTqN/x1PQmylD1hgFOyDDyvZazvCtFiyoxj9Fn 67zctJ4u0RM9g== From: Masahiro Yamada <masahiroy@kernel.org> To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>, William McVicker <willmcvicker@google.com>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu> Subject: [PATCH] kbuild: do not automatically add -w option to modpost Date: Mon, 23 Jan 2023 14:26:53 +0900 Message-Id: <20230123052653.711899-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755790119243816533?= X-GMAIL-MSGID: =?utf-8?q?1755790119243816533?= |
Series |
kbuild: do not automatically add -w option to modpost
|
|
Commit Message
Masahiro Yamada
Jan. 23, 2023, 5:26 a.m. UTC
When there is a missing input file (vmlinux.o or Module.symvers), you
are likely to get a ton of unresolved symbols.
Currently, Kbuild automatically adds the -w option to allow module builds
to continue with warnings instead of errors.
This may not be what the user expects because it is generally more useful
to catch all possible issues at build time instead of at run time.
Let's not do what the user did not ask.
If you still want to build modules anyway, you can proceed by explicitly
setting KBUILD_MODPOST_WARN=1. Since you may miss a real issue, you need
to be aware of what you are doing.
Suggested-by: William McVicker <willmcvicker@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/Makefile.modpost | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
Comments
On 01/23/2023, Masahiro Yamada wrote: > When there is a missing input file (vmlinux.o or Module.symvers), you > are likely to get a ton of unresolved symbols. > > Currently, Kbuild automatically adds the -w option to allow module builds > to continue with warnings instead of errors. > > This may not be what the user expects because it is generally more useful > to catch all possible issues at build time instead of at run time. > > Let's not do what the user did not ask. > > If you still want to build modules anyway, you can proceed by explicitly > setting KBUILD_MODPOST_WARN=1. Since you may miss a real issue, you need > to be aware of what you are doing. > > Suggested-by: William McVicker <willmcvicker@google.com> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > --- > > scripts/Makefile.modpost | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost > index 43343e13c542..9254ed811ddd 100644 > --- a/scripts/Makefile.modpost > +++ b/scripts/Makefile.modpost > @@ -121,16 +121,14 @@ modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) > > endif # ($(KBUILD_EXTMOD),) > > -ifneq ($(missing-input),) > -modpost-args += -w > -endif > - > quiet_cmd_modpost = MODPOST $@ > cmd_modpost = \ > $(if $(missing-input), \ > echo >&2 "WARNING: $(missing-input) is missing."; \ > echo >&2 " Modules may not have dependencies or modversions."; \ > - echo >&2 " You may get many unresolved symbol warnings.";) \ > + echo >&2 " You may get many unresolved symbol errors.";) \ You need to move the closing parenthesis to come at the end of these echo messages. Otherwise you get this new message unconditionally. I also found during testing that the refactoring in commit f73edc8951b2 ("kbuild: unify two modpost invocations") dropped the check for missing KBUILD_EXTRA_SYMBOLS. That means if an external module depends on another external module and sets: KBUILD_EXTRA_SYMBOLS=/path/to/ext_module/Module.symvers ... then make will fail even with KBUILD_MODPOST_WARN=1 since we unconditionally add KBUILD_EXTRA_SYMBOLS to the modpost-args like this: modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) To fix this, I suggest you also take the following patch so that KBUILD_MODPOST_WARN=1 will allow you to skip those unresolved symbols as well: diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 931a3272a4ba..0e2f7fa58056 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -149,14 +149,12 @@ include $(kbuild-file) output-symdump := $(KBUILD_EXTMOD)/Module.symvers -ifeq ($(wildcard Module.symvers),) -missing-input := Module.symvers -else -modpost-args += -i Module.symvers -modpost-deps += Module.symvers -endif +input-symdump := Module.symvers $(KBUILD_EXTRA_SYMBOLS) +existing-input-symdump := $(wildcard $(input-symdump)) +missing-input := $(filter-out $(existing-input-symdump), $(input-symdump)) -modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) +modpost-deps += $(existing-input-symdumps) +modpost-args += -e $(addprefix -i , $(existing-input-symdump)) endif # ($(KBUILD_EXTMOD),) With those changes, the patch works for me as expected. I verified I get a build time error when referencing unresolved symbols without setting KBUILD_MODPOST_WARN=1. And then I verified setting KBUILD_MODPOST_WARN=1 treated those errors as warnings. Thanks, Will > + echo >&2 " You can set KBUILD_MODPOST_WARN=1 to turn errors into warning"; \ > + echo >&2 " if you want to proceed at your own risk."; \ > $(MODPOST) $(modpost-args) > > targets += $(output-symdump) > -- > 2.34.1 >
On Tue, Jan 24, 2023 at 7:42 AM William McVicker <willmcvicker@google.com> wrote: > > On 01/23/2023, Masahiro Yamada wrote: > > When there is a missing input file (vmlinux.o or Module.symvers), you > > are likely to get a ton of unresolved symbols. > > > > Currently, Kbuild automatically adds the -w option to allow module builds > > to continue with warnings instead of errors. > > > > This may not be what the user expects because it is generally more useful > > to catch all possible issues at build time instead of at run time. > > > > Let's not do what the user did not ask. > > > > If you still want to build modules anyway, you can proceed by explicitly > > setting KBUILD_MODPOST_WARN=1. Since you may miss a real issue, you need > > to be aware of what you are doing. > > > > Suggested-by: William McVicker <willmcvicker@google.com> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > --- > > > > scripts/Makefile.modpost | 8 +++----- > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost > > index 43343e13c542..9254ed811ddd 100644 > > --- a/scripts/Makefile.modpost > > +++ b/scripts/Makefile.modpost > > @@ -121,16 +121,14 @@ modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) > > > > endif # ($(KBUILD_EXTMOD),) > > > > -ifneq ($(missing-input),) > > -modpost-args += -w > > -endif > > - > > quiet_cmd_modpost = MODPOST $@ > > cmd_modpost = \ > > $(if $(missing-input), \ > > echo >&2 "WARNING: $(missing-input) is missing."; \ > > echo >&2 " Modules may not have dependencies or modversions."; \ > > - echo >&2 " You may get many unresolved symbol warnings.";) \ > > + echo >&2 " You may get many unresolved symbol errors.";) \ > > You need to move the closing parenthesis to come at the end of these > echo messages. Otherwise you get this new message unconditionally. Ah, thanks for catching it. > I also found during testing that the refactoring in commit f73edc8951b2 > ("kbuild: unify two modpost invocations") dropped the check for missing > KBUILD_EXTRA_SYMBOLS. That means if an external module depends on > another external module and sets: > > KBUILD_EXTRA_SYMBOLS=/path/to/ext_module/Module.symvers > > ... then make will fail even with KBUILD_MODPOST_WARN=1 since we > unconditionally add KBUILD_EXTRA_SYMBOLS to the modpost-args like this: > > modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) > > To fix this, I suggest you also take the following patch so that > KBUILD_MODPOST_WARN=1 will allow you to skip those unresolved symbols as > well: How is this useful? KBUILD_EXTRA_SYMBOLS is explicitly specified by the user via the command line or the environment variable. If $(KBUILD_EXTRA_SYMBOLS) does not exist, it is a user's fault, isn't it?
On 01/24/2023, Masahiro Yamada wrote: > On Tue, Jan 24, 2023 at 7:42 AM William McVicker > <willmcvicker@google.com> wrote: > > > > On 01/23/2023, Masahiro Yamada wrote: > > > When there is a missing input file (vmlinux.o or Module.symvers), you > > > are likely to get a ton of unresolved symbols. > > > > > > Currently, Kbuild automatically adds the -w option to allow module builds > > > to continue with warnings instead of errors. > > > > > > This may not be what the user expects because it is generally more useful > > > to catch all possible issues at build time instead of at run time. > > > > > > Let's not do what the user did not ask. > > > > > > If you still want to build modules anyway, you can proceed by explicitly > > > setting KBUILD_MODPOST_WARN=1. Since you may miss a real issue, you need > > > to be aware of what you are doing. > > > > > > Suggested-by: William McVicker <willmcvicker@google.com> > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > > --- > > > > > > scripts/Makefile.modpost | 8 +++----- > > > 1 file changed, 3 insertions(+), 5 deletions(-) > > > > > > diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost > > > index 43343e13c542..9254ed811ddd 100644 > > > --- a/scripts/Makefile.modpost > > > +++ b/scripts/Makefile.modpost > > > @@ -121,16 +121,14 @@ modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) > > > > > > endif # ($(KBUILD_EXTMOD),) > > > > > > -ifneq ($(missing-input),) > > > -modpost-args += -w > > > -endif > > > - > > > quiet_cmd_modpost = MODPOST $@ > > > cmd_modpost = \ > > > $(if $(missing-input), \ > > > echo >&2 "WARNING: $(missing-input) is missing."; \ > > > echo >&2 " Modules may not have dependencies or modversions."; \ > > > - echo >&2 " You may get many unresolved symbol warnings.";) \ > > > + echo >&2 " You may get many unresolved symbol errors.";) \ > > > > You need to move the closing parenthesis to come at the end of these > > echo messages. Otherwise you get this new message unconditionally. > > > Ah, thanks for catching it. > > > > I also found during testing that the refactoring in commit f73edc8951b2 > > ("kbuild: unify two modpost invocations") dropped the check for missing > > KBUILD_EXTRA_SYMBOLS. That means if an external module depends on > > another external module and sets: > > > > KBUILD_EXTRA_SYMBOLS=/path/to/ext_module/Module.symvers > > > > ... then make will fail even with KBUILD_MODPOST_WARN=1 since we > > unconditionally add KBUILD_EXTRA_SYMBOLS to the modpost-args like this: > > > > modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) > > > > To fix this, I suggest you also take the following patch so that > > KBUILD_MODPOST_WARN=1 will allow you to skip those unresolved symbols as > > well: > > > How is this useful? > > KBUILD_EXTRA_SYMBOLS is explicitly specified by the user > via the command line or the environment variable. > > If $(KBUILD_EXTRA_SYMBOLS) does not exist, > it is a user's fault, isn't it? Sort of, yes. One could argue that it's the same situation as missing the in-tree Module.symvers or the vmlinuux.o/vmlinux.symvers. Basically, if you keep it as is, then KBUILD_MODPOST_WARN=1 would only work if the user edits the Makefile to remove the KBUILD_EXTRA_SYMBOLS line. With my suggested patch, the user could build the module as is without any dependencies by setting KBUILD_MODPOST_WARN=1. I'm fine with whichever way you choose to support since I know this is an external modules edge-case. I personally like to build my modules with all the dependencies present to try an catch any issues at build time. Thanks, Will > > > > > > > -- > Best Regards > Masahiro Yamada
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 43343e13c542..9254ed811ddd 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -121,16 +121,14 @@ modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS)) endif # ($(KBUILD_EXTMOD),) -ifneq ($(missing-input),) -modpost-args += -w -endif - quiet_cmd_modpost = MODPOST $@ cmd_modpost = \ $(if $(missing-input), \ echo >&2 "WARNING: $(missing-input) is missing."; \ echo >&2 " Modules may not have dependencies or modversions."; \ - echo >&2 " You may get many unresolved symbol warnings.";) \ + echo >&2 " You may get many unresolved symbol errors.";) \ + echo >&2 " You can set KBUILD_MODPOST_WARN=1 to turn errors into warning"; \ + echo >&2 " if you want to proceed at your own risk."; \ $(MODPOST) $(modpost-args) targets += $(output-symdump)