.\" raz(1) - the raz compiler .Dd October 19, 2026 .Dt RAZ 1 .Os .Sh NAME .Nm raz .Nd compile a raz program to a Linux executable .Sh SYNOPSIS .Nm .Op Ar option ... .Ar Main.raz .Nm .Cm run .Op Ar option ... .Ar Main.raz .Op Ar arg ... .Nm .Fl q Cm check .Op Ar option ... .Ar Main.raz .Nm .Fl q Cm words .Op Ar option ... .Ar Main.raz : Ns Ar LINE : Ns Ar COL .Nm .Fl q Cm def .Op Ar option ... .Ar Main.raz : Ns Ar LINE : Ns Ar COL .Sh DESCRIPTION .Nm compiles the module in .Ar Main.raz , and every module it imports, to an executable for x86-64 Linux, with no assembler, linker or C library in between. A program that names a C library in a .Ic link line, or declares an .Ic extern procedure, is linked against C dynamically; any other is static. .Pp A module .Ar Name is found as .Ar Name Ns .linux-x86_64.raz or .Ar Name Ns .raz in the directory of .Ar Main.raz , then in each .Fl I directory in turn, then in the user library directories (see .Sx ENVIRONMENT ) , then in the library, .Pa lib/ beside the .Nm executable (or the one .Fl lib names), whose modules .Xr raz-lib 3 says. A program has one module of each name: a module found in two of these places is an error, unless one of the files is a symbolic link to the other, which chooses it. .Pp .Nm .Cm run compiles the same way, then runs the program with the .Ar arg Ns s , writing no file: its output and exit status are those of the command. .Pp Every array index and slice is checked, unless the module says .Ic check off ; a failed check, a nil pointer, a division by zero or a stack overflow ends the program with status 2, and says on standard error where it was, the calls under way, and their variables: .Bd -literal -offset indent Bad.raz:6:7: index 5 is out of range for a length of 3 in Bad.main at Bad.raz:6:7: i = 5 .Ed .Pp The executable has a symbol table and line numbers for .Xr gdb 1 , .Xr nm 1 and .Xr perf 1 , unless built with .Fl s . .Sh OPTIONS .Bl -tag -width "-noprofile" .It Fl o Ar file Write the executable to .Ar file . Left out, it is .Ar Main.raz without .Pa .raz . .Cm run takes no .Fl o . .It Fl I Ar dir Look for imported modules in .Ar dir too, after the main module's own directory and before the library. It may be given up to 16 times. An error in a module found in such a directory, or in one of .Ev RAZ_PATH , names that directory in its path; and if the directory holds a file .Pa RAZ-VERSION , of one line such as .Ql 0.21 , a second line says the raz the library was written for and this one: .Ql (a library written for raz 0.18; this is raz 0.21) . The compiler only reads the file; it never refuses to build for it. .It Fl lib Ar dir The standard library is .Ar dir , not the .Pa lib/ beside the .Nm executable. It is searched last, after the main module's directory, the .Fl I directories and the user library directories, as the default library is; the duplicate-module rule and its symbolic-link exception apply to it unchanged. It is an error if .Ar dir cannot be reached. A kernel's library holds its own .Pa Rt.raz and .Pa Sys.raz , with symbolic links to the modules of raz's own library that it takes. .It Fl Werror A warning counts as an error. .It Fl S List the main module's machine code, each instruction under the line of source it was made for, on standard output, and write no executable. .It Fl s Strip the program of what is there for finding faults: its symbol table, its line numbers, the places a failure is told by, and the profiler. A failure then says only its address, and the program is much smaller: hello, world is 7 KB, against 28 KB. .It Fl base Ar addr Load the program at .Ar addr , not 400000H, as a kernel may want: a multiple of 4096, written as raz writes a number, as .Cm 0FFFFFFFF80000000H . The program must lie wholly in the low or the top 2 GB of the address space, which a 32-bit address reaches. .It Fl bare Make a program for the bare machine, a kernel, with no Linux under it. Its entry point reads no arguments, so .Fn ARGC is 0, and runs no body of .Cm Rt , whose system calls set the handlers of signals: a nil pointer or a division fault is not told. A failed check is still told, by a system call the kernel must catch. Its stack must be 16-byte aligned, as Linux leaves it, and its bss zeroed. A program that uses C is refused. .It Fl noprofile Leave out the profiler, which .Ev RAZ_PROFILE turns on, but keep the rest. .It Fl libc Ar name Link a program that uses C against .Ar name , .Cm glibc or .Cm musl . Left out, it is glibc, or musl on a machine that has musl's loader, .Pa /lib/ld-musl-x86_64.so.1 , and not glibc's, as Alpine has. A program without C needs no C library, and runs on either. .It Fl q Cm check For an editor: check .Ar Main.raz , reading its text from standard input, as the editor holds it, and write no program. Each message is a row on standard output; see .Sx FOR AN EDITOR . .It Fl q Cm words For an editor: with .Ar Main.raz : Ns Ar LINE : Ns Ar COL in place of .Ar Main.raz , write the names that can be typed at that cursor, a row each, and nothing else. .It Fl q Cm def For an editor: with .Ar Main.raz : Ns Ar LINE : Ns Ar COL in place of .Ar Main.raz , write where the name at that cursor is declared, and what it is. .It Fl h , Fl \-help Say the options. .It Fl \-version Say the version of .Nm , and the version of the report it follows. .El .Sh ENVIRONMENT .Bl -tag -width "RAZ_PROFILE" .It Ev RAZ_PATH Colon-separated directories of installed raz source modules, searched after the .Fl I directories and before the standard library. When unset, the user library directory is .Pa $HOME/.raz/lib ; with no nonempty .Ev HOME , there is no default. An explicitly empty .Ev RAZ_PATH disables user library directories; it does not disable the standard library. Empty entries are ignored, not taken as the working directory. Relative paths are relative to the compiler's working directory. The compiler does not expand a tilde or variables within paths. Directories are not searched recursively: install a library's source modules directly in one of them, with their target-specific siblings. The duplicate-module error and symbolic-link exception apply across all search directories; .Fl I does not override an installed module. .It Ev RAZ_PROFILE Set to anything, in the environment of a program built without .Fl s or .Fl noprofile , it has the program sample itself every millisecond of its time, and say at its end, on standard error, which procedures took the most of it, each with its share in its own code and its share in all, with the procedures it called, and which places in the source: .Bd -literal -offset indent profile: 521 samples of a millisecond; each procedure's own, then with its calls' 16% 27% Screen.put 9% 93% Parser.feed by place: 8% src/Screen.raz:275:5 .Ed .El .Sh EXIT STATUS .Nm exits 0 if it wrote the program, and 1 if it found an error, which it says on standard error, with the line of source and a mark under the place. .Nm .Cm run exits as the program does. .Sh FOR AN EDITOR .Fl q is for an editor's language server, which asks of the text it holds, saved or not. The text of the main module comes from standard input; the modules it imports are read from their files, found as for a compile. Every row is fields split by tabs. .Pp .Fl q Cm check gives a row for each error, warning and note: .Bd -literal -offset indent FILE LINE COL ENDLINE ENDCOL KIND MESSAGE .Ed .Pp where the place runs from .Ar LINE and .Ar COL up to, not including, .Ar ENDLINE and .Ar ENDCOL , lines and bytes in a line counted from 1, and .Ar KIND is .Cm error , .Cm warning or .Cm note . .Ar FILE may be another module's, as for a note. An error about no place in a file, as a module not found, has an empty .Ar FILE and zeros. It exits 1 if there was an error, else 0. .Pp .Fl q Cm words reads the module up to the cursor, past any errors, and gives a row for each name that can be typed there and starts with what is typed of the name the cursor is in or just after: .Bd -literal -offset indent KIND NAME TYPE .Ed .Pp where .Ar KIND is .Cm const , .Cm type , .Cm var , .Cm proc , .Cm module , .Cm field or .Cm builtin . After a module's name and a dot, the names are those the module exports; elsewhere, every name in scope there, a local hiding a global of its name. The rows come in no order. Inside a comment or a string, after a record's dot, or where a name is declared, there are none. It exits 0. .Pp .Fl q Cm def reads the module up to the cursor as .Cm words does, and gives one row for the name the cursor is in, or just after: .Bd -literal -offset indent FILE LINE COL ENDLINE ENDCOL KIND NAME TYPE .Ed .Pp where the place is that of the name in its declaration, as .Cm check gives places, and .Ar KIND and .Ar TYPE are as .Cm words gives them. A module's place is its name in its own .Li module line, on an import's name too; a name of the language's own, as .Cm INT or .Cm LEN , has no file, and zeros. Where .Cm words would give no names, it gives no row. It exits 0. .Sh LISTING The listing of .Fl S is in lines of three kinds, which a tool may read: .Bl -bullet -offset indent .It a blank line, then a procedure's name as .Ql Module.name: ; .It a source line: its number, right-aligned in 6 columns, two spaces, and the line's text as it is in the file; .It an instruction: its offset in the procedure, right-aligned in 14 columns, two spaces, and the instruction as an assembler would read it; a jump within the procedure gives its target as an offset in the same way, and a call of a procedure names it. .El .Pp The listing is of the main module's live procedures, those the program uses, in the order their code was made. Nothing is disassembled: each instruction is the one the compiler meant to write. A source line comes before the first instruction made for it, and is not repeated until the line changes. .Sh EXAMPLES Compile and run hello, world: .Bd -literal -offset indent raz Hello.raz && ./Hello raz run Hello.raz .Ed .Pp Build a small program for shipping, then see where its time goes: .Bd -literal -offset indent raz -s -o hello Hello.raz raz -o prog Prog.raz && RAZ_PROFILE=1 ./prog .Ed .Sh SEE ALSO .Xr raz-lib 3 , the library; .Xr raz-tutorial 7 , a tour of the language; .Xr raz 7 , the language at a glance; .Xr gdb 1 . The report, .Pa doc/raz.md , defines the language, and the guide to the compiler, .Pa doc/compiler.md , walks through its sources.