Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

Requirements

  • SBCL (Steel Bank Common Lisp) 2.0 or later. Install from sbcl.org or your distribution's package manager (dnf install sbcl, apt install sbcl).
  • Linux kernel 5.3+ for bounded loop support in the BPF verifier. Kernel 5.8+ is recommended for ring buffer maps and BTF support.
  • FiveAM is required only for running the test suite.

Info

Whistler has zero non-Lisp dependencies. No LLVM, no libelf, no kernel headers.

Loading the compiler

Clone the repository and load the system with ASDF:

git clone https://github.com/atgreen/whistler.git
cd whistler

From an SBCL REPL:

(require :asdf)
(push #p"/path/to/whistler/" asdf:*central-registry*)
(asdf:load-system "whistler")
(in-package #:whistler-user)

Or use the Makefile to start a REPL with Whistler already loaded:

make repl

This drops you into the whistler-user package, ready to define maps and programs.

Using Whistler from your own package

A plain (:use :cl :whistler) signals a name conflict. Whistler has its own case, defstruct, incf and decf, which compile to BPF, and the package can't use those and CL's at the same time. Pick Whistler's with uiop:define-package and :mix, which lets the first package listed win each conflict:

(uiop:define-package #:my-probes
  (:mix #:whistler #:whistler/helpers #:whistler/loader #:cl))

Or, with plain defpackage, shadow the four by hand:

(defpackage #:my-probes
  (:use #:cl #:whistler #:whistler/helpers #:whistler/loader)
  (:shadowing-import-from #:whistler #:case #:defstruct #:incf #:decf))

whistler/helpers and whistler/loader are optional. whistler/loader needs the loader system loaded. whistler/helpers gives your editor each BPF helper's argument list (see BPF Helpers); helper calls compile without it. Neither conflicts with CL or Whistler. whistler-user is set up this way already.

Either way, case, defstruct, incf and decf in that package are Whistler's, so ordinary Lisp code in it needs care:

  • case compiles only as BPF; write cl:case in ordinary Lisp code.
  • defstruct also defines a CL-side struct with the same accessors (see defstruct), but takes BPF field types. Use cl:defstruct for a plain Lisp struct.
  • incf and decf expand to (setf place (+ place delta)), which works in ordinary code but evaluates PLACE twice. Prefer cl:incf there.

Loading the userspace loader

The loader is a separate ASDF system that depends on the compiler:

(asdf:load-system "whistler/loader")
(in-package #:whistler-user)

Loading the loader adds it to whistler-user, which then has with-bpf-session, with-bpf-object, ring buffer consumers, and map accessors -- all in pure Common Lisp. (whistler-loader-user, the package's old name, still works.)

Or use the Makefile:

make repl-loader

This is the most convenient day-to-day workflow for Lisp development: compiler, loader, and REPL in one image.

Building the CLI binary

Whistler can be built as a standalone command-line binary using ASDF's program-op:

make

This produces a whistler executable in the repository root. The Makefile runs:

sbcl --noinform --non-interactive \
  --eval '(require :asdf)' \
  --eval '(push #p"./" asdf:*central-registry*)' \
  --eval '(asdf:make "whistler")'

The whistler.asd system definition specifies :build-operation "program-op" and :entry-point "whistler:main", so asdf:make produces a self-contained binary.

Use it to compile BPF source files from the shell:

./whistler compile examples/count-xdp.lisp -o count.bpf.o

Check your local environment before trying to load programs:

./whistler doctor

This reports the local kernel version, tool availability, tracefs/BTF readability, and any obvious missing capabilities.

Running the test suite

Tests require FiveAM:

make test

Or from a REPL:

(asdf:test-system "whistler")

The test suite covers ALU operations, memory access, branching, control flow, protocol parsing, map operations, register allocation, and end-to-end compilation.