From: Johan Hovold <johan@kernel.org>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: "Johan Hovold" <johan@kernel.org>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Michal Marek" <michal.lkml@markovi.net>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jslaby@suse.com>, "Rob Herring" <robh@kernel.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Sascha Hauer" <kernel@pengutronix.de>,
"kbuild test robot" <lkp@intel.com>,
"Linux Kbuild mailing list" <linux-kbuild@vger.kernel.org>
Subject: Re: kbuild obj-m directory descend (was: Re: [PATCH] serdev: fix builds with CONFIG_SERIAL_DEV_BUS=m)
Date: Thu, 19 Dec 2019 10:49:01 +0100 [thread overview]
Message-ID: <20191219094901.GR22665@localhost> (raw)
In-Reply-To: <CAK7LNASHZ9HsYj+sncDqOBWRV+YoFNTciKOxfeYrA7MtBJ9T7A@mail.gmail.com>
On Thu, Dec 19, 2019 at 05:55:54PM +0900, Masahiro Yamada wrote:
> On Thu, Dec 19, 2019 at 5:18 PM Johan Hovold <johan@kernel.org> wrote:
> >
> > On Thu, Dec 19, 2019 at 11:00:15AM +0900, Masahiro Yamada wrote:
> > > Hi.
> > >
> > > On Thu, Dec 19, 2019 at 2:23 AM Johan Hovold <johan@kernel.org> wrote:
> >
> > > > The offending patch is broken since it effectively makes
> > > > CONFIG_SERIAL_DEV_BUS bool (built-in or disabled), but for some reason
> > > > those symbols do not end up in vmlinux (despite being compiled) when you
> > > > add a built-in object goal under a directory that was entered using
> > > > obj-m.
> > > >
> > > > That seems like a bug to me and contradicts the kbuild documentation
> > > > (3.6):
> > > >
> > > > Example:
> > > >
> > > > #fs/Makefile
> > > > obj-$(CONFIG_EXT2_FS) += ext2/
> > > >
> > > > If CONFIG_EXT2_FS is set to either ‘y’ (built-in) or ‘m’
> > > > (modular) the corresponding obj- variable will be set, and
> > > > kbuild will descend down in the ext2 directory. Kbuild only uses
> > > > this information to decide that it needs to visit the directory,
> > > > it is the Makefile in the subdirectory that specifies what is
> > > > modular and what is built-in.
> > > >
> > > > I tried adding other targets to obj-y directly and they are also are not
> > > > included, seemingly since the directory was entered using obj-m.
> > > >
> > > > Masahiro or Michal, can you shed some light?
> >
> > > I saw similar questions in ML in the past.
> > > Yes, this is how Kbuild works;
> > > Kbuild only links objects in Makefiles visited by obj-y.
> > >
> > > If you use
> > > obj-m += serdev/
> > > all objects in serdev/ are considered as modular.
> >
> > Well, any objects in serdev/ specified in obj-y would currently be built
> > but never included in either built-in.a or any module.
>
> Right.
>
> > > I think it is better to make the document
> > > clarify this.
> >
> > Yeah, I don't have a use case for this, but the documentation would need
> > to be updated to not have more people look into this.
> >
> > And at least this behaviour allowed us to catch this bug, but only
> > because we had dependent modules that failed to build. I see now that
> > you posted a patch adding a general warning about obj-y under obj-m last
> > fall, but that was apparently never merged.
>
> This one?
>
> https://lore.kernel.org/patchwork/patch/1126959/
Yep, that's the one I meant.
> This patch detected several Makefile/Kconfig bugs,
> and it is good.
>
> But, it also turned out to cause false positive warnings
> on some architectures.
> I thought it was not so easy to fix it.
> So, I decided to postpone it.
Ok.
> > But when was this behaviour changed? And was that done on purpose?
>
> No. Not changed at all.
>
> In my understanding, the current behavior has been kept
> from the beginning.
Ok, thanks for confirming. The contradicting documentation I refer to
above has been there since before git at least however.
Here's a random example of someone being bit by this five years ago:
https://www.spinics.net/lists/linux-kbuild/msg10887.html
Would you mind taking a stab at updating the docs?
Johan
prev parent reply other threads:[~2019-12-19 9:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <201912181000.82Z7czbN%lkp@intel.com>
2019-12-18 8:38 ` [PATCH] serdev: fix builds with CONFIG_SERIAL_DEV_BUS=m Uwe Kleine-König
2019-12-18 9:06 ` Johan Hovold
2019-12-18 9:29 ` Uwe Kleine-König
2019-12-18 9:38 ` Johan Hovold
2019-12-18 10:39 ` Uwe Kleine-König
2019-12-18 12:51 ` Johan Hovold
2019-12-18 17:23 ` kbuild obj-m directory descend (was: Re: [PATCH] serdev: fix builds with CONFIG_SERIAL_DEV_BUS=m) Johan Hovold
2019-12-19 2:00 ` Masahiro Yamada
2019-12-19 8:18 ` Johan Hovold
2019-12-19 8:55 ` Masahiro Yamada
2019-12-19 9:49 ` Johan Hovold [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191219094901.GR22665@localhost \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=kernel@pengutronix.de \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=masahiroy@kernel.org \
--cc=michal.lkml@markovi.net \
--cc=robh@kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).