qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] qemu-2007-10-24 build error
@ 2007-10-24  0:36 Hwang YunSong(황윤성)
  2007-10-24 10:20 ` Edgar E. Iglesias
  2007-10-24 10:33 ` J. Mayer
  0 siblings, 2 replies; 6+ messages in thread
From: Hwang YunSong(황윤성) @ 2007-10-24  0:36 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2081 bytes --]

gcc32  -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o block-parallels.o irq.o i2c.o smbus.o scsi-disk.o cdrom.o lsi53c895a.o usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o etraxfs_timer.o etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o libqemu.a  -lm -lz -lgnutls   -L/usr/lib -lSDL -lpthread  -lrt -lutil
libqemu.a(helper.o): In function `do_interrupt':
/usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined reference to `__builtin_clz'
libqemu.a(translate-op.o): In function `dyngen_code':
/home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to `__builtin_clz'
libqemu.a(op.o): In function `op_lz_T0_T1':
/usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined reference to `__builtin_clz'
collect2: ld returned 1 exit status





Linux localhost.localdomain 2.6.19-10hs #1 Tue Apr 3 11:29:42 KST 2007 i686 i686 i386 GNU/Linux

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-Haansoft-linux
Thread model: posix
gcc version 4.1.1 20061120 (Haansoft 4.1.1-41)


-------------------------------------------------
Your Life on the Net
DreamWiz Free Mail @ http://www.dreamwiz.com/


[-- Attachment #2: Type: TEXT/HTML, Size: 6173 bytes --]

<HTML>
<BODY>

<BR>gcc32  -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o block-parallels.o irq.o i2c.o smbus.o scsi-disk.o cdrom.o lsi53c895a.o usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o etraxfs_timer.o etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o libqemu.a  -lm -lz -lgnutls   -L/usr/lib -lSDL -lpthread  -lrt -lutil
<BR>libqemu.a(helper.o): In function `do_interrupt':
<BR>/usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined reference to `__builtin_clz'
<BR>libqemu.a(translate-op.o): In function `dyngen_code':
<BR>/home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to `__builtin_clz'
<BR>libqemu.a(op.o): In function `op_lz_T0_T1':
<BR>/usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined reference to `__builtin_clz'
<BR>collect2: ld returned 1 exit status
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>Linux localhost.localdomain 2.6.19-10hs #1 Tue Apr 3 11:29:42 KST 2007 i686 i686 i386 GNU/Linux
<BR>
<BR>Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-Haansoft-linux
<BR>Thread model: posix
<BR>gcc version 4.1.1 20061120 (Haansoft 4.1.1-41)
<BR>
<BR></BODY>
</HTML>

<BR>
<LINK href=http://www.dreamwiz.com/css/wd.css rel=STYLESHEET title="text spacing" type=text/css>
<table  border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
			<table  border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td align=left colspan=2>
				<!--@@@@ 개인 이미지관련 셋팅 START@@@@-->


<!--@@@@ 개인주소 스킨형태 START@@@@-->
<!---------------------------------->
	<!----------	스킨 2 START    -------->
	<!---------------------------------->
	<table width="225" border="0" cellspacing="0" cellpadding="0" background="http://address.dreamwiz.com/IMG/photo_img/h/y/hys545/p_hys545_SKIN">
	<tr><td style='padding:1 1 1 1' align="center">
	<table width="200" border="0" cellspacing="0" cellpadding="0">
	<tr height="10"><td></td></tr>
	<tr><td height="19" style="font-size: 11pt;  font-weight:bold;">황윤성</td></tr>
	<tr height="7"><td></td></tr>
	<tr><td>
	<table width="200" border="0" cellspacing="0" cellpadding="0">
	<tr height="14">
	<td >1980/10/28()</td></tr>
	</table>
	</td></tr>
	<tr height="8"><td></td></tr>
	<tr><td>
	<table width="200" border="0" cellspacing="0" cellpadding="0">
	<tr height="14">
	<td width="42" >426-811</td>
	<td width="4">
	<td width="154" >815-19 301호</td>
	</tr>
	</table>
	</td></tr>
	<tr height="3"><td></td></tr>
	<tr><td>
	<table width="200" border="0" cellspacing="0" cellpadding="0">
	<tr height="14"><td ></td></tr>
	<tr height="4"><td></td></tr>
	<tr height="19"><td  style="padding:0 0 0 0" class="f9 orange"><a href="http://mail.dreamwiz.com/AUTH/mail.cgi?c=W&to=hys545@dreamwiz.com" target=_blank class="ca_a2">hys545@dreamwiz.com</a></td></td>
	<tr height="1"><td></td></tr>
	<tr height="14"><td class="blue"><a href="http://" target=_blank class="b_q"></a></td></tr>
	</table>
	</td></tr>
	<tr><td height="7"></td></tr>
	<tr><td>
	<table width="200" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td width="117" height="47"></td>
	<td width="83" rowspan="3" style="padding:0 0 1 0">
	<table width="83" border="0" cellspacing="0" cellpadding="0">
	<tr><td height="83" align="right" valign="bottom"></td></tr>
	</table>
	</td></tr>
	<tr height="17"><td  style="padding:3 0 0 0"></td></tr>
	<tr height="19"><td  style="padding:4 0 0 0">H.P : 016-469-7702</td></tr>
	<tr><td height="10"></td></tr>
	</table>
	</td></tr>
	</table>
	</td></tr>
	</table>


				</td>
			</tr>
			</table>
		</td>
		</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0"><tr><td height="5"></td></tr></table>
<table  border="0" cellspacing="0" cellpadding="0">
	<tr><td>
	<A HREF="http://www.dreamwiz.com/wd/add/ev/addcard_pr.htm" target=_blank><img src="http://i.dreamwiz.com/img/wd/add/ma_card.gif" border=0></A>
	</td>
	</tr>
</table>


<BR>
<a HREF="http://www.dreamwiz.com/" TARGET=_blank><img src=http://i.dreamwiz.com/img/wd/ma/m_dw_logo.gif WIDTH=223 HEIGHT=23 BORDER=0 style=margin-bottom:-5;></a> <span style="font-size: 9pt; font-family:gulim,Arial; color: #494949; text-decoration: none;">http://www.dreamwiz.com/</span><br>
<img src="http://i.dreamwiz.com/dw/ko/n.gif" width=1 height=3 border="0"><br><a href="http://www.dpump.net/BIN/ssr.cgi?siteid=34105015265541322cccd9ea972f582f6ea90e6de7fb34e&url=/" target="_blank"><img src="http://i.dreamwiz.com/img/pump/pump_mail_bottomb01.gif" width="270" height="27" align="absmiddle" border="0"></a>
&nbsp;&nbsp;
<img src="http://i.dreamwiz.com/dw/ko/n.gif" width=5 height=1 border="0"><a href="http://ebiz.dreamwiz.com/BIN/pl.cgi?page=quiz_ev_foot&sub=mail&save=100&http://www.qbattle.com" target="_blank"><img src="http://i.dreamwiz.com/img/quiz/hompy_img/eventimg/m_qb.gif" width=270 height=27 align="absmiddle" border="0"></a>


<IMG SRC="http://mailchk.dreamwiz.com/cgi-bin/receive_check.cgi?sender=hys545@dreamwiz.com&msgid=%3C20071024003602.0000F11F01F20261@mail6.dreamwiz.com%3E&receiver=qemu-devel@nongnu.org&key=a4179b46849a94e2b0d116f4ff397feb&wiz=/n.gif" WIDTH="1" HEIGHT="1" BORDER="0">

                                                             

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

* Re: [Qemu-devel] qemu-2007-10-24 build error
  2007-10-24  0:36 [Qemu-devel] qemu-2007-10-24 build error Hwang YunSong(황윤성)
@ 2007-10-24 10:20 ` Edgar E. Iglesias
  2007-10-24 10:33 ` J. Mayer
  1 sibling, 0 replies; 6+ messages in thread
From: Edgar E. Iglesias @ 2007-10-24 10:20 UTC (permalink / raw)
  To: hys545, qemu-devel

On Wed, Oct 24, 2007 at 09:36:02AM +0900, Hwang YunSong(??????) wrote:
>    gcc32 -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o
>    console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o
>    block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o
>    block-vpc.o block-vvfat.o block-qcow2.o block-parallels.o irq.o i2c.o
>    smbus.o scsi-disk.o cdrom.o lsi53c895a.o usb.o usb-hub.o usb-linux.o
>    usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o eeprom93xx.o eepro100.o
>    ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o etraxfs_timer.o
>    etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o slirp/cksum.o
>    slirp/if.o slirp/ip_icmp.o slirp/ip_input.o slirp/ip_output.o
>    slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o slirp/socket.o
>    slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o slirp/tcp_timer.o
>    slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o libqemu.a -lm -lz
>    -lgnutls -L/usr/lib -lSDL -lpthread -lrt -lutil
>    libqemu.a(helper.o): In function `do_interrupt':
>    /usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined
>    reference to `__builtin_clz'
>    libqemu.a(translate-op.o): In function `dyngen_code':
>    /home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to
>    `__builtin_clz'
>    libqemu.a(op.o): In function `op_lz_T0_T1':
>    /usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined reference
>    to `__builtin_clz'
>    collect2: ld returned 1 exit status
>    Linux localhost.localdomain 2.6.19-10hs #1 Tue Apr 3 11:29:42 KST 2007
>    i686 i686 i386 GNU/Linux
>    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
>    --infodir=/usr/share/info --enable-shared --enable-threads=posix
>    --enable-checking=release --with-system-zlib --enable-__cxa_atexit
>    --disable-libunwind-exceptions --enable-libgcj-multifile
>    --enable-languages=c,c++,objc,obj-c++,java,fortran,ada
>    --enable-java-awt=gtk --disable-dssi --enable-plugin
>    --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
>    --with-cpu=generic --host=i386-Haansoft-linux
>    Thread model: posix
>    gcc version 4.1.1 20061120 (Haansoft 4.1.1-41)

Hello,

This patch adds a version of clz that does not rely on the builtin from GCC for GCC versions where it's not expected to be available. Test were done with the cris qemu testsuite with gcc version 4.1.2 (Gentoo 4.1.2) and with gcc version 3.3.6 (Gentoo 3.3.6-r1 p1.4, ssp-3.3.6-1.0, pie-8.7.8).

You indicate the use of a GCC 4.1.1 which AFAIK should provide the __builtin_clz. I don't know whats going on but from the cmdline (gcc32) one might guess that a GCC 3.2 was used. Could you verify this?

If so, this patch will hopefully solve the build problem you see.

Best regards
-- 
Edgar E. Iglesias
Axis Communications AB

diff --git a/target-cris/op.c b/target-cris/op.c
index 3ce9888..fbbae5b 100644
--- a/target-cris/op.c
+++ b/target-cris/op.c
@@ -1006,7 +1006,34 @@ void OPPROTO op_lz_T0_T1 (void)
 	if (T1 == 0)
 		T0 = 32;
 	else
+#if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3
+	{
 		T0 = __builtin_clz(T1);
+	}
+#else	
+	{
+		/* Binary search for leading zeros.  */
+
+		T0 = 1;
+		if ((T1 >> 16) == 0) {
+			T0 = T0 + 16; 
+			T1 = T1 << 16;
+		}
+		if ((T1 >> 24) == 0) {
+			T0 = T0 + 8;
+			T1 = T1 << 8;
+		}
+		if ((T1 >> 28) == 0) {
+			T0 = T0 + 4; 
+			T1 = T1 << 4;
+		}
+		if ((T1 >> 30) == 0) {
+			T0 = T0 + 2; 
+			T1 = T1 << 2;
+		}
+		T0 = T0 - (T1 >> 31);
+	}
+#endif
 	RETURN();
 }
 

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

