blob: 3a2c2a4c48a88d7e5a0574c6e70b276508fb0ed8 [file] [log] [blame]
Daniel Dunbardbec0332009-04-29 01:00:32 +00001=pod
2
3=head1 NAME
4
Chris Lattnerb5f6e802009-05-06 02:47:51 +00005clang - the Clang C and Objective-C compiler
Daniel Dunbardbec0332009-04-29 01:00:32 +00006
7=head1 SYNOPSIS
8
Chris Lattnerb5f6e802009-05-06 02:47:51 +00009B<clang> [B<-c>|B<-S>|B<-E>] B<-std=>I<standard> B<-g>
10 [B<-O0>|B<-O1>|B<-O2>|B<-Os>|B<-O3>|B<-O4>]
11 B<-W>I<warnings...> B<-pedantic>
12 B<-I>I<dir...> B<-L>I<dir...>
13 B<-D>I<macro[=defn]>
14 B<-f>I<feature-option...>
15 B<-m>I<machine-option...>
16 B<-o> I<output-file>
17 I<input-filenames>
Daniel Dunbardbec0332009-04-29 01:00:32 +000018
19=head1 DESCRIPTION
20
Chris Lattnerb5f6e802009-05-06 02:47:51 +000021B<clang> is a C and Objective-C compiler which encompasses preprocessing,
22parsing, optimization, code generation, assembly, and linking. Depending on
23which high-level mode setting is passed, Clang will stop before doing a full
24link. While Clang is highly integrated, it is important to understand the
25stages of compilation, to understand how to invoke it. These stages are:
Daniel Dunbardbec0332009-04-29 01:00:32 +000026
27=over
28
Chris Lattnerb5f6e802009-05-06 02:47:51 +000029=item B<Driver>
Daniel Dunbardbec0332009-04-29 01:00:32 +000030
Chris Lattnerb5f6e802009-05-06 02:47:51 +000031The B<clang> executable is actually a small driver which controls the overall
32execution of other tools such as the compiler, assembler and linker. Typically
33you do not need to interact with the driver, but you transparently use it to run
34the other tools.
Daniel Dunbardbec0332009-04-29 01:00:32 +000035
Chris Lattnerb5f6e802009-05-06 02:47:51 +000036=item B<Preprocessing>
Daniel Dunbardbec0332009-04-29 01:00:32 +000037
Chris Lattnerb5f6e802009-05-06 02:47:51 +000038This stage handles tokenization of the input source file, macro expansion,
39#include expansion and handling of other preprocessor directives. The output of
40this stage is typically called a ".i" (for C) or ".mi" (for Objective-C) file.
41
42=item B<Parsing and Semantic Analysis>
43
44This stage parses the input file, translating preprocessor tokens into a parse
45tree. Once in the form of a parser tree, it applies semantic analysis to compute
46types for expressions as well and determine whether the code is well formed. This
47stage is responsible for generating most of the compiler warnings as well as
48parse errors. The output of this stage is an "Abstract Syntax Tree" (AST).
49
50=item B<Code Generation and Optimization>
51
52This stage translates an AST into low-level intermediate code or machine code
53(depending on the optimization level). This phase is responsible for optimizing
54the generated code and handling target-specfic code generation. The output of
55this stage is typically called a ".s" file.
56
Chris Lattner9b081c62009-05-06 17:22:08 +000057=item B<Assembler>
Chris Lattnerb5f6e802009-05-06 02:47:51 +000058
59This stage runs the target assembler to translate the output of the compiler
60into a target object file. The output of this stage is typically called a ".o"
61file.
62
Chris Lattner9b081c62009-05-06 17:22:08 +000063=item B<Linker>
Chris Lattnerb5f6e802009-05-06 02:47:51 +000064
65This stage runs the target linker to merge multiple object files into an
66executable or dynamic library. The output of this stage is typically called an
67"a.out", ".dylib" or ".so" file.
68
69=back
70
71The Clang compiler supports a large number of options to control each of these
Chris Lattner9b081c62009-05-06 17:22:08 +000072stages. In addition to compilation of code, Clang also supports other tools.
73
74B<Clang Static Analyzer>
75
76The Clang Static Analyzer is a tool that scans source code to try to find bugs
77though code analysis. This tool uses many parts of Clang and is built into the
78same driver.
79
Chris Lattnerb5f6e802009-05-06 02:47:51 +000080
81=head1 OPTIONS
82
Chris Lattnerb5f6e802009-05-06 02:47:51 +000083=head2 Stage Selection Options
84
85=over
Daniel Dunbardbec0332009-04-29 01:00:32 +000086
Daniel Dunbardbec0332009-04-29 01:00:32 +000087=item B<-E>
88
Chris Lattner9b081c62009-05-06 17:22:08 +000089Run the preprocessor stage.
Daniel Dunbardbec0332009-04-29 01:00:32 +000090
Chris Lattner9b081c62009-05-06 17:22:08 +000091=item B<-fsyntax-only>
Chris Lattnerb5f6e802009-05-06 02:47:51 +000092
Chris Lattner9b081c62009-05-06 17:22:08 +000093Run the preprocessor, parser and type checking stages.
Chris Lattnerb5f6e802009-05-06 02:47:51 +000094
95=item B<-emit-llvm>
96
Chris Lattner9b081c62009-05-06 17:22:08 +000097Run the preprocessor, parser, type checking stages, LLVM generation and
98optimization stages.
Chris Lattnerb5f6e802009-05-06 02:47:51 +000099
Chris Lattner9b081c62009-05-06 17:22:08 +0000100=item B<-S>
Chris Lattnerb5f6e802009-05-06 02:47:51 +0000101
Chris Lattner9b081c62009-05-06 17:22:08 +0000102Run all of the above, plus target-specific code generation, producing an
103assembly file.
Chris Lattnerb5f6e802009-05-06 02:47:51 +0000104
Chris Lattner9b081c62009-05-06 17:22:08 +0000105=item B<-c>
106
107Run all of the above, plus the assembler, generating a target ".o" object file.
108
109=item B<no stage selection option>
110
111If no stage selection option is specified, all stages above are run, and the
112linker is run to combine the results into an executable or shared library.
113
114=item B<--analyze>
115
116Run the Clang Static Analyzer.
Chris Lattnerb5f6e802009-05-06 02:47:51 +0000117
118=back
119
120
121
Chris Lattner9b081c62009-05-06 17:22:08 +0000122=head2 Driver Options
Chris Lattnerb5f6e802009-05-06 02:47:51 +0000123
124=over
125
Chris Lattner9b081c62009-05-06 17:22:08 +0000126=item B<-###>
Chris Lattnerb5f6e802009-05-06 02:47:51 +0000127
Chris Lattner9b081c62009-05-06 17:22:08 +0000128Print the commands to run for this compilation.
129
130=item B<--help>
131
132Display available options.
133
Daniel Dunbardbec0332009-04-29 01:00:32 +0000134=item B<-ObjC++>
135
136Treat source input files as Objective-C++ inputs.
137
138=item B<-ObjC>
139
140Treat source input files as Objective-C inputs.
141
142=item B<-Qunused-arguments>
143
144Don't emit warning for unused driver arguments.
145
Daniel Dunbardbec0332009-04-29 01:00:32 +0000146=item B<-Wa,>I<args>
147
148Pass the comma separated arguments in I<args> to the assembler.
149
150=item B<-Wl,>I<args>
151
152Pass the comma separated arguments in I<args> to the linker.
153
154=item B<-Wp,>I<args>
155
156Pass the comma separated arguments in I<args> to the preprocessor.
157
158=item B<-Xanalyzer> I<arg>
159
160Pass I<arg> to the static analyzer.
161
162=item B<-Xassembler> I<arg>
163
164Pass I<arg> to the assembler.
165
166=item B<-Xclang> I<arg>
167
168Pass I<arg> to the clang compiler.
169
170=item B<-Xlinker> I<arg>
171
172Pass I<arg> to the linker.
173
174=item B<-Xpreprocessor> I<arg>
175
176Pass I<arg> to the preprocessor.
177
Daniel Dunbardbec0332009-04-29 01:00:32 +0000178=item B<-o> I<file>
179
180Write output to I<file>.
181
Daniel Dunbardbec0332009-04-29 01:00:32 +0000182=item B<-print-file-name>=I<file>
183
184Print the full library path of I<file>.
185
186=item B<-print-libgcc-file-name>
187
188Print the library path for "libgcc.a".
189
190=item B<-print-prog-name>=I<name>
191
192Print the full program path of I<name>.
193
194=item B<-print-search-dirs>
195
196Print the paths used for finding libraries and programs.
197
198=item B<-save-temps>
199
200Save intermediate compilation results.
201
202=item B<-time>
203
204Time individual commands.
205
206=item B<-v>
207
208Show commands to run and use verbose output.
209
210=item B<-x> I<language>
211
212Treat subsequent input files as having type I<language>.
213
Chris Lattner9b081c62009-05-06 17:22:08 +0000214
Daniel Dunbardbec0332009-04-29 01:00:32 +0000215=back
216
Chris Lattner9b081c62009-05-06 17:22:08 +0000217
218
219
220
221=head2 Preprocessor Options
222
223=over
224
225=back
226
227
228
229
230=head2 Parser and Semantic Analysis Options
231
232=over
233
234=back
235
236
237
238=head2 Code Generation and Optimization Options
239
240=over
241
242=back
243
244
245=head2 Assembler Options
246
247=over
248
249=back
250
251
252=head2 Linker Options
253
254=over
255
256=back
257
258
Daniel Dunbardbec0332009-04-29 01:00:32 +0000259=head1 ENVIRONMENT
260
Daniel Dunbare58c9432009-05-06 19:18:09 +0000261=over
262
263=item B<TMPDIR>, B<TEMP>, B<TMP>
264
265These environment variables are checked, in order, for the location to
266write temporary files used during the compilation process.
267
268=item B<CPATH>
269
270If this environment variable is present, it is treated as a delimited
271list of paths to be added to the default system include path list. The
272delimiter is the platform dependent delimitor, as used in the I<PATH>
273environment variable.
274
275Empty components in the environment variable are ignored.
276
277=item B<C_INCLUDE_PATH>, B<OBJC_INCLUDE_PATH>, B<CPLUS_INCLUDE_PATH>,
278B<OBJCPLUS_INCLUDE_PATH>
279
280These environment variables specify additional paths, as for CPATH,
281which are only used when processing the appropriate language.
282
283=item B<MACOSX_DEPLOYMENT_TARGET> (Apple only)
284
285If -mmacosx-version-min is unspecified, the default deployment target
286is read from this environment variable.
287
288=back
Daniel Dunbardbec0332009-04-29 01:00:32 +0000289
290=head1 BUGS
291
Chris Lattner9b081c62009-05-06 17:22:08 +0000292Clang currently does not have C++ support, and this manual page is incomplete.
293To report bugs, please visit L<http://llvm.org/bugs/>. Most bug reports should
Daniel Dunbare58c9432009-05-06 19:18:09 +0000294include preprocessed source files (use the B<-E> option) and the full output of
295the compiler, along with information to reproduce.
Daniel Dunbardbec0332009-04-29 01:00:32 +0000296
297=head1 SEE ALSO
298
Chris Lattner9b081c62009-05-06 17:22:08 +0000299as(1), ld(1)
Daniel Dunbardbec0332009-04-29 01:00:32 +0000300
301=head1 AUTHOR
302
303Maintained by the Clang / LLVM Team (L<http://clang.llvm.org>).
304
305=cut