Report 2026-11.0: darwin-arm64, a second target; PLAN.md 5, the port The report names arm64 macOS as a target (section 3), its file names as uname gives them, and its calling convention and assembly language (appendix A); the sizes given for x86-64 hold on arm64. No language changes. PLAN.md 5 is the port, v0.26.0, with the owner's answers; the clean-up moves to v0.27.0.
| @@ -151,8 +151,107 @@ | ||
| 151 | 151 | v0.25.3, 2026-10-29: `raz -q def` on a module, used or imported, gives |
| 152 | 152 | its `module` line. |
| 153 | 153 | |
| 154 | -## 5. Clean-up: v0.26.0, the last before 1.0 | |
| 154 | +## 5. arm64 macOS: v0.26.0 | |
| 155 | + | |
| 156 | +Started by the owner's word of 2026-11-15: raz on an Apple Silicon Mac, | |
| 157 | +natively, as a second target, `darwin-arm64`. Report 2026-11.0 names | |
| 158 | +it and changes no language (section 3, appendix A). | |
| 159 | + | |
| 160 | +**The shape.** `Gen` is the only unit that knows the machine, and | |
| 161 | +`Elf` the only one that knows the executable, so the port is new | |
| 162 | +units beside them, not a change to `Parse` or `Item`: | |
| 163 | + | |
| 164 | +- `A64.raz`, beside `X64.raz`: arm64's instructions encoded, branches | |
| 165 | + within a procedure, and the assembler for code procedures (Arm's | |
| 166 | + syntax, the instructions the library's code procedures use; `db` for | |
| 167 | + any other). | |
| 168 | +- `Gen.arm64.raz`, beside `Gen.raz` (to be `Gen.x86_64.raz`): the same | |
| 169 | + calls, the stack machine kept in arm64's registers; Apple's calling | |
| 170 | + convention (x18 never touched, a frame record in x29, the arguments | |
| 171 | + past a variadic C procedure's own on the stack); every address by | |
| 172 | + `adrp` and `add`, since macOS runs no executable at a fixed address; | |
| 173 | + the atomics by the LSE instructions every Apple processor has. | |
| 174 | + Two things x86 does for free and arm64 doesn't, which the report | |
| 175 | + binds: a division by zero, or the smallest value by -1, stops the | |
| 176 | + program (arm64's `sdiv` gives 0), so it is checked; a real out of an | |
| 177 | + `I64`'s range, or a NaN, gives the smallest `I64` (arm64's `fcvtzs` | |
| 178 | + saturates), so it is mended after. | |
| 179 | +- `MachO.raz`, beside `Elf.raz`: a Mach-O executable for dyld, linked | |
| 180 | + to libSystem, as every macOS program must be; C's symbols bound into | |
| 181 | + a table of quadwords, as GLOB_DAT does now; every address in data | |
| 182 | + rebased, since the program is position-independent; its symbol table | |
| 183 | + for lldb's backtraces; and an ad-hoc code signature, SHA-256 hashes | |
| 184 | + of its pages, without which arm64 macOS won't run it. No line | |
| 185 | + numbers for a debugger at first. | |
| 186 | +- `Host.darwin.raz`: the library beside the compiler by | |
| 187 | + `_NSGetExecutablePath`, C always, a program run from a file written | |
| 188 | + and made executable (no `memfd_create`). | |
| 189 | +- `Link`: the places in data that hold an address, listed for | |
| 190 | + `MachO`'s rebasing. | |
| 191 | + | |
| 192 | +A compiler compiles for the system it runs on, as now: its target is | |
| 193 | +the one it was built for, its back end and executable chosen at its | |
| 194 | +build by the target's suffixes (section 3), `Gen.arm64.raz` and | |
| 195 | +`Host.darwin.raz` as `Sys.linux-x86_64.raz` is today. No `-target`. | |
| 196 | +A compiler for one system that runs on another is built by staging, | |
| 197 | +as appendix (b) proposes for Moss: `src/cross.sh` copies `src/` with | |
| 198 | +the other target's files in place. It is needed once, for the first | |
| 199 | +Mac compiler, and wherever a release for one system is made on the | |
| 200 | +other. | |
| 201 | + | |
| 202 | +**The library.** Over libSystem, through `lib/Sys.raz`, the C one, | |
| 203 | +with `CAbi.darwin-arm64.raz` made by `tools/cabi.c` on the Mac, never | |
| 204 | +by hand. `Rt.darwin-arm64.raz`: the signals and their own stack, the | |
| 205 | +place a fault stopped at from the Mac's `ucontext`, and `framePtr`, | |
| 206 | +`liveRegs`, `here` and `sigReturn` in arm64. `Thread.darwin.raz` over | |
| 207 | +pthreads, its `Mutex` on `os_unfair_lock`. `Bytes.arm64.raz`. `Math`'s | |
| 208 | +`sqrt`, `mul` and `div128` and `Str`'s code procedure move into | |
| 209 | +`.x86_64` files with arm64 twins: no generic file keeps machine code. | |
| 210 | +None of it breaks a program. | |
| 211 | + | |
| 212 | +**Steps**, one commit each, `make check` passing first (in a | |
| 213 | +linux/amd64 container on the Mac until there is a Mac compiler): | |
| 214 | + | |
| 215 | +1. Report 2026-11.0, for the owner's review. (This commit.) | |
| 216 | +2. A container to build and check in on the Mac (`make docker-check`), | |
| 217 | + the budget raised to 18,000 in `CLAUDE.md` and `doc/compiler.md`, | |
| 218 | + and the Makefile and scripts made to run on BSD's tools as on GNU's | |
| 219 | + (`sed -i`, `stat`, `sha256sum`). | |
| 220 | +3. `Gen.raz` to `Gen.x86_64.raz`, `Elf` behind a unit of the target's | |
| 221 | + (`Exe`), `src/cross.sh`: Linux's compiler unchanged, byte for byte. | |
| 222 | +4. `A64.raz`, its encoder checked against `llvm-mc`'s bytes. | |
| 223 | +5. `Gen.arm64.raz`, in pieces: values and operations; jumps and | |
| 224 | + checks; calls and frames; reals; atomics, deferred statements, the | |
| 225 | + entry point. | |
| 226 | +6. `MachO.raz` and `Link`'s rebases, its line numbers for lldb; | |
| 227 | + `Host.darwin.raz`. | |
| 228 | +7. The library: `CAbi`, `Sys`, `Rt`, `Thread`, `Bytes`, `Math`, `Str`. | |
| 229 | +8. `test/` and `conform/` passing on the Mac; what differs by target | |
| 230 | + (signals' words, errors' numbers) in files of the target's. | |
| 231 | +9. The first Mac compiler, by the staged cross compiler; it builds | |
| 232 | + itself; `make fixpoint` on the Mac; `make bench` at 400,000 lines a | |
| 233 | + second there. | |
| 234 | +10. The release: two tarballs, `linux-x86_64` and `darwin-arm64`; | |
| 235 | + `BOOT` names one for each host, with its sum. | |
| 236 | + | |
| 237 | +**The owner's answers**, 2026-11-15: | |
| 238 | + | |
| 239 | +a. The budget is 18,000 lines of code. | |
| 240 | +b. The names are `darwin-arm64`. | |
| 241 | +c. No CI for now: the Mac's tarball is made here by `make dist`. | |
| 242 | +d. The port is v0.26.0; the clean-up and 1.0 move one on. | |
| 243 | +e. Line numbers for lldb are in v0.26.0 (below). | |
| 155 | 244 | |
| 245 | +**Line numbers on the Mac.** `Elf` writes DWARF 4 already: the line | |
| 246 | +table `makeLines` makes, target-blind, and the one compile unit | |
| 247 | +`putDebug` writes. lldb reads DWARF from an executable's `__DWARF` | |
| 248 | +segment, as it does Go's, so `MachO` writes the same three sections, | |
| 249 | +`__debug_line`, `__debug_info` and `__debug_abbrev`, there, unloaded, | |
| 250 | +before `__LINKEDIT`; `make gdb`'s twin drives `lldb --batch`. About 50 | |
| 251 | +lines, `makeLines` and `putDebug` shared by the two writers. | |
| 252 | + | |
| 253 | +## 6. Clean-up: v0.27.0, the last before 1.0 | |
| 254 | + | |
| 156 | 255 | The files that served the thaws are made a record, short and true: |
| 157 | 256 | |
| 158 | 257 | - `PROPOSALS.md` and `MEM_PROPOSAL.md`: gone, done early (2026-10-26); |
| @@ -169,11 +268,11 @@ | ||
| 169 | 268 | - The programs in `~/r` that pin an older raz (rmacs, ravite, rnet, ...) |
| 170 | 269 | moved to the release. |
| 171 | 270 | |
| 172 | -## 6. 1.0 | |
| 271 | +## 7. 1.0 | |
| 173 | 272 | |
| 174 | -No date. raz is 1.0 when use shows it: programs written against v0.26.0 | |
| 273 | +No date. raz is 1.0 when use shows it: programs written against v0.27.0 | |
| 175 | 274 | for long enough that no defect is outstanding. Until then it is |
| 176 | -0.26.x, mending defects only. | |
| 275 | +0.27.x, mending defects only. | |
| 177 | 276 | |
| 178 | 277 | ## Appendix: the Moss work, as proposed |
| 179 | 278 |
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | This report defines the language. It is short on purpose. Whatever it |
| 14 | 14 | doesn't allow, raz doesn't have. |
| 15 | 15 | |
| 16 | -This is version 2026-10.38 of the report; section 11 says where each | |
| 16 | +This is version 2026-11.0 of the report; section 11 says where each | |
| 17 | 17 | version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose, |
| 18 | 18 | for a language anyone can build again. They break programs written |
| 19 | 19 | for 2026-10.10 and before: for 2026-10.9, say, the report of compiler |
| @@ -81,7 +81,8 @@ | ||
| 81 | 81 | is for a program on the bare machine: a code procedure names a |
| 82 | 82 | procedure or a global variable in three operands (section 8), and |
| 83 | 83 | section 10 gives the least an implementation accepts, and what it does |
| 84 | -past its own limits; it breaks no program. | |
| 84 | +past its own limits; it breaks no program. 2026-11.0 names a second | |
| 85 | +target, arm64 macOS, and changes no language. | |
| 85 | 86 | |
| 86 | 87 | The language is frozen, softly, from this version on: it changes only |
| 87 | 88 | to mend a defect, and its library grows only by what breaks no program |
| @@ -354,8 +355,10 @@ | ||
| 354 | 355 | directories, with its target-specific files beside them. In each |
| 355 | 356 | directory the compiler takes the |
| 356 | 357 | first of `Name.OS-ARCH.raz`, `Name.OS.raz`, `Name.ARCH.raz` and |
| 357 | -`Name.raz` that exists, where `OS-ARCH` is the target, for now only | |
| 358 | -`linux-x86_64`. So a module whose code depends on the machine or the | |
| 358 | +`Name.raz` that exists, where `OS-ARCH` is the target: `linux-x86_64` | |
| 359 | +or `darwin-arm64`. The names are the system's and the machine's as | |
| 360 | +`uname` gives them, in lower case, and a machine has one name on every | |
| 361 | +system: `arm64` on Linux too. So a module whose code depends on the machine or the | |
| 359 | 362 | system comes in one file per target, and the modules that import it |
| 360 | 363 | don't change. Machine code (section 8) and system calls belong in such |
| 361 | 364 | files. |
| @@ -530,7 +533,7 @@ | ||
| 530 | 533 | | Type | Size | Values | |
| 531 | 534 | |---|---|---| |
| 532 | 535 | | `I8` `I16` `I32` `I64` | 1, 2, 4, 8 | signed integers, two's complement | |
| 533 | -| `INT` | an address's: 8 on x86-64 | signed, as big as an address | | |
| 536 | +| `INT` | an address's: 8 on x86-64 and arm64 | signed, as big as an address | | |
| 534 | 537 | | `UINT` | an address's | unsigned, as big as an address | |
| 535 | 538 | | `U8` `U16` `U32` `U64` | 1, 2, 4, 8 | unsigned integers | |
| 536 | 539 | | `BOOL` | 1 | `false` (0), `true` (1) | |
| @@ -552,7 +555,8 @@ | ||
| 552 | 555 | used code names isn't, so a module like `Fmt` keeps one interface on |
| 553 | 556 | every target. |
| 554 | 557 | |
| 555 | -Each is aligned as the target's C aligns it: to its size on x86-64. | |
| 558 | +Each is aligned as the target's C aligns it: to its size on x86-64 | |
| 559 | +and arm64. | |
| 556 | 560 | So are `ERROR` (section 5.8), pointers |
| 557 | 561 | and procedures, each as big as an address; a slice is aligned as an |
| 558 | 562 | address is. |
| @@ -565,7 +569,7 @@ | ||
| 565 | 569 | ### 5.3 Slices |
| 566 | 570 | |
| 567 | 571 | `[]T` is a view of elements that live elsewhere: a pointer to the first |
| 568 | -and a count, two addresses' worth, 16 bytes on x86-64. | |
| 572 | +and a count, two addresses' worth, 16 bytes on x86-64 and arm64. | |
| 569 | 573 | |
| 570 | 574 | ``` |
| 571 | 575 | Slice = record ptr: ^T; len: INT; end; (* its layout *) |
| @@ -657,7 +661,8 @@ | ||
| 657 | 661 | in that space as a record's would be, after the tag, and the cases |
| 658 | 662 | share it, so the variant is as big as its largest case needs, padded |
| 659 | 663 | to its alignment, the largest of an `INT`'s and its fields'. |
| 660 | -`variant a(x: U8); b(y: I64; z: U8); end` is 24 bytes on x86-64. A | |
| 664 | +`variant a(x: U8); b(y: I64; z: U8); end` is 24 bytes on x86-64 and | |
| 665 | +arm64. A | |
| 661 | 666 | variant that starts at zero therefore holds its first case. |
| 662 | 667 | |
| 663 | 668 | ### 5.7 Enumerations and sets |
| @@ -1980,7 +1985,7 @@ | ||
| 1980 | 1985 | `conform/check.sh` runs them. |
| 1981 | 1986 | |
| 1982 | 1987 | - **The target.** Which machines and systems it compiles for, and the |
| 1983 | - names of their files (`linux-x86_64`, section 3); for each, the size | |
| 1988 | + names of their files (`linux-x86_64`, `darwin-arm64`, section 3); for each, the size | |
| 1984 | 1989 | of an address, and so of `INT`, whether it has reals, and which C |
| 1985 | 1990 | library a program that uses C is linked against. |
| 1986 | 1991 | - **Separate compilation.** Whether modules are compiled on their own, |
| @@ -1993,7 +1998,9 @@ | ||
| 1993 | 1998 | on one with a single processor, by holding off interrupts while |
| 1994 | 1999 | they run, for one. |
| 1995 | 2000 | - **The calling convention.** On x86-64 Linux it is System V |
| 1996 | - (sections 8 and 9); elsewhere it is the C library's own, so that | |
| 2001 | + (sections 8 and 9); on arm64 macOS, Apple's arm64 one, which passes | |
| 2002 | + the arguments past a C procedure's own parameters on the stack; | |
| 2003 | + elsewhere it is the C library's own, so that | |
| 1997 | 2004 | `extern` procedures and callbacks work. How a procedure returns |
| 1998 | 2005 | several results, and how its frame is laid out, are the |
| 1999 | 2006 | implementation's. |
| @@ -2001,10 +2008,11 @@ | ||
| 2001 | 2008 | target's machine code, written in its assembly language, and exist |
| 2002 | 2009 | only where the implementation says so; `SYSTEM.SYSCALL` exists only on Linux targets (section 6.8). A record's |
| 2003 | 2010 | layout is the target's C layout (section 5.5), and the order of a |
| 2004 | - value's bytes is the target's (little-endian on x86-64). | |
| 2011 | + value's bytes is the target's (little-endian on x86-64 and arm64). | |
| 2005 | 2012 | - **The assembly language.** How a code procedure's instructions are |
| 2006 | 2013 | written (section 8). On x86-64 it is Intel's syntax, as NASM writes |
| 2007 | - it, destination first. Which instructions it knows is the | |
| 2014 | + it, destination first; on arm64, Arm's, as its reference manual | |
| 2015 | + writes it, destination first. Which instructions it knows is the | |
| 2008 | 2016 | implementation's; `db` gives any others. |
| 2009 | 2017 | - **Sizes in the library.** How many bytes `Out` keeps before it |
| 2010 | 2018 | writes them, `Sys.outSize` (the library volume): 4 KB on Linux, fewer on a |
| @@ -299,3 +299,10 @@ | ||
| 299 | 299 | labels, deferred statements, type arguments), and says that past its |
| 300 | 300 | own limits it rejects the program with an error naming the limit; |
| 301 | 301 | appendix A leaves how far past to it. It breaks no program. |
| 302 | +- **2026-11.0.** A second target, `darwin-arm64`: arm64 macOS. The | |
| 303 | + names of a target's files are the system's and the machine's as | |
| 304 | + `uname` gives them, in lower case, a machine's the same on every | |
| 305 | + system (section 3). Appendix A gives arm64 macOS's calling | |
| 306 | + convention, Apple's, and its assembly language, Arm's. The sizes the | |
| 307 | + report gives for x86-64 hold on arm64. It changes no language and | |
| 308 | + breaks no program. |
| @@ -38,7 +38,7 @@ | ||
| 38 | 38 | import SYSTEM; |
| 39 | 39 | |
| 40 | 40 | const |
| 41 | - Report = "2026-10.38"; (* the version of doc/raz.md it follows *) | |
| 41 | + Report = "2026-11.0"; (* the version of doc/raz.md it follows *) | |
| 42 | 42 | |
| 43 | 43 | var |
| 44 | 44 | links: [4]Gen.Link; |