The fly Command Line

fly compiles a directory, not a list of files. You never pass source files on the command line: the compiler discovers the entry point from the source root and pulls everything else in through the import graph.

fly                      # build the program rooted in the current directory
fly --src-dir src        # build the program rooted in ./src
fly --suite              # build ONE test binary with every suite, and run it
fly --lib                # the whole directory becomes a library

An unknown option is an error — fly never ignores a flag silently. From 0.16.0 the same holds for everything else on the command line: a missing or invalid value (-O4, -j abc, --suite=), a directory that does not exist (-L, --src-dir), two output formats, an argument too many, an option written before a subcommand (fly -v build) and an option a subcommand does not take (fly build --relase) all stop fly with exit 1. Up to 0.15.x they were ignored, clamped or taken as something else.


Source discovery

The source root is the current directory, or --src-dir <dir>. What becomes the entry depends on the build mode:

ModeEntry
defaultthe single file declaring a top-level main() (two mains = error)
--suite (test mode)every file declaring a suite (see Testing)
--lib / --lib-dynevery source — the directory is the library

The entry's import closure pulls the remaining sources automatically, and so do the other files of each namespace it reaches — the files with no namespace are one namespace, the default one, so a main.fly without a namespace brings in every other file without one (from 0.16.0); std namespaces resolve against the .fly.h headers next to the compiler (and any -L package dir) and link from their archives.

The walk never descends into a directory whose name starts with a dot (.fly, .git, …) — so what Fly writes cannot break discovery. Up to 0.15.x it also skipped every directory named build, which the bootstrap of Fly used.

Nothing else is left out without a word (from 0.16.0): a directory the walk cannot list, or an entry it cannot reach, stops the build with error: cannot read directory '<path>' (error: cannot read '<path>'), and fly fmt reports it and exits with 2. On Windows a source file may lie under a path longer than 260 characters — the limit of the system calls the runtime used up to 0.15.x, which went on without the file; no setting of the machine is needed. Two limits of Windows itself remain: the current directory and the executable a process is started from must stay within 260 characters.

--src-dir is repeatable. The first one is the discovery root; all of them resolve imports. That is how a program links against a source tree it does not live in:

fly --src-dir tools/admin --src-dir app

--entry: a second executable from the same tree

--entry <file> names the file declaring main() outright, so discovery never runs.

Without it, the command above fails when app also declares a main(): two entry points in the discovery set is an error. With it, only the named file is the entry; the rest of every source root is still reachable through its import closure.

fly --entry tools/admin/Admin.fly --src-dir tools/admin --src-dir app -o admin

The named file holds the program's only main() (from 0.16.0): a file that declares a top-level main() of its own is never part of the build, even when it is in the entry's namespace. So the second program needs no namespace of its own: with Admin.fly and app/main.fly both without one, the build above takes Admin.fly and leaves main.fly out, where the default namespace would otherwise hold two main(). A function the entry needs must not live in a file with another main().

--entry is incompatible with --lib/--lib-dyn: a library has no entry.

With --test or --suite, --entry names one suite file, built on its own (from 0.16.0; up to 0.15.x the combination was refused). The executable holds that suite alone, whatever other suites lie under the source roots:

fly --suite --entry test/MathSuite.fly --src-dir . -o math_suite

A suite built this way reads what it imports, looked for under every source root, and nothing else: no other file declaring a suite is ever read, and a suite file with no namespace does not bring in the other files with no namespace. This is the build fly test runs for each suite of a project.


The three option axes

Output is controlled by three independent axes. Combining them incompatibly is a diagnosed error — no axis silently rewrites another.

FORMAT — what artifact a compiled unit produces:

OptionArtifact
(default)native object, then linked
--emit-llLLVM IR (.ll)
--emit-bcLLVM bitcode (.bc)
--emit-as, -Starget assembly (.s)

One format per build: two different ones (--emit-ll --emit-bc) are an error (from 0.16.0; up to 0.15.x the last one won).

STAGE — how far the pipeline runs:

OptionEffect
(default)compile and link
-ccompile only, do not link
--no-outputparse and analyse only (type-check), produce nothing

SHAPE — what the link produces:

OptionProduct
(default)executable
--lib, --lib-staticone merged object + the declaration artifacts (see below); the archive is built on top
--lib-dyn, --lib-dynamicdynamic library + the declaration artifacts, implies PIC. -o dyn writes dyn.so (Linux), dyn.dylib (macOS) or dyn.dll (Windows): the system's extension is added unless -o already carries it. See Dynamic libraries
--headeronly the declaration artifacts, no object

What a library ships

Each public module produces exactly one <module>.fly.h. A library directory holds those and the archive — no other textual file.

The header is named after the source file (str.fly gives str.fly.h). From 0.16.0, source files of one library that share a base name in different directories put their namespace in the header's name: a/p.fly (namespace a) and b/p.fly (namespace b) give a.p.fly.h and b.p.fly.h. Two such files with the same namespace, or with none, are an error that names both. Up to 0.15.x the second header silently replaced the first.

Most of a header is declarations: signatures with no bodies, since the code lives in the archive. The exception is a generic class or function, which the header carries as source, body included. Monomorphization re-walks a template's syntax with the type parameter bound to a concrete type, so — exactly as in C++ headers or Rust's rlib metadata — no compiled form of a template can be shipped in its place.

A public class is declared with every field, since the layout of its objects needs them all, and with every method and constructor that is not private, in the order the class declares them. From 0.16.0 each member is written with its modifiers (private, protected, static, const, final, abstract), and the class with abstract or final: a program reading the header is held to the same rules as one compiled with the library's source. private methods and constructors are left out: they are called only from inside the class, and never through its method table. A class whose constructors are all private is given one line, private Name(), so that the reader does not take it for a class with the default constructor.

A header also declares, from 0.16.0, each type that is not public and that one of its declarations names: the type of a field, a parameter or a return type of a listed method or of a public function, a base class or an interface, a type a template's text names — and the types those name in turn. Such a type keeps the modifier it has (none, or private) and is written like a public one, in the header of the file that declares it. The program needs it to read the header at all, and to lay out an object that holds a struct of that type; it still cannot write the type's name, which is refused with the message of the source build. A non-public type that nothing in a header names is not declared. Up to 0.15.x such a header could not be read (unknown type).

Only the templates travel that way; everything else in the module stays a declaration, and no name is emitted twice. When a template's body calls a non-public function of its own module, that function travels with it and the compiler warns, naming it — it is private code becoming readable in a shipped artifact.


Output and paths

OptionMeaning
-o <file>output name (default: named after the entry — see below)
--out-dir <dir>directory for the output and its intermediate objects
--src-dir <dir>source root for discovery and import resolution (default: .). Repeatable — the first is the discovery root, all of them resolve imports. Each must be a directory that exists (from 0.16.0)
--entry <file>the file declaring main(), instead of discovering it; with --test/--suite, the one suite file to build
-L <dir>package dir: its .fly.h headers resolve imports, its .a/.lib archives and its dynamic libraries (.so, .dylib or .dll, the target system's) are linked; where the directory holds an archive and a dynamic library of one name, the archive is linked. Repeatable — one per library directory: every directory resolves imports and is linked, in the order given (up to 0.15.2 only the last one was read, and no dynamic library was linked). Each must be a directory that exists (from 0.16.0)
--runtime-lib-dir <dir>dir holding fly_std_lib.a / fly_runtime_lib.a (default: <exe>/../lib)
--mingw-sysroot <dir>mingw/UCRT sysroot for Windows linking (default: <exe>/mingw)
--llvm-lib-dir <dir>dir holding LLVM-20.lib for programs using the LLVM-C API (default: <exe>/llvm/lib)
--link-lib <name>link a native library (-lname)
--keep-objectkeep the object of a linked build (<output>.o) next to the output instead of deleting it
--rpath <dir>a run-time library search path of the executable, repeatable; $ORIGIN is the executable's directory (@loader_path on macOS), and is searched without asking when a dynamic library is linked. Windows has none: a DLL is found next to the executable
--tlslink the real TLS backend (OpenSSL on Linux, Schannel on Windows) instead of the no-op stub

Dynamic libraries

--lib-dyn builds a directory into a dynamic library and one .fly.h per public module. A program uses it as it uses an archive: it names the directory with -L, the headers resolve its imports and the library is linked.

fly --lib-dyn -o dyn --out-dir out --src-dir lib     # out/dyn.so (.dylib, .dll) + out/dyn.fly.h
fly --src-dir prog -o app --out-dir out -L out       # out/app, linked against out/dyn.so
  • At run time the library is found next to the executable, on the three systems: Windows looks there by itself, and on Linux and macOS a program linked against a dynamic library searches its own directory ($ORIGIN, @loader_path). --rpath adds other directories — --rpath '$ORIGIN/../lib' for a bin/ + lib/ layout — and the system's own means still apply (PATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH).
  • The library is recorded under its file name (the SONAME on Linux, @rpath/<name> on macOS): it can be moved with the program, not renamed.
  • On Windows no import library is written: the linker reads the .dll.
  • One runtime (from 0.16.0). A dynamic library and a program that links one take the standard library and the runtime from one more dynamic library, fly_runtime.dll (libfly_runtime.so, libfly_runtime.dylib), which the compiler links from its own archives next to what it builds — when it is missing or older than them — and which is loaded once at run time. An object crosses the boundary like a value: created by the library, it is deleted by the program, and one nobody deletes is in the report at the end of main. Ship it with the program, next to the library. A program that links no dynamic library is built from the archives in one piece, as before. Up to 0.15.x each side had its own copy: on Windows an object created by the library and deleted by the program corrupted the heap (0xC0000374), and the library's objects were not reported. The shared runtime also makes the library small: it holds its own code alone (a one-class library: 67 KB instead of 1.5 MB on Windows).

Up to 0.15.2 a program could not link what --lib-dyn built: -L linked archives only, and on Linux and macOS the library was written without an extension.

With no -o, the output is named after what the build starts from:

The buildDefault name
a program (one file declares main())that file's name without .fly, written next to the file; under --out-dir, the name alone — src/main.fly gives <out-dir>/main
--suite=<Sel>the selector
--suite with one suitethe suite's name
--suite with several suites, --lib, --lib-dyn, a compile of a whole directorythe source directory's name: --src-dir proj gives proj, and . is the directory it is (in myproj/, fly --suite builds myproj)

Under --out-dir a default name never carries a directory of the sources, so the output lies directly in <out-dir>. From 0.16.0; up to 0.15.x the name kept the path of the entry file below --out-dir, a directory that does not exist there, and the build stopped with error: object emission failed. A failed emission now names the path: error: object emission failed: cannot write 'out/missing/app.o'.

--tls is opt-in for a reason: linking the real backend makes the program depend on the platform's TLS library, so a build without it still links on a machine that has none. Without the flag, fly.net.tls.tlsAvailable() returns false and every connect attempt fails cleanly instead of pretending otherwise.


Test options

Covered in depth in Testing; the short version:

OptionMeaning
--suitebuild ONE test executable containing every discovered suite, run it, and exit with the run's code (0 = all passed, 1 = failures). From 0.16.0 the files of each directory are read sorted by name, so the suites run in the same order on every machine
--suite=<Sel>run a subset. Sel is a suite name (MathSuite), a qualified name (fly.math.test.MathSuite), or a namespace — a namespace runs every suite declared under it, sub-namespaces included (--suite=fly.compiler.target.test)
--testbare: compile in test mode (test {} blocks compiled in) without running anything — for library builds whose blocks a later suite activates
--test=<Method>run only that test-method (Prova matches Prova or ProvaTest). A filter matching zero methods across the selected suites is a compile error — a typo cannot produce a green run

A selector that matches no suite or namespace is an error, and so is an empty one (--suite=, --test=). --suite builds the suites and runs them, so it cannot be combined with an output that is not run: --suite with --no-output, -c, --emit-ll/--emit-bc/--emit-as, --lib or --lib-dyn is an error (from 0.16.0; up to 0.15.x such a build ran nothing and exited 0, a green result for suites that never ran).


Codegen and target

OptionMeaning
-O<n>, -O <n>optimisation level 0–3; any other value is an error (from 0.16.0; up to 0.15.x -O4 was -O3, -Ox was -O0 and a huge number stopped the driver). At 1–3, LLVM's optimization pipeline (default<O1> to default<O3>) runs before the module is written, whatever the output: object, assembly, --emit-ll or --emit-bc. At 0 none runs. From 0.16.0; up to 0.15.x every level wrote the code of -O0.
--target <triple>target triple (default: the host; on Windows x86_64-w64-windows-gnu — Fly links UCRT-only through its bundled toolchain, no MSVC)
--target-cpu <cpu>the CPU LLVM generates code for, e.g. x86-64-v3 (default: generic). A name LLVM does not know is reported by LLVM ('…' is not a recognized processor for this target) and the code is built for a generic CPU. From 0.16.0; up to 0.15.x the option was read and not used
-j, --jobs <n>LLVM parallelism (0 = auto); anything but a number is an error (from 0.16.0)
--mcmodel <m>the code model: tiny, small, kernel, medium, large or default (the target's). x86 builds small, kernel, medium and large; AArch64 small and large, and tiny on ELF; other targets small. Another name, or a model the target does not build, is an error. From 0.16.0; up to 0.15.x any value was taken and not used
--mthread-model <m>posix (default) or single — validated, not yet applied by the backend (a warning says so; silent in 0.14.6)
-static / -pielink-mode flags (ELF/Linux targets; ignored by the Windows linker). From 0.16.0 a program is position independent (PIE) by default and -pie changes nothing; -static links it at a fixed address. Up to 0.15.x a program was PIE only with -pie. The protections every link adds are listed in Conformance
--debug-symbolsemit DWARF: functions, files, source lines, parameters and locals (from 0.14.8; ignored with a warning in 0.14.7, silently in 0.14.6)
--debug-prefix-map=OLD=NEWwrite NEW instead of the directory prefix OLD in the DWARF file names and, from 0.15.0, in the source positions of run-time trap messages (repeatable; the last match wins; / and \ compare equal). Keeps the build machine's paths out of the object (from 0.14.8)
--trace-callsinstrument every function entry/exit with fly.log trace hooks (see below)

--trace-calls: function-call tracing

--trace-calls makes the compiler inject a call to fly.log.enter in every function's entry block and a call to fly.log.exit — or fly.log.exitFail, when the function is left through an unhandled fail — before every return. It is Fly's -finstrument-functions: no source change, no import (the std archive is linked into every program anyway).

What gets instrumented: every function, method and constructor of your code. The fly.* namespaces (std, runtime, the compiler) are excluded, both to keep the trace readable and because the hooks themselves live in fly.log. A fail caught by an enclosing handle branches to the handle block — that is not a function exit, and correctly logs nothing.

The instrumented binary is silent by default: the hooks print at TRACE, and the logger's threshold defaults to INFO. Tracing is switched on at run time:

fly --trace-calls -o app
FLY_LOG_LEVEL=trace ./app
2026-07-31 15:00:27 [TRACE] > main
2026-07-31 15:00:27 [TRACE]   > fib
2026-07-31 15:00:27 [TRACE]     > fib
2026-07-31 15:00:27 [TRACE]     < fib
2026-07-31 15:00:27 [TRACE]   < fib
2026-07-31 15:00:27 [TRACE]   > risky
2026-07-31 15:00:27 [TRACE]   <! risky
2026-07-31 15:00:27 [TRACE] < main

Indentation follows call depth; <! marks the failing exit. The hook call carries its own zeroed error slot, so tracing never disturbs a failure being propagated — exit codes and error <code>: <message> output are identical with and without the flag.


Diagnostics and introspection

OptionMeaning
-v, --verboselog each compilation phase to stderr
--debugverbose logging (also requests DWARF)
--print-statscompilation statistics to stderr (files parsed, deps pulled, headers loaded, dirs scanned)
--stats-file <f>write the statistics as JSON to <f>
--log-file <f>log every diagnostic to <f>
--log-format <fmt>diagnostics log format: txt (default) or json
--ftime-reportno effect yet (a warning says so; silent in 0.14.6) — use --print-stats
-w, --no-warningreport no warning (the compiler's and the driver's "no effect yet" notes)
--warnings-as-errorsa warning fails the build like an error (from 0.15.0)
--no-warn=<name>switch off one warning, by the name shown after its message: unused-variable, unused-import, shadow, lossy-conversion, non-exhaustive-switch, header-private, missing-const (repeatable; from 0.15.0)
--versionprint the version
--helpfull usage

Warnings

From 0.15.0 the compiler reports code that is valid but probably not what was meant. A warning never stops the build (unless --warnings-as-errors), and its message ends with its name in brackets:

main.fly:8:9: warning: unused variable 'count' [unused-variable]
main.fly:5:13: warning: 'total' shadows the local variable of the same name declared in an enclosing scope [shadow]
NameReported when
unused-variablea local variable that no name ever refers to, at the end of its block. Not reported for a name starting with _ (unused on purpose: bool _ok = table.insert(x))
shadowa local variable that hides a local variable or a parameter of an enclosing scope
unused-importan import none of whose names the file writes: the prefix of import fly.str (str.), the symbol of import fly.data.List, any name of import fly.str.*. Checked on the source text, so it can only miss a case, never report a used import
lossy-conversionan integer converted implicitly to a floating type that cannot hold all its digits: int, uint, long, ulong into float (24-bit mantissa); long, ulong into double (53). Not for a literal, nor with an explicit cast
non-exhaustive-switcha switch over an enum, with no default, that does not handle every value of the enum; the message lists the values it misses
header-privatea private declaration shipped as readable source in a .fly.h because a generic template uses it
missing-consta parameter without const that the body never writes (from 0.16.0). A non-const parameter is an output: the callee may write the caller's variable, so one never written belongs as const. Written means the parameter itself: an assignment, ++/--, a receiver of a multi-assignment, a variable passed to a non-const parameter, delete; a field or an element written through it (p.x = 1, p[i] = 1) does not count, as const protects the variable only. Not reported for a name starting with _, a generic function or class, fly.runtime and fly.llvm (where const decides the C signature), and a method with a slot in the method table, whose parameters must declare const as the method it overrides

Warnings are about the code being compiled: none is reported inside a shipped .fly.h header, including the generic code instantiated from one. The Fly tree builds its own libraries and tools with --warnings-as-errors.


Exit codes

SituationExit
build succeeded0
compile/link error1
command-line error: unknown option, missing or invalid value, argument too many, options that cannot go together1
a project command (fly build, run, test, lock, …) run where there is no Manifest.fly2
fly init where a manifest or src/main.fly already exists, or with a --name or --version the manifest refuses; fly add with more than one of --tag, --branch, --rev3
Manifest.fly does not parse (each error is printed with its place, from 0.16.0)210
Manifest.fly declares no class extending fly.meta.Manifest211
Manifest.fly does not respect the schema (each issue is printed with its place)212
fly fmt: a path that does not exist or is not a .fly file, a file that does not parse, a directory that cannot be read2
fly fmt --check: a file would change1
--suite runthe run's code: 0 = every case passed, 1 = any failure
running a built programmain()'s error protocol: 0 clean, otherwise the code of the last unhandled failure (printed as error <code>: <message>)

Projects — Manifest.fly

Everything above is the unitary mode: one directory, one artifact, no configuration. A project adds a Manifest.fly in the working directory (a lowercase manifest.fly is also accepted) and a set of subcommands that manage multiple targets, dependencies, a lockfile and an incremental cache.

There is no TOML. The manifest is Fly source — a class extending fly.meta.Manifest, with literal field initialisers — and the package manager reads it with the compiler's own parser, walking the AST. One language, one parser, and a manifest your editor already understands. The read is parse-only: no semantic analysis, no codegen.

fly init

fly init --name hello --version 0.1.0

writes src/main.fly and this Manifest.fly:

namespace pkg.manifest
import fly.meta.*

class Manifest : fly.meta.Manifest {
    string name = "hello"
    string version = "0.1.0"
    string flyVersion = "0.14.4"
    Target[] targets = { new Target("hello", "src/main.fly", "") }
}

Both flags are optional (my-project and 0.1.0 by default). fly init writes over nothing: an existing manifest or src/main.fly stops it, with exit 3 (up to 0.15.x it replaced an existing src/main.fly with the template). The name and the version must be ones the manifest accepts (see the schema below): fly init --name "Bad Name" prints why and writes nothing (up to 0.15.x it wrote a manifest no command could read).

Manifest schema

The fields are those of fly.meta.Manifest, and every one is optional. From 0.16.0 fly.meta is a module of the standard library (std/lib/meta.fly), so the toolchain ships its header in lib/ (API). Object collections are array literals of new T(...) with positional arguments, and trailing arguments may be omitted.

FieldTypeMeaning
namestringpackage name: lower-case letters, digits, - and _
versionstringthe package's version, in the form its author chooses: letters, digits, ., - and _ (1.2.3, 2026.11, 1.0.0.RC1-SNAPSHOT_linux)
description, license, homepage, repositorystringmetadata
flyVersionstringthe toolchain version the project expects
registriesRegistry[]the registries dependencies are fetched from, each { name = "...", url = "..." } (from 0.16.0, see Dependencies)
registrystringthe registry of a dependency that names none: the name of one of registries
authorsstring[]
linkLibsstring[]native libraries to link (-lname)
targetsTarget[]new Target(name, path, lib) — lib is "" for an executable, else "static", "dynamic" or "both"; or the named form below. See the path of a target
profilesProfile[]build profiles, named form (from 0.15.2)
dependencies, devDependenciesDependency[]see below

The path of a target

In the positional form the path names a source file, relative to the project. For an executable it is the entry, the file whose main() the program runs (built as with --entry), and its directory is the source directory; for a library its directory is the library. From 0.16.0 the path must name a .fly file that exists, inside the project:

error: target 'x': path 'src/nothere.fly' does not exist
error: target 'x': no path (the source file to build)
error: target 'x': path '../a.fly' is outside the project

Two programs may then live in one directory, one target each:

Target[] targets = { new Target("a", "src/a.fly", ""), new Target("b", "src/b.fly", "") }

Up to 0.15.x only the directory of the path counted: a path naming a missing file built the directory's program anyway, two programs in one directory stopped with multiple main() functions, and an empty path built the directory above the project. A build announces each target by its name ( fly a), not by its path.

A manifest is checked against the schema (0.16.0)

fly build, fly run, fly test and every other command that reads the manifest check what it writes against fly.meta, and stop on the first manifest that does not respect it, naming each place:

Manifest.fly:7:28: error: unknown field 'srcDir' in a target
error: Manifest.fly is not valid

A manifest that does not parse names its place the same way (from 0.16.0; up to 0.15.x it said only that there was no valid manifest):

Manifest.fly:4:54: error: unclosed '(': missing ')' to match the opening parenthesis
  • A field the schema does not declare — in the manifest, in a target or in a profile — is an error. Before 0.16.0 it was left out without a word: a mistyped srcDir built a project that was not the one written.
  • A value has the shape of its field: a string, a list of strings ({ "a", "b" }), true or false, and 0 to 3 for optLevel.
  • lib and os take their own values ("static", "dynamic", "both"; "linux", "windows", "macos"): os = "window" used to skip the target on every host.
  • A name is written once: a field of the manifest, of a target or of a profile; and two targets, two profiles or two dependencies do not share a name. Each of them needs one.
  • name and version, when written, hold the characters the table above gives.

The manifest of a dependency is read by the same rules: a fetched package whose manifest is not valid stops the resolution, with its first issue. fly-lsp publishes the same errors on the manifest while it is edited.

The schema holds what Fly reads and nothing else: repositories, tst, workspace and hooks, which fly.meta declared before 0.16.0 and no command read, are no longer part of it (registries are declared with registries).

Targets and profiles, named form (0.15.2)

A target or a profile can also be a struct literal with named fields, which is how a target says more than a name, a path and a library kind:

Profile[] profiles = {
    { name = "dist", optLevel = 2, debugInfo = false, warningsAsErrors = true }
}

Target[] targets = {
    { name = "std", lib = "static", artifact = "fly_std_lib", srcDirs = { "std/lib" }, libDirs = { "@out" } },
    { name = "runtime", os = "linux", lib = "static", artifact = "fly_runtime_lib",
      files = { "runtime/lib/RuntimeLinux.fly" } },
    { name = "admin", srcDirs = { "tools/admin", "app" }, entry = "tools/admin/Admin.fly",
      libDirs = { "@out" }, flags = { "--runtime-lib-dir", "@out" } }
}
Target fieldTypeMeaning
name, path, libstringas in the positional form (path is ignored when srcDirs or files is set)
srcDirsstring[]source roots (--src-dir); the first is where main() is discovered, the others resolve imports
filesstring[]compile exactly these files, copied into a directory of their own (for example one per-platform source out of several in the same directory)
entrystringthe file declaring main() (--entry), when the tree has more than one
osstring"linux", "windows" or "macos": the target is built only on that host (skipped elsewhere)
artifactstringthe exact output name: a static library becomes <artifact>.a (.lib on Windows) with no lib prefix, and its .fly.h headers land next to it
libDirsstring[]package directories (-L): their headers resolve imports and their archives and dynamic libraries are linked
linkLibsstring[]native libraries for this target only
flagsstring[]further compiler arguments, one per element, passed as they are
dirstringthe subdirectory of the output directory the artifact lands in (a library's headers too), e.g. "bin" or "lib" for an installable layout
copystring[]files or directories copied into the target's directory: a file under its own name (a symbolic link is followed), a directory as a whole tree, dir/prefix*suffix for the matching files — possibly none, which is how an optional file is listed. A target with only copy compiles nothing; a copy is skipped when it already has the source's size and is not older
rpathsstring[]where the executable finds its shared libraries at run time (--rpath), e.g. "$ORIGIN/../lib"

In libDirs, flags, copy, rpaths and a profile's debugPrefixMap, @out stands for the output directory (@out/lib for a library with dir = "lib"): targets are built in the order they are listed, so a later target finds the libraries an earlier one put there. @root is the package root (the directory fly build runs in) and @fly the installation of the fly that compiles (the directory above its bin/, so @fly/lib is where it reads the standard library's headers).

Profile fieldTypeMeaning
namestringthe profile (fly build --profile <name>; --release is release)
optLevelint-O<n>
debugInfobool--debug-symbols
warningsAsErrorsbool--warnings-as-errors
debugPrefixMapstringOLD=NEW for --debug-prefix-map, or several pairs separated by ; (the last one that matches a path wins), e.g. "@root=.;@fly/lib=lib;@out=out": the objects then hold no path of the machine that built them
assertions, lto, stripboolrecorded, not applied yet

A field left out keeps the built-in value of that profile name: release is -O3 with no debug info and assertions off, any other name -O0 with debug info and assertions on. Without a declared profile the built-in one applies.

A program reads its own manifest: fly.meta.package

Every executable fly build builds gets a generated module, fly.meta.package, with the manifest's name(), version() and description() — the equivalent of Cargo's CARGO_PKG_VERSION:

import fly.meta.package
import fly.os.io

void main() {
    io.printLn(package.version())   // the version Manifest.fly declares
}

Libraries do not get one (two libraries would define it twice).

Fly builds itself with fly build

The Fly repository has its own Manifest.fly: fly build --profile dist builds runtime, TLS archives, standard library and compiler, laid out as a release: bin/ with the executables, the linker, the debugger and (on Windows) the mingw sysroot, lib/ with the archives, their headers and the LLVM shared libraries, copied from the LLVM the bootstrap downloads. From 0.16.0 the two tools are packages of their own inside the repository - tools/lsp and tools/registry, each with its Manifest.fly - built after the root with the same command and the same --out-dir, run in the tool's directory. They link what the root built instead of compiling it again: the standard library and, for fly-lsp, the compiler's front end, which the root manifest also builds as a library (lib/compiler, a directory no build reads unless it names it, and which a release leaves out). The executables find lib/ through $ORIGIN/../lib, so the result is a toolchain of its own. From 0.16 that is how Fly is built: stage 2 of the bootstrap is fly build --profile dist --out-dir .fly/bootstrap/stage2 and stage 3 the compiler once more with the result, compared byte for byte; the CI checks at every build (test_fly_build) that the stage-2 fly starts and compiles a program with nothing on PATH or in the loader path and no option. Since 0.15.2 that Manifest.fly is the only place the version is written: fly --version reads it through fly.meta.package.

Dependencies

A Dependency is new Dependency(name, version, registry, git, tag, branch, rev, path) and the fields that matter depend on the kind:

Registry[] registries = {
    { name = "central", url = "https://pkg.example.org" },
    { name = "corp", url = "https://fly.corp.example" }
}
string registry = "central"

Dependency[] dependencies = {
    new Dependency("json", "^1.2.0"),                                   // registry: the default one
    new Dependency("billing", "2.4.1", "corp"),                         // registry: the one it names
    new Dependency("util", "", "", "https://github.com/acme/util", "v1.0"),  // git tag
    new Dependency("local", "", "", "", "", "", "", "../local")         // path
}

Registries (0.16.0)

A dependency that names neither a git repository nor a path comes from a registry, a server such as fly-registry. The manifest says where its registries are, each under a short name:

  • registries lists them: { name = "central", url = "https://..." }.
  • registry names the one a dependency uses when it names none.
  • A dependency names another one in its third argument.

The address is written once, and the project carries with it where its packages are found. The manifest is checked: a registry, or the registry of a dependency, that is not one of registries is an error, and so is a registry dependency in a manifest with no default registry:

Manifest.fly:6:35: error: dependency 'json' names no registry, git or path, and the manifest has no default 'registry'
Manifest.fly:7:9: error: registry 'corp' is not one of 'registries'

Every dependency of a build, also those of its dependencies, is fetched from the registries of the project being built.

Before 0.16.0 there was no field to declare a registry in, and a registry dependency could not be resolved.

Building with dependencies (0.16.0)

fly build, fly run and fly test build the dependencies of the project before its targets, and give them to every compile: a source imports the namespaces of a dependency as it imports those of the standard library.

// Manifest.fly
Dependency[] dependencies = { new Dependency("json", "^1.0") }
Target[] targets = { { name = "app", srcDirs = { "src" } } }
// src/main.fly
import json.parser

void main() {
    parser.parse("{}")
}
$ fly build
  wrote Lock.fly
  dependency json 1.0.3
  fly json
  fly app
  • A dependency is a library. Each package is built from its own manifest: its library targets (lib = "static", "dynamic" or "both"), all of them, and none of its executables. A package with no library target stops the build: error: dependency 'json' has no library target.
  • Under the project's output: .fly/<profile>/deps/<name>/ holds the headers and the archive of each dependency, per project and per profile. fly clean removes them.
  • In order: a package is built after the ones it depends on, and is given their libraries. The dev-dependencies of the project take part in fly test alone; those of a dependency are never built.
  • Where a package is read from: a path dependency where it is (a path is relative to the manifest that writes it), a git or registry one in the cache.
  • Incremental: a dependency is built again when its sources change, and the targets of the project with it; with nothing changed everything is up-to-date.

Before 0.16.0 the build did not look at the dependencies: fly lock resolved them and nothing built them.

Versions and requirements (0.16.0)

A version is of one of two kinds:

KindFormExamples
canonicalnumbers and dots alone1, 1.2, 1.2.3, 1.2.3.4 (a leading v is dropped: v1.2.3)
freeanything else its author writes1.0.0-RC1, 2026.11-beta, nightly

A canonical version has an order, number by number, a missing number counting 0: 1.2.3.4 is higher than 1.2.3, which is 1.2.3.0. A free version has none: it is equal to the same text and to nothing else.

The version requirement of a registry dependency is:

RequirementTakes
*, or left outthe highest canonical version
1.2.3that version
^1.2.3the highest canonical version from 1.2.3 up to, not including, 2.0.0 (^0.2.3: below 0.3.0)
~1.2.3from 1.2.3 up to, not including, 1.3.0
>=1.0, >1.0, <=2.0, <2.0, joined by ,the highest canonical version in the interval (>=1.0,<2.0)
1.x, 1.*the highest 1.something
a free version, in full: 1.0.0-RC1, nightlythat very version

No operator selects a free version. With 1.0.0-RC1, 1.0.0, 1.0.0.1 and nightly in the registry:

new Dependency("json", "^1.0")         // 1.0.0.1: the highest compatible canonical one
new Dependency("json", "1.0.0-RC1")    // exactly 1.0.0-RC1
new Dependency("json", "nightly")      // exactly nightly
new Dependency("json", "^1.0.0-RC1")   // error: an operator on a version that is not numbers and dots

An operator works on the order of versions, and a free version has none: this is how Cargo and pip treat pre-releases, extended to any free form. The same holds for the tags of git dependencies: canonical tags are ordered and the highest one required wins; two different free tags of one package are a conflict.

Commands

Run from the directory holding the manifest.

CommandMeaning
fly init [--name N] [--version V]scaffold Manifest.fly + src/main.fly
fly build [--target N] [--out-dir D] [--keep-objects]build every target, or one (a name no target has is an error); --out-dir writes the output to D instead of .fly/<profile>, --keep-objects leaves each executable's object (<name>.o) next to it
fly run [--bin N]build, then run the (named) executable target. It takes no other argument: fly run a b is an error (up to 0.15.x a and b were dropped)
fly testbuild and run the project's suites (the *Suite.fly files), each on its own, into .fly/test/<its path below the project>; a *Suite.fly that declares no suite is left out, with a skip line
fly clean [--profile P]remove .fly/, or .fly/P alone; Lock.fly stays
fly lockresolve dependencies and write Lock.fly
fly add <name> [--git URL] [--tag T | --branch B | --rev R] [--dev]add a dependency and re-lock
fly remove <name>drop a dependency and re-lock
fly why <name>explain why a package is in the graph
fly versionthe toolchain version
fly fmt [--check] <path>...lay out the .fly files under each path in the house style (from 0.14.9; see below)

Shared flags: --release (or --profile <name>) selects the profile of build, run, test and clean, and --force bypasses the incremental cache of build, run and test.

Each command takes exactly the options listed for it, the value after the option or after = (--profile release, --profile=release); fly <command> --help prints them. From 0.16.0 anything else is an error with exit 1 and the command's usage: an unknown option (fly build --relase used to build the debug profile), an option without its value, a value option given twice, --release with --profile, an argument too many. The command comes first: fly -v build is an error.

The table is the complete set. update, upgrade, vendor, search, publish, workspace, deploy, cache and doctor are not implemented in the self-hosted driver: fly rejects them as an unknown argument and exits 1, rather than pretending to do something.

fly fmt

fly fmt rewrites the layout of Fly sources and nothing else. It needs no manifest: give it files or directories (every .fly below a directory; never a .fly.h).

  • Every statement of a block starts on a line of its own and the closing } stands alone, so one-line bodies are expanded, one level deeper than the line of the block's {. An empty body ({}, an extern) is left as it is.
  • A parameter list on a line longer than 120 columns is broken after a comma, continuation indented 8 more; when two lines are not enough, one parameter per line.
  • A switch is laid out like a block (from 0.16.0): each case/default label on a line of its own, one level deeper than the switch, its statements one level deeper still. A label whose body opens with a block on its own line (case 1: {) keeps it there.
  • The comment that ends a one-line block (if c { a } // why) moves to the end of the { line when the block is expanded. The comment after the } of a block that already spans lines stays where it is (up to 0.15.x it was moved to the { line too).
  • No trailing whitespace, never two blank lines in a row, exactly one final newline. A file keeps its line endings (LF or CRLF).
switch x { case 1: a() default: b() }

becomes

switch x {
    case 1:
        a()
    default:
        b()
}

Statement boundaries come from the parser, never from guessing: Fly needs no separator between two statements, so only the grammar can split a() b = 1. A file that does not parse is left untouched, its errors are printed with the file's name (bad.fly:1:12: error: …), and the exit code is 2. --check writes nothing: it lists the files that would change and exits 1 if there is any.

A path that does not exist, or a file that is not a .fly source, is an error with exit 2 (from 0.16.0; up to 0.15.x it succeeded with 0 file(s) reformatted). Below a directory, fly fmt never enters one whose name starts with a dot — .fly/ holds what builds write, generated sources among them — like every source walk of Fly.

Long calls, long conditions and long string literals are not broken: where to break them is a judgement call.

The lockfile

fly lock — and any command that changes the dependency set — resolves the graph with minimal version selection and writes Lock.fly. Like the manifest it is Fly source (a class extending fly.meta.Lockfile), read back with the same parser. It is machine-generated: commit it, do not edit it.

Each locked package records its name, version, source (git+<url>, registry+<url> or path+<dir>), the resolved rev/tag and a checksum. The dev-dependencies are locked too. The lockfile also stores a checksum of the manifest, so a manifest edit invalidates it.

fly build, fly run and fly test do not need fly lock to be run first: with no Lock.fly, or one that is no longer the lock of the manifest, they resolve, fetch and write it, then build.

Where Fly writes

Everything fly build, fly run, fly test and fly lock write for a project goes into one directory, .fly/, next to Manifest.fly — the one directory a project's .gitignore needs (.fly/). The one exception is Lock.fly, which stays next to the manifest because it is committed: it is what makes a build tomorrow use the versions of today.

my-project/
  Manifest.fly
  Lock.fly                 written by fly lock (and by a build that relocks); committed
  src/
  .fly/                    everything else; ignore it
    debug/                 the output of a profile (--profile, --release → release/)
      app                  an executable target (app.exe on Windows)
      lib/  bin/           a target's `dir`
      deps/json/           the dependencies, built as libraries
      .state/              the build's own state: fingerprints, staged files, generated sources
    release/
    test/                  fly test: one executable per suite, by its path
      x/FooSuite
      .state/
~/.fly/                    shared by every project of the user
  cache/                   fetched packages (git and registry); FLYLANG_CACHE moves it
  registry/                the storage of a fly-registry you run; --storage or FLY_HOME moves it
  • --out-dir D writes a build's output to D instead of .fly/<profile>, anywhere — the project's own directory included; its state goes to D/.state.
  • fly clean removes .fly/ (fly clean --profile P: .fly/P alone). Lock.fly and the shared ~/.fly stay.
  • The source walk never enters a directory whose name starts with a dot — so neither .fly/ nor a .state/ below an --out-dir. The fingerprint of a build reads the same sources.

Before 0.16.0 the output went to target/<profile> and target/test, and a build's state to <output>/.fly. A target/ left by an older Fly is no longer written nor read.

Build layout and incremental builds

Output goes to .fly/<profile> (plus /<triple> when cross-compiling), and .fly/test for test binaries.

fly test names each suite by the path of its file below the project, without .fly, and .fly/test mirrors the project's directories: x/FooSuite.fly builds .fly/test/x/FooSuite (FooSuite.exe on Windows), a suite file next to the manifest builds .fly/test/<name>. The result lines carry the same name:

  up-to-date x/FooSuite
  PASS  x/FooSuite
  PASS  y/FooSuite

A file whose name ends in Suite.fly but that declares no suite is not built nor run (from 0.16.0):

  skip  src/HelperSuite (no suite)

Up to 0.15.x it was built as the program it is, run, and reported PASS when it exited with 0.

So two suite files with one name in two directories each keep their own executable and their own fingerprint (from 0.16.0; up to 0.15.x every suite was named by its file name alone, and two such suites replaced each other's executable and were compiled again at every run).

Each suite is a build of its own: its file is the only entry, so its executable holds, and runs, that suite alone. What the suite imports is looked for in the whole project, from the manifest's directory down — a suite in tests/ imports the namespaces of src/ — and no other suite's file is read. A suite needs no namespace: it sees what it imports, and a suite file without one does not bring in the project's other files with no namespace. So a suite builds and runs the same whatever suites lie next to it or below it. (From 0.16.0. Up to 0.15.x a suite was compiled with its own directory as the source directory and every suite file below it: its executable also ran its neighbours and the suites of the directories below, it could not import a namespace from a directory beside its own, and a suite above two suite files of one name did not compile.)

Each target, and each suite of fly test, gets a fingerprint under <outdir>/.state/<key>.fp (.fly/test/.state/x/FooSuite.fp for a suite): a hash of its sources (every source root, staged files and the package module included; for a suite, every source of the project), its flags, the package's name and version, the lockfile, the compiler's own identity (its version, size and modification time) and, from 0.16.0, the files of its libDirs (fly-lang/fly#310): each file there (archives, libraries, headers) with its size and modification time, as the build left them. A library rebuilt since — by another target of the manifest, built alone with --target — links the target again; a file that appeared later does not, and neither does what the manifest's copy targets put there. Up to 0.15.x only the directory names counted, and the target kept the old library. The sources count by their content hash. A target whose fingerprint is unchanged is skipped; --force rebuilds regardless. Because debug and release have separate output directories, their fingerprints cannot collide.

The package cache

Git and registry dependencies are cached under ~/.fly/cache, or wherever FLYLANG_CACHE points. Cache entries are keyed by host, owner, repository and the resolved 40-character revision, so two projects pinning the same commit share one copy.

Downloaded archives are unpacked in-process with fly.targz, and their gzip CRC-32 and length are verified before anything is written — a truncated or corrupt download is rejected rather than stored. No tar or curl process is involved anywhere.


Companion binaries

The toolchain ships three more executables next to fly, built or bundled by the same pipeline and covered by the same test suites: fly-lsp and fly-registry are Fly packages of the repository (tools/lsp, tools/registry), compiled by the self-hosted compiler; lldb (with lldb-dap) comes from the project's own LLVM build.

fly-lsp — the language server

Speaks the Language Server Protocol over stdio; it takes no options. Point your editor's Fly client at the binary:

<install>/bin/fly-lsp

Diagnostics come from the real compiler pipeline — the same parser and semantic analysis fly itself runs — so what the editor underlines is what the build will report.

CapabilityMethod
DiagnosticstextDocument/publishDiagnostics (on open and save)
Go to definitiontextDocument/definition
Go to type definitiontextDocument/typeDefinition
Go to implementationtextDocument/implementation
HovertextDocument/hover
ReferencestextDocument/references
HighlighttextDocument/documentHighlight
Document outlinetextDocument/documentSymbol
FoldingtextDocument/foldingRange
CompletiontextDocument/completion
Signature helptextDocument/signatureHelp
Semantic tokenstextDocument/semanticTokens/full
Inlay hintstextDocument/inlayHint
Workspace symbolsworkspace/symbol

Method calls resolve through the receiver's static type, so p.getX(), p.x, this.x and static access all navigate — including members inherited from a base class.

From 0.16.0:

  • Positions in UTF-16. LSP counts a line's characters in UTF-16 units, the compiler in bytes. The server converts every column in both directions, so a position after an accented letter or an emoji lands where the editor shows it.
  • Completion.
    • After name. it offers the members of the class of name, and of a chain of fields such as this.cg.. Visibility follows the compiler's rules: a private member from its own class only, a protected one from that class and its subclasses. After a namespace prefix (str.) it offers the names of the namespace.
    • Elsewhere it offers the names in scope, then the keywords that start a statement (in a function body) or a declaration (outside one).
    • The text before the cursor is read from the editor, so it does not need to be saved.
  • Hover shows a declaration's modifiers, as in public static int f(const int n), (field) protected int x or (param) const int n. The slot the compiler adds for a function's result is not shown.
  • Implementation:
    • of a class or an interface: the classes derived from it;
    • of a method: its own body and the overrides;
    • of anything else: its declaration.
  • References honour includeDeclaration: the declaration is listed once, only when asked for. The object of a delete is one of the uses of its name. A name in a field initializer navigates like any other.
  • Errors and lifecycle:
    • A request whose analysis fails (a half-typed file that trips the compiler) is answered with error -32603, and the server keeps running.
    • A body that is not JSON is answered with -32700.
    • After shutdown, every request gets -32600.
    • The process exits 0 after shutdown + exit, and 1 on an exit without a shutdown.
    • The Content-Length header is read whatever its case.

A file is compiled with the project it belongs to: the directory of the nearest Manifest.fly above it, else the workspace folder the editor announced, else the file's own directory. From 0.16.0, under a manifest, the server compiles a file with what the toolchain would be given to build it — the files with no namespace being one namespace, read together, a single root for every file made each program of a tree meet the main of all the others:

The fileIs compiled with
is under a source directory of one of the manifest's targets (srcDirs, the directory of its files or of its path)the project; its default namespace is taken from that target's directories alone
declares a suitethe project, on its own and in test mode, as fly test builds a suite: it reads what it imports and never another suite's file
any other file — an example, a probethe directory of its program: the nearest directory, from the file's own up to the project's, that holds a file declaring main(); when none does, the file's own directory

The project's Manifest.fly itself is read, not compiled: opened in the editor it is checked as fly build reads it — its syntax, and its fields against the schema — and a valid manifest reports nothing (before 0.16.0 the server analysed it as a source, and a manifest was reported as errors).

A manifest that names no target says nothing about where the sources are: every file below it is compiled with the project. The answer depends on the files alone, never on which one was opened first. From 0.16.0 the server also reads the library directories the project's manifest gives its targets (libDirs), as a build passes them with -L: a relative entry is taken from the manifest's directory; @out/… and @fly/… are looked for in the toolchain fly-lsp runs from, since the output directory of a build is known to the build alone (which is where the tools of the Fly repository find the compiler library they link).

Current limits, stated rather than hidden:

  • The server compiles from disk: unsaved edits are analysed only after a save. Only completion reads the editor's text.
  • A receiver that is itself a call (f().m()) is not typed.
  • An overloaded name resolves to the first declaration.
  • References and highlights cover the open file, and match a name rather than a declaration: an n of another function is listed with the uses of this n.

fly-registry — the package registry server

Serves the endpoints the package manager speaks, so a team can host its own index without any third-party service.

fly-registry --storage ./packages --port 5000 --token secret
OptionDefaultMeaning
--storage <dir>$FLY_HOME/registry, else ~/.fly/registrypackage storage root
--port <n>, -p <n>5000listening port (0 = pick a free one and print it)
--host <addr>0.0.0.0bind address
--token <t>$FLY_REGISTRY_TOKENbearer token required to publish; unset = publishing is open
--onceoffserve exactly one request and exit (for scripts and tests)
EndpointMeaning
GET /v1/{name}JSON array of published versions
GET /v1/{name}/{version}the package's Manifest.fly
GET /v1/{name}/{version}/downloadthe source tarball (.tar.gz)
POST /v1/{name}/{version}publish a tarball (bearer token when one is set)
GET /v1/search?q={query}JSON array of matching package names

Publishing verifies the upload: the gzip CRC-32 and length are checked and the Manifest.fly is extracted in-process before anything is stored, so a truncated upload is rejected with 400 instead of being served to every client afterwards. Package and version names that would escape the storage directory (absolute, drive-qualified, or containing ..) are rejected with 400.

Storage layout is one directory per package: <storage>/<name>/<version>.tar.gz alongside <storage>/<name>/<version>/Manifest.fly.

lldb — the debugger

The LLDB driver from the project's own LLVM build, shipped under its original name next to fly — fully self-contained: no Python, no libedit, no curses, no system LLDB. On Windows liblldb.dll sits beside it; on Linux liblldb lives in lib/ and lldb-server (which lldb launches local processes through) in bin/.

<install>/bin/lldb ./myprog

Batch mode drives the built-in command interpreter — scripting is via -o commands (Python scripting is intentionally off):

lldb -b -o 'breakpoint set -f main.fly -l 3' -o run -o bt -o continue -- ./myprog

What the debug information covers, from 0.14.8. A program compiled with --debug-symbols describes every function and method body, its file and the line of each statement, plus its parameters, its local variables and this. That gives breakpoints by file.fly:line or by function name, backtraces with file, line and argument values, next/step, and frame variable:

Fly typeShown as
bool, integers, float, doubletheir value (long reads as long long: the info is tagged as C)
pointeran address
string(data = "…", size = n)
arrays(data = 0x…, len = n)
enumsthe entry index
classes and structsa pointer to the class (Box *)

Current limits, stated rather than hidden: the fields of a class are not described yet, so p *this shows nothing useful; and a string's bytes are not NUL-terminated, so a debugger prints data past its end — trust size (p s.size). A method is named by its own name, without its class. At -O0 the back end runs without optimization so every statement keeps its own line. In 0.14.7 and earlier the self-host emitted no debug information at all.

lldb-dap — IDE debugging

lldb-dap (same engine, Debug Adapter Protocol over stdio) ships alongside for editor integration. Any DAP-capable editor can point at it; in VS Code (with the LLDB DAP extension):

{
  "type": "lldb-dap",
  "request": "launch",
  "name": "Debug (fly)",
  "program": "${workspaceFolder}/out/myprog",
  "debugAdapterExecutable": "<install>/bin/lldb-dap"
}