Last updated: 2026-11-22
PatLang 2.0 Beyond Windows: Linux and WebAssembly Targets
For new readers
Up to v2.0.0, PatLang's compiler wrote Windows executables only. Two routes off Windows followed: on 19 November 2026 the compiler, built as WebAssembly, began building programs under Node on Linux; and v2.1.0, on 20 November, added --linux, which writes a static Linux executable with no C library. This page lists the issues each route met and how each was settled.
The compiler as WebAssembly under Node Applied / MethodologicalKnowledge with a 5โ10 year half-life โ stable practice
The first route needed no new back end. The compiler is built as a WebAssembly module from the bootstrap IR by bootstrap/ir_wasm.py, and run_node.mjs --real-files gives the module's file calls to the real disk, so the WebAssembly compiler can build programs. tools/ci_wasm.sh builds the compiler that way and builds and runs the demos with it, skipping those that use sockets. The gates run it as the unit ci_wasm, and a GitHub workflow runs it on Linux.
| Issue | Cause | Fix |
|---|---|---|
The WebAssembly compiler stopped on v2_own_path's contract | The compiler reads its cache key from beside its own executable; a WebAssembly module has no program path | Built as WebAssembly, the compiler keeps no key and no cache |
| Failure paths of file calls had no test | Real disks rarely fail on demand | run_node.mjs --fail NAME:N makes the Nth call to a host function fail; wasm_fail_selftest fails the open, the size and the read in turn, and read_file gives "" each time |
One operating-system layer per target FoundationalKnowledge that endures for decades โ core principles
Native Linux support began by drawing a line through the runtime. The runtime reaches the operating system only in runtime/os_windows.patlang and runtime/os_linux.patlang, which define the same functions; a repository check holds the two files to the same names. Everything above that line is shared.
v2.exe SRC.patlang OUT --linux
writes a static, position-independent ELF executable through lib/x64_elf_link.patlang. Memory, files, time, randomness, threads, fibres, processes, sockets and signals all go through system calls. There is no libc, so whatever a C program would take from it, the runtime provides itself.no libc means no hidden deps you own every syscall
print(host_caps())
print(cwd())
Built with --linux and run under WSL's Ubuntu 24.04, this prints:
[x64, subprocess, tcp, tcp_remote, fs]
/mnt/d/PatLang
and file reports ELF 64-bit LSB pie executable, x86-64, statically linked. The Windows interpreter prints the same first line. The compiler and the interpreter both build for Linux, and the Linux compiler writes the same bytes as the Windows compiler's --linux build, which linux_compiler_selftest checks.
What a missing C library cost Applied / MethodologicalKnowledge with a 5โ10 year half-life โ stable practice
| Need | Windows | Linux, without libc |
|---|---|---|
| Mathematical functions | The system's | runtime/libm.patlang, written in PatLang and checked against reference vectors; both targets now use it, with a fast path for float arithmetic |
| Name lookup | getaddrinfo | /etc/hosts, then an A query over UDP to each nameserver in /etc/resolv.conf (5ย s, twice). New UDP primitives; CNAMEs followed; [] for NXDOMAIN or silence |
| Starting a child on a terminal | ConPTY | /dev/ptmx; the child needs its own session and a controlling terminal, set up by a spawn_exec stub in the code generator |
| Raw console input | Console modes | Its own implementation in os_linux; console_raw_enable, console_read_raw_byte and console_raw_disable behave the same on both |
| Root certificates (planned, for TLS) | The system ROOT store | /etc/ssl/certs/ca-certificates.crt, decoded from PEM |
Behaviour that differed between the systems Applied / MethodologicalKnowledge with a 5โ10 year half-life โ stable practice
Each of these passed on Windows and failed, or would have failed, on Linux.
| Issue | Cause | Fix |
|---|---|---|
| Signals had nowhere to keep their token | LOCALAPPDATA and TEMP are unset on Linux | The token goes under XDG_RUNTIME_DIR, else ~/.cache |
A wait after is_alive lost the child's exit code | is_alive collected the child's status | is_alive asks with waitid and WNOWAIT, leaving the status for the wait |
| A port stayed taken after its program ended | A connection in TIME_WAIT holds the address on Linux | Listeners set SO_REUSEADDR |
| A program asking for "the interpreter" got the Windows one | v2_interpreter() named the .exe | It names the Linux interpreter when the program runs on Linux |
| A Linux program could not reach a Windows interpreter it started | A Windows program started through WSL's interop listens on a loopback the Linux program cannot reach | Scenarios that start the interpreter start the Linux build, v2_interp_linux |
| The end of a terminal session went missing | ConPTY sends a program's last output after the program has ended | pty_close returns the console's last output; tests read the whole transcript |
The is_alive and port issues led to a standing rule: an operating-system-layer function gets a Part 1 fixture run on every target, not only a Windows test.
Measuring on Linux Applied / MethodologicalKnowledge with a 5โ10 year half-life โ stable practice
Part 1 fixtures check peak memory, so the Linux gates needed a peak they could trust.
- The peak of
wsl.exe, as Windows sees it, says nothing about the program inside. A small Linux-built helper,spec/linux_peak.patlang, runs the fixture and reports its peak resident set fromwait4. - With address-space layout randomisation on, a fixture's peak varied by about 15% between runs. Peaks are measured with it off (
setarch -R).
Linux in the gates Ephemeral / ToolingKnowledge that evolves in months to a year โ check for updates
| Unit | Runs |
|---|---|
part1_linux | The Part 1 fixtures as Linux builds under WSL, with their peaks |
language_linux | The language scenarios, with "compiled" meaning a Linux build |
interpreter_linux | Builds the Linux interpreter the scenarios start |
showcase_linux, demos_linux | The showcase programs and the demos as Linux builds |
ci_wasm | The WebAssembly compiler under Node |
Two issues came from adding these units. language_linux first passed by running nothing: its runner's arguments were placed where its source belongs, so it listed no feature files. A suite whose runner lists nothing now fails as SUITE/listing. It was also given a lane of its own, so its build_daemon_exemplar ran beside the Windows suite's and the two shared port 9410, the task registry and the daemon's history file. Lanes are now per feature file and shared across the language suites, so one scenario never runs on two engines at once while different scenarios run side by side.
At v2.1.0 the gates held 859 units, none failing.
Running a Linux build from Windows Ephemeral / ToolingKnowledge that evolves in months to a year โ check for updates
From Git Bash, a Linux build runs under WSL as
MSYS_NO_PATHCONV=1 wsl -d Ubuntu-24.04 -e /mnt/d/PATH/TO/PROGRAM
Without MSYS_NO_PATHCONV=1, Git Bash rewrites the /mnt/d/... argument into a Windows path before WSL sees it.
See also
Porting to PatLang 2.0: issues by stage covers the move of programs and content onto v2. The v2 IR and its readers describes the IR the WebAssembly route builds from. Issues found in the v2 gates covers lanes, listings and measurement in the gates generally.
Graduate Attributes
Modelled on this page
- Subject Specialist: Technical distinctions are drawn between static linking, position-independent executables and system calls to explain the architecture.
- Researcher: Specific issues encountered during porting are documented alongside the precise fixes implemented to resolve them.
- Digitally Fluent: The integration of WebAssembly modules with Node.js and Linux environments is described with reference to specific scripts and workflows.
University of Reading Graduate Attributes framework.