CLANG(1)
๐ CLANG(1) โ the Clang compiler, but make it a group chat
okay bestie, sit down, hydrate, because clang(1) is the moment. this is the manual page for the Clang C, C++, and Objective-C compiler, and yes we are going through all of it. no skimming. no cap. ๐
โจ NAME โจ
clang โ the Clang C, C++, and Objective-C compiler ๐
๐ธ SYNOPSIS ๐ธ
clang [options] filename ...
๐ฆ DESCRIPTION ๐ฆ
so like, clang is a C, C++, and Objective-C compiler, and she does everything: preprocessing, parsing, optimization, code generation, assembly, and linking. all of it. she's booked and busy. ๐
depending on which high-level mode setting you pass, Clang will stop before doing a full link. and listen โ even though Clang is super integrated, you gotta understand the stages of compilation to understand how to invoke her. it's giving "know your queen". these are the stages:
- Driver โ the
clangexecutable is actually just a lil driver that controls the overall execution of the other tools, like the compiler, assembler and linker. typically you don't need to interact with the driver directly, but you transparently use it to run all those other tools. she's the manager fr. ๐ - Preprocessing โ this stage handles tokenization of the input source file, macro expansion,
#includeexpansion and handling of other preprocessor directives. the output of this stage is typically called a".i"(for C),".ii"(for C++),".mi"(for Objective-C), or".mii"(for Objective-C++) file. - Parsing and Semantic Analysis โ this stage parses the input file, translating preprocessor tokens into a parse tree. once it's in parse-tree form, it applies semantic analysis to compute types for expressions as well as to determine whether the code is well formed. this stage is responsible for generating most of the compiler warnings as well as parse errors. the output of this stage is an "Abstract Syntax Tree" (AST). ๐ณ
- Code Generation and Optimization โ this stage translates an AST into low-level intermediate code (known as "LLVM IR") and ultimately to machine code. this phase is responsible for optimizing the generated code and handling target-specific code generation. the output of this stage is typically called a
".s"file or "assembly" file.
Clang also supports the use of an integrated assembler, in which the code generator produces object files directly. this avoids the overhead of generating the ".s" file and of calling the target assembler. efficiency queen. โจ
- Assembler โ this stage runs the target assembler to translate the output of the compiler into a target object file. the output of this stage is typically called a
".o"file or "object" file. - Linker โ this stage runs the target linker to merge multiple object files into an executable or dynamic library. the output of this stage is typically called an
"a.out",".dylib"or".so"file.
๐ Clang Static Analyzer ๐
the Clang Static Analyzer is a tool that scans source code to try to find bugs through code analysis. this tool uses many parts of Clang and is built into the same driver. please see https://clang-analyzer.llvm.org for more details on how to use the static analyzer. she's a detective, your honor. ๐ต๏ธโโ๏ธ
๐ OPTIONS ๐
๐ Stage Selection Options ๐
-Eโ run the preprocessor stage.-fsyntax-onlyโ run the preprocessor, parser and semantic analysis stages.-Sโ run the previous stages as well as LLVM generation and optimization stages and target-specific code generation, producing an assembly file.-cโ run all of the above, plus the assembler, generating a target".o"object file.- no stage selection option โ if you don't specify any stage selection option, all the stages above get run, and then the linker is run to combine the results into an executable or shared library. full send. ๐ฅ
๐ Language Selection and Mode Options ๐
-x <language>โ treat subsequent input files as having type language.-std=<standard>โ specify the language standard to compile for.
Supported values for the C language are:
c89,c90,iso9899:1990โ ISO C 1990iso9899:199409โ ISO C 1990 with amendment 1gnu89,gnu90โ ISO C 1990 with GNU extensionsc99,iso9899:1999โ ISO C 1999gnu99โ ISO C 1999 with GNU extensionsc11,iso9899:2011โ ISO C 2011gnu11โ ISO C 2011 with GNU extensionsc17,iso9899:2017โ ISO C 2017gnu17โ ISO C 2017 with GNU extensions
the default C language standard is gnu17, except on PS4, where it is gnu99. (PS4 girlies stay winning, i guess ๐ฎ)
Supported values for the C++ language are:
c++98,c++03โ ISO C++ 1998 with amendmentsgnu++98,gnu++03โ ISO C++ 1998 with amendments and GNU extensionsc++11โ ISO C++ 2011 with amendmentsgnu++11โ ISO C++ 2011 with amendments and GNU extensionsc++14โ ISO C++ 2014 with amendmentsgnu++14โ ISO C++ 2014 with amendments and GNU extensionsc++17โ ISO C++ 2017 with amendmentsgnu++17โ ISO C++ 2017 with amendments and GNU extensionsc++20โ ISO C++ 2020 with amendmentsgnu++20โ ISO C++ 2020 with amendments and GNU extensionsc++23โ ISO C++ 2023 with amendmentsgnu++23โ ISO C++ 2023 with amendments and GNU extensionsc++2cโ Working draft for C++2cgnu++2cโ Working draft for C++2c with GNU extensions
the default C++ language standard is gnu++17.
Supported values for the OpenCL language are:
cl1.0โ OpenCL 1.0cl1.1โ OpenCL 1.1cl1.2โ OpenCL 1.2cl2.0โ OpenCL 2.0
the default OpenCL language standard is cl1.0.
Supported values for the CUDA language are:
cudaโ NVIDIA CUDA(tm)
-stdlib=<library>โ specify the C++ standard library to use; supported options arelibstdc++andlibc++. if not specified, the platform default will be used.-rtlib=<library>โ specify the compiler runtime library to use; supported options arelibgccandcompiler-rt. if not specified, the platform default will be used.-ansiโ same as-std=c89.-ObjC,-ObjC++โ treat source input files as Objective-C and Object-C++ inputs respectively.-trigraphsโ enable trigraphs. ๐-ffreestandingโ indicate that the file should be compiled for a freestanding, not a hosted, environment. note that it is assumed that a freestanding environment will additionally providememcpy,memmove,memsetandmemcmpimplementations, as these are needed for efficient codegen for many programs. so like, you gotta bring your own snacks. ๐-fno-builtinโ disable special handling and optimizations of well-known library functions, likestrlen()andmalloc().-fno-builtin-<function>โ disable special handling and optimizations for the specific library function. for example,-fno-builtin-strlenremoves any special handling for thestrlen()library function.-fno-builtin-std-<function>โ disable special handling and optimizations for the specific C++ standard library function in namespacestd. for example,-fno-builtin-std-move_if_noexceptremoves any special handling for thestd::move_if_noexcept()library function.
for C standard library functions that the C++ standard library also provides in namespace std, use -fno-builtin-<function> instead. (iykyk ๐
)
-fmath-errnoโ indicate that math functions should be treated as updatingerrno.-fpascal-stringsโ enable support for Pascal-style strings with"\pfoo".-fms-extensionsโ enable support for Microsoft extensions.-fmsc-version=โ set_MSC_VER. when on Windows, this defaults to either the same value as the currently installed version ofcl.exe, or1933. not set otherwise.-fborland-extensionsโ enable support for Borland extensions.-fwritable-stringsโ make all string literals default to writable. this disables uniquing of strings and other optimizations.-flax-vector-conversions,-flax-vector-conversions=<kind>,-fno-lax-vector-conversionsโ allow loose type checking rules for implicit vector conversions. possible values of<kind>:none: allow no implicit conversions between vectorsinteger: allow implicit bitcasts between integer vectors of the same overall bit-widthall: allow implicit bitcasts between any vectors of the same overall bit-width
<kind> defaults to integer if unspecified.
-fblocksโ enable the "Blocks" language feature.-fobjc-abi-version=versionโ select the Objective-C ABI version to use. available versions are1(legacy "fragile" ABI),2(non-fragile ABI 1), and3(non-fragile ABI 2).-fobjc-nonfragile-abi-version=<version>โ select the Objective-C non-fragile ABI version to use by default. this will only be used as the Objective-C ABI when the non-fragile ABI is enabled (either via-fobjc-nonfragile-abi, or because it is the platform default).-fobjc-nonfragile-abi,-fno-objc-nonfragile-abiโ enable use of the Objective-C non-fragile ABI. on platforms for which this is the default ABI, it can be disabled with-fno-objc-nonfragile-abi.
โญ Target Selection Options โญ
Clang fully supports cross compilation as an inherent part of its design. depending on how your version of Clang is configured, it may have support for a number of cross compilers, or may only support a native target. she's versatile like that. ๐ง
-arch <architecture>โ specify the architecture to build for (Mac OS X specific).-target <architecture>โ specify the architecture to build for (all platforms).-mmacos-version-min=<version>โ when building for macOS, specify the minimum version supported by your application.-miphoneos-version-minโ when building for iPhone OS, specify the minimum version supported by your application.--print-supported-cpusโ drops a whole list of supported processors for whatever target you're repping (say it with--target=<architecture>or-arch <architecture>). No target? Then it just uses your system default target. easy.-mcpu=?,-mtune=?โ literally just an alias for--print-supported-cpus. same energy.-mcpu=help,-mtune=helpโ also an alias for--print-supported-cpus. yes bestie, all roads lead there.-march=<cpu>โ tells Clang to generate code for a specific processor family member and later. so if you say-march=i486, the compiler is allowed to spit out instructions that are valid on i486 and everything after it โ but those instructions might not exist on earlier processors. iykyk.--print-enabled-extensionsโ prints the list of extensions that are turned on for the target you built out of the--target,-march, and-mcpuvalues combined. ngl, rn this one only works on AArch64 and RISC-V. on RISC-V it also prints the ISA string of the enabled extensions. slay.--print-supported-extensionsโ prints the list of all the extensions supported for every CPU target of an architecture (you specify it with--target=<architecture>or-arch <architecture>). no target given? system default target steps in. again, only supported on AArch64 and RISC-V for now.
โจ Code Generation Options โจ
-O0,-O1,-O2,-O3,-Ofast,-Os,-Oz,-Og,-O,-O4โ pick your optimization level, bestie. here's the tea:-O0means "no optimization": this level compiles the fastest and generates the most debuggable code.-O1is somewhere between-O0and-O2.-O2is a moderate level of optimization which enables most optimizations.-O3is like-O2, except that it enables optimizations that take longer to perform or that may generate larger code (in an attempt to make the program run faster).-Ofastenables all the optimizations from-O3along with other aggressive optimizations that may violate strict compliance with language standards. this is deprecated in Clang 19 and a warning gets emitted saying that-O3in combination with-ffast-mathshould be used instead if the request for non-standard math behavior is intended. there's no timeline yet for removal; the aim is to discourage use of-Ofastbecause of the surprising behavior of an optimization flag changing the observable behavior of correct code. ๐ so like, be careful.-Osis like-O2with extra optimizations to reduce code size.-Ozis like-Os(and thus-O2), but reduces code size further.-Ogis like-O1. in future versions, this option might disable different optimizations in order to improve debuggability.-Ois equivalent to-O1.-O4and higher: currently equivalent to-O3.
-g,-gline-tables-only,-gmodulesโ these control debug information output. heads up: Clang debug information works best at-O0. when more than one option starting with-gis specified, the last one wins (last one standing, periodt):-ggenerates debug information.-gline-tables-onlygenerates only line table debug information. this allows for symbolicated backtraces with inlining information, but does not include any information about variables, their locations or types.-gmodulesgenerates debug information that contains external references to types defined in Clang modules or precompiled headers instead of emitting redundant debug type information into every object file. this option transparently switches the Clang module format to object file containers that hold the Clang module together with the debug information. when compiling a program that uses Clang modules or precompiled headers, this option produces complete debug information with faster compile times and much smaller object files.
don't use this option when building static libraries for distribution to other machines, because the debug info will contain references to the module cache on the machine the object files in the library were built on. not the vibe for shipping.
-fstandalone-debug-fno-standalone-debugโ Clang supports a number of optimizations to reduce the size of debug information in the binary. they work based on the assumption that the debug type information can be spread out over multiple compilation units. for instance, Clang will not emit type definitions for types that are not needed by a module and could be replaced with a forward declaration. further, Clang will only emit type info for a dynamic C++ class in the module that contains the vtable for the class.
the -fstandalone-debug option turns off these optimizations. this is useful when working with 3rd-party libraries that don't come with debug information. this is the default on Darwin. note that Clang will never emit type information for types that are not referenced at all by the program. ok that's the rule, no exceptions.
-feliminate-unused-debug-typesโ by default, Clang does not emit type information for types that are defined but not used in a program. to retain the debug info for these unused types, you can use the negation-fno-eliminate-unused-debug-types. flip it and reverse it. ๐ฆ-fexceptionsโ allow exceptions to be thrown through Clang compiled stack frames (on many targets, this will enable unwind information for functions that might have an exception thrown through them). for most targets, this is enabled by default for C++. iconic.-ftrapvโ generate code to catch integer overflow errors. signed integer overflow is undefined in C. with this flag, extra code is generated to detect this and abort when it happens. it's giving safety net.-fvisibilityโ this flag sets the default visibility level.-fcommon,-fno-commonโ this flag specifies that variables without initializers get common linkage. it can be disabled with-fno-common.-ftls-model=<model>โ set the default thread-local storage (TLS) model to use for thread-local variables. valid values are:"global-dynamic","local-dynamic","initial-exec"and"local-exec". the default is"global-dynamic". the default model can be overridden with thetls_modelattribute. the compiler will try to choose a more efficient model if possible. main character energy: it wants the best for you.-flto,-flto=full,-flto=thin,-emit-llvmโ generate output files in LLVM formats, suitable for link time optimization. when used with-Sthis generates LLVM intermediate language assembly files, otherwise this generates LLVM bitcode format object files (which may be passed to the linker depending on the stage selection options).
the default for -flto is "full", in which the LLVM bitcode is suitable for monolithic Link Time Optimization (LTO), where the linker merges all such modules into a single combined module for optimization. with "thin", ThinLTO compilation is invoked instead.
NOTE: on Darwin, when using-fltoalong with-gand compiling and linking in separate steps, you also need to pass-Wl,-object_path_lto,<lto-filename>.oat the linking step to instruct theld64linker not to delete the temporary object file generated during Link Time Optimization (this flag is automatically passed to the linker by Clang if compilation and linking are done in a single step). this allows debugging the executable as well as generating the.dSYMbundle usingdsymutil(1). don't skip this step bestie, fr fr.
๐ Driver Options ๐
-###โ print (but do not run) the commands to run for this compilation. peek but don't touch.--helpโ display available options.-Qunused-argumentsโ do not emit any warnings for unused driver arguments. no nagging, we love that.-Wa,<args>โ pass the comma separated arguments in args to the assembler.-Wl,<args>โ pass the comma separated arguments in args to the linker.-Wp,<args>โ pass the comma separated arguments in args to the preprocessor.-Xanalyzer <arg>โ pass arg to the static analyzer.-Xassembler <arg>โ pass arg to the assembler.-Xlinker <arg>โ pass arg to the linker.-Xpreprocessor <arg>โ pass arg to the preprocessor.-o <file>โ write output to file.-print-file-name=<file>โ print the full library path of file.-print-libgcc-file-nameโ print the library path for the currently used compiler runtime library ("libgcc.a"or"libclang_rt.builtins.*.a").-print-prog-name=<name>โ print the full program path of name.-print-search-dirsโ print the paths used for finding libraries and programs.-save-tempsโ save intermediate compilation results.-save-stats,-save-stats=cwd,-save-stats=objโ save internal code generation (LLVM) statistics to a file in the current directory (-save-stats/"-save-stats=cwd") or the directory of the output file ("-save-state=obj").
you can also use environment variables to control the statistics reporting. setting CC_PRINT_INTERNAL_STAT to 1 enables the feature, the report goes to stdout in JSON format.
setting CC_PRINT_INTERNAL_STAT_FILE to a file path makes it report statistics to the given file in the JSON format.
note that-save-statstake precedence overCC_PRINT_INTERNAL_STATandCC_PRINT_INTERNAL_STAT_FILE. it's the boss here.
-integrated-as,-no-integrated-asโ used to enable and disable, respectively, the use of the integrated assembler. whether the integrated assembler is on by default is target dependent.-timeโ time individual commands. โฑ๏ธ-ftime-reportโ print timing summary of each stage of compilation.-vโ show commands to run and use verbose output.
๐ Diagnostics Options ๐
-fshow-column,-fshow-source-location,-fcaret-diagnostics,-fdiagnostics-fixit-info,-fdiagnostics-parseable-fixits,-fdiagnostics-print-source-range-info,-fprint-source-range-info,-fdiagnostics-show-option,-fmessage-lengthโ these options control how Clang prints out information about diagnostics (errors and warnings). please see the Clang User's Manual for more information. โจ
๐ธ Preprocessor Options ๐ธ
-D<macroname>=<value>โ bestie this sneaks an implicit#defineinto the predefines buffer, and that buffer gets read before your source file even gets preprocessed. so the macro is just... there. iconic.-U<macroname>โ same vibe, opposite direction: adds an implicit#undefinto the predefines buffer, read before the source file is preprocessed. undefining before you even defined anything? we love a preemptive strike ๐-include <filename>โ drops an implicit#includeinto the predefines buffer, and yeah, that buffer is read before your source file gets preprocessed. free include, no code changes.-I<directory>โ adds the directory you name to the search path for include files. your headers, your rules ๐-F<directory>โ adds the directory you name to the search path for framework include files.-nostdincโ do not search the standard system directories, and also do not search the compiler builtin directories, for include files. full isolation era.-nostdlibincโ do not search the standard system directories for include files, but do still search compiler builtin include directories. bestie is picking and choosing, honestly valid.-nobuiltinincโ do not search clang's builtin directory for include files.-fkeep-system-includesโ okay so this one is only usable with-E. Instead of copying the preprocessed content of "system" headers into the output, it preserves the#includedirective instead. The way this can greatly reduce the volume of text that-Eproduces ๐ญ which is super helpful when you're trying to produce a "small" reproduceable test case.
But listen โ this option does not guarantee reproduceability. If the including source defines preprocessor symbols that influence the behavior of system headers (for example,_XOPEN_SOURCE), then-Ewill remove that definition, and that can change the semantics of the included header. Also, using a different version of the system headers (especially a different version of the STL) may result in different behavior. Always verify the preprocessed file by compiling it separately. no skipping the vibe check on this one, fr fr.
๐ ENVIRONMENT ๐
TMPDIR,TEMP,TMPโ these get checked, in order, for the location to write temporary files used during the compilation process. first one wins, so if you're being shady about temp files, they will find out ๐CPATHโ if this environment variable is present, it's treated as a delimited list of paths to be added to the default system include path list. The delimiter is the platform dependent delimiter, as used in thePATHenvironment variable.
Empty components in the environment variable are ignored. (shoutout to empty components, they simply do not exist here ๐)
C_INCLUDE_PATH,OBJC_INCLUDE_PATH,CPLUS_INCLUDE_PATH,OBJCPLUS_INCLUDE_PATHโ these environment variables specify additional paths, exactly as forCPATH, except they're only used when processing the appropriate language. so C paths for C, ObjC paths for ObjC, etc. each one knows its assignment โจMACOSX_DEPLOYMENT_TARGETโ if-mmacos-version-minis unspecified, the default deployment target is read from this environment variable. Heads up: this option only affects Darwin targets. Apple girlies only ๐
๐ BUGS ๐
To report bugs, please visit <https://github.com/llvm/llvm-project/issues/>.
Most bug reports should include preprocessed source files (use the -E option) and the full output of the compiler, along with information to reproduce. like bestie, give us the receipts or we literally cannot help you ๐
๐ซถ SEE ALSO ๐ซถ
๐ AUTHOR ๐
Maintained by the Clang / LLVM Team (<http://clang.llvm.org>)
๐ COPYRIGHT ๐
2007-2026, The Clang Team
and that's the whole page, bestie ๐ that version is from Mar 11, 2026 and it's page 19 of CLANG(1) โ slay, go compile something iconic โจ๐
๐ฆ where this page comes from
- fedora 43: clang19 19.1.7-16.fc43 ยท Apache-2.0 WITH LLVM-exception OR NCSA
- fedora 43: clang19 19.1.7-16.fc43 ยท Apache-2.0 WITH LLVM-exception OR NCSA
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms