Skip to content
Early preview. Maxon is under active development — incomplete in places, with breaking changes expected before a 1.0 release.

Targets

maxon compiles for five targets. Without --target, it compiles for the host it runs on.

Target Output Extension
x64-windows PE executable .exe
x64-linux Static ELF executable, no libc none
arm64-linux Static ELF executable, no libc none
arm64-macos Mach-O executable, ad-hoc signed none
wasm32-wasi WASI Preview 2 component .wasm

maxon version prints the host target. A spelling that names none of them is refused and the command exits 1:

error: unknown --target 'x86-linux' (expected one of: x64-windows, x64-linux, arm64-macos, arm64-linux, wasm32-wasi)

--target= makes the compiler cross-compile the program: the compiler itself still runs on the host. Any host can build for any target, with no extra toolchain for the four native targets: the compiler writes the executable, including the macOS code signature, itself.

Commands that take --target=:

Command What the target changes
maxon build The executable it writes
maxon test The test binary, which it then runs; on a host that cannot execute that target, every test is reported as not run
maxon spec-test Each spec test, which it then runs where this host has a runner for that target (see its --target option)

maxon execute always builds for the host, and so do a .maxproj project file and a .maxtasks task file (the builds they describe follow --target). An executable copied from Windows to a Linux or macOS machine may need chmod +x before it runs.

The output is a WASI Preview 2 component. Run it under a runtime that supports components, such as wasmtime, enabling the cli-exit-with-code interface the component imports so its exit code is delivered:

Terminal window
maxon build app.maxon --target=wasm32-wasi # writes app.wasm
wasmtime run -S cli-exit-with-code=y app.wasm

Without -S cli-exit-with-code=y, wasmtime refuses to start the component.

A module that contains a tail-jumped runtime routine, which is any program that uses arrays or boxes, needs a runtime with the WebAssembly tail-call proposal (return_call) enabled. The vendored wasmtime 44 enables it by default; wasmtime -W tail-call=n refuses the module.

Building a component needs two tools the compiler calls: wasm-tools, and the WASI WIT package. The compiler looks for them as vendor/wasm-tools/ and vendor/wasi-wit/ in the working directory and the nine directories above it. A Maxon source checkout stages them with scripts/fetch-vendor.sh; an installed compiler does not include them. A build that cannot find one is refused with error E6005, naming what is missing and where it looked, before anything is compiled; a wasm-tools step that fails is refused with the same code and what the step printed.

x64-windows, x64-linux, arm64-linux and arm64-macos support the whole standard library. The differences a program can meet are:

  • x64-windows needs Windows 8 or later: its executables read the wall clock through GetSystemTimePreciseAsFileTime.
  • maxon profile samples a program built for the host’s own native target: through thread handles on x64-windows, ptrace on x64-linux and arm64-linux, and Mach task ports on arm64-macos, which maxon profile takes of a temporary copy re-signed with the get-task-allow entitlement.
  • The interactive debugger — maxon debug, maxon dap-server and the MCP debug_* tools — debugs a program built for the host’s own native target, through that host’s debug interface: a debug port on x64-windows, ptrace on x64-linux and arm64-linux, and Apple’s debugserver on arm64-macos, where a host without the Xcode command line tools is refused.
  • On the Linux targets, host-name resolution for sockets is built in and simple: A records only, the first nameserver in /etc/resolv.conf, no search domains and no CNAME following.

wasm32-wasi runs heap-allocated values, strings, print, structs, arrays, closures, interfaces and floating point, the monotonic and wall clocks, sleep (which waits the whole program), command-line arguments and environment variables. A program that reaches one of the following is refused at compile time, at the call:

Not available on wasm32-wasi Refused with
async/await, green threads, services (the standard library’s Log included), Scheduler.yield, Scheduler.processorCount E3104
Machine uptime and thread CPU time (Clock.osTickMs, Clock.threadCpuTicks) E3104
File and directory I/O E3104
Sockets E3104
Reading console stdin E3104
Process information, priority, CPU count E3104
Subprocesses E3074
error E3104: app.maxon:3:10: 'Clock.threadCpuTicks' lowers to the runtime entry '__thread_cpu_ticks', which has no wasm32-wasi implementation
error E3074: app.maxon:5:17: Subprocess is not supported on wasm32-wasi (no process-spawn primitive); guard the call with #if not os(Wasi).

E3104 and E3074 are reported once the program has no other error, beside any unneeded cast (E3010), so a program with a language error shows that error alone.

To keep one source for several targets, guard the unsupported part with #if not os(Wasi).

Build options that need a host facility are refused on wasm32-wasi before anything is compiled: --debugstream (needs shared memory and an uptime clock) and --coverage (needs file output). maxon test --color=auto cannot detect a terminal there and prints no colour.

On Windows, a program’s output to a console is converted from UTF-8 as it is written, so non-ASCII text displays correctly; output to a pipe or file is the program’s UTF-8 bytes unchanged. The console’s code page is never modified.