Targets and cross-compilation
The supported target matrix, how to select a target with --target, and the accepted target spellings.
elephc compiles to native machine code for a fixed set of first-class targets. All supported targets are equal: a feature is not considered done until it works on every one of them.
Supported target matrix
| Target | Platform | Architecture |
|---|---|---|
macos-aarch64 | macOS | ARM64 (Apple Silicon) |
linux-aarch64 | Linux | ARM64 |
linux-x86_64 | Linux | x86-64 |
By default the compiler targets the host it runs on, detected automatically.
Selecting a target
elephc --target linux-aarch64 hello.php
elephc --target linux-x86_64 hello.php
elephc --target=macos-aarch64 hello.php
Both the spaced (--target VALUE) and inline (--target=VALUE) forms work.
Accepted spellings
Each target accepts several spellings, including the LLVM-style triple, so build scripts written for other toolchains keep working:
| Canonical | Also accepted |
|---|---|
macos-aarch64 | macos-arm64, aarch64-apple-darwin |
linux-aarch64 | linux-arm64, aarch64-unknown-linux-gnu |
linux-x86_64 | x86_64-unknown-linux-gnu |
The parser also recognizes macos-x86_64 / x86_64-apple-darwin and
windows-x86_64 / x86_64-pc-windows-msvc /
x86_64-pc-windows-gnu. These spellings are groundwork for future backends,
not supported targets: compilation stops with an explicit unsupported-backend
diagnostic.
Cross-compilation notes
Selecting a target different from the host produces assembly and an object file
for that target. Producing a final linked binary still depends on having a
linker and any target libraries available for that platform; the elephc test
suite uses the Docker scripts under scripts/ to build and run the Linux
targets from a macOS host.
For the target-aware ABI and runtime details behind each platform, see Architecture and The Code Generator.