Skip to contentSkip to conversation

compilation issues of qemu, sparc64-bsd-user and OpenbSD

Qemu-devel Mikolaj Kucharski 3 participants 9 messages Apr 9, 2009 – Apr 10, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Please see attached file for ./configure output.

gmake[1]: Entering directory `/var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/sparc64-bsd-user'
CC sparc64-bsd-user/cpu-exec.o
/var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c: In function `cpu_sparc_signal_handler':
/var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1189: error: structure has no member named uc_mcontext' /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1189: error: EIP' undeclared (first use in this function) /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1189: error: (Each undeclared identifier is reported only once /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1189: error: for each function it appears in.) /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1190: error: structure has no member named uc_mcontext' /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1190: error: TRAPNO' undeclared (first use in this function) /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1193: error: structure has no member named uc_mcontext' /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1193: error: ERR' undeclared (first use in this function) /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1194: error: structure has no member named `uc_sigmask' gmake[1]: *** [cpu-exec.o] Error 1
gmake[1]: Leaving directory `/var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2/sparc64-bsd-user'
gmake: *** [subdir-sparc64-bsd-user] Error 2
*** Error code 2

# sysctl -n kern.version
OpenBSD 4.5 (GENERIC) #1749: Sat Feb 28 14:51:18 MST 2009
    [email protected]:/usr/src/sys/arch/i386/compile/GENERIC
Signature · 2 lines
best regards
q#

Thu Apr 9 01:50:45 IST 2009
===> Verifying update for texi2html-* in textproc/texi2html ===> Returning to build of qemu-0.10.2
===> qemu-0.10.2 depends on: texi2html-* - found ===> Verifying update for gmake-* in devel/gmake ===> Returning to build of qemu-0.10.2
===> qemu-0.10.2 depends on: gmake-* - found
===> Verifying update for sdl-* in devel/sdl
===> Returning to build of qemu-0.10.2

===>  qemu-0.10.2 depends on: sdl-* - found
===>  Verifying specs: SDL SDL c m ossaudio z pthread c m ossaudio z pthread
===>  found SDL.8.0 c.50.1 m.5.0 ossaudio.3.1 z.4.1 pthread.11.1
===>  Checking files for qemu-0.10.2

