blob: 3461674befe34cf2544c3a88c7f210fdc67763ed [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
182=item B<-pipe>
183
Chris Lattner9b081c62009-05-06 17:22:08 +0000184FIXME: WHY DOCUMENT THIS.
Daniel Dunbardbec0332009-04-29 01:00:32 +0000185Use pipes between commands, when possible.
186
187=item B<-print-file-name>=I<file>
188
189Print the full library path of I<file>.
190
191=item B<-print-libgcc-file-name>
192
193Print the library path for "libgcc.a".
194
195=item B<-print-prog-name>=I<name>
196
197Print the full program path of I<name>.
198
199=item B<-print-search-dirs>
200
201Print the paths used for finding libraries and programs.
202
203=item B<-save-temps>
204
205Save intermediate compilation results.
206
207=item B<-time>
208
209Time individual commands.
210
211=item B<-v>
212
213Show commands to run and use verbose output.
214
215=item B<-x> I<language>
216
217Treat subsequent input files as having type I<language>.
218
Chris Lattner9b081c62009-05-06 17:22:08 +0000219
Daniel Dunbardbec0332009-04-29 01:00:32 +0000220=back
221
Chris Lattner9b081c62009-05-06 17:22:08 +0000222
223
224
225
226=head2 Preprocessor Options
227
228=over
229
230=back
231
232
233
234
235=head2 Parser and Semantic Analysis Options
236
237=over
238
239=back
240
241
242
243=head2 Code Generation and Optimization Options
244
245=over
246
247=back
248
249
250=head2 Assembler Options
251
252=over
253
254=back
255
256
257=head2 Linker Options
258
259=over
260
261=back
262
263
Daniel Dunbardbec0332009-04-29 01:00:32 +0000264=head1 ENVIRONMENT
265
Chris Lattner9b081c62009-05-06 17:22:08 +0000266No environment variables read.
Daniel Dunbardbec0332009-04-29 01:00:32 +0000267
268=head1 BUGS
269
Chris Lattner9b081c62009-05-06 17:22:08 +0000270Clang currently does not have C++ support, and this manual page is incomplete.
271To report bugs, please visit L<http://llvm.org/bugs/>. Most bug reports should
272include preprocessed source files (use the B<-E> option) along with information
273to reproduce.
Daniel Dunbardbec0332009-04-29 01:00:32 +0000274
275=head1 SEE ALSO
276
Chris Lattner9b081c62009-05-06 17:22:08 +0000277as(1), ld(1)
Daniel Dunbardbec0332009-04-29 01:00:32 +0000278
279=head1 AUTHOR
280
281Maintained by the Clang / LLVM Team (L<http://clang.llvm.org>).
282
283=cut