From owner-freebsd-emulation@freebsd.org Fri Sep 22 23:01:30 2017 Return-Path: Delivered-To: freebsd-emulation@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D165E146D0 for ; Fri, 22 Sep 2017 23:01:30 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 6A367822B6 for ; Fri, 22 Sep 2017 23:01:30 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: by mailman.ysv.freebsd.org (Postfix) id 69309E146CF; Fri, 22 Sep 2017 23:01:30 +0000 (UTC) Delivered-To: emulation@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 68ACEE146CE for ; Fri, 22 Sep 2017 23:01:30 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3A627822B5 for ; Fri, 22 Sep 2017 23:01:30 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: by freefall.freebsd.org (Postfix) id 87B7883FF; Fri, 22 Sep 2017 23:01:29 +0000 (UTC) Delivered-To: vbox@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 5AA2B83FE for ; Fri, 22 Sep 2017 23:01:29 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) by mx1.freebsd.org (Postfix) with ESMTP id 30C15821B5; Fri, 22 Sep 2017 23:01:25 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Subject: Re: [virtualbox-ose] Build failure: global register variable To: soralx@cydem.org, vbox@FreeBSD.org References: <20170917195419.431341e7@mscad14> <20170920191710.58d335df@mscad14> <20170921160000.689755f8@mscad14> From: Jung-uk Kim Message-ID: <5c68323f-5fed-342b-ad92-e74d178f9daf@FreeBSD.org> Date: Fri, 22 Sep 2017 19:00:30 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170921160000.689755f8@mscad14> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6dqovKTVV29EhUUsPtMhBjAgAMWjB914i" X-Mailman-Approved-At: Sat, 23 Sep 2017 10:48:58 +0000 X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 22 Sep 2017 23:01:30 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6dqovKTVV29EhUUsPtMhBjAgAMWjB914i Content-Type: multipart/mixed; boundary="pf5um9quJBItC4M3Itu0WE8AhVaH4cDA0"; protected-headers="v1" From: Jung-uk Kim To: soralx@cydem.org, vbox@FreeBSD.org Message-ID: <5c68323f-5fed-342b-ad92-e74d178f9daf@FreeBSD.org> Subject: Re: [virtualbox-ose] Build failure: global register variable References: <20170917195419.431341e7@mscad14> <20170920191710.58d335df@mscad14> <20170921160000.689755f8@mscad14> In-Reply-To: <20170921160000.689755f8@mscad14> --pf5um9quJBItC4M3Itu0WE8AhVaH4cDA0 Content-Type: multipart/mixed; boundary="------------108A7E82504979B3712037CF" Content-Language: en-US This is a multi-part message in MIME format. --------------108A7E82504979B3712037CF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/21/2017 19:00, soralx@cydem.org wrote: >=20 >>> [...] >>> kBuild: Compiling VBoxRemPrimary >>> - /usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.1.28/src/reco= mpiler/target-i386/op_helper.c >>> In file included >>> from /usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.1.28/src/r= ecompiler/target-i386/op_helper.c:29: >>> /usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.1.28/src/re= compiler/target-i386/exec.h:41:38: >>> error: register 'r14' unsuitable for global register variables on thi= s >>> target register struct CPUX86State *env asm(AREG0); ^ >>> /usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.1.28/src/recomp= iler/dyngen-exec.h:81:15: >>> note: expanded from macro 'AREG0' >>> #define AREG0 "r14" =20 >> >> Turns out that the fix for this is to make sure that devel/kBuild >> is compiled with GCC, not clang; thus, that module of VBox that >> has global register variable (and fails to build with clang) is >> automagically built with gcc. So some parts of VBox are built >> with base clang, some with gcc from ports; it is awkward, but >> it all works somehow. >=20 > Alternatively, one can try changing 'r14' to 'rbp' in definition > of "AREG0" for amd64 at src/recompiler/dyngen-exec.h:81. This is > the only place where gcc is needed, as clang cannot handle r14 > for now [0]. >=20 > I recompiled kBuild with clang, and succeeded compiling virtualbox-ose > with 'r14' to 'rbp' change. It seems to work normally, but I don't know= > what are the performance implications of using up rbp. >=20 > [0] clang/lib/Basic/Targets/X86.h: > 860 bool validateGlobalRegisterVariable(StringRef RegName, unsigned= RegSize, > 861 bool &HasSizeMismatch) cons= t override { > 862 // rsp and rbp are the only 64-bit registers the x86 backend = can currently > 863 // handle. > 864 if (RegName.equals("rsp") || RegName.equals("rbp")) { > 865 // Check that the register size is 64-bit. > 866 HasSizeMismatch =3D RegSize !=3D 64; > 867 return true; > 868 } Please try the attached patch. Jung-uk Kim --------------108A7E82504979B3712037CF Content-Type: text/x-patch; name="vbox.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="vbox.diff" Index: emulators/virtualbox-ose/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- emulators/virtualbox-ose/Makefile (revision 450418) +++ emulators/virtualbox-ose/Makefile (working copy) @@ -227,8 +227,12 @@ KMK_FLAGS+=3D -j${MAKE_JOBS_NUMBER} PATCH_DEPENDS+=3D ${LOCALBASE}/share/kBuild/tools/GXX3.kmk:devel/kBuild EXTRA_PATCHES+=3D ${PATCHDIR}/extrapatch-Config.kmk \ ${PATCHDIR}/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk \ - ${PATCHDIR}/extrapatch-src-recompiler-Makefile.kmk + ${PATCHDIR}/extrapatch-src_recompiler_dyngen-exec.h \ + ${PATCHDIR}/extrapatch-src_recompiler_tcg_i386_tcg-target.h +.if ${COMPILER_VERSION} < 35 +EXTRA_PATCHES+=3D ${PATCHDIR}/extrapatch-src-recompiler-Makefile.kmk .endif +.endif =20 .if ${PYTHON_MAJOR_VER} >=3D 3 PLIST_SUB+=3D PYTHON_PYCDIR=3D/__pycache__/ \ Index: emulators/virtualbox-ose/files/extrapatch-src_recompiler_dyngen-ex= ec.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- emulators/virtualbox-ose/files/extrapatch-src_recompiler_dyngen-exec.= h (nonexistent) +++ emulators/virtualbox-ose/files/extrapatch-src_recompiler_dyngen-exec.= h (working copy) @@ -0,0 +1,21 @@ +--- src/recompiler/dyngen-exec.h.orig 2017-09-13 09:34:47 UTC ++++ src/recompiler/dyngen-exec.h +@@ -75,10 +75,18 @@ typedef void * host_reg_t; + # ifndef VBOX + #define AREG0 "ebp" + # else /* VBOX - why are we different? frame-pointer optimizations on = mac? */ ++# ifndef __clang__ + # define AREG0 "esi" ++# else /* __clang __ */ ++# define AREG0 "ebp" ++# endif /* __clang __ */ + # endif /* VBOX */ + #elif defined(__x86_64__) ++# ifndef __clang__ + #define AREG0 "r14" ++# else /* __clang__ */ ++# define AREG0 "rbp" ++# endif /* __clang__ */ + #elif defined(_ARCH_PPC) + #define AREG0 "r27" + #elif defined(__arm__) Property changes on: emulators/virtualbox-ose/files/extrapatch-src_recomp= iler_dyngen-exec.h ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: emulators/virtualbox-ose/files/extrapatch-src_recompiler_tcg_i386_= tcg-target.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- emulators/virtualbox-ose/files/extrapatch-src_recompiler_tcg_i386_tcg= -target.h (nonexistent) +++ emulators/virtualbox-ose/files/extrapatch-src_recompiler_tcg_i386_tcg= -target.h (working copy) @@ -0,0 +1,23 @@ +--- src/recompiler/tcg/i386/tcg-target.h.orig 2017-09-13 09:34:48 UTC ++++ src/recompiler/tcg/i386/tcg-target.h +@@ -120,12 +120,20 @@ enum { +=20 + /* Note: must be synced with dyngen-exec.h */ + #if TCG_TARGET_REG_BITS =3D=3D 64 ++# ifndef __clang__ + # define TCG_AREG0 TCG_REG_R14 ++# else /* __clang__ */ ++# define TCG_AREG0 TCG_REG_RBP ++# endif /* __clang__ */ + #else + # ifndef VBOX /* we're using ESI instead of EBP, probably due to frame = pointer opt issues */ + # define TCG_AREG0 TCG_REG_EBP + # else /* VBOX */ ++# ifndef __clang__ + # define TCG_AREG0 TCG_REG_ESI ++# else /* __clang__ */ ++# define TCG_AREG0 TCG_REG_EBP ++# endif /* __clang__ */ + # endif /* VBOX */ + #endif +=20 Property changes on: emulators/virtualbox-ose/files/extrapatch-src_recomp= iler_tcg_i386_tcg-target.h ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property --------------108A7E82504979B3712037CF-- --pf5um9quJBItC4M3Itu0WE8AhVaH4cDA0-- --6dqovKTVV29EhUUsPtMhBjAgAMWjB914i Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEl1bqgKaRyqfWXu/CfJ+WJvzb8UYFAlnFlkAACgkQfJ+WJvzb 8Ua4MAf+NUABUa4WfBQrbFp27k0l7/pb/uoUamFOKjHGQNSG8xKR7Gzk8xCCfUy4 Xxf098Srgk6MtYqtHkHHXxExxDWx2UEMQa9jvBVwauJsgns2sVF+x89F9Bxbkx+a 1044JdOVRcNUp5vCp9sFbiaXqNo2FhCBdZFfs3ND1IBKvhEBZyI727UaaJd6cVJQ jHfyZCSrf+mdf9dlMBpNqmtcupzMzXyEZSonktbaByYvO0OVJ1AZGGYLfmM1ak7S jSaxNyB6TSV42RlTTgvYAljIL7486HfJssyyS1B7n17LEldiC04xEOkejA5m1ftE RT1FMIZVI/4DRaiDATjM378vIqt8fQ== =MMqD -----END PGP SIGNATURE----- --6dqovKTVV29EhUUsPtMhBjAgAMWjB914i--