All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification
@ 2013-05-20 17:23 Paolo Bonzini
  2013-05-20 20:57 ` Andreas Färber
  2013-05-20 21:41 ` Eric Blake
  0 siblings, 2 replies; 6+ messages in thread
From: Paolo Bonzini @ 2013-05-20 17:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

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

Paolo Bonzini (4):
  build: rename TARGET_ARCH2 to TARGET_NAME
  build: do not use TARGET_ARCH
  build: 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             | 66 +++++++++++++++++++++++++++------------------------
 docs/tracing.txt      |  2 +-
 linux-user/main.c     |  6 ++---
 qapi-schema.json      | 18 +-------------
 scripts/create_config | 15 ++++--------
 scripts/tracetool.py  | 18 +++++++-------
 9 files changed, 65 insertions(+), 82 deletions(-)

-- 
1.8.1.4

>From a78bf9e9aa5b9948735eccc345cea5bcc4d09836 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 20 May 2013 18:43:00 +0200
Subject: [RFC PATCH 1/4] configure: rename TARGET_ARCH2 to TARGET_NAME

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 Makefile.target       |  6 +++---
 configure             | 42 +++++++++++++++++++++---------------------
 scripts/create_config |  2 +-
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index ce4391f..a55b163 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -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)
diff --git a/configure b/configure
index 5ae7e4a..d2c234e 100755
--- a/configure
+++ b/configure
@@ -4142,10 +4142,10 @@ fi
 for target in $target_list; do
 target_dir="$target"
 config_target_mak=$target_dir/config-target.mak
-target_arch2=`echo $target | cut -d '-' -f 1`
+target_name=`echo $target | cut -d '-' -f 1`
 target_bigendian="no"
 
-case "$target_arch2" in
+case "$target_name" in
   armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
   target_bigendian=yes
   ;;
@@ -4155,17 +4155,17 @@ target_user_only="no"
 target_linux_user="no"
 target_bsd_user="no"
 case "$target" in
-  ${target_arch2}-softmmu)
+  ${target_name}-softmmu)
     target_softmmu="yes"
     ;;
-  ${target_arch2}-linux-user)
+  ${target_name}-linux-user)
     if test "$linux" != "yes" ; then
       error_exit "Target '$target' is only available on a Linux host"
     fi
     target_user_only="yes"
     target_linux_user="yes"
     ;;
-  ${target_arch2}-bsd-user)
+  ${target_name}-bsd-user)
     if test "$bsd" != "yes" ; then
       error_exit "Target '$target' is only available on a BSD host"
     fi
@@ -4183,14 +4183,14 @@ echo "# Automatically generated by configure - do not modify" > $config_target_m
 
 bflt="no"
 target_nptl="no"
-interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
+interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_name/g"`
 gdb_xml_files=""
 
-TARGET_ARCH="$target_arch2"
+TARGET_ARCH="$target_name"
 TARGET_BASE_ARCH=""
 TARGET_ABI_DIR=""
 
-case "$target_arch2" in
+case "$target_name" in
   i386)
   ;;
   x86_64)
@@ -4305,14 +4305,14 @@ upper() {
 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_ARCH2=$target_arch2" >> $config_target_mak
-echo "TARGET_TYPE=TARGET_TYPE_`upper $target_arch2`" >> $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
 fi
 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
-case "$target_arch2" in
+case "$target_name" in
   i386|x86_64)
     if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
       echo "CONFIG_XEN=y" >> $config_target_mak
@@ -4323,24 +4323,24 @@ case "$target_arch2" in
     ;;
   *)
 esac
-case "$target_arch2" in
+case "$target_name" in
   arm|i386|x86_64|ppcemb|ppc|ppc64|s390x)
     # Make sure the target and host cpus are compatible
     if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
