public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Thomas Huth <thuth@redhat.com>
Cc: Nicholas Piggin <npiggin@gmail.com>,
	Andrew Jones <andrew.jones@linux.dev>,
	"Marc Hartmayer" <mhartmay@linux.ibm.com>,
	kvm@vger.kernel.org
Subject: [RFC kvm-unit-tests PATCH] build: fix .aux.o target building
Date: Wed,  5 Jun 2024 18:16:23 +1000	[thread overview]
Message-ID: <20240605081623.8765-1-npiggin@gmail.com> (raw)

Here's another oddity I ran into with the build system. Try run make
twice. With arm64 and ppc64, the first time it removes some intermediate
files and the second causes another rebuild of several files. After
that it's fine. s390x seems to follow a similar pattern but does not
suffer from the problem. Also, the .PRECIOUS directive is not preventing
them from being deleted inthe first place. So... that probably means I
haven't understood it properly and the fix may not be correct, but it
does appear to DTRT... Anybody with some good Makefile knowledge might
have a better idea.

Thanks,
Nick
---
powerpc and arm64 remove .aux.o files because they are seen as
intermediate, I think because they don't have an explicit target
(for some reason not s390x, haven't tested arm or riscv). This
causes them to be those files to be removed after the make runs.
If make is run again the .aux.o and .elf targets are rebuild,
but for some reason they are treated differently and not removed,
leading to the 3rd make being a no-op.
---
 arm/Makefile.common     | 3 ++-
 powerpc/Makefile.common | 2 +-
 riscv/Makefile          | 2 +-
 s390x/Makefile          | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arm/Makefile.common b/arm/Makefile.common
index f828dbe01..3ebbcc13e 100644
--- a/arm/Makefile.common
+++ b/arm/Makefile.common
@@ -72,7 +72,7 @@ eabiobjs = lib/arm/eabi_compat.o
 FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libeabi)
 
 ifeq ($(CONFIG_EFI),y)
-%.aux.o: $(SRCDIR)/lib/auxinfo.c
+$(tests-all:.$(exe)=.aux.o): $(SRCDIR)/lib/auxinfo.c
 	$(CC) $(CFLAGS) -c -o $@ $< \
 		-DPROGNAME=\"$(@:.aux.o=.efi)\" -DAUXFLAGS=$(AUXFLAGS)
 
@@ -92,6 +92,7 @@ ifeq ($(CONFIG_EFI),y)
 		-j .reloc \
 		-O binary $^ $@
 else
+$(tests-all:.$(exe)=.aux.o): $(SRCDIR)/lib/auxinfo.c
 %.aux.o: $(SRCDIR)/lib/auxinfo.c
 	$(CC) $(CFLAGS) -c -o $@ $< \
 		-DPROGNAME=\"$(@:.aux.o=.flat)\" -DAUXFLAGS=$(AUXFLAGS)
diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
index b98f71c2f..3b219eee0 100644
--- a/powerpc/Makefile.common
+++ b/powerpc/Makefile.common
@@ -52,7 +52,7 @@ cflatobjs += lib/powerpc/smp.o
 
 OBJDIRS += lib/powerpc
 
-%.aux.o: $(SRCDIR)/lib/auxinfo.c
+$(tests-all:.elf=.aux.o): $(SRCDIR)/lib/auxinfo.c
 	$(CC) $(CFLAGS) -c -o $@ $< -DPROGNAME=\"$(@:.aux.o=.elf)\"
 
 FLATLIBS = $(libcflat) $(LIBFDT_archive)
diff --git a/riscv/Makefile b/riscv/Makefile
index 919a3ebb5..4610cb4d4 100644
--- a/riscv/Makefile
+++ b/riscv/Makefile
@@ -81,7 +81,7 @@ CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt
 asm-offsets = lib/riscv/asm-offsets.h
 include $(SRCDIR)/scripts/asm-offsets.mak
 
-%.aux.o: $(SRCDIR)/lib/auxinfo.c
+$(tests:.$(exe)=.aux.o): $(SRCDIR)/lib/auxinfo.c
 	$(CC) $(CFLAGS) -c -o $@ $< \
 		-DPROGNAME=\"$(notdir $(@:.aux.o=.$(exe)))\" -DAUXFLAGS=$(AUXFLAGS)
 
diff --git a/s390x/Makefile b/s390x/Makefile
index 23342bd64..4c0c8085c 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -178,7 +178,7 @@ lds-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -MT $@
 %.lds: %.lds.S $(asm-offsets)
 	$(CPP) $(lds-autodepend-flags) $(CPPFLAGS) -P -C -o $@ $<
 
-%.aux.o: $(SRCDIR)/lib/auxinfo.c
+$(tests:.elf=.aux.o): $(SRCDIR)/lib/auxinfo.c
 	$(CC) $(CFLAGS) -c -o $@ $< -DPROGNAME=\"$(@:.aux.o=.elf)\"
 
 .SECONDEXPANSION:
-- 
2.43.0


             reply	other threads:[~2024-06-05  8:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  8:16 Nicholas Piggin [this message]
2024-06-05 10:42 ` [RFC kvm-unit-tests PATCH] build: fix .aux.o target building Marc Hartmayer
2024-06-05 10:49   ` Andrew Jones
2024-06-05 10:53   ` Nicholas Piggin
2024-06-05 15:07     ` Marc Hartmayer
2024-06-06  3:49       ` Nicholas Piggin
2024-06-06  7:58         ` Marc Hartmayer

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=20240605081623.8765-1-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=andrew.jones@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=mhartmay@linux.ibm.com \
    --cc=thuth@redhat.com \
    /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