Synopsis
Required Arguments
Path to the C source file to compile.Example:
Output Options
Specify the output file path for the compiled executable.Short form:
-oDefault: Input filename without extensionExamples:Generate and keep the assembly file after compilation.When specified:
- Assembly file is saved with
.sextension - Executable is still produced
- Assembly file persists after linking
- If
-o programis specified:program.s - If no
-oflag:input.s(based on input filename)
Stage Control Options
Stop compilation at a specific stage. These flags are mutually exclusive.Stop after lexing (tokenization).Pipeline stages executed:
- Preprocessing
- Lexing ← stops here
Stop after parsing.Pipeline stages executed:
- Preprocessing
- Lexing
- Parsing ← stops here
Stop after lowering to Three Address Code (TACKY) intermediate representation.Pipeline stages executed:
- Preprocessing
- Lexing
- Parsing
- Type checking
- Lowering to TACKY ← stops here
Stop after code generation (assembly IR creation).Pipeline stages executed:
- Preprocessing
- Lexing
- Parsing
- Type checking
- Lowering to TACKY
- Code generation ← stops here
Target Options
Specify the target architecture triple for cross-compilation.Default: Host system’s default targetFormat:
<arch>-<vendor>-<os>-<abi>Common targets:x86_64-unknown-linux-gnu- 64-bit Linux (GNU)x86_64-unknown-linux-musl- 64-bit Linux (musl)x86_64-apple-darwin- macOSaarch64-unknown-linux-gnu- ARM64 Linux
Display Options
Control colored output for diagnostics and error messages.Choices:
auto- Enable colors if outputting to a terminal (default)always- Always use colorsnever- Never use colors
autoExamples:Environment Variables
The compiler respects the following environment variables:The C compiler to use for preprocessing and linking.Default: Note: This is a hidden option not shown in
ccUsed for:- Running the C preprocessor
- Assembling and linking object files
--help output but can be overridden.Control tracing and logging output for compiler internals.Default:
warn,mcc=debug,mcc-syntax=debug,mcc-driver=debugLog levels: trace, debug, info, warn, errorExamples:Flag Combinations
Valid Combinations
Many flags can be combined:Invalid Combinations
Stage control flags are mutually exclusive:Exit Codes
Success - Compilation completed without errors
Failure - Compilation failed due to:
- Syntax errors
- Type errors
- File I/O errors
- Linker errors
- Internal compiler errors
Examples
Basic Compilation
Assembly Generation
Stage Debugging
Cross-Compilation
CI/CD Usage
Development and Debugging
Related Documentation
- Basic Compilation - Getting started with mcc
- Compilation Stages - Detailed stage documentation