[llvm-dev] Success : VirtualBox(clang-built): Ubuntu 17.10 x86_64(clang-built kernel/modules)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Success : VirtualBox(clang-built): Ubuntu 17.10 x86_64(clang-built kernel/modules)

Tim Northover via llvm-dev
Hello All,

On Ubuntu 17.10 x86_64 running on clang-built kernel v4.16.3, after fixing a whole bunch of issues around VirtualBox 5.2.8 and Qt5.10.1, I have been able to successfully build VirtualBox 5.2.8(along with its kernel modules) using clang/LLVM(with its integrated-assembler) and bring-up that with Qt5.10.1(also clang-built) requited by VirtualBox GUI. So, I wanted to share the overall experience, research, and final success here for the interested people.

For easy reading with formatting, etc : https://ubuntuforums.org/showthread.php?t=2389838

Cheers.






Issues fixed with respect to VirtualBox 5.2.8 source code, build scripts, compiler/toolchain environment, etc.




  1. Disabled hard-coded gcc check(gcc 4.x...7.x) since clang/LLVM is the compiler/toolchain in use.
    Code:
    File affected : configure
  2. Fixed paths of mesa, sdl, qt5.10.1 etc - these are not installed into default system paths since I have Nvidia hardware-acclerated driver providing the OpenGL/Mesa functionality for my host system - Ubuntu 17.10 x86_64 and I am having qt5.9.1 in the system path for other applications' compatibility which gets broken with qt5.10.1 if installed to system folders(in fact, the latter did happen, it was a big annoyance to fix the qt* stuff back to get my other applications dependent on older qt5.9.1 to again work, and so on).
  3. Corrected $PATH and SDL-specific variables($INCSDL, $LIBSDL) in configure script(passing via command-line args didn't work for some reason).
    Code:
    File affected : configure
  4. Corrected Qt5 tools(for moc, etc) path in configure. File affected : configure
  5. Created symlink to the qt5.10.1 source/lib directory in qt-tools directory of VirtualBox-5.2.8/*
  6. Selectively enabled/disabled c++11 standard for clang++ for applicable C++ source files. Some C++ sources needed c++11 features while some other failed build. Hence, the need.
  7. Disabled any other Qt5(.10.1) installed via the Qt SDK installer.
  8. Despite CC/HOSTCC, CXX/HOSTCXX and other variables set to clang/clang++, there appeared many residual hard-coded gcc/g++ references - so, I wrote placeholder scripts to redirect all the gcc/g++ invocations to clang/clang++ respectively.
  9. Disabled another gcc-specific check in top-level Makefile.kmk.
    Code:
    File affected : Makefile.kmk
  10. iPxe had some variable length arrays, etc and I didn't need iPxe* anyway for my use case, so disabled it.
    Code:
    File affected :  src/VBox/Devices/Makefile.kmk
  11. Comment symbol in an assembly source code was used to be frontslash(/) instead of the usual semi-colon(';'). But, since semi-colon(';') didn't work, used hash(#) - worked.
    Code:
    File affected : VirtualBox-5.2.8/src/libs/xpcom18a4/nsprpub/pr/src/md/unix/os_Linux_x86_64.s
    .
  12. Disabled iPxeBiosBin and NetBiosBinm - not needed for my use case. File affected : src/VBox/Devices/Makefile.kmk
  13. Removed register storage class for the error-flagged(
    Code:
    error: regiser 'r14' unsuitable for global register variables on this
    ). After completing all of my effort in this project, I researched on this error and found rbp register needs to be used in place of r14(AREG0) register when using clang instead of gcc. But, the latter didn't work : resulted in another error shown below. So, removed the register qualifier therein. So far, I didn't see any issues within the guest with this logic.
    Code:
    File affected : VirtualBox-5.2.8/src/recompiler/target-i386/exec.h
    Code:
    fatal error: error in backend: register rbp is allocatable: function has no frame pointer
    clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
  14. Used limits.h in place of not-found syslimits.h.
    Code:
    File affected : VirtualBox-5.2.8/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceLibCWrappers.h
  15. For Qt5X11Extras libs : added symlinks for qtx11extras/lib/* under qtbase/lib/* - to keep all the libs referenced from one place
  16. Disabled reference to g_abNetBiosBinary as iPxe* are disabled - not needed for my use case.
    Code:
    File affected : src/VBox/Devices/build/VBoxDD2.cpp
  17. Disabled all the VBox test cases - not needed for my use case - so ignored any errors therein.
    Code:
    File affected : src/VBox/Frontends/VBoxHeadless/testcase/Makefile.kmk and src/VBox/Frontends/VBoxSDL/Makefile.kmk
  18. Disabled reference to g_abNetBiosBinary as iPxe* are disabled - not needed for my use case.
    Code:
    File affected : VirtualBox-5.2.8/src/VBox/Devices/PC/DevPcBios.cpp
  19. Reordered libpthread and libdl linking them in the last(appended to LDFLAGS) so that there were no "undefined reference..." errors for dlclose and sem_getvalue symbols.
    Code:
    File affected : ./src/VBox/Frontends/VBoxSDL/Makefile.kmk
  20. Fixed package string to be free from space - caused issue as the clang/preprocessing considered them as two strings due to a space between them(rdesktop 1.8.3) : inserted a hyphen(- : rdesktop-1.8.3) between them to fix this issue.
    Code:
    File affected : src/VBox/RDP/client-1.8.3/configure. File affected : src/VBox/RDP/client-1.8.3/Makefile.kmk
  21. Added qtx11extras INC paths needed using CXXFLAGS.
    Code:
    File affected : VirtualBox-5.2.8/src/VBox/Frontends/VirtualBox/Makefile.kmk
  22. Fixed missing lrelease Qt tool by copying it from qt-everywhere-src-5.10.1/qttools/bin/ to qt-everywhere-src-5.10.1/qtbase/bin/. Earlier, symlinking it from between them didn't work - complained about some libQt5*.so* not found, etc - so copied that lrelease.
  23. Disabled other test cases.
    Code:
     File affected : src/VBox/Runtime/Makefile.kmk
  24. VirtualBox build completed without any errors.
  25. For Qt5 libs, added qt-everywhere-src-5.10.1..qtbase..lib path to LD_LIBRARY_PATH(in cmd line)
  26. Fixed "could not find or load the Qt platform plugin "xcb"" issue by providing QT_QPA_PLATFORM_PLUGIN_PATH(in cmd line) with the appropriate path having Qt xcb library(libqxcb.so*) needed for VirtualBox - this was annoying to the core as there was no hint from where it was searching for that lib - I thought of using strace on it and finally that gave away the path to fix it after a lot of debugging, searching on the internet, etc. By the way, I did *not* install my clang-built Qt5.10.1 onto system paths since there were some other applications that weren't compatible with Qt5.10.1 and needed the older Qt versions for them to properly work. My post on this can be found here : https://askubuntu.com/questions/3081...017955#1017955 and https://unix.stackexchange.com/a/432606/275686
  27. VirtualBox was launched - no issues.
  28. Ubuntu 17.10 VM was started with thus clang-built VirtualBox - failed to run with undefined symbol(memset and also memcpy, in individual cases) needed by VBoxDDR0.r0. 

    Code:
    <ui_error> 
    Failed to load R0 module .../VirtualBox-5.2.8_final/VirtualBox-5.2.8/out/linux.amd64/release/bin/VBoxDDR0.r0: Unable to locate imported symbol 'memset' for module 'VBoxDDR0.r0' (VERR_SYMBOL_NOT_FOUND). 
    Failed to register ourselves as a PCI Bus (VERR_MODULE_NOT_FOUND). 
    Result Code: 
    NS_ERROR_FAILURE (0x80004005) 
    Component: 
    ConsoleWrap 
    Interface: 
    IConsole {872da645-4a9b-1727-bee2-5585105b9eed} 
    </ui_error>
  29. Added my own implementations of memcpy and memset in existing headers - didn't work - same "undefined symbol..." error as above.
    Code:
    File affected : ./include/iprt/nocrt/string.h. File affected : ./include/iprt/string.h
  30. Added new module with my own implementations of memcpy and memset.
    Code:
    New file : VirtualBox-5.2.8/my_mem.c
  31. Added my new module to VBoxDDR0 sources list for the sake of VBoxDDR0.cpp which uses memset, etc and that's where "undefined symbol..." error was flagged from.
    Code:
    File affected : ./src/VBox/Devices/Makefile.kmk
  32. Updated VirtualBox/About dialog box metadata with information of clang/LLVM/kernel/Ubuntu used in this research and success.
    Code:
    File affected : ./src/VBox/Frontends/VirtualBox/src/VBoxAboutDlg.cpp
  33. VirualBox kernel modules were also built using clang/LLVM(with its integrated-assembler) - no build issues.
  34. Fixed "driver not accessible" specific to /dev/vboxdrv by changing its permission and ownership to current user.
  35. Final command that successfully brings up thus clang-built VirtualBox : 
    Code:
    QT_QPA_PLATFORM_PLUGIN_PATH=/home/exp/clang-virtualbox/qt-everywhere-src-5.10.1/qtbase/plugins/platforms LD_LIBRARY_PATH=/home/exp/clang-virtualbox/qt-everywhere-src-5.10.1/qtbase/lib ./VirtualBox





NOTE : During the course of the above research, experiment, and success, my system got so messed up with different Qt(5/4)* versions,
mesa drivers, etc so that my host Ubuntu 17.10 system lost its graphics configuration and while trying to restore by getting rid
of the newly installed mesa drivers(I use Nvidia hardware-acclerated drivers for OpenGL/Mesa as mentioned in the beginning), etc,
at somepoint, the removal(apt remove..) got interrupted and after sometime, when I rebooted, booting got stuck with a black screen
- I lost the home directory itself! So, at that point, I thought I had lost whole lot of data for the sake of above research and
what not. So, booted the system to Ubuntu-recovery mode, and ran all the fsck, testdisk(TestDisk tool), etc to recover the home directory
if possible - even then, it was not visible readily when I ran those tests, etc. At that point, I had decided that I will *not* do
any more research or any more effort in anything that damages/fiddles with my system graphics(mesa, etc)! But, when I rebooted,
for my relief, I got back the Ubuntu-screen and system started booting(so, it looked like testdisk, etc worked actually in recovering
some lost i-nodes in the corrupted file system?!). Thereafter, reinstalled all the Nvidia graphics again, removed the mesa drivers, etc
and finally got my system back to its sane state. Thus, after couple of days, I got some more motivation again to continue where
I had stopped this research of building VirtualBox with clang/LLVM with Qt5.10.1(also clang-built by me). This time, I decided,
I won't install the built mesa/SDL, etc into system paths but keep them in known locations and provide those paths for the VirtualBox
configure script as mentioned in the beginning - thus, I was able to build VirtualBox using clang/LLVM thereafter and finally after
fixing all the above issues. I had completed VirtualBox-clang/LLVM stuff already without building Qt5.10.1 myself with clang/LLVM
but using installed Qt5.10.1 - but I wanted the whole thing to be clang-built(VirtualBox + Qt5.10.1). So, took Qt5.10.1 source and
built it from its source(that had some more issues and they are mentioned below at the end for the interested people) using clang/LLVM.
Finally, rebuilt VirtualBox entirely for the second set of attempts, with this clang-built Qt5.10.1 and after fixing all the above
listed issues, I was able to successfully bring up clang-built VirtualBox on clang-built kernel 4.16.3/Ubuntu 17.10 x86_64.





Platform Info(host and guest)

On host Ubuntu 17.10 x86_64


Code:
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 17.10
Release:    17.10
Codename:    artful
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$


.../VirtualBox-5.2.8$ cat /proc/version 
Linux version 4.16.3 (exp@exp) (clang version 5.0.0-3 (tags/RELEASE_500/final)) #1 SMP Thu Apr 19 05:00:08 PDT 2018
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 


.../VirtualBox-5.2.8$ ./VirtualBox --help
++ QT_QPA_PLATFORM_PLUGIN_PATH=.../qt-everywhere-src-5.10.1/qtbase/plugins/platforms
++ LD_LIBRARY_PATH=.../qt-everywhere-src-5.10.1/qtbase/lib
++ out/linux.amd64/release/bin/VirtualBox --help


Oracle VM VirtualBox Manager 5.2.8
 ## Built from src - clang/LLVM-kernel-Ubuntu-17.10 by Raghavan Santhanam
 ## with Qt5.10.1 - Built from src - clang/LLVM-kernel-Ubuntu-17.10 by Raghavan Santhanam


(C) 2005-2018 Oracle Corporation
All rights reserved.


Usage:
  --startvm <vmname|UUID>    start a VM by specifying its UUID or name
  --separate                 start a separate VM process
  --normal                   keep normal (windowed) mode during startup
  --fullscreen               switch to fullscreen mode during startup
  --seamless                 switch to seamless mode during startup
  --scale                    switch to scale mode during startup
  --no-startvm-errormsgbox   do not show a message box for VM start errors
  --restore-current          restore the current snapshot before starting
  --no-aggressive-caching    delays caching media info in VM processes
  --fda <image|none>         Mount the specified floppy image
  --dvd <image|none>         Mount the specified DVD image
  --dbg                      enable the GUI debug menu
  --debug                    like --dbg and show debug windows at VM startup
  --debug-command-line       like --dbg and show command line window at VM startup
  --debug-statistics         like --dbg and show statistics window at VM startup
  --no-debug                 disable the GUI debug menu and debug windows
  --start-paused             start the VM in the paused state
  --start-running            start the VM running (for overriding --debug*)


Expert options:
  --disable-patm             disable code patching (ignored by AMD-V/VT-x)
  --disable-csam             disable code scanning (ignored by AMD-V/VT-x)
  --recompile-supervisor     recompiled execution of supervisor code (*)
  --recompile-user           recompiled execution of user code (*)
  --recompile-all            recompiled execution of all code, with disabled
                             code patching and scanning
  --execute-all-in-iem       For debugging the interpreted execution mode.
  --warp-pct <pct>           time warp factor, 100% (= 1.0) = normal speed
  (*) For AMD-V/VT-x setups the effect is --recompile-all.


The following environment (and extra data) variables are evaluated:
  VBOX_GUI_DBG_ENABLED (GUI/Dbg/Enabled)
                             enable the GUI debug menu if set
  VBOX_GUI_DBG_AUTO_SHOW (GUI/Dbg/AutoShow)
                             show debug windows at VM startup
  VBOX_GUI_NO_DEBUGGER       disable the GUI debug menu and debug windows


.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 


.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ eclang VirtualBox-5.2.8/out/linux.amd64/release/bin/VirtualBox 
++ strings -a VirtualBox-5.2.8/out/linux.amd64/release/bin/VirtualBox
++ grep 'clang version'
++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$
Within guest Ubuntu 17.10 x86_64



Code:
exp@exp:~$ 
exp@exp:~$ dmesg | grep VirtualBox
[    0.000000] DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[    1.538806] usb 1-1: Manufacturer: VirtualBox
[    1.561604] input: VirtualBox USB Tablet as /devices/pci0000:00/0000:00:1f.4/usb1/1-1/1-1:1.0/0003:80EE:0021.0001/input/input6
[    1.561781] hid-generic 0003:80EE:0021.0001: input,hidraw0: USB HID v1.10 Mouse [VirtualBox USB Tablet] on usb-0000:00:1f.4-1/input0
exp@exp:~$ 
exp@exp:~$ 


exp@exp:~$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 17.10
Release:    17.10
Codename:    artful
exp@exp:~$ 

exp@exp:~$ 
exp@exp:~$ sudo dmidecode -t system | grep "Manufacturer\|Product"
    Manufacturer: innotek GmbH
    Product Name: VirtualBox
exp@exp:~$ 
exp@exp:~$ 

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



exp@exp:~$ 
exp@exp:~$ sudo dmidecode -t baseboard | grep "Manufacturer\|Product\|Vendor\|Version"
    Manufacturer: Oracle Corporation
    Product Name: VirtualBox
    Version: 1.2
exp@exp:~$ 


exp@exp:~$ 
exp@exp:~$ cat /proc/cpuinfo | grep "processor\|vendor_id\|model"
processor    : 0
vendor_id    : GenuineIntel
model        : 60
model name    : Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
processor    : 1
vendor_id    : GenuineIntel
model        : 60
model name    : Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
exp@exp:~$ 

exp@exp:~$ 
exp@exp:~$ sudo dmidecode --version
3.1
exp@exp:~$ 

exp@exp:~$ 
exp@exp:~$ sudo dmidecode
# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 2.5 present.
10 structures occupying 449 bytes.
Table at 0x000E1000.


Handle 0x0000, DMI type 0, 20 bytes
BIOS Information
    Vendor: innotek GmbH
    Version: VirtualBox
.
.
Handle 0x0001, DMI type 1, 27 bytes
System Information
    Manufacturer: innotek GmbH
    Product Name: VirtualBox
    Version: 1.2
.
.
Handle 0x0008, DMI type 2, 15 bytes
Base Board Information
    Manufacturer: Oracle Corporation
    Product Name: VirtualBox
    Version: 1.2
.
.
Handle 0x0003, DMI type 3, 13 bytes
Chassis Information
    Manufacturer: Oracle Corporation
.
.
Handle 0x0002, DMI type 11, 7 bytes
OEM Strings
    String 1: vboxVer_5.2.8
    String 2: vboxRev_120774
.
.


exp@exp:~$ 
exp@exp:~$ 
exp@exp:~$ uname -arv
Linux exp 4.13.0-38-generic #43-Ubuntu SMP Wed Mar 14 15:20:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
exp@exp:~$ 


exp@exp:~$ 
exp@exp:~$ cat /proc/version
Linux version 4.13.0-38-generic (buildd@lgw01-amd64-042) (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)) #43-Ubuntu SMP Wed Mar 14 15:20:44 UTC 2018
exp@exp:~$ 
exp@exp:~$ 
exp@exp:~$
On host Ubuntu 17.10 x86_64[contd..]


Code:
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ ~/vbox-driver-compiler.sh 
++ head -1
+++ uname -r
++ eclang /lib/modules/4.16.3/misc/vboxdrv.ko
+++ strings -a /lib/modules/4.16.3/misc/vboxdrv.ko
+++ grep 'clang version'
+++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
++ head -1
+++ uname -r
++ eclang /lib/modules/4.16.3/misc/vboxpci.ko
+++ strings -a /lib/modules/4.16.3/misc/vboxpci.ko
+++ grep 'clang version'
+++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
++ head -1
+++ uname -r
++ eclang /lib/modules/4.16.3/misc/vboxnetflt.ko
+++ strings -a /lib/modules/4.16.3/misc/vboxnetflt.ko
+++ grep 'clang version'
+++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
++ head -1
+++ uname -r
++ eclang /lib/modules/4.16.3/misc/vboxnetadp.ko
+++ strings -a /lib/modules/4.16.3/misc/vboxnetadp.ko
+++ grep 'clang version'
+++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ ~/vbox-driver-modules-version.sh 
++ grep '^version='
+++ uname -r
++ strings -a /lib/modules/4.16.3/misc/vboxdrv.ko
version=5.2.8 r120774 (0x00290001)
++ grep '^version='
+++ uname -r
++ strings -a /lib/modules/4.16.3/misc/vboxpci.ko
version=5.2.8 r120774
++ grep '^version='
+++ uname -r
++ strings -a /lib/modules/4.16.3/misc/vboxnetadp.ko
version=5.2.8 r120774 ((0xA2CDe001U))
++ grep '^version='
+++ uname -r
++ strings -a /lib/modules/4.16.3/misc/vboxnetflt.ko
version=5.2.8 r120774 ((0xA2CDe001U))
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 


.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ uname -arv
Linux exp 4.16.3 #1 SMP Thu Apr 19 05:00:08 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 


.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ eclang /lib/modules/4.16.3/build/vmlinux
++ strings -a /lib/modules/4.16.3/build/vmlinux
++ grep 'clang version'
++ head -1
Linux version 4.16.3 (exp@exp) (clang version 5.0.0-3 (tags/RELEASE_500/final)) #1 SMP Thu Apr 19 05:00:08 PDT 2018
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 


.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ clang -v
clang version 5.0.0-3 (tags/RELEASE_500/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin


.../VirtualBox-5.2.8$
.../VirtualBox-5.2.8$ clang++ -v
clang version 5.0.0-3 (tags/RELEASE_500/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin


.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ ls -lrt out/linux.amd64/release/bin/src/*.ko
-rw-r--r-- 1 g g 4094920 Apr 19 16:10 out/linux.amd64/release/bin/src/vboxdrv.ko
-rw-r--r-- 1 g g  644392 Apr 19 16:11 out/linux.amd64/release/bin/src/vboxnetflt.ko
-rw-r--r-- 1 g g  349216 Apr 19 16:11 out/linux.amd64/release/bin/src/vboxnetadp.ko
-rw-r--r-- 1 g g  567168 Apr 19 16:11 out/linux.amd64/release/bin/src/vboxpci.ko
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 


.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ eclang out/linux.amd64/release/bin/src/*.ko
++ strings -a out/linux.amd64/release/bin/src/vboxdrv.ko out/linux.amd64/release/bin/src/vboxnetadp.ko out/linux.amd64/release/bin/src/vboxnetflt.ko out/linux.amd64/release/bin/src/vboxpci.ko
++ grep 'clang version'
++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ eclang out/linux.amd64/release/bin/src/vboxpci.ko | head -1
++ strings -a out/linux.amd64/release/bin/src/vboxpci.ko
++ grep 'clang version'
++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ eclang out/linux.amd64/release/bin/src/vboxnetadp.ko | head -1
++ strings -a out/linux.amd64/release/bin/src/vboxnetadp.ko
++ grep 'clang version'
++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
.../VirtualBox-5.2.8$ eclang out/linux.amd64/release/bin/src/vboxnetflt.ko | head -1
++ strings -a out/linux.amd64/release/bin/src/vboxnetflt.ko
++ grep 'clang version'
++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
.../VirtualBox-5.2.8$ eclang out/linux.amd64/release/bin/src/vboxdrv.ko | head -1
++ strings -a out/linux.amd64/release/bin/src/vboxdrv.ko
++ grep 'clang version'
++ head -1
clang version 5.0.0-3 (tags/RELEASE_500/final)
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$


.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ strings -a out/linux.amd64/release/bin/src/vboxdrv.ko | grep "^version="
version=5.2.8 r120774 (0x00290001)
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ strings -a out/linux.amd64/release/bin/src/vboxpci.ko | grep "^version="
version=5.2.8 r120774
.../VirtualBox-5.2.8$ strings -a out/linux.amd64/release/bin/src/vboxnetadp.ko | grep "^version="
version=5.2.8 r120774 ((0xA2CDe001U))
.../VirtualBox-5.2.8$ 
.../VirtualBox-5.2.8$ strings -a out/linux.amd64/release/bin/src/vboxnetflt.ko | grep "^version="
version=5.2.8 r120774 ((0xA2CDe001U))
.../VirtualBox-5.2.8$




Qt5.10.1 built with clang/LLVM - success and issues









  1. Downloaded qt-everywhere-src-5.10.1.zip(https://download.qt.io/archive/qt/5....src-5.10.1.zip) first, extracted, and tried to run "configure" - failed with (error - /bin/sh^M: bad interpreter: No such file or directory). This was due to CR-LF DOS line-ending format in the files instead of LF Unix line-ending format. Doing "dos2unix" on the top-level "configure" script fixed the issue at the top-level, but the subsequent scripts failed with the same CR-LF DOS vs LF Unix line-ending issue as under. Ran dos2unix recursively on the entire qt-everywhere-src-5.10.1/* and that fixed this issue entirely. It's likely that this qt-everywhere-src-5.10.1.zip has been created on a Windows system and hence the DOS-CR/LF line-ending instead of Unix-LF line-ending - just my observation.
    Code:
    ...qt-everywhere-src-5.10.1$ 
    ...qt-everywhere-src-5.10.1$ unzip ../qt-everywhere-src-5.10.1.zip
    ...qt-everywhere-src-5.10.1$ ./configure -platform linux-clang
    bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory
    .../qt-everywhere-src-5.10.1$ 
    ...qt-everywhere-src-5.10.1$ 
    ...qt-everywhere-src-5.10.1$ dos2unix configure
    dos2unix: converting file configure to Unix format...
    ...qt-everywhere-src-5.10.1$ 
    ...qt-everywhere-src-5.10.1$ ./configure -platform linux-clang
    + cd qtbase
    + .../qt-everywhere-src-5.10.1/qtbase/configure -top-level -platform linux-clang
    ./configure: .../qt-everywhere-src-5.10.1/qtbase/configure: /bin/sh^M: bad interpreter: No such file or directory
    ./configure: line 49: .../qt-everywhere-src-5.10.1/qtbase/configure: Success
    ...qt-everywhere-src-5.10.1$ 
    ...qt-everywhere-src-5.10.1$
  2. After solving the above issue, checked if qt-everywhere-src-5.10.1.tar.xz(https://download.qt.io/archive/qt/5....-5.10.1.tar.xz) also had the same issue though I knew it might not have since usually on tar.* archives are not popular among Windows systems but *zip archive formats. Extracted it as usual and didn't see any CR-LF/LF line-ending format issue for configure, etc.
  3. Fixed a macro definiton, PACKAGE_STRING, by removing space and placing a hyphen(could be anything but space) - space caused clang to truncate the macro at space causing the latter part of the string to be separate from the definition. Also, escaping the space didn't work. 
    Code:
    File affected : qtwebengine/src/3rdparty/chromium/third_party/libsrtp/BUILD.gn
    Code:
    Error : 
    ++ /usr/bin/clang -fintegrated-as -integrated-as ........... '-DPACKAGE_STRING="libsrtp2\' '2.1.0-pre"' ...................
    clang: error: no such file or directory: '2.1.0-pre"'
    [10/32] CC obj/third_party/libsrtp/libsrtp/crypto_kernel.o
    FAILED: obj/third_party/libsrtp/libsrtp/crypto_kernel.o
  4. Selectively enabled/disabled C++11 support for some C++ source code - added -std=c++11 to clang++ command-line.

    Code:
    Error :
    qt-everywhere-src-5.10.1/qtbase/include/QtCore/../../src/corelib/global/qcompilerdetection.h:567:6: 
    error: Qt requires a  C++11 compiler and yours does not seem to be that.
    #    error Qt requires a C++11 compiler and yours does not seem to be that.
  5. Finally, after a long period of time(spread over several days due to the time-consuming fetching of *chromium* source code and also having patience, time and motivation to fix narrow down above issues one by one), I was able to successfully built Qt5.10.1 from its source using clang-LLVM on Ubuntu 17.10 x86_64.



Code:
exp@exp:~$ 
exp@exp:~$ uname -arv
Linux exp 4.16.3 #1 SMP Thu Apr 19 05:00:08 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux
exp@exp:~$ 
exp@exp:~$
exp@exp:~$ cat /proc/version 
Linux version 4.16.3 (exp@exp) (clang version 5.0.0-3 (tags/RELEASE_500/final)) #1 SMP Thu Apr 19 05:00:08 PDT 2018
exp@exp:~$
exp@exp:~$


exp@exp:~$
exp@exp:~$ eclang /lib/modules/4.16.3/build/vmlinux
++ strings -a /lib/modules/4.16.3/build/vmlinux
++ grep 'clang version'
++ head -1
Linux version 4.16.3 (exp@exp) (clang version 5.0.0-3 (tags/RELEASE_500/final)) #1 SMP Thu Apr 19 05:00:08 PDT 2018
exp@exp:~$
exp@exp:~$


exp@exp:~$
exp@exp:~$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 17.10
Release:    17.10
Codename:    artful
exp@exp:~$
exp@exp:~$


exp@exp:~$ 
exp@exp:~$ eclang ./qt-everywhere-src-5.10.1/qtbase/bin/qmake 
++ strings -a ./qt-everywhere-src-5.10.1/qtbase/bin/qmake
++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)
clang version 5.0.0-3 (tags/RELEASE_500/final)
exp@exp:~$ 
exp@exp:~$ eclang ./qt-everywhere-src-5.10.1/qtbase/bin/moc
++ strings -a ./qt-everywhere-src-5.10.1/qtbase/bin/moc
++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)
exp@exp:~$ 
exp@exp:~$ 


exp@exp:~$ 
exp@exp:~$ ./qt-everywhere-src-5.10.1/qtbase/bin/moc -v
moc 5.10.1
exp@exp:~$ 


exp@exp:~$ ./qt-everywhere-src-5.10.1/qtbase/bin/qmake -v | head -1
QMake version 3.1
exp@exp:~$ 
exp@exp:~$ 
exp@exp:~$ 
exp@exp:~$ eclang ./qt-everywhere-src-5.10.1/qtbase/lib/libQt5Core.so.5.10.1 
++ strings -a ./qt-everywhere-src-5.10.1/qtbase/lib/libQt5Core.so.5.10.1
++ grep 'clang version'
clang version 5.0.0-3 (tags/RELEASE_500/final)
exp@exp:~$ 
exp@exp:~$



_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev