All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
@ 2019-07-30 12:37 Paolo Bonzini
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 1/3] tests/tcg: use EXTRA_CFLAGS everywhere Paolo Bonzini
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Paolo Bonzini @ 2019-07-30 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.bennee

The tests/tcg rely a lot on per-target informations from
the QEMU makefiles, but most of the definitions in there
aren't really relevant to TCG tests.

This series is just a cleanup, but it could also be
a useful start in making it possible to compile tests/tcg
out of QEMU's tree, and/or making it a submodule, and/or
unifying the system emulation tests with kvm-unit-tests.

Paolo

Paolo Bonzini (3):
  tests/tcg: use EXTRA_CFLAGS everywhere
  tests/tcg: cleanup Makefile inclusions
  tests/tcg: move configuration to a sub-shell script

 Makefile                                  |   1 +
 Makefile.target                           |   3 -
 configure                                 | 155 ++------------------
 tests/Makefile.include                    |  25 ++--
 tests/tcg/Makefile.include                |  88 ------------
 tests/tcg/Makefile.prereqs                |  18 +++
 tests/tcg/Makefile.probe                  |  31 ----
 tests/tcg/Makefile.qemu                   |  95 +++++++++++++
 tests/tcg/{Makefile => Makefile.target}   |  15 +-
 tests/tcg/aarch64/Makefile.include        |   8 --
 tests/tcg/aarch64/Makefile.softmmu-target |   4 +-
 tests/tcg/aarch64/Makefile.target         |  12 +-
 tests/tcg/alpha/Makefile.include          |   2 -
 tests/tcg/alpha/Makefile.softmmu-target   |   4 +-
 tests/tcg/arm/Makefile.include            |   8 --
 tests/tcg/arm/Makefile.softmmu-target     |   6 +-
 tests/tcg/configure.sh                    | 228 ++++++++++++++++++++++++++++++
 tests/tcg/cris/Makefile.include           |   6 -
 tests/tcg/hppa/Makefile.include           |   2 -
 tests/tcg/i386/Makefile.include           |   9 --
 tests/tcg/i386/Makefile.softmmu-target    |  12 +-
 tests/tcg/i386/Makefile.target            |  13 +-
 tests/tcg/m68k/Makefile.include           |   2 -
 tests/tcg/minilib/Makefile.target         |   2 +-
 tests/tcg/mips/Makefile.include           |  20 ---
 tests/tcg/ppc/Makefile.include            |  10 --
 tests/tcg/riscv/Makefile.include          |  10 --
 tests/tcg/s390x/Makefile.include          |   2 -
 tests/tcg/sh4/Makefile.include            |   4 -
 tests/tcg/sparc64/Makefile.include        |   2 -
 tests/tcg/x86_64/Makefile.softmmu-target  |  36 +++++
 tests/tcg/x86_64/Makefile.target          |   7 +-
 tests/tcg/xtensa/Makefile.include         |  11 --
 tests/tcg/xtensa/Makefile.softmmu-target  |   4 +-
 34 files changed, 435 insertions(+), 420 deletions(-)
 delete mode 100644 tests/tcg/Makefile.include
 create mode 100644 tests/tcg/Makefile.prereqs
 delete mode 100644 tests/tcg/Makefile.probe
 create mode 100644 tests/tcg/Makefile.qemu
 rename tests/tcg/{Makefile => Makefile.target} (90%)
 delete mode 100644 tests/tcg/aarch64/Makefile.include
 delete mode 100644 tests/tcg/alpha/Makefile.include
 delete mode 100644 tests/tcg/arm/Makefile.include
 create mode 100644 tests/tcg/configure.sh
 delete mode 100644 tests/tcg/cris/Makefile.include
 delete mode 100644 tests/tcg/hppa/Makefile.include
 delete mode 100644 tests/tcg/i386/Makefile.include
 delete mode 100644 tests/tcg/m68k/Makefile.include
 delete mode 100644 tests/tcg/mips/Makefile.include
 delete mode 100644 tests/tcg/ppc/Makefile.include
 delete mode 100644 tests/tcg/riscv/Makefile.include
 delete mode 100644 tests/tcg/s390x/Makefile.include
 delete mode 100644 tests/tcg/sh4/Makefile.include
 delete mode 100644 tests/tcg/sparc64/Makefile.include
 create mode 100644 tests/tcg/x86_64/Makefile.softmmu-target
 delete mode 100644 tests/tcg/xtensa/Makefile.include

-- 
1.8.3.1



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

* [Qemu-devel] [PATCH 1/3] tests/tcg: use EXTRA_CFLAGS everywhere
  2019-07-30 12:37 [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles Paolo Bonzini
@ 2019-07-30 12:37 ` Paolo Bonzini
  2019-08-07 12:51   ` Alex Bennée
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions Paolo Bonzini
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Paolo Bonzini @ 2019-07-30 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.bennee

For i386 specifically, this allows using the host GCC
to compile the i386 tests.  But, it should really be
done for all targets, unless we want to pass $(EXTRA_CFLAGS)
directly as part of $(CC).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/tcg/aarch64/Makefile.softmmu-target | 4 ++--
 tests/tcg/alpha/Makefile.softmmu-target   | 4 ++--
 tests/tcg/arm/Makefile.softmmu-target     | 2 +-
 tests/tcg/i386/Makefile.softmmu-target    | 4 ++--
 tests/tcg/minilib/Makefile.target         | 2 +-
 tests/tcg/xtensa/Makefile.softmmu-target  | 4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/Makefile.softmmu-target
index 2e560e4..4c4aaf6 100644
--- a/tests/tcg/aarch64/Makefile.softmmu-target
+++ b/tests/tcg/aarch64/Makefile.softmmu-target
@@ -22,11 +22,11 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
 .PRECIOUS: $(CRT_OBJS)
 
 %.o: $(CRT_PATH)/%.S
-	$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -c $< -o $@
 
 # Build and link the tests
 %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
 
 memory: CFLAGS+=-DCHECK_UNALIGNED=1
 
diff --git a/tests/tcg/alpha/Makefile.softmmu-target b/tests/tcg/alpha/Makefile.softmmu-target
index 3c0f34c..09193a6 100644
--- a/tests/tcg/alpha/Makefile.softmmu-target
+++ b/tests/tcg/alpha/Makefile.softmmu-target
@@ -22,11 +22,11 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
 .PRECIOUS: $(CRT_OBJS)
 
 %.o: $(CRT_PATH)/%.S
-	$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -c $< -o $@
 
 # Build and link the tests
 %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
 
 memory: CFLAGS+=-DCHECK_UNALIGNED=0
 
diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile.softmmu-target
index 49d48d8..2deb06e 100644
--- a/tests/tcg/arm/Makefile.softmmu-target
+++ b/tests/tcg/arm/Makefile.softmmu-target
@@ -18,7 +18,7 @@ CFLAGS+=-Wl,--build-id=none -x assembler-with-cpp
 LDFLAGS+=-nostdlib -N -static
 
 %: %.S %.ld
-	$(CC) $(CFLAGS) $(ASFLAGS) $< -o $@ $(LDFLAGS) -T $(ARM_SRC)/$@.ld
+	$(CC) $(CFLAGS) $(ASFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) -T $(ARM_SRC)/$@.ld
 
 # Specific Test Rules
 
diff --git a/tests/tcg/i386/Makefile.softmmu-target b/tests/tcg/i386/Makefile.softmmu-target
index 0a43648..cee3420 100644
--- a/tests/tcg/i386/Makefile.softmmu-target
+++ b/tests/tcg/i386/Makefile.softmmu-target
@@ -32,11 +32,11 @@ TESTS+=$(MULTIARCH_TESTS)
 .PRECIOUS: $(CRT_OBJS)
 
 %.o: $(CRT_PATH)/%.S
-	$(CC) $(CFLAGS) -c $< -o $@
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
 
 # Build and link the tests
 %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
-	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
 
 memory: CFLAGS+=-DCHECK_UNALIGNED=1
 
diff --git a/tests/tcg/minilib/Makefile.target b/tests/tcg/minilib/Makefile.target
index 3ed8077..c821d28 100644
--- a/tests/tcg/minilib/Makefile.target
+++ b/tests/tcg/minilib/Makefile.target
@@ -18,4 +18,4 @@ MINILIB_INC=-isystem $(SYSTEM_MINILIB_SRC)
 .PRECIOUS: $(MINILIB_OBJS)
 
 %.o: $(SYSTEM_MINILIB_SRC)/%.c
-	$(CC) $(CFLAGS) -c $< -o $@
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
diff --git a/tests/tcg/xtensa/Makefile.softmmu-target b/tests/tcg/xtensa/Makefile.softmmu-target
index 8212d96..9530cac 100644
--- a/tests/tcg/xtensa/Makefile.softmmu-target
+++ b/tests/tcg/xtensa/Makefile.softmmu-target
@@ -34,9 +34,9 @@ $(XTENSA_USABLE_TESTS): linker.ld macros.inc $(CRT) Makefile.softmmu-target
 
 # special rule for common blobs
 %.o: %.S
-	$(CC) $(XTENSA_INC) $($*_ASFLAGS) $(ASFLAGS) -c $< -o $@
+	$(CC) $(XTENSA_INC) $($*_ASFLAGS) $(ASFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
 
 %: %.S
-	$(CC) $(XTENSA_INC) $(ASFLAGS) $< -o $@ $(LDFLAGS) $(NOSTDFLAGS) $(CRT)
+	$(CC) $(XTENSA_INC) $(ASFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) $(NOSTDFLAGS) $(CRT)
 
 endif
-- 
1.8.3.1




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

* [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions
  2019-07-30 12:37 [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles Paolo Bonzini
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 1/3] tests/tcg: use EXTRA_CFLAGS everywhere Paolo Bonzini
@ 2019-07-30 12:37 ` Paolo Bonzini
  2019-07-30 12:44   ` Philippe Mathieu-Daudé
  2019-08-07 13:05   ` Alex Bennée
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script Paolo Bonzini
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 20+ messages in thread
From: Paolo Bonzini @ 2019-07-30 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.bennee

Rename Makefile.probe to Makefile.prereqs and make it actually
define rules for the tests.

Rename Makefile to Makefile.target, since it is not a toplevel
makefile.

Rename Makefile.include to Makefile.qemu and disentangle it
from the QEMU Makefile.target, so that it is invoked recursively
by tests/Makefile.include.  Tests are now placed in
tests/tcg/$(TARGET).

Drop the usage of TARGET_BASE_ARCH, which is ignored by everything except
x86_64 and aarch64.  Fix x86 tests by using -cpu max and, while
at it, standardize on QEMU_OPTS for aarch64 tests too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 Makefile.target                                |  3 --
 tests/Makefile.include                         | 23 +++++++-----
 tests/tcg/{Makefile.probe => Makefile.prereqs} |  5 ++-
 tests/tcg/{Makefile.include => Makefile.qemu}  | 48 +++++++++++++++-----------
 tests/tcg/{Makefile => Makefile.target}        | 13 +++----
 tests/tcg/aarch64/Makefile.target              | 12 ++++---
 tests/tcg/arm/Makefile.softmmu-target          |  4 ---
 tests/tcg/i386/Makefile.softmmu-target         |  8 -----
 tests/tcg/i386/Makefile.target                 | 13 +++----
 tests/tcg/x86_64/Makefile.softmmu-target       | 36 +++++++++++++++++++
 tests/tcg/x86_64/Makefile.target               |  7 ++--
 11 files changed, 100 insertions(+), 72 deletions(-)
 rename tests/tcg/{Makefile.probe => Makefile.prereqs} (92%)
 rename tests/tcg/{Makefile.include => Makefile.qemu} (52%)
 rename tests/tcg/{Makefile => Makefile.target} (92%)
 create mode 100644 tests/tcg/x86_64/Makefile.softmmu-target

diff --git a/Makefile.target b/Makefile.target
index 933b274..5e91623 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -39,9 +39,6 @@ endif
 PROGS=$(QEMU_PROG) $(QEMU_PROGW)
 STPFILES=
 
-# Makefile Tests
-include $(SRC_PATH)/tests/tcg/Makefile.include
-
 config-target.h: config-target.h-timestamp
 config-target.h-timestamp: config-target.mak
 
diff --git a/tests/Makefile.include b/tests/Makefile.include
index fd7fdb8..8bb5c97 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1061,23 +1061,28 @@ RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
 ifeq ($(HAVE_USER_DOCKER),y)
 # Probe for the Docker Builds needed for each build
 $(foreach PROBE_TARGET,$(TARGET_DIRS), 				\
-	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.probe) 	\
-	$(if $(DOCKER_PREREQ), 					\
-		$(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ))))
+	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
 endif
 
 build-tcg-tests-%:
-	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
-		SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" guest-tests, \
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
+		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
+		SRC_PATH=$(SRC_PATH) \
+	       	V="$(V)" TARGET_DIR="$*/" guest-tests, \
 		"BUILD", "TCG tests for $*")
 
-run-tcg-tests-%: % build-tcg-tests-%
-	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
-		SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" run-guest-tests, \
+run-tcg-tests-%: build-tcg-tests-% %/all
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
+		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
+		SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
+		V="$(V)" TARGET_DIR="$*/" run-guest-tests, \
 		"RUN", "TCG tests for $*")
 
 clean-tcg-tests-%:
-	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,)
+	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
+		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
+		SRC_PATH=$(SRC_PATH) TARGET_DIR="$*/" clean-guest-tests, \
+		"RUN", "TCG tests for $*")
 
 .PHONY: build-tcg
 build-tcg: $(BUILD_TCG_TARGET_RULES)
diff --git a/tests/tcg/Makefile.probe b/tests/tcg/Makefile.prereqs
similarity index 92%
rename from tests/tcg/Makefile.probe
rename to tests/tcg/Makefile.prereqs
index 9dc6546..53b0196 100644
--- a/tests/tcg/Makefile.probe
+++ b/tests/tcg/Makefile.prereqs
@@ -8,20 +8,19 @@
 # each target.
 
 # First we need the target makefile which tells us the target architecture
+CROSS_CC_GUEST:=
 -include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
 
 # Then we load up the target architecture makefiles which tell us
 # about the compilers
-CROSS_CC_GUEST:=
 DOCKER_IMAGE:=
-DOCKER_PREREQ:=
 
 -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
 
 ifndef CROSS_CC_GUEST
 ifneq ($(DOCKER_IMAGE),)
-DOCKER_PREREQ:=docker-image-$(DOCKER_IMAGE)
+build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE)
 endif
 endif
 
diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.qemu
similarity index 52%
rename from tests/tcg/Makefile.include
rename to tests/tcg/Makefile.qemu
index 73b5626..d3f3437 100644
--- a/tests/tcg/Makefile.include
+++ b/tests/tcg/Makefile.qemu
@@ -2,20 +2,23 @@
 #
 # TCG tests (per-target rules)
 #
-# This Makefile fragment is included from the per-target
-# Makefile.target so will be invoked for each linux-user program we
-# build. We have two options for compiling, either using a configured
-# guest compiler or calling one of our docker images to do it for us.
+# This Makefile fragment is included from the build-tcg target, once
+# for each target we build. We have two options for compiling, either
+# using a configured guest compiler or calling one of our docker images
+# to do it for us.
 #
 
 # The per ARCH makefile, if it exists, holds extra information about
 # useful docker images or alternative compiler flags.
 
--include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
--include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
+include $(TARGET_DIR)config-target.mak
+include $(SRC_PATH)/rules.mak
+include $(wildcard \
+	$(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
+	$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
 
 GUEST_BUILD=
-TCG_MAKE=$(SRC_PATH)/tests/tcg/Makefile
+TCG_MAKE=../Makefile.target
 # Support installed Cross Compilers
 
 ifdef CROSS_CC_GUEST
@@ -23,9 +26,9 @@ ifdef CROSS_CC_GUEST
 .PHONY: cross-build-guest-tests
 cross-build-guest-tests:
 	$(call quiet-command, \
-	   (mkdir -p tests && cd tests && \
-	    $(MAKE) -f $(TCG_MAKE) CC=$(CROSS_CC_GUEST) \
-			BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
+	   (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
+	    $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \
+			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
 			EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \
 	"BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
 
@@ -39,20 +42,20 @@ ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
 ifneq ($(DOCKER_IMAGE),)
 
 # We also need the Docker make rules to depend on
+SKIP_DOCKER_BUILD=1
 include $(SRC_PATH)/tests/docker/Makefile.include
 
 DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
 		--cc $(DOCKER_CROSS_COMPILER) \
 		-i qemu:$(DOCKER_IMAGE) \
 		-s $(SRC_PATH) -- "
-DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
 
 .PHONY: docker-build-guest-tests
-docker-build-guest-tests: $(DOCKER_PREREQ)
+docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
 	$(call quiet-command, \
-	  (mkdir -p tests && cd tests && \
-	   $(MAKE) -f $(TCG_MAKE) CC=$(DOCKER_COMPILE_CMD) \
-			BUILD_STATIC=y \
+	  (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
+	   $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC=$(DOCKER_COMPILE_CMD) \
+			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
 			EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \
 	"BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
 
@@ -62,27 +65,32 @@ endif
 endif
 
 # Final targets
+all:
+	@echo "Do not invoke this Makefile directly"; exit 1
+
 .PHONY: guest-tests
 
 ifneq ($(GUEST_BUILD),)
 guest-tests: $(GUEST_BUILD)
 
-run-guest-tests: guest-tests qemu-$(subst y,system-,$(CONFIG_SOFTMMU))$(TARGET_NAME)
+run-guest-tests: guest-tests
 	$(call quiet-command, \
-	(cd tests && $(MAKE) -f $(TCG_MAKE) SPEED=$(SPEED) run), \
+	(cd tests/tcg/$(TARGET_DIR) && \
+	 $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" \
+	 		SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
 	"RUN", "tests for $(TARGET_NAME)")
 
 else
 guest-tests:
 	$(call quiet-command, /bin/true, "BUILD", \
-		"$(TARGET_NAME) guest-tests SKIPPED")
+		"$(TARGET_DIR) guest-tests SKIPPED")
 
 run-guest-tests:
 	$(call quiet-command, /bin/true, "RUN", \
-		"tests for $(TARGET_NAME) SKIPPED")
+		"tests for $(TARGET_DIR) SKIPPED")
 endif
 
 # It doesn't matter if these don't exits
 .PHONY: clean-guest-tests
 clean-guest-tests:
-	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
+	rm -rf tests/tcg/$(TARGET_DIR)
diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile.target
similarity index 92%
rename from tests/tcg/Makefile
rename to tests/tcg/Makefile.target
index 9f56768..8dbcba4 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile.target
@@ -29,8 +29,9 @@
 # We also expect to be in the tests build dir for the FOO-(linux-user|softmmu).
 #
 
+all:
 -include ../../config-host.mak
--include ../config-target.mak
+-include ../../../$(TARGET_DIR)/config-target.mak
 
 # for including , in command strings
 COMMA := ,
@@ -64,9 +65,9 @@ LDFLAGS=
 
 # The QEMU for this TARGET
 ifdef CONFIG_USER_ONLY
-QEMU=../qemu-$(TARGET_NAME)
+QEMU=../../../$(TARGET_DIR)/qemu-$(TARGET_NAME)
 else
-QEMU=../qemu-system-$(TARGET_NAME)
+QEMU=../../../$(TARGET_DIR)/qemu-system-$(TARGET_NAME)
 endif
 QEMU_OPTS=
 
@@ -82,10 +83,7 @@ ifdef CONFIG_USER_ONLY
 # The order we include is important. We include multiarch, base arch
 # and finally arch if it's not the same as base arch.
 -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
--include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target
-ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
-endif
 
 # Add the common build options
 CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
@@ -101,10 +99,7 @@ else
 # are expected to provide their own build recipes.
 -include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
 -include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
--include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.softmmu-target
-ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
-endif
 
 endif
 
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 31ba9cf..e763dd9 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -2,12 +2,14 @@
 #
 # AArch64 specific tweaks
 
+ARM_SRC=$(SRC_PATH)/tests/tcg/arm
+VPATH 		+= $(ARM_SRC)
+
 AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
 VPATH 		+= $(AARCH64_SRC)
 
-# we don't build any of the ARM tests
-AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS))
-AARCH64_TESTS+=fcvt
+# we don't build any other ARM test
+AARCH64_TESTS=fcvt
 
 fcvt: LDFLAGS+=-lm
 
@@ -16,6 +18,6 @@ run-fcvt: fcvt
 	$(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref)
 
 AARCH64_TESTS += pauth-1 pauth-2
-run-pauth-%: QEMU += -cpu max
+run-pauth-%: QEMU_OPTS += -cpu max
 
-TESTS:=$(AARCH64_TESTS)
+TESTS += $(AARCH64_TESTS)
diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile.softmmu-target
index 2deb06e..231e9a5 100644
--- a/tests/tcg/arm/Makefile.softmmu-target
+++ b/tests/tcg/arm/Makefile.softmmu-target
@@ -3,8 +3,6 @@
 # ARM SoftMMU tests - included from tests/tcg/Makefile
 #
 
-ifeq ($(TARGET_ABI_DIR),arm)
-
 ARM_SRC=$(SRC_PATH)/tests/tcg/arm
 
 # Set search path for all sources
@@ -25,5 +23,3 @@ LDFLAGS+=-nostdlib -N -static
 test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0
 
 run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel
-
-endif
diff --git a/tests/tcg/i386/Makefile.softmmu-target b/tests/tcg/i386/Makefile.softmmu-target
index cee3420..1c8790e 100644
--- a/tests/tcg/i386/Makefile.softmmu-target
+++ b/tests/tcg/i386/Makefile.softmmu-target
@@ -12,17 +12,9 @@ X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
 # These objects provide the basic boot code and helper functions for all tests
 CRT_OBJS=boot.o
 
-ifeq ($(TARGET_X86_64), y)
-CRT_PATH=$(X64_SYSTEM_SRC)
-CFLAGS=-march=x86-64
-LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
-LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
-else
 CRT_PATH=$(I386_SYSTEM_SRC)
-CFLAGS+=-m32
 LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld
 LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386
-endif
 CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
 LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
 
diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index d0eb702..08c5736 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -6,14 +6,11 @@ I386_SRC=$(SRC_PATH)/tests/tcg/i386
 VPATH 		+= $(I386_SRC)
 
 I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c))
-I386_TESTS=$(I386_SRCS:.c=)
-I386_ONLY_TESTS=$(filter-out test-i386-ssse3, $(I386_TESTS))
+ALL_X86_TESTS=$(I386_SRCS:.c=)
+I386_TESTS:=$(filter-out test-i386-ssse3, $(ALL_X86_TESTS))
+X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS))
 # Update TESTS
-TESTS+=$(I386_ONLY_TESTS)
-
-ifneq ($(TARGET_NAME),x86_64)
-CFLAGS+=-m32
-endif
+TESTS=$(MULTIARCH_TESTS) $(I386_TESTS)
 
 #
 # hello-i386 is a barebones app
@@ -26,7 +23,7 @@ hello-i386: LDFLAGS+=-nostdlib
 #
 
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
+	$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ \
 	   $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 ifeq ($(SPEED), slow)
diff --git a/tests/tcg/x86_64/Makefile.softmmu-target b/tests/tcg/x86_64/Makefile.softmmu-target
new file mode 100644
index 0000000..df252e7
--- /dev/null
+++ b/tests/tcg/x86_64/Makefile.softmmu-target
@@ -0,0 +1,36 @@
+#
+# x86 system tests
+#
+# This currently builds only for i386. The common C code is built
+# with standard compiler flags however so we can support both by
+# adding additional boot files for x86_64.
+#
+
+I386_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/i386/system
+X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
+
+# These objects provide the basic boot code and helper functions for all tests
+CRT_OBJS=boot.o
+
+CRT_PATH=$(X64_SYSTEM_SRC)
+LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
+LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
+CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
+LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
+
+TESTS+=$(MULTIARCH_TESTS)
+
+# building head blobs
+.PRECIOUS: $(CRT_OBJS)
+
+%.o: $(CRT_PATH)/%.S
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
+
+# Build and link the tests
+%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
+
+memory: CFLAGS+=-DCHECK_UNALIGNED=1
+
+# Running
+QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel
diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target
index 74f170b..20bf962 100644
--- a/tests/tcg/x86_64/Makefile.target
+++ b/tests/tcg/x86_64/Makefile.target
@@ -6,9 +6,10 @@
 # $(SRC)/tests/tcg/i386/
 #
 
-X86_64_TESTS=$(filter-out $(I386_ONLY_TESTS), $(TESTS))
-X86_64_TESTS+=test-x86_64
-TESTS:=$(X86_64_TESTS)
+include $(SRC_PATH)/tests/tcg/i386/Makefile.target
+
+TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
+QEMU_OPTS += -cpu max
 
 test-x86_64: LDFLAGS+=-lm -lc
 test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h
-- 
1.8.3.1




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

* [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script
  2019-07-30 12:37 [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles Paolo Bonzini
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 1/3] tests/tcg: use EXTRA_CFLAGS everywhere Paolo Bonzini
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions Paolo Bonzini
@ 2019-07-30 12:37 ` Paolo Bonzini
  2019-08-07 12:42   ` Alex Bennée
  2019-08-07 13:10   ` Alex Bennée
  2019-07-30 12:53 ` [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles no-reply
  2019-08-07 12:40 ` Alex Bennée
  4 siblings, 2 replies; 20+ messages in thread
From: Paolo Bonzini @ 2019-07-30 12:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: alex.bennee

Avoid the repeated inclusions of config-target.mak, which have
risks of namespace pollution, and instead build minimal configuration
files in a configuration script.  The same configuration files can
also be included in Makefile and Makefile.qemu

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 Makefile                           |   1 +
 configure                          | 155 +++----------------------
 tests/Makefile.include             |   8 +-
 tests/tcg/Makefile.prereqs         |  18 +--
 tests/tcg/Makefile.qemu            |  51 ++++-----
 tests/tcg/Makefile.target          |   8 +-
 tests/tcg/aarch64/Makefile.include |   8 --
 tests/tcg/alpha/Makefile.include   |   2 -
 tests/tcg/arm/Makefile.include     |   8 --
 tests/tcg/configure.sh             | 228 +++++++++++++++++++++++++++++++++++++
 tests/tcg/cris/Makefile.include    |   6 -
 tests/tcg/hppa/Makefile.include    |   2 -
 tests/tcg/i386/Makefile.include    |   9 --
 tests/tcg/m68k/Makefile.include    |   2 -
 tests/tcg/mips/Makefile.include    |  20 ----
 tests/tcg/ppc/Makefile.include     |  10 --
 tests/tcg/riscv/Makefile.include   |  10 --
 tests/tcg/s390x/Makefile.include   |   2 -
 tests/tcg/sh4/Makefile.include     |   4 -
 tests/tcg/sparc64/Makefile.include |   2 -
 tests/tcg/xtensa/Makefile.include  |  11 --
 21 files changed, 276 insertions(+), 289 deletions(-)
 delete mode 100644 tests/tcg/aarch64/Makefile.include
 delete mode 100644 tests/tcg/alpha/Makefile.include
 delete mode 100644 tests/tcg/arm/Makefile.include
 create mode 100644 tests/tcg/configure.sh
 delete mode 100644 tests/tcg/cris/Makefile.include
 delete mode 100644 tests/tcg/hppa/Makefile.include
 delete mode 100644 tests/tcg/i386/Makefile.include
 delete mode 100644 tests/tcg/m68k/Makefile.include
 delete mode 100644 tests/tcg/mips/Makefile.include
 delete mode 100644 tests/tcg/ppc/Makefile.include
 delete mode 100644 tests/tcg/riscv/Makefile.include
 delete mode 100644 tests/tcg/s390x/Makefile.include
 delete mode 100644 tests/tcg/sh4/Makefile.include
 delete mode 100644 tests/tcg/sparc64/Makefile.include
 delete mode 100644 tests/tcg/xtensa/Makefile.include

diff --git a/Makefile b/Makefile
index ecb788b..e76288a 100644
--- a/Makefile
+++ b/Makefile
@@ -718,6 +718,7 @@ endef
 
 distclean: clean
 	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
+	rm -f tests/tcg/config-*.mak
 	rm -f config-all-devices.mak config-all-disas.mak config.status
 	rm -f $(SUBDIR_DEVICES_MAK)
 	rm -f po/*.mo tests/qemu-iotests/common.env
diff --git a/configure b/configure
index 714e7fb..b0bd308 100755
--- a/configure
+++ b/configure
@@ -500,22 +500,6 @@ debug_mutex="no"
 libpmem=""
 default_devices="yes"
 
-# cross compilers defaults, can be overridden with --cross-cc-ARCH
-cross_cc_aarch64="aarch64-linux-gnu-gcc"
-cross_cc_aarch64_be="$cross_cc_aarch64"
-cross_cc_cflags_aarch64_be="-mbig-endian"
-cross_cc_arm="arm-linux-gnueabihf-gcc"
-cross_cc_cflags_armeb="-mbig-endian"
-cross_cc_i386="i386-pc-linux-gnu-gcc"
-cross_cc_cflags_i386=""
-cross_cc_ppc="powerpc-linux-gnu-gcc"
-cross_cc_cflags_ppc="-m32"
-cross_cc_ppc64="powerpc-linux-gnu-gcc"
-cross_cc_cflags_ppc64="-m64"
-cross_cc_ppc64le="powerpc64le-linux-gnu-gcc"
-
-enabled_cross_compilers=""
-
 supported_cpu="no"
 supported_os="no"
 bogus_os="no"
@@ -548,9 +532,12 @@ for opt do
   ;;
   --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
                       eval "cross_cc_cflags_${cc_arch}=\$optarg"
+                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
   ;;
   --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
+                cc_archs="$cc_archs $cc_arch"
                 eval "cross_cc_${cc_arch}=\$optarg"
+                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
   ;;
   esac
 done
@@ -745,42 +732,34 @@ ARCH=
 case "$cpu" in
   ppc|ppc64|s390|s390x|sparc64|x32|riscv32|riscv64)
     supported_cpu="yes"
-    eval "cross_cc_${cpu}=\$host_cc"
   ;;
   ppc64le)
     ARCH="ppc64"
     supported_cpu="yes"
-    cross_cc_ppc64le=$host_cc
   ;;
   i386|i486|i586|i686|i86pc|BePC)
     cpu="i386"
     supported_cpu="yes"
-    cross_cc_i386=$host_cc
   ;;
   x86_64|amd64)
     cpu="x86_64"
     supported_cpu="yes"
-    cross_cc_x86_64=$host_cc
   ;;
   armv*b|armv*l|arm)
     cpu="arm"
     supported_cpu="yes"
-    cross_cc_arm=$host_cc
   ;;
   aarch64)
     cpu="aarch64"
     supported_cpu="yes"
-    cross_cc_aarch64=$host_cc
   ;;
   mips*)
     cpu="mips"
     supported_cpu="yes"
-    cross_cc_mips=$host_cc
   ;;
   sparc|sun4[cdmuv])
     cpu="sparc"
     supported_cpu="yes"
-    cross_cc_sparc=$host_cc
   ;;
   *)
     # This will result in either an error or falling back to TCI later
@@ -1555,44 +1534,30 @@ case "$cpu" in
     ppc)
            CPU_CFLAGS="-m32"
            LDFLAGS="-m32 $LDFLAGS"
-           cross_cc_ppc=$cc
-           cross_cc_cflags_ppc="$CPU_CFLAGS"
            ;;
     ppc64)
            CPU_CFLAGS="-m64"
            LDFLAGS="-m64 $LDFLAGS"
-           cross_cc_ppc64=$cc
-           cross_cc_cflags_ppc64="$CPU_CFLAGS"
            ;;
     sparc)
            CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
            LDFLAGS="-m32 -mv8plus $LDFLAGS"
-           cross_cc_sparc=$cc
-           cross_cc_cflags_sparc="$CPU_CFLAGS"
            ;;
     sparc64)
            CPU_CFLAGS="-m64 -mcpu=ultrasparc"
            LDFLAGS="-m64 $LDFLAGS"
-           cross_cc_sparc64=$cc
-           cross_cc_cflags_sparc64="$CPU_CFLAGS"
            ;;
     s390)
            CPU_CFLAGS="-m31"
            LDFLAGS="-m31 $LDFLAGS"
-           cross_cc_s390=$cc
-           cross_cc_cflags_s390="$CPU_CFLAGS"
            ;;
     s390x)
            CPU_CFLAGS="-m64"
            LDFLAGS="-m64 $LDFLAGS"
-           cross_cc_s390x=$cc
-           cross_cc_cflags_s390x="$CPU_CFLAGS"
            ;;
     i386)
            CPU_CFLAGS="-m32"
            LDFLAGS="-m32 $LDFLAGS"
-           cross_cc_i386=$cc
-           cross_cc_cflags_i386="$CPU_CFLAGS"
            ;;
     x86_64)
            # ??? Only extremely old AMD cpus do not have cmpxchg16b.
@@ -1600,18 +1565,16 @@ case "$cpu" in
            # runtime and generate the fallback to serial emulation.
            CPU_CFLAGS="-m64 -mcx16"
            LDFLAGS="-m64 $LDFLAGS"
-           cross_cc_x86_64=$cc
-           cross_cc_cflags_x86_64="$CPU_CFLAGS"
            ;;
     x32)
            CPU_CFLAGS="-mx32"
            LDFLAGS="-mx32 $LDFLAGS"
-           cross_cc_i386=$cc
-           cross_cc_cflags_i386="$CPU_CFLAGS"
            ;;
     # No special flags required for other host CPUs
 esac
 
+eval "cross_cc_${cpu}=\$host_cc"
+cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
 
 # For user-mode emulation the host arch has to be one we explicitly
@@ -5894,17 +5857,6 @@ EOF
 fi
 
 ##########################################
-# Docker and cross-compiler support
-#
-# This is specifically for building test
-# cases for foreign architectures, not
-# cross-compiling QEMU itself.
-
-if has "docker"; then
-    docker=$($python $source_path/tests/docker/docker.py probe)
-fi
-
-##########################################
 # check for libpmem
 
 if test "$libpmem" != "no"; then
@@ -6516,6 +6468,12 @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
   echo "warning: Python 3 will be required for building future versions of QEMU" >&2
 fi
 
+(for i in $cross_cc_vars; do
+  export $i
+done
+export target_list source_path
+${SHELL-/bin/sh} $source_path/tests/tcg/configure.sh)
+
 config_host_mak="config-host.mak"
 
 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
@@ -7388,10 +7346,6 @@ if test "$gcov" = "yes" ; then
   echo "GCOV=$gcov_tool" >> $config_host_mak
 fi
 
-if test "$docker" != "no"; then
-    echo "HAVE_USER_DOCKER=y" >> $config_host_mak
-fi
-
 if test "$libudev" != "no"; then
     echo "CONFIG_LIBUDEV=y" >> $config_host_mak
     echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
@@ -7460,10 +7414,6 @@ case "$target" in
     ;;
 esac
 
-target_compiler=""
-target_compiler_static=""
-target_compiler_cflags=""
-
 mkdir -p $target_dir
 echo "# Automatically generated by configure - do not modify" > $config_target_mak
 
@@ -7480,26 +7430,20 @@ case "$target_name" in
   i386)
     mttcg="yes"
 	gdb_xml_files="i386-32bit.xml"
-    target_compiler=$cross_cc_i386
-    target_compiler_cflags=$cross_cc_ccflags_i386
   ;;
   x86_64)
     TARGET_BASE_ARCH=i386
     mttcg="yes"
 	gdb_xml_files="i386-64bit.xml"
-    target_compiler=$cross_cc_x86_64
   ;;
   alpha)
     mttcg="yes"
-    target_compiler=$cross_cc_alpha
   ;;
   arm|armeb)
     TARGET_ARCH=arm
     bflt="yes"
     mttcg="yes"
     gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
-    target_compiler=$cross_cc_arm
-    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
   ;;
   aarch64|aarch64_be)
     TARGET_ARCH=aarch64
@@ -7507,41 +7451,32 @@ case "$target_name" in
     bflt="yes"
     mttcg="yes"
     gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
-    target_compiler=$cross_cc_aarch64
-    eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
   ;;
   cris)
-    target_compiler=$cross_cc_cris
   ;;
   hppa)
     mttcg="yes"
-    target_compiler=$cross_cc_hppa
   ;;
   lm32)
-    target_compiler=$cross_cc_lm32
   ;;
   m68k)
     bflt="yes"
     gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
-    target_compiler=$cross_cc_m68k
   ;;
   microblaze|microblazeel)
     TARGET_ARCH=microblaze
     bflt="yes"
     echo "TARGET_ABI32=y" >> $config_target_mak
-    target_compiler=$cross_cc_microblaze
   ;;
   mips|mipsel)
     mttcg="yes"
     TARGET_ARCH=mips
-    target_compiler=$cross_cc_mips
     echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
   ;;
   mipsn32|mipsn32el)
     mttcg="yes"
     TARGET_ARCH=mips64
     TARGET_BASE_ARCH=mips
-    target_compiler=$cross_cc_mipsn32
     echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
     echo "TARGET_ABI32=y" >> $config_target_mak
   ;;
@@ -7549,32 +7484,24 @@ case "$target_name" in
     mttcg="yes"
     TARGET_ARCH=mips64
     TARGET_BASE_ARCH=mips
-    target_compiler=$cross_cc_mips64
     echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
   ;;
   moxie)
-    target_compiler=$cross_cc_moxie
   ;;
   nios2)
-    target_compiler=$cross_cc_nios2
   ;;
   or1k)
-    target_compiler=$cross_cc_or1k
     TARGET_ARCH=openrisc
     TARGET_BASE_ARCH=openrisc
   ;;
   ppc)
     gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
-    target_compiler=$cross_cc_ppc
-    target_compiler_cflags="$cross_cc_cflags_ppc"
   ;;
   ppc64)
     TARGET_BASE_ARCH=ppc
     TARGET_ABI_DIR=ppc
     mttcg=yes
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
-    target_compiler=$cross_cc_ppc64
-    target_compiler_cflags="$cross_cc_cflags_ppc64"
   ;;
   ppc64le)
     TARGET_ARCH=ppc64
@@ -7582,7 +7509,6 @@ case "$target_name" in
     TARGET_ABI_DIR=ppc
     mttcg=yes
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
-    target_compiler=$cross_cc_ppc64le
   ;;
   ppc64abi32)
     TARGET_ARCH=ppc64
@@ -7590,60 +7516,48 @@ case "$target_name" in
     TARGET_ABI_DIR=ppc
     echo "TARGET_ABI32=y" >> $config_target_mak
     gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
-    target_compiler=$cross_cc_ppc64abi32
   ;;
   riscv32)
     TARGET_BASE_ARCH=riscv
     TARGET_ABI_DIR=riscv
     mttcg=yes
     gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-32bit-csr.xml"
-    target_compiler=$cross_cc_riscv32
   ;;
   riscv64)
     TARGET_BASE_ARCH=riscv
     TARGET_ABI_DIR=riscv
     mttcg=yes
     gdb_xml_files="riscv-64bit-cpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml"
-    target_compiler=$cross_cc_riscv64
   ;;
   sh4|sh4eb)
     TARGET_ARCH=sh4
     bflt="yes"
-    target_compiler=$cross_cc_sh4
   ;;
   sparc)
-    target_compiler=$cross_cc_sparc
   ;;
   sparc64)
     TARGET_BASE_ARCH=sparc
-    target_compiler=$cross_cc_sparc64
   ;;
   sparc32plus)
     TARGET_ARCH=sparc64
     TARGET_BASE_ARCH=sparc
     TARGET_ABI_DIR=sparc
-    target_compiler=$cross_cc_sparc32plus
     echo "TARGET_ABI32=y" >> $config_target_mak
   ;;
   s390x)
     mttcg=yes
     gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
-    target_compiler=$cross_cc_s390x
   ;;
   tilegx)
-    target_compiler=$cross_cc_tilegx
   ;;
   tricore)
-    target_compiler=$cross_cc_tricore
   ;;
   unicore32)
-    target_compiler=$cross_cc_unicore32
   ;;
   xtensa|xtensaeb)
     TARGET_ARCH=xtensa
     bflt="yes"
     mttcg="yes"
-    target_compiler=$cross_cc_xtensa
   ;;
   *)
     error_exit "Unsupported target CPU"
@@ -7654,27 +7568,6 @@ if [ "$TARGET_BASE_ARCH" = "" ]; then
   TARGET_BASE_ARCH=$TARGET_ARCH
 fi
 
-# Do we have a cross compiler for this target?
-if has $target_compiler; then
-
-    write_c_skeleton
-
-    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
-        # For host systems we might get away with building without -static
-        if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
-            target_compiler=""
-        else
-            enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
-            target_compiler_static="n"
-        fi
-    else
-        enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
-        target_compiler_static="y"
-    fi
-else
-    target_compiler=""
-fi
-
 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
 
 upper() {
@@ -7748,18 +7641,6 @@ if test "$target_bsd_user" = "yes" ; then
   echo "CONFIG_BSD_USER=y" >> $config_target_mak
 fi
 
-if test -n "$target_compiler"; then
-  echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
-
-  if test -n "$target_compiler_static"; then
-      echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
-  fi
-
-  if test -n "$target_compiler_cflags"; then
-      echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
-  fi
-fi
-
 
 # generate QEMU_CFLAGS/LDFLAGS for targets
 
@@ -7890,11 +7771,6 @@ done # for target in $targets
 echo "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak
 echo "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak
 
-if test -n "$enabled_cross_compilers"; then
-    echo
-    echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
-fi
-
 if [ "$fdt" = "git" ]; then
   echo "config-host.h: dtc/all" >> $config_host_mak
 fi
@@ -7923,15 +7799,14 @@ fi
 # so the build tree will be missing the link back to the new file, and
 # tests might fail. Prefer to keep the relevant files in their own
 # directory and symlink the directory instead.
-DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
+DIRS="tests tests/tcg tests/tcg/lm32 tests/libqos tests/qapi-schema tests/qemu-iotests tests/vm"
 DIRS="$DIRS tests/fp tests/qgraph"
 DIRS="$DIRS docs docs/interop fsdev scsi"
 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
 DIRS="$DIRS roms/seabios roms/vgabios"
-LINKS="Makefile tests/tcg/Makefile"
-LINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
-LINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
-LINKS="$LINKS tests/fp/Makefile"
+LINKS="Makefile"
+LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
+LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
 LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
 LINKS="$LINKS pc-bios/spapr-rtas/Makefile"
 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 8bb5c97..a3ee649 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1058,30 +1058,28 @@ BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS))
 CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TARGET_DIRS))
 RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
 
-ifeq ($(HAVE_USER_DOCKER),y)
 # Probe for the Docker Builds needed for each build
 $(foreach PROBE_TARGET,$(TARGET_DIRS), 				\
 	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
-endif
 
 build-tcg-tests-%:
 	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
 		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
 		SRC_PATH=$(SRC_PATH) \
-	       	V="$(V)" TARGET_DIR="$*/" guest-tests, \
+	       	V="$(V)" TARGET="$*" guest-tests, \
 		"BUILD", "TCG tests for $*")
 
 run-tcg-tests-%: build-tcg-tests-% %/all
 	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
 		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
 		SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
-		V="$(V)" TARGET_DIR="$*/" run-guest-tests, \
+		V="$(V)" TARGET="$*" run-guest-tests, \
 		"RUN", "TCG tests for $*")
 
 clean-tcg-tests-%:
 	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
 		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
-		SRC_PATH=$(SRC_PATH) TARGET_DIR="$*/" clean-guest-tests, \
+		SRC_PATH=$(SRC_PATH) TARGET="$*" clean-guest-tests, \
 		"RUN", "TCG tests for $*")
 
 .PHONY: build-tcg
diff --git a/tests/tcg/Makefile.prereqs b/tests/tcg/Makefile.prereqs
index 53b0196..7494b31 100644
--- a/tests/tcg/Makefile.prereqs
+++ b/tests/tcg/Makefile.prereqs
@@ -7,24 +7,12 @@
 # selection of required docker targets before we invoke a sub-make for
 # each target.
 
-# First we need the target makefile which tells us the target architecture
-CROSS_CC_GUEST:=
--include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
-
-# Then we load up the target architecture makefiles which tell us
-# about the compilers
 DOCKER_IMAGE:=
 
--include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
--include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
+-include $(BUILD_DIR)/tests/tcg/config-$(PROBE_TARGET).mak
 
-ifndef CROSS_CC_GUEST
 ifneq ($(DOCKER_IMAGE),)
 build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE)
