]> git.xonotic.org Git - xonotic/gmqcc.git/blob - gmqcc.ini.example
Fix QuakeWorld compilation by treating assignment to constants as a warning when...
[xonotic/gmqcc.git] / gmqcc.ini.example
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.
4
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.
10
11 [flags]
12     #Add some additional characters to the string table in order to
13     #compensate for a wrong boundcheck in some specific version of the
14     #darkplaces engine.
15
16     DARKPLACES_STRING_TABLE_BUG = true
17
18
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.
25
26     ADJUST_VECTOR_FIELDS = true
27
28
29     #Enable a partially fteqcc-compatible preprocessor. It supports
30     #all the features used in the Xonotic codebase. If you need more,
31     #write a ticket.
32
33     FTEPP = true
34
35
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:
39     #
40     #   __LINE__
41     #   __FILE__
42     #   __COUNTER__
43     #   __COUNTER_LAST__
44     #   __RANDOM__
45     #   __RANDOM_LAST__
46     #   __DATE__
47     #   __TIME__
48     #   __FUNC__
49     #
50     #Note that __FUNC__ is not actually a preprocessor macro, but is
51     #recognized by the parser even with the preprocessor disabled.
52     #
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.
61
62     FTEPP_PREDEFS = false
63
64
65     #Allow switch cases to use non constant variables.
66
67     RELAXED_SWITCH = true
68
69
70     #Perform early out in logical AND and OR expressions. The final
71     #result will be either a 0 or a 1, see the next flag for more pos‐
72     #sibilities.
73
74     SHORT_LOGIC = true
75
76
77     #In many languages, logical expressions perform early out in a
78     #special way: If the left operand of an AND yeilds true, or the
79     #one of an OR yields false, the complete expression evaluates to
80     #the right side.  Thus ‘true && 5’ evaluates to 5 rather than 1.
81
82     PERL_LOGIC = false
83
84
85     #Enable the underscore intrinsic: Using ‘_("A string constant")’
86     #will cause the string immediate to get a name with a "dotrans‐
87     #late_" prefix. The darkplaces engine recognizes these and trans‐
88     #lates them in a way similar to how gettext works.
89
90     TRANSLATABLE_STRINGS = true
91
92
93     #Don't implicitly convert initialized variables to constants. With
94     #this flag, the const keyword is required to make a constant.
95
96     INITIALIZED_NONCONSTANTS = false
97
98
99     #If this flag is not set, (and it is set by default in the qcc and
100     #fteqcc standards), assigning function pointers of mismatching
101     #signatures will result in an error rather than a warning.
102
103     ASSIGN_FUNCTION_TYPES = true
104
105
106     #Produce a linenumber file along with the output .dat file.
107
108     LNO = false
109
110
111     #Use C's operator precedence for ternary expressions. Unless your
112     #code depends on fteqcc-compatible behaviour, you'll want to use
113     #this option.
114
115     CORRECT_TERNARY = true
116
117
118     #Normally vectors generate 4 defs, once for the vector, and once
119     #for its components with _x, _y, _z suffixes. This option prevents
120     #components from being listed.
121
122
123     SINGLE_VECTOR_DEFS = true
124
125
126     #Most QC compilers translate ‘if(a_vector)’ directly as an IF on
127     #the vector, which means only the x-component is checked. This
128     #option causes vectors to be cast to actual booleans via a NOT_V
129     #and, if necessary, a NOT_F chained to it.
130     #
131     #   if (a_vector) // becomes
132     #   if not(!a_vector)
133     #   // likewise
134     #   a = a_vector && a_float // becomes
135     #   a = !!a_vector && a_float
136
137     CORRECT_LOGIC = true
138
139
140     #An empty string is considered to be true everywhere. The NOT_S
141     #instruction usually considers an empty string to be false, this
142     #option effectively causes the unary not in strings to use NOT_F
143     #instead.
144
145     TRUE_EMPTY_STRINGS = false
146
147
148     #An empty string is considered to be false everywhere. This means
149     #loops and if statements which depend on a string will perform a
150     #NOT_S instruction on the string before using it.
151
152     FALSE_EMPTY_STRINGS = true
153
154
155     #Enable utf8 characters. This allows utf-8 encoded character con‐
156     #stants, and escape sequence codepoints in the valid utf-8 range.
157     #Effectively enabling escape sequences like '\{x2211}'.
158
159     UTF8 = true
160
161
162     #When a warning is treated as an error, and this option is set
163     #(which it is by default), it is like any other error and will
164     #cause compilation to stop. When disabling this flag by using
165     #-fno-bail-on-werror, compilation will continue until the end, but
166     #no output is generated. Instead the first such error message's
167     #context is shown.
168
169     BAIL_ON_WERROR = false
170
171
172     #Allow loops to be labeled, and allow 'break' and 'continue' to
173     #take an optional label to decide which loop to actually jump out
174     #of or continue.
175     #
176     #   for :outer (i = 0; i < n; ++i) {
177     #       while (inner) {
178     #           ...;
179     #           if (something)
180     #               continue outer;
181     #       }
182     #   }
183
184     LOOP_LABELS = true
185
186
187     #Adds a global named 'nil' which is of no type and can be assigned
188     #to anything. No typechecking will be performed on assignments.
189     #Assigning to it is forbidden, using it in any other kind of
190     #expression is also not allowed.
191     #
192     #Note that this is different from fteqcc's __NULL__: In fteqcc,
193     #__NULL__ maps to the integer written as '0i'. It's can be
194     #assigned to function pointers and integers, but it'll error about
195     #invalid instructions when assigning it to floats without enabling
196     #the FTE instruction set. There's also a bug which allows it to be
197     #assigned to vectors, for which the source will be the global at
198     #offset 0, meaning the vector's y and z components will contain
199     #the OFS_RETURN x and y components.#
200     #
201     #In that gmqcc the nil global is an actual global filled with
202     #zeroes, and can be assigned to anything including fields, vectors
203     #or function pointers, and they end up becoming zeroed.
204
205
206     UNTYPED_NIL = true
207
208
209     #Various effects, usually to weaken some conditions.
210     #   with -funtyped-nil
211     #       Allow local variables named ‘nil’.  (This will not
212     #       allow declaring a global of that name.)
213
214     PERMISSIVE = false
215
216
217     #Allow variadic parameters to be accessed by QC code. This can be
218     #achieved via the '...' function, which takes a parameter index
219     #and a typename.
220     #
221     #Example:
222     #
223     #   void vafunc(string...count) {
224     #       float i;
225     #       for (i = 0; i < count; ++i)
226     #           print(...(i, string), "\n");
227     #   }
228
229     VARIADIC_ARGS = true
230
231
232     #Most Quake VMs, including the one from FTEQW or up till recently
233     #Darkplaces, do not cope well with vector instructions with over‐
234     #lapping input and output. This option will avoid producing such
235     #code.
236
237     LEGACY_VECTOR_MATHS = false
238
239
240     #Usually builtin-numbers are just immediate constants. With this
241     #flag expressions can be used, as long as they are compile-time
242     #constant.
243     #
244     #Example:
245     #
246     #   void printA() = #1;   // the usual way
247     #   void printB() = #2-1; // with a constant expression
248
249     EXPRESSIONS_FOR_BUILTINS = true
250
251
252     #Enabiling this option will allow assigning values or expressions
253     #to the return keyword as if it were a local variable of the same
254     #type as the function's signature's return type.
255     #
256     #Example:
257     #
258     #   float bar() { return 1024; }
259     #   float fun() {
260     #       return = bar();
261     #       return; // returns value of bar (this can be omitted)
262     #   }
263
264     RETURN_ASSIGNMENTS = true
265
266
267     #When passing on varargs to a different functions, this turns some
268     #static error cases into warnings. Like when the caller's varargs
269     #are restricted to a different type than the callee's parameter.
270     #Or a list of unrestricted varargs is passed into restricted
271     #varargs.
272
273     UNSAFE_VARARGS = false
274
275
276     #Always use STORE_F, LOAD_F, STOREP_F when accessing scalar variables.
277     #This is somewhat incorrect assembly instruction use, but in all engines
278     #they do exactly the same. This makes disassembly output harder to read,
279     #breaks decompilers, but causes the output file to be better compressible.
280
281     TYPELESS_STORES = false
282
283
284     #In commutative instructions, always put the lower-numbered operand first.
285     #This shaves off 1 byte of entropy from all these instructions, reducing
286     #compressed size of the output file.
287
288     SORT_OPERANDS = false
289
290
291
292 [warnings]
293     #Generate a warning about variables which are declared but never
294     #used.  This can be avoided by adding the ‘noref’ keyword in front
295     #of the variable declaration. Additionally a complete section of
296     #unreferenced variables can be opened using ‘#pragma noref 1’ and
297     #closed via ‘#pragma noref 0’.
298
299     UNUSED_VARIABLE = false
300
301
302     #Generate a warning if it is possible that a variable can be used
303     #without prior initialization. Note that this warning is not nec‐
304     #essarily reliable if the initialization happens only under cer‐
305     #tain conditions. The other way is not possible: that the warning
306     #is not generated when uninitialized use is possible.
307
308     USED_UNINITIALIZED = false
309
310
311     #Generate an error when an unrecognized control sequence in a
312     #string is used. Meaning: when there's a character after a back‐
313     #slash in a string which has no known meaning.
314
315     UNKNOWN_CONTROL_SEQUENCE = false
316
317
318     #Warn when using special extensions which are not part of the
319     #selected standard.
320
321     EXTENSIONS = false
322
323
324     #Generally QC compilers ignore redeclaration of fields. Here you
325     #can optionally enable a warning.
326
327     FIELD_REDECLARED = false
328
329
330     #Functions which aren't of type void will warn if it possible to
331     #reach the end without returning an actual value.
332
333     MISSING_RETURN_VALUES = false
334
335
336     #Warn about a function call with an invalid number of parameters.
337
338     INVALID_PARAMETER_COUNT = false
339
340
341     #Warn when a locally declared variable shadows variable.
342
343     LOCAL_SHADOWS = false
344
345
346     #Warn when the initialization of a local variable turns the vari‐
347     #able into a constant. This is default behaviour unless
348     #-finitialized-nonconstants is used.
349
350     LOCAL_CONSTANTS = false
351
352
353     #There are only 2 known global variables of type void:
354     #‘end_sys_globals’ and ‘end_sys_fields’.  Any other void-variable
355     #will warn.
356
357     VOID_VARIABLES = false
358
359
360     #A global function which is not declared with the ‘var’ keyword is
361     #expected to have an implementing body, or be a builtin. If nei‐
362     #ther is the case, it implicitly becomes a function pointer, and a
363     #warning is generated.
364
365     IMPLICIT_FUNCTION_POINTER = false
366
367
368     #Currently there's no way for an in QC implemented function to
369     #access variadic parameters. If a function with variadic parame‐
370     #ters has an implementing body, a warning will be generated.
371
372     VARIADIC_FUNCTION = false
373
374
375     #Generate warnings about ‘$frame’ commands, for instance about
376     #duplicate frame definitions.
377
378     FRAME_MACROS = false
379
380
381     #Warn about statements which have no effect. Any expression which
382     #does not call a function or assigns a variable.
383
384     EFFECTLESS_STATEMENT = false
385
386
387     #The ‘end_sys_fields’ variable is supposed to be a global variable
388     #of type void.  It is also recognized as a field but this will
389     #generate a warning.
390
391     END_SYS_FIELDS = false
392
393
394     #Warn when assigning to a function pointer with an unmatching sig‐
395     #nature. This usually happens in cases like assigning the null
396     #function to an entity's .think function pointer.
397
398     ASSIGN_FUNCTION_TYPES = false
399
400
401     #Show warnings created using the preprocessor's '#warning' directive
402
403     CPP = true
404
405
406     #Warn if there's a preprocessor #if spanning across several files.
407
408     MULTIFILE_IF = true
409
410
411     #Warn about multiple declarations of globals. This seems pretty
412     #common in QC code so you probably do not want this unless you
413     #want to clean up your code.
414
415     DOUBLE_DECLARATION = false
416
417
418     #The combination of const and var is not illegal, however differ‐
419     #ent compilers may handle them differently. We were told, the
420     #intention is to create a function-pointer which is not assigna‐
421     #ble.  This is exactly how we interpret it. However for this
422     #interpretation the ‘var’ keyword is considered superfluous (and
423     #philosophically wrong), so it is possible to generate a warning
424     #about this.
425
426     CONST_VAR = true
427
428
429     #Warn about multibyte character constants, they do not work right
430     #now.
431
432     MULTIBYTE_CHARACTER = false
433
434
435     #Warn if a ternary expression which contains a comma operator is
436     #used without enclosing parenthesis, since this is most likely not
437     #what you actually want. We recommend the -fcorrect-ternary
438     #option.
439
440     TERNARY_PRECEDENCE = false
441
442
443     #Warn when encountering an unrecognized ‘#pragma’ line.
444
445     UNKNOWN_PRAGMAS = true
446
447
448     #Warn about unreachable code. That is: code after a return state‐
449     #ment, or code after a call to a function marked as 'noreturn'.
450
451     UNREACHABLE_CODE = true
452
453
454     #Enable some warnings added in order to help debugging in the com‐
455     #piler.  You won't need this.
456
457     DEBUG = false
458
459
460     #Warn on an unknown attribute. The warning will inlclude only the
461     #first token inside the enclosing attribute-brackets. This may
462     #change when the actual attribute syntax is better defined.
463
464     UNKNOWN_ATTRIBUTE = true
465
466
467     #Warn when using reserved names such as ‘nil’.
468
469     RESERVED_NAMES = true
470
471
472     #Warn about global constants (using the ‘const’ keyword) with no
473     #assigned value.
474
475     UNINITIALIZED_CONSTANT = true
476
477
478     #Warn about global variables with no initializing value. This is
479     #off by default, and is added mostly to help find null-values
480     #which are supposed to be replaced by the untyped 'nil' constant.
481
482     UNINITIALIZED_GLOBAL = true
483
484
485     #Warn when a variables is redeclared with a different qualifier.
486     #For example when redeclaring a variable as 'var' which was previ‐
487     #ously marked 'const'.
488
489     DIFFERENT_QUALIFIERS = true
490
491
492     #Similar to the above but for attributes like ‘[[noreturn]]’.
493
494     DIFFERENT_ATTRIBUTES = true
495
496
497     #Warn when a function is marked with the attribute "[[depre‐
498     #cated]]". This flag enables a warning on calls to functions
499     #marked as such.
500
501     DEPRECATED = true
502
503
504     #Warn about possible mistakes caused by missing or wrong parenthe‐
505     #sis, like an assignment in an 'if' condition when there's no
506     #additional set of parens around the assignment.
507
508     PARENTHESIS = true
509
510
511     #When passing variadic parameters via ...(N) it can happen that
512     #incompatible types are passed to functions. This enables several
513     #warnings when static typechecking cannot guarantee consistent
514     #behavior.
515
516     UNSAFE_TYPES = true
517
518
519     #When compiling original id1 QC there is a definition for `break`
520     #which conflicts with the 'break' keyword in GMQCC. Enabling this
521     #print a warning when the definition occurs. The definition is
522     #ignored for both cases.
523
524     BREAKDEF = true
525
526
527     #When compiling original QuakeWorld QC there are instances where
528     #code overwrites constants. This is considered an error, however
529     #for QuakeWorld to compile it needs to be treated as a warning
530     #instead, as such this warning only works when -std=qcc.
531
532     CONST_OVERWRITE = true
533
534 [optimizations]
535     #Some general peephole optimizations. For instance the code `a = b
536     #+ c` typically generates 2 instructions, an ADD and a STORE. This
537     #optimization removes the STORE and lets the ADD write directly
538     #into A.
539
540     PEEPHOLE = true
541
542
543     #Tail recursive function calls will be turned into loops to avoid
544     #the overhead of the CALL and RETURN instructions.
545
546     TAIL_RECURSION = true
547
548
549     #Make all functions which use neither local arrays nor have locals
550     #which are seen as possibly uninitialized use the same local sec‐
551     #tion.  This should be pretty safe compared to other compilers
552     #which do not check for uninitialized values properly. The problem
553     #is that there's QC code out there which really doesn't initialize
554     #some values. This is fine as long as this kind of optimization
555     #isn't used, but also, only as long as the functions cannot be
556     #called in a recursive manner. Since it's hard to know whether or
557     #not an array is actually fully initialized, especially when ini‐
558     #tializing it via a loop, we assume functions with arrays to be
559     #too dangerous for this optimization.
560
561     OVERLAP_LOCALS = true
562
563
564
565     #This promotes locally declared variables to "temps". Meaning when
566     #a temporary result of an operation has to be stored somewhere, a
567     #local variable which is not 'alive' at that point can be used to
568     #keep the result. This can reduce the size of the global section.
569     #This will not have declared variables overlap, even if it was
570     #possible.
571
572     LOCAL_TEMPS = true
573
574
575     #Causes temporary values which do not need to be backed up on a
576     #CALL to not be stored in the function's locals-area. With this, a
577     #CALL to a function may need to back up fewer values and thus exe‐
578     #cute faster.
579
580     GLOBAL_TEMPS = true
581
582
583     #Don't generate defs for immediate values or even declared con‐
584     #stants.  Meaning variables which are implicitly constant or qual‐
585     #ified as such using the 'const' keyword.
586
587     STRIP_CONSTANT_NAMES = true
588
589
590     #Aggressively reuse strings in the string section. When a string
591     #should be added which is the trailing substring of an already
592     #existing string, the existing string's tail will be returned
593     #instead of the new string being added.
594     #
595     #For example the following code will only generate 1 string:
596     #
597     #   print("Hello you!\n");
598     #   print("you!\n"); // trailing substring of "Hello you!\n"
599     #
600     #There's however one limitation. Strings are still processed in
601     #order, so if the above print statements were reversed, this opti‐
602     #mization would not happen.
603
604     OVERLAP_STRINGS = true
605
606
607     #By default, all parameters of a CALL are copied into the parame‐
608     #ter-globals right before the CALL instructions. This is the easi‐
609     #est and safest way to translate calls, but also adds a lot of
610     #unnecessary copying and unnecessary temporary values. This opti‐
611     #mization makes operations which are used as a parameter evaluate
612     #directly into the parameter-global if that is possible, which is
613     #when there's no other CALL instruction in between.
614
615     CALL_STORES = true
616
617
618     #Usually an empty RETURN instruction is added to the end of a void
619     #typed function. However, additionally after every function a DONE
620     #instruction is added for several reasons. (For example the qcvm's
621     #disassemble switch uses it to know when the function ends.). This
622     #optimization replaces that last RETURN with DONE rather than
623     #adding the DONE additionally.
624
625     VOID_RETURN = true
626
627
628     #Because traditional QC code doesn't allow you to access individ‐
629     #ual vector components of a computed vector without storing it in
630     #a local first, sometimes people multiply it by a constant like
631     #‘'0 1 0'’ to get, in this case, the y component of a vector. This
632     #optimization will turn such a multiplication into a direct compo‐
633     #nent access. If the factor is anything other than 1, a float-mul‐
634     #tiplication will be added, which is still faster than a vector
635     #multiplication.
636
637     VECTOR_COMPONENTS = true
638
639
640     #For constant expressions that result in dead code (such as a
641     #branch whos condition can be evaluated at compile-time), this
642     #will eliminate the branch and else body (if present) to produce
643     #more optimal code.
644
645     CONST_FOLD_DCE = true
646
647     #For constant expressions we can fold them to immediate values.
648     #this option cannot be disabled or enabled, the compiler forces
649     #it to stay enabled by ignoring the value entierly. There are
650     #plans to enable some level of constant fold disabling, but right
651     #now the language can't function without it. This is merley here
652     #as an exercise to the reader.
653
654     CONST_FOLD = true