-h, --help | Print help and exit |
--watch | Enable compiler REPL |
--color <arg> | Enable or disable colored message |
-femit-bin | (default) Output machine code |
-fno-emit-bin | Do not output machine code |
-femit-asm | Output .s (assembly code) |
-fno-emit-asm | (default) Do not output .s (assembly code) |
-femit-llvm-ir | Produce a .ll file with LLVM IR (requires LLVM extensions) |
-fno-emit-llvm-ir | (default) Do not produce a .ll file with LLVM IR |
-femit-llvm-bc | Produce a LLVM module as a .bc file (requires LLVM extensions) |
-fno-emit-llvm-bc | (default) Do not produce a LLVM module as a .bc file |
-femit-h | Generate a C header file (.h) |
-fno-emit-h | (default) Do not generate a C header file (.h) |
-femit-docs | Create a docs/ dir with html documentation |
-fno-emit-docs | (default) Do not produce docs/ dir with html documentation |
-femit-analysis | Write analysis JSON file with type information |
-fno-emit-analysis | (default) Do not write analysis JSON file with type information |
-femit-implib | (default) Produce an import .lib when building a Windows DLL |
-fno-emit-implib | Do not produce an import .lib when building a Windows DLL |
--show-builtin | Output the source of @import("builtin") then exit |
--cache-dir <arg> | Override path to local Zig cache directory |
--global-cache-dir <arg> | Override path to global Zig cache directory |
--zig-lib-dir <arg> | Override path to Zig lib directory |
--enable-cache | Output to cache directory; print path to stdout |
-target | <arch><sub>-<os>-<abi> see the targets command |
-mcpu | Specify target CPU and feature set |
-mcmodel <arg> | Limit range of code and data virtual addresses |
-mred-zone | Force-enable the "red-zone" |
-mnored-zone | Force-disable the "red-zone" |
-fomit-frame-pointer | Omit the stack frame pointer |
-fno-omit-frame-pointer | Store the stack frame pointer |
-mexec-model | (WASI) Execution model |
--name | Override root name (not a file path) |
-O <mode> | Choose what to optimize for |
--pkg-begin <name> <path> | Make pkg available to import and push current pkg |
--pkg-end | Pop current pkg |
--main-pkg-path <path> | Set the directory of the root package |
-fPIC | Force-enable Position Independent Code |
-fno-PIC | Force-disable Position Independent Code |
-fPIE | Force-enable Position Independent Executable |
-fno-PIE | Force-disable Position Independent Executable |
-flto | Force-enable Link Time Optimization (requires LLVM extensions) |
-fno-lto | Force-disable Link Time Optimization |
-fstack-check | Enable stack probing in unsafe builds |
-fno-stack-check | Disable stack probing in unsafe builds |
-fstack-protector | Enable stack protection in unsafe builds |
--fno-stack-protector | Disable stack protection in unsafe builds |
-fsanitize-c | Enable C undefined behavior detection in unsafe builds |
-fno-sanitize-c | Disable C undefined behavior detection in safe builds |
-fvalgrind | Include valgrind client requests in release builds |
-fno-valgrind | Omit valgrind client requests in debug builds |
-fsanitize-thread | Enable Thread Sanitizer |
-fno-sanitize-thread | Disable Thread Sanitizer |
-fdll-export-fns | Mark exported functions as DLL exports (Windows) |
-fno-dll-export-fns | Force-disable marking exported functions as DLL exports |
-funwind-tables | Always produce unwind table entries for all functions |
-fno-unwind-tables | Never produce unwind table entries |
-fLLVM | Force using LLVM as the codegen backend |
-fno-LLVM | Prevent using LLVM as the codegen backend |
-fClang | Force using Clang as the C/C++ compilation backend |
-fno-Clang | Prevent using Clang as the C/C++ compilation backend |
-fstage1 | Force using bootstrap compiler as the codegen backend |
-fno-stage1 | Prevent using bootstrap compiler as the codegen backend |
-freference-trace | How many lines of reference trace should be shown per compile error |
-fno-reference-trace | Disable reference trace |
-fsingle-threaded | Code assumes there is only one thread |
-fno-single-threaded | Code may not assume there is only one thread |
-fbuiltin | Enable implicit builtin knowledge of functions |
-fno-builtin | Disable implicit builtin knowledge of functions |
-ffunction-sections | Places each function in a separate section |
-fno-function-sections | All functions go into same section |
-fstrip | Omit debug symbols |
-fno-strip | Keep debug symbols |
-ofmt <mode> | Override target object format |
-idirafter <dir> | Add directory to AFTER include search path |
-isystem <dir> | Add directory to SYSTEM include search path |
-I | Add directory to include search path |
-D | Define C [macro] to [value] (1 if [value] omitted) |
--libc <file> | Provide a file which specifies libc paths |
-cflags | Set extra flags for the next positional C source files |
-l, --library <lib> | Link against system library (only if actually used) |
-needed-l, --needed-library <lib> | Link against system library (even if unused) |
-L, --library-directory <d> | Add a directory to the library search path |
-T, --script <script> | Use a custom linker script |
--version-script <path> | Provide a version .map file |
--dynamic-linker <path> | Set the dynamic interpreter path (usually ld.so) |
--sysroot <path> | Set the system root directory (usually /) |
--version <ver> | Dynamic library semver |
--entry <name> | Set the entrypoint symbol name |
-fsoname | Override the default SONAME value |
-fno-soname | Disable emitting a SONAME |
-fLLD | Force using LLD as the linker |
-fno-LLD | Prevent using LLD as the linker |
-fcompiler-rt | Always include compiler-rt symbols in output |
-fno-compiler-rt | Prevent including compiler-rt symbols in output |
-rdynamic | Add all symbols to the dynamic symbol table |
-rpath <path> | Add directory to the runtime library search path |
-feach-lib-rpath | Ensure adding rpath for each used dynamic library |
-fno-each-lib-rpath | Prevent adding rpath for each used dynamic library |
-fallow-shlib-undefined | Allows undefined symbols in shared libraries |
-fno-allow-shlib-undefined | Disallows undefined symbols in shared libraries |
-fbuild-id | Helps coordinate stripped binaries with debug symbols |
-fno-build-id | (default) Saves a bit of time linking |
--eh-frame-hdr | Enable C++ exception handling by passing --eh-frame-hdr to linker |
--emit-relocs | Enable output of relocation sections for post build tools |
-z <arg> | Set linker extension flags |
-dynamic | Force output to be dynamically linked |
-static | Force output to be statically linked |
-Bsymbolic | Bind global references locally |
--compress-debug-sections <e> | Debug section compression settings |
--gc-sections | Force removal of functions and data that are unreachable by the entry point or exported symbols |
--no-gc-sections | Don't force removal of unreachable functions and data |
--subsystem <subsystem> | (Windows) /SUBSYSTEM:<subsystem> to the linker |
--stack <size> | Override default stack size |
--image-base <addr> | Set base address for executable image |
-weak-l, -weak_library <lib> | (Darwin) link against system library and mark it and all referenced symbols as weak |
-framework <name> | (Darwin) link against framework |
-needed_framework <name> | (Darwin) link against framework (even if unused) |
-needed_library <lib> | (Darwin) link against framework (even if unused) |
-weak_framework <name> | (Darwin) link against framework and mark it and all referenced symbols as weak |
-F <dir> | (Darwin) add search path for frameworks |
-install_name | (Darwin) add dylib's install name |
--entitlements <path> | (Darwin) add path to entitlements file for embedding in code signature |
-pagezero_size <value> | (Darwin) size of the __PAGEZERO segment in hexadecimal notation |
-search_paths_first | (Darwin) search each dir in library search paths for `libx.dylib` then `libx.a` |
-search_dylibs_first | (Darwin) search `libx.dylib` in each dir in library search paths, then `libx.a` |
-headerpad <value> | (Darwin) set minimum space for future expansion of the load commands in hexadecimal notation |
-headerpad_max_install_names | (Darwin) set enough space as if all paths were MAXPATHLEN |
-dead_strip | (Darwin) remove functions and data that are unreachable by the entry point or exported symbols |
-dead_strip_dylibs | (Darwin) remove dylibs that are unreachable by the entry point or exported symbols |
--import-memory | (WebAssembly) import memory from the environment |
--import-table | (WebAssembly) import function table from the host environment |
--export-table | (WebAssembly) export function table to the host environment |
--initial-memory | (WebAssembly) initial size of the linear memory |
--max-memory | (WebAssembly) maximum size of the linear memory |
--shared-memory | (WebAssembly) use shared linear memory |
--global-base | (WebAssembly) where to start to place global data |
--export | (WebAssembly) Force a symbol to be exported |
--test-filter <filter> | Skip tests that do not match filter |
--test-name-prefix <text> | Add prefix to all tests |
--test-cmd <arg> | Specify test execution command one arg at a time |
--test-cmd-bin | Appends test binary path to test cmd args |
--test-evented-io | Runs the test in evented I/O mode |
--test-no-exec | Compiles test binary without running it |
-ftime-report | Print timing diagnostics |
-fstack-report | Print stack size diagnostics |
--verbose-link | Display linker invocations |
--verbose-cc | Display linker invocations |
--verbose-air | Enable compiler debug output for Zig AIR |
--verbose-llvm-ir | Enable compiler debug output for LLVM IR |
--verbose-cimport | Enable compiler debug output for C imports |
--verbose-llvm-cpu-features | Enable compiler debug output for LLVM CPU features |
--debug-log <scope> | Enable printing debug/info log messages for scope |
--debug-compile-errors | Crash with helpful diagnostics at the first compile error |
--debug-link-snapshot | Enable dumping of the linker's state in JSON format |