kefir(1)
π¦ NAME π¦
kefir β C17/C23 language compiler. This is the kefir(1) page from the General Commands Manual, bestie, and we're getting through it together. π
π SYNOPSIS π
kefir [options] files... [-run [args...]]
π DESCRIPTION π
Okay so kefir command-line options follow the c99(1) compiler interface, and they extend it with some of the supported gcc(1) flags plus flags for special kefir features. Unknown command-line flags are ignored with a warning printed for each such flag passed to the compiler β yes, every single one, no cap. π
The kefir compiler driver has multiple operation modes. Command-line flags are parsed in left-to-right order, and later flags override earlier ones. Some operation modes, once selected, prevent further parsing and immediately invoke the selected mode β refer to the β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 the βENVIRONMENTβ section below).--environment-headerβ Print compiler environment header file (based on the βENVIRONMENTβ section and current target).-verboseβ Report commands executed by the driver verbosely.
If passed, the -cc1 argument invokes the kefir-cc1 compiler directly, skipping the driver. The argument shall always be passed first to take an effect. π«Ά
The rest of the command-line options are parsed normally:
-cβ Skip the link-edit phase of the compilation, save object files.-Sβ Skip the 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.-ofile β Save results to the output file.--targetspecification β Generate code for the specified target system (see the βTARGETβ section below).-Olevel β Code optimization level (default is0). All non-zero levels are equivalent to1. All non-numerical levels (such as-Os) are also equivalent to1.-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 fromgcc, which might break some builds. Enable with care.-funsigned-charβ Let the typecharbe unsigned. By default, it is target-specific.-fsigned-charβ Let the typecharbe signed. By default, it is target-specific.-fcommonβ Place tentative definitions into common section (equivalent tocommonattribute applied to all variables).-fvisibility=default|internal|hidden|protectedβ Set visibility for symbols in the program, unless overridden by a particular symbol attribute.-fno-commonβ Do not place tentative definitions into common section [default].-Dname[=value] β Define preprocessor macro.-Uname β Undefine predefined preprocessor macro.-Idirectory β Add directory to preprocessor include path.-isystemdirectory β Add directory to preprocessor system include path.-iquotedirectory β Add directory to preprocessor include path for quoted includes exclusively (processed before-I).-idirafterdirectory β 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 dependency of source file.-MTtarget β Override the default target name of make rule produced by dependency generation.-MFfilename β Override the default output file for make rule produced by dependency generation.-includefile β Include file during preprocessing phase.-sβ Strip linked executable.-rβ Retain relocations in linked executable.-eentry β Override entry point of linked executable.-usymbol β Add undefined symbol to linked executable.-llibrary β Link library.-Ldirectory β Add directory to linker library search path.-rpathdirectory β Add directory to runtime library search path.-sonamename β Pass-sonameoption to the linker.-pthreadβ Define macros and link pthread library.-rdynamicβ Pass--export-dynamicoption 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-fPICflag).-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 forx86_64-gas-intel),att(alias forx86_64-gas-att)]. Also affects assembler flags. Note thatKEFIR_ASorASenvironment variable shall 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 than0[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-supportoption and links appropriate atomic primitives library (libatomic/libcompiler_rt) where necessary.--disable-atomicsβ Disables atomic support. Implies--Wno-declare-atomic-supportoption.-Wp,optionβ Pass"option"to preprocessing phase as command line option. If option contains commas, it is split into multiple options.-Xpreprocessoroption β 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.-Xassembleroption β 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.-Xlinkeroption β Pass"option"to linking phase as command line option.-Woptionβ Pass"--option"to compiling phase as command line option.-Woption β 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.-runargarg β Pass an argument to the runned process (shall precede-runflag).-run-stdinfile β Redirect runned process stdin from file (shall precede-runflag).-run-stdoutfile β Redirect runned process stdout to file (shall precede-runflag).-run-stderrfile β Redirect runned process stderr to file (shall precede-runflag).-run-stderr2outβ Redirect runned process stderr to stdout (shall precede-runflag).
π§ COMPILER OPTIONS π§
Extra compiler options available via the -W switch:
--c17-standardβ Use C17 language standard.--c23-standardβ Use C23 language standard.--pp-timestamptimestamp β Override preprocessor timestamp.--json-errorsβ Print errors in JSON format to stderr.--tabular-errorsβ Print errors in tabular format to stderr.--target-profileprofile β Generate code for specified target (see the βTARGETβ subsection).--source-ididentifier β Force use provided source file identifier.--extension-liblibpath β loads up an extension library from libpath, bestie π--system-include-dirdir β drops dir onto the include search path and flags it as a system include path (which matters for dependency output, iykyk)--embed-dirdirectory β adds directory to the preprocessor's embed search path π--debug-infoβ bakes debug information right into the produced output--optimizer-max-inline-depthdepth β the max depth for function inlining (5by default, no cap on the vibes)--optimizer-max-inlines-per-funcinlines β the max number of inlined functions per function (10by default)--enable-loweringβ does the target-specific SSA lowering. This one is mandatory for bit-precise integer support, so likeβ¦ don't skip it [default] β¨--disable-loweringβ skips the target-specific SSA lowering entirely π--preprocessor-assembly-modeβ turns on assembly preprocessing mode (that's the default for.Sfiles, lowercase-capital-S girlies). In this mode, leading'$'characters are not treated as part of an identifier--preprocessor-normal-modeβ turns assembly preprocessing mode back off (the default) π¦--feature-[name]β enables a compiler feature (go peek at the βFEATURESβ subsection π)--no-feature-[name]β disables a compiler feature (again: βFEATURESβ subsection)--internal-[flag]β enables a compiler internal flag (see βINTERNALSβ)--no-internal-[flag]β disables a compiler internal flag (see βINTERNALSβ)--codegen-[option]β enables an option for the code generator (see βCODEGENβ)--no-codegen-[option]β disables an option for the code generator (see βCODEGENβ)--optimizer-pipelinespec β your optimizer pipeline specification (see βOPTIMIZERβ)--precise-bitfield-load-storeβ loads and stores bitfields at byte boundaries [default: on]. It gives you extra correctness for structures allocated close to a boundary with unmapped memory pages, at the cost of less efficient bitfield handling. Does not change bitfield layout, so breathe π«Ά--no-precise-bitfield-load-storeβ loads and stores bitfields at machine word boundaries [default: off]. Heads up: this may cause failures for structures allocated close to boundaries with unmapped memory pages. Still doesn't change bitfield layout though β--declare-atomic-supportβ declares that atomics are supported (might require you to explicitly link a software atomic library likelibatomicorlibcompiler_rt, fr fr)--no-declare-atomic-supportβ declares the absence of atomic support by defining the__STDC_NO_ATOMICS__macro π--optimize-stack-frameβ optimizes the stack frame layout by reusing space for variables with disjoint lifetimes. Might increase compilation time and memory use on very large functions [default: on]--no-optimize-stack-frameβ no stack frame layout optimization, every variable gets its own separate allocation, no sharing, no slay πΈ--unsigned-charβ makes the typecharunsigned. By default it's target-specific, so don't @ me--signed-charβ makes the typecharsigned. By default it's target-specific π--codegen-tentative-commonβ places tentative definitions into the common section (equivalent to thecommonattribute applied to all variables)--codegen-tentative-no-commonβ does not place tentative definitions into the common section [default]--codegen-visibility-defaultβ keeps default visibility for all symbols [default] β¨--codegen-visibility-hiddenβ makes all symbols hidden unless an attribute says otherwise--codegen-visibility-protectedβ makes all symbols protected unless an attribute says otherwise--codegen-visibility-internalβ makes all symbols internal unless an attribute says otherwise
β¨ FEATURES β¨
These are the supported features, and you use them with the --Wfeature-[feature-name] and --Wno-feature-[feature-name] flags. Okay so here's the whole menu π
fail-on-attributesβ fails if__attribute__((...))shows up [default: off]missing-function-return-typeβ permits function definitions that are missing their return type [default: on]designated-init-colonsβ permits the"fieldname:"syntax in designated initializers [default: on]labels-as-valuesβ permits label-addressing with the&&operator [default: on]non-strict-qualifiersβ disables strict qualifier checks for pointers [default: on]signed-enumsβ forces all enums to have a signed integral type [default: off]implicit-function-declβ permits implicit function declarations at the use-site [default: on]empty-structsβ permits empty structure/union definitions [default: on]ext-pointer-arithmeticsβ permits pointer arithmetics with function and void pointers [default: on]missing-braces-subobjβ permits missing braces for subobject initialization with scalar [default: on]statement-expressionsβ enables statement expressions [default: on]omitted-conditional-operandβ permits omission of the middle ternary expression operand [default: on]int-to-pointerβ permits any integral type conversion to pointer [default: on]permissive-pointer-convβ permits conversions between any pointer types [default: on]named-macro-varargβ permits named macro variable arguments [default: on]include-nextβ permits theinclude_nextpreprocessor directive [default: on]fail-on-assemblyβ disables support of inline assembly [default: off]va-args-comma-concatβ enables special processing for the", ##__VA_ARGS"case in the preprocessor [default: on]switch-case-rangesβ enables support for ranges in switch cases [default: on]designator-subscript-rangesβ enables support for ranges in designator subscripts [default: on]
π CODEGEN π
Supported code generator options, and you use these with the --Wcodegen-[option] and --Wno-codegen-[option] flags π
emulated-tlsβ use emulated TLS [disabled by default, enabled on theopenbsdplatform]tls-commonβ generate a common section for thread-local storage if the respective attribute is on [enabled forlinuxandnetbsd]picβ generate position-independent code β¨omit-frame-pointerβ omit the frame pointer in leaf functions that don't need itvalgrind-compatible-x87β replaces x87 opcodes that Valgrind doesn't support with more expensive alternatives [default: on]syntax=SYNTAXβ produces assembly output with the specified syntax. Your options arex86_64-intel_noprefix,x86_64-intel_prefix,x86_64-att(that's the default), andx86_64-yasm.details=DETAILS-SPECβ augments assembly output with internal code generator details in comments.DETAILS-SPECcan be:vasm(virtual assembly),vasm+regs(virtual assembly and register allocations), ordevasm(devirtualized assembly).pipeline=PIPELINE-SPECβ the code generator transformation pipeline spec, which is a comma separated list of pipeline pass names:noopβ no-operation pass πamd64-drop-virtualβ non-functional virtual instruction elimination for amd64 targetsamd64-peepholeβ peephole optimizations for amd64 targets
π₯ OPTIMIZER π₯
The optimizer pipeline specification is a comma separated list of pipeline pass names. Here's the roster π
noopβ no-operation pass. She does nothing and she does it flawlessly πphi-propagateβ wherever possible, substitutes phi nodes of the SSA representation with actual referencesmem2regβ pulls function local variables into registersop-simplifyβ general code simplificationconstant-foldβ folding constant expressionsgvnβ global value numbering pass, there to eliminate redundant arithmetic and bitwise operationslocal-alloc-sinkβ moves local variable allocations closer to their actual uses (and does not affect effective variable lifetimes, noted)dead-code-eliminationβ eliminates dead code, blocks and phi linksblock-mergeβ removes unnecessary jump instructions and merges the respective blocksdead-allocβ removes dead local variable allocationsinline-funcβ performs function inliningtail-callβ performs tail call optimizationloweringβ performs target-specific lowering of the SSA representation. Mandatory for bit-precise integer support, so this one's kind of a big deal π€
π¦ TARGET π¦
Target platforms get specified in the 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 the optional parts of the target specification, bestie β they can dip if they want π«
Variant "none" avoids any implicit library linkages and include path. On linux, "default" is equivalent to "gnu", and on other platforms it's equivalent to "system". That's the whole tea β
β¨ ENVIRONMENT β¨
okay bestie, these are the env vars that change how kefir behaves. read carefully, some of them are literally mandatory for certain platforms π
KEFIR_AS|ASβ overrides the default"as"assembler π οΈKEFIR_LD|LDβ overrides the default"ld"linker πKEFIR_RTINCβ tells kefir where the runtime include location lives. this one is mandatory for every platform variant except"*-none"π«ΆKEFIR_MUSL_INCLUDEβ musl include paths, separated by';'. mandatory for the"linux-musl"platform variant πΈKEFIR_MUSL_LIBβ musl library paths, separated by';'. mandatory for the"linux-musl"platform variant πΈKEFIR_MUSL_DYNAMIC_LINKERβ dynamic linker path. optional for the"linux-musl"platform variant β¨KEFIR_GNU_INCLUDEβ GNU include paths, separated by';'. mandatory for the"linux-gnu"platform variant πKEFIR_GNU_LIBβ GNU library paths, separated by';'. mandatory for the"linux-gnu"platform variant πKEFIR_GNU_DYNAMIC_LINKERβ dynamic linker path. optional for the"linux-gnu"platform variant β¨KEFIR_FREEBSD_INCLUDEβ FreeBSD include paths, separated by';'. mandatory for the"freebsd-system"platform variant π¦KEFIR_FREEBSD_LIBβ FreeBSD library paths, separated by';'. mandatory for the"freebsd-system"platform variant π¦KEFIR_FREEBSD_DYNAMIC_LINKERβ dynamic linker path. optional for the"freebsd-system"platform variant β¨KEFIR_OPENBSD_INCLUDEβ OpenBSD include paths, separated by';'. mandatory for the"openbsd-system"platform variant π‘KEFIR_OPENBSD_LIBβ OpenBSD library paths, separated by';'. mandatory for the"openbsd-system"platform variant π‘KEFIR_OPENBSD_DYNAMIC_LINKERβ dynamic linker path. optional for the"openbsd-system"platform variant β¨KEFIR_TMPDIRβ overrides kefir's temporary directory πKEFIR_DRIVER_CLI_QUIETβ set it to"yes"(no quotes, bestie) and it suppresses warnings about unknown command line options π€«SOURCE_DATE_EPOCHβ overrides the preprocessor timestamp with whatever value you give it. it wants a Unix epoch timestamp β°
fyi the ; separators are literal, don't go putting spaces or commas in there, okay? iykyk π
π EXIT STATUS π
normally kefir exits with a 0 exit code, slay. but if literally any error shows up in any of the compilation stages, all further compilation gets aborted and you get a non-zero exit code back. so if you see a non-zero, something went wrong, no cap π
π STANDARDS π
kefir implements the C17 language standard as specified in its final draft, plus the C23 language standard (except _Decimal support) as specified in the first draft of C2Y. the range, the icon behavior π«Ά
π¦ NOTES π¦
the kefir compiler is licensed under the terms of the GNU GPLv3 license. the runtime code provided along with kefir is licensed under the terms of the BSD-3-Clause license π
kefir is developed and maintained by Jevgenij Protopopov (legally: Jevgenijs Protopopovs) π
please report bugs found in kefir to jevgenij@protopopov.lv β like, actually do it, don't just complain in the group chat π
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 π
and that's the whole page bestie, you're officially caught up π this one's the Debian build from September 2025, filed under kefir(1) β go compile something iconic, periodt β¨π
π¦ where this page comes from
- alpine 3.24: kefir-doc 0.5.0-r1 Β· GPL-3.0-only AND BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms