I have a Go program that uses the Qt wrapper library https://github.com/therecipe/qt. Unfortunately, the build time gets extremely high with it (assuming it's the go part)
go build -i . // takes about 14 seconds
go run . // takes about 8 seconds
After running either of the above commands I get the pre-compiled dependencies in my $GOPATH/pkg/linux_amd64/github.com/therecipe/qt
as .a
files so they are not rebuilding each time.
I've tried to use ccache
and Gold linker /usr/bin/ld.gold
as described in https://github.com/therecipe/qt/wiki/Faster-builds-(Linux) but it didn't improve anything. Also this Qt wrapper ships with its own build tool qtdeploy
which I tried but it is roughly the same build time.
System I'm running on:
go version go1.14.4 linux/amd64
Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
16GB Ram
Would anyone know if it's possible to improve the build time at least a bit?
EDIT:
Running go build -x .
shows that the biggest time consumer is the following command
~/.go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -buildmode=exe -buildid=k8lYa6JYqRdCY9Gyt0jX/16myMybByG5X6rOfaRpS/WHdW2kCTfMCZs2I4x9WE/k8lYa6JYqRdCY9Gyt0jX -extld=g++ ~/.cache/go-build/b5/b5e47b7f77c2df06ba69937dc8b1399b1289b7c90d2e08b3341fdf13e119c860-d
go build -x
and inspect the build log?-x
makesgo build
write out every step it takes to produce the executable image. – Fernandogo build -x
– RaskinCGO_ENABLED=0 go build .
– Misusage-extld=g++
hints at that it's gcc's linker which is slow. I have no immediate idea on how to time it (except for wrappingg++
with a custom script in thePATH
which would somehow instrument a call to the realg++
to help to find out where it's spending). – Fernandocgo
is supposed to work when the program explicitly uses C or C++ library code? – FernandoCGO_ENABLED=0
flag will result in an output (without doing any compiling):package test imports github.com/therecipe/qt/core: build constraints exclude all Go files in /home/dan/Golang/Programs/src/github.com/therecipe/qt/core
. As @Fernando already pointed out, how would that even work if it uses C/C++ library code? – Raskinperf
is a linux tool for profiling, you can find it in thelinux-tools
package in Ubuntu. You can use it by recording the events while running your command (perf record
) or see in real time (perf top
), both using root. The perf tool will profile the calls and give you an idea where your application is hogging. For more info, see perf.wiki.kernel.org/index.php/Tutorial – Carin