More tests/tcg cleanups
Subsystems (2)
cover More tests/tcg cleanups
Building on the introduction of config-$target.mak, make tests/tcg a "regular" subdirectory that is entered simply with "make -C", like the ROMs or the plugins.
The next step could be to unify all the sub-make rules; this series stops short of that.
Paolo
Paolo Bonzini (7):
meson: put cross compiler info in a separate section
build: include pc-bios/ part in the ROMS variable
configure: allow more host/target combos to use the host compiler
configure: move tests/tcg/Makefile.prereqs to root build directory
configure: store container engine in config-host.mak
tests: simplify Makefile invocation for tests/tcg tests/tcg: remove -f from Makefile invocation
Makefile | 17 +++---- configure | 90 +++++++++++++++++++++-------------- meson.build | 15 +++--- tests/Makefile.include | 13 ++--- tests/docker/Makefile.include | 2 +- tests/tcg/Makefile.target | 2 +- 6 files changed, 77 insertions(+), 62 deletions(-)
Signature · 1 line
2.36.1
PATCH 1/7 meson: put cross compiler info in a separate section
While at it, remove a dead assignment and simply inline the value of the "target" variable, which is used just once.
--- meson.build | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
meson.build +9 -6
@@ -3740,21 +3740,24 @@ endif summary_info += {'strip binaries': get_option('strip')} summary_info += {'sparse': sparse} summary_info += {'mingw32 support': targetos == 'windows'} +summary(summary_info, bool_yn: true, section: 'Compilation') # snarf the cross-compilation information for tests +summary_info = {} +have_cross = false foreach target: target_dirs tcg_mak = meson.current_build_dir() / 'tests/tcg' / 'config-' + target + '.mak' if fs.exists(tcg_mak) config_cross_tcg = keyval.load(tcg_mak) - target = config_cross_tcg['TARGET_NAME'] - compiler = '' if 'CC' in config_cross_tcg - summary_info += {target + ' tests': config_cross_tcg['CC']} + summary_info += {config_cross_tcg['TARGET_NAME']: config_cross_tcg['CC']} + have_cross = true endif - endif + endif endforeach - -summary(summary_info, bool_yn: true, section: 'Compilation') +if have_cross + summary(summary_info, bool_yn: true, section: 'Cross compilers') +endif # Targets and accelerators summary_info = {}
Signature · 1 line
2.36.1
PATCH 2/7 build: include pc-bios/ part in the ROMS variable
In reply to Paolo BonziniInclude the full path in TARGET_DIR, so that messages from sub-Makefiles are clearer. Also, prepare for possibly building firmware outside pc-bios/ from the Makefile,
--- Makefile | 12 +++++------- configure | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-)
Makefile +5 -7
@@ -186,16 +186,14 @@ include $(SRC_PATH)/tests/Makefile.include all: recurse-all -ROM_DIRS = $(addprefix pc-bios/, $(ROMS)) -ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS))) -# Only keep -O and -g cflags -.PHONY: $(ROM_DIRS_RULES) -$(ROM_DIRS_RULES): +ROMS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROMS))) +.PHONY: $(ROMS_RULES) +$(ROMS_RULES): $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),) .PHONY: recurse-all recurse-clean -recurse-all: $(addsuffix /all, $(ROM_DIRS)) -recurse-clean: $(addsuffix /clean, $(ROM_DIRS)) +recurse-all: $(addsuffix /all, $(ROMS)) +recurse-clean: $(addsuffix /clean, $(ROMS)) ######################################################################
configure +3 -3
@@ -2242,7 +2242,7 @@ if test -n "$target_cc" && fi done if test -n "$ld_i386_emulation"; then - roms="optionrom" + roms="pc-bios/optionrom" config_mak=pc-bios/optionrom/config.mak echo "# Automatically generated by configure - do not modify" > $config_mak echo "TOPSRC_DIR=$source_path" >> $config_mak
@@ -2253,7 +2253,7 @@ fi probe_target_compilers ppc ppc64 if test -n "$target_cc" && test "$softmmu" = yes; then - roms="$roms vof" + roms="$roms pc-bios/vof" config_mak=pc-bios/vof/config.mak echo "# Automatically generated by configure - do not modify" > $config_mak echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
@@ -2272,7 +2272,7 @@ if test -n "$target_cc" && test "$softmmu" = yes; then echo "WARNING: Your compiler does not support the z900!" echo " The s390-ccw bios will only work with guest CPUs >= z10." fi - roms="$roms s390-ccw" + roms="$roms pc-bios/s390-ccw" config_mak=pc-bios/s390-ccw/config-host.mak echo "# Automatically generated by configure - do not modify" > $config_mak echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
Signature · 1 line
2.36.1
PATCH 3/7 configure: allow more host/target combos to use the host compiler
In reply to Paolo BonziniDo not require a cross-compiler prefix for e.g. i386 on x86_64, or big endian on little endian.
--- configure | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
configure +21 -13
@@ -2058,19 +2058,27 @@ probe_target_compiler() { compute_target_variable $1 target_objcopy objcopy compute_target_variable $1 target_ranlib ranlib compute_target_variable $1 target_strip strip - if test "$1" = $cpu; then - : ${target_cc:=$cc} - : ${target_ccas:=$ccas} - : ${target_as:=$as} - : ${target_ld:=$ld} - : ${target_ar:=$ar} - : ${target_as:=$as} - : ${target_ld:=$ld} - : ${target_nm:=$nm} - : ${target_objcopy:=$objcopy} - : ${target_ranlib:=$ranlib} - : ${target_strip:=$strip} - fi + case "$1:$cpu" in + aarch64:aarch64_be | aarch64_be:aarch64 | \ + arm:armeb | armeb:arm | \ + i386:x86_64 | \ + ppc:ppc64* | \ + ppc64*:ppc64* | \ + sparc:sparc64 | \ + "$cpu:$cpu") + : ${target_cc:=$cc} + : ${target_ccas:=$ccas} + : ${target_as:=$as} + : ${target_ld:=$ld} + : ${target_ar:=$ar} + : ${target_as:=$as} + : ${target_ld:=$ld} + : ${target_nm:=$nm} + : ${target_objcopy:=$objcopy} + : ${target_ranlib:=$ranlib} + : ${target_strip:=$strip} + ;; + esac if test -n "$target_cc"; then case $1 in i386|x86_64)
Signature · 1 line
2.36.1
PATCH 4/7 configure: move tests/tcg/Makefile.prereqs to root build directory
In reply to Paolo BonziniIt will not be specific to tests/tcg anymore once it will be possible to build firmware using container-based cross compilers too. Prepare for that already, after all Makefile.prereqs is not _used_ by tests/tcg.
--- Makefile | 5 ++++- configure | 15 +++++++-------- tests/Makefile.include | 3 --- 3 files changed, 11 insertions(+), 12 deletions(-)
Makefile +4 -1
@@ -42,6 +42,9 @@ configure: ; ifneq ($(wildcard config-host.mak),) include config-host.mak +include Makefile.prereqs +Makefile.prereqs: config-host.mak + git-submodule-update: .git-submodule-status: git-submodule-update config-host.mak Makefile: .git-submodule-status
@@ -216,7 +219,7 @@ qemu-%.tar.bz2: distclean: clean -$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || : - rm -f config-host.mak + rm -f config-host.mak Makefile.prereqs rm -f tests/tcg/config-*.mak rm -f config.status rm -f roms/seabios/config.mak
configure +7 -8
@@ -2126,6 +2126,7 @@ write_target_makefile() { } write_container_target_makefile() { + echo "$1: docker-image-$container_image" >> Makefile.prereqs if test -n "$container_cross_cc"; then echo "CC=\$(DOCKER_SCRIPT) cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" echo "CCAS=\$(DOCKER_SCRIPT) cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
@@ -2234,6 +2235,8 @@ for f in $LINKS ; do fi done +echo "# Automatically generated by configure - do not modify" > Makefile.prereqs + # Mac OS X ships with a broken assembler roms= probe_target_compilers i386 x86_64
@@ -2471,10 +2474,7 @@ if test "$safe_stack" = "yes"; then fi # tests/tcg configuration -(makefile=tests/tcg/Makefile.prereqs -echo "# Automatically generated by configure - do not modify" > $makefile - -config_host_mak=tests/tcg/config-host.mak +(config_host_mak=tests/tcg/config-host.mak echo "# Automatically generated by configure - do not modify" > $config_host_mak echo "SRC_PATH=$source_path" >> $config_host_mak echo "HOST_CC=$host_cc" >> $config_host_mak
@@ -2570,9 +2570,8 @@ for target in $target_list; do ;; esac elif test -n "$container_image"; then - echo "build-tcg-tests-$target: docker-image-$container_image" >> $makefile echo "BUILD_STATIC=y" >> $config_target_mak - write_container_target_makefile >> $config_target_mak + write_container_target_makefile build-tcg-tests-$target >> $config_target_mak case $target in aarch64-*) echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak
@@ -2595,11 +2594,11 @@ for target in $target_list; do mkdir -p tests/tcg/$target echo "QEMU=$PWD/$qemu" >> $config_target_mak echo "EXTRA_CFLAGS=$target_cflags" >> $config_target_mak - echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> $makefile + echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs tcg_tests_targets="$tcg_tests_targets $target" fi done -echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> $makefile) +echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak) if test "$skip_meson" = no; then cross="config-meson.cross.new"
tests/Makefile.include +0 -3
@@ -36,9 +36,6 @@ export SRC_PATH SPEED = quick --include tests/tcg/Makefile.prereqs -tests/tcg/Makefile.prereqs: config-host.mak - # Per guest TCG tests BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TCG_TESTS_TARGETS)) CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TCG_TESTS_TARGETS))
Signature · 1 line
2.36.1
PATCH 5/7 configure: store container engine in config-host.mak
In reply to Paolo BonziniIn preparation for removing $(DOCKER_SCRIPT) from the tests/tcg configuration files, have Make use the same container engine that had been probed at configure time.
--- configure | 11 ++++++++--- tests/docker/Makefile.include | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-)
configure +8 -3
@@ -1819,9 +1819,11 @@ esac container="no" if test $use_containers = "yes"; then - if has "docker" || has "podman"; then - container=$($python $source_path/tests/docker/docker.py probe) - fi + case $($python $source_path/tests/docker/docker.py probe) in + *docker) container=docker ;; + podman) container=podman ;; + no) container=no ;; + esac fi # cross compilers defaults, can be overridden with --cross-cc-ARCH
@@ -2401,6 +2403,9 @@ if test -n "$gdb_bin"; then fi fi +if test "$container" != no; then + echo "ENGINE=$container" >> $config_host_mak +fi echo "ROMS=$roms" >> $config_host_mak echo "MAKE=$make" >> $config_host_mak echo "PYTHON=$python" >> $config_host_mak
tests/docker/Makefile.include +1 -1
@@ -14,7 +14,7 @@ DOCKER_DEFAULT_REGISTRY := registry.gitlab.com/qemu-project/qemu endif DOCKER_REGISTRY := $(if $(REGISTRY),$(REGISTRY),$(DOCKER_DEFAULT_REGISTRY)) -ENGINE := auto +ENGINE ?= auto DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(ENGINE) CUR_TIME := $(shell date +%Y-%m-%d-%H.%M.%S.$$$$)
Signature · 1 line
2.36.1
PATCH 6/7 tests: simplify Makefile invocation for tests/tcg
In reply to Paolo BonziniThe tests/tcg Makefile invocation contains the paths to DOCKER_SCRIPT and TARGET.
One can just resolve the path to docker.py in configure so that submakes do not need the DOCKER_SCRIPT variable. In order to remove the TARGET variable, create a config-target.mak file in tests/tcg/$TARGET. For now config-$target.mak is created before the check for compiler presence, while tests/tcg/$TARGET is created afterwards. This is temporary.
--- configure | 23 ++++++++++++++--------- tests/Makefile.include | 9 +++------ tests/tcg/Makefile.target | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-)
configure +14 -9
@@ -1824,6 +1824,9 @@ if test $use_containers = "yes"; then podman) container=podman ;; no) container=no ;; esac + if test "$container" != "no"; then + docker_py="$python $source_path/tests/docker/docker.py --engine $container" + fi fi # cross compilers defaults, can be overridden with --cross-cc-ARCH
@@ -2130,16 +2133,16 @@ write_target_makefile() { write_container_target_makefile() { echo "$1: docker-image-$container_image" >> Makefile.prereqs if test -n "$container_cross_cc"; then - echo "CC=\$(DOCKER_SCRIPT) cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" - echo "CCAS=\$(DOCKER_SCRIPT) cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" + echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" + echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" fi - echo "AR=\$(DOCKER_SCRIPT) cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --" - echo "AS=\$(DOCKER_SCRIPT) cc --cc $container_cross_as -i qemu/$container_image -s $source_path --" - echo "LD=\$(DOCKER_SCRIPT) cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --" - echo "NM=\$(DOCKER_SCRIPT) cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --" - echo "OBJCOPY=\$(DOCKER_SCRIPT) cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --" - echo "RANLIB=\$(DOCKER_SCRIPT) cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --" - echo "STRIP=\$(DOCKER_SCRIPT) cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --" + echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --" + echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --" + echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --" + echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --" + echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --" + echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --" + echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --" }
@@ -2597,6 +2600,8 @@ for target in $target_list; do fi if test $got_cross_cc = yes; then mkdir -p tests/tcg/$target + ln -sf ../config-$target.mak tests/tcg/$target/config-target.mak + echo "TARGET=$target" >> $config_target_mak echo "QEMU=$PWD/$qemu" >> $config_target_mak echo "EXTRA_CFLAGS=$target_cflags" >> $config_target_mak echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
tests/Makefile.include +3 -6
@@ -47,23 +47,20 @@ $(foreach TARGET,$(TCG_TESTS_TARGETS), \ .PHONY: $(TCG_TESTS_TARGETS:%=build-tcg-tests-%) $(TCG_TESTS_TARGETS:%=build-tcg-tests-%): build-tcg-tests-%: $(BUILD_DIR)/tests/tcg/config-%.mak $(call quiet-command, \ - $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) \ - DOCKER_SCRIPT="$(DOCKER_SCRIPT)" \ - TARGET="$*" SRC_PATH="$(SRC_PATH)", \ + $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS), \ "BUILD","$* guest-tests") .PHONY: $(TCG_TESTS_TARGETS:%=run-tcg-tests-%) $(TCG_TESTS_TARGETS:%=run-tcg-tests-%): run-tcg-tests-%: build-tcg-tests-% $(call quiet-command, \ $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) \ - TARGET="$*" SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run, \ + SPEED=$(SPEED) run, \ "RUN", "$* guest-tests") .PHONY: $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%) $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%): clean-tcg-tests-%: $(call quiet-command, \ - $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) \ - TARGET="$*" SRC_PATH="$(SRC_PATH)" clean, \ + $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) clean, \ "CLEAN", "$* guest-tests") .PHONY: build-tcg
tests/tcg/Makefile.target +1 -1
@@ -31,7 +31,7 @@ all: -include ../config-host.mak --include ../config-$(TARGET).mak +-include config-target.mak # Get semihosting definitions for user-mode emulation ifeq ($(filter %-softmmu, $(TARGET)),)
Signature · 1 line
2.36.1
PATCH 7/7 tests/tcg: remove -f from Makefile invocation
In reply to Paolo BonziniName the symbolic link "Makefile" and place it in the target subdirectory.
--- configure | 3 ++- tests/Makefile.include | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-)
configure +2 -1
@@ -2224,7 +2224,6 @@ fi # tests might fail. Prefer to keep the relevant files in their own # directory and symlink the directory instead. LINKS="Makefile" -LINKS="$LINKS tests/tcg/Makefile.target" LINKS="$LINKS pc-bios/optionrom/Makefile" LINKS="$LINKS pc-bios/s390-ccw/Makefile" LINKS="$LINKS pc-bios/vof/Makefile"
@@ -2483,6 +2482,7 @@ fi # tests/tcg configuration (config_host_mak=tests/tcg/config-host.mak +mkdir -p tests/tcg echo "# Automatically generated by configure - do not modify" > $config_host_mak echo "SRC_PATH=$source_path" >> $config_host_mak echo "HOST_CC=$host_cc" >> $config_host_mak
@@ -2600,6 +2600,7 @@ for target in $target_list; do fi if test $got_cross_cc = yes; then mkdir -p tests/tcg/$target + ln -sf $source_path/tests/tcg/Makefile.target tests/tcg/$target/Makefile ln -sf ../config-$target.mak tests/tcg/$target/config-target.mak echo "TARGET=$target" >> $config_target_mak echo "QEMU=$PWD/$qemu" >> $config_target_mak
tests/Makefile.include +3 -4
@@ -47,20 +47,19 @@ $(foreach TARGET,$(TCG_TESTS_TARGETS), \ .PHONY: $(TCG_TESTS_TARGETS:%=build-tcg-tests-%) $(TCG_TESTS_TARGETS:%=build-tcg-tests-%): build-tcg-tests-%: $(BUILD_DIR)/tests/tcg/config-%.mak $(call quiet-command, \ - $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS), \ + $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS), \ "BUILD","$* guest-tests") .PHONY: $(TCG_TESTS_TARGETS:%=run-tcg-tests-%) $(TCG_TESTS_TARGETS:%=run-tcg-tests-%): run-tcg-tests-%: build-tcg-tests-% $(call quiet-command, \ - $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) \ - SPEED=$(SPEED) run, \ + $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) SPEED=$(SPEED) run, \ "RUN", "$* guest-tests") .PHONY: $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%) $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%): clean-tcg-tests-%: $(call quiet-command, \ - $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) clean, \ + $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) clean, \ "CLEAN", "$* guest-tests") .PHONY: build-tcg
Signature · 1 line
2.36.1
Quoted 1 line · Paolo Bonzini
Building on the introduction of config-$target.mak
Brain fart, or perhaps selective amnesia: building on the removal of Makefile.qemu.
Paolo
Quoted 3 lines
, make tests/tcg a
"regular" subdirectory that is entered simply with "make -C", like the ROMs or the plugins.