[virtualbox-ose] Build failure: global register variable

Jung-uk Kim jkim at FreeBSD.org
Fri Sep 22 23:01:30 UTC 2017


On 09/21/2017 19:00, soralx at cydem.org wrote:
> 
>>> [...]
>>> kBuild: Compiling VBoxRemPrimary
>>> - /usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.1.28/src/recompiler/target-i386/op_helper.c
>>> In file included
>>> from /usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.1.28/src/recompiler/target-i386/op_helper.c:29:
>>>     /usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.1.28/src/recompiler/target-i386/exec.h:41:38:
>>> error: register 'r14' unsuitable for global register variables on this
>>> target register struct CPUX86State *env asm(AREG0); ^
>>> /usr/ports/emulators/virtualbox-ose/work/VirtualBox-5.1.28/src/recompiler/dyngen-exec.h:81:15:
>>> note: expanded from macro 'AREG0'
>>> #define AREG0 "r14"  
>>
>> 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.
> 
> 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].
> 
> 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.
> 
> [0] clang/lib/Basic/Targets/X86.h:
>   860   bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
>   861                                       bool &HasSizeMismatch) const 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 = RegSize != 64;
>   867       return true;
>   868     }

Please try the attached patch.

Jung-uk Kim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vbox.diff
Type: text/x-patch
Size: 3654 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-emulation/attachments/20170922/9ac15a71/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-emulation/attachments/20170922/9ac15a71/attachment.sig>


More information about the freebsd-emulation mailing list