mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] ACPI: tools: Fix stale headers in incremental builds
@ 2026-10-05 15:37 Fuad Tabba
  2026-10-05 15:37 ` [PATCH 1/2] ACPI: tools: Link include/acpi instead of copying it Fuad Tabba
  2026-10-05 15:37 ` [PATCH 2/2] ACPI: tools: Rebuild objects when a header they include changes Fuad Tabba
  0 siblings, 2 replies; 3+ messages in thread
From: Fuad Tabba @ 2026-10-05 15:37 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Maciej Wieczor-Retman, Pawel Chmielewski, linux-acpi,
	acpica-devel, linux-kernel, Fuad Tabba

Hi folks,

Two fixes for incremental builds of the ACPI tools, which compile
against old headers after a header changes. The first replaces the
copy of include/acpi with a link, so the tools see the current headers.
The second adds dependency files, so objects that include a changed
header are rebuilt.

I found these while fixing the same kind of bug in the KVM selftests'
sysreg header [1].

Based on Linux 7.3-rc5 (72d3fcf802c45).

Cheers,
/fuad

[1] https://lore.kernel.org/all/20260922071945.693714-1-fuad.tabba@linux.dev/

Fuad Tabba (2):
  ACPI: tools: Link include/acpi instead of copying it
  ACPI: tools: Rebuild objects when a header they include changes

 tools/power/acpi/Makefile.rules | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] ACPI: tools: Link include/acpi instead of copying it
  2026-10-05 15:37 [PATCH 0/2] ACPI: tools: Fix stale headers in incremental builds Fuad Tabba
@ 2026-10-05 15:37 ` Fuad Tabba
  2026-10-05 15:37 ` [PATCH 2/2] ACPI: tools: Rebuild objects when a header they include changes Fuad Tabba
  1 sibling, 0 replies; 3+ messages in thread
From: Fuad Tabba @ 2026-10-05 15:37 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Maciej Wieczor-Retman, Pawel Chmielewski, linux-acpi,
	acpica-devel, linux-kernel, Fuad Tabba

An incremental build of the ACPI tools uses an old copy of the
include/acpi headers after they change. The copy under $(OUTPUT)include
is made by a rule for the directory with no prerequisites, so once it
exists it's never refreshed.

Link $(OUTPUT)include/acpi to include/acpi instead, which keeps the rest
of include/ out of the tools' include path as the copy did. The link is
recreated on every build, so it also replaces a copy left by an earlier
one, and the objects take it as an order-only prerequisite so that
recreating it rebuilds nothing. Rebuilding them when a header changes
is the next patch.

Fixes: d5a4b1a540b8 ("tools/power/acpi: Remove direct kernel source include reference")
Assisted-by: LLM
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
 tools/power/acpi/Makefile.rules | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/power/acpi/Makefile.rules b/tools/power/acpi/Makefile.rules
index b71aada776889..48d9280a63f72 100644
--- a/tools/power/acpi/Makefile.rules
+++ b/tools/power/acpi/Makefile.rules
@@ -13,13 +13,12 @@ $(OUTPUT)$(TOOL): $(toolobjs) FORCE
 	$(ECHO) "  STRIP   " $(subst $(OUTPUT),,$@)
 	$(QUIET) $(STRIPCMD) $@
 
-$(KERNEL_INCLUDE):
-	$(ECHO) "  MKDIR   " $(subst $(OUTPUT),,$@)
+$(KERNEL_INCLUDE)/acpi: FORCE
 	$(QUIET) mkdir -p $(KERNEL_INCLUDE)
-	$(ECHO) "  CP      " $(subst $(OUTPUT),,$@)
-	$(QUIET) cp -rf $(srctree)/../../../include/acpi $(KERNEL_INCLUDE)/
+	$(QUIET) rm -rf $@
+	$(QUIET) ln -s $(abspath $(srctree)/../../../include/acpi) $@
 
-$(objdir)%.o: %.c $(KERNEL_INCLUDE)
+$(objdir)%.o: %.c | $(KERNEL_INCLUDE)/acpi
 	$(ECHO) "  CC      " $(subst $(OUTPUT),,$@)
 	$(QUIET) $(MKDIR) -p $(objdir) 2>/dev/null
 	$(QUIET) $(CC) -c $(CFLAGS) -o $@ $<
-- 
2.39.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ACPI: tools: Rebuild objects when a header they include changes
  2026-10-05 15:37 [PATCH 0/2] ACPI: tools: Fix stale headers in incremental builds Fuad Tabba
  2026-10-05 15:37 ` [PATCH 1/2] ACPI: tools: Link include/acpi instead of copying it Fuad Tabba
@ 2026-10-05 15:37 ` Fuad Tabba
  1 sibling, 0 replies; 3+ messages in thread
From: Fuad Tabba @ 2026-10-05 15:37 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, Maciej Wieczor-Retman, Pawel Chmielewski, linux-acpi,
	acpica-devel, linux-kernel, Fuad Tabba

An incremental build of the ACPI tools recompiles an object only when
its .c file changes. The objects have no dependencies on the headers
they include, from include/acpi, drivers/acpi/acpica or the tools
themselves, so a header change leaves them built against the old one.

Generate a dependency file beside each object with -MMD, adding -MP so
that a removed header doesn't break the build, include those files, and
remove them on clean.

Assisted-by: LLM
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
---
 tools/power/acpi/Makefile.rules | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/power/acpi/Makefile.rules b/tools/power/acpi/Makefile.rules
index 48d9280a63f72..b520a966c1c1b 100644
--- a/tools/power/acpi/Makefile.rules
+++ b/tools/power/acpi/Makefile.rules
@@ -21,13 +21,15 @@ $(KERNEL_INCLUDE)/acpi: FORCE
 $(objdir)%.o: %.c | $(KERNEL_INCLUDE)/acpi
 	$(ECHO) "  CC      " $(subst $(OUTPUT),,$@)
 	$(QUIET) $(MKDIR) -p $(objdir) 2>/dev/null
-	$(QUIET) $(CC) -c $(CFLAGS) -o $@ $<
+	$(QUIET) $(CC) -c $(CFLAGS) -MMD -MP -o $@ $<
+
+-include $(toolobjs:.o=.d)
 
 all: $(OUTPUT)$(TOOL)
 clean:
 	$(ECHO) "  RMOBJ   " $(subst $(OUTPUT),,$(objdir))
 	$(QUIET) find $(objdir) \( -not -type d \)\
-		 -and \( -name '*~' -o -name '*.[oas]' \)\
+		 -and \( -name '*~' -o -name '*.[oasd]' \)\
 		 -type f -print | xargs rm -f
 	$(ECHO) "  RM      " $(TOOL)
 	$(QUIET) rm -f $(OUTPUT)$(TOOL)
-- 
2.39.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-05 15:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05 15:37 [PATCH 0/2] ACPI: tools: Fix stale headers in incremental builds Fuad Tabba
2026-10-05 15:37 ` [PATCH 1/2] ACPI: tools: Link include/acpi instead of copying it Fuad Tabba
2026-10-05 15:37 ` [PATCH 2/2] ACPI: tools: Rebuild objects when a header they include changes Fuad Tabba

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®