Is dylib library compile faster?

In bevy_dylib:

Dynamic linking causes Bevy to be built and linked as a dynamic library. This will make incremental builds compile much faster.

And in the Book Setup section has:

Enable Bevy's Dynamic Linking Feature: This is the most impactful compilation time decrease!

My question is:

  • How much time does it save compared to normal incremental builds?
  • If faster, what is the reason behind it?

It's likely impossible to give a single accurate number. Compilation speed depends on a whole series of factors. (If we ever find a way to efficiently simulate quantum mechanics in classical computers, it'll probably be via compilation speed benchmarks. </sarcasm>)

Linking a dynamic library only involves hooking up appropriate entries of the symbol tables to each other, while static linking involves copying all the code for all the necessary symbols (and even modifying it, for eg. relocation). So roughly speaking, static linking is O(generated machine code size), while dynamic linking is O(number of symbols).

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.