Skip to content

Instantly share code, notes, and snippets.

@qguv
Created February 3, 2023 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qguv/979053535b8d12d5e19ecf545b708bd2 to your computer and use it in GitHub Desktop.
Save qguv/979053535b8d12d5e19ecf545b708bd2 to your computer and use it in GitHub Desktop.
build a C binary step-by-step
libs = -lc
rule compile
command = gcc -Wall -Werror -Wpedantic -S -o $out $in
rule assemble
command = gcc -c -o $out $in
rule link
command = gcc $libs -o $out $in
build main.s: compile main.c
build main.o: assemble main.s
build main: link main.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment