From ca1d9f1c12f037fb6a13c8d84727d7026038cbc3 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Fri, 16 Oct 2026 12:59:06 +0100 Subject: [PATCH] site: v0.17.2 The download, the library's PDF and spec page with Sys.execve. --- diff --git a/site/public/_redirects b/site/public/_redirects index 9468464..74e7873 100644 --- a/site/public/_redirects +++ b/site/public/_redirects @@ -1 +1 @@ -/download/latest /download/raz-0.17.1-linux-x86_64.tar.gz 302 +/download/latest /download/raz-0.17.2-linux-x86_64.tar.gz 302 diff --git a/site/public/advanced/listing.html b/site/public/advanced/listing.html index 0d6986b..0e883ad 100644 --- a/site/public/advanced/listing.html +++ b/site/public/advanced/listing.html @@ -258,18 +258,18 @@
$ raz -o Dot Dot.raz
 $ objdump -d -M intel --no-show-raw-insn Dot | sed -n '/<Dot.dot>:/,/ret/p' | head -12
-0000000000403bc0 <Dot.dot>:
-  403bc0:	push   rbp
-  403bc1:	mov    rbp,rsp
-  403bc4:	sub    rsp,0x40
-  403bcb:	mov    QWORD PTR [rbp-0x38],rbx
-  403bcf:	xor    ebx,ebx
-  403bd1:	mov    QWORD PTR [rbp-0x30],r12
-  403bd5:	xor    r12d,r12d
-  403bd8:	mov    QWORD PTR [rbp-0x28],r13
-  403bdc:	xor    r13d,r13d
-  403bdf:	mov    QWORD PTR [rbp-0x20],rdx
-  403be3:	mov    QWORD PTR [rbp-0x18],rcx
+0000000000403b00 <Dot.dot>: + 403b00: push rbp + 403b01: mov rbp,rsp + 403b04: sub rsp,0x40 + 403b0b: mov QWORD PTR [rbp-0x38],rbx + 403b0f: xor ebx,ebx + 403b11: mov QWORD PTR [rbp-0x30],r12 + 403b15: xor r12d,r12d + 403b18: mov QWORD PTR [rbp-0x28],r13 + 403b1c: xor r13d,r13d + 403b1f: mov QWORD PTR [rbp-0x20],rdx + 403b23: mov QWORD PTR [rbp-0x18],rcx

The listing is what the encoder meant; objdump is what the processor will read. They tell the same story.

Save a program under its module’s name and run it with raz run Name.raz.

← System callsContents
diff --git a/site/public/advanced/static.html b/site/public/advanced/static.html index c292548..78c6483 100644 --- a/site/public/advanced/static.html +++ b/site/public/advanced/static.html @@ -65,7 +65,7 @@ $ ldd Bare not a dynamic executable $ ls -l Bare | awk '{print $5, "bytes"}' -26728 bytes +26304 bytes

It is statically linked: no interpreter, no shared libraries, no libc. ldd says so.

What it does when it runs

strace lists every system call a program makes. This is the whole of it:

@@ -134,14 +134,14 @@
$ raz Lean.raz
 $ raz Heavy.raz
 $ ls -l Lean Heavy | awk '{print $9, $5}'
-Heavy 28904
-Lean 28896
+Heavy 28480 +Lean 28464

The sizes differ by a few bytes, not by the hundreds of kilobytes that the table and the procedure would take: they are not in the executable at all. You can link in a library module without worrying what else it offers.

Stripping

-s leaves out what is there for finding faults: the symbols and line numbers, the places a failure is told by, and the profiler. It is for the final build of a size-conscious program; the default keeps them so that gdb and failure messages work.

$ raz -s -o Lean-stripped Lean.raz
 $ ls -l Lean Lean-stripped | awk '{print $9, $5}'
-Lean 28896
+Lean 28464
 Lean-stripped 6856
 $ ./Lean-stripped
 same program
diff --git a/site/public/advanced/targets.html b/site/public/advanced/targets.html index f94f96a..25adc32 100644 --- a/site/public/advanced/targets.html +++ b/site/public/advanced/targets.html @@ -52,7 +52,7 @@ Sys.raz Thread.linux-x86_64.raz $ cd $RAZLIB && grep -c SYSCALL Sys.linux-x86_64.raz Sys.raz -Sys.linux-x86_64.raz:128 +Sys.linux-x86_64.raz:129 Sys.raz:0

A module of your own

Here is a module with two files. Clock.linux-x86_64.raz is for this target; Clock.raz is what any other target would use. Both say what they are in Name, and both make ticks.

diff --git a/site/public/download/raz-0.17.2-linux-x86_64.tar.gz b/site/public/download/raz-0.17.2-linux-x86_64.tar.gz new file mode 100644 index 0000000..ced433e Binary files /dev/null and b/site/public/download/raz-0.17.2-linux-x86_64.tar.gz differ diff --git a/site/public/download/raz-0.17.2-linux-x86_64.tar.gz.sha256 b/site/public/download/raz-0.17.2-linux-x86_64.tar.gz.sha256 new file mode 100644 index 0000000..301d1c3 --- /dev/null +++ b/site/public/download/raz-0.17.2-linux-x86_64.tar.gz.sha256 @@ -0,0 +1 @@ +ba019964915644ce6c0efe08258a08dcaf6ee20ce37a32ac2404a587c0b2c387 raz-0.17.2-linux-x86_64.tar.gz diff --git a/site/public/index.html b/site/public/index.html index b423100..45c1cfe 100644 --- a/site/public/index.html +++ b/site/public/index.html @@ -113,24 +113,24 @@ the library.

Download

-

raz 0.17.1 is a tarball for x86-64 Linux with the compiler, raz, +

raz 0.17.2 is a tarball for x86-64 Linux with the compiler, raz, its library, lib/, which it finds beside itself, the formatter and the documentation tool as sources in tools/, and the manual pages. It needs nothing else installed.

- Download raz 0.17.1 - SHA-256 + Download raz 0.17.2 + SHA-256
-
$ tar xzf raz-0.17.1-linux-x86_64.tar.gz
-$ ln -s $PWD/raz-0.17.1-linux-x86_64/raz ~/.local/bin/raz
+
$ tar xzf raz-0.17.2-linux-x86_64.tar.gz
+$ ln -s $PWD/raz-0.17.2-linux-x86_64/raz ~/.local/bin/raz
 $ raz run Hello.raz

The link works since raz finds lib/ beside its real path. The manual pages are in man/: man ./man/raz-tutorial.7. The address download/latest always leads to the newest release, -and download/raz-0.17.1-linux-x86_64.tar.gz to this one, for -good. Earlier releases: 0.17.0, 0.16.0, 0.15.0, 0.14.0, 0.13.0, 0.12.0, 0.11.1, 0.11.0, 0.10.1, 0.10.0, 0.9.1, 0.9.0, 0.8.0, 0.7.1; each has its SHA-256 beside it, with +and download/raz-0.17.2-linux-x86_64.tar.gz to this one, for +good. Earlier releases: 0.17.1, 0.17.0, 0.16.0, 0.15.0, 0.14.0, 0.13.0, 0.12.0, 0.11.1, 0.11.0, 0.10.1, 0.10.0, 0.9.1, 0.9.0, 0.8.0, 0.7.1; each has its SHA-256 beside it, with .sha256 added to its name.

-

SHA-256 49fb424ac3b7ee9ed29c87cd9fcb89ed314d2c17ca449077154aa293f2b9ff1c

+

SHA-256 ba019964915644ce6c0efe08258a08dcaf6ee20ce37a32ac2404a587c0b2c387

