configure: TARGET_ARCH cleanups
cover configure: TARGET_ARCH cleanups
We have three variables currently in config-target.h:
- TARGET_ARCH is used to create a unique per-arch symbol, used in #ifdefs. It is also used as a string through config-target.h, but this is almost always wrong.
- TARGET_ARCH2 is the name of the executable (minus the qemu-/qemu-system- prefix); it is not available in config-target.h.
- TARGET_TYPE is an enum but is otherwise the same as TARGET_ARCH2
This series changes all uses of TARGET_ARCH to refer to TARGET_ARCH2 instead (which is renamed to TARGET_NAME). The TARGET_ARCH #define is dropped, only the per-arch symbol remains. TARGET_TYPE is then also removed since it is serialized to the same string if TARGET_NAME is used directly.
Paolo Bonzini (4):
build: rename TARGET_ARCH2 to TARGET_NAME
build: do not use TARGET_ARCH
main: use TARGET_ARCH only for the target-specific #define
build: drop TARGET_TYPE
Makefile.target | 12 ++++++------ arch_init.c | 4 ++-- bsd-user/main.c | 6 +++--- configure | 42 ++++++++++++++++++++---------------------- docs/tracing.txt | 2 +- linux-user/main.c | 6 +++--- qapi-schema.json | 18 +----------------- scripts/create_config | 15 +++++---------- scripts/tracetool.py | 18 +++++++++--------- 9 files changed, 50 insertions(+), 73 deletions(-)
Signature · 1 line
1.8.1.4
PATCH 1/4 build: rename TARGET_ARCH2 to TARGET_NAME
Do not introduce any new use yet.
--- Makefile.target | 6 +++--- configure | 42 +++++++++++++++++++++--------------------- scripts/create_config | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-)
Makefile.target +3 -3
@@ -15,14 +15,14 @@ QEMU_CFLAGS+=-I$(SRC_PATH)/include ifdef CONFIG_USER_ONLY # user emulator name -QEMU_PROG=qemu-$(TARGET_ARCH2) +QEMU_PROG=qemu-$(TARGET_NAME) else # system emulator name ifneq (,$(findstring -mwindows,$(libs_softmmu))) # Terminate program name with a 'w' because the linker builds a windows executable. -QEMU_PROGW=qemu-system-$(TARGET_ARCH2)w$(EXESUF) +QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF) endif # windows executable -QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF) +QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF) endif PROGS=$(QEMU_PROG)
configure +21 -21
107 lines not on this page · raw message
scripts/create_config +1 -1
@@ -87,7 +87,7 @@ case $line in TARGET_ABI_DIR=*) # do nothing ;; - TARGET_ARCH2=*) + TARGET_NAME=*) # do nothing ;; TARGET_DIRS=*)
Signature · 1 line
1.8.1.4
PATCH 2/4 build: do not use TARGET_ARCH
In reply to Paolo BonziniTARGET_ARCH is generally wrong to use, there are better variables provided in config-target.mak. The right one is usually TARGET_NAME (previously TARGET_ARCH2), but for bsd-user we can also use TARGET_ABI_DIR for consistency with linux-user.
--- Makefile.target | 6 +++--- docs/tracing.txt | 2 +- scripts/tracetool.py | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-)
Makefile.target +3 -3
@@ -48,7 +48,7 @@ $(QEMU_PROG).stp: $(SRC_PATH)/trace-events --format=stap \ --backend=$(TRACE_BACKEND) \ --binary=$(bindir)/$(QEMU_PROG) \ - --target-arch=$(TARGET_ARCH) \ + --target-name=$(TARGET_NAME) \ --target-type=$(TARGET_TYPE) \ < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG).stp") else
@@ -95,7 +95,7 @@ endif #CONFIG_LINUX_USER ifdef CONFIG_BSD_USER -QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH) +QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) obj-y += bsd-user/ obj-y += gdbstub.o user-exec.o
@@ -122,7 +122,7 @@ obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o obj-$(CONFIG_NO_XEN) += xen-stub.o # Hardware support -ifeq ($(TARGET_ARCH), sparc64) +ifeq ($(TARGET_NAME), sparc64) obj-y += hw/sparc64/ else obj-y += hw/$(TARGET_BASE_ARCH)/
docs/tracing.txt +1 -1
@@ -225,7 +225,7 @@ probes: scripts/tracetool --dtrace --stap \ --binary path/to/qemu-binary \ --target-type system \ - --target-arch x86_64 \ + --target-name x86_64 \ <trace-events >qemu.stp == Trace event properties ==
scripts/tracetool.py +9 -9
@@ -46,9 +46,9 @@ Options: --check-backend Check if the given backend is valid. --binary <path> Full path to QEMU binary. --target-type <type> QEMU emulator target type ('system' or 'user'). - --target-arch <arch> QEMU emulator target arch. + --target-name <name> QEMU emulator target name. --probe-prefix <prefix> Prefix for dtrace probe names - (default: qemu-<target-type>-<target-arch>).\ + (default: qemu-<target-type>-<target-name>).\ """ % { "script" : _SCRIPT, "backends" : backend_descr,
@@ -66,7 +66,7 @@ def main(args): _SCRIPT = args[0] long_opts = [ "backend=", "format=", "help", "list-backends", "check-backend" ] - long_opts += [ "binary=", "target-type=", "target-arch=", "probe-prefix=" ] + long_opts += [ "binary=", "target-type=", "target-name=", "probe-prefix=" ] try: opts, args = getopt.getopt(args[1:], "", long_opts)
@@ -78,7 +78,7 @@ def main(args): arg_format = "" binary = None target_type = None - target_arch = None + target_name = None probe_prefix = None for opt, arg in opts: if opt == "--help":
@@ -100,8 +100,8 @@ def main(args): binary = arg elif opt == '--target-type': target_type = arg - elif opt == '--target-arch': - target_arch = arg + elif opt == '--target-name': + target_name = arg elif opt == '--probe-prefix': probe_prefix = arg
@@ -122,11 +122,11 @@ def main(args): error_opt("--binary is required for SystemTAP tapset generator") if probe_prefix is None and target_type is None: error_opt("--target-type is required for SystemTAP tapset generator") - if probe_prefix is None and target_arch is None: - error_opt("--target-arch is required for SystemTAP tapset generator") + if probe_prefix is None and target_name is None: + error_opt("--target-name is required for SystemTAP tapset generator") if probe_prefix is None: - probe_prefix = ".".join([ "qemu", target_type, target_arch ]) + probe_prefix = ".".join([ "qemu", target_type, target_name ]) try: tracetool.generate(sys.stdin, arg_format, arg_backend,
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH 2/4] build: do not use TARGET_ARCH
Quoted 4 lines · Paolo Bonzini
TARGET_ARCHis generally wrong to use, there are better variables provided in config-target.mak. The right one is usuallyTARGET_NAME(previouslyTARGET_ARCH2), but for bsd-user we can also useTARGET_ABI_DIRfor consistency with linux-user.
Makefile.target endif #CONFIG_LINUX_USER · line 101
Quoted 9 lines
Makefile.target +1
-1@@ -95,7 +95,7 @@ endif #CONFIG_LINUX_USER ifdef CONFIG_BSD_USER -QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH) +QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) obj-y += bsd-user/ obj-y += gdbstub.o user-exec.o
This part of this patch gave me pause for a moment since for sparc32plus TARGET_ABI_DIR isn't the same as TARGET_ARCH, but bsd-user is only built for i386/x86_64/sparc/sparc64 so this doesn't actually matter.
thanks
-- PMM
PATCH 3/4 main: use TARGET_ARCH only for the target-specific #define
In reply to Paolo BonziniEverything else needs to match the executable name, which is TARGET_NAME.
Before:
$ sh4eb-linux-user/qemu-sh4eb --help
usage: qemu-sh4 [options] program [arguments...]
Linux CPU emulator (compiled for sh4 emulation)After:
$ sh4eb-linux-user/qemu-sh4eb --help
usage: qemu-sh4eb [options] program [arguments...]
Linux CPU emulator (compiled for sh4eb emulation)--- arch_init.c | 2 +- bsd-user/main.c | 6 +++--- configure | 25 +++++++++++++++---------- linux-user/main.c | 6 +++--- scripts/create_config | 13 ++++--------- 5 files changed, 26 insertions(+), 26 deletions(-)
arch_init.c +1 -1
@@ -123,7 +123,7 @@ static struct defconfig_file {bool userconfig; } default_config_files[] = { { CONFIG_QEMU_CONFDIR "/qemu.conf", true }, - { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf", true }, + { CONFIG_QEMU_CONFDIR "/target-" TARGET_NAME ".conf", true }, { NULL }, /* end of list */ };
bsd-user/main.c +3 -3
@@ -670,8 +670,8 @@ void cpu_loop(CPUSPARCState *env)static void usage (void ) { -printf ("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n" -"usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n" +printf ("qemu-" TARGET_NAME " version " QEMU_VERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n" +"usage: qemu-" TARGET_NAME " [options] program [arguments...]\n" "BSD CPU emulator (compiled for %s emulation)\n" "\n" "Standard options:\n"
@@ -706,7 +706,7 @@ static void usage(void)"Note that if you provide several changes to single variable\n" "last change will stay in effect.\n" , -TARGET_ARCH , +TARGET_NAME , interp_prefix, x86_stack_size);exit (1 );
configure +0 -1
@@ -4302,7 +4311,6 @@ upper() { echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]' } -echo "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak target_arch_name="`upper $TARGET_ARCH`" echo "TARGET_$target_arch_name=y" >> $config_target_mak echo "TARGET_NAME=$target_name" >> $config_target_mak
linux-user/main.c +3 -3
@@ -3339,7 +3339,7 @@ static void handle_arg_strace(const char *arg)static void handle_arg_version (const char *arg) { -printf ("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION +printf ("qemu-" TARGET_NAME " version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n" );exit (0 ); }
@@ -3400,8 +3400,8 @@ static void usage(void)int maxarglen;int maxenvlen; -printf ("usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n" -"Linux CPU emulator (compiled for " TARGET_ARCH " emulation)\n" +printf ("usage: qemu-" TARGET_NAME " [options] program [arguments...]\n" +"Linux CPU emulator (compiled for " TARGET_NAME " emulation)\n" "\n" "Options and associated environment variables:\n" "\n" );
scripts/create_config +4 -9
@@ -70,16 +70,10 @@ case $line in value=${line#*=} echo "#define $name $value" ;; - TARGET_ARCH=*) # configuration - target_arch=${line#*=} - echo "#define TARGET_ARCH \"$target_arch\"" - ;; TARGET_BASE_ARCH=*) # configuration target_base_arch=${line#*=} - if [ "$target_base_arch" != "$target_arch" ]; then - base_arch_name=`echo $target_base_arch | LC_ALL=C tr '[a-z]' '[A-Z]'` - echo "#define TARGET_$base_arch_name 1" - fi + base_arch_name=`echo $target_base_arch | LC_ALL=C tr '[a-z]' '[A-Z]'` + echo "#define TARGET_$base_arch_name 1" ;; TARGET_XML_FILES=*) # do nothing
@@ -88,7 +82,8 @@ case $line in # do nothing ;; TARGET_NAME=*) - # do nothing + target_name=${line#*=} + echo "#define TARGET_NAME \"$target_name\"" ;; TARGET_DIRS=*) # do nothing
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH 3/4] main: use TARGET_ARCH only for the target-specific #define
Quoted 27 lines · Paolo Bonzini
Everything else needs to match the executable name, which is
TARGET_NAME.Before:
$ sh4eb-linux-user/qemu-sh4eb --help usage: qemu-sh4 [options] program [arguments...] Linux CPU emulator (compiled for sh4 emulation)After:
$ sh4eb-linux-user/qemu-sh4eb --help usage: qemu-sh4eb [options] program [arguments...] Linux CPU emulator (compiled for sh4eb emulation)Signed-off-by Paolo Bonzini <[email protected]>--- arch_init.c | 2 +- bsd-user/main.c | 6 +++--- configure | 25 +++++++++++++++---------- linux-user/main.c | 6 +++--- scripts/create_config | 13 ++++--------- 5 files changed, 26 insertions(+), 26 deletions(-)arch_init.c +0
-0
arch_init.c static struct defconfig_file { · line 127
Quoted 6 lines
arch_init.c +1
-1@@ -123,7 +123,7 @@ static struct defconfig_file {bool userconfig; } default_config_files[] = { { CONFIG_QEMU_CONFDIR "/qemu.conf", true }, - { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf", true }, + { CONFIG_QEMU_CONFDIR "/target-" TARGET_NAME ".conf", true }, { NULL }, /* end of list */
I note this changes user-visible behaviour since we're now looking for different config files. Doesn't this need to be documented somewhere? Or is it that we can get away with making the change because it is undocumented?
Quoted 9 lines
scripts/create_config +0
-3@@ -70,16 +70,10 @@ case $line in value=${line#*=} echo "#define $name $value" ;; - TARGET_ARCH=*) # configuration - target_arch=${line#*=} - echo "#define TARGET_ARCH \"$target_arch\""
scripts/create_config case $line in · line 77
Quoted 10 lines
scripts/create_config +2
-5- ;; TARGET_BASE_ARCH=*) # configuration target_base_arch=${line#*=} - if [ "$target_base_arch" != "$target_arch" ]; then - base_arch_name=`echo $target_base_arch | LC_ALL=C tr '[a-z]' '[A-Z]'` - echo "#define TARGET_$base_arch_name 1" - fi + base_arch_name=`echo $target_base_arch | LC_ALL=C tr '[a-z]' '[A-Z]'` + echo "#define TARGET_$base_arch_name 1" ;;
This change means that (eg) arm-softmmu/config-target.h now has two lines "#define TARGET_ARM 1", once because config-target.mak has TARGET_ARM=y and once becgaues of TARGET_BASE_ARCH=arm. I guess that's just cosmetic though.
thanks
-- PMM
Re: [Qemu-devel] [PATCH 3/4] main: use TARGET_ARCH only for the target-specific #define
Il 28/05/2013 20:09, Peter Maydell ha scritto:
Quoted 23 lines · Paolo Bonzini
Quoted 22 lines
Everything else needs to match the executable name, which is
TARGET_NAME.Before:
$ sh4eb-linux-user/qemu-sh4eb --help usage: qemu-sh4 [options] program [arguments...] Linux CPU emulator (compiled for sh4 emulation)After:
$ sh4eb-linux-user/qemu-sh4eb --help usage: qemu-sh4eb [options] program [arguments...] Linux CPU emulator (compiled for sh4eb emulation)Signed-off-by Paolo Bonzini <[email protected]>--- arch_init.c | 2 +- bsd-user/main.c | 6 +++--- configure | 25 +++++++++++++++---------- linux-user/main.c | 6 +++--- scripts/create_config | 13 ++++--------- 5 files changed, 26 insertions(+), 26 deletions(-)
Quoted 16 lines
arch_init.c static struct defconfig_file { · line 127
Quoted 11 lines
arch_init.c +1
-1@@ -123,7 +123,7 @@ static struct defconfig_file {bool userconfig; } default_config_files[] = { { CONFIG_QEMU_CONFDIR "/qemu.conf", true }, - { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf", true }, + { CONFIG_QEMU_CONFDIR "/target-" TARGET_NAME ".conf", true }, { NULL }, /* end of list */I note this changes user-visible behaviour since we're now looking for different config files. Doesn't this need to be documented somewhere? Or is it that we can get away with making the change because it is undocumented?
I don't think that is documented, but I can check. The patch needs a respin anyway on top of Alon's systemtap patch (semantic conflict).
Quoted 16 lines
Quoted 16 lines
scripts/create_config +0
-8@@ -70,16 +70,10 @@ case $line in value=${line#*=} echo "#define $name $value" ;; - TARGET_ARCH=*) # configuration - target_arch=${line#*=} - echo "#define TARGET_ARCH \"$target_arch\"" - ;; TARGET_BASE_ARCH=*) # configuration target_base_arch=${line#*=} - if [ "$target_base_arch" != "$target_arch" ]; then - base_arch_name=`echo $target_base_arch | LC_ALL=C tr '[a-z]' '[A-Z]'` - echo "#define TARGET_$base_arch_name 1" - fi
Quoted 8 lines
scripts/create_config case $line in · line 77
Quoted 3 lines
scripts/create_config +2
-0+ base_arch_name=`echo $target_base_arch | LC_ALL=C tr '[a-z]' '[A-Z]'` + echo "#define TARGET_$base_arch_name 1" ;;This change means that (eg)
arm-softmmu/config-target.hnow has two lines "#defineTARGET_ARM1", once because config-target.mak has TARGET_ARM=y and once becgaues of TARGET_BASE_ARCH=arm. I guess that's just cosmetic though.
Yes.
Paolo
PATCH 4/4 build: drop TARGET_TYPE
In reply to Paolo BonziniJust use the TARGET_NAME free string.
--- arch_init.c | 2 +- configure | 1 - qapi-schema.json | 18 +----------------- 3 files changed, 2 insertions(+), 19 deletions(-)
arch_init.c +1 -1
@@ -1094,7 +1094,7 @@ TargetInfo *qmp_query_target(Error **errp) {TargetInfo *info =g_malloc0 (sizeof (*info)); - info->arch =TARGET_TYPE ; + info->arch =g_strdup (TARGET_NAME );return info; }
configure +0 -1
@@ -4314,7 +4314,6 @@ upper() { target_arch_name="`upper $TARGET_ARCH`" echo "TARGET_$target_arch_name=y" >> $config_target_mak echo "TARGET_NAME=$target_name" >> $config_target_mak -echo "TARGET_TYPE=TARGET_TYPE_`upper $target_name`" >> $config_target_mak echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak if [ "$TARGET_ABI_DIR" = "" ]; then TARGET_ABI_DIR=$TARGET_ARCH
qapi-schema.json +1 -17
@@ -3008,22 +3008,6 @@ { 'command': 'query-fdsets', 'returns': ['FdsetInfo'] } ## -# @TargetType -# -# Target CPU emulation type -# -# These parameters correspond to the softmmu binary CPU name that is currently -# running. -# -# Since: 1.2.0 -## -{ 'enum': 'TargetType', - 'data': [ 'alpha', 'arm', 'cris', 'i386', 'lm32', 'm68k', 'microblazeel', - 'microblaze', 'mips64el', 'mips64', 'mipsel', 'mips', 'moxie', - 'or32', 'ppc64', 'ppcemb', 'ppc', 's390x', 'sh4eb', 'sh4', - 'sparc64', 'sparc', 'unicore32', 'x86_64', 'xtensaeb', 'xtensa' ] } - -## # @TargetInfo: # # Information describing the QEMU target.
@@ -3033,7 +3017,7 @@ # Since: 1.2.0 ## { 'type': 'TargetInfo', - 'data': { 'arch': 'TargetType' } } + 'data': { 'arch': 'str' } } ## # @query-target:
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH 4/4] build: drop TARGET_TYPE
Quoted 8 lines · Paolo Bonzini
Just use the
TARGET_NAMEfree string.Signed-off-by Paolo Bonzini <[email protected]>--- arch_init.c | 2 +- configure | 1 - qapi-schema.json | 18 +----------------- 3 files changed, 2 insertions(+), 19 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org