NURL

Compiling and running

How a .nu source file becomes a native binary.

A NURL source file goes through two stages to become a program you can run:

hello.nu → (nurlc)  → hello.ll   (LLVM IR — a text format, human-readable)
hello.ll → (clang)  → hello      (native binary for your machine)

nurlc (the NURL compiler) never touches your CPU's instruction set directly. It emits LLVM IR and hands that to clang, which turns it into a real binary. This is the same backend Rust and Swift use.

Script compiling

Whether you installed the prebuilt toolchain (nurl) or built from source (./nurl.sh / nurl.bat), the wrapper drives both stages for you:

nurl hello.nu                   # → ./hello
nurl hello.nu myprogram         # → ./myprogram
nurl --run hello.nu             # compile and run immediately
./nurl.sh hello.nu              # repo-root equivalent in a source checkout

Useful flags (put them before the source file):

FlagEffect
-O0 … -O3Optimization level passed to clang (default -O2)
-g, --debugEmit DWARF debug info (#line directives mapping back to .nu lines)
--checkFast parse, type check, and borrow check without LLVM IR codegen
--lintReport unused bindings/functions, shadowed locals, and redundant frees
--unsafe-reportAudit every unsafe function and raw pointer/FFI operation
--splitEmit multi-file C shards and compile them across CPU cores in parallel
--sanitizeCompile and link with AddressSanitizer, UBSan, and LeakSanitizer
--coverageInstrument line/branch coverage for nurl-cov
--staticProduce a statically linked binary
--target=<triple>Cross-compile for the given target triple
--emit-irStop after stage 1 — just produce the .ll file, do not link
--emit-asmEmit native assembly (.s), skip linking
--stdin NAMERead the source from stdin; diagnostics and the default output name use NAME (no file needs to exist)

Manual compiling

./build/nurlc hello.nu > hello.ll
clang hello.ll stdlib/runtime.native.o -lm -lpthread -o hello
./hello

Link against stdlib/runtime.native.o, not stdlib/runtime.o — after a normal build the latter is LLVM bitcode (for link-time optimization), and a plain clang link rejects it with "file format not recognized".

If you installed the prebuilt toolchain

The prebuilt installer (curl | sh or install.ps1) places nurl, nurlc, nurlpkg, nurlfmt, stdlib/, and lib/runtime.native.o in $NURL_HOME (~/.nurl), so you can compile and run .nu files directly with nurl hello.nu or nurl --run hello.nu without building from source.

Compiling to WebAssembly

See the online playground to try NURL in the browser without an install, and docs/PLATFORMS.md for the full target list when you are ready to cross-compile.

Last updated on

On this page