raz is under the ISC license.
diff --git a/site/public/raz-lib.pdf b/site/public/raz-lib.pdf index c23cc0e..0bbf95a 100644 Binary files a/site/public/raz-lib.pdf and b/site/public/raz-lib.pdf differ diff --git a/site/public/spec.html b/site/public/spec.html index c724c3c..08d9666 100644 --- a/site/public/spec.html +++ b/site/public/spec.html @@ -869,7 +869,7 @@ Sys -system calls: open, openMode, openRead, create, read, write, seek, position, truncate, sync, syncAll, lock, close, dup, dupTo, dupAbove, keepOnExec, mmap, munmap, isTerminal, yield, exit; files and directories, rename, remove, removeDir, makeDir, chmod, access, umask, symlink, readLink, info, linkInfo, infoOf, openDir, nextEntry, entryKind, closeDir; the terminal, rawMode, restoreMode, getMode, setMode, termSize, ready; the environment, env, envAt, setEnv, workDir, setWorkDir; programs, spawn and exec, pipes and signals; the user, the machine, time used and limits; time, clock, now, sleep; random; what an errno means, errorText; sockets, among them datagrams served and files passed; and memory shared through a file. One file per target, and Sys.raz over the C library for the others +system calls: open, openMode, openRead, create, read, write, seek, position, truncate, sync, syncAll, lock, close, dup, dupTo, dupAbove, keepOnExec, mmap, munmap, isTerminal, yield, exit; files and directories, rename, remove, removeDir, makeDir, chmod, access, umask, symlink, readLink, info, linkInfo, infoOf, openDir, nextEntry, entryKind, closeDir; the terminal, rawMode, restoreMode, getMode, setMode, termSize, ready; the environment, env, envAt, setEnv, workDir, setWorkDir; programs, spawn, exec and execve, pipes and signals; the user, the machine, time used and limits; time, clock, now, sleep; random; what an errno means, errorText; sockets, among them datagrams served and files passed; and memory shared through a file. One file per target, and Sys.raz over the C library for the others Out @@ -1128,6 +1128,7 @@ proc setTermSize*(fd, cols, rows: INT): INT; (* the size its programs are told of *) proc spawn*(p: Program): INT; (* a program started: its process id *) proc exec*(p: Program): INT; (* p run in this program's place; returns only if it can't *) +proc execve*(path: []U8; args, env: [][]U8): INT; (* as the kernel's execve: no search *) proc fork*: INT; (* this program copied: 0 in the copy, its process id in this one *) proc wait*(pid: INT; block: BOOL): (INT, Status, INT); (* which program, how, and its code *) proc kill*(pid, signal: INT): INT; @@ -1178,6 +1179,7 @@

spawn starts the program at p.path, with p.args as its arguments, the first being its name. A p.path without a / is looked for as a shell looks for a command, and as C’s execvp does: in each directory of this program’s PATH in turn, an empty one being the working directory, or of /bin:/usr/bin if PATH is unset or empty; the first that runs is the program. Its environment is this program’s with each NAME=value of p.env added or put in place of the old value, or, if p.onlyEnv, p.env alone. It starts in p.dir. Its standard input, output and error are p.fds; a 0 gives it this program’s own, so {path: "ls", args: ["ls"]} runs ls as a shell runs it, with every other field zero. It gets no other open file but those of p.more, each at its own number, as a shell passes 3<file on, every signal does what it does at first, and none is blocked. If p.tty is a pseudo-terminal’s fd, the program starts a session on that terminal: it is its controlling terminal, and its standard input, output and error, and p.fds and p.group are not used.

p.group puts the program in a process group, the programs that a shell’s job is made of: -1 makes it the first of a new group, whose number is its process id, and the other programs of the job join that number. The terminal gives its keys, and the signals of Ctrl-C and Ctrl-Z, to one group, the one in its foreground: p.foreground puts the program’s group there before it starts, and foreground puts any group there, as a shell does to take the terminal back. setGroup moves a program to a group, as the shell does for each program it starts, for whichever of the two runs first; a shell runs in a group of its own, setGroup(0, 0).

exec runs the program p describes in this program’s place, as a shell’s exec cmd does, found and started as spawn would start it, p.tty, p.group, p.foreground, p.fds and p.dir included, except that it keeps this program’s other open files: each stays open in the program unless keepOnExec(fd, false) was said of it, as it is of pipe’s, and those of p.more are kept. It returns only if the program can’t run: -2 (ENOENT) or -13 (EACCES) if there is none to run, with nothing done; or, if the program is found but won’t start, minus the errno, with what p asks of the terminal, the group, the files and the directory done, and this program’s signals as they were.

+

execve(path, args, env) is the kernel’s execve, for a shell, which has looked for the program along its own PATH and set up the child already: the program at path is run with args and with env, NAME=value, for its whole environment. Nothing is searched for, and every fd and signal stays as it is, but that a handled signal does what it does at first: an ignored one stays ignored, as trap '' HUP wants of the command it comes before. It returns only if it can’t: minus an errno, with nothing changed.

A shell moves its own files with dup and dupTo, for 2>&1 and exec >log and around a builtin: dupTo(fd, into) makes into the same open file as fd, closing what into was, and dup gives a new fd for it, the lowest free, as a shell saves a file to give it back. dupAbove(fd, 10) gives one at 10 or above, closed on exec, out of the way of the fds a script names (3>log), as a shell keeps its own. fork copies this program, which goes on from there in both: it is 0 in the copy and the copy’s process id in this one, as a shell runs a builtin or a procedure as a stage of a pipe. Only the thread that calls it is copied, so a program with threads mustn’t; and what Out keeps is copied too, to be written twice, so Out.flush comes first. group is the process group this program is in: a shell starting on a terminal waits until it is foregroundOf(0) before it takes it. access says whether this user, by its real ids, may read, write or execute a file, as test -r, -w and -x ask, which Info.mode alone can’t say; an empty how asks only whether it is there. open refuses executing, with -22 (EINVAL). umask sets the bits taken away from the mode of every file this program, and those it starts, make, and says what they were. envAt gives the environment one variable at a time, from 0, for a shell to list it and to pass it on whole with onlyEnv. setEnv refuses a name that is empty or holds an =, and a 0 in either, with -22; as C’s setenv, it isn’t safe while another thread reads the environment, and what env gave for a variable may be gone once it sets that variable again. getMode reads a terminal’s modes, and setMode sets them again once what was written is sent, so that a shell keeps them for each job: a program stopped by Ctrl-Z with its terminal raw gets it back raw, and the shell its own between. cpuTime says how long the processor ran this program, in its own code and in the system for it, or, if children, the programs it started and has waited for, as time and times say. limit gives a limit, limitFiles say, soft and hard, and setLimit sets them, as ulimit does: a program may raise its soft limit up to the hard one, and lower either. uid is the user this program runs as, euid the one whose rights it has, 0 for root, as a prompt shows #; hostName is the machine’s name.

wait waits for the program pid to change, for any of this program’s if pid is -1, or for any of the group g if pid is -g, as a shell waits for a job’s programs, and says which one, and how: exited, with its exit status; killed, with the number of the signal that ended it; or stopped, by Ctrl-Z or a signal, with the signal’s number. Without block it doesn’t wait, and is 0 and running if no program changed. A program that has nothing to wait for is -10 (ECHILD). kill sends a program a signal, sigTerm to end it; to a group, if pid is minus its number.

Signals. catch takes the signals sigs away from what they would do, ending the program most of them, and gives an fd that is ready to read when one comes, so that a program waits for signals with ready and readyOf as it waits for keys or a server. caught gives each signal that came, in turn. A later catch adds to the signals caught and gives the same fd. Catching sigKill or sigStop, or the signals Rt reports, SIGSEGV and SIGFPE, is -22 (EINVAL). ignore makes a signal do nothing, as a shell ignores sigTtou so that it can take its terminal back, and ignore(sig, false) gives it back what it does at first. A program that spawn starts begins with neither.

diff --git a/site/public/tour/hello.html b/site/public/tour/hello.html index 002f685..ea8c881 100644 --- a/site/public/tour/hello.html +++ b/site/public/tour/hello.html @@ -70,7 +70,7 @@ $ raz run Quiet.raz hello, again $ ls -l Quiet | awk '{print $5, "bytes"}' -28904 bytes
+28480 bytes

The program is a static executable with no run time besides the code it uses, so it is a few kilobytes, and runs without any library installed.

What Out can write

Out is the library's buffered output. It writes strings, single characters, numbers in decimal or hexadecimal, and a line feed. A string is written as it is, with \n for a line feed, \t for a tab, \" and \\; or between backquotes, as a raw string with no escapes at all, which may run over lines (lesson 6).