`/usr/ports/distfiles/qemu-0.10.2.tar.gz' is up to date.

Quoted 1 line
Quoted 1 line

(SHA256) qemu-0.10.2.tar.gz: OK

===>  Extracting for qemu-0.10.2
===>  Patching for qemu-0.10.2
===>  Configuring for qemu-0.10.2
Install prefix    /usr/local
BIOS directory    /usr/local/share/qemu
binary directory  /usr/local/bin
Manual directory  /usr/local/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path       /var/tmp/port-obj/qemu-0.10.2/qemu-0.10.2
C compiler        cc
Host C compiler   cc
ARCH_CFLAGS       -m32
make              gmake
install           install
host CPU          i386
host big endian   no
target list       i386-softmmu x86_64-softmmu arm-softmmu cris-softmmu m68k-softmmu mips-softmmu mipsel-softmmu mips64-softmmu mips64el-softmmu ppc-softmmu ppcemb-softmmu ppc64-softmmu sh4-softmmu sh4eb-softmmu sparc-softmmu sparc64-bsd-user 
gprof enabled     no
sparse enabled    no
profiler          no
static build      no
-Werror enabled   no
SDL support       yes
SDL static link   no
curses support    yes
mingw32 support   no
Audio drivers     oss
Extra audio cards ac97 es1370 sb16
Mixer emulation   no
VNC TLS support   no
kqemu support     no
brlapi support    no
Documentation     yes
NPTL support      no
vde support       no
AIO support       yes
Install blobs     yes
KVM support       no
fdt support       no

The error log from compiling the libSDL test is:
/usr/X11R6/lib/libXau.so.9.0: warning: strcpy() is almost always misused, please use strlcpy() /usr/X11R6/lib/libXau.so.9.0: warning: strcat() is almost always misused, please use strlcat() /usr/X11R6/lib/libX11.so.11.1: warning: sprintf() is often misused, please use snprintf() 0
Thu Apr 9 01:51:24 IST 2009

#1 lore raw
Quoted 8 lines · Mikolaj Kucharski

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Please see attached file for ./configure output.

Does the attached patch help? I don't have an OpenBSD/i386 machine.

cpu-exec.c +12 -1
Index: qemu/cpu-exec.c
===================================================================
@@ -1165,17 +1165,28 @@
 # define EIP_sig(context)  (*((unsigned long*)&(context)->uc_mcontext->ss.eip))
 # define TRAP_sig(context)    ((context)->uc_mcontext->es.trapno)
 # define ERROR_sig(context)   ((context)->uc_mcontext->es.err)
+# define MASK_sig(context)    ((context)->uc_sigmask)
+#elif defined(__OpenBSD__)
+# define EIP_sig(context)     ((context)->sc_eip)
+# define TRAP_sig(context)    ((context)->sc_trapno)
+# define ERROR_sig(context)   ((context)->sc_err)
+# define MASK_sig(context)    ((context)->sc_mask)
 #else
 # define EIP_sig(context)     ((context)->uc_mcontext.gregs[REG_EIP])
 # define TRAP_sig(context)    ((context)->uc_mcontext.gregs[REG_TRAPNO])
 # define ERROR_sig(context)   ((context)->uc_mcontext.gregs[REG_ERR])
+# define MASK_sig(context)    ((context)->uc_sigmask)
 #endif
 
 int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
+#if defined(__OpenBSD__)
+    struct sigcontext *uc = puc;
+#else
     struct ucontext *uc = puc;
+#endif
     unsigned long pc;
     int trapno;
 
@@ -1190,7 +1201,7 @@
     return handle_cpu_signal(pc, (unsigned long)info->si_addr,
                              trapno == 0xe ?
                              (ERROR_sig(uc) >> 1) & 1 : 0,
-                             &uc->uc_sigmask, puc);
+                             &MASK_sig(uc), puc);
 }
 
 #elif defined(__x86_64__)
#2 lore raw
Quoted 11 lines · Blue Swirl
Quoted 8 lines · Mikolaj Kucharski

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Please see attached file for ./configure output.

Does the attached patch help? I don't have an OpenBSD/i386 machine.

Yes, that fixed compilation problem. I would like to be notified when your patch (or different fix for issue in this thread) get commited to revision repository. Thank you.

Signature · 2 lines
best regards
q#
#6 lore raw
In reply to Blue Swirl
Quoted 11 lines · Blue Swirl
Quoted 8 lines · Mikolaj Kucharski

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Please see attached file for ./configure output.

Does the attached patch help? I don't have an OpenBSD/i386 machine.

This helps with this one partiular issue but there is still the issue of the PowerPC targets being broken as I had already pointed out on the list.

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#7 lore raw
Quoted 9 lines · On Thursday 09 April 2009 20:24:48 Brad wrote:
Quoted 8 lines · Blue Swirl
Quoted 7 lines · Mikolaj Kucharski

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Please see attached file for ./configure output.

Does the attached patch help? I don't have an OpenBSD/i386 machine.

This helps with this one partiular issue but there is still the issue of the PowerPC targets being broken as I had already pointed out on the list.

Actually it still does not build on amd64..

gmake[1]: Entering directory `/usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/sparc64-bsd-user'
CC sparc64-bsd-user/cpu-exec.o
In file included
from /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/target-sparc/exec.h:13,

