On 9/4/26 14:45, Alex Bennée wrote:
From: Pierrick Bouvier <[email protected]>
Tested-by: Aniket Sahu <[email protected]>
Signed-off-by: Pierrick Bouvier <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
diff --git a/tests/tcg/x86_64/Makefile.softmmu-target
b/tests/tcg/x86_64/Makefile.softmmu-target
deleted file mode 100644
index 4e65f58b570..00000000000
--- a/tests/tcg/x86_64/Makefile.softmmu-target
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# x86_64 system tests
-#
-
-X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
-X64_SYSTEM_TESTS=$(patsubst $(X64_SYSTEM_SRC)/%.c, %, $(wildcard
$(X64_SYSTEM_SRC)/*.c))
-
-VPATH+=$(X64_SYSTEM_SRC)
-
-# 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) $(X64_SYSTEM_TESTS)
-EXTRA_RUNS+=$(MULTIARCH_RUNS)
-
-# building head blobs
-.PRECIOUS: $(CRT_OBJS)
-
-%.o: $(CRT_PATH)/%.S
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -Wa,--noexecstack -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
-
-ifeq ($(CONFIG_PLUGIN),y)
-run-plugin-patch-target-with-libpatch.so: \
- PLUGIN_ARGS=$(COMMA)target=ffc0$(COMMA)patch=9090$(COMMA)use_hwaddr=true
-run-plugin-patch-target-with-libpatch.so: \
- CHECK_PLUGIN_OUTPUT_COMMAND=$(X64_SYSTEM_SRC)/validate-patch.py [email protected]
-run-plugin-patch-target-with-libpatch.so: patch-target libpatch.so
-EXTRA_RUNS_WITH_PLUGIN+=run-plugin-patch-target-with-libpatch.so
-endif
diff --git a/tests/tcg/x86_64/meson.build b/tests/tcg/x86_64/meson.build
index 2607a1cbcf4..ab336eca9b2 100644
--- a/tests/tcg/x86_64/meson.build
+++ b/tests/tcg/x86_64/meson.build
@@ -2,6 +2,8 @@ cc = 'x86_64-linux-gnu-gcc'
cc_dockerfile = 'debian-amd64-cross'
cc_docker_host_arch = ['x86_64']
+subdir('system')
+
tests = []
tests += tcg_tests['multiarch-linux-user']['tests']
diff --git a/tests/tcg/x86_64/system/meson.build
b/tests/tcg/x86_64/system/meson.build
new file mode 100644
index 00000000000..80110d0ae57
--- /dev/null
+++ b/tests/tcg/x86_64/system/meson.build
@@ -0,0 +1,63 @@
+tests = []
+
+minilib_dir = meson.current_source_dir() / '..' / '..' / 'minilib'
+minilib_printf = files(minilib_dir / 'printf.c')[0]
+link_script = files('kernel.ld')[0]
+boot = files('boot.S')[0]
+cflags = ['-nostdlib',
+ '-ffreestanding',
+ '-Wa,--noexecstack',
+ '-I', minilib_dir, minilib_printf, boot,
+ '-Wl,-T', link_script,
+ '-Wl,-melf_x86_64',
+ '-Wl,--no-warn-rwx-segments',
+ '-Wl,--build-id=none',
+ '-lgcc']
+qemu_def_args = ['-display', 'none',
+ '-device', 'isa-debugcon,chardev=stdio',
+ '-chardev', 'stdio,id=stdio',
+ '-device', 'isa-debug-exit,iobase=0xf4,iosize=0x4',
+ '-kernel']
+
+# Multi arch tests
+multi_src = []
+foreach t: tcg_tests['multiarch-softmmu']['tests']
+ foreach src, setup: t
+ new_cflags = cflags
+ if fs.stem(src) == 'memory'
+ new_cflags += '-DCHECK_UNALIGNED=1'
+ endif
+ if src not in multi_src
+ setup += {'cflags': [new_cflags]}
+ multi_src += src
+ endif
+ tests += {src: setup + {'qemu_args': qemu_def_args}}
+ endforeach
+endforeach
+
+tests += {
+ 'patch-target.c': {
+ 'cflags': cflags,
+ 'qemu_args': qemu_def_args,
+ 'plugin_test': {
+ 'plugin': 'patch',
+ 'args': ['target=ffc0', 'patch=9090', 'use_hwaddr=true'],
+ },
+ 'wrapper': [prog_check_plugin_output,
+ find_program('./validate-patch.py')]
+ }
+}
+
+if 'qemu-system-x86_64' in emulators
+ tcg_tests += {
+ 'x86_64-softmmu': {
+ 'cc': cc,
+ 'cc_dockerfile': cc_dockerfile,
+ 'cc_docker_host_arch': cc_docker_host_arch,
+ 'folder': 'x86_64/system',
+ 'gdb_arch': 'x86_64',
+ 'qemu': emulators['qemu-system-x86_64'],
+ 'tests': tests,
+ }
+ }
+endif
With this patch I get under Archlinux:
$ make tests/tcg/x86_64-softmmu-hello.test
[1/1] Generating tests/tcg/x86_64-softmmu-hello with a custom command
FAILED: [code=1] tests/tcg/x86_64-softmmu-hello.test
/usr/bin/x86_64-linux-gnu-gcc
qemu/src/tests/tcg/multiarch/system/hello.c -o
tests/tcg/x86_64-softmmu-hello.test -static -MMD -MF
tests/tcg/x86_64-softmmu-hello.d -Wall -Werror -O0 -g
-fno-strict-aliasing -nostdlib -ffreestanding -Wa,--noexecstack -I
qemu/src/tests/tcg/x86_64/system/../../minilib
qemu/src/tests/tcg/x86_64/system/../../minilib/printf.c
../src/tests/tcg/x86_64/system/boot.S -Wl,-T
../src/tests/tcg/x86_64/system/kernel.ld -Wl,-melf_x86_64
-Wl,--no-warn-rwx-segments -Wl,--build-id=none -lgcc
/usr/bin/ld: /tmp/ccRh6mPz.o: in function `print_num':
qemu/src/tests/tcg/x86_64/system/../../minilib/printf.c:45:(.text+0xec):
undefined reference to `__stack_chk_fail'
/usr/bin/ld: /tmp/ccRh6mPz.o: in function `ml_printf':
qemu/src/tests/tcg/x86_64/system/../../minilib/printf.c:136:(.text+0x549):
undefined reference to `__stack_chk_fail'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
make: *** [Makefile:170: run-ninja] Error 1
Reverting this patch I'm able to run `make check` successfully again.
Any idea what might be causing this?
Best regards,
Bernhard