Skip to content

Faster builds (Linux)

5k3105 edited this page Dec 18, 2021 · 6 revisions

Because this library uses cgo in order to communicate with Qt library, compilation is slow. However there are a few options.

Using ccache

Note the output of the following command (on *nix systems):

# On Arch linux
$ which gcc
/usr/sbin/gcc

# On Ubuntu
$ which gcc
/usr/bin/gcc

After installing ccache, you need update your PATH. In ~/.zshrc or ~/.bashrc:

# On Arch
export PATH="/usr/lib/ccache/bin:$PATH"

# On Ubuntu
export PATH="/usr/lib/ccache:$PATH"

Now you should see something like this:

# On Arch linux
$ which gcc
/usr/lib/ccache/bin/gcc

# On Ubuntu
$ which gcc
/usr/lib/ccache/gcc

Now all your compilations will go through ccache and it does its best job to cache the results. You can query its statistics with ccache -s and clear its cache with ccache -C.

Gold Linker

Qt is a complex library, therefore there are a lot of objects to be linked. This is one reason why your builds are slow. Fortunately there is an alternative to gnu's linker called Gold Linker, which links way faster than gnu's. It comes in binutils on Linux. In order to use it you need to make move the old ld and make a symbolic link to ld.gold. You can find them in these locations:

/usr/bin/ld
/usr/bin/ld.gold

Now your builds should be significantly faster.

Mold

https://github.com/rui314/mold

mold -run qtdeploy

Much faster than GNU Gold (from 1 minute 10 sec -> 12 sec flat).

Clone this wiki locally