Date: Fri, 22 Sep 2017 19:00:30 -0400 From: Jung-uk Kim <jkim@FreeBSD.org> To: soralx@cydem.org, vbox@FreeBSD.org Subject: Re: [virtualbox-ose] Build failure: global register variable Message-ID: <5c68323f-5fed-342b-ad92-e74d178f9daf@FreeBSD.org> In-Reply-To: <20170921160000.689755f8@mscad14> References: <20170917195419.431341e7@mscad14> <20170920191710.58d335df@mscad14> <20170921160000.689755f8@mscad14>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <jkim@FreeBSD.org> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5c68323f-5fed-342b-ad92-e74d178f9daf>