[vbox-dev] Building Virtualbox using clang/llvm on Linux

Raghavan Santhanam raghavanil4m at gmail.com
Fri Mar 16 07:52:38 GMT 2018


Hello All,

I wanted to know the feasibility of VirtualBox source to be built with
Clang/LLVM on Linux. As far as I researched, tried
and experimented so far, it turned out that there are many hard-coded
gcc/g++-specific Makefile variables, etc which I tried
to update beforehand via configure script. And also tried to work upon some
of the code that used non-standard VLAIS
that gcc supports as an extension but clang doesn't. With that, I was able
to some of the code with Clang/LLVM and still
there are some more to build that are likely to throw some more compilation
errors, etc due to gcc/clang extensions differences.
I also tried to reuse the MacOS/darwin settings(as an experiment) as it
seems to use Clang/LLVM as the compiler - but
appeared to require more effort than using Linux(OS) specific Makefile
settings to point to Clang/LLVM and get the build
going. So, before proceeding further, I wanted to know if there have been
attempts to build Virtualbox using Clang/LLVM
on Linux for Linux. I saw an old thread discussing about the same being
possible for FreeBSD. So, I tried to set the OS to
be FreeBSD and get going to see how far the build can go - it failed in the
first few steps when it didn't find some FreeBSD
specific settings which I had expected to happen as I am using Ubuntu 17.10
x86_64 as the host to build Virtualbox using
Clang/LLVM. So, any thoughts on this?

By the way, I was successful in building all of the Virtualbox kernel
modules(vboxpci, vboxnetadp, vboxnetfltm, vboxdrv),
using Clang/LLVM and they are completely working as expected as I verified
the same by running Ubuntu 17.10 x86_64
as the guest within the installed Virtualbox(v5.2.8) on the same host Ubuntu
17.10 x86_64 I am using for the above
Clang/LLVM/Virtualbox/Linux building process. Below are the metadata
embedded within these kernel modules showing
the compiler used to build them to be Clang/LLVM along with the other
details of host and VirtualBox guest to give a
better context in this regard.

Cheers,
Raghavan Santhanam


*On host Ubuntu 17.10 x86_64 with Clang-built kernel 4.15.10 an Clang-built
Nvidia driver 390.25 :*


