DEV Community

Cover image for I got tired of typing nasm/ld/gcc by hand, so I built a tool that does it for me
Alex Voste
Alex Voste

Posted on

I got tired of typing nasm/ld/gcc by hand, so I built a tool that does it for me

If you've ever written assembly or C without CMake, Makefiles, or any build system — you know the ritual.

Open terminal. Remember the flags. Compile one file. Then another. Then link them. Then mess up the argument order. Then do it again. And again. Every. Single. Time.

I did this long enough to finally say: enough.

That's how fz (ForgeZero) was born — a small CLI tool written in Go that takes all the assembly/C build drudgery off your plate. No extra dependencies. No 300-line config files. It just works.


What it actually does

Build a single file — one command

fz -asm hello.asm
fz -cc main.c
Enter fullscreen mode Exit fullscreen mode

No need to remember nasm, fasm, or gcc flags. fz figures out what it's looking at and spits out a binary.

Build an entire project — also one command

fz -dir ./src
Enter fullscreen mode Exit fullscreen mode

Recursively finds all .asm, .s, .fasm, and .c files, compiles each into an object file, then links everything together. Object filenames are unique, so hello_asm.o and hello_s.o don't step on each other.

SHA256 caching — because waiting is pain

Incremental builds without changes are near-instant. fz hashes each source file + build flags, and if nothing changed, the compiler doesn't even get invoked. That's it.

Strict mode for C — no escape from quality

C files are compiled with the full warnings-as-errors suite:

-Wall -Wextra -Werror -Wpedantic -Wshadow -Wconversion
Enter fullscreen mode Exit fullscreen mode

AddressSanitizer and UBSan are on by default. The -strict flag adds use-after-return and use-after-scope, and automatically prefers clang if it's available, falling back to gcc with limited support.

Don't want sanitizers? -no-sanitize. Done.

Watch mode — because hitting ↑ Enter is still too many keystrokes

fz -watch -dir ./src
Enter fullscreen mode Exit fullscreen mode

Watches your source files and config for changes, rebuilds with a 500ms debounce. Save a file, and a second later you've got a fresh binary.

JSON output — for your CI/CD pipelines

fz -json -dir ./src
Enter fullscreen mode Exit fullscreen mode

Returns structured JSON: status, exit code, build time, list of sources and object files, binary name, error message. Easy to parse in any pipeline, no string-scraping needed.

Config file — set it and forget it

Drop a .fz.yaml in your project root and stop passing flags every time:

source_dir: ./src
output: my_program
mode: auto
debug: false
keep_obj: false
exclude:
  - legacy/
Enter fullscreen mode Exit fullscreen mode

Also accepts fz.yaml, .fz.yml, fz.yml — whatever you prefer.


Three linker modes

Not all projects are the same, so you can pick:

Mode What it does
auto Tries gcc, then gcc -no-pie, then ld
c Only gcc (for C projects)
raw Only ld (for pure assembly)

fz also checks for duplicate symbols before linking via nm / objdump, so you get a clean, readable error instead of a linker wall of text.


Linters & formatters

Since fz builds real C and assembly, it plays nicely with the tools you're already using:

C:

  • clang-format — format your sources before/after build
  • clang-tidy — static analysis; pairs well with fz's strict mode
  • cppcheck — extra static checks on top of GCC/clang warnings
  • splint — if you're into really paranoid C checking

Assembly (NASM/GAS):

  • asmfmt — NASM formatter (like gofmt, but for asm)
  • nasm -E — preprocessor pass to inspect macro expansion
  • GAS has no official formatter, but indent-style scripts exist in the wild

Go (fz itself):

  • gofmt / goimports — standard Go formatting
  • golangci-lint — runs staticcheck, errcheck, govet and a bunch more in one shot
  • go vet — built-in static analysis

The philosophy: fz enforces quality at the compiler level (warnings as errors, sanitizers), and you layer your preferred linter on top.


Installation

go install github.com/forgezero-cli/ForgeZero/cmd/fz@latest
Enter fullscreen mode Exit fullscreen mode

You just need Go, plus whatever compilers you're already using (nasm, gcc, fasm). That's it. No package manager drama.


Roadmap (v1.4.0 → v1.5.0)

Here's what's coming:

  • C++ support.cpp files → g++, same strict flags
  • Custom flags-asm-flag, -cc-flag, -ld-flag for when you need to pass something weird
  • Exclude patterns-exclude in CLI and exclude: in config
  • Better error messages — with hints like "did you forget #include <stdio.h>?"
  • Colored output — errors in red, success in green, respects NO_COLOR
  • CI/CD matrix — automated tests on Linux, macOS, Windows
  • Packages — Homebrew tap and AUR package
  • Shell completions — bash, zsh, fish

Current state

Version 1.3.0 is stable, production-ready, with ~70% test coverage, a built-in man page (fz -man), and a colored --help with grouped options and examples.

If you write low-level code and this pain sounds familiar — give it a shot. Feedback and ⭐ on GitHub are always appreciated.

github.com/forgezero-cli/ForgeZero

Top comments (0)