kefir(1) General Commands Manual kefir(1)
NAME
kefir — C17/C23 language compiler
SYNOPSIS
kefir [options] files... [
−run [args...] ]
DESCRIPTION
kefir command-line options follow c99(1) compiler interface, extending it with some of supported gcc(1) flags and flags for special kefir features. Unknown command-line flags are ignored with a warning printed for each such flag passed to the compiler. kefir compiler driver features multiple operation modes. Command-line flags are parsed in left-to-right order with later flags overriding earlier. Some of operation modes, once selected, prevent further parsing and immediately invoke selected mode (refer to “OPTIONS” section for details).
OPTIONS
The following options terminate command-line argument parsing:
−h | −−help
Print help text
−v | −−version
Print compiler version
−−compiler-info
Print compiler information
−−environment-info
Print compiler environment information (see “ENVIRONMENT” section below)
−−environment-header
Print compiler environment header file (based on “ENVIRONMENT” section and current target)
−verbose
Report commands executed by the driver verbosely
If passed, −cc1 argument invokes kefir-cc1 compiler directly, skipping the driver. The argument shall always be passed first to take an effect.
The rest of command-line options are parsed normally:
−c
Skip the link-edit phase of the compilation, save object files
−S
Skip assembling phase of the compilation, save assembly files
−E
Preprocess C-language source files, print results to standard output
−P
Preprocess C-language source files, print results to standard output
−std= standard
Determine language standard. For C23, supported values are: c23, c2x, gnu23, gnu2x, iso9899:2024. For C17 [default], any other value not explicitly listed for C23.
−x −language
Specify processing for the next input files. Supported values: none [default], c, c-header, cpp-output, assembler, assembler-with-cpp.
−preprocess−save
Preprocess C-language source files, save results
−o file
Save results to the output file
−−target specification
Generate code for specified target system (see “TARGET” section below)
−O level
Code optimization level (default is 0). All non-zero levels are equivalent to 1. All non-numerical levels (such as −Os) are also equivalent to 1.
−fpreprocessed
Skip preprocessor directive processing and macro expansion. Preprocessor skips over any directive except for line directive, and acts solely as tokenizer.
−−preprocessor-linemarkers
Include linemarkers into preprocessor output [default: off]. Likemarker content slightly differs from gcc, which might break some builds. Enable with care.
−funsigned-char
Let the type char be unsigned. By default, it is target-specific.
−fsigned-char
Let the type char be signed. By default, it is target-specific.
−fcommon
Place tentative definitions into common section (equivalent to common attribute applied to all variables).
−fvisibility=default|internal|hidden|protected
Set visibility for symbols in the program, unless overriden by particular symbol attribute.
−fno-common
Do not place tentative definitions into common section [default].
−D name[=value]
Define preprocessor macro
−U name
Undefine predefined preprocessor macro
−I directory
Add directory to preprocessor include path
−isystem directory
Add directory to preprocessor system include path
−iquote directory
Add directory to preprocessor include path for quoted includes exclusively (processed before −I ).
−idirafter directory
Add directory to preprocessor system include path (after processing other system include directories)
−−embed-dir= directory
Add directory to preprocessor embed search path
−M
Output a make rule describing the dependencies of source file (including the dependencies from system path)
−MM
Output a make rule describing the dependencies of source file (excluding the dependencies from system path and their transitive includes)
−MD
Output a make rule describing the dependencies of source file (including the dependencies from system path), while also running normal compilation pipeline.
−MMD
Output a make rule describing the dependencies of source file (excluding the dependencies from system path and their transitive includes), while also running normal compilation pipeline.
−MP
Output a phony target for each depenendency of source file
−MT target
Override the default target name of make rule produced by dependency generation
−MF filename
Override the default output file for make rule produced by dependency generation.
−include file
Include file during preprocessing phase
−s
Strip linked executable
−r
Retain relocations in linked executable
−e entry
Override entry point of linked executable
−u symbol
Add undefined symbol to linked executable
−l library
Link library
−L directory
Add directory to linker library search path
−rpath directory
Add directory to runtime library search path
−soname name
Pass −soname option to the linker
−pthread
Define macros and link pthread library
−rdynamic
Pass −−export-dynamic option to the linker
−static
Produce a statically linked executable
−shared
Produce a shared object
−fPIC | −fpic
Produce position-independent code [default]
−fno-pic
Do not produce position-independent code [default]
−pie
Produce position-independent executable (requires −fPIC flag)
−no-pie
Do not produce position-independent executable [default]
−masm=ASSEMBLER
Produce code for the following assembler: [x86_64-gas-intel, x86_64-gas-intel_prefix, x86_64-gas-att (default), x86_64-yasm, intel (alias for x86_64-gas-intel), att (alias for x86_64-gas-att)]. Also affects assembler flags. Note that KEFIR_AS or AS envinronment variable shall be point to the respective assembler executable.
−fomit-frame-pointer
Omit frame pointer in leaf functions that do not need it [default on optimization levels > 0]
−fno-omit-frame-pointer
Always use frame pointer in all functions [default on optimization level 0]
−g | −ggdb
Produce debug information [default: off]
−g[level] | −ggdb[level]
Produce debug information if level is greater than 0 [default: off]
−nostartfiles
Do not link start files
−nodefaultlibs
Do not link default libraries
−nolibc
Do not link libc
−nostdlib
Do not link start files and default libraries
−nostdinc
Do not add standard library to include path
−nortinc
Do not add runtime includes to include path
−−enable-atomics
Enables atomic support. Implies −−Wdeclare-atomic-support option and links appropriate atomic primitives library (libatomic/libcompiler_rt) where necessary.
−−disable-atomics
Disables atomic support. Implies −−Wno-declare-atomic-support option.
−Wp,option
Pass "option" to preprocessing phase as command line option. If option contains commas, it is split into multiple options
−Xpreprocessor option
Pass "option" to preprocessing phase as command line option
−Wc,option
Pass "option" to compiling phase as command line option. If option contains commas, it is split into multiple options
−Wa,option
Pass "option" to assembler phase as command line option. If option contains commas, it is split into multiple options
−Xassembler option
Pass "option" to assembler phase as command line option.
−Wl,option
Pass "option" to linking phase as command line option. If option contains commas, it is split into multiple options
−z −keyword
Pass "−z keyword" to linking phase as command line options.
−Xlinker option
Pass "option" to linking phase as command line option
−Woption
Pass "--option" to compiling phase as command line option
−W option
Pass "option" to compiling phase as command line option
−−restrictive-c
Enable restrictive compiling mode with C extensions disabled
−−permissive-c
Enable permissive compiling mode with C extensions enabled [default]
−−print-tokens
Print tokenized source in JSON format
−−print-ast
Print AST in JSON format
−−print-ir
Print intermediate representation in JSON format
−−print-opt
Print optimization representation in JSON format
−run [file args...]
Run the linked executable with the rest of command line arguments. If no input file was specified, the first argument is treated as input file.
−runarg arg
Pass an argument to the runned process (shall precede −run flag)
−run-stdin file
Redirect runned process stdin from file (shall precede −run flag)
−run-stdout file
Redirect runned process stdout to file (shall precede −run flag)
−run-stderr file
Redirect runned process stderr to file (shall precede −run flag)
−run-stderr2out
Redirect runned process stderr to stdout (shall precede −run flag)
COMPILER OPTIONS
Extra compiler options available via -W switch:
−−c17-standard
Use C17 language language standard.
−−c23-standard
Use C23 language language standard.
−−pp-timestamp timestamp
Override preprocessor timestamp
−−json-errors
Print errors in JSON format to stderr
−−tabular-errors
Print errors in tabular format to stderr
−−target-profile profile
Generate code for specified target (see “TARGET” subsection)
−−source-id identifier
Force use provided source file identifier
−−extension-lib libpath
Load extension library
−−system-include-dir dir
Add directory to include search path and mark it as a system include path (used for dependency output)
−−embed-dir directory
Add directory to preprocessor embed search path
−−debug-info
Include debug information into produced output
−−optimizer-max-inline-depth depth
Maximum depth of function inlining (5 by default).
−−optimizer-max-inlines-per-func inlines
Maximum number of inlined functions (10 by default).
−−enable-lowering
Perform target-specific SSA lowering (mandatory for bit-precise integer support) [default]
−−disable-lowering
Skip target-specific SSA lowering.
−−preprocessor-assembly-mode
Enable assembly preprocessing mode (default for .S files). In this mode, leading ’$’ characters are not treated as identifier part.
−−preprocessor-normal-mode
Disable assembly preprocessing mode (default).
−−feature-[name]
Enable compiler feature (see “FEATURES” subsection)
−−no-feature-[name]
Disable compiler feature (see “FEATURES” subsection)
−−internal-[flag]
Enable compiler internal flag (see “INTERNALS” subsection)
−−no-internal-[flag]
Disable compiler internal flag (see “INTERNALS” subsection)
−−codegen-[option]
Enable option for code generator (see “CODEGEN” subsection)
−−no-codegen-[option]
Disable option for code generator (see “CODEGEN” subsection)
−−optimizer-pipeline spec
Optimizer pipeline specification (see “OPTIMIZER” subsection)
−−precise-bitfield-load-store
Load and store bitfields at byte boundaries [default: on]. Provides extra correctness for structures allocated close to a boundary with unmapped memory pages at the expense of less efficient bitfield handling. Does not change bitfield layout.
−−no-precise-bitfield-load-store
Load and store bitfields at machine word boundaries [default: off]. May cause failures for structures allocated close to boundaries with unmapped memory pages. Does not change bitfield layout.
−−declare-atomic-support
Declare support of atomics (might require explicit linking of software atomic library such as libatomic or libcompiler_rt).
−−no-declare-atomic-support
Declare the absence of atomic support via defining __STDC_NO_ATOMICS__ macro.
−−optimize-stack-frame
Optimize stack frame layout by reusing space for variables for disjoint lifetimes. Might increase compilation time and memory use on very large functions. [default: on].
−−no-optimize-stack-frame
Do not optimize stack frame layout and allocate each variable separately.
−−unsigned-char
Let the type char be unsigned. By default, it is target-specific.
−−signed-char
Let the type char be signed. By default, it is target-specific.
−−codegen-tentative-common
Place tentative definitions into common section (equivalent to common attribute applied to all variables).
−−codegen-tentative-no-common
Do not place tentative definitions into common section [default].
−−codegen-visibility-default
Keep default visibility for all symbols [default].
−−codegen-visibility-hidden
Make all symbols hidden unless an attribute specifies otherwise.
−−codegen-visibility-protected
Make all symbols protected unless an attribute specifies otherwise.
−−codegen-visibility-internal
Make all symbols internal unless an attribute specifies otherwise.
FEATURES
Supported features (to be used with −−Wfeature-[feature-name] and −−Wno-feature-[feature-name] flags):
fail-on-attributes
Fail if __attribute__((...)) is encountered [default: off]
missing-function-return-type
Permit function definitions with missing return type [default: on]
designated-init-colons
Permit "fieldname:" syntax in designated initializers [default: on]
labels-as-values
Permit label-addressing with && operator [default: on]
non-strict-qualifiers
Disable strict qualifier checks for pointers [default: on]
signed-enums
Force all enums to have signed integral type [default: off]
implicit-function-decl
Permit implicit funciton declarations at use-site [default: on]
empty-structs
Permit empty structure/union definitions [default: on]
ext-pointer-arithmetics
Permit pointer arithmetics with function and void pointers [default: on]
missing-braces-subobj
Permit missing braces for subobject initialization with scalar [default: on]
statement-expressions
Enable statement expressions [default: on]
omitted-conditional-operand
Permit omission of the middle ternary expression operand [default: on]
int-to-pointer
Permit any integral type conversion to pointer [default: on]
permissive-pointer-conv
Permit conversions between any pointer types [default: on]
named-macro-vararg
Permit named macro variable arguments [default: on]
include-next
Permit include_next preprocessor directive [default: on]
fail-on-assembly
Disable support of inline assembly [default: off]
va-args-comma-concat
Enable special processing for ", ##__VA_ARGS" case in preprocessor [default: on]
switch-case-ranges
Enable support for ranges in switch cases [default: on]
designator-subscript-ranges
Enable support for ranges in designator subscripts [default: on]
CODEGEN
Supported code geneator options (to be used with −−Wcodegen-[option] and −−Wno-codegen-[option] flags):
emulated-tls
Use emulated TLS [disabled by default, enabled on openbsd platform]
tls-common
Generate common section for thread-local storage if respective attribute is on [enabled for linux and netbsd]
pic
Generate position-independent code
omit-frame-pointer
Omit frame pointer in leaf function that do not need it
valgrind-compatible-x87
Replace x87 opcodes not supported by Valgrind by more expensive alternatives [default: on]
syntax=SYNTAX
Produce assembly output with specified syntax [x86_64-intel_noprefix, x86_64-intel_prefix, x86_64-att (default), x86_64-yasm].
details=DETAILS-SPEC
Augment assembly output with internal code generator details in comments. DETAILS-SPEC can be: vasm (virtual assembly), vasm+regs (virtual assembly and register allocations), devasm (devirtualized assembly).
pipeline=PIPELINE-SPEC
Code generator transformation pipeline specification consists of comma separated names of pipeline passes:
noop
No-operation pass
amd64-drop-virtual
Non-functional virtual instruction elimination for amd64 targets
amd64-peephole
Peephole optimizations for amd64 targets
OPTIMIZER
Optimizer pipeline specification consists of comma separated names of pipeline passes:
noop
No-operation pass
phi-propagate
Wherever possible, substitue phi nodes of SSA representation by actual references
mem2reg
Pull function local variables into registers
op-simplify
General code simplification
constant-fold
Folding constant expressions
gvn
Global value numering pass to eliminate redundant arithmetic and bitwise operations
local-alloc-sink
Moving local variable allocations closer to their actual uses (does not affect effective variable lifetimes).
dead-code-elimination
Eliminating dead code, blocks and phi links.
block-merge
Remove unnecessary jump instructions and merge respective blocks.
dead-alloc
Remove dead local variable allocations.
inline-func
Perform function inlining.
tail-call
Perform tail call optimization.
lowering
Perform target-specific lowering of the SSA representation. Mandatory for bit-precise integer support.
TARGET
Target platforms are specified in format [<backend>-]<platform>[-<variant>] where
backend
opt [default]
platform
<arch>-<os> | host [default]
arch
x86_64 | hostcpu [default]
platform
linux | freebsd | openbsd | netbsd | hostos [default]
variant
none | musl | gnu | system | default
Backend and variant are optional parts of the target specification. Variant "none" avoids any implicit library linkages and include path. On linux, "default" is equivalent to "gnu", on other platforms -- to "system".
ENVIRONMENT
Environment variables that affect kefir operation:
KEFIR_AS | AS
Override the default "as" assembler
KEFIR_LD | LD
Override the default "ld" linker
KEFIR_RTINC
Specify kefir runtime include location. Mandatory for all platform variants except "*-none"
KEFIR_MUSL_INCLUDE
Specify musl include paths (separated by ’;’). Mandatory for "linux-musl" platform variant
KEFIR_MUSL_LIB
Specify musl library paths (separated by ’;’). Mandatory for "linux-musl" platform variant
KEFIR_MUSL_DYNAMIC_LINKER
Specify dynamic linker path. Optional for "linux-musl" platform variant
KEFIR_GNU_INCLUDE
Specify GNU include paths (separated by ’;’). Mandatory for "linux-gnu" platform variant
KEFIR_GNU_LIB
Specify GNU library paths (separated by ’;’). Mandatory for "linux-gnu" platform variant
KEFIR_GNU_DYNAMIC_LINKER
Specify dynamic linker path. Optional for "linux-gnu" platform variant
KEFIR_FREEBSD_INCLUDE
Specify FreeBSD include paths (separated by ’;’). Mandatory for "freebsd-system" platform variant
KEFIR_FREEBSD_LIB
Specify FreeBSD library paths (separated by ’;’). Mandatory for "freebsd-system" platform variant
KEFIR_FREEBSD_DYNAMIC_LINKER
Specify dynamic linker path. Optional for "freebsd-system" platform variant
KEFIR_OPENBSD_INCLUDE
Specify OpenBSD include paths (separated by ’;’). Mandatory for "openbsd-system" platform variant
KEFIR_OPENBSD_LIB
Specify OpenBSD library paths (separated by ’;’). Mandatory for "openbsd-system" platform variant
KEFIR_OPENBSD_DYNAMIC_LINKER
Specify dynamic linker path. Optional for "openbsd-system" platform variant
KEFIR_TMPDIR
Override kefir temporary directory
KEFIR_DRIVER_CLI_QUIET
Assign "yes" (without quotes) to suppress warnings related to unknown command line options.
SOURCE_DATE_EPOCH
Override preprocessor timestamp to specified value. Expects Unix epoch timestamp.
EXIT STATUS
Normally kefir exits with 0 exit code. In case of any errors in any of compilation stages, all further compilation is aborted and non-zero exit code returned.
STANDARDS
kefir implements C17 language standard as specified in its final draft, and C23 language stadard (except _Decimal support) as specified in the first draft of C2Y.
NOTES
The kefir compiler is licensed under the terms of GNU GPLv3 license. Runtime code provided along with kefir is licensed under the terms of BSD-3-Clause license.
kefir is developed and maintained by Jevgenij Protopopov (legally: Jevgenijs Protopopovs)
Please report bugs found in kefir to [email protected]
kefir is available online at https://sr.ht/~jprotopopov/kefir/ with read-only mirrors at https://git.protopopov.lv/kefir and https://codeberg.org/jprotopopov/kefir GNU September 2025 kefir(1)