from /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:22:
/usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/target-sparc/cpu.h: In function `cpu_clone_regs':
/usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/target-sparc/cpu.h:493:
warning: implicit declaration of function printf' /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c: In function cpu_sparc_signal_handler':
/usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1222: error:
dereferencing pointer to incomplete type /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1222: error:
`REG_RIP' undeclared (first use in this function) /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1222: error:
(Each undeclared identifier is reported only once /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1222: error:
for each function it appears in.) /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1224: error:
dereferencing pointer to incomplete type /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1224: error:
`REG_TRAPNO' undeclared (first use in this function) /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1225: error:
dereferencing pointer to incomplete type /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1225: error:
`REG_ERR' undeclared (first use in this function) /usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/cpu-exec.c:1226: error:
dereferencing pointer to incomplete type
gmake[1]: *** [cpu-exec.o] Error 1
gmake[1]: Leaving directory `/usr/ports/emulators/qemu/w-qemu-0.10.2/qemu-0.10.2/sparc64-bsd-user'

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#8 lore raw
Quoted 12 lines · Brad
Quoted 11 lines · On Thursday 09 April 2009 20:24:48 Brad wrote:
Quoted 10 lines · Blue Swirl
Quoted 8 lines · Mikolaj Kucharski

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Please see attached file for ./configure output.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Does the attached patch help? I don't have an OpenBSD/i386 machine.

This helps with this one partiular issue but there is still the issue of the PowerPC targets being broken as I had already pointed out on the list.

Actually it still does not build on amd64..

For that another patch is needed, please test.

cpu-exec.c +19 -11
Index: qemu/cpu-exec.c
===================================================================
@@ -1207,14 +1207,20 @@
 #elif defined(__x86_64__)
 
 #ifdef __NetBSD__
-#define REG_ERR _REG_ERR
-#define REG_TRAPNO _REG_TRAPNO
-
-#define QEMU_UC_MCONTEXT_GREGS(uc, reg)	(uc)->uc_mcontext.__gregs[(reg)]
-#define QEMU_UC_MACHINE_PC(uc)		_UC_MACHINE_PC(uc)
+#define PC_sig(context)       _UC_MACHINE_PC(context)
+#define TRAP_sig(context)     ((context)->uc_mcontext.__gregs[_REG_TRAPNO])
+#define ERROR_sig(context)    ((context)->uc_mcontext.__gregs[_REG_ERR])
+#define MASK_sig(context)     ((context)->uc_sigmask)
+#elif defined(__OpenBSD__)
+#define PC_sig(context)       ((context)->sc_rip)
+#define TRAP_sig(context)     ((context)->sc_trapno)
+#define ERROR_sig(context)    ((context)->sc_err)
+#define MASK_sig(context)     ((context)->sc_mask)
 #else
-#define QEMU_UC_MCONTEXT_GREGS(uc, reg)	(uc)->uc_mcontext.gregs[(reg)]
-#define QEMU_UC_MACHINE_PC(uc)		QEMU_UC_MCONTEXT_GREGS(uc, REG_RIP)
+#define PC_sig(context)       ((context)->uc_mcontext.gregs[REG_RIP])
+#define TRAP_sig(context)     ((context)->uc_mcontext.gregs[REG_TRAPNO])
+#define ERROR_sig(context)    ((context)->uc_mcontext.gregs[REG_ERR])
+#define MASK_sig(context)     ((context)->uc_sigmask)
 #endif
 
 int cpu_signal_handler(int host_signum, void *pinfo,
@@ -1224,15 +1230,17 @@
     unsigned long pc;
 #ifdef __NetBSD__
     ucontext_t *uc = puc;
+#elif defined(__OpenBSD__)
+    struct sigcontext *uc = puc;
 #else
     struct ucontext *uc = puc;
 #endif
 
-    pc = QEMU_UC_MACHINE_PC(uc);
+    pc = PC_sig(uc);
     return handle_cpu_signal(pc, (unsigned long)info->si_addr,
-                             QEMU_UC_MCONTEXT_GREGS(uc, REG_TRAPNO) == 0xe ?
-                             (QEMU_UC_MCONTEXT_GREGS(uc, REG_ERR) >> 1) & 1 : 0,
-                             &uc->uc_sigmask, puc);
+                             TRAP_sig(uc) == 0xe ?
+                             (ERROR_sig(uc) >> 1) & 1 : 0,
+                             &MASK_sig(uc), puc);
 }
 
 #elif defined(_ARCH_PPC)
#3 lore raw
In reply to Mikolaj Kucharski
Quoted 9 lines · Mikolaj Kucharski
Quoted 8 lines · Blue Swirl
Quoted 7 lines · Mikolaj Kucharski

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Please see attached file for ./configure output.

Does the attached patch help? I don't have an OpenBSD/i386 machine.

Yes, that fixed compilation problem. I would like to be notified
when your patch (or different fix for issue in this thread) get commited to revision repository. Thank you.

I've committed the patch to development branch as r7065, thanks for testing.

This is not a bug fix, so I guess it doesn't qualify for the stable branch.

#4 lore raw
Quoted 12 lines · On Friday 10 April 2009 03:34:48 Blue Swirl wrote:
Quoted 11 lines · Mikolaj Kucharski
Quoted 10 lines · Blue Swirl
Quoted 8 lines · Mikolaj Kucharski

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and
I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Please see attached file for ./configure output.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Does the attached patch help? I don't have an OpenBSD/i386 machine.

Yes, that fixed compilation problem. I would like to be notified
when your patch (or different fix for issue in this thread) get commited to revision repository. Thank you.

I've committed the patch to development branch as r7065, thanks for testing.

I will also have powerpc tested as a host since that is the 4th architecture we currently support for the OpenBSD QEMU port (so far -- I'd like to look into adding support for alpha and sparc64 after updating to 0.10.2).

Signature · 3 lines
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
#5 lore raw
Quoted 19 lines · Brad
Quoted 18 lines · On Friday 10 April 2009 03:34:48 Blue Swirl wrote:
Quoted 16 lines · Mikolaj Kucharski
Quoted 11 lines · Blue Swirl
Quoted 8 lines · Mikolaj Kucharski

Hi,

I'm trying to compile qemu-0.10.2 on OpenBSD 4.5 (pre-release) and
I have following issue with sparc64-bsd-user target. Everythine else compiles, when I use --target-list and select all targets except sparc64-bsd-user.

Please see attached file for ./configure output.

Does the attached patch help? I don't have an OpenBSD/i386 machine.

Yes, that fixed compilation problem. I would like to be notified
when your patch (or different fix for issue in this thread) get commited to revision repository. Thank you.

Quoted 7 lines
Quoted 2 lines

I've committed the patch to development branch as r7065, thanks for testing.

I will also have powerpc tested as a host since that is the 4th architecture
we currently support for the OpenBSD QEMU port (so far -- I'd like to look into adding support for alpha and sparc64 after updating to 0.10.2).

Maybe this patch helps? I'm not sure about TRAP_sig(), it should contain the exception number and while sc_frame.exc sounds like that, I can't find from OpenBSD sources where it's used.

cpu-exec.c +14 -1
Index: qemu/cpu-exec.c
===================================================================
@@ -1267,6 +1267,7 @@
 # define DAR_sig(context)			REG_sig(dar, context)
 # define DSISR_sig(context)			REG_sig(dsisr, context)
 # define TRAP_sig(context)			REG_sig(trap, context)
+# define MASK_sig(context)                      ((context)->uc_sigmask)
 #endif /* linux */
 
 #ifdef __APPLE__
@@ -1292,13 +1293,25 @@
 # define DAR_sig(context)			EXCEPREG_sig(dar, context)     /* Fault registers for coredump */
 # define DSISR_sig(context)			EXCEPREG_sig(dsisr, context)
 # define TRAP_sig(context)			EXCEPREG_sig(exception, context) /* number of powerpc exception taken */
+# define MASK_sig(context)                      ((context)->uc_sigmask)
 #endif /* __APPLE__ */
 
+#if defined(__OpenBSD__)
+# define IAR_sig(context)                       ((context)->sc_frame.srr0)
+# define DSISR_sig(context)                     ((context)->sc_frame.dsisr)
+# define TRAP_sig(context)                      ((context)->sc_frame.exc)
+# define MASK_sig(context)                      ((context)->sc_mask)
+#endif
+
 int cpu_signal_handler(int host_signum, void *pinfo,
                        void *puc)
 {
     siginfo_t *info = pinfo;
+#if defined(__OpenBSD__)
+    struct sigcontext *uc = puc;
+#else
     struct ucontext *uc = puc;
+#endif
     unsigned long pc;
     int is_write;
 
@@ -1313,7 +1326,7 @@
         is_write = 1;
 #endif
     return handle_cpu_signal(pc, (unsigned long)info->si_addr,
-                             is_write, &uc->uc_sigmask, puc);
+                             is_write, &MASK_sig(uc), puc);
 }
 
 #elif defined(__alpha__)