* Re: [Qemu-devel] qemu-2007-10-24 build error
  2007-10-24  0:36 [Qemu-devel] qemu-2007-10-24 build error Hwang YunSong(황윤성)
  2007-10-24 10:20 ` Edgar E. Iglesias
@ 2007-10-24 10:33 ` J. Mayer
  2007-10-24 12:36   ` Edgar E. Iglesias
  1 sibling, 1 reply; 6+ messages in thread
From: J. Mayer @ 2007-10-24 10:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: hys545

On Wed, 2007-10-24 at 09:36 +0900, Hwang YunSong(황윤성) wrote:
> 
> gcc32 -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o
> console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o
> block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
> block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o
> block-parallels.o irq.o i2c.o smbus.o scsi-disk.o cdrom.o lsi53c895a.o
> usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o
> eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o
> etraxfs_timer.o etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o
> slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o
> slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o
> slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o
> slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o
> libqemu.a -lm -lz -lgnutls -L/usr/lib -lSDL -lpthread -lrt -lutil 
> libqemu.a(helper.o): In function `do_interrupt': 
> /usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined
> reference to `__builtin_clz' 
> libqemu.a(translate-op.o): In function `dyngen_code': 
> /home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to
> `__builtin_clz' 
> libqemu.a(op.o): In function `op_lz_T0_T1': 
> /usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined
> reference to `__builtin_clz' 
> collect2: ld returned 1 exit status 

It does not seem to be a good idea, imho, to use gcc builtins directly
from micro-ops. But your compiler should implement __builtin_clz. As far
as I can see, the 4.1.1 version I got (Gentoo distribution) has this
builtin implemented, then there might be a problem in your gcc package.
I used this little program to check the builtin presence and found no
version from gcc 3.4.4 to gcc 4.2.2 without __builtin_clz implemented:

int a = 123456;

int main (void)
{
    int b;

    b = __builtin_clz(a);

    return b;
}

Compiled with gcc-<version> -O2 -Wall -W -o /tmp/clz /tmp/ckz.c

[...]

-- 
J. Mayer <l_indien@magic.fr>
Never organized

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

* Re: [Qemu-devel] qemu-2007-10-24 build error
  2007-10-24 10:33 ` J. Mayer
@ 2007-10-24 12:36   ` Edgar E. Iglesias
  2007-10-24 15:33     ` Thiemo Seufer
  0 siblings, 1 reply; 6+ messages in thread
From: Edgar E. Iglesias @ 2007-10-24 12:36 UTC (permalink / raw)
  To: J. Mayer; +Cc: qemu-devel, hys545

On Wed, Oct 24, 2007 at 12:33:24PM +0200, J. Mayer wrote:
> On Wed, 2007-10-24 at 09:36 +0900, Hwang YunSong(?????????) wrote:
> > 
> > gcc32 -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o
> > console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o
> > block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
> > block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o
> > block-parallels.o irq.o i2c.o smbus.o scsi-disk.o cdrom.o lsi53c895a.o
> > usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o
> > eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o
> > etraxfs_timer.o etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o
> > slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o
> > slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o
> > slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o
> > slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o
> > libqemu.a -lm -lz -lgnutls -L/usr/lib -lSDL -lpthread -lrt -lutil 
> > libqemu.a(helper.o): In function `do_interrupt': 
> > /usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined
> > reference to `__builtin_clz' 
> > libqemu.a(translate-op.o): In function `dyngen_code': 
> > /home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to
> > `__builtin_clz' 
> > libqemu.a(op.o): In function `op_lz_T0_T1': 
> > /usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined
> > reference to `__builtin_clz' 
> > collect2: ld returned 1 exit status 
> 
> It does not seem to be a good idea, imho, to use gcc builtins directly
> from micro-ops. But your compiler should implement __builtin_clz. As far

Hi,

I submitted a patch that at compile-time fallbacks to clz code without builtins. Do you see any additional issues with using the builtins?

I think the speed-up with GCC ports implementing fast builtin variants of operations like clz would be significant enough to justify their use but if there is disagreement I'll send in a new patch removing the builtin_clz alltogether.

Best regards


> as I can see, the 4.1.1 version I got (Gentoo distribution) has this
> builtin implemented, then there might be a problem in your gcc package.
> I used this little program to check the builtin presence and found no
> version from gcc 3.4.4 to gcc 4.2.2 without __builtin_clz implemented:
> 
> int a = 123456;
> 
> int main (void)
> {
>     int b;
> 
>     b = __builtin_clz(a);
> 
>     return b;
> }
> 
> Compiled with gcc-<version> -O2 -Wall -W -o /tmp/clz /tmp/ckz.c
> 
> [...]
> 
> -- 
> J. Mayer <l_indien@magic.fr>
> Never organized
> 
> 
> 

