Fix catch trace bug and inline cost bug
[hiphop-php.git] / hphp / doc / options.compiler
blob23997ee4df3486084c8ebc43ccffd4f870eca47c
1 <h2>Configurable Options for Compiler</h2>
3 Compiler has a --config option to take a configuration file in HDF format, and
4 it has a --config-value to take ad-hoc configurable options in HDF format.
5 This documentation describes what's available for both of them.
7 When in doubt, look for how these options are parsed in compiler/options.cpp.
9 = AllDynamic
11 Default is false. When turned on, all functions and methods can be invoked
12 dynamically even without a literal string. When turned off, some dynamic
13 function calls may fail, if compiler is not able to tell that function may be
14 invoked dynamically. Recommend to turn on this switch.
16 = AllVolatile
18 Default is false. When turned on, order-dependent function or class declaration
19 vs. existence testing can work. When turned off, some function_exists(),
20 class_exists(), get_defined_functions() or get_declared_classes() may return
21 different results than PHP does. Most programs don't have dependencies on their
22 behaviors, so this is recommended to leave as off.
24 = EnableEval
26 Default is 0, eval() will throw a fatal error. When 1, eval() is supported in
27 a limited way, mixed together with compiled program. When 2, eval() is fully
28 supported as an interpreter mode.
30 = IncludeRoots
32 Only needed when --input-list is not used, and --parse-on-demand is turned on.
33 In this case, compiler needs to understand every single include. Currently it
34 only understands these formats (compiler/analysis/dependency_graph.cpp),
36   include 'literal_file_path';
37   include $SOME_VARIABLE . 'literal_file_path';
39 IncludeRoots is designed to look up $SOME_VARIABLE in the second case, so to
40 resolve file paths at compilation time. It will look like this,
42   IncludeRoots {
43     * {
44       root = $SOME_VARIABLE
45       path = lib/
46     }
47     * {
48       root = $SOME_OTHER_ROOT
49       path = lib/another
50     }
51   }
53 = AutoloadRoots
55 Only needed when --input-list is not used, and --parse-on-demand is turned on.
56 In this case, compiler needs to understand all autoloads to find a class file.
57 It will look like this,
59   AutoloadRoots {
60     * {
61       root = $GLOBALS['THRIFT_AUTOLOAD']
62       path = lib/thrift/packages
63     }
64   }
66 With the above configuration, whenever a class name is added to the array,
68   $GLOBALS['THRIFT_AUTOLOAD'][] = 'myclass';
70 It will be searched against the specified path. Please note that, this is
71 not a good way to work around the problem. --include-list is recommended to
72 specify all class files explicitly. Then this option isn't needed.
74 = IncludeSearchPaths
76 Only needed when --input-list is not used, and --parse-on-demand is turned on.
77 Specifies more paths to search for include files. For example,
79   IncludeSearchPaths {
80     * = lib/thrift/packages
81     * = lib/common
82   }
84 = PackageDirectories
86 Add all PHP files under these directories. For example,
88   PackageDirectories {
89     * = lib/thrift/packages
90     * = lib/common
91   }
93 = PackageExcludeDirs
95 Exclude file under these directories. Same as --exclude-dir command line
96 option. For example,
98   PackageExcludeDirs {
99     * = scripts/
100     * = tests/
101   }
103 = PackageExcludeFiles
105 Exclude these files. Same as --exclude-file command line option. For example,
107   PackageExcludeFiles {
108     * = scripts/delete_user.php
109     * = tests/create_database.php
110   }
112 = PackageExcludeStaticFiles
114 Exclude files matching these patterns from static file content cache. A static
115 content cache creates one single file from all static contents, including
116 css, js, html, images and other MIME format files. When building static
117 content cache, the compiler will look for all non-PHP files to try to include
118 them. This option allows one to exclude certain files. Same as
119 --exclude-static-pattern command line option. For example,
121   PackageExcludeStaticFiles {
122     * = .*\\.js
123     * = .*\\.css
124   }
126 = CachePHPFile
128 Default is false. Whether to include PHP files in static content cache.
130 = ScalarArrayFileCount
132 Default is 1. Scalar arrays are arrays with scalar values, including literal
133 strings, numbers and scalar arrays as keys and values, so their values are
134 entirely determined at compilation time. We pre-generate these arrays during
135 program startup time just once to avoid initialization costs. These scalar
136 arrays are groups into their own files. This option specifies how many files
137 to generate or split up scalar arrays, so we can compile them faster. For
138 large project with a lot of scalar arrays, use a higher value. Then each file
139 is smaller. When using distcc, normally it finishes compilation faster.
141 = ScalarArrayOverflowLimit
143 Default is 2000. Some scalar arrays can become extremely large when nested
144 with lots of elements and levels. This option controls how to split them up
145 into small ones, having sub-arrays defined by their own, so to flatten array
146 data structure for faster compilation.
148 = LiteralStringFileCount
150 Default is 1. Similar to scalar arrays, we have literal strings pre-generated
151 in files. This option specifies how many of these files are generated for
152 faster compilation.
154 = EnableHipHopSyntax
156 Default is false. Enables new syntax, including yield, new type names for
157 function parameter, function return and class variable type hints (string,
158 int, boolean, etc..), new array types (vector, map, set).
160 = EnableHipHopExperimentalSyntax
162 Default is false. Enables experimental syntax, including type hints for local
163 variables and global variables.
165 = EnableShortTags
167 Default is true. Is &lt;? allowed with PHP code?
169 = EnableAspTags
171 Default is false. Is &lt;% %&gt; allowed with PHP code?
173 = EnableXHP
175 Whether to enable XHP extension. XHP adds some syntax sugar to allow better and
176 safer HTML templating. For more information, search XHP.
178 = NativeXHP
180 Whether to use HPHP to directly handle XHP.
182 = ParserThreadCount
184 How many threads to use when parsing PHP files. By default, it's 2x CPU count.
186 = FlibDirectory
188 Facebook specific. Ignore.
190 = GenerateCppLibCode
192 Default is false. When turned on, it will generate better C++ code to be used
193 as C++ libraries, including better class methods and doc comments.
195 = GenerateSourceInfo
197 Default is false. Source info is a map from locations in C++ files to those in
198 PHP files. It can be used to translate C++ stacktrace to more readable PHP
199 stacktrace. When FrameInjection enabled, there is no need to do stacktrace
200 translation any more, so this option is by default set to false to save space.
202 = GenerateDocComments
204 Default is true. Whether to store doc comments in class map, so they can be
205 queried from reflection.
207 = PregenerateCPP
209 Default is false. In case clustering of output files has been requested and this
210 option is set to true, the files are pre-generated in memory in order to perform
211 a more precise partitioning.
213 = GCCOptimization
215 Default is disabled. This option allows to selectively decrease the compiler
216 optimization level for long functions. It is specified as:
218   GCCOptimization {
219     O2 = X
220     O1 = Y
221     O0 = Z
222   }
224 where X, Y, Z are the minimum length functions must have (measured as line
225 count) for their optimization level to be decreased respectively to O2, O1,
226 O0. Note that all these parameters are optional, so it is possible for example
227 to only specify O1 and O0 but not O2, meaning that O2 will never be used as an
228 optimization level. In general it is expected that if specified, the minimum
229 line counts will be increasing for a decreasing optimization level.
231 = DynamicFunctionPrefix
233 Deprecating. These are options for specifying which functions may be called
234 dynamically. This turned out to be hard to configure, and it's replaced by
235 AllDynamics.
237 = DynamicFunctionPostfix
239 Deprecating. These are options for specifying which functions may be called
240 dynamically. This turned out to be hard to configure, and it's replaced by
241 AllDynamics.
243 = DynamicMethodPrefix
245 Deprecating. These are options for specifying which methods may be called
246 dynamically. This turned out to be hard to configure, and it's replaced by
247 AllDynamics.
249 = DynamicInvokeFunctions
251 Deprecating. These are options for specifying which functions may be called
252 dynamically. This turned out to be hard to configure, and it's replaced by
253 AllDynamics.
255 = CodeGeneration
257 Under "CodeGeneration", one can specify alternative name prefixes that are
258 used in different places of code generation.
260 - IdPrefix
261 - LabelEscape
262 - LambdaPrefix
263 - FunctionPrefix
264 - BuiltinFunctionPrefix
265 - InvokePrefix
266 - CreateObjectPrefix
267 - PseudoMainPrefix
268 - VariablePrefix
269 - GlobalVariablePrefix
270 - StaticVariablePrefix
271 - ScalarArrayName
272 - SystemScalarArrayName
273 - ClassPrefix
274 - ClassStaticsPrefix
275 - ClassStaticsObjectPrefix
276 - ClassStaticsCallbackPrefix
277 - ClassStaticsIdGetterPrefix
278 - ClassStaticInitializerPrefix
279 - ClassStaticInitializerFlagPrefix
280 - ClassWrapperFunctionPrefix
281 - ObjectPrefix
282 - ObjectStaticPrefix
283 - SmartPtrPrefix
284 - MethodPrefix
285 - MethodWrapperPrefix
286 - MethodImplPrefix
287 - PropertyPrefix
288 - StaticPropertyPrefix
289 - ConstantPrefix
290 - ClassConstantPrefix
291 - ExceptionPrefix
292 - TempVariablePrefix
293 - EvalOrderTempPrefix
294 - SilencerPrefix
295 - EvalInvokePrefix
296 - TempPrefix
297 - MapPrefix
298 - IterPrefix
299 - InitPrefix
300 - FFIFnPrefix
301 - SystemFilePrefix
302 - UserFilePrefix
303 - ClassHeaderPrefix
304 - ClusterPrefix
305 - FFIFilePrefix