0

Our build system uses pkg-config to build the software, but the linking can take very long (sometimes up to 20 minutes). We identified pkg-config as the guilty tool.

So, is there a faster alternative to pkg-config? Or, are there some settings to use to speed up the linking?

PS I am not sure if this question is relevant for this question.

2
  • 3
    Are you certain pkg-config is the problem? That's just used to get build options (usually) which is orders of magnitude faster than actual linking (linking can be very expensive, especially with large-ish C++ code).
    – Mat
    Mar 27, 2012 at 11:00
  • @Mat When I do top, I see pkg-config blocking the CPU. I also did vmstat 1 and I see that both high disk access and high CPU usage. The code is large, but I don't think it should take 20 minutes to link an application. It is not that large. And I see it happening randomly. Mar 27, 2012 at 11:09

3 Answers 3

3

Is pkg-config being invoked multiple times with the same options? This could happen if you have an invocation of it embedded into a Makefile's LDFLAGS variable or similar.

With GNU Make, at least, if you call an external program via backticks, it is recalled every time it is referenced. E.g., in this instance, you'll get two different outputs:

foo = `date`
asdfsdf:
    echo $(foo)
    sleep 4
    echo $(foo)

However if you use the shell function, the result is evaluated only once:

foo = $(shell date)
asdfsdf:
    echo $(foo)
    sleep 4
    echo $(foo)
0

There are other build tools such as scons and cmake which maybe faster.

However, since your performance happens randomly, I would do more investigation before doing a large scale restructure of your build system.

4
  • But even for those, you have to somehow pass compiler/linker options. And for that you need pkg-config (unless you set them in your makefile, or whatever is used). Mar 27, 2012 at 11:56
  • 2
    Have you tried running those pkg-config commands on their own, not as part of the build system? Mar 27, 2012 at 12:12
  • They still block even if run on their own. Mar 27, 2012 at 12:27
  • 3
    Have you tried to strace them to see where/why they block? Mar 27, 2012 at 13:06
0

My colleague found pykg-config, which proved to be much faster then pkg-config.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .