Re: [PATCH] kbuild: prevent building single targets twice

From: Nathan Chancellor

Date: Wed Oct 21 2026 - 17:56:05 EST


On Wed, Oct 21, 2026 at 11:25:13PM +0200, Mathias Krause wrote:
> On 21.10.26 21:03, Nathan Chancellor wrote:
> > On Wed, Oct 21, 2026 at 07:04:33PM +0200, Nicolas Schier wrote:
> >> On Wed, Oct 21, 2026 at 08:53:56AM +0200, Mathias Krause wrote:
> >>> Ping! I know, it's the merge window but this patch may have fallen
> >>> through the cracks as there was no response so far. Just trying to take
> >>> care it doesn't get lost.
> >>
> >> thanks for the ping. The patch is in my review queue for the upcoming
> >> cycle.
> >
> > Same, I will try to review it this week or next once I clear my tip of
> > tree clang regressions backlog and Kbuild merge window madness.

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@xxxxxxxxxx/
https://lore.kernel.org/CAK7LNAQhORSPEuB=XFa_i5EcQfsJ6uXy0MM5YWo_84eLGcoxNQ@xxxxxxxxxxxxxx/

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

--
Cheers,
Nathan