Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 1 | =pod |
| 2 | |
| 3 | =head1 NAME |
| 4 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 5 | clang - the Clang C and Objective-C compiler |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 6 | |
| 7 | =head1 SYNOPSIS |
| 8 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 9 | B<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 Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 18 | |
| 19 | =head1 DESCRIPTION |
| 20 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 21 | B<clang> is a C and Objective-C compiler which encompasses preprocessing, |
| 22 | parsing, optimization, code generation, assembly, and linking. Depending on |
| 23 | which high-level mode setting is passed, Clang will stop before doing a full |
| 24 | link. While Clang is highly integrated, it is important to understand the |
| 25 | stages of compilation, to understand how to invoke it. These stages are: |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 26 | |
| 27 | =over |
| 28 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 29 | =item B<Driver> |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 30 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 31 | The B<clang> executable is actually a small driver which controls the overall |
| 32 | execution of other tools such as the compiler, assembler and linker. Typically |
| 33 | you do not need to interact with the driver, but you transparently use it to run |
| 34 | the other tools. |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 35 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 36 | =item B<Preprocessing> |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 37 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 38 | This stage handles tokenization of the input source file, macro expansion, |
| 39 | #include expansion and handling of other preprocessor directives. The output of |
| 40 | this stage is typically called a ".i" (for C) or ".mi" (for Objective-C) file. |
| 41 | |
| 42 | =item B<Parsing and Semantic Analysis> |
| 43 | |
| 44 | This stage parses the input file, translating preprocessor tokens into a parse |
| 45 | tree. Once in the form of a parser tree, it applies semantic analysis to compute |
| 46 | types for expressions as well and determine whether the code is well formed. This |
| 47 | stage is responsible for generating most of the compiler warnings as well as |
| 48 | parse errors. The output of this stage is an "Abstract Syntax Tree" (AST). |
| 49 | |
| 50 | =item B<Code Generation and Optimization> |
| 51 | |
| 52 | This stage translates an AST into low-level intermediate code or machine code |
| 53 | (depending on the optimization level). This phase is responsible for optimizing |
| 54 | the generated code and handling target-specfic code generation. The output of |
| 55 | this stage is typically called a ".s" file. |
| 56 | |
| 57 | =item B<Assembly> |
| 58 | |
| 59 | This stage runs the target assembler to translate the output of the compiler |
| 60 | into a target object file. The output of this stage is typically called a ".o" |
| 61 | file. |
| 62 | |
| 63 | =item B<Linking> |
| 64 | |
| 65 | This stage runs the target linker to merge multiple object files into an |
| 66 | executable or dynamic library. The output of this stage is typically called an |
| 67 | "a.out", ".dylib" or ".so" file. |
| 68 | |
| 69 | =back |
| 70 | |
| 71 | The Clang compiler supports a large number of options to control each of these |
| 72 | stages. |
| 73 | |
| 74 | =head1 OPTIONS |
| 75 | |
| 76 | |
| 77 | =head2 Stage Selection Options |
| 78 | |
| 79 | =over |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 80 | |
| 81 | =item B<--help> |
| 82 | |
| 83 | Display available options. |
| 84 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 85 | |
| 86 | =item B<-###> |
| 87 | |
| 88 | Print the commands to run for this compilation. |
| 89 | |
| 90 | |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 91 | =item B<-E> |
| 92 | |
| 93 | Only run the preprocessor. |
| 94 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 95 | =item B<-S> |
| 96 | |
| 97 | Only run preprocess and compilation steps. |
| 98 | |
| 99 | =item B<-c> |
| 100 | |
| 101 | Only run preprocess, compile, and assemble steps. |
| 102 | |
| 103 | =item B<-emit-llvm> |
| 104 | |
| 105 | Use 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 | |
| 121 | Run the static analyzer. |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 122 | =item B<-ObjC++> |
| 123 | |
| 124 | Treat source input files as Objective-C++ inputs. |
| 125 | |
| 126 | =item B<-ObjC> |
| 127 | |
| 128 | Treat source input files as Objective-C inputs. |
| 129 | |
| 130 | =item B<-Qunused-arguments> |
| 131 | |
| 132 | Don't emit warning for unused driver arguments. |
| 133 | |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 134 | =item B<-Wa,>I<args> |
| 135 | |
| 136 | Pass the comma separated arguments in I<args> to the assembler. |
| 137 | |
| 138 | =item B<-Wl,>I<args> |
| 139 | |
| 140 | Pass the comma separated arguments in I<args> to the linker. |
| 141 | |
| 142 | =item B<-Wp,>I<args> |
| 143 | |
| 144 | Pass the comma separated arguments in I<args> to the preprocessor. |
| 145 | |
| 146 | =item B<-Xanalyzer> I<arg> |
| 147 | |
| 148 | Pass I<arg> to the static analyzer. |
| 149 | |
| 150 | =item B<-Xassembler> I<arg> |
| 151 | |
| 152 | Pass I<arg> to the assembler. |
| 153 | |
| 154 | =item B<-Xclang> I<arg> |
| 155 | |
| 156 | Pass I<arg> to the clang compiler. |
| 157 | |
| 158 | =item B<-Xlinker> I<arg> |
| 159 | |
| 160 | Pass I<arg> to the linker. |
| 161 | |
| 162 | =item B<-Xpreprocessor> I<arg> |
| 163 | |
| 164 | Pass I<arg> to the preprocessor. |
| 165 | |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 166 | =item B<-o> I<file> |
| 167 | |
| 168 | Write output to I<file>. |
| 169 | |
| 170 | =item B<-pipe> |
| 171 | |
| 172 | Use pipes between commands, when possible. |
| 173 | |
| 174 | =item B<-print-file-name>=I<file> |
| 175 | |
| 176 | Print the full library path of I<file>. |
| 177 | |
| 178 | =item B<-print-libgcc-file-name> |
| 179 | |
| 180 | Print the library path for "libgcc.a". |
| 181 | |
| 182 | =item B<-print-prog-name>=I<name> |
| 183 | |
| 184 | Print the full program path of I<name>. |
| 185 | |
| 186 | =item B<-print-search-dirs> |
| 187 | |
| 188 | Print the paths used for finding libraries and programs. |
| 189 | |
| 190 | =item B<-save-temps> |
| 191 | |
| 192 | Save intermediate compilation results. |
| 193 | |
| 194 | =item B<-time> |
| 195 | |
| 196 | Time individual commands. |
| 197 | |
| 198 | =item B<-v> |
| 199 | |
| 200 | Show commands to run and use verbose output. |
| 201 | |
| 202 | =item B<-x> I<language> |
| 203 | |
| 204 | Treat subsequent input files as having type I<language>. |
| 205 | |
| 206 | =back |
| 207 | |
| 208 | =head1 ENVIRONMENT |
| 209 | |
| 210 | FIXME: Fill in environment. |
| 211 | |
| 212 | =head1 BUGS |
| 213 | |
Chris Lattner | b5f6e80 | 2009-05-06 02:47:51 +0000 | [diff] [blame^] | 214 | It is inconceivable that Clang may have a bug. |
Daniel Dunbar | dbec033 | 2009-04-29 01:00:32 +0000 | [diff] [blame] | 215 | |
| 216 | =head1 SEE ALSO |
| 217 | |
| 218 | FIXME: See also? |
| 219 | |
| 220 | =head1 AUTHOR |
| 221 | |
| 222 | Maintained by the Clang / LLVM Team (L<http://clang.llvm.org>). |
| 223 | |
| 224 | =cut |