From: Janosch Frank <frankja@linux.ibm.com>
To: pbonzini@redhat.com
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com,
borntraeger@de.ibm.com, cohuck@redhat.com,
linux-s390@vger.kernel.org, imbrenda@linux.ibm.com,
thuth@redhat.com
Subject: [kvm-unit-tests GIT PULL 2/8] s390x: snippets: Add snippet compilation
Date: Wed, 7 Jul 2021 16:03:12 +0200 [thread overview]
Message-ID: <20210707140318.44255-3-frankja@linux.ibm.com> (raw)
In-Reply-To: <20210707140318.44255-1-frankja@linux.ibm.com>
From: Steffen Eiden <seiden@linux.ibm.com>
This patch provides the necessary make targets to properly compile
snippets and link them into their associated host.
To define the guest-host definition, we use the make-feature
`SECONDEXPANSION` in combination with `Target specific Variable
Values`. The variable `snippets` has different values depending on the
current target. This enables us to define which snippets (=guests)
belong to which hosts. Furthermore, using the second-expansion, we can
use `snippets` in the perquisites of the host's `%.elf` rule, which
otherwise would be not set.
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Acked-by: Thomas Huth <thuth@redhat.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
---
s390x/Makefile | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/s390x/Makefile b/s390x/Makefile
index 8820e998..ba32f4c2 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -76,11 +76,26 @@ OBJDIRS += lib/s390x
asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o
FLATLIBS = $(libcflat)
-%.elf: %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(asmlib)
- $(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) \
- $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\"
- $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \
- $(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
+
+SNIPPET_DIR = $(TEST_DIR)/snippets
+snippet_asmlib = $(SNIPPET_DIR)/c/cstart.o
+
+# perquisites (=guests) for the snippet hosts.
+# $(TEST_DIR)/<snippet-host>.elf: snippets = $(SNIPPET_DIR)/<c/asm>/<snippet>.gbin
+
+$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o $(FLATLIBS)
+ $(OBJCOPY) -O binary $(patsubst %.gbin,%.o,$@) $@
+ $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $@ $@
+
+$(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_asmlib) $(FLATLIBS)
+ $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds $(patsubst %.gbin,%.o,$@) $(snippet_asmlib) $(FLATLIBS)
+ $(OBJCOPY) -O binary $@ $@
+ $(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $@ $@
+
+.SECONDEXPANSION:
+%.elf: $$(snippets) %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(asmlib)
+ $(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) $(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\"
+ $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds $(filter %.o, $^) $(FLATLIBS) $(snippets) $(@:.elf=.aux.o)
$(RM) $(@:.elf=.aux.o)
@chmod a-x $@
@@ -94,7 +109,7 @@ FLATLIBS = $(libcflat)
$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify --image $< -o $@
arch_clean: asm_offsets_clean
- $(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d lib/s390x/.*.d
+ $(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d $(SNIPPET_DIR)/c/*.{o,gbin} $(SNIPPET_DIR)/c/.*.d lib/s390x/.*.d
generated-files = $(asm-offsets)
$(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files)
--
2.31.1
next prev parent reply other threads:[~2021-07-07 14:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 14:03 [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 1/8] s390x: snippets: Add gitignore as well as linker script and start assembly Janosch Frank
2021-07-07 14:03 ` Janosch Frank [this message]
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 3/8] s390x: mvpg: Add SIE mvpg test Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 4/8] s390x: sie: Add missing includes Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 5/8] s390x: sie: Fix sie.h integer types Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 6/8] lib: s390x: uv: Add offset comments to uv_query and extend it Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 7/8] lib: s390x: Print if a pgm happened while in SIE Janosch Frank
2021-07-07 14:03 ` [kvm-unit-tests GIT PULL 8/8] lib: s390x: Remove left behing PGM report Janosch Frank
2021-07-07 17:33 ` [kvm-unit-tests GIT PULL 0/8] s390x update 2021-07-07 Paolo Bonzini
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=20210707140318.44255-3-frankja@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.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