← All docs

CLI reference

The complete, authoritative list of every elephc command-line flag, its accepted values, default, and environment-variable override.

This page lists every flag the elephc command accepts. Topical pages (optimization, output, linking) explain the why; this page is the exhaustive what.

Synopsis

elephc [OPTIONS] <source.php>

Exactly one positional argument is required: the path to the PHP source file. The binary is written next to it, named after the source without its extension.

Input and output

FlagValuesDefaultDescription
<source.php>pathRequired. The PHP file to compile.
--emit KIND / --emit=KINDexecutable (exe, bin), cdylib (dylib, shared)executableOutput artifact kind. cdylib builds a C-ABI shared library.
--emit-asmoffWrite generated assembly instead of a binary.
--emit-iroffPrint the EIR textual form and stop.
--checkoffRun front-end checks only; write nothing.
--source-mapoffEmit a .map JSON sidecar next to the assembly (schema).
--debug-infooffEmbed DWARF .file/.loc line directives in the assembly for lldb/gdb/profilers.
--weboffCompile a prefork HTTP server binary instead of a CLI executable. See Web Server.

--emit-ir, --emit-asm, and --check are mutually exclusive. --web cannot be combined with --check, --emit cdylib, --emit-asm, or --emit-ir. See Output formats and diagnostics.

Web server binary runtime arguments

When a program is compiled with --web, the produced binary accepts these runtime arguments (not elephc compiler flags):

ArgumentRequiredDefaultDescription
--listen host:portYesAddress and port to bind. Missing --listen prints an error to stderr and exits non-zero.
--workers NNoCPU countNumber of prefork worker processes. Minimum 1.
--max-body-size NNo8388608 (8 MiB)Max request body in bytes (0 = unlimited); oversized bodies get 413.
--max-requests NNo0 (never)Recycle each worker after N requests (bounds memory growth).
--access-logNooffLog one line per request to stderr.
--help, --versionNoPrint usage / version and exit.
elephc --web app.php
./app --listen 127.0.0.1:8080
./app --listen 0.0.0.0:8080 --workers 4 --max-body-size 1048576 --access-log

The served program also receives $_COOKIE, $_REQUEST, and $_ENV, and can emit cookies with setcookie(). The server shuts down cleanly on SIGINT/SIGTERM and respawns workers that die.

The served program receives the HTTP request through the standard superglobals $_SERVER, $_GET, $_POST, and php://input, and controls the response status and headers with http_response_code() and header(). See Web Server.

Targets

FlagValuesDefaultDescription
--target TARGET / --target=TARGETmacos-aarch64, linux-aarch64, linux-x86_64 (plus alias spellings; recognized future targets produce an unsupported-backend diagnostic)host platformSelect the compilation target.

See Targets and cross-compilation for the full list of accepted spellings.

Optimization and code generation

FlagValuesDefaultEnv overrideDescription
--ir-opt=on|offon, offonELEPHC_IR_OPTToggle the EIR optimization passes: identity folding, peepholes, constant folding, common-subexpression elimination, loop-invariant code motion, dead-instruction elimination, dead-store elimination, branch simplification, and the cross-function small-function inliner — run to a module-level fixed point.
--no-ir-optELEPHC_IR_OPT=offShorthand for --ir-opt=off.
--regalloc=linear|stacklinear, stacklinearELEPHC_REGALLOCRegister allocator: linear-scan, or stack-only fallback.
--null-repr=sentinel|taggedsentinel, taggedtaggedELEPHC_NULL_REPRRepresentation for null-capable scalar slots.

See Optimization and codegen controls.

Linking and FFI

FlagValuesDefaultDescription
--link LIB / -l LIB / -lLIBlibrary nameLink an extra native library (repeatable).
--link-path DIR / -L DIR / -LDIRdirectoryAdd a library search path (repeatable).
--framework NAMEframework nameLink a macOS framework (repeatable).
--with-CRATEpdo, tls, crypto, phar, tz, image, webForce-enable a bridge crate regardless of feature auto-detection (repeatable). Force-links the staticlib (whole-archived, so it is not dead-stripped) and, for crates with a PHP-surface prelude (pdo, tz, image), force-injects that prelude so the API is available. --with-web is an alias for --web. An unknown crate name is an error.

See Linking, heap, and conditional compilation.

Memory and conditional compilation

FlagValuesDefaultDescription
--heap-size=BYTESinteger ≥ 655368388608 (8 MB)Size of the program’s runtime heap.
--define SYMBOL / --define=SYMBOLsymbol nameDefine a compile-time symbol for ifdef (repeatable).

Diagnostics and debugging

FlagValuesDefaultDescription
--timingsoffPrint per-phase compiler timings to stderr.
--gc-statsoffPrint allocation/free counters at exit.
--heap-debugoffEnable runtime heap verification (double-free, bad refcount, free-list corruption).

See Output formats and diagnostics.

Environment variables

Three environment variables provide defaults that the matching flag overrides. They exist mainly so a whole test run or benchmark can flip a default without changing every invocation:

VariableValuesEquivalent flag
ELEPHC_IR_OPTon, off--ir-opt=
ELEPHC_REGALLOClinear, stack--regalloc=
ELEPHC_NULL_REPRtagged, sentinel--null-repr=