+$(BUILD_DIR)/tests/tcg/config_$(PROBE_TARGET).mak: config-host.mak
+config-host.mak: $(SRC_PATH)/tests/tcg/configure.sh
 endif
-endif
-
-# Clean-up
-# undefine TARGET_NAME
-# undefine TARGET_BASE_ARCH
-# undefine TARGET_ABI_DIR
diff --git a/tests/tcg/Makefile.qemu b/tests/tcg/Makefile.qemu
index d3f3437..c8bec7b 100644
--- a/tests/tcg/Makefile.qemu
+++ b/tests/tcg/Makefile.qemu
@@ -8,17 +8,22 @@
 # to do it for us.
 #
 
-# The per ARCH makefile, if it exists, holds extra information about
+include $(SRC_PATH)/rules.mak
+
+# The configure script fills in extra information about
 # useful docker images or alternative compiler flags.
 
-include $(TARGET_DIR)config-target.mak
-include $(SRC_PATH)/rules.mak
-include $(wildcard \
-	$(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
-	$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
+CROSS_CC_GUEST:=
+DOCKER_IMAGE:=
+-include $(BUILD_DIR)/tests/tcg/config-$(TARGET).mak
 
 GUEST_BUILD=
 TCG_MAKE=../Makefile.target
+
+# We also need the Docker make rules to depend on
+SKIP_DOCKER_BUILD=1
+include $(SRC_PATH)/tests/docker/Makefile.include
+
 # Support installed Cross Compilers
 
 ifdef CROSS_CC_GUEST
@@ -26,11 +31,11 @@ ifdef CROSS_CC_GUEST
 .PHONY: cross-build-guest-tests
 cross-build-guest-tests:
 	$(call quiet-command, \
-	   (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
-	    $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \
+	   (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
+	    $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
 			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
-			EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \
-	"BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
+			EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
+	"BUILD","$(TARGET) guest-tests with $(CROSS_CC_GUEST)")
 
 GUEST_BUILD=cross-build-guest-tests
 
@@ -38,31 +43,25 @@ endif
 
 # Support building with Docker
 
-ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
 ifneq ($(DOCKER_IMAGE),)
 
-# We also need the Docker make rules to depend on
-SKIP_DOCKER_BUILD=1
-include $(SRC_PATH)/tests/docker/Makefile.include
-
 DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
-		--cc $(DOCKER_CROSS_COMPILER) \
+		--cc $(DOCKER_CROSS_CC_GUEST) \
 		-i qemu:$(DOCKER_IMAGE) \
 		-s $(SRC_PATH) -- "
 
 .PHONY: docker-build-guest-tests
 docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
 	$(call quiet-command, \
-	  (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
-	   $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC=$(DOCKER_COMPILE_CMD) \
+	  (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
+	   $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC=$(DOCKER_COMPILE_CMD) \
 			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
-			EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \
-	"BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
+			EXTRA_CFLAGS="$(CROSS_CC_GUEST_CFLAGS)"), \
+	"BUILD","$(TARGET) guest-tests with docker qemu:$(DOCKER_IMAGE)")
 
 GUEST_BUILD=docker-build-guest-tests
 
 endif
-endif
 
 # Final targets
 all:
@@ -75,22 +74,22 @@ guest-tests: $(GUEST_BUILD)
 
 run-guest-tests: guest-tests
 	$(call quiet-command, \
-	(cd tests/tcg/$(TARGET_DIR) && \
-	 $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" \
+	(cd tests/tcg/$(TARGET) && \
+	 $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" \
 	 		SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
 	"RUN", "tests for $(TARGET_NAME)")
 
 else
 guest-tests:
 	$(call quiet-command, /bin/true, "BUILD", \
-		"$(TARGET_DIR) guest-tests SKIPPED")
+		"$(TARGET) guest-tests SKIPPED")
 
 run-guest-tests:
 	$(call quiet-command, /bin/true, "RUN", \
-		"tests for $(TARGET_DIR) SKIPPED")
+		"tests for $(TARGET) SKIPPED")
 endif
 
 # It doesn't matter if these don't exits
 .PHONY: clean-guest-tests
 clean-guest-tests:
-	rm -rf tests/tcg/$(TARGET_DIR)
+	rm -rf tests/tcg/$(TARGET)
diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
index 8dbcba4..8808bea 100644
--- a/tests/tcg/Makefile.target
+++ b/tests/tcg/Makefile.target
@@ -31,7 +31,7 @@
 
 all:
 -include ../../config-host.mak
--include ../../../$(TARGET_DIR)/config-target.mak
+-include ../config-$(TARGET).mak
 
 # for including , in command strings
 COMMA := ,
@@ -63,12 +63,6 @@ CFLAGS=
 QEMU_CFLAGS=
 LDFLAGS=
 
-# The QEMU for this TARGET
-ifdef CONFIG_USER_ONLY
-QEMU=../../../$(TARGET_DIR)/qemu-$(TARGET_NAME)
-else
-QEMU=../../../$(TARGET_DIR)/qemu-system-$(TARGET_NAME)
-endif
 QEMU_OPTS=
 
 
diff --git a/tests/tcg/aarch64/Makefile.include b/tests/tcg/aarch64/Makefile.include
deleted file mode 100644
index 5d4e4c6..0000000
--- a/tests/tcg/aarch64/Makefile.include
+++ /dev/null
@@ -1,8 +0,0 @@
-# Makefile.include for AArch64 targets
-#
-# We don't have any bigendian build tools so we only use this for AArch64
-
-ifeq ($(TARGET_NAME),aarch64)
-DOCKER_IMAGE=debian-buster-arm64-cross
-DOCKER_CROSS_COMPILER=aarch64-linux-gnu-gcc
-endif
diff --git a/tests/tcg/alpha/Makefile.include b/tests/tcg/alpha/Makefile.include
deleted file mode 100644
index c7dc48e..0000000
--- a/tests/tcg/alpha/Makefile.include
+++ /dev/null
@@ -1,2 +0,0 @@
-DOCKER_IMAGE=debian-alpha-cross
-DOCKER_CROSS_COMPILER=alpha-linux-gnu-gcc
diff --git a/tests/tcg/arm/Makefile.include b/tests/tcg/arm/Makefile.include
deleted file mode 100644
index 8e7eac0..0000000
--- a/tests/tcg/arm/Makefile.include
+++ /dev/null
@@ -1,8 +0,0 @@
-# Makefile.include for all ARM targets
-#
-# We don't have any bigendian build tools so we only use this for armhf
-
-ifeq ($(TARGET_NAME),arm)
-DOCKER_IMAGE=debian-armhf-cross
-DOCKER_CROSS_COMPILER=arm-linux-gnueabihf-gcc
-endif
diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh
new file mode 100644
index 0000000..5a8f52e
--- /dev/null
+++ b/tests/tcg/configure.sh
@@ -0,0 +1,228 @@
+#!/bin/sh
+
+if test -z "$source_path"; then
+  echo Do not invoke this script directly.  It is called
+  echo automatically by configure.
+  exit 1
+fi
+
+write_c_skeleton() {
+    cat > $TMPC <<EOF
+int main(void) { return 0; }
+EOF
+}
+
+has() {
+  command -v "$1" >/dev/null 2>&1
+}
+
+do_compiler() {
+  # Run the compiler, capturing its output to the log. First argument
+  # is compiler binary to execute.
+  local compiler="$1"
+  shift
+  if test -n "$BASH_VERSION"; then eval '
+      echo >>config.log "
+funcs: ${FUNCNAME[*]}
+lines: ${BASH_LINENO[*]}"
+  '; fi
+  echo $compiler "$@" >> config.log
+  $compiler "$@" >> config.log 2>&1 || return $?
+}
+
+
+TMPDIR1="config-temp"
+TMPC="${TMPDIR1}/qemu-conf.c"
+TMPE="${TMPDIR1}/qemu-conf.exe"
+
+if has docker; then
+  docker=$($python $source_path/tests/docker/docker.py probe)
+fi
+
+# cross compilers defaults, can be overridden with --cross-cc-ARCH
+: ${cross_cc_aarch64="aarch64-linux-gnu-gcc"}
+: ${cross_cc_aarch64_be="$cross_cc_aarch64"}
+: ${cross_cc_cflags_aarch64_be="-mbig-endian"}
+: ${cross_cc_arm="arm-linux-gnueabihf-gcc"}
+: ${cross_cc_cflags_armeb="-mbig-endian"}
+: ${cross_cc_i386="i386-pc-linux-gnu-gcc"}
+: ${cross_cc_cflags_i386="-m32"}
+: ${cross_cc_x86_64="x86_64-pc-linux-gnu-gcc"}
+: ${cross_cc_cflags_x86_64="-m64"}
+: ${cross_cc_ppc="powerpc-linux-gnu-gcc"}
+: ${cross_cc_cflags_ppc="-m32"}
+: ${cross_cc_ppc64="powerpc-linux-gnu-gcc"}
+: ${cross_cc_cflags_ppc64="-m64"}
+: ${cross_cc_ppc64le="powerpc64le-linux-gnu-gcc"}
+: ${cross_cc_cflags_s390x="-m64"}
+: ${cross_cc_cflags_sparc="-m32 -mv8plus -mcpu=ultrasparc"}
+: ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
+
+for target in $target_list; do
+  arch=${target%%-*}
+  case $arch in
+    arm|armeb)
+      arches=arm
+      ;;
+    aarch64|aarch64_be)
+      arches="aarch64 arm"
+      ;;
+    mips*)
+      arches=mips
+      ;;
+    ppc*)
+      arches=ppc
+      ;;
+    sh4|sh4eb)
+      arches=sh4
+      ;;
+    x86_64)
+      arches="x86_64 i386"
+      ;;
+    xtensa|xtensaeb)
+      arches=xtensa
+      ;;
+    alpha|cris|hppa|i386|lm32|m68k|openrisc|riscv64|s390x|sh4|sparc64)
+      arches=$target
+      ;;
+    *)
+      continue
+      ;;
+  esac
+
+  docker_image=
+  case $target in
+    aarch64-*)
+      # We don't have any bigendian build tools so we only use this for AArch64
+      docker_image=debian-buster-arm64-cross
+      docker_cross_cc=aarch64-linux-gnu-gcc
+      ;;
+    alpha-*)
+      docker_image=debian-alpha-cross
+      docker_cross_cc=alpha-linux-gnu-gcc
+      ;;
+    arm-*)
+      # We don't have any bigendian build tools so we only use this for AArch64
+      docker_image=debian-armhf-cross
+      docker_cross_cc=arm-linux-gnueabihf-gcc
+      ;;
+    cris-*)
+      docker_image=fedora-cris-cross
+      docker_cross_cc=cris-linux-gnu-gcc
+      ;;
+    hppa-*)
+      docker_image=debian-hppa-cross
+      docker_cross_cc=hppa-linux-gnu-gcc
+      ;;
+    i386-*)
+      docker_image=fedora-i386-cross
+      docker_cross_cc=gcc
+      ;;
+    m68k-*)
+      docker_image=debian-m68k-cross
+      docker_cross_cc=m68k-linux-gnu-gcc
+      ;;
+    mips64el-*)
+      docker_image=debian-mips64el-cross
+      docker_cross_cc=mips64el-linux-gnuabi64-gcc
+      ;;
+    mips64-*)
+      docker_image=debian-mips64-cross
+      docker_cross_cc=mips64-linux-gnuabi64-gcc
+      ;;
+    mipsel-*)
+      docker_image=debian-mipsel-cross
+      docker_cross_cc=mipsel-linux-gnu-gcc
+      ;;
+    mips-*)
+      docker_image=debian-mips-cross
+      docker_cross_cc=mips-linux-gnu-gcc
+      ;;
+    ppc-*)
+      docker_image=debian-powerpc-cross
+      docker_cross_cc=powerpc-linux-gnu-gcc
+      ;;
+    ppc64-*)
+      docker_image=debian-ppc64-cross
+      docker_cross_cc=powerpc64-linux-gnu-gcc
+      ;;
+    ppc64le-*)
+      docker_image=debian-ppc64el-cross
+      docker_cross_cc=powerpc64le-linux-gnu-gcc
+      ;;
+    riscv64-*)
+      docker_image=debian-riscv64-cross
+      docker_cross_cc=riscv64-linux-gnu-gcc
+      ;;
+    s390x-*)
+      docker_image=debian-s390x-cross
+      docker_cross_cc=s390x-linux-gnu-gcc
+      ;;
+    sh4-*)
+      docker_image=debian-sh4-cross
+      docker_cross_cc=sh4-linux-gnu-gcc
+      ;;
+    sparc64-*)
+      docker_image=debian-sparc64-cross
+      docker_cross_cc=sparc64-linux-gnu-gcc
+      ;;
+    xtensa*-softmmu)
+      docker_image=debian-xtensa-cross
+
+      # default to the dc232b cpu
+      docker_cross_cc=/opt/2018.02/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-gcc
+      ;;
+  esac
+
+  config_target_mak=tests/tcg/config-$target.mak
+
+  echo "# Automatically generated by configure - do not modify" > $config_target_mak
+  echo "TARGET_NAME=$arch" >> $config_target_mak
+  case $target in
+    *-linux-user | *-bsd-user)
+      echo "CONFIG_USER_ONLY=y" >> $config_target_mak
+      echo "QEMU=\$(BUILD_DIR)/$target/qemu-$arch" >> $config_target_mak
+      ;;
+    *-softmmu)
+      echo "CONFIG_SOFTMMU=y" >> $config_target_mak
+      echo "QEMU=\$(BUILD_DIR)/$target/qemu-system-$arch" >> $config_target_mak
+      ;;
+  esac
+
+  eval "target_compiler_cflags=\${cross_cc_cflags_$arch}"
+  echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
+
+  got_cross_cc=no
+  for i in $arch $arches; do
+    if eval test "x\${cross_cc_$i+yes}" != xyes; then
+      continue
+    fi
+
+    eval "target_compiler=\${cross_cc_$i}"
+    if ! has $target_compiler; then
+      continue
+    fi
+    write_c_skeleton
+    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
+      # For host systems we might get away with building without -static
+      if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
+        continue
+      fi
+      echo "CROSS_CC_GUEST_STATIC=y" >> $config_target_mak
+    fi
+    echo "CROSS_CC_GUEST=$target_compiler" >> $config_target_mak
+    enabled_cross_compilers="$enabled_cross_compilers $target_compiler"
+    got_cross_cc=yes
+    break
+  done
+
+  if test $got_cross_cc = no && test "$docker" != no && test -n "$docker_image"; then
+    echo "DOCKER_IMAGE=$docker_image" >> $config_target_mak
+    echo "DOCKER_CROSS_CC_GUEST=$docker_cross_cc" >> $config_target_mak
+  fi
+done
+
+if test -n "$enabled_cross_compilers"; then
+    echo
+    echo "NOTE: guest cross-compilers enabled:$enabled_cross_compilers"
+fi
diff --git a/tests/tcg/cris/Makefile.include b/tests/tcg/cris/Makefile.include
deleted file mode 100644
index 1c03782..0000000
--- a/tests/tcg/cris/Makefile.include
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Makefile.include for all CRIS targets
-#
-
-DOCKER_IMAGE=fedora-cris-cross
-DOCKER_CROSS_COMPILER=cris-linux-gnu-gcc
diff --git a/tests/tcg/hppa/Makefile.include b/tests/tcg/hppa/Makefile.include
deleted file mode 100644
index da23534..0000000
--- a/tests/tcg/hppa/Makefile.include
+++ /dev/null
@@ -1,2 +0,0 @@
-DOCKER_IMAGE=debian-hppa-cross
-DOCKER_CROSS_COMPILER=hppa-linux-gnu-gcc
diff --git a/tests/tcg/i386/Makefile.include b/tests/tcg/i386/Makefile.include
deleted file mode 100644
index be1c300..0000000
--- a/tests/tcg/i386/Makefile.include
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Makefile.include for all i386
-#
-# There is enough brokeness in x86_64 compilers that we don't default
-# to using the x86_64 system compiler for i386 binaries.
-#
-
-DOCKER_IMAGE=fedora-i386-cross
-DOCKER_CROSS_COMPILER=gcc
diff --git a/tests/tcg/m68k/Makefile.include b/tests/tcg/m68k/Makefile.include
deleted file mode 100644
index cd7c6bf..0000000
--- a/tests/tcg/m68k/Makefile.include
+++ /dev/null
@@ -1,2 +0,0 @@
-DOCKER_IMAGE=debian-m68k-cross
-DOCKER_CROSS_COMPILER=m68k-linux-gnu-gcc
diff --git a/tests/tcg/mips/Makefile.include b/tests/tcg/mips/Makefile.include
deleted file mode 100644
index 4a14fc0..0000000
--- a/tests/tcg/mips/Makefile.include
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Makefile.include for all MIPs targets
-#
-# As Debian doesn't support mip64 in big endian mode the only way to
-# build BE is to pass a working cross compiler to ./configure
-#
-
-ifeq ($(TARGET_NAME),mips64el)
-DOCKER_IMAGE=debian-mips64el-cross
-DOCKER_CROSS_COMPILER=mips64el-linux-gnuabi64-gcc
-else ifeq ($(TARGET_NAME),mips64)
-DOCKER_IMAGE=debian-mips64-cross
-DOCKER_CROSS_COMPILER=mips64-linux-gnuabi64-gcc
-else ifeq ($(TARGET_NAME),mipsel)
-DOCKER_IMAGE=debian-mipsel-cross
-DOCKER_CROSS_COMPILER=mipsel-linux-gnu-gcc
-else ifeq ($(TARGET_NAME),mips)
-DOCKER_IMAGE=debian-mips-cross
-DOCKER_CROSS_COMPILER=mips-linux-gnu-gcc
-endif
diff --git a/tests/tcg/ppc/Makefile.include b/tests/tcg/ppc/Makefile.include
deleted file mode 100644
index ae01fb8..0000000
--- a/tests/tcg/ppc/Makefile.include
+++ /dev/null
@@ -1,10 +0,0 @@
-ifeq ($(TARGET_NAME),ppc)
-DOCKER_IMAGE=debian-powerpc-cross
-DOCKER_CROSS_COMPILER=powerpc-linux-gnu-gcc
-else ifeq ($(TARGET_NAME),ppc64)
-DOCKER_IMAGE=debian-ppc64-cross
-DOCKER_CROSS_COMPILER=powerpc64-linux-gnu-gcc
-else ifeq ($(TARGET_NAME),ppc64le)
-DOCKER_IMAGE=debian-ppc64el-cross
-DOCKER_CROSS_COMPILER=powerpc64le-linux-gnu-gcc
-endif
diff --git a/tests/tcg/riscv/Makefile.include b/tests/tcg/riscv/Makefile.include
deleted file mode 100644
index d92ac6c..0000000
--- a/tests/tcg/riscv/Makefile.include
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# Makefile.include for all RISCV targets
-#
-# Debian only really cares about 64 bit going forward
-#
-
-ifeq ($(TARGET_NAME),riscv64)
-DOCKER_IMAGE=debian-riscv64-cross
-DOCKER_CROSS_COMPILER=riscv64-linux-gnu-gcc
-endif
diff --git a/tests/tcg/s390x/Makefile.include b/tests/tcg/s390x/Makefile.include
deleted file mode 100644
index 1f58115..0000000
--- a/tests/tcg/s390x/Makefile.include
+++ /dev/null
@@ -1,2 +0,0 @@
-DOCKER_IMAGE=debian-s390x-cross
-DOCKER_CROSS_COMPILER=s390x-linux-gnu-gcc
diff --git a/tests/tcg/sh4/Makefile.include b/tests/tcg/sh4/Makefile.include
deleted file mode 100644
index ad21594..0000000
--- a/tests/tcg/sh4/Makefile.include
+++ /dev/null
@@ -1,4 +0,0 @@
-ifneq ($(TARGET_NAME), sh4eb)
-DOCKER_IMAGE=debian-sh4-cross
-DOCKER_CROSS_COMPILER=sh4-linux-gnu-gcc
-endif
diff --git a/tests/tcg/sparc64/Makefile.include b/tests/tcg/sparc64/Makefile.include
deleted file mode 100644
index 95fc8de..0000000
--- a/tests/tcg/sparc64/Makefile.include
+++ /dev/null
@@ -1,2 +0,0 @@
-DOCKER_IMAGE=debian-sparc64-cross
-DOCKER_CROSS_COMPILER=sparc64-linux-gnu-gcc
diff --git a/tests/tcg/xtensa/Makefile.include b/tests/tcg/xtensa/Makefile.include
deleted file mode 100644
index 423c00a..0000000
--- a/tests/tcg/xtensa/Makefile.include
+++ /dev/null
@@ -1,11 +0,0 @@
-# Makefile.include for xtensa targets
-#
-# The compilers can only be used for building system tests
-
-ifeq ($(CONFIG_SOFTMMU),y)
-DOCKER_IMAGE=debian-xtensa-cross
-
-# default to the dc232b cpu
-DOCKER_CROSS_COMPILER=/opt/2018.02/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-gcc
-DOCKER_CROSS_LINKER=/opt/2018.02/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-ld
-endif
-- 
1.8.3.1



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

* Re: [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions Paolo Bonzini
@ 2019-07-30 12:44   ` Philippe Mathieu-Daudé
  2019-07-30 13:21     ` Paolo Bonzini
  2019-08-07 13:05   ` Alex Bennée
  1 sibling, 1 reply; 20+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-07-30 12:44 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: alex.bennee

On 7/30/19 2:37 PM, Paolo Bonzini wrote:
[...]
> Drop the usage of TARGET_BASE_ARCH, which is ignored by everything except
> x86_64 and aarch64.  Fix x86 tests by using -cpu max and, while
> at it, standardize on QEMU_OPTS for aarch64 tests too.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
[...]
> --- a/tests/tcg/Makefile.include
> +++ b/tests/tcg/Makefile.qemu
> @@ -2,20 +2,23 @@
>  #
>  # TCG tests (per-target rules)
>  #
> -# This Makefile fragment is included from the per-target
> -# Makefile.target so will be invoked for each linux-user program we
> -# build. We have two options for compiling, either using a configured
> -# guest compiler or calling one of our docker images to do it for us.
> +# This Makefile fragment is included from the build-tcg target, once
> +# for each target we build. We have two options for compiling, either
> +# using a configured guest compiler or calling one of our docker images
> +# to do it for us.
>  #
>  
>  # The per ARCH makefile, if it exists, holds extra information about
>  # useful docker images or alternative compiler flags.
>  
> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
> --include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
> +include $(TARGET_DIR)config-target.mak
> +include $(SRC_PATH)/rules.mak
> +include $(wildcard \
> +	$(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
> +	$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
>  

It is still used here... Else we could clean ./configure way more.


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

* Re: [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
  2019-07-30 12:37 [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles Paolo Bonzini
                   ` (2 preceding siblings ...)
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script Paolo Bonzini
@ 2019-07-30 12:53 ` no-reply
  2019-08-07 12:40 ` Alex Bennée
  4 siblings, 0 replies; 20+ messages in thread
From: no-reply @ 2019-07-30 12:53 UTC (permalink / raw)
  To: pbonzini; +Cc: alex.bennee, qemu-devel

Patchew URL: https://patchew.org/QEMU/20190730123759.21723-1-pbonzini@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Subject: [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
Message-id: 20190730123759.21723-1-pbonzini@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
   ee9545e..6e9a6cb  master     -> master
 * [new tag]         patchew/20190730123759.21723-1-pbonzini@redhat.com -> patchew/20190730123759.21723-1-pbonzini@redhat.com
Submodule 'capstone' (https://git.qemu.org/git/capstone.git) registered for path 'capstone'
Submodule 'dtc' (https://git.qemu.org/git/dtc.git) registered for path 'dtc'
Submodule 'roms/QemuMacDrivers' (https://git.qemu.org/git/QemuMacDrivers.git) registered for path 'roms/QemuMacDrivers'
Submodule 'roms/SLOF' (https://git.qemu.org/git/SLOF.git) registered for path 'roms/SLOF'
Submodule 'roms/edk2' (https://git.qemu.org/git/edk2.git) registered for path 'roms/edk2'
Submodule 'roms/ipxe' (https://git.qemu.org/git/ipxe.git) registered for path 'roms/ipxe'
Submodule 'roms/openbios' (https://git.qemu.org/git/openbios.git) registered for path 'roms/openbios'
Submodule 'roms/openhackware' (https://git.qemu.org/git/openhackware.git) registered for path 'roms/openhackware'
Submodule 'roms/opensbi' (https://git.qemu.org/git/opensbi.git) registered for path 'roms/opensbi'
Submodule 'roms/qemu-palcode' (https://git.qemu.org/git/qemu-palcode.git) registered for path 'roms/qemu-palcode'
Submodule 'roms/seabios' (https://git.qemu.org/git/seabios.git/) registered for path 'roms/seabios'
Submodule 'roms/seabios-hppa' (https://git.qemu.org/git/seabios-hppa.git) registered for path 'roms/seabios-hppa'
Submodule 'roms/sgabios' (https://git.qemu.org/git/sgabios.git) registered for path 'roms/sgabios'
Submodule 'roms/skiboot' (https://git.qemu.org/git/skiboot.git) registered for path 'roms/skiboot'
Submodule 'roms/u-boot' (https://git.qemu.org/git/u-boot.git) registered for path 'roms/u-boot'
Submodule 'roms/u-boot-sam460ex' (https://git.qemu.org/git/u-boot-sam460ex.git) registered for path 'roms/u-boot-sam460ex'
Submodule 'slirp' (https://git.qemu.org/git/libslirp.git) registered for path 'slirp'
Submodule 'tests/fp/berkeley-softfloat-3' (https://git.qemu.org/git/berkeley-softfloat-3.git) registered for path 'tests/fp/berkeley-softfloat-3'
Submodule 'tests/fp/berkeley-testfloat-3' (https://git.qemu.org/git/berkeley-testfloat-3.git) registered for path 'tests/fp/berkeley-testfloat-3'
Submodule 'ui/keycodemapdb' (https://git.qemu.org/git/keycodemapdb.git) registered for path 'ui/keycodemapdb'
Cloning into 'capstone'...
Submodule path 'capstone': checked out '22ead3e0bfdb87516656453336160e0a37b066bf'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '88f18909db731a627456f26d779445f84e449536'
Cloning into 'roms/QemuMacDrivers'...
Submodule path 'roms/QemuMacDrivers': checked out '90c488d5f4a407342247b9ea869df1c2d9c8e266'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out 'ba1ab360eebe6338bb8d7d83a9220ccf7e213af3'
Cloning into 'roms/edk2'...
Submodule path 'roms/edk2': checked out '20d2e5a125e34fc8501026613a71549b2a1a3e54'
Submodule 'SoftFloat' (https://github.com/ucb-bar/berkeley-softfloat-3.git) registered for path 'ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3'
Submodule 'CryptoPkg/Library/OpensslLib/openssl' (https://github.com/openssl/openssl) registered for path 'CryptoPkg/Library/OpensslLib/openssl'
Cloning into 'ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3'...
Submodule path 'roms/edk2/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3': checked out 'b64af41c3276f97f0e181920400ee056b9c88037'
Cloning into 'CryptoPkg/Library/OpensslLib/openssl'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl': checked out '50eaac9f3337667259de725451f201e784599687'
Submodule 'boringssl' (https://boringssl.googlesource.com/boringssl) registered for path 'boringssl'
Submodule 'krb5' (https://github.com/krb5/krb5) registered for path 'krb5'
Submodule 'pyca.cryptography' (https://github.com/pyca/cryptography.git) registered for path 'pyca-cryptography'
Cloning into 'boringssl'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl': checked out '2070f8ad9151dc8f3a73bffaa146b5e6937a583f'
Cloning into 'krb5'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/krb5': checked out 'b9ad6c49505c96a088326b62a52568e3484f2168'
Cloning into 'pyca-cryptography'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/pyca-cryptography': checked out '09403100de2f6f1cdd0d484dcb8e620f1c335c8f'
Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 'de4565cbe76ea9f7913a01f331be3ee901bb6e17'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out 'c79e0ecb84f4f1ee3f73f521622e264edd1bf174'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/opensbi'...
Submodule path 'roms/opensbi': checked out 'ce228ee0919deb9957192d723eecc8aaae2697c6'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out 'bf0e13698872450164fa7040da36a95d2d4b326f'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 'a5cab58e9a3fb6e168aba919c5669bea406573b4'
Cloning into 'roms/seabios-hppa'...
Submodule path 'roms/seabios-hppa': checked out '0f4fe84658165e96ce35870fd19fc634e182e77b'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 'cbaee52287e5f32373181cff50a00b6c4ac9015a'
Cloning into 'roms/skiboot'...
Submodule path 'roms/skiboot': checked out '261ca8e779e5138869a45f174caa49be6a274501'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 'd3689267f92c5956e09cc7d1baa4700141662bff'
Cloning into 'roms/u-boot-sam460ex'...
Submodule path 'roms/u-boot-sam460ex': checked out '60b3916f33e617a815973c5a6df77055b2e3a588'
Cloning into 'slirp'...
Submodule path 'slirp': checked out 'f0da6726207b740f6101028b2992f918477a4b08'
Cloning into 'tests/fp/berkeley-softfloat-3'...
Submodule path 'tests/fp/berkeley-softfloat-3': checked out 'b64af41c3276f97f0e181920400ee056b9c88037'
Cloning into 'tests/fp/berkeley-testfloat-3'...
Submodule path 'tests/fp/berkeley-testfloat-3': checked out '5a59dcec19327396a011a17fd924aed4fec416b3'
Cloning into 'ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out '6b3d716e2b6472eb7189d3220552280ef3d832ce'
Switched to a new branch 'test'
a8a63d5 tests/tcg: move configuration to a sub-shell script
7a1ae61 tests/tcg: cleanup Makefile inclusions
d5cb6df tests/tcg: use EXTRA_CFLAGS everywhere

=== OUTPUT BEGIN ===
1/3 Checking commit d5cb6df2dcd3 (tests/tcg: use EXTRA_CFLAGS everywhere)
2/3 Checking commit 7a1ae6123820 (tests/tcg: cleanup Makefile inclusions)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#83: 
rename from tests/tcg/Makefile.probe

total: 0 errors, 1 warnings, 341 lines checked

Patch 2/3 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/3 Checking commit a8a63d5aa20e (tests/tcg: move configuration to a sub-shell script)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#690: 
deleted file mode 100644

WARNING: line over 80 characters
#909: FILE: tests/tcg/configure.sh:179:
+  echo "# Automatically generated by configure - do not modify" > $config_target_mak

ERROR: line over 90 characters
#936: FILE: tests/tcg/configure.sh:206:
+    if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then

WARNING: line over 80 characters
#938: FILE: tests/tcg/configure.sh:208:
+      if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then

WARNING: line over 80 characters
#949: FILE: tests/tcg/configure.sh:219:
+  if test $got_cross_cc = no && test "$docker" != no && test -n "$docker_image"; then

total: 1 errors, 4 warnings, 845 lines checked

Patch 3/3 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20190730123759.21723-1-pbonzini@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

* Re: [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions
  2019-07-30 12:44   ` Philippe Mathieu-Daudé
@ 2019-07-30 13:21     ` Paolo Bonzini
  0 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2019-07-30 13:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: alex.bennee

On 30/07/19 14:44, Philippe Mathieu-Daudé wrote:
> On 7/30/19 2:37 PM, Paolo Bonzini wrote:
> [...]
>> Drop the usage of TARGET_BASE_ARCH, which is ignored by everything except
>> x86_64 and aarch64.  Fix x86 tests by using -cpu max and, while
>> at it, standardize on QEMU_OPTS for aarch64 tests too.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
> [...]
>> --- a/tests/tcg/Makefile.include
>> +++ b/tests/tcg/Makefile.qemu
>> @@ -2,20 +2,23 @@
>>  #
>>  # TCG tests (per-target rules)
>>  #
>> -# This Makefile fragment is included from the per-target
>> -# Makefile.target so will be invoked for each linux-user program we
>> -# build. We have two options for compiling, either using a configured
>> -# guest compiler or calling one of our docker images to do it for us.
>> +# This Makefile fragment is included from the build-tcg target, once
>> +# for each target we build. We have two options for compiling, either
>> +# using a configured guest compiler or calling one of our docker images
>> +# to do it for us.
>>  #
>>  
>>  # The per ARCH makefile, if it exists, holds extra information about
>>  # useful docker images or alternative compiler flags.
>>  
>> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
>> --include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>> +include $(TARGET_DIR)config-target.mak
>> +include $(SRC_PATH)/rules.mak
>> +include $(wildcard \
>> +	$(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
>> +	$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
>>  
> 
> It is still used here... Else we could clean ./configure way more.

Yes, I only made that part go away in the next patch to keep it simple
(the next patch gets rid of Makefile.include altogether, so I didn't
want to add churn in this one).  But it would not clean ./configure much
since TARGET_BASE_ARCH is used by QEMU itself.

Paolo


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

* Re: [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
  2019-07-30 12:37 [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles Paolo Bonzini
                   ` (3 preceding siblings ...)
  2019-07-30 12:53 ` [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles no-reply
@ 2019-08-07 12:40 ` Alex Bennée
  2019-08-07 13:06   ` Paolo Bonzini
  4 siblings, 1 reply; 20+ messages in thread
From: Alex Bennée @ 2019-08-07 12:40 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


Paolo Bonzini <pbonzini@redhat.com> writes:

> The tests/tcg rely a lot on per-target informations from
> the QEMU makefiles, but most of the definitions in there
> aren't really relevant to TCG tests.
>
> This series is just a cleanup, but it could also be
> a useful start in making it possible to compile tests/tcg
> out of QEMU's tree, and/or making it a submodule, and/or
> unifying the system emulation tests with kvm-unit-tests.

Hmm something is throwing off configure and making it use my login shell
instead of /bin/sh:

  libpmem support   no
  libudev           yes
  default devices   yes
  ~/lsrc/qemu.git/tests/tcg/configure.sh (line 63): 'case' builtin not inside of switch block
    case $arch in
    ^
  <W> fish: Error while reading file /home/alex/lsrc/qemu.git/tests/tcg/configure.sh

>
> Paolo
>
> Paolo Bonzini (3):
>   tests/tcg: use EXTRA_CFLAGS everywhere
>   tests/tcg: cleanup Makefile inclusions
>   tests/tcg: move configuration to a sub-shell script
>
>  Makefile                                  |   1 +
>  Makefile.target                           |   3 -
>  configure                                 | 155 ++------------------
>  tests/Makefile.include                    |  25 ++--
>  tests/tcg/Makefile.include                |  88 ------------
>  tests/tcg/Makefile.prereqs                |  18 +++
>  tests/tcg/Makefile.probe                  |  31 ----
>  tests/tcg/Makefile.qemu                   |  95 +++++++++++++
>  tests/tcg/{Makefile => Makefile.target}   |  15 +-
>  tests/tcg/aarch64/Makefile.include        |   8 --
>  tests/tcg/aarch64/Makefile.softmmu-target |   4 +-
>  tests/tcg/aarch64/Makefile.target         |  12 +-
>  tests/tcg/alpha/Makefile.include          |   2 -
>  tests/tcg/alpha/Makefile.softmmu-target   |   4 +-
>  tests/tcg/arm/Makefile.include            |   8 --
>  tests/tcg/arm/Makefile.softmmu-target     |   6 +-
>  tests/tcg/configure.sh                    | 228 ++++++++++++++++++++++++++++++
>  tests/tcg/cris/Makefile.include           |   6 -
>  tests/tcg/hppa/Makefile.include           |   2 -
>  tests/tcg/i386/Makefile.include           |   9 --
>  tests/tcg/i386/Makefile.softmmu-target    |  12 +-
>  tests/tcg/i386/Makefile.target            |  13 +-
>  tests/tcg/m68k/Makefile.include           |   2 -
>  tests/tcg/minilib/Makefile.target         |   2 +-
>  tests/tcg/mips/Makefile.include           |  20 ---
>  tests/tcg/ppc/Makefile.include            |  10 --
>  tests/tcg/riscv/Makefile.include          |  10 --
>  tests/tcg/s390x/Makefile.include          |   2 -
>  tests/tcg/sh4/Makefile.include            |   4 -
>  tests/tcg/sparc64/Makefile.include        |   2 -
>  tests/tcg/x86_64/Makefile.softmmu-target  |  36 +++++
>  tests/tcg/x86_64/Makefile.target          |   7 +-
>  tests/tcg/xtensa/Makefile.include         |  11 --
>  tests/tcg/xtensa/Makefile.softmmu-target  |   4 +-
>  34 files changed, 435 insertions(+), 420 deletions(-)
>  delete mode 100644 tests/tcg/Makefile.include
>  create mode 100644 tests/tcg/Makefile.prereqs
>  delete mode 100644 tests/tcg/Makefile.probe
>  create mode 100644 tests/tcg/Makefile.qemu
>  rename tests/tcg/{Makefile => Makefile.target} (90%)
>  delete mode 100644 tests/tcg/aarch64/Makefile.include
>  delete mode 100644 tests/tcg/alpha/Makefile.include
>  delete mode 100644 tests/tcg/arm/Makefile.include
>  create mode 100644 tests/tcg/configure.sh
>  delete mode 100644 tests/tcg/cris/Makefile.include
>  delete mode 100644 tests/tcg/hppa/Makefile.include
>  delete mode 100644 tests/tcg/i386/Makefile.include
>  delete mode 100644 tests/tcg/m68k/Makefile.include
>  delete mode 100644 tests/tcg/mips/Makefile.include
>  delete mode 100644 tests/tcg/ppc/Makefile.include
>  delete mode 100644 tests/tcg/riscv/Makefile.include
>  delete mode 100644 tests/tcg/s390x/Makefile.include
>  delete mode 100644 tests/tcg/sh4/Makefile.include
>  delete mode 100644 tests/tcg/sparc64/Makefile.include
>  create mode 100644 tests/tcg/x86_64/Makefile.softmmu-target
>  delete mode 100644 tests/tcg/xtensa/Makefile.include


--
Alex Bennée


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

* Re: [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script Paolo Bonzini
@ 2019-08-07 12:42   ` Alex Bennée
  2019-08-07 13:10   ` Alex Bennée
  1 sibling, 0 replies; 20+ messages in thread
From: Alex Bennée @ 2019-08-07 12:42 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


Paolo Bonzini <pbonzini@redhat.com> writes:

> Avoid the repeated inclusions of config-target.mak, which have
> risks of namespace pollution, and instead build minimal configuration
> files in a configuration script.  The same configuration files can
> also be included in Makefile and Makefile.qemu
>
<snip>
> diff --git a/configure b/configure
> index 714e7fb..b0bd308 100755
> --- a/configure
> +++ b/configure
<snip>
>
>  if test "$libpmem" != "no"; then
> @@ -6516,6 +6468,12 @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
>    echo "warning: Python 3 will be required for building future versions of QEMU" >&2
>  fi
>
> +(for i in $cross_cc_vars; do
> +  export $i
> +done
> +export target_list source_path
> +${SHELL-/bin/sh} $source_path/tests/tcg/configure.sh)
> +

Do we really want to use the users SHELL here? What's wrong with just
calling it and letting the OS derive things from the #!?

--
Alex Bennée


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

* Re: [Qemu-devel] [PATCH 1/3] tests/tcg: use EXTRA_CFLAGS everywhere
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 1/3] tests/tcg: use EXTRA_CFLAGS everywhere Paolo Bonzini
@ 2019-08-07 12:51   ` Alex Bennée
  2019-08-07 13:10     ` Paolo Bonzini
  0 siblings, 1 reply; 20+ messages in thread
From: Alex Bennée @ 2019-08-07 12:51 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


Paolo Bonzini <pbonzini@redhat.com> writes:

> For i386 specifically, this allows using the host GCC
> to compile the i386 tests.  But, it should really be
> done for all targets, unless we want to pass $(EXTRA_CFLAGS)
> directly as part of $(CC).

Hmm well for softmmu the tests take the decision:

  # For softmmu targets we include a different Makefile fragement as the
  # build options for bare programs are usually pretty different. They
  # are expected to provide their own build recipes.

So we are not expecting to handle multi-classing the system compiler to
generate different binaries with a common build string. To be honest I
wonder if we should just drop the EXTRA_CFLAGS shenanigans in favour of
an explicit compiler per target?

>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/tcg/aarch64/Makefile.softmmu-target | 4 ++--
>  tests/tcg/alpha/Makefile.softmmu-target   | 4 ++--
>  tests/tcg/arm/Makefile.softmmu-target     | 2 +-
>  tests/tcg/i386/Makefile.softmmu-target    | 4 ++--
>  tests/tcg/minilib/Makefile.target         | 2 +-
>  tests/tcg/xtensa/Makefile.softmmu-target  | 4 ++--
>  6 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/tests/tcg/aarch64/Makefile.softmmu-target b/tests/tcg/aarch64/Makefile.softmmu-target
> index 2e560e4..4c4aaf6 100644
> --- a/tests/tcg/aarch64/Makefile.softmmu-target
> +++ b/tests/tcg/aarch64/Makefile.softmmu-target
> @@ -22,11 +22,11 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
>  .PRECIOUS: $(CRT_OBJS)
>
>  %.o: $(CRT_PATH)/%.S
> -	$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -c $< -o $@
>
>  # Build and link the tests
>  %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
> -	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
>
>  memory: CFLAGS+=-DCHECK_UNALIGNED=1
>
> diff --git a/tests/tcg/alpha/Makefile.softmmu-target b/tests/tcg/alpha/Makefile.softmmu-target
> index 3c0f34c..09193a6 100644
> --- a/tests/tcg/alpha/Makefile.softmmu-target
> +++ b/tests/tcg/alpha/Makefile.softmmu-target
> @@ -22,11 +22,11 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
>  .PRECIOUS: $(CRT_OBJS)
>
>  %.o: $(CRT_PATH)/%.S
> -	$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -c $< -o $@
>
>  # Build and link the tests
>  %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
> -	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
>
>  memory: CFLAGS+=-DCHECK_UNALIGNED=0
>
> diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile.softmmu-target
> index 49d48d8..2deb06e 100644
> --- a/tests/tcg/arm/Makefile.softmmu-target
> +++ b/tests/tcg/arm/Makefile.softmmu-target
> @@ -18,7 +18,7 @@ CFLAGS+=-Wl,--build-id=none -x assembler-with-cpp
>  LDFLAGS+=-nostdlib -N -static
>
>  %: %.S %.ld
> -	$(CC) $(CFLAGS) $(ASFLAGS) $< -o $@ $(LDFLAGS) -T $(ARM_SRC)/$@.ld
> +	$(CC) $(CFLAGS) $(ASFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) -T $(ARM_SRC)/$@.ld
>
>  # Specific Test Rules
>
> diff --git a/tests/tcg/i386/Makefile.softmmu-target b/tests/tcg/i386/Makefile.softmmu-target
> index 0a43648..cee3420 100644
> --- a/tests/tcg/i386/Makefile.softmmu-target
> +++ b/tests/tcg/i386/Makefile.softmmu-target
> @@ -32,11 +32,11 @@ TESTS+=$(MULTIARCH_TESTS)
>  .PRECIOUS: $(CRT_OBJS)
>
>  %.o: $(CRT_PATH)/%.S
> -	$(CC) $(CFLAGS) -c $< -o $@
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
>
>  # Build and link the tests
>  %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
> -	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
>
>  memory: CFLAGS+=-DCHECK_UNALIGNED=1
>
> diff --git a/tests/tcg/minilib/Makefile.target b/tests/tcg/minilib/Makefile.target
> index 3ed8077..c821d28 100644
> --- a/tests/tcg/minilib/Makefile.target
> +++ b/tests/tcg/minilib/Makefile.target
> @@ -18,4 +18,4 @@ MINILIB_INC=-isystem $(SYSTEM_MINILIB_SRC)
>  .PRECIOUS: $(MINILIB_OBJS)
>
>  %.o: $(SYSTEM_MINILIB_SRC)/%.c
> -	$(CC) $(CFLAGS) -c $< -o $@
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
> diff --git a/tests/tcg/xtensa/Makefile.softmmu-target b/tests/tcg/xtensa/Makefile.softmmu-target
> index 8212d96..9530cac 100644
> --- a/tests/tcg/xtensa/Makefile.softmmu-target
> +++ b/tests/tcg/xtensa/Makefile.softmmu-target
> @@ -34,9 +34,9 @@ $(XTENSA_USABLE_TESTS): linker.ld macros.inc $(CRT) Makefile.softmmu-target
>
>  # special rule for common blobs
>  %.o: %.S
> -	$(CC) $(XTENSA_INC) $($*_ASFLAGS) $(ASFLAGS) -c $< -o $@
> +	$(CC) $(XTENSA_INC) $($*_ASFLAGS) $(ASFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
>
>  %: %.S
> -	$(CC) $(XTENSA_INC) $(ASFLAGS) $< -o $@ $(LDFLAGS) $(NOSTDFLAGS) $(CRT)
> +	$(CC) $(XTENSA_INC) $(ASFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) $(NOSTDFLAGS) $(CRT)
>
>  endif


--
Alex Bennée


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

* Re: [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions Paolo Bonzini
  2019-07-30 12:44   ` Philippe Mathieu-Daudé
@ 2019-08-07 13:05   ` Alex Bennée
  2019-08-07 13:11     ` Paolo Bonzini
  1 sibling, 1 reply; 20+ messages in thread
From: Alex Bennée @ 2019-08-07 13:05 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


Paolo Bonzini <pbonzini@redhat.com> writes:

> Rename Makefile.probe to Makefile.prereqs and make it actually
> define rules for the tests.
>
> Rename Makefile to Makefile.target, since it is not a toplevel
> makefile.
>
> Rename Makefile.include to Makefile.qemu and disentangle it
> from the QEMU Makefile.target, so that it is invoked recursively
> by tests/Makefile.include.  Tests are now placed in
> tests/tcg/$(TARGET).
>
> Drop the usage of TARGET_BASE_ARCH, which is ignored by everything except
> x86_64 and aarch64.  Fix x86 tests by using -cpu max and, while
> at it, standardize on QEMU_OPTS for aarch64 tests too.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  Makefile.target                                |  3 --
>  tests/Makefile.include                         | 23 +++++++-----
>  tests/tcg/{Makefile.probe => Makefile.prereqs} |  5 ++-
>  tests/tcg/{Makefile.include => Makefile.qemu}  | 48 +++++++++++++++-----------
>  tests/tcg/{Makefile => Makefile.target}        | 13 +++----
>  tests/tcg/aarch64/Makefile.target              | 12 ++++---
>  tests/tcg/arm/Makefile.softmmu-target          |  4 ---
>  tests/tcg/i386/Makefile.softmmu-target         |  8 -----
>  tests/tcg/i386/Makefile.target                 | 13 +++----
>  tests/tcg/x86_64/Makefile.softmmu-target       | 36 +++++++++++++++++++
>  tests/tcg/x86_64/Makefile.target               |  7 ++--
>  11 files changed, 100 insertions(+), 72 deletions(-)
>  rename tests/tcg/{Makefile.probe => Makefile.prereqs} (92%)
>  rename tests/tcg/{Makefile.include => Makefile.qemu} (52%)
>  rename tests/tcg/{Makefile => Makefile.target} (92%)
>  create mode 100644 tests/tcg/x86_64/Makefile.softmmu-target
>
> diff --git a/Makefile.target b/Makefile.target
> index 933b274..5e91623 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -39,9 +39,6 @@ endif
>  PROGS=$(QEMU_PROG) $(QEMU_PROGW)
>  STPFILES=
>
> -# Makefile Tests
> -include $(SRC_PATH)/tests/tcg/Makefile.include
> -

So this looses the ability to run:

  make run-guest-tests

in any given build directory. It would be useful to have a target that
could still get us there.

>  config-target.h: config-target.h-timestamp
>  config-target.h-timestamp: config-target.mak
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index fd7fdb8..8bb5c97 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -1061,23 +1061,28 @@ RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
>  ifeq ($(HAVE_USER_DOCKER),y)
>  # Probe for the Docker Builds needed for each build
>  $(foreach PROBE_TARGET,$(TARGET_DIRS), 				\
> -	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.probe) 	\
> -	$(if $(DOCKER_PREREQ), 					\
> -		$(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ))))
> +	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
>  endif
>
>  build-tcg-tests-%:
> -	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
> -		SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" guest-tests, \
> +	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
> +		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
> +		SRC_PATH=$(SRC_PATH) \
> +	       	V="$(V)" TARGET_DIR="$*/" guest-tests, \
>  		"BUILD", "TCG tests for $*")
>
> -run-tcg-tests-%: % build-tcg-tests-%
> -	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
> -		SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" run-guest-tests, \
> +run-tcg-tests-%: build-tcg-tests-% %/all
> +	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
> +		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
> +		SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
> +		V="$(V)" TARGET_DIR="$*/" run-guest-tests, \
>  		"RUN", "TCG tests for $*")
>
>  clean-tcg-tests-%:
> -	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,)
> +	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
> +		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
> +		SRC_PATH=$(SRC_PATH) TARGET_DIR="$*/" clean-guest-tests, \
> +		"RUN", "TCG tests for $*")
>
>  .PHONY: build-tcg
>  build-tcg: $(BUILD_TCG_TARGET_RULES)
> diff --git a/tests/tcg/Makefile.probe b/tests/tcg/Makefile.prereqs
> similarity index 92%
> rename from tests/tcg/Makefile.probe
> rename to tests/tcg/Makefile.prereqs
> index 9dc6546..53b0196 100644
> --- a/tests/tcg/Makefile.probe
> +++ b/tests/tcg/Makefile.prereqs
> @@ -8,20 +8,19 @@
>  # each target.
>
>  # First we need the target makefile which tells us the target architecture
> +CROSS_CC_GUEST:=
>  -include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
>
>  # Then we load up the target architecture makefiles which tell us
>  # about the compilers
> -CROSS_CC_GUEST:=
>  DOCKER_IMAGE:=
> -DOCKER_PREREQ:=
>
>  -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
>  -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>
>  ifndef CROSS_CC_GUEST
>  ifneq ($(DOCKER_IMAGE),)
> -DOCKER_PREREQ:=docker-image-$(DOCKER_IMAGE)
> +build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE)
>  endif
>  endif
>
> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.qemu
> similarity index 52%
> rename from tests/tcg/Makefile.include
> rename to tests/tcg/Makefile.qemu
> index 73b5626..d3f3437 100644
> --- a/tests/tcg/Makefile.include
> +++ b/tests/tcg/Makefile.qemu
> @@ -2,20 +2,23 @@
>  #
>  # TCG tests (per-target rules)
>  #
> -# This Makefile fragment is included from the per-target
> -# Makefile.target so will be invoked for each linux-user program we
> -# build. We have two options for compiling, either using a configured
> -# guest compiler or calling one of our docker images to do it for us.
> +# This Makefile fragment is included from the build-tcg target, once
> +# for each target we build. We have two options for compiling, either
> +# using a configured guest compiler or calling one of our docker images
> +# to do it for us.
>  #
>
>  # The per ARCH makefile, if it exists, holds extra information about
>  # useful docker images or alternative compiler flags.
>
> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
> --include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
> +include $(TARGET_DIR)config-target.mak
> +include $(SRC_PATH)/rules.mak
> +include $(wildcard \
> +	$(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
> +	$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
>
>  GUEST_BUILD=
> -TCG_MAKE=$(SRC_PATH)/tests/tcg/Makefile
> +TCG_MAKE=../Makefile.target
>  # Support installed Cross Compilers
>
>  ifdef CROSS_CC_GUEST
> @@ -23,9 +26,9 @@ ifdef CROSS_CC_GUEST
>  .PHONY: cross-build-guest-tests
>  cross-build-guest-tests:
>  	$(call quiet-command, \
> -	   (mkdir -p tests && cd tests && \
> -	    $(MAKE) -f $(TCG_MAKE) CC=$(CROSS_CC_GUEST) \
> -			BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
> +	   (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
> +	    $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \
> +			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
>  			EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \
>  	"BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
>
> @@ -39,20 +42,20 @@ ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
>  ifneq ($(DOCKER_IMAGE),)
>
>  # We also need the Docker make rules to depend on
> +SKIP_DOCKER_BUILD=1
>  include $(SRC_PATH)/tests/docker/Makefile.include
>
>  DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
>  		--cc $(DOCKER_CROSS_COMPILER) \
>  		-i qemu:$(DOCKER_IMAGE) \
>  		-s $(SRC_PATH) -- "
> -DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
>
>  .PHONY: docker-build-guest-tests
> -docker-build-guest-tests: $(DOCKER_PREREQ)
> +docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
>  	$(call quiet-command, \
> -	  (mkdir -p tests && cd tests && \
> -	   $(MAKE) -f $(TCG_MAKE) CC=$(DOCKER_COMPILE_CMD) \
> -			BUILD_STATIC=y \
> +	  (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
> +	   $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC=$(DOCKER_COMPILE_CMD) \
> +			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
>  			EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \
>  	"BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
>
> @@ -62,27 +65,32 @@ endif
>  endif
>
>  # Final targets
> +all:
> +	@echo "Do not invoke this Makefile directly"; exit 1
> +
>  .PHONY: guest-tests
>
>  ifneq ($(GUEST_BUILD),)
>  guest-tests: $(GUEST_BUILD)
>
> -run-guest-tests: guest-tests qemu-$(subst y,system-,$(CONFIG_SOFTMMU))$(TARGET_NAME)
> +run-guest-tests: guest-tests
>  	$(call quiet-command, \
> -	(cd tests && $(MAKE) -f $(TCG_MAKE) SPEED=$(SPEED) run), \
> +	(cd tests/tcg/$(TARGET_DIR) && \
> +	 $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" \
> +	 		SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
>  	"RUN", "tests for $(TARGET_NAME)")
>
>  else
>  guest-tests:
>  	$(call quiet-command, /bin/true, "BUILD", \
> -		"$(TARGET_NAME) guest-tests SKIPPED")
> +		"$(TARGET_DIR) guest-tests SKIPPED")
>
>  run-guest-tests:
>  	$(call quiet-command, /bin/true, "RUN", \
> -		"tests for $(TARGET_NAME) SKIPPED")
> +		"tests for $(TARGET_DIR) SKIPPED")
>  endif
>
>  # It doesn't matter if these don't exits
>  .PHONY: clean-guest-tests
>  clean-guest-tests:
> -	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
> +	rm -rf tests/tcg/$(TARGET_DIR)
> diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile.target
> similarity index 92%
> rename from tests/tcg/Makefile
> rename to tests/tcg/Makefile.target
> index 9f56768..8dbcba4 100644
> --- a/tests/tcg/Makefile
> +++ b/tests/tcg/Makefile.target
> @@ -29,8 +29,9 @@
>  # We also expect to be in the tests build dir for the FOO-(linux-user|softmmu).
>  #
>
> +all:
>  -include ../../config-host.mak
> --include ../config-target.mak
> +-include ../../../$(TARGET_DIR)/config-target.mak
>
>  # for including , in command strings
>  COMMA := ,
> @@ -64,9 +65,9 @@ LDFLAGS=
>
>  # The QEMU for this TARGET
>  ifdef CONFIG_USER_ONLY
> -QEMU=../qemu-$(TARGET_NAME)
> +QEMU=../../../$(TARGET_DIR)/qemu-$(TARGET_NAME)
>  else
> -QEMU=../qemu-system-$(TARGET_NAME)
> +QEMU=../../../$(TARGET_DIR)/qemu-system-$(TARGET_NAME)
>  endif
>  QEMU_OPTS=
>
> @@ -82,10 +83,7 @@ ifdef CONFIG_USER_ONLY
>  # The order we include is important. We include multiarch, base arch
>  # and finally arch if it's not the same as base arch.
>  -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target
> -ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
>  -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
> -endif

Comment above needs fixing up.

>
>  # Add the common build options
>  CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
> @@ -101,10 +99,7 @@ else
>  # are expected to provide their own build recipes.
>  -include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
>  -include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.softmmu-target
> -ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
>  -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
> -endif
>
>  endif
>
> diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
> index 31ba9cf..e763dd9 100644
> --- a/tests/tcg/aarch64/Makefile.target
> +++ b/tests/tcg/aarch64/Makefile.target
> @@ -2,12 +2,14 @@
>  #
>  # AArch64 specific tweaks
>
> +ARM_SRC=$(SRC_PATH)/tests/tcg/arm
> +VPATH 		+= $(ARM_SRC)
> +
>  AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
>  VPATH 		+= $(AARCH64_SRC)
>
> -# we don't build any of the ARM tests
> -AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS))
> -AARCH64_TESTS+=fcvt
> +# we don't build any other ARM test
> +AARCH64_TESTS=fcvt
>
>  fcvt: LDFLAGS+=-lm
>
> @@ -16,6 +18,6 @@ run-fcvt: fcvt
>  	$(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref)
>
>  AARCH64_TESTS += pauth-1 pauth-2
> -run-pauth-%: QEMU += -cpu max
> +run-pauth-%: QEMU_OPTS += -cpu max
>
> -TESTS:=$(AARCH64_TESTS)
> +TESTS += $(AARCH64_TESTS)
> diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile.softmmu-target
> index 2deb06e..231e9a5 100644
> --- a/tests/tcg/arm/Makefile.softmmu-target
> +++ b/tests/tcg/arm/Makefile.softmmu-target
> @@ -3,8 +3,6 @@
>  # ARM SoftMMU tests - included from tests/tcg/Makefile
>  #
>
> -ifeq ($(TARGET_ABI_DIR),arm)
> -
>  ARM_SRC=$(SRC_PATH)/tests/tcg/arm
>
>  # Set search path for all sources
> @@ -25,5 +23,3 @@ LDFLAGS+=-nostdlib -N -static
>  test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0
>
>  run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel
> -
> -endif
> diff --git a/tests/tcg/i386/Makefile.softmmu-target b/tests/tcg/i386/Makefile.softmmu-target
> index cee3420..1c8790e 100644
> --- a/tests/tcg/i386/Makefile.softmmu-target
> +++ b/tests/tcg/i386/Makefile.softmmu-target
> @@ -12,17 +12,9 @@ X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
>  # These objects provide the basic boot code and helper functions for all tests
>  CRT_OBJS=boot.o
>
> -ifeq ($(TARGET_X86_64), y)
> -CRT_PATH=$(X64_SYSTEM_SRC)
> -CFLAGS=-march=x86-64
> -LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
> -LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
> -else
>  CRT_PATH=$(I386_SYSTEM_SRC)
> -CFLAGS+=-m32
>  LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld
>  LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386
> -endif
>  CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
>  LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
>
> diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
> index d0eb702..08c5736 100644
> --- a/tests/tcg/i386/Makefile.target
> +++ b/tests/tcg/i386/Makefile.target
> @@ -6,14 +6,11 @@ I386_SRC=$(SRC_PATH)/tests/tcg/i386
>  VPATH 		+= $(I386_SRC)
>
>  I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c))
> -I386_TESTS=$(I386_SRCS:.c=)
> -I386_ONLY_TESTS=$(filter-out test-i386-ssse3, $(I386_TESTS))
> +ALL_X86_TESTS=$(I386_SRCS:.c=)
> +I386_TESTS:=$(filter-out test-i386-ssse3, $(ALL_X86_TESTS))
> +X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS))
>  # Update TESTS
> -TESTS+=$(I386_ONLY_TESTS)
> -
> -ifneq ($(TARGET_NAME),x86_64)
> -CFLAGS+=-m32
> -endif
> +TESTS=$(MULTIARCH_TESTS) $(I386_TESTS)
>
>  #
>  # hello-i386 is a barebones app
> @@ -26,7 +23,7 @@ hello-i386: LDFLAGS+=-nostdlib
>  #
>
>  test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386-shift.h test-i386-muldiv.h
> -	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
> +	$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ \
>  	   $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
>
>  ifeq ($(SPEED), slow)
> diff --git a/tests/tcg/x86_64/Makefile.softmmu-target b/tests/tcg/x86_64/Makefile.softmmu-target
> new file mode 100644
> index 0000000..df252e7
> --- /dev/null
> +++ b/tests/tcg/x86_64/Makefile.softmmu-target
> @@ -0,0 +1,36 @@
> +#
> +# x86 system tests
> +#
> +# This currently builds only for i386. The common C code is built
> +# with standard compiler flags however so we can support both by
> +# adding additional boot files for x86_64.
> +#
> +
> +I386_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/i386/system

I think this is redundant now...

> +X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
> +
> +# These objects provide the basic boot code and helper functions for all tests
> +CRT_OBJS=boot.o
> +
> +CRT_PATH=$(X64_SYSTEM_SRC)
> +LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
> +LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
> +CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
> +LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
> +
> +TESTS+=$(MULTIARCH_TESTS)
> +
> +# building head blobs
> +.PRECIOUS: $(CRT_OBJS)
> +
> +%.o: $(CRT_PATH)/%.S
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
> +
> +# Build and link the tests
> +%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
> +
> +memory: CFLAGS+=-DCHECK_UNALIGNED=1
> +
> +# Running
> +QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel
> diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target
> index 74f170b..20bf962 100644
> --- a/tests/tcg/x86_64/Makefile.target
> +++ b/tests/tcg/x86_64/Makefile.target
> @@ -6,9 +6,10 @@
>  # $(SRC)/tests/tcg/i386/
>  #
>
> -X86_64_TESTS=$(filter-out $(I386_ONLY_TESTS), $(TESTS))
> -X86_64_TESTS+=test-x86_64
> -TESTS:=$(X86_64_TESTS)
> +include $(SRC_PATH)/tests/tcg/i386/Makefile.target
> +
> +TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
> +QEMU_OPTS += -cpu max
>
>  test-x86_64: LDFLAGS+=-lm -lc
>  test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h


--
Alex Bennée


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

* Re: [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
  2019-08-07 12:40 ` Alex Bennée
@ 2019-08-07 13:06   ` Paolo Bonzini
  2019-08-07 13:33     ` Eric Blake
  0 siblings, 1 reply; 20+ messages in thread
From: Paolo Bonzini @ 2019-08-07 13:06 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel

On 07/08/19 14:40, Alex Bennée wrote:
> 
> Paolo Bonzini <pbonzini@redhat.com> writes:
> 
>> The tests/tcg rely a lot on per-target informations from
>> the QEMU makefiles, but most of the definitions in there
>> aren't really relevant to TCG tests.
>>
>> This series is just a cleanup, but it could also be
>> a useful start in making it possible to compile tests/tcg
>> out of QEMU's tree, and/or making it a submodule, and/or
>> unifying the system emulation tests with kvm-unit-tests.
> 
> Hmm something is throwing off configure and making it use my login shell
> instead of /bin/sh:
> 
>   libpmem support   no
>   libudev           yes
>   default devices   yes
>   ~/lsrc/qemu.git/tests/tcg/configure.sh (line 63): 'case' builtin not inside of switch block
>     case $arch in
>     ^
>   <W> fish: Error while reading file /home/alex/lsrc/qemu.git/tests/tcg/configure.sh

It's the ${SHELL} you found in patch 3.  The disadvantage of relying on
#! is that some people have bash in /usr/bin/bash rather than /bin/bash.
 But we already assume /bin/bash elsewhere so I can drop it.

Paolo

>>
>> Paolo
>>
>> Paolo Bonzini (3):
>>   tests/tcg: use EXTRA_CFLAGS everywhere
>>   tests/tcg: cleanup Makefile inclusions
>>   tests/tcg: move configuration to a sub-shell script
>>
>>  Makefile                                  |   1 +
>>  Makefile.target                           |   3 -
>>  configure                                 | 155 ++------------------
>>  tests/Makefile.include                    |  25 ++--
>>  tests/tcg/Makefile.include                |  88 ------------
>>  tests/tcg/Makefile.prereqs                |  18 +++
>>  tests/tcg/Makefile.probe                  |  31 ----
>>  tests/tcg/Makefile.qemu                   |  95 +++++++++++++
>>  tests/tcg/{Makefile => Makefile.target}   |  15 +-
>>  tests/tcg/aarch64/Makefile.include        |   8 --
>>  tests/tcg/aarch64/Makefile.softmmu-target |   4 +-
>>  tests/tcg/aarch64/Makefile.target         |  12 +-
>>  tests/tcg/alpha/Makefile.include          |   2 -
>>  tests/tcg/alpha/Makefile.softmmu-target   |   4 +-
>>  tests/tcg/arm/Makefile.include            |   8 --
>>  tests/tcg/arm/Makefile.softmmu-target     |   6 +-
>>  tests/tcg/configure.sh                    | 228 ++++++++++++++++++++++++++++++
>>  tests/tcg/cris/Makefile.include           |   6 -
>>  tests/tcg/hppa/Makefile.include           |   2 -
>>  tests/tcg/i386/Makefile.include           |   9 --
>>  tests/tcg/i386/Makefile.softmmu-target    |  12 +-
>>  tests/tcg/i386/Makefile.target            |  13 +-
>>  tests/tcg/m68k/Makefile.include           |   2 -
>>  tests/tcg/minilib/Makefile.target         |   2 +-
>>  tests/tcg/mips/Makefile.include           |  20 ---
>>  tests/tcg/ppc/Makefile.include            |  10 --
>>  tests/tcg/riscv/Makefile.include          |  10 --
>>  tests/tcg/s390x/Makefile.include          |   2 -
>>  tests/tcg/sh4/Makefile.include            |   4 -
>>  tests/tcg/sparc64/Makefile.include        |   2 -
>>  tests/tcg/x86_64/Makefile.softmmu-target  |  36 +++++
>>  tests/tcg/x86_64/Makefile.target          |   7 +-
>>  tests/tcg/xtensa/Makefile.include         |  11 --
>>  tests/tcg/xtensa/Makefile.softmmu-target  |   4 +-
>>  34 files changed, 435 insertions(+), 420 deletions(-)
>>  delete mode 100644 tests/tcg/Makefile.include
>>  create mode 100644 tests/tcg/Makefile.prereqs
>>  delete mode 100644 tests/tcg/Makefile.probe
>>  create mode 100644 tests/tcg/Makefile.qemu
>>  rename tests/tcg/{Makefile => Makefile.target} (90%)
>>  delete mode 100644 tests/tcg/aarch64/Makefile.include
>>  delete mode 100644 tests/tcg/alpha/Makefile.include
>>  delete mode 100644 tests/tcg/arm/Makefile.include
>>  create mode 100644 tests/tcg/configure.sh
>>  delete mode 100644 tests/tcg/cris/Makefile.include
>>  delete mode 100644 tests/tcg/hppa/Makefile.include
>>  delete mode 100644 tests/tcg/i386/Makefile.include
>>  delete mode 100644 tests/tcg/m68k/Makefile.include
>>  delete mode 100644 tests/tcg/mips/Makefile.include
>>  delete mode 100644 tests/tcg/ppc/Makefile.include
>>  delete mode 100644 tests/tcg/riscv/Makefile.include
>>  delete mode 100644 tests/tcg/s390x/Makefile.include
>>  delete mode 100644 tests/tcg/sh4/Makefile.include
>>  delete mode 100644 tests/tcg/sparc64/Makefile.include
>>  create mode 100644 tests/tcg/x86_64/Makefile.softmmu-target
>>  delete mode 100644 tests/tcg/xtensa/Makefile.include
> 
> 
> --
> Alex Bennée
> 



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

* Re: [Qemu-devel] [PATCH 1/3] tests/tcg: use EXTRA_CFLAGS everywhere
  2019-08-07 12:51   ` Alex Bennée
@ 2019-08-07 13:10     ` Paolo Bonzini
  0 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2019-08-07 13:10 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel

On 07/08/19 14:51, Alex Bennée wrote:
>> For i386 specifically, this allows using the host GCC
>> to compile the i386 tests.  But, it should really be
>> done for all targets, unless we want to pass $(EXTRA_CFLAGS)
>> directly as part of $(CC).
> Hmm well for softmmu the tests take the decision:
> 
>   # For softmmu targets we include a different Makefile fragement as the
>   # build options for bare programs are usually pretty different. They
>   # are expected to provide their own build recipes.
> 
> So we are not expecting to handle multi-classing the system compiler to
> generate different binaries with a common build string.

We almost do, since we have

case "$cpu" in
    i386)
           CPU_CFLAGS="-m32"
           LDFLAGS="-m32 $LDFLAGS"
           cross_cc_i386=$cc
           cross_cc_cflags_i386="$CPU_CFLAGS"

So you can compile with "./configure --cpu=i386" and have it use "gcc
-m32" as a cross compiler on x86_64, also for TCG tests.  So it seemed
half-baked to me.

> To be honest I
> wonder if we should just drop the EXTRA_CFLAGS shenanigans in favour of
> an explicit compiler per target?

I don't know.  I think supporting "gcc -m32" on x86_64 is a good idea
though.  Yet another possibility is to use "--cross-cc-i386='gcc -m32'"
directly, but that would be a separate patch.  For these I really wanted
to have no semantic change.

Paolo


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

* Re: [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script
  2019-07-30 12:37 ` [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script Paolo Bonzini
  2019-08-07 12:42   ` Alex Bennée
@ 2019-08-07 13:10   ` Alex Bennée
  2019-08-07 13:26     ` Paolo Bonzini
  1 sibling, 1 reply; 20+ messages in thread
From: Alex Bennée @ 2019-08-07 13:10 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


Paolo Bonzini <pbonzini@redhat.com> writes:

> Avoid the repeated inclusions of config-target.mak, which have
> risks of namespace pollution, and instead build minimal configuration
> files in a configuration script.  The same configuration files can
> also be included in Makefile and Makefile.qemu
>
<snip>
>  if [ "$fdt" = "git" ]; then
>    echo "config-host.h: dtc/all" >> $config_host_mak
>  fi
> @@ -7923,15 +7799,14 @@ fi
>  # so the build tree will be missing the link back to the new file, and
>  # tests might fail. Prefer to keep the relevant files in their own
>  # directory and symlink the directory instead.
> -DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
> +DIRS="tests tests/tcg tests/tcg/lm32 tests/libqos tests/qapi-schema tests/qemu-iotests tests/vm"
>  DIRS="$DIRS tests/fp tests/qgraph"
>  DIRS="$DIRS docs docs/interop fsdev scsi"
>  DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
>  DIRS="$DIRS roms/seabios roms/vgabios"
> -LINKS="Makefile tests/tcg/Makefile"
> -LINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
> -LINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
> -LINKS="$LINKS tests/fp/Makefile"
> +LINKS="Makefile"
> +LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
> +LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"

Is this why I get complaints on a clean tree:


  libpmem support   no
  libudev           yes
  default devices   yes
  /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 179: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
  /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 180: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
  /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 183: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
  /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 184: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
  /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 193: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
  /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 213: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
  /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 179: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-arm-linux-user.mak: Directory nonexist
  ...


>  LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
>  LINKS="$LINKS pc-bios/spapr-rtas/Makefile"
>  LINKS="$LINKS pc-bios/s390-ccw/Makefile"
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 8bb5c97..a3ee649 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -1058,30 +1058,28 @@ BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS))
>  CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TARGET_DIRS))
>  RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
>
> -ifeq ($(HAVE_USER_DOCKER),y)
>  # Probe for the Docker Builds needed for each build
>  $(foreach PROBE_TARGET,$(TARGET_DIRS), 				\
>  	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
> -endif
>
>  build-tcg-tests-%:
>  	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>  		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
>  		SRC_PATH=$(SRC_PATH) \
> -	       	V="$(V)" TARGET_DIR="$*/" guest-tests, \
> +	       	V="$(V)" TARGET="$*" guest-tests, \
>  		"BUILD", "TCG tests for $*")
>
>  run-tcg-tests-%: build-tcg-tests-% %/all
>  	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>  		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
>  		SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
> -		V="$(V)" TARGET_DIR="$*/" run-guest-tests, \
> +		V="$(V)" TARGET="$*" run-guest-tests, \
>  		"RUN", "TCG tests for $*")
>
>  clean-tcg-tests-%:
>  	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>  		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
> -		SRC_PATH=$(SRC_PATH) TARGET_DIR="$*/" clean-guest-tests, \
> +		SRC_PATH=$(SRC_PATH) TARGET="$*" clean-guest-tests, \
>  		"RUN", "TCG tests for $*")
>
>  .PHONY: build-tcg
> diff --git a/tests/tcg/Makefile.prereqs b/tests/tcg/Makefile.prereqs
> index 53b0196..7494b31 100644
> --- a/tests/tcg/Makefile.prereqs
> +++ b/tests/tcg/Makefile.prereqs
> @@ -7,24 +7,12 @@
>  # selection of required docker targets before we invoke a sub-make for
>  # each target.
>
> -# First we need the target makefile which tells us the target architecture
> -CROSS_CC_GUEST:=
> --include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
> -
> -# Then we load up the target architecture makefiles which tell us
> -# about the compilers
>  DOCKER_IMAGE:=
>
> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
> --include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
> +-include $(BUILD_DIR)/tests/tcg/config-$(PROBE_TARGET).mak
>
> -ifndef CROSS_CC_GUEST
>  ifneq ($(DOCKER_IMAGE),)
>  build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE)
> +$(BUILD_DIR)/tests/tcg/config_$(PROBE_TARGET).mak: config-host.mak
> +config-host.mak: $(SRC_PATH)/tests/tcg/configure.sh
>  endif
> -endif
> -
> -# Clean-up
> -# undefine TARGET_NAME
> -# undefine TARGET_BASE_ARCH
> -# undefine TARGET_ABI_DIR
> diff --git a/tests/tcg/Makefile.qemu b/tests/tcg/Makefile.qemu
> index d3f3437..c8bec7b 100644
> --- a/tests/tcg/Makefile.qemu
> +++ b/tests/tcg/Makefile.qemu
> @@ -8,17 +8,22 @@
>  # to do it for us.
>  #
>
> -# The per ARCH makefile, if it exists, holds extra information about
> +include $(SRC_PATH)/rules.mak
> +
> +# The configure script fills in extra information about
>  # useful docker images or alternative compiler flags.
>
> -include $(TARGET_DIR)config-target.mak
> -include $(SRC_PATH)/rules.mak
> -include $(wildcard \
> -	$(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
> -	$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
> +CROSS_CC_GUEST:=
> +DOCKER_IMAGE:=
> +-include $(BUILD_DIR)/tests/tcg/config-$(TARGET).mak
>
>  GUEST_BUILD=
>  TCG_MAKE=../Makefile.target
> +
> +# We also need the Docker make rules to depend on
> +SKIP_DOCKER_BUILD=1
> +include $(SRC_PATH)/tests/docker/Makefile.include
> +
>  # Support installed Cross Compilers
>
>  ifdef CROSS_CC_GUEST
> @@ -26,11 +31,11 @@ ifdef CROSS_CC_GUEST
>  .PHONY: cross-build-guest-tests
>  cross-build-guest-tests:
>  	$(call quiet-command, \
> -	   (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
> -	    $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \
> +	   (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
> +	    $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
>  			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
> -			EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \

I expect given we need config-FOO.mak files before that these mkdir's are in the wrong place.

<snip>

Otherwise I think this is going in the right direction.

--
Alex Bennée


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

* Re: [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions
  2019-08-07 13:05   ` Alex Bennée
@ 2019-08-07 13:11     ` Paolo Bonzini
  0 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2019-08-07 13:11 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel

On 07/08/19 15:05, Alex Bennée wrote:
> So this looses the ability to run:
> 
>   make run-guest-tests
> 
> in any given build directory. It would be useful to have a target that
> could still get us there.

There's "make run-tcg-tests-TARGET" (from the toplevel directory).

Paolo

>>  config-target.h: config-target.h-timestamp
>>  config-target.h-timestamp: config-target.mak
>>
>> diff --git a/tests/Makefile.include b/tests/Makefile.include
>> index fd7fdb8..8bb5c97 100644
>> --- a/tests/Makefile.include
>> +++ b/tests/Makefile.include
>> @@ -1061,23 +1061,28 @@ RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
>>  ifeq ($(HAVE_USER_DOCKER),y)
>>  # Probe for the Docker Builds needed for each build
>>  $(foreach PROBE_TARGET,$(TARGET_DIRS), 				\
>> -	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.probe) 	\
>> -	$(if $(DOCKER_PREREQ), 					\
>> -		$(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ))))
>> +	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
>>  endif
>>
>>  build-tcg-tests-%:
>> -	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
>> -		SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" guest-tests, \
>> +	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>> +		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
>> +		SRC_PATH=$(SRC_PATH) \
>> +	       	V="$(V)" TARGET_DIR="$*/" guest-tests, \
>>  		"BUILD", "TCG tests for $*")
>>
>> -run-tcg-tests-%: % build-tcg-tests-%
>> -	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
>> -		SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" run-guest-tests, \
>> +run-tcg-tests-%: build-tcg-tests-% %/all
>> +	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>> +		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
>> +		SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
>> +		V="$(V)" TARGET_DIR="$*/" run-guest-tests, \
>>  		"RUN", "TCG tests for $*")
>>
>>  clean-tcg-tests-%:
>> -	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,)
>> +	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>> +		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
>> +		SRC_PATH=$(SRC_PATH) TARGET_DIR="$*/" clean-guest-tests, \
>> +		"RUN", "TCG tests for $*")
>>
>>  .PHONY: build-tcg
>>  build-tcg: $(BUILD_TCG_TARGET_RULES)
>> diff --git a/tests/tcg/Makefile.probe b/tests/tcg/Makefile.prereqs
>> similarity index 92%
>> rename from tests/tcg/Makefile.probe
>> rename to tests/tcg/Makefile.prereqs
>> index 9dc6546..53b0196 100644
>> --- a/tests/tcg/Makefile.probe
>> +++ b/tests/tcg/Makefile.prereqs
>> @@ -8,20 +8,19 @@
>>  # each target.
>>
>>  # First we need the target makefile which tells us the target architecture
>> +CROSS_CC_GUEST:=
>>  -include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
>>
>>  # Then we load up the target architecture makefiles which tell us
>>  # about the compilers
>> -CROSS_CC_GUEST:=
>>  DOCKER_IMAGE:=
>> -DOCKER_PREREQ:=
>>
>>  -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
>>  -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>>
>>  ifndef CROSS_CC_GUEST
>>  ifneq ($(DOCKER_IMAGE),)
>> -DOCKER_PREREQ:=docker-image-$(DOCKER_IMAGE)
>> +build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE)
>>  endif
>>  endif
>>
>> diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.qemu
>> similarity index 52%
>> rename from tests/tcg/Makefile.include
>> rename to tests/tcg/Makefile.qemu
>> index 73b5626..d3f3437 100644
>> --- a/tests/tcg/Makefile.include
>> +++ b/tests/tcg/Makefile.qemu
>> @@ -2,20 +2,23 @@
>>  #
>>  # TCG tests (per-target rules)
>>  #
>> -# This Makefile fragment is included from the per-target
>> -# Makefile.target so will be invoked for each linux-user program we
>> -# build. We have two options for compiling, either using a configured
>> -# guest compiler or calling one of our docker images to do it for us.
>> +# This Makefile fragment is included from the build-tcg target, once
>> +# for each target we build. We have two options for compiling, either
>> +# using a configured guest compiler or calling one of our docker images
>> +# to do it for us.
>>  #
>>
>>  # The per ARCH makefile, if it exists, holds extra information about
>>  # useful docker images or alternative compiler flags.
>>
>> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
>> --include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>> +include $(TARGET_DIR)config-target.mak
>> +include $(SRC_PATH)/rules.mak
>> +include $(wildcard \
>> +	$(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
>> +	$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
>>
>>  GUEST_BUILD=
>> -TCG_MAKE=$(SRC_PATH)/tests/tcg/Makefile
>> +TCG_MAKE=../Makefile.target
>>  # Support installed Cross Compilers
>>
>>  ifdef CROSS_CC_GUEST
>> @@ -23,9 +26,9 @@ ifdef CROSS_CC_GUEST
>>  .PHONY: cross-build-guest-tests
>>  cross-build-guest-tests:
>>  	$(call quiet-command, \
>> -	   (mkdir -p tests && cd tests && \
>> -	    $(MAKE) -f $(TCG_MAKE) CC=$(CROSS_CC_GUEST) \
>> -			BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
>> +	   (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
>> +	    $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \
>> +			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
>>  			EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \
>>  	"BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
>>
>> @@ -39,20 +42,20 @@ ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
>>  ifneq ($(DOCKER_IMAGE),)
>>
>>  # We also need the Docker make rules to depend on
>> +SKIP_DOCKER_BUILD=1
>>  include $(SRC_PATH)/tests/docker/Makefile.include
>>
>>  DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
>>  		--cc $(DOCKER_CROSS_COMPILER) \
>>  		-i qemu:$(DOCKER_IMAGE) \
>>  		-s $(SRC_PATH) -- "
>> -DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
>>
>>  .PHONY: docker-build-guest-tests
>> -docker-build-guest-tests: $(DOCKER_PREREQ)
>> +docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
>>  	$(call quiet-command, \
>> -	  (mkdir -p tests && cd tests && \
>> -	   $(MAKE) -f $(TCG_MAKE) CC=$(DOCKER_COMPILE_CMD) \
>> -			BUILD_STATIC=y \
>> +	  (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
>> +	   $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC=$(DOCKER_COMPILE_CMD) \
>> +			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
>>  			EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \
>>  	"BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
>>
>> @@ -62,27 +65,32 @@ endif
>>  endif
>>
>>  # Final targets
>> +all:
>> +	@echo "Do not invoke this Makefile directly"; exit 1
>> +
>>  .PHONY: guest-tests
>>
>>  ifneq ($(GUEST_BUILD),)
>>  guest-tests: $(GUEST_BUILD)
>>
>> -run-guest-tests: guest-tests qemu-$(subst y,system-,$(CONFIG_SOFTMMU))$(TARGET_NAME)
>> +run-guest-tests: guest-tests
>>  	$(call quiet-command, \
>> -	(cd tests && $(MAKE) -f $(TCG_MAKE) SPEED=$(SPEED) run), \
>> +	(cd tests/tcg/$(TARGET_DIR) && \
>> +	 $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" \
>> +	 		SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
>>  	"RUN", "tests for $(TARGET_NAME)")
>>
>>  else
>>  guest-tests:
>>  	$(call quiet-command, /bin/true, "BUILD", \
>> -		"$(TARGET_NAME) guest-tests SKIPPED")
>> +		"$(TARGET_DIR) guest-tests SKIPPED")
>>
>>  run-guest-tests:
>>  	$(call quiet-command, /bin/true, "RUN", \
>> -		"tests for $(TARGET_NAME) SKIPPED")
>> +		"tests for $(TARGET_DIR) SKIPPED")
>>  endif
>>
>>  # It doesn't matter if these don't exits
>>  .PHONY: clean-guest-tests
>>  clean-guest-tests:
>> -	rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
>> +	rm -rf tests/tcg/$(TARGET_DIR)
>> diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile.target
>> similarity index 92%
>> rename from tests/tcg/Makefile
>> rename to tests/tcg/Makefile.target
>> index 9f56768..8dbcba4 100644
>> --- a/tests/tcg/Makefile
>> +++ b/tests/tcg/Makefile.target
>> @@ -29,8 +29,9 @@
>>  # We also expect to be in the tests build dir for the FOO-(linux-user|softmmu).
>>  #
>>
>> +all:
>>  -include ../../config-host.mak
>> --include ../config-target.mak
>> +-include ../../../$(TARGET_DIR)/config-target.mak
>>
>>  # for including , in command strings
>>  COMMA := ,
>> @@ -64,9 +65,9 @@ LDFLAGS=
>>
>>  # The QEMU for this TARGET
>>  ifdef CONFIG_USER_ONLY
>> -QEMU=../qemu-$(TARGET_NAME)
>> +QEMU=../../../$(TARGET_DIR)/qemu-$(TARGET_NAME)
>>  else
>> -QEMU=../qemu-system-$(TARGET_NAME)
>> +QEMU=../../../$(TARGET_DIR)/qemu-system-$(TARGET_NAME)
>>  endif
>>  QEMU_OPTS=
>>
>> @@ -82,10 +83,7 @@ ifdef CONFIG_USER_ONLY
>>  # The order we include is important. We include multiarch, base arch
>>  # and finally arch if it's not the same as base arch.
>>  -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
>> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target
>> -ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
>>  -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
>> -endif
> 
> Comment above needs fixing up.
> 
>>
>>  # Add the common build options
>>  CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
>> @@ -101,10 +99,7 @@ else
>>  # are expected to provide their own build recipes.
>>  -include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
>>  -include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
>> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.softmmu-target
>> -ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
>>  -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
>> -endif
>>
>>  endif
>>
>> diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
>> index 31ba9cf..e763dd9 100644
>> --- a/tests/tcg/aarch64/Makefile.target
>> +++ b/tests/tcg/aarch64/Makefile.target
>> @@ -2,12 +2,14 @@
>>  #
>>  # AArch64 specific tweaks
>>
>> +ARM_SRC=$(SRC_PATH)/tests/tcg/arm
>> +VPATH 		+= $(ARM_SRC)
>> +
>>  AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
>>  VPATH 		+= $(AARCH64_SRC)
>>
>> -# we don't build any of the ARM tests
>> -AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS))
>> -AARCH64_TESTS+=fcvt
>> +# we don't build any other ARM test
>> +AARCH64_TESTS=fcvt
>>
>>  fcvt: LDFLAGS+=-lm
>>
>> @@ -16,6 +18,6 @@ run-fcvt: fcvt
>>  	$(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref)
>>
>>  AARCH64_TESTS += pauth-1 pauth-2
>> -run-pauth-%: QEMU += -cpu max
>> +run-pauth-%: QEMU_OPTS += -cpu max
>>
>> -TESTS:=$(AARCH64_TESTS)
>> +TESTS += $(AARCH64_TESTS)
>> diff --git a/tests/tcg/arm/Makefile.softmmu-target b/tests/tcg/arm/Makefile.softmmu-target
>> index 2deb06e..231e9a5 100644
>> --- a/tests/tcg/arm/Makefile.softmmu-target
>> +++ b/tests/tcg/arm/Makefile.softmmu-target
>> @@ -3,8 +3,6 @@
>>  # ARM SoftMMU tests - included from tests/tcg/Makefile
>>  #
>>
>> -ifeq ($(TARGET_ABI_DIR),arm)
>> -
>>  ARM_SRC=$(SRC_PATH)/tests/tcg/arm
>>
>>  # Set search path for all sources
>> @@ -25,5 +23,3 @@ LDFLAGS+=-nostdlib -N -static
>>  test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0
>>
>>  run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel
>> -
>> -endif
>> diff --git a/tests/tcg/i386/Makefile.softmmu-target b/tests/tcg/i386/Makefile.softmmu-target
>> index cee3420..1c8790e 100644
>> --- a/tests/tcg/i386/Makefile.softmmu-target
>> +++ b/tests/tcg/i386/Makefile.softmmu-target
>> @@ -12,17 +12,9 @@ X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
>>  # These objects provide the basic boot code and helper functions for all tests
>>  CRT_OBJS=boot.o
>>
>> -ifeq ($(TARGET_X86_64), y)
>> -CRT_PATH=$(X64_SYSTEM_SRC)
>> -CFLAGS=-march=x86-64
>> -LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
>> -LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
>> -else
>>  CRT_PATH=$(I386_SYSTEM_SRC)
>> -CFLAGS+=-m32
>>  LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld
>>  LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386
>> -endif
>>  CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
>>  LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
>>
>> diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
>> index d0eb702..08c5736 100644
>> --- a/tests/tcg/i386/Makefile.target
>> +++ b/tests/tcg/i386/Makefile.target
>> @@ -6,14 +6,11 @@ I386_SRC=$(SRC_PATH)/tests/tcg/i386
>>  VPATH 		+= $(I386_SRC)
>>
>>  I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c))
>> -I386_TESTS=$(I386_SRCS:.c=)
>> -I386_ONLY_TESTS=$(filter-out test-i386-ssse3, $(I386_TESTS))
>> +ALL_X86_TESTS=$(I386_SRCS:.c=)
>> +I386_TESTS:=$(filter-out test-i386-ssse3, $(ALL_X86_TESTS))
>> +X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS))
>>  # Update TESTS
>> -TESTS+=$(I386_ONLY_TESTS)
>> -
>> -ifneq ($(TARGET_NAME),x86_64)
>> -CFLAGS+=-m32
>> -endif
>> +TESTS=$(MULTIARCH_TESTS) $(I386_TESTS)
>>
>>  #
>>  # hello-i386 is a barebones app
>> @@ -26,7 +23,7 @@ hello-i386: LDFLAGS+=-nostdlib
>>  #
>>
>>  test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386-shift.h test-i386-muldiv.h
>> -	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
>> +	$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ \
>>  	   $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
>>
>>  ifeq ($(SPEED), slow)
>> diff --git a/tests/tcg/x86_64/Makefile.softmmu-target b/tests/tcg/x86_64/Makefile.softmmu-target
>> new file mode 100644
>> index 0000000..df252e7
>> --- /dev/null
>> +++ b/tests/tcg/x86_64/Makefile.softmmu-target
>> @@ -0,0 +1,36 @@
>> +#
>> +# x86 system tests
>> +#
>> +# This currently builds only for i386. The common C code is built
>> +# with standard compiler flags however so we can support both by
>> +# adding additional boot files for x86_64.
>> +#
>> +
>> +I386_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/i386/system
> 
> I think this is redundant now...
> 
>> +X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
>> +
>> +# These objects provide the basic boot code and helper functions for all tests
>> +CRT_OBJS=boot.o
>> +
>> +CRT_PATH=$(X64_SYSTEM_SRC)
>> +LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
>> +LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
>> +CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
>> +LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
>> +
>> +TESTS+=$(MULTIARCH_TESTS)
>> +
>> +# building head blobs
>> +.PRECIOUS: $(CRT_OBJS)
>> +
>> +%.o: $(CRT_PATH)/%.S
>> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
>> +
>> +# Build and link the tests
>> +%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
>> +	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
>> +
>> +memory: CFLAGS+=-DCHECK_UNALIGNED=1
>> +
>> +# Running
>> +QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel
>> diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target
>> index 74f170b..20bf962 100644
>> --- a/tests/tcg/x86_64/Makefile.target
>> +++ b/tests/tcg/x86_64/Makefile.target
>> @@ -6,9 +6,10 @@
>>  # $(SRC)/tests/tcg/i386/
>>  #
>>
>> -X86_64_TESTS=$(filter-out $(I386_ONLY_TESTS), $(TESTS))
>> -X86_64_TESTS+=test-x86_64
>> -TESTS:=$(X86_64_TESTS)
>> +include $(SRC_PATH)/tests/tcg/i386/Makefile.target
>> +
>> +TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
>> +QEMU_OPTS += -cpu max
>>
>>  test-x86_64: LDFLAGS+=-lm -lc
>>  test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h
> 
> 
> --
> Alex Bennée
> 



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

* Re: [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script
  2019-08-07 13:10   ` Alex Bennée
@ 2019-08-07 13:26     ` Paolo Bonzini
  0 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2019-08-07 13:26 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel

On 07/08/19 15:10, Alex Bennée wrote:
>> -DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
>> +DIRS="tests tests/tcg tests/tcg/lm32 tests/libqos tests/qapi-schema tests/qemu-iotests tests/vm"
>>  DIRS="$DIRS tests/fp tests/qgraph"
>>  DIRS="$DIRS docs docs/interop fsdev scsi"
>>  DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
>>  DIRS="$DIRS roms/seabios roms/vgabios"
>> -LINKS="Makefile tests/tcg/Makefile"
>> -LINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
>> -LINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
>> -LINKS="$LINKS tests/fp/Makefile"
>> +LINKS="Makefile"
>> +LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
>> +LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
> 
> Is this why I get complaints on a clean tree:
> 
>   libpmem support   no
>   libudev           yes
>   default devices   yes
>   /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 179: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
>   /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 180: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
>   /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 183: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
>   /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 184: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
>   /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 193: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
>   /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 213: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-aarch64-linux-user.mak: Directory nonexistent
>   /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: 179: /home/alex/lsrc/qemu.git/tests/tcg/configure.sh: cannot create tests/tcg/config-arm-linux-user.mak: Directory nonexist

configure.sh is invoked too early.

> 
> 
>>  LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
>>  LINKS="$LINKS pc-bios/spapr-rtas/Makefile"
>>  LINKS="$LINKS pc-bios/s390-ccw/Makefile"
>> diff --git a/tests/Makefile.include b/tests/Makefile.include
>> index 8bb5c97..a3ee649 100644
>> --- a/tests/Makefile.include
>> +++ b/tests/Makefile.include
>> @@ -1058,30 +1058,28 @@ BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS))
>>  CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TARGET_DIRS))
>>  RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
>>
>> -ifeq ($(HAVE_USER_DOCKER),y)
>>  # Probe for the Docker Builds needed for each build
>>  $(foreach PROBE_TARGET,$(TARGET_DIRS), 				\
>>  	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
>> -endif
>>
>>  build-tcg-tests-%:
>>  	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>>  		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
>>  		SRC_PATH=$(SRC_PATH) \
>> -	       	V="$(V)" TARGET_DIR="$*/" guest-tests, \
>> +	       	V="$(V)" TARGET="$*" guest-tests, \
>>  		"BUILD", "TCG tests for $*")
>>
>>  run-tcg-tests-%: build-tcg-tests-% %/all
>>  	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>>  		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
>>  		SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
>> -		V="$(V)" TARGET_DIR="$*/" run-guest-tests, \
>> +		V="$(V)" TARGET="$*" run-guest-tests, \
>>  		"RUN", "TCG tests for $*")
>>
>>  clean-tcg-tests-%:
>>  	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
>>  		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
>> -		SRC_PATH=$(SRC_PATH) TARGET_DIR="$*/" clean-guest-tests, \
>> +		SRC_PATH=$(SRC_PATH) TARGET="$*" clean-guest-tests, \
>>  		"RUN", "TCG tests for $*")
>>
>>  .PHONY: build-tcg
>> diff --git a/tests/tcg/Makefile.prereqs b/tests/tcg/Makefile.prereqs
>> index 53b0196..7494b31 100644
>> --- a/tests/tcg/Makefile.prereqs
>> +++ b/tests/tcg/Makefile.prereqs
>> @@ -7,24 +7,12 @@
>>  # selection of required docker targets before we invoke a sub-make for
>>  # each target.
>>
>> -# First we need the target makefile which tells us the target architecture
>> -CROSS_CC_GUEST:=
>> --include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
>> -
>> -# Then we load up the target architecture makefiles which tell us
>> -# about the compilers
>>  DOCKER_IMAGE:=
>>
>> --include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
>> --include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
>> +-include $(BUILD_DIR)/tests/tcg/config-$(PROBE_TARGET).mak
>>
>> -ifndef CROSS_CC_GUEST
>>  ifneq ($(DOCKER_IMAGE),)
>>  build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE)
>> +$(BUILD_DIR)/tests/tcg/config_$(PROBE_TARGET).mak: config-host.mak
>> +config-host.mak: $(SRC_PATH)/tests/tcg/configure.sh
>>  endif
>> -endif
>> -
>> -# Clean-up
>> -# undefine TARGET_NAME
>> -# undefine TARGET_BASE_ARCH
>> -# undefine TARGET_ABI_DIR
>> diff --git a/tests/tcg/Makefile.qemu b/tests/tcg/Makefile.qemu
>> index d3f3437..c8bec7b 100644
>> --- a/tests/tcg/Makefile.qemu
>> +++ b/tests/tcg/Makefile.qemu
>> @@ -8,17 +8,22 @@
>>  # to do it for us.
>>  #
>>
>> -# The per ARCH makefile, if it exists, holds extra information about
>> +include $(SRC_PATH)/rules.mak
>> +
>> +# The configure script fills in extra information about
>>  # useful docker images or alternative compiler flags.
>>
>> -include $(TARGET_DIR)config-target.mak
>> -include $(SRC_PATH)/rules.mak
>> -include $(wildcard \
>> -	$(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
>> -	$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
>> +CROSS_CC_GUEST:=
>> +DOCKER_IMAGE:=
>> +-include $(BUILD_DIR)/tests/tcg/config-$(TARGET).mak
>>
>>  GUEST_BUILD=
>>  TCG_MAKE=../Makefile.target
>> +
>> +# We also need the Docker make rules to depend on
>> +SKIP_DOCKER_BUILD=1
>> +include $(SRC_PATH)/tests/docker/Makefile.include
>> +
>>  # Support installed Cross Compilers
>>
>>  ifdef CROSS_CC_GUEST
>> @@ -26,11 +31,11 @@ ifdef CROSS_CC_GUEST
>>  .PHONY: cross-build-guest-tests
>>  cross-build-guest-tests:
>>  	$(call quiet-command, \
>> -	   (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
>> -	    $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \
>> +	   (mkdir -p tests/tcg/$(TARGET) && cd tests/tcg/$(TARGET) && \
>> +	    $(MAKE) -f $(TCG_MAKE) TARGET="$(TARGET)" CC="$(CROSS_CC_GUEST)" \
>>  			SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
>> -			EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \
> 
> I expect given we need config-FOO.mak files before that these mkdir's are in the wrong place.

These are mkdirs for tests/tcg/FOO, but I do need to add mkdir -p
tests/tcg to the configure.sh script.

Paolo


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

* Re: [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
  2019-08-07 13:06   ` Paolo Bonzini
@ 2019-08-07 13:33     ` Eric Blake
  2019-08-07 14:30       ` Paolo Bonzini
  0 siblings, 1 reply; 20+ messages in thread
From: Eric Blake @ 2019-08-07 13:33 UTC (permalink / raw)
  To: Paolo Bonzini, Alex Bennée; +Cc: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 1379 bytes --]

On 8/7/19 8:06 AM, Paolo Bonzini wrote:
> On 07/08/19 14:40, Alex Bennée wrote:
>>
>> Paolo Bonzini <pbonzini@redhat.com> writes:
>>
>>> The tests/tcg rely a lot on per-target informations from
>>> the QEMU makefiles, but most of the definitions in there
>>> aren't really relevant to TCG tests.
>>>
>>> This series is just a cleanup, but it could also be
>>> a useful start in making it possible to compile tests/tcg
>>> out of QEMU's tree, and/or making it a submodule, and/or
>>> unifying the system emulation tests with kvm-unit-tests.
>>
>> Hmm something is throwing off configure and making it use my login shell
>> instead of /bin/sh:
>>
>>   libpmem support   no
>>   libudev           yes
>>   default devices   yes
>>   ~/lsrc/qemu.git/tests/tcg/configure.sh (line 63): 'case' builtin not inside of switch block
>>     case $arch in
>>     ^
>>   <W> fish: Error while reading file /home/alex/lsrc/qemu.git/tests/tcg/configure.sh
> 
> It's the ${SHELL} you found in patch 3.  The disadvantage of relying on
> #! is that some people have bash in /usr/bin/bash rather than /bin/bash.
>  But we already assume /bin/bash elsewhere so I can drop it.

Rather, we use '#!/usr/bin/env bash' to find bash anywhere.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
  2019-08-07 13:33     ` Eric Blake
@ 2019-08-07 14:30       ` Paolo Bonzini
  2019-08-07 16:38         ` Alex Bennée
  0 siblings, 1 reply; 20+ messages in thread
From: Paolo Bonzini @ 2019-08-07 14:30 UTC (permalink / raw)
  To: Eric Blake, Alex Bennée; +Cc: qemu-devel

On 07/08/19 15:33, Eric Blake wrote:
> On 8/7/19 8:06 AM, Paolo Bonzini wrote:
>> On 07/08/19 14:40, Alex Bennée wrote:
>>>
>>> Paolo Bonzini <pbonzini@redhat.com> writes:
>>>
>>>> The tests/tcg rely a lot on per-target informations from
>>>> the QEMU makefiles, but most of the definitions in there
>>>> aren't really relevant to TCG tests.
>>>>
>>>> This series is just a cleanup, but it could also be
>>>> a useful start in making it possible to compile tests/tcg
>>>> out of QEMU's tree, and/or making it a submodule, and/or
>>>> unifying the system emulation tests with kvm-unit-tests.
>>>
>>> Hmm something is throwing off configure and making it use my login shell
>>> instead of /bin/sh:
>>>
>>>   libpmem support   no
>>>   libudev           yes
>>>   default devices   yes
>>>   ~/lsrc/qemu.git/tests/tcg/configure.sh (line 63): 'case' builtin not inside of switch block
>>>     case $arch in
>>>     ^
>>>   <W> fish: Error while reading file /home/alex/lsrc/qemu.git/tests/tcg/configure.sh
>>
>> It's the ${SHELL} you found in patch 3.  The disadvantage of relying on
>> #! is that some people have bash in /usr/bin/bash rather than /bin/bash.
>>  But we already assume /bin/bash elsewhere so I can drop it.
> 
> Rather, we use '#!/usr/bin/env bash' to find bash anywhere.

Nevermind - this script is pure Bourne shell.  The only fix needed should be

diff --git a/configure b/configure
index eeeda8760a..f216f3f9d9 100755
--- a/configure
+++ b/configure
@@ -6468,12 +6468,6 @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
   echo "warning: Python 3 will be required for building future versions of QEMU" >&2
 fi
 
-(for i in $cross_cc_vars; do
-  export $i
-done
-export target_list source_path
-${SHELL-/bin/sh} $source_path/tests/tcg/configure.sh)
-
 config_host_mak="config-host.mak"
 
 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
@@ -7844,6 +7838,12 @@ for f in $LINKS ; do
     fi
 done
 
+(for i in $cross_cc_vars; do
+  export $i
+done
+export target_list source_path
+$source_path/tests/tcg/configure.sh)
+
 # temporary config to build submodules
 for rom in seabios vgabios ; do
     config_mak=roms/$rom/config.mak


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

* Re: [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
  2019-08-07 14:30       ` Paolo Bonzini
@ 2019-08-07 16:38         ` Alex Bennée
  2019-08-07 16:58           ` Paolo Bonzini
  0 siblings, 1 reply; 20+ messages in thread
From: Alex Bennée @ 2019-08-07 16:38 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


Paolo Bonzini <pbonzini@redhat.com> writes:

> On 07/08/19 15:33, Eric Blake wrote:
>> On 8/7/19 8:06 AM, Paolo Bonzini wrote:
>>> On 07/08/19 14:40, Alex Bennée wrote:
>>>>
>>>> Paolo Bonzini <pbonzini@redhat.com> writes:
>>>>
>>>>> The tests/tcg rely a lot on per-target informations from
>>>>> the QEMU makefiles, but most of the definitions in there
>>>>> aren't really relevant to TCG tests.
>>>>>
>>>>> This series is just a cleanup, but it could also be
>>>>> a useful start in making it possible to compile tests/tcg
>>>>> out of QEMU's tree, and/or making it a submodule, and/or
>>>>> unifying the system emulation tests with kvm-unit-tests.
>>>>
>>>> Hmm something is throwing off configure and making it use my login shell
>>>> instead of /bin/sh:
>>>>
>>>>   libpmem support   no
>>>>   libudev           yes
>>>>   default devices   yes
>>>>   ~/lsrc/qemu.git/tests/tcg/configure.sh (line 63): 'case' builtin not inside of switch block
>>>>     case $arch in
>>>>     ^
>>>>   <W> fish: Error while reading file /home/alex/lsrc/qemu.git/tests/tcg/configure.sh
>>>
>>> It's the ${SHELL} you found in patch 3.  The disadvantage of relying on
>>> #! is that some people have bash in /usr/bin/bash rather than /bin/bash.
>>>  But we already assume /bin/bash elsewhere so I can drop it.
>>
>> Rather, we use '#!/usr/bin/env bash' to find bash anywhere.
>
> Nevermind - this script is pure Bourne shell.  The only fix needed
> should be

I thought we wanted to use pure POSIX shell and not rely on bash-ism's
creeping in?

>
> diff --git a/configure b/configure
> index eeeda8760a..f216f3f9d9 100755
> --- a/configure
> +++ b/configure
> @@ -6468,12 +6468,6 @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
>    echo "warning: Python 3 will be required for building future versions of QEMU" >&2
>  fi
>
> -(for i in $cross_cc_vars; do
> -  export $i
> -done
> -export target_list source_path
> -${SHELL-/bin/sh} $source_path/tests/tcg/configure.sh)
> -
>  config_host_mak="config-host.mak"
>
>  echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
> @@ -7844,6 +7838,12 @@ for f in $LINKS ; do
>      fi
>  done
>
> +(for i in $cross_cc_vars; do
> +  export $i
> +done
> +export target_list source_path
> +$source_path/tests/tcg/configure.sh)
> +

I also had chmod +x the script.

>  # temporary config to build submodules
>  for rom in seabios vgabios ; do
>      config_mak=roms/$rom/config.mak


--
Alex Bennée


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

* Re: [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles
  2019-08-07 16:38         ` Alex Bennée
@ 2019-08-07 16:58           ` Paolo Bonzini
  0 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2019-08-07 16:58 UTC (permalink / raw)
  To: Alex Bennée; +Cc: qemu-devel

On 07/08/19 18:38, Alex Bennée wrote:
>>> Rather, we use '#!/usr/bin/env bash' to find bash anywhere.
>> Nevermind - this script is pure Bourne shell.  The only fix needed
>> should be
> I thought we wanted to use pure POSIX shell and not rely on bash-ism's
> creeping in?
> 

There are uses of bash as long as it's marked as such (and not /bin/sh).
 But Bourne shell = /bin/sh, bash is the "Bourne-again" shell. :)

Paolo


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

end of thread, other threads:[~2019-08-07 16:59 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30 12:37 [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles Paolo Bonzini
2019-07-30 12:37 ` [Qemu-devel] [PATCH 1/3] tests/tcg: use EXTRA_CFLAGS everywhere Paolo Bonzini
2019-08-07 12:51   ` Alex Bennée
2019-08-07 13:10     ` Paolo Bonzini
2019-07-30 12:37 ` [Qemu-devel] [PATCH 2/3] tests/tcg: cleanup Makefile inclusions Paolo Bonzini
2019-07-30 12:44   ` Philippe Mathieu-Daudé
2019-07-30 13:21     ` Paolo Bonzini
2019-08-07 13:05   ` Alex Bennée
2019-08-07 13:11     ` Paolo Bonzini
2019-07-30 12:37 ` [Qemu-devel] [PATCH 3/3] tests/tcg: move configuration to a sub-shell script Paolo Bonzini
2019-08-07 12:42   ` Alex Bennée
2019-08-07 13:10   ` Alex Bennée
2019-08-07 13:26     ` Paolo Bonzini
2019-07-30 12:53 ` [Qemu-devel] [PATCH 0/3] tests/tcg: disentangle makefiles no-reply
2019-08-07 12:40 ` Alex Bennée
2019-08-07 13:06   ` Paolo Bonzini
2019-08-07 13:33     ` Eric Blake
2019-08-07 14:30       ` Paolo Bonzini
2019-08-07 16:38         ` Alex Bennée
2019-08-07 16:58           ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.