-- 
Edgar E. Iglesias
Axis Communications AB

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

* Re: [Qemu-devel] qemu-2007-10-24 build error
  2007-10-24 12:36   ` Edgar E. Iglesias
@ 2007-10-24 15:33     ` Thiemo Seufer
  2007-10-24 16:03       ` Edgar E. Iglesias
  0 siblings, 1 reply; 6+ messages in thread
From: Thiemo Seufer @ 2007-10-24 15:33 UTC (permalink / raw)
  To: Edgar E. Iglesias; +Cc: J. Mayer, qemu-devel, hys545

Edgar E. Iglesias wrote:
> On Wed, Oct 24, 2007 at 12:33:24PM +0200, J. Mayer wrote:
> > On Wed, 2007-10-24 at 09:36 +0900, Hwang YunSong(?????????) wrote:
> > > 
> > > gcc32 -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o
> > > console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o
> > > block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
> > > block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o
> > > block-parallels.o irq.o i2c.o smbus.o scsi-disk.o cdrom.o lsi53c895a.o
> > > usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o
> > > eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o
> > > etraxfs_timer.o etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o
> > > slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o
> > > slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o
> > > slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o
> > > slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o
> > > libqemu.a -lm -lz -lgnutls -L/usr/lib -lSDL -lpthread -lrt -lutil 
> > > libqemu.a(helper.o): In function `do_interrupt': 
> > > /usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined
> > > reference to `__builtin_clz' 
> > > libqemu.a(translate-op.o): In function `dyngen_code': 
> > > /home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to
> > > `__builtin_clz' 
> > > libqemu.a(op.o): In function `op_lz_T0_T1': 
> > > /usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined
> > > reference to `__builtin_clz' 
> > > collect2: ld returned 1 exit status 
> > 
> > It does not seem to be a good idea, imho, to use gcc builtins directly
> > from micro-ops. But your compiler should implement __builtin_clz. As far
> 
> Hi,
> 
> I submitted a patch that at compile-time fallbacks to clz code without builtins. Do you see any additional issues with using the builtins?
> 
> I think the speed-up with GCC ports implementing fast builtin variants of operations like clz would be significant enough to justify their use but if there is disagreement I'll send in a new patch removing the builtin_clz alltogether.

If the builtin ends up calling into libgcc (this can happen depending
on the host / host compiler), then the dynamic code generation breaks.

It is safer not to force the compiler to use builtins.


Thiemo

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

* Re: [Qemu-devel] qemu-2007-10-24 build error
  2007-10-24 15:33     ` Thiemo Seufer
@ 2007-10-24 16:03       ` Edgar E. Iglesias
  0 siblings, 0 replies; 6+ messages in thread
From: Edgar E. Iglesias @ 2007-10-24 16:03 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: J. Mayer, qemu-devel, hys545

On Wed, Oct 24, 2007 at 04:33:49PM +0100, Thiemo Seufer wrote:
> Edgar E. Iglesias wrote:
> > On Wed, Oct 24, 2007 at 12:33:24PM +0200, J. Mayer wrote:
> > > On Wed, 2007-10-24 at 09:36 +0900, Hwang YunSong(?????????) wrote:
> > > > 
> > > > gcc32 -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o
> > > > console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o
> > > > block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
> > > > block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o
> > > > block-parallels.o irq.o i2c.o smbus.o scsi-disk.o cdrom.o lsi53c895a.o
> > > > usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o
> > > > eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o
> > > > etraxfs_timer.o etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o
> > > > slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o
> > > > slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o
> > > > slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o
> > > > slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o
> > > > libqemu.a -lm -lz -lgnutls -L/usr/lib -lSDL -lpthread -lrt -lutil 
> > > > libqemu.a(helper.o): In function `do_interrupt': 
> > > > /usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined
> > > > reference to `__builtin_clz' 
> > > > libqemu.a(translate-op.o): In function `dyngen_code': 
> > > > /home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to
> > > > `__builtin_clz' 
> > > > libqemu.a(op.o): In function `op_lz_T0_T1': 
> > > > /usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined
> > > > reference to `__builtin_clz' 
> > > > collect2: ld returned 1 exit status 
> > > 
> > > It does not seem to be a good idea, imho, to use gcc builtins directly
> > > from micro-ops. But your compiler should implement __builtin_clz. As far
> > 
> > Hi,
> > 
> > I submitted a patch that at compile-time fallbacks to clz code without builtins. Do you see any additional issues with using the builtins?
> > 
> > I think the speed-up with GCC ports implementing fast builtin variants of operations like clz would be significant enough to justify their use but if there is disagreement I'll send in a new patch removing the builtin_clz alltogether.
> 
> If the builtin ends up calling into libgcc (this can happen depending
> on the host / host compiler), then the dynamic code generation breaks.
> 
> It is safer not to force the compiler to use builtins.

Right, if calls are made things could break. Thanks for clarifying that. 

Here's a new patch to remove the builtin altogether. When building the system simulator for CRIS I found another one which will cause build problems with older GCC's so I replaced that one aswell.

Best regards
-- 
Edgar E. Iglesias
Axis Communications AB

diff --git a/target-cris/helper.c b/target-cris/helper.c
index 3db3bea..43fcdd1 100644
--- a/target-cris/helper.c
+++ b/target-cris/helper.c
@@ -87,6 +87,32 @@ static void cris_shift_ccs(CPUState *env)
 	env->pregs[SR_CCS] = ccs;
 }
 
+static int cris_clz(uint32_t x)
+{
+	int n;
+	/* Binary search for leading zeros.  */
+
+	n = 1;
+	if ((x >> 16) == 0) {
+		n = n + 16; 
+		x = x << 16;
+	}
+	if ((x >> 24) == 0) {
+		n = n + 8;
+		x = x << 8;
+	}
+	if ((x >> 28) == 0) {
+		n = n + 4; 
+		x = x << 4;
+	}
+	if ((x >> 30) == 0) {
+		n = n + 2; 
+		x = x << 2;
+	}
+	n = n - (x >> 31);
+	return n;
+}
+
 void do_interrupt(CPUState *env)
 {
 	uint32_t ebp, isr;
@@ -135,7 +161,7 @@ void do_interrupt(CPUState *env)
 				}
 
 				irqnum = 31 -
-					__builtin_clz(env->pending_interrupts);
+					cris_clz(env->pending_interrupts);
 				irqnum += 0x30;
 				ebp = env->pregs[SR_EBP];
 				isr = ldl_code(ebp + irqnum * 4);
diff --git a/target-cris/op.c b/target-cris/op.c
index 3ce9888..12188b4 100644
--- a/target-cris/op.c
+++ b/target-cris/op.c
@@ -1006,7 +1006,28 @@ void OPPROTO op_lz_T0_T1 (void)
 	if (T1 == 0)
 		T0 = 32;
 	else
-		T0 = __builtin_clz(T1);
+	{
+		/* Binary search for leading zeros.  */
+
+		T0 = 1;
+		if ((T1 >> 16) == 0) {
+			T0 = T0 + 16; 
+			T1 = T1 << 16;
+		}
+		if ((T1 >> 24) == 0) {
+			T0 = T0 + 8;
+			T1 = T1 << 8;
+		}
+		if ((T1 >> 28) == 0) {
+			T0 = T0 + 4; 
+			T1 = T1 << 4;
+		}
+		if ((T1 >> 30) == 0) {
+			T0 = T0 + 2; 
+			T1 = T1 << 2;
+		}
+		T0 = T0 - (T1 >> 31);
+	}
 	RETURN();
 }
 

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

end of thread, other threads:[~2007-10-24 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-24  0:36 [Qemu-devel] qemu-2007-10-24 build error Hwang YunSong(황윤성)
2007-10-24 10:20 ` Edgar E. Iglesias
2007-10-24 10:33 ` J. Mayer
2007-10-24 12:36   ` Edgar E. Iglesias
2007-10-24 15:33     ` Thiemo Seufer
2007-10-24 16:03       ` Edgar E. Iglesias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).