blob: 7c1c873b4976075363abb929ddf0de2e57190479 [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
57=item B<Assembly>
58
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
63=item B<Linking>
64
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
72stages.
73
74=head1 OPTIONS
75
76
77=head2 Stage Selection Options
78
79=over
Daniel Dunbardbec0332009-04-29 01:00:32 +000080
81=item B<--help>
82
83Display available options.
84
Chris Lattnerb5f6e802009-05-06 02:47:51 +000085
86=item B<-###>
87
88Print the commands to run for this compilation.
89
90
Daniel Dunbardbec0332009-04-29 01:00:32 +000091=item B<-E>
92
93Only run the preprocessor.
94
Chris Lattnerb5f6e802009-05-06 02:47:51 +000095=item B<-S>
96
97Only run preprocess and compilation steps.
98
99=item B<-c>
100
101Only run preprocess, compile, and assemble steps.
102
103=item B<-emit-llvm>
104
105Use the LLVM representation for assembler and object files.
106
107
108
109
110=back
111
112
113
114
115
116
117=over
118
119=item B<--analyze>
120
121Run the static analyzer.
Daniel Dunbardbec0332009-04-29 01:00:32 +0000122=item B<-ObjC++>
123
124Treat source input files as Objective-C++ inputs.
125
126=item B<-ObjC>
127
128Treat source input files as Objective-C inputs.
129
130=item B<-Qunused-arguments>
131
132Don't emit warning for unused driver arguments.
133
Daniel Dunbardbec0332009-04-29 01:00:32 +0000134=item B<-Wa,>I<args>
135
136Pass the comma separated arguments in I<args> to the assembler.
137
138=item B<-Wl,>I<args>
139
140Pass the comma separated arguments in I<args> to the linker.
141
142=item B<-Wp,>I<args>
143
144Pass the comma separated arguments in I<args> to the preprocessor.
145
146=item B<-Xanalyzer> I<arg>
147
148Pass I<arg> to the static analyzer.
149
150=item B<-Xassembler> I<arg>
151
152Pass I<arg> to the assembler.
153
154=item B<-Xclang> I<arg>
155
156Pass I<arg> to the clang compiler.
157
158=item B<-Xlinker> I<arg>
159
160Pass I<arg> to the linker.
161
162=item B<-Xpreprocessor> I<arg>
163
164Pass I<arg> to the preprocessor.
165
Daniel Dunbardbec0332009-04-29 01:00:32 +0000166=item B<-o> I<file>
167
168Write output to I<file>.
169
170=item B<-pipe>
171
172Use pipes between commands, when possible.
173
174=item B<-print-file-name>=I<file>
175
176Print the full library path of I<file>.
177
178=item B<-print-libgcc-file-name>
179
180Print the library path for "libgcc.a".
181
182=item B<-print-prog-name>=I<name>
183
184Print the full program path of I<name>.
185
186=item B<-print-search-dirs>
187
188Print the paths used for finding libraries and programs.
189
190=item B<-save-temps>
191
192Save intermediate compilation results.
193
194=item B<-time>
195
196Time individual commands.
197
198=item B<-v>
199
200Show commands to run and use verbose output.
201
202=item B<-x> I<language>
203
204Treat subsequent input files as having type I<language>.
205
206=back
207
208=head1 ENVIRONMENT
209
210FIXME: Fill in environment.
211
212=head1 BUGS
213
Chris Lattnerb5f6e802009-05-06 02:47:51 +0000214It is inconceivable that Clang may have a bug.
Daniel Dunbardbec0332009-04-29 01:00:32 +0000215
216=head1 SEE ALSO
217
218FIXME: See also?
219
220=head1 AUTHOR
221
222Maintained by the Clang / LLVM Team (L<http://clang.llvm.org>).
223
224=cut