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

Bernhard Fröhlich decke at bluelife.at
Fri Mar 16 10:05:00 GMT 2018


On Fri, Mar 16, 2018 at 8:52 AM, Raghavan Santhanam
<raghavanil4m at gmail.com> wrote:
> 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

Yeah, we are building (most parts) with clang on FreeBSD since around virtualbox
4.3.10 so almost 4 years now. The commit back then which might give you a good
summary of the changes is here:

https://svnweb.freebsd.org/ports?view=revision&revision=349473

Beware that also includes patches that are not clang relevant.

-- 
Bernhard Fröhlich
http://www.bluelife.at/



More information about the vbox-dev mailing list