16.3 · Static and dynamic linking, duplicate symbols, and the dependency graph

How modules are linked decides launch time, binary size and a class of bugs that appear only at link or run time. The shape of the graph decides what can build in parallel.

Mental model. Static copies code into the app at link time; dynamic loads a separate image at launch. The dependency graph must be a directed acyclic graph, and its shape is your build speed.

Link types

Static versus dynamic, and duplicate symbols.

  1. How do static and dynamic linking differ for an app, what do they cost at launch and in size, and what are duplicate symbols? 16.3.1 · L5
    Static linking copies the needed code from a library (.a, or a static framework) into the final executable at build time. There is nothing to load at launch…

The graph

Cycles, layering and depth.

  1. Why must the module dependency graph be acyclic, how do you layer it, and what does its shape do to build times? 16.3.2 · L5
    A module must be compiled after everything it imports, so dependencies must form a directed acyclic graph. If A depends on B and B on A, neither can be built…

More in Modularization & SPM