-      \( "$target_arch2" = "$cpu" -o \
-      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
-      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
-      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
-      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
-      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
-      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
+      \( "$target_name" = "$cpu" -o \
+      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
+      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
+      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
+      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
+      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
+      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
       echo "CONFIG_KVM=y" >> $config_target_mak
       if test "$vhost_net" = "yes" ; then
         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
       fi
     fi
 esac
-case "$target_arch2" in
+case "$target_name" in
   i386|x86_64)
     echo "CONFIG_HAVE_GET_MEMORY_MAPPING=y" >> $config_target_mak
 esac
@@ -4349,7 +4349,7 @@ if test "$target_bigendian" = "yes" ; then
 fi
 if test "$target_softmmu" = "yes" ; then
   echo "CONFIG_SOFTMMU=y" >> $config_target_mak
-  case "$target_arch2" in
+  case "$target_name" in
     i386|x86_64)
       echo "CONFIG_HAVE_CORE_DUMP=y" >> $config_target_mak
   esac
diff --git a/scripts/create_config b/scripts/create_config
index c471e8c..e52cca1 100755
--- a/scripts/create_config
+++ b/scripts/create_config
@@ -87,7 +87,7 @@ case $line in
  TARGET_ABI_DIR=*)
     # do nothing
     ;;
- TARGET_ARCH2=*)
+ TARGET_NAME=*)
     # do nothing
     ;;
  TARGET_DIRS=*)
-- 
1.8.1.4


>From 93d160c8b82e4524ed89a51822d0b9a9f5f2e382 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 30 Apr 2013 10:36:40 +0200
Subject: [RFC PATCH 2/4] build: do not use TARGET_ARCH

TARGET_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.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 Makefile.target      |  6 +++---
 docs/tracing.txt     |  2 +-
 scripts/tracetool.py | 18 +++++++++---------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index a55b163..c66f03d 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -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)/
diff --git a/docs/tracing.txt b/docs/tracing.txt
index 60ff9c5..bfc261b 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -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 ==
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index a79ec0f..5f4890f 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -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,
-- 
1.8.1.4


>From d0e52781e6e5f6bc50f796212b272d3ae17adf52 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 30 Apr 2013 10:55:02 +0200
Subject: [RFC PATCH 3/4] build: use TARGET_ARCH only for the target-specific
 #define

Everything else needs to match the executable name, which is
in $target_arch2.

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 <pbonzini@redhat.com>
---
 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(-)

diff --git a/arch_init.c b/arch_init.c
index 49c5dc2..22fbe96 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -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 */
 };
 
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 0da3ab9..572f13a 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -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);
diff --git a/configure b/configure
index d2c234e..bbafbac 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/linux-user/main.c b/linux-user/main.c
index b97b8cf..21725a4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -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");
diff --git a/scripts/create_config b/scripts/create_config
index e52cca1..d776927 100755
--- a/scripts/create_config
+++ b/scripts/create_config
@@ -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
-- 
1.8.1.4


>From a707344a471a15c095d9d8c733ddbbfdce693ddb Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 30 Apr 2013 11:18:13 +0200
Subject: [RFC PATCH 4/4] build: drop TARGET_TYPE

Just use the TARGET_NAME free string.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch_init.c      |  2 +-
 configure        |  1 -
 qapi-schema.json | 18 +-----------------
 3 files changed, 2 insertions(+), 19 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index 22fbe96..ebea903 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -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;
 }
diff --git a/configure b/configure
index bbafbac..d6912bd 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/qapi-schema.json b/qapi-schema.json
index 199744a..95ba6a5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -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:
-- 
1.8.1.4

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

* Re: [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification
  2013-05-20 17:23 [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification Paolo Bonzini
@ 2013-05-20 20:57 ` Andreas Färber
  2013-05-20 21:33   ` Peter Maydell
  2013-05-20 21:41 ` Eric Blake
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Färber @ 2013-05-20 20:57 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: peter.maydell, qemu-devel

Am 20.05.2013 19:23, schrieb Paolo Bonzini:
> 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

Add to that

- TARGET_BASE_ARCH in Makefile.target is assumed to be the name of the
target-* subdirectory, but this will not always be desirable.

> 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.

For a long time already I have been carrying the following patch
introducing TARGET_ARCH_DIR:
https://github.com/afaerber/qemu-rl78/commit/9eddd60dae6603235fddf9070c73e5bf65edf292

Still need to rebase that, but it looks as if there are no conflicts
with your series.

TARGET_NAME while a bit invasive is certainly nicer than TARGET_ARCH2,
and dropping TargetType enum makes rebasing/adding new targets easier.

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification
  2013-05-20 20:57 ` Andreas Färber
@ 2013-05-20 21:33   ` Peter Maydell
  2013-05-20 21:45     ` Andreas Färber
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2013-05-20 21:33 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Paolo Bonzini, qemu-devel

On 20 May 2013 21:57, Andreas Färber <afaerber@suse.de> wrote:
> Am 20.05.2013 19:23, schrieb Paolo Bonzini:
> Add to that
>
> - TARGET_BASE_ARCH in Makefile.target is assumed to be the name of the
> target-* subdirectory, but this will not always be desirable.

Isn't it the name of the target-* subdirectory by definition?
(ie we need to be able to set that somehow if you have a subarch
that's piggybacking on another subarch, and this is how we set it).

> For a long time already I have been carrying the following patch
> introducing TARGET_ARCH_DIR:
> https://github.com/afaerber/qemu-rl78/commit/9eddd60dae6603235fddf9070c73e5bf65edf292
>
> Still need to rebase that, but it looks as if there are no conflicts
> with your series.

It seems to me that if you're going to put the source code in
the target-rl78 directory you should make rl78 the
TARGET_BASE_ARCH. Alternatively call the directory target-78k0
if you want the TARGET_BASE_ARCH to be 78k0.

thanks
-- PMM

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

* Re: [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification
  2013-05-20 17:23 [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification Paolo Bonzini
  2013-05-20 20:57 ` Andreas Färber
@ 2013-05-20 21:41 ` Eric Blake
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Blake @ 2013-05-20 21:41 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: peter.maydell, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2373 bytes --]

On 05/20/2013 11:23 AM, Paolo Bonzini wrote:
> 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.

[Ugg - there's no good way to convince Thunderbird to reply to just 4/4,
when you inline everything after your "-- " signoff...]

> +++ b/qapi-schema.json
> @@ -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' } }

No change to the wire format, and being type-safe didn't really add
anything (since a binary only supported a single arch, not the entire
enum of arches).  Chaning now will avoid us being locked into something
once introspection is added (deleting it after we have introspection may
still be possible, but it would be harder to prove that it is not
backwards incompatible at that point).  I'm okay with this deletion.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


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

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

* Re: [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification
  2013-05-20 21:33   ` Peter Maydell
@ 2013-05-20 21:45     ` Andreas Färber
  2013-05-20 22:50       ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Färber @ 2013-05-20 21:45 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Paolo Bonzini, qemu-devel

Am 20.05.2013 23:33, schrieb Peter Maydell:
> On 20 May 2013 21:57, Andreas Färber <afaerber@suse.de> wrote:
>> Am 20.05.2013 19:23, schrieb Paolo Bonzini:
>> Add to that
>>
>> - TARGET_BASE_ARCH in Makefile.target is assumed to be the name of the
>> target-* subdirectory, but this will not always be desirable.
> 
> Isn't it the name of the target-* subdirectory by definition?
> (ie we need to be able to set that somehow if you have a subarch
> that's piggybacking on another subarch, and this is how we set it).

The base architecture is by definition the architecture another one is
basing on. The base architecture's define is present for all derived
ones (e.g., TARGET_PPC for TARGET_PPC64).

>> For a long time already I have been carrying the following patch
>> introducing TARGET_ARCH_DIR:
>> https://github.com/afaerber/qemu-rl78/commit/9eddd60dae6603235fddf9070c73e5bf65edf292
>>
>> Still need to rebase that, but it looks as if there are no conflicts
>> with your series.
> 
> It seems to me that if you're going to put the source code in
> the target-rl78 directory you should make rl78 the
> TARGET_BASE_ARCH. Alternatively call the directory target-78k0
> if you want the TARGET_BASE_ARCH to be 78k0.

I tried that and it is awful for two reasons:
* 78k0 is not a valid identifier in C, so I can't write 78k0_cpu_foo.
* I only care about implementing RL78 but I know it has a documented
base architecture of 78K/0 that I would like to mark up to avoid the
issues we have with implementing older ARM versions after the fact. Ties
in with the topic of whether to autogenerate the default targets.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification
  2013-05-20 21:45     ` Andreas Färber
@ 2013-05-20 22:50       ` Peter Maydell
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2013-05-20 22:50 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Paolo Bonzini, qemu-devel

On 20 May 2013 22:45, Andreas Färber <afaerber@suse.de> wrote:
> Am 20.05.2013 23:33, schrieb Peter Maydell:
>> On 20 May 2013 21:57, Andreas Färber <afaerber@suse.de> wrote:
>>> - TARGET_BASE_ARCH in Makefile.target is assumed to be the name of the
>>> target-* subdirectory, but this will not always be desirable.
>>
>> Isn't it the name of the target-* subdirectory by definition?
>> (ie we need to be able to set that somehow if you have a subarch
>> that's piggybacking on another subarch, and this is how we set it).
>
> The base architecture is by definition the architecture another one is
> basing on. The base architecture's define is present for all derived
> ones (e.g., TARGET_PPC for TARGET_PPC64).

Yes; the architecture you're basing on is the one whose target-foo
directory you're using. That's what using another architecture
as the base architecture means.

Actually, I looked at your code and I couldn't immediately
see why we need two targets at all here. The current in-tree
uses of TARGET_BASE_ARCH are:
 * 64 bit extensions to 32 bit CPUs, so TARGET_LONG_BITS in
   particular needs to be different
 * different ABI variants for linux-user

It looks like both of these cpu families are less-than-32-bit
so maybe we could make them runtime cpu choices in a single
target executable?

>> It seems to me that if you're going to put the source code in
>> the target-rl78 directory you should make rl78 the
>> TARGET_BASE_ARCH. Alternatively call the directory target-78k0
>> if you want the TARGET_BASE_ARCH to be 78k0.
>
> I tried that and it is awful for two reasons:
> * 78k0 is not a valid identifier in C, so I can't write 78k0_cpu_foo.

This is true, but it's going to be a problem to be dealt with
if we care about 78k regardless of how we structure it relative
to rl78.

> * I only care about implementing RL78 but I know it has a documented
> base architecture of 78K/0 that I would like to mark up to avoid the
> issues we have with implementing older ARM versions after the fact.

The problems ARM has with implementing older versions are mostly
that (a) v5-only stuff wasn't explicitly marked when we coded it
(b) v4-only semantics weren't implemented (and to some extent
(c) nobody cares enough about the v4 stuff to do the implementation
and test it). This doesn't have any particular relevance to naming.

The Renesas website seems to say the family name is just '78K', not
'78K0', incidentally.

Two suggestions:
 * call it r78k to go with i386 and m68k
 * just call it rl78 as the "modern" name and have the 78k cores
   be part of that (in the same way that if we implemented a 286
   we'd put it in target-i386)

But I really do think that flipping the base and not-base
names around is going to be confusing. We're in the middle
of this conversation so the concept is fresh in my mind, but
I still read translate.c and thought "why the heck is the rl78
translate.c doing #ifdef TARGET_RL78, that's always true".

thanks
-- PMM

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

end of thread, other threads:[~2013-05-20 22:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-20 17:23 [Qemu-devel] [RFC PATCH 0/4] build: TARGET_ARCH/ARCH2/TYPE simplification Paolo Bonzini
2013-05-20 20:57 ` Andreas Färber
2013-05-20 21:33   ` Peter Maydell
2013-05-20 21:45     ` Andreas Färber
2013-05-20 22:50       ` Peter Maydell
2013-05-20 21:41 ` Eric Blake

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.