Subject: pkg/36602: qemu does not compile on NetBSD before 4.0
To: None <,,>
From: None <>
List: pkgsrc-bugs
Date: 07/04/2007 02:05:00
>Number:         36602
>Category:       pkg
>Synopsis:       qemu does not compile on NetBSD before 4.0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 04 02:05:00 +0000 2007
>Originator:     Pierre Pronchery
>Release:        NetBSD 4.0_BETA2
System: NetBSD syn.defora.rom 4.0_BETA2 NetBSD 4.0_BETA2 (GENERIC.MP) #9: Tue Jul 3 04:15:02 CEST 2007 khorben@syn.defora.rom:/usr/obj/sys/arch/amd64/compile/GENERIC.MP amd64
Architecture: x86_64
Machine: amd64

qemu 0.9.0 from pkgsrc does not build on NetBSD. It's complaining about
a missing symbol:
libqemu.a(softfloat-native.o)(.text+0x21a): In function `float64_trunc_to_int':
/home/netbsd/pkgsrc/work/emulators/qemu/work/qemu-0.9.0/fpu/softfloat-native.c:226: undefined reference to `trunc'
collect2: ld returned 1 exit status
gmake[1]: *** [qemu] Error 1
gmake[1]: Leaving directory `/home/netbsd/pkgsrc/work/emulators/qemu/work/qemu-0.9.0/i386-softmmu'
gmake: *** [subdir-i386-softmmu] Error 2
*** Error code 2

Compiling this file actually triggers the following warning:

/home/netbsd/pkgsrc/work/emulators/qemu/work/qemu-0.9.0/fpu/softfloat-native.c: In function `float64_trunc_to_int':
/home/netbsd/pkgsrc/work/emulators/qemu/work/qemu-0.9.0/fpu/softfloat-native.c:226: warning: implicit declaration of function `trunc'

trunc() was added to NetBSD in March 2006, and is apparently not
available in a release before 4.0:

RCS file: /cvsroot/src/lib/libm/src/s_trunc.c,v
Working file: s_trunc.c
head: 1.2
locks: strict
access list:
symbolic names:
        wrstuden-fixsa-base-1: 1.1
        wrstuden-fixsa-base: 1.1
        abandoned-netbsd-4-base: 1.1
        netbsd-4-base: 1.1
keyword substitution: kv
total revisions: 2;     selected revisions: 2
revision 1.2
date: 2007/01/17 23:24:22;  author: hubertf;  state: Exp;  lines: +2 -3
Remove more duplicate #includes, and a few spurious whitespaces at EOL
From Slava Semushin <>
revision 1.1
date: 2006/03/25 16:41:12;  author: xtraeme;  state: Exp;
Add trunc() and truncf() C99 functions, from FreeBSD.


Compile code that uses trunc() from <math.h> on any NetBSD release
before 4.0.


I would suggest implementing trunc() in qemu like this: (pseudo code)

#if defined(__NetBSD__) && __NetBSD_VERSION__ < 4.0
/* dump the content of trunc() here */

 With a NetBSD 3.1 userland (amd64).