1 #This configuration file is similar to a regular .ini file. Comments start
2 #with hashtags or semicolons, sections are written in square brackets and
3 #in each section there can be arbitrary many key-value pairs.
5 #There are 3 sections currently: ‘flags’, ‘warnings’, ‘optimizations’.
6 #They contain a list of boolean values of the form ‘VARNAME = true’ or
7 #‘VARNAME = false’. The variable names are the same as for the corre‐
8 #sponding -W, -f or -O flag written with only capital letters and dashes
9 #replaced by underscores.
12 #Add some additional characters to the string table in order to
13 #compensate for a wrong boundcheck in some specific version of the
16 DARKPLACES_STRING_TABLE_BUG = true
19 #When assigning to field pointers of type .vector the common be‐
20 #haviour in compilers like fteqcc is to only assign the x-compo‐
21 #nent of the pointer. This means that you can use the vector as
22 #such, but you cannot use its y and z components directly. This
23 #flag fixes this behaviour. Before using it make sure your code
24 #does not depend on the buggy behaviour.
26 ADJUST_VECTOR_FIELDS = true
29 #Enable a partially fteqcc-compatible preprocessor. It supports
30 #all the features used in the Xonotic codebase. If you need more,
36 #Enable some predefined macros. This only works in combination
37 #with '-fftepp' and is currently not included by '-std=fteqcc'.
38 #The following macros will be added:
50 #Note that __FUNC__ is not actually a preprocessor macro, but is
51 #recognized by the parser even with the preprocessor disabled.
53 #Note that fteqcc also defines __NULL__ which becomes the first
54 #global. Assigning it to a vector does not yield the same result
55 #as in gmqcc where __NULL__ is defined to nil (See -funtyped-nil
56 #), which will cause the vector to be zero in all components. With
57 #fteqcc only the first component will be 0, while the other two
58 #will become the first to of the global return value. This behav‐
59 #ior is odd and relying on it should be discouraged, and thus is
60 #not supported by gmqcc.
65 #Enable math constant definitions. This only works in combination
66 #with '-fftepp' and is currently not included by '-std=fteqcc'.
67 #The following macros will be added:
84 FTEPP_MATHDEFS = false
87 #Allow switch cases to use non constant variables.
92 #Perform early out in logical AND and OR expressions. The final
93 #result will be either a 0 or a 1, see the next flag for more pos‐
99 #In many languages, logical expressions perform early out in a
100 #special way: If the left operand of an AND yeilds true, or the
101 #one of an OR yields false, the complete expression evaluates to
102 #the right side. Thus ‘true && 5’ evaluates to 5 rather than 1.
107 #Enable the underscore intrinsic: Using ‘_("A string constant")’
108 #will cause the string immediate to get a name with a "dotrans‐
109 #late_" prefix. The darkplaces engine recognizes these and trans‐
110 #lates them in a way similar to how gettext works.
112 TRANSLATABLE_STRINGS = true
115 #Don't implicitly convert initialized variables to constants. With
116 #this flag, the const keyword is required to make a constant.
118 INITIALIZED_NONCONSTANTS = false
121 #If this flag is not set, (and it is set by default in the qcc and
122 #fteqcc standards), assigning function pointers of mismatching
123 #signatures will result in an error rather than a warning.
125 ASSIGN_FUNCTION_TYPES = true
128 #Produce a linenumber file along with the output .dat file.
133 #Use C's operator precedence for ternary expressions. Unless your
134 #code depends on fteqcc-compatible behaviour, you'll want to use
137 CORRECT_TERNARY = true
140 #Normally vectors generate 4 defs, once for the vector, and once
141 #for its components with _x, _y, _z suffixes. This option prevents
142 #components from being listed.
145 SINGLE_VECTOR_DEFS = true
148 #Most QC compilers translate ‘if(a_vector)’ directly as an IF on
149 #the vector, which means only the x-component is checked. This
150 #option causes vectors to be cast to actual booleans via a NOT_V
151 #and, if necessary, a NOT_F chained to it.
153 # if (a_vector) // becomes
156 # a = a_vector && a_float // becomes
157 # a = !!a_vector && a_float
162 #An empty string is considered to be true everywhere. The NOT_S
163 #instruction usually considers an empty string to be false, this
164 #option effectively causes the unary not in strings to use NOT_F
167 TRUE_EMPTY_STRINGS = false
170 #An empty string is considered to be false everywhere. This means
171 #loops and if statements which depend on a string will perform a
172 #NOT_S instruction on the string before using it.
174 FALSE_EMPTY_STRINGS = true
177 #Enable utf8 characters. This allows utf-8 encoded character con‐
178 #stants, and escape sequence codepoints in the valid utf-8 range.
179 #Effectively enabling escape sequences like '\{x2211}'.
184 #When a warning is treated as an error, and this option is set
185 #(which it is by default), it is like any other error and will
186 #cause compilation to stop. When disabling this flag by using
187 #-fno-bail-on-werror, compilation will continue until the end, but
188 #no output is generated. Instead the first such error message's
191 BAIL_ON_WERROR = false
194 #Allow loops to be labeled, and allow 'break' and 'continue' to
195 #take an optional label to decide which loop to actually jump out
198 # for :outer (i = 0; i < n; ++i) {
209 #Adds a global named 'nil' which is of no type and can be assigned
210 #to anything. No typechecking will be performed on assignments.
211 #Assigning to it is forbidden, using it in any other kind of
212 #expression is also not allowed.
214 #Note that this is different from fteqcc's __NULL__: In fteqcc,
215 #__NULL__ maps to the integer written as '0i'. It's can be
216 #assigned to function pointers and integers, but it'll error about
217 #invalid instructions when assigning it to floats without enabling
218 #the FTE instruction set. There's also a bug which allows it to be
219 #assigned to vectors, for which the source will be the global at
220 #offset 0, meaning the vector's y and z components will contain
221 #the OFS_RETURN x and y components.#
223 #In that gmqcc the nil global is an actual global filled with
224 #zeroes, and can be assigned to anything including fields, vectors
225 #or function pointers, and they end up becoming zeroed.
231 #Various effects, usually to weaken some conditions.
233 # Allow local variables named ‘nil’. (This will not
234 # allow declaring a global of that name.)
239 #Allow variadic parameters to be accessed by QC code. This can be
240 #achieved via the '...' function, which takes a parameter index
245 # void vafunc(string...count) {
247 # for (i = 0; i < count; ++i)
248 # print(...(i, string), "\n");
254 #Most Quake VMs, including the one from FTEQW or up till recently
255 #Darkplaces, do not cope well with vector instructions with over‐
256 #lapping input and output. This option will avoid producing such
259 LEGACY_VECTOR_MATHS = false
262 #Usually builtin-numbers are just immediate constants. With this
263 #flag expressions can be used, as long as they are compile-time
268 # void printA() = #1; // the usual way
269 # void printB() = #2-1; // with a constant expression
271 EXPRESSIONS_FOR_BUILTINS = true
274 #Enabiling this option will allow assigning values or expressions
275 #to the return keyword as if it were a local variable of the same
276 #type as the function's signature's return type.
280 # float bar() { return 1024; }
283 # return; // returns value of bar (this can be omitted)
286 RETURN_ASSIGNMENTS = true
289 #When passing on varargs to a different functions, this turns some
290 #static error cases into warnings. Like when the caller's varargs
291 #are restricted to a different type than the callee's parameter.
292 #Or a list of unrestricted varargs is passed into restricted
295 UNSAFE_VARARGS = false
298 #Always use STORE_F, LOAD_F, STOREP_F when accessing scalar variables.
299 #This is somewhat incorrect assembly instruction use, but in all engines
300 #they do exactly the same. This makes disassembly output harder to read,
301 #breaks decompilers, but causes the output file to be better compressible.
303 TYPELESS_STORES = false
306 #In commutative instructions, always put the lower-numbered operand first.
307 #This shaves off 1 byte of entropy from all these instructions, reducing
308 #compressed size of the output file.
310 SORT_OPERANDS = false
313 #Turn on arithmetic exception tests in the compiler. In constant expressions
314 #which trigger exceptions like division by zero, overflow, underflow, etc,
315 #the following flag will produce diagnostics for what triggered that
317 ARITHMETIC_EXCEPTIONS = false
320 #Generate a warning about variables which are declared but never
321 #used. This can be avoided by adding the ‘noref’ keyword in front
322 #of the variable declaration. Additionally a complete section of
323 #unreferenced variables can be opened using ‘#pragma noref 1’ and
324 #closed via ‘#pragma noref 0’.
326 UNUSED_VARIABLE = false
329 #Generate a warning if it is possible that a variable can be used
330 #without prior initialization. Note that this warning is not nec‐
331 #essarily reliable if the initialization happens only under cer‐
332 #tain conditions. The other way is not possible: that the warning
333 #is not generated when uninitialized use is possible.
335 USED_UNINITIALIZED = false
338 #Generate an error when an unrecognized control sequence in a
339 #string is used. Meaning: when there's a character after a back‐
340 #slash in a string which has no known meaning.
342 UNKNOWN_CONTROL_SEQUENCE = false
345 #Warn when using special extensions which are not part of the
351 #Generally QC compilers ignore redeclaration of fields. Here you
352 #can optionally enable a warning.
354 FIELD_REDECLARED = false
357 #Functions which aren't of type void will warn if it possible to
358 #reach the end without returning an actual value.
360 MISSING_RETURN_VALUES = false
363 #Warn about a function call with an invalid number of parameters.
365 INVALID_PARAMETER_COUNT = false
368 #Warn when a locally declared variable shadows variable.
370 LOCAL_SHADOWS = false
373 #Warn when the initialization of a local variable turns the vari‐
374 #able into a constant. This is default behaviour unless
375 #-finitialized-nonconstants is used.
377 LOCAL_CONSTANTS = false
380 #There are only 2 known global variables of type void:
381 #‘end_sys_globals’ and ‘end_sys_fields’. Any other void-variable
384 VOID_VARIABLES = false
387 #A global function which is not declared with the ‘var’ keyword is
388 #expected to have an implementing body, or be a builtin. If nei‐
389 #ther is the case, it implicitly becomes a function pointer, and a
390 #warning is generated.
392 IMPLICIT_FUNCTION_POINTER = false
395 #Currently there's no way for an in QC implemented function to
396 #access variadic parameters. If a function with variadic parame‐
397 #ters has an implementing body, a warning will be generated.
399 VARIADIC_FUNCTION = false
402 #Generate warnings about ‘$frame’ commands, for instance about
403 #duplicate frame definitions.
408 #Warn about statements which have no effect. Any expression which
409 #does not call a function or assigns a variable.
411 EFFECTLESS_STATEMENT = false
414 #The ‘end_sys_fields’ variable is supposed to be a global variable
415 #of type void. It is also recognized as a field but this will
418 END_SYS_FIELDS = false
421 #Warn when assigning to a function pointer with an unmatching sig‐
422 #nature. This usually happens in cases like assigning the null
423 #function to an entity's .think function pointer.
425 ASSIGN_FUNCTION_TYPES = false
428 #Show warnings created using the preprocessor's '#warning' directive
433 #Warn if there's a preprocessor #if spanning across several files.
438 #Warn about multiple declarations of globals. This seems pretty
439 #common in QC code so you probably do not want this unless you
440 #want to clean up your code.
442 DOUBLE_DECLARATION = false
445 #The combination of const and var is not illegal, however differ‐
446 #ent compilers may handle them differently. We were told, the
447 #intention is to create a function-pointer which is not assigna‐
448 #ble. This is exactly how we interpret it. However for this
449 #interpretation the ‘var’ keyword is considered superfluous (and
450 #philosophically wrong), so it is possible to generate a warning
456 #Warn about multibyte character constants, they do not work right
459 MULTIBYTE_CHARACTER = false
462 #Warn if a ternary expression which contains a comma operator is
463 #used without enclosing parenthesis, since this is most likely not
464 #what you actually want. We recommend the -fcorrect-ternary
467 TERNARY_PRECEDENCE = false
470 #Warn when encountering an unrecognized ‘#pragma’ line.
472 UNKNOWN_PRAGMAS = true
475 #Warn about unreachable code. That is: code after a return state‐
476 #ment, or code after a call to a function marked as 'noreturn'.
478 UNREACHABLE_CODE = true
481 #Enable some warnings added in order to help debugging in the com‐
482 #piler. You won't need this.
487 #Warn on an unknown attribute. The warning will inlclude only the
488 #first token inside the enclosing attribute-brackets. This may
489 #change when the actual attribute syntax is better defined.
491 UNKNOWN_ATTRIBUTE = true
494 #Warn when using reserved names such as ‘nil’.
496 RESERVED_NAMES = true
499 #Warn about global constants (using the ‘const’ keyword) with no
502 UNINITIALIZED_CONSTANT = true
505 #Warn about global variables with no initializing value. This is
506 #off by default, and is added mostly to help find null-values
507 #which are supposed to be replaced by the untyped 'nil' constant.
509 UNINITIALIZED_GLOBAL = true
512 #Warn when a variables is redeclared with a different qualifier.
513 #For example when redeclaring a variable as 'var' which was previ‐
514 #ously marked 'const'.
516 DIFFERENT_QUALIFIERS = true
519 #Similar to the above but for attributes like ‘[[noreturn]]’.
521 DIFFERENT_ATTRIBUTES = true
524 #Warn when a function is marked with the attribute "[[depre‐
525 #cated]]". This flag enables a warning on calls to functions
531 #Warn about possible mistakes caused by missing or wrong parenthe‐
532 #sis, like an assignment in an 'if' condition when there's no
533 #additional set of parens around the assignment.
538 #When passing variadic parameters via ...(N) it can happen that
539 #incompatible types are passed to functions. This enables several
540 #warnings when static typechecking cannot guarantee consistent
546 #When compiling original id1 QC there is a definition for `break`
547 #which conflicts with the 'break' keyword in GMQCC. Enabling this
548 #print a warning when the definition occurs. The definition is
549 #ignored for both cases.
554 #When compiling original QuakeWorld QC there are instances where
555 #code overwrites constants. This is considered an error, however
556 #for QuakeWorld to compile it needs to be treated as a warning
557 #instead, as such this warning only works when -std=qcc.
559 CONST_OVERWRITE = true
562 #Warn about the use of preprocessor directives inside macros.
564 DIRECTIVE_INMACRO = true
567 #When using a function that is not explicitly defined, the compiler
568 #will search its intrinsics table for something that matches that
569 #function name by appending "__builtin_" to it. This behaviour may
570 #be unexpected, so enabling this will produce a diagnostic when
571 #such a function is resolved to a builtin.
576 #When comparing an inexact value such as `1.0/3.0' the result is
577 #pathologically wrong. Enabling this will trigger a compiler warning
578 #on such expressions.
579 INEXACT_COMPARES = true
583 #Some general peephole optimizations. For instance the code `a = b
584 #+ c` typically generates 2 instructions, an ADD and a STORE. This
585 #optimization removes the STORE and lets the ADD write directly
591 #Tail recursive function calls will be turned into loops to avoid
592 #the overhead of the CALL and RETURN instructions.
594 TAIL_RECURSION = true
597 #Make all functions which use neither local arrays nor have locals
598 #which are seen as possibly uninitialized use the same local sec‐
599 #tion. This should be pretty safe compared to other compilers
600 #which do not check for uninitialized values properly. The problem
601 #is that there's QC code out there which really doesn't initialize
602 #some values. This is fine as long as this kind of optimization
603 #isn't used, but also, only as long as the functions cannot be
604 #called in a recursive manner. Since it's hard to know whether or
605 #not an array is actually fully initialized, especially when ini‐
606 #tializing it via a loop, we assume functions with arrays to be
607 #too dangerous for this optimization.
609 OVERLAP_LOCALS = true
612 #This promotes locally declared variables to "temps". Meaning when
613 #a temporary result of an operation has to be stored somewhere, a
614 #local variable which is not 'alive' at that point can be used to
615 #keep the result. This can reduce the size of the global section.
616 #This will not have declared variables overlap, even if it was
622 #Causes temporary values which do not need to be backed up on a
623 #CALL to not be stored in the function's locals-area. With this, a
624 #CALL to a function may need to back up fewer values and thus exe‐
630 #Don't generate defs for immediate values or even declared con‐
631 #stants. Meaning variables which are implicitly constant or qual‐
632 #ified as such using the 'const' keyword.
634 STRIP_CONSTANT_NAMES = true
637 #Aggressively reuse strings in the string section. When a string
638 #should be added which is the trailing substring of an already
639 #existing string, the existing string's tail will be returned
640 #instead of the new string being added.
642 #For example the following code will only generate 1 string:
644 # print("Hello you!\n");
645 # print("you!\n"); // trailing substring of "Hello you!\n"
647 #There's however one limitation. Strings are still processed in
648 #order, so if the above print statements were reversed, this opti‐
649 #mization would not happen.
651 OVERLAP_STRINGS = true
654 #By default, all parameters of a CALL are copied into the parame‐
655 #ter-globals right before the CALL instructions. This is the easi‐
656 #est and safest way to translate calls, but also adds a lot of
657 #unnecessary copying and unnecessary temporary values. This opti‐
658 #mization makes operations which are used as a parameter evaluate
659 #directly into the parameter-global if that is possible, which is
660 #when there's no other CALL instruction in between.
665 #Usually an empty RETURN instruction is added to the end of a void
666 #typed function. However, additionally after every function a DONE
667 #instruction is added for several reasons. (For example the qcvm's
668 #disassemble switch uses it to know when the function ends.). This
669 #optimization replaces that last RETURN with DONE rather than
670 #adding the DONE additionally.
675 #Because traditional QC code doesn't allow you to access individ‐
676 #ual vector components of a computed vector without storing it in
677 #a local first, sometimes people multiply it by a constant like
678 #‘'0 1 0'’ to get, in this case, the y component of a vector. This
679 #optimization will turn such a multiplication into a direct compo‐
680 #nent access. If the factor is anything other than 1, a float-mul‐
681 #tiplication will be added, which is still faster than a vector
684 VECTOR_COMPONENTS = true
687 #For constant expressions that result in dead code (such as a
688 #branch whos condition can be evaluated at compile-time), this
689 #will eliminate the branch and else body (if present) to produce
692 CONST_FOLD_DCE = true
695 #For constant expressions we can fold them to immediate values.
696 #this option cannot be disabled or enabled, the compiler forces
697 #it to stay enabled by ignoring the value entierly. There are
698 #plans to enable some level of constant fold disabling, but right
699 #now the language can't function without it. This is merley here
700 #as an exercise to the reader.