0

My project consists of three static libraries (A, B, and C) and one executable (D). D depends on B and C, while C depends on A and B. A, B and C large libraries (500k lines of code in total). In the past, the three libraries were compiled as shared objects, but were switched to static because of performance issues and bugs. My CMakeLists.txt looks like this:

add_library(A)
add_library(B)
add_library(C)

add_executable(D)
target_link_libraries(D PRIVATE libSomeLib.so C B A)

When I modify one source file (.cpp) from D, the entire executable has to be relinked. Ninja is smart enough to only recompile the modified source file. This edit-compile-run cycle lasts 15 seconds out of which 10 are spent in linking.

I have already implemented precompiled headers which seem to shorten this cycle. I already tried using incremental linking as asked in this question, but I couldn't get it to work in my case.

I am worried that I waste a lot of time while waiting for the linker. I would like to know whether these times are normal and if the architecture of this project is optimal. How would you implement something like this that doesn't take too long to link?

featherless biped
  • 163
  • 1
  • 5
  • 16
  • That's the nature of static libraries, if you're changing any part in the dependency chain? How would you expect changing your executable, won't need to relink it with the static libraries? – πάντα ῥεῖ Jun 18 '23 at 12:50
  • I was hoping for something like incremental linking so that I can modify only the part of the program that has changed. Unfortunately, I could not get it to work with clang. – featherless biped Jun 18 '23 at 12:53

0 Answers0