Skip to contentSkip to conversation

(arm|powerpc|s390x): Makefile: add `%.aux.o` target

PATCH In review Marc Hartmayer 3 participants 5 messages Jan 25, 2024 – Feb 1, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 (arm|powerpc|s390x): Makefile: add `%.aux.o` target

It's unusual to create multiple files in one target rule, therefore create an extra target for %.aux.o and list it as prerequisite. As a side effect, this change fixes the dependency tracking of the prerequisites of .aux.o (lib/auxinfo.c was missing).

---
 arm/Makefile.common     | 23 ++++++++++++-----------
 powerpc/Makefile.common | 10 +++++-----
 s390x/Makefile          |  9 +++++----
 3 files changed, 22 insertions(+), 20 deletions(-)
arm/Makefile.common +12 -11
index 5214c8acdab3..54cb4a63ab64 100644
@@ -70,14 +70,14 @@ eabiobjs = lib/arm/eabi_compat.o
 FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libeabi)
 
 ifeq ($(CONFIG_EFI),y)
+%.aux.o: $(SRCDIR)/lib/auxinfo.c
+	$(CC) $(CFLAGS) -c -o $@ $^ \
+		-DPROGNAME=\"$(@:.aux.o=.efi)\" -DAUXFLAGS=$(AUXFLAGS)
+
 %.so: EFI_LDFLAGS += -defsym=EFI_SUBSYSTEM=0xa --no-undefined
-%.so: %.o $(FLATLIBS) $(SRCDIR)/arm/efi/elf_aarch64_efi.lds $(cstart.o)
-	$(CC) $(CFLAGS) -c -o $(@:.so=.aux.o) $(SRCDIR)/lib/auxinfo.c \
-		-DPROGNAME=\"$(@:.so=.efi)\" -DAUXFLAGS=$(AUXFLAGS)
+%.so: %.o $(FLATLIBS) $(SRCDIR)/arm/efi/elf_aarch64_efi.lds $(cstart.o) %.aux.o
 	$(LD) $(EFI_LDFLAGS) -o $@ -T $(SRCDIR)/arm/efi/elf_aarch64_efi.lds \
-		$(filter %.o, $^) $(FLATLIBS) $(@:.so=.aux.o) \
-		$(EFI_LIBS)
-	$(RM) $(@:.so=.aux.o)
+		$(filter %.o, $^) $(FLATLIBS) $(EFI_LIBS)
 
 %.efi: %.so
 	$(call arch_elf_check, $^)
@@ -90,13 +90,14 @@ ifeq ($(CONFIG_EFI),y)
 		-j .reloc \
 		-O binary $^ $@
 else
+%.aux.o: $(SRCDIR)/lib/auxinfo.c
+	$(CC) $(CFLAGS) -c -o $@ $^ \
+		-DPROGNAME=\"$(@:.aux.o=.flat)\" -DAUXFLAGS=$(AUXFLAGS)
+
 %.elf: LDFLAGS += $(arch_LDFLAGS)
-%.elf: %.o $(FLATLIBS) $(SRCDIR)/arm/flat.lds $(cstart.o)
-	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c \
-		-DPROGNAME=\"$(@:.elf=.flat)\" -DAUXFLAGS=$(AUXFLAGS)
+%.elf: %.o $(FLATLIBS) $(SRCDIR)/arm/flat.lds $(cstart.o) %.aux.o
 	$(LD) $(LDFLAGS) -o $@ -T $(SRCDIR)/arm/flat.lds \
-		$(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
-	$(RM) $(@:.elf=.aux.o)
+		$(filter %.o, $^) $(FLATLIBS)
 	@chmod a-x $@
 
 %.flat: %.elf
powerpc/Makefile.common +5 -5
index f8f474908b06..483ff64829a7 100644
@@ -47,16 +47,16 @@ cflatobjs += lib/powerpc/smp.o
 
 OBJDIRS += lib/powerpc
 
+%.aux.o: $(SRCDIR)/lib/auxinfo.c
+	$(CC) $(CFLAGS) -c -o $@ $^ -DPROGNAME=\"$(@:.aux.o=.elf)\"
+
 FLATLIBS = $(libcflat) $(LIBFDT_archive)
 %.elf: CFLAGS += $(arch_CFLAGS)
 %.elf: LDFLAGS += $(arch_LDFLAGS) -pie -n
-%.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o)
-	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c \
-		-DPROGNAME=\"$@\"
+%.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o) %.aux.o
 	$(LD) $(LDFLAGS) -o $@ \
 		-T $(SRCDIR)/powerpc/flat.lds --build-id=none \
-		$(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
-	$(RM) $(@:.elf=.aux.o)
+		$(filter %.o, $^) $(FLATLIBS)
 	@chmod a-x $@
 	@echo -n Checking $@ for unsupported reloc types...
 	@if $(OBJDUMP) -R $@ | grep R_ | grep -v R_PPC64_RELATIVE; then	\
s390x/Makefile +5 -4
index f79fd0098312..e64521e002ce 100644
@@ -176,13 +176,14 @@ 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
+	$(CC) $(CFLAGS) -c -o $@ $^ -DPROGNAME=\"$(@:.aux.o=.elf)\"
+
 .SECONDEXPANSION:
-%.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o
-	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\"
+%.elf: $(FLATLIBS) $(asmlib) $(SRCDIR)/s390x/flat.lds $$(snippets-obj) $$(snippet-hdr-obj) %.o %.aux.o
 	@$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \
-		$(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) $(@:.elf=.aux.o) || \
+		$(filter %.o, $^) $(FLATLIBS) $(snippets-obj) $(snippet-hdr-obj) || \
 		{ echo "Failure probably caused by missing definition of gen-se-header executable"; exit 1; }
-	$(RM) $(@:.elf=.aux.o)
 	@chmod a-x $@
 
 # Secure Execution Customer Communication Key file
Signature · 1 line
2.34.1
#1 lore raw
Quoted 7 lines · Marc Hartmayer

It's unusual to create multiple files in one target rule, therefore create an extra target for %.aux.o and list it as prerequisite. As a side effect, this change fixes the dependency tracking of the prerequisites of .aux.o (lib/auxinfo.c was missing).

---

Note: I have only tested it for s390x, so please take a close look!

Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#2 lore raw
In reply to Marc Hartmayer
Quoted 11 lines · Marc Hartmayer

It's unusual to create multiple files in one target rule, therefore create an extra target for %.aux.o and list it as prerequisite. As a side effect, this change fixes the dependency tracking of the prerequisites of .aux.o (lib/auxinfo.c was missing).

---
  arm/Makefile.common     | 23 ++++++++++++-----------
  powerpc/Makefile.common | 10 +++++-----
  s390x/Makefile          |  9 +++++----
  3 files changed, 22 insertions(+), 20 deletions(-)

Patch looks sane to me, so I went ahead and pushed it to the git repo. Thanks!

By the way, unrelated to your modifications, but while testing it, I noticed that "make distclean" leaves some files behind for the s390x build:

./configure --arch=s390x --cross-prefix=s390x-linux-gnu- make -j$(nproc)
make distclean
git status --ignored

On branch master
Your branch is up to date with 'origin/master'.

Ignored files:
(use "git add -f <file>..." to include in what will be committed)

	.mvpg-snippet.d
	.sie-dat.d
	.spec_ex.d
	lib/auxinfo.o
	s390x/snippets/c/.cstart.d
	s390x/snippets/c/.flat.d

... in case someone wants to have a look ...

Thomas

#3 lore raw
Quoted 6 lines · Thomas Huth
Quoted 5 lines · Marc Hartmayer

It's unusual to create multiple files in one target rule, therefore create an extra target for %.aux.o and list it as prerequisite. As a side effect, this change fixes the dependency tracking of the prerequisites of .aux.o (lib/auxinfo.c was missing).

Quoted 8 lines
Quoted 6 lines
---
  arm/Makefile.common     | 23 ++++++++++++-----------
  powerpc/Makefile.common | 10 +++++-----
  s390x/Makefile          |  9 +++++----
  3 files changed, 22 insertions(+), 20 deletions(-)

Patch looks sane to me, so I went ahead and pushed it to the git repo. Thanks!

I'll update the riscv port to make the same changes before merging it.

Thanks,
drew

Quoted 25 lines

By the way, unrelated to your modifications, but while testing it, I noticed that "make distclean" leaves some files behind for the s390x build:

./configure --arch=s390x --cross-prefix=s390x-linux-gnu- make -j$(nproc)
make distclean
git status --ignored

On branch master
Your branch is up to date with 'origin/master'.

Ignored files:
(use "git add -f <file>..." to include in what will be committed)

	.mvpg-snippet.d
	.sie-dat.d
	.spec_ex.d
	lib/auxinfo.o
	s390x/snippets/c/.cstart.d
	s390x/snippets/c/.flat.d

... in case someone wants to have a look ...

Thomas

#4 lore raw
In reply to Thomas Huth
Quoted 13 lines · Thomas Huth
Quoted 11 lines · Marc Hartmayer

It's unusual to create multiple files in one target rule, therefore create an extra target for %.aux.o and list it as prerequisite. As a side effect, this change fixes the dependency tracking of the prerequisites of .aux.o (lib/auxinfo.c was missing).

---
  arm/Makefile.common     | 23 ++++++++++++-----------
  powerpc/Makefile.common | 10 +++++-----
  s390x/Makefile          |  9 +++++----
  3 files changed, 22 insertions(+), 20 deletions(-)
Quoted 2 lines

Patch looks sane to me, so I went ahead and pushed it to the git repo. Thanks!

Thanks.

Quoted 12 lines

By the way, unrelated to your modifications, but while testing it, I noticed that "make distclean" leaves some files behind for the s390x build:

  ./configure --arch=s390x --cross-prefix=s390x-linux-gnu-
  make -j$(nproc)
  make distclean
  git status --ignored

On branch master
Your branch is up to date with 'origin/master'.

Quoted 7 lines

Ignored files:

   (use "git add -f <file>..." to include in what will be committed)
	.mvpg-snippet.d
	.sie-dat.d
	.spec_ex.d

	lib/auxinfo.o

At least, this file is related to this patch. Before it was always deleted, now it’s only removed if the “Makefile semantics” enforce it.

[…snip]

Signature · 8 lines
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294