>
> *##*
> *## VirtualBox version**##*
>
> *tp at tp:~$ *
> *tp at tp:~$ VirtualBox --help | head -1*
> *Oracle VM VirtualBox Manager 5.2.8*
> *tp at tp:~$ **tp at tp:~$ *
>
> *##*
> *## VirtualBox clang-built kernel modules loaded on host**##*
>
> *tp at tp:~$ *
> *tp at tp:~$ lsmod | grep vbox*
> *vboxpci                28672  0 *
> *vboxnetadp             28672  0 *
> *vboxnetflt             32768  0 *
> *vboxdrv               487424  4 vboxpci,vboxnetadp,vboxnetflt**tp at tp:~$ *
>
> *##*
> *## VirtualBox kernel modules built using Clang/LLVM having the Clang/LLVM
> specific metadata within*
> *## them**##*
>
> *tp at tp:~$ *
> *tp at tp:~$ *
> *tp at tp:~$ eclang /lib/modules/4.15.10/misc/vboxdrv.ko | head -1*
> *++ strings -a /lib/modules/4.15.10/misc/vboxdrv.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)*
> *tp at tp:~$ *
> *tp at tp:~$ *
> *tp at tp:~$ eclang /lib/modules/4.15.10/misc/vboxnetadp.ko | head -1*
> *++ strings -a /lib/modules/4.15.10/misc/vboxnetadp.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)*
> *tp at tp:~$ *
> *tp at tp:~$ eclang /lib/modules/4.15.10/misc/vboxnetflt.ko | head -1*
> *++ strings -a /lib/modules/4.15.10/misc/vboxnetflt.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)*
> *tp at tp:~$ *
> *tp at tp:~$ *
> *tp at tp:~$ eclang /lib/modules/4.15.10/misc/vboxpci.ko | head -1*
> *++ strings -a /lib/modules/4.15.10/misc/vboxpci.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)**tp at tp:~$ *
>
> *##*
> *## VirtualBox kernel modules showing VirtualBox version info**##*
>
> *tp at tp:~$ virtualboxmeta *
> *++ grep 'VirtualBox\|^version='*
> *+++ uname -r*
> *++ strings -a /lib/modules/4.15.10/misc/vboxdrv.ko*
> *description=Oracle VM VirtualBox Support Driver*
> *version=5.2.8 r121009 (0x00290001)*
> *++ grep 'VirtualBox\|^version='*
> *+++ uname -r*
> *++ strings -a /lib/modules/4.15.10/misc/vboxnetadp.ko*
> *description=Oracle VM VirtualBox Network Adapter Driver*
> *version=5.2.8 r121009 ((0xA2CDe001U))*
> *++ grep 'VirtualBox\|^version='*
> *+++ uname -r*
> *++ strings -a /lib/modules/4.15.10/misc/vboxnetflt.ko*
> *description=Oracle VM VirtualBox Network Filter Driver*
> *version=5.2.8 r121009 ((0xA2CDe001U))*
> *++ grep 'VirtualBox\|^version='*
> *+++ uname -r*
> *++ strings -a /lib/modules/4.15.10/misc/vboxpci.ko*
> *description=Oracle VM VirtualBox PCI access Driver*
> *version=5.2.8 r121009**tp at tp:~$ *
>
> *##*
> *## Clang-built 4.15.10 kernel used by host Ubuntu 17.10 x86_64**##*
>
> *tp at tp:~$ *
> *tp at tp:~$ cat /proc/version *
> *Linux version 4.15.10 (tp at tp) (clang version 5.0.0-3
> (tags/RELEASE_500/final)) #2 SMP Thu Mar 15 16:24:39 PDT 2018*
> *tp at tp:~$ **tp at tp:~$ *
>
> *tp at tp:~$ dmesg | grep clang*
> *[    0.000000] Linux version 4.15.10 (tp at tp) (clang version 5.0.0-3
> (tags/RELEASE_500/final)) #2 SMP Thu Mar 15 16:24:39 PDT 2018**tp at tp:~$ *
>
> *##*
> *## DMI specific host hardware information**##*
>
> *tp at tp:~$ *
> *tp at tp:~$ sudo dmidecode -t system | grep "Manufacturer:\|Version"*
> * Manufacturer: LENOVO*
> * Version: Lenovo Y50-70 Touch*
> *tp at tp:~$ *
> *tp at tp:~$ *
> *tp at tp:~$ sudo dmidecode -t bios | grep "Vendor"*
> * Vendor: LENOVO*
> *tp at tp:~$ **tp at tp:~$ *
>
>
> *##*
> *## Clang-built NVIDIA 390.25 host graphics driver info**##*
>
> *tp at tp:~$ nvidia-smi*
> *Fri Mar 16 00:28:49 2018       *
>
> *+-----------------------------------------------------------------------------+*
> *| NVIDIA-SMI 390.25                 Driver Version: 390.25
>     |*
>
> *|-------------------------------+----------------------+----------------------+*
> *| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr.
> ECC |*
> *| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util
> Compute M. |*
>
> *|===============================+======================+======================|*
> *|   0  GeForce GTX 860M    Off  | 00000000:01:00.0 Off |
> N/A |*
> *| N/A   53C    P8    N/A /  N/A |    527MiB /  4046MiB |      0%
> Default |*
> *+-------------------------------+----------------------+----------------------+*
>
> *##*
> *## Clang-built NVIDIA 390.25 host graphics driver modules having
> Clang/LLVM compiler specific*
> *## metadata within them**##*
>
> *tp at tp:~$ *
> *tp at tp:~$ eclang /lib/modules/4.15.10/kernel/drivers/video/nvidia.ko |
> head -1*
> *++ strings -a /lib/modules/4.15.10/kernel/drivers/video/nvidia.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)*
> *tp at tp:~$ eclang
> /lib/modules/4.15.10/kernel/drivers/video/nvidia-modeset.ko| head -1*
> *++ strings -a /lib/modules/4.15.10/kernel/drivers/video/nvidia-modeset.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)*
> *tp at tp:~$ *
> *tp at tp:~$ *
> *tp at tp:~$ eclang
> /lib/modules/4.15.10/kernel/drivers/video/nvidia-modeset.ko | head -1*
> *++ strings -a /lib/modules/4.15.10/kernel/drivers/video/nvidia-modeset.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)*
> *tp at tp:~$ *
> *tp at tp:~$ *
> *tp at tp:~$ eclang /lib/modules/4.15.10/kernel/drivers/video/nvidia-uvm.ko |
> head -1*
> *++ strings -a /lib/modules/4.15.10/kernel/drivers/video/nvidia-uvm.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)*
> *tp at tp:~$ *
> *tp at tp:~$ *
> *tp at tp:~$ eclang /lib/modules/4.15.10/kernel/drivers/video/nvidia-drm.ko |
> head -1*
> *++ strings -a /lib/modules/4.15.10/kernel/drivers/video/nvidia-drm.ko*
> *++ grep clang*
> *clang version 5.0.0-3 (tags/RELEASE_500/final)**tp at tp:~$ *
>
> *##*
> *## NVIDIA 390.25 driver modules loaded on host**##*
>
> *tp at tp:~$ *
> *tp at tp:~$ lsmod | grep nvidia*
> *nvidia_uvm            815104  0 *
> *nvidia_drm             24576  2 *
> *nvidia_modeset       1097728  5 nvidia_drm*
> *nvidia              14352384  427 nvidia_uvm,nvidia_modeset*
> *ipmi_msghandler        61440  2 nvidia,ipmi_devintf*
> *drm                   454656  6 nvidia_drm,i915,drm_kms_helper*
> *tp at tp:~$ *
>
> *##*
> *## OpenGL/ES info for NVIDIA 390.25 host graphics driver**##*
>
> *tp at tp:~$ glxinfo | grep NVIDIA*
> *server glx vendor string: NVIDIA Corporation*
> *client glx vendor string: NVIDIA Corporation*
> *OpenGL vendor string: NVIDIA Corporation*
> *OpenGL core profile version string: 4.5.0 NVIDIA 390.25*
> *OpenGL core profile shading language version string: 4.50 NVIDIA*
> *OpenGL version string: 4.6.0 NVIDIA 390.25*
> *OpenGL shading language version string: 4.60 NVIDIA*
> *OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 390.25**tp at tp:~$ *


*Within VirtualBox guest Ubuntu 17.10 x86_64 with the default kernel and
drivers installed using the standard Ubuntu 17.10 ISO :*


> *exp at exp:~$ *
> *exp at exp:~$ *
> *exp at exp:~$ dmesg | grep VirtualBox*
> *[    0.000000] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox
> 12/01/2006*
> *[    1.403681] usb 1-1: Manufacturer: VirtualBox*
> *[    1.424711] input: VirtualBox USB Tablet as
> /devices/pci0000:00/0000:00:06.0/usb1/1-1/1-1:1.0/0003:80EE:0021.0001/input/input6*
> *[    1.424873] hid-generic 0003:80EE:0021.0001: input,hidraw0: USB HID
> v1.10 Mouse [VirtualBox USB Tablet] on usb-0000:00:06.0-1/input0*
> *exp at exp:~$ **exp at exp:~$ *
>
> *exp at exp:~$ *
> *exp at exp:~$ sudo dmidecode -t system | grep
> "Manufacturer\|Product\|Version"*
> * Manufacturer: innotek GmbH*
> * Product Name: VirtualBox*
> * Version: 1.2*
> *exp at exp:~$ **exp at exp:~$ *


> *exp at exp:~$ *
> *exp at exp:~$ sudo dmidecode -t bios | grep "Vendor\|Version"*
> * Vendor: innotek GmbH*
> * Version: VirtualBox**exp at exp:~$  *


>
> *exp at exp:~$ *
> *exp at exp:~$ cat /proc/cmdline *
> *BOOT_IMAGE=/boot/vmlinuz-4.13.0-21-generic
> root=UUID=01b1b4a5-b38a-4998-bbae-8abbb8efcc70 ro quiet splash*
> *exp at exp:~$ *
> *exp at exp:~$ cat /proc/version*
> *Linux version 4.13.0-21-generic (buildd at lgw01-amd64-037) (gcc version
> 7.2.0 (Ubuntu 7.2.0-8ubuntu3)) #24-Ubuntu SMP Mon Dec 18 17:29:16 UTC 2017*
> *exp at exp:~$ *
>
> *exp at exp:~$ *
> *exp at exp:~$ lspci | grep VirtualBox*
> *00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox
> Graphics Adapter*
> *00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest
> Service**exp at exp:~$ *
>
>
> *exp at exp:~$ *
> *exp at exp:~$ lsb_release -a*
> *No LSB modules are available.*
> *Distributor ID: Ubuntu*
> *Description: Ubuntu 17.10*
> *Release: 17.10*
> *Codename: artful**exp at exp:~$ *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20180316/bc8eff5e/attachment.html>


More information about the vbox-dev mailing list