Skip to the content ForoHackers
Log inJoin

Build systems: start here

Build systems
#3351 · · Quote · Report

A build system turns source files into something that runs: it decides what to compile, in which order, with which flags, and what it can skip because nothing changed. A good one is fast, correct and repeatable, so the same inputs give the same output on your machine, a colleague's and a server.

Key concepts

  • Dependency graph: targets depend on inputs and on each other; the tool walks the graph in order.
  • Incremental builds: rebuild only what changed, which needs every input to be declared.
  • Reproducibility: pinned tools and dependencies, and no hidden state from the environment.
  • Dependency management: fetching libraries at fixed versions, with checks of what was fetched.
  • Caching and parallelism: independent steps run at once, and results are reused.

Vocabulary

  • Target: something to build, such as a library or a binary.
  • Artifact: the file a build produces.
  • Make: the classic tool built around rules and timestamps.
  • Lock file: a record of the exact versions a build used.

What to study, in order

  1. Write a Makefile by hand for a small C project, with header dependencies.
  2. Read the compiler and linker commands your build runs and explain each flag.
  3. Use your language's standard build tool, and inspect how it resolves dependencies.
  4. Make a build reproducible: pin everything, build twice and compare the results byte for byte.
  5. Try a build tool with a strict dependency graph and see what breaks when an input is undeclared.

Related tags

#toolchains #ci-cd #compilers #developer-tools

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply