From owner-freebsd-emulation@FreeBSD.ORG Tue Jun 12 18:13:36 2012 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6E2271065678 for ; Tue, 12 Jun 2012 18:13:36 +0000 (UTC) (envelope-from nox@jelal.kn-bremen.de) Received: from smtp.kn-bremen.de (gelbbaer.kn-bremen.de [78.46.108.116]) by mx1.freebsd.org (Postfix) with ESMTP id 28B308FC1C for ; Tue, 12 Jun 2012 18:13:36 +0000 (UTC) Received: by smtp.kn-bremen.de (Postfix, from userid 10) id F06CC1E00701; Tue, 12 Jun 2012 20:13:28 +0200 (CEST) Received: from triton8.kn-bremen.de (noident@localhost [127.0.0.1]) by triton8.kn-bremen.de (8.14.4/8.14.4) with ESMTP id q5CIBvru088679; Tue, 12 Jun 2012 20:11:57 +0200 (CEST) (envelope-from nox@triton8.kn-bremen.de) Received: (from nox@localhost) by triton8.kn-bremen.de (8.14.4/8.14.3/Submit) id q5CIBugV088678; Tue, 12 Jun 2012 20:11:56 +0200 (CEST) (envelope-from nox) Date: Tue, 12 Jun 2012 20:11:56 +0200 (CEST) From: Juergen Lock Message-Id: <201206121811.q5CIBugV088678@triton8.kn-bremen.de> To: bfalk_bsd@brandonfa.lk X-Newsgroups: local.list.freebsd.emulation In-Reply-To: <4FD67192.2010001@brandonfa.lk> Organization: Cc: freebsd-emulation@freebsd.org Subject: Re: Building QEMU with clang X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 18:13:36 -0000 In article <4FD67192.2010001@brandonfa.lk> you write: >Greetings, Hi! > >I could go on a rant, but I'll keep it short and sweet. I'm wondering if >there are any efforts to get QEMU building with clang. I know this >should go on the QEMU mailing lists, but I wanted to post it here as >well as I'd be using FreeBSD as the host. > >When working with qemu-devel (with --enable-tcg-interpreter), I get: > >multiboot.S:31:8: error: .code16 not supported yet > >multiboot.S:123:17: error: unexpected token in argument list > data32 lgdt %gs:6 > ^ >multiboot.S:131:15: error: unknown token in expression > data32 ljmp *%gs:0 > >Now, code16 is a pretty big deal, and that's obviously a feature that >clang needs to add. However what is it with the complaints of the other >two (I'm an Intel syntax guy, not AT&T :P)? > I don't know about those but I do know clang can be told to call (g)as instead of using its internal assembler by passing -no-integrated-as. >Semi-sidenote: >Since clang does not support global registers, --enable-tcg-interpreter >has to be specified to ./configure. This should be added to the port as >an option. Heh I didn't know about --enable-tcg-interpreter... The following patch makes the port build, but the result is much slower than with gcc. (and without --enable-tcg-interpreter.) And also halt -p in a FreeBSD guest causes qemu-system-x86_64 to fail with a tcg error. I'm not sure it makes much sense to commit this nevertheless...? Index: Makefile =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/Makefile,v retrieving revision 1.140 diff -u -p -r1.140 Makefile --- Makefile 9 Jun 2012 16:19:05 -0000 1.140 +++ Makefile 12 Jun 2012 17:57:16 -0000 @@ -48,11 +48,19 @@ ADD_AUDIO_DESC= "Emulate more audio har ALL_TARGETS_DESC= "Also build bsd-user targets (for testing)" OPTIONS_DEFAULT=SDL OPENGL GNUTLS SASL JPEG PNG CURL CDROM_DMA PCAP -.include +.include CONFIGURE_ARGS+= --extra-ldflags=-L${LOCALBASE}/lib PORTDOCS= docs qemu-doc.html qemu-tech.html +# XXX this fixes build with clang but --enable-tcg-interpreter that's +# needed to avoid global register usage that clang doesn't support +# causes the result to be slow. +.if ${CC:T:Mclang} == "clang" +CONFIGURE_ARGS+= --enable-tcg-interpreter +CLANG_CFLAGS_AS+= -no-integrated-as +.endif + .if empty(PORT_OPTIONS:MALL_TARGETS) CONFIGURE_ARGS+= --disable-bsd-user PLIST_SUB+= ALLTARGETS="@comment " @@ -191,6 +199,9 @@ post-patch: -e "s|^(LDFLAGS=).*|\1${LDFLAGS}|" \ ${WRKSRC}/Makefile @${REINPLACE_CMD} -E \ + -e "s|^(CFLAGS[ ]*:=.*)|\1 ${CLANG_CFLAGS_AS}|" \ + ${WRKSRC}/pc-bios/optionrom/Makefile + @${REINPLACE_CMD} -E \ -e "1s|^(#! )/usr/bin/perl|\1${PERL}|" \ ${WRKSRC}/scripts/texi2pod.pl @@ -217,4 +228,4 @@ post-install: fi @${CAT} ${PKGMESSAGE} -.include +.include