From: Mathias Krause <minipli@grsecurity.net>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nsc@kernel.org>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kbuild: prevent building single targets twice
Date: Thu, 22 Oct 2026 12:05:27 +0200 [thread overview]
Message-ID: <e313803a-47ba-4d27-89d9-47dd1abb5183@grsecurity.net> (raw)
In-Reply-To: <20261021215524.GA627677@ax162>
On 21.10.26 23:55, Nathan Chancellor wrote:
> [...]
> I forgot to mention, it looks like this is a known corner case in Kbuild
> that has come up before:
>
> https://lore.kernel.org/7b663b86-4df0-c3df-18a7-e4f47f900be4@kernel.org/
> https://lore.kernel.org/CAK7LNAQhORSPEuB=XFa_i5EcQfsJ6uXy0MM5YWo_84eLGcoxNQ@mail.gmail.com/
Yeah, I saw these too when looking for related issues and fixes.
However, even Masahiro admitted, that this is just working around the
issue instead of solving the more fundamental kbuild bug.
>
> This patch might be the fix that Masahiro could not figure out but it
> might be better to just forsake drivers-y here and use obj-y properly,
> especially since it looks like core-y is not even used for x86 anymore
> (but maybe these objects still need to linked towards the end of the
> kernel?). This diff appears to resolve the reported issue but I did not
> try running the result.
>
> diff --git a/arch/x86/Kbuild b/arch/x86/Kbuild
> index 36b985d0e7bf..bd0621207c0c 100644
> --- a/arch/x86/Kbuild
> +++ b/arch/x86/Kbuild
> @@ -36,5 +36,12 @@ obj-$(CONFIG_KEXEC_FILE) += purgatory/
>
> obj-y += virt/
>
> +obj-$(CONFIG_PCI) += pci/
> +
> +# suspend and hibernation support
> +obj-$(CONFIG_PM) += power/
> +
> +obj-$(CONFIG_VIDEO) += video/
> +
> # for cleaning
> subdir- += boot tools
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index b7e08519b8c1..9a872bd9520e 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -279,14 +279,6 @@ archprepare: $(cpufeaturemasks.hdr)
>
> libs-y += arch/x86/lib/
>
> -# drivers-y are linked after core-y
> -drivers-$(CONFIG_PCI) += arch/x86/pci/
> -
> -# suspend and hibernation support
> -drivers-$(CONFIG_PM) += arch/x86/power/
> -
> -drivers-$(CONFIG_VIDEO) += arch/x86/video/
> -
> ####
> # boot loader support. Several targets are kept for legacy purposes
>
This only "fixes" (read on why in quotes) this one instance but leaves
others unsolved.
Already visible in the diff context is 'libs-y' which has the same issue
and a real behavioral change, depending on which compiler invocation
runs last for arch/x86/lib/delay.o, it'll either be compiled with or
without -pg under KCSAN.
Others are:
- arch/x86/platform/pvh/enlighten.o (via arch/x86/Kbuild),
- drivers/char/ipmi/ipmi_msghandler.o (via drivers/Makefile,
intentionally there for init ordering),
- drivers/input/serio/i8042.o (also via drivers/Makefile)
But what's worse, your change also affects link order which also defines
runtime initialization order. I don't want to crawl into that rabbit
hole and look for all the implicit dependencies that'd be broken by that
change...
One obvious, however, would be pci_subsys_init() which would then run
before acpi_init(), leaving out ACPI-discovered PCI roots from getting
discovered.
So no, I don't like your change and prefer the more fundamental kbuild
fix to get this sorted out once for all.
Thanks,
Mathias
prev parent reply other threads:[~2026-10-22 10:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 12:39 Mathias Krause
2026-10-21 6:53 ` Mathias Krause
2026-10-21 17:04 ` Nicolas Schier
2026-10-21 19:03 ` Nathan Chancellor
2026-10-21 21:25 ` Mathias Krause
2026-10-21 21:55 ` Nathan Chancellor
2026-10-22 10:05 ` Mathias Krause [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=e313803a-47ba-4d27-89d9-47dd1abb5183@grsecurity.net \
--to=minipli@grsecurity.net \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
/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
all inboxes | Powered by JetHome®