Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Blogpost about the build process
Found a blogpost about ELF Linking and Symbol Resolution :: Noratrieb's blog
Simplified summary with questions
cargo build
uses rustc
which compiles each crate separately. Dependencies are also a compilation units (CUs).
Each CU โincluding our own crateโ is compiled to an object file (with.o
suffix). The .o
s have undefined symbols since the deps are not included yet.
Linking is the process of resolving those undefined symbols in the crate's object file.
Static Libraries (.a
) are bundles of object files. They are included in the final binary.
.o
files are included right?For Dynamic Libraries (*.so
) the content is instead searched at Runtime, it's not in the binary. This is done by ld-linux
before our program's main
runs.
In summary, linking static libraries (and object files) resolves the symbol and puts content in; linking dynamic libraries skip the last step (don't put content in).
That's just the intro of the blogpost, the deeper part read in the link.
5 posts - 3 participants
๐ท๏ธ rust_feed