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

If you built NURL from source, ./nurl.sh (or nurl.bat) drives both stages for you:

./nurl.sh hello.nu              # → ./hello
./nurl.sh hello.nu myprogram    # → ./myprogram

Useful flags (put them before the source file):

FlagEffect
-O0-O3Optimization level passed to clang (default -O2)
-g, --debugInclude debug info
--emit-irStop after stage 1 — just produce the .ll file, do not link
--emit-asmEmit native assembly (.s), skip linking

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 curl | sh installer gives you nurlc, nurlpkg, and nurlfmt, but not the nurl.sh convenience wrapper or a local runtime. See Installation 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