[Interest] update on building Qt/Linux with clang?

Thiago Macieira thiago.macieira at intel.com
Mon Nov 5 21:30:38 CET 2018


On Monday, 5 November 2018 11:33:58 PST René J.V. Bertin wrote:
> On Monday November 05 2018 12:03:31 René J.V. Bertin wrote:
> >In my experience clang generates significantly more compact binaries
> 
> Quite: bzipped tarballs of everything except the examples, translations,
> QWE, QtWebView and Qt3D:

Off-topic: no one uses bzip2 anymore. It's slow to compress, slow to 
decompress and produces worse results than xz.

> -rw-r--r-- 1 root root 363M Sep  8 13:22
> qt5-kde-devel-5.9.6.linux_3.x86_64.tbz2 (1003Mb uncompressed tarball)
> -rw-r--r-- 1 root root 199M Nov  5 19:22
> qt5-kde-devel-5.9.7.linux_3.x86_64.tbz2 (710Mb uncompressed tarball)
> 
> The first built with GCC 8, the 2nd with clang 6.0; identical compiler
> options (release build, -O3, force_debug_info for qtbase).

Please compare debug-stripped binaries.

   text    data     bss     dec     hex filename
7205857  200632    1714 7408203  710a4b lib/libQt5Widgets.so
6727027  197920    1576 6926523  69b0bb clang/libQt5Widgets.so

Both are -O3 -march=native -g1 builds. So yes, the Clang build is smaller, but 
not significantly so. And since -O3 means "aggressively optimise, even if it 
takes longer to compile or increases the size considerably", you don't really 
care about size. Bigger code could indicate more optimisations applied (loop 
unrolling, vectorisation).

Anyway, compare the debug sections of the two:

GCC:
Section Headers:
[Nr] Name                 Type         Off      Size     ES Flags Lk Inf Al
[29] .debug_line          PROGBITS     00710a80 002c360b  0        0   0  1
[30] .debug_info          PROGBITS     009d408b 00567018  0        0   0  1
[31] .debug_abbrev        PROGBITS     00f3b0a3 0002813a  0        0   0  1
[32] .debug_aranges       PROGBITS     00f631e0 0000fd70  0        0   0 16
[33] .debug_str           PROGBITS     00f72f50 001f84b5  1 MS     0   0  1
[34] .debug_ranges        PROGBITS     0116b410 002f3a20  0        0   0 16

Clang:
[28] .debug_aranges       PROGBITS     0069c0a0 00000080  0        0   0 16
[29] .debug_info          PROGBITS     0069c120 004b52fc  0        0   0  1
[30] .debug_abbrev        PROGBITS     00b5141c 00006dea  0        0   0  1
[31] .debug_line          PROGBITS     00b58206 0032d586  0        0   0  1
[32] .debug_str           PROGBITS     00e8578c 000377fb  1 MS     0   0  1
[33] .debug_macinfo       PROGBITS     00ebcf87 000000b6  0        0   0  1
[34] .debug_ranges        PROGBITS     00ebd040 00135ff0  0        0   0 16

Clang carries 9793421 bytes of debug information, while GCC produces 13951906. 
That's a much bigger difference.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center






More information about the Interest mailing list