File: castle-fpc.cfg

package info (click to toggle)
castle-game-engine 6.4%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 194,520 kB
  • sloc: pascal: 364,585; ansic: 8,606; java: 2,851; objc: 2,601; cpp: 1,412; xml: 851; makefile: 725; sh: 563; php: 26
file content (383 lines) | stat: -rw-r--r-- 11,004 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# -*- mode: shell-script -*-
#
# FPC configuration file for Castle Game Engine.
# Pretty much normal configuration for people that like modern ObjectPascal
# and ObjFpc mode.
#
# Accepts two switches: DEBUG and RELEASE. If you don't define any of them
# debug and optimizing code will be done according to compiler defaults.
# Never define both of them.
#
# Accepts a switch CASTLE_ENGINE_PATHS_ALREADY_DEFINED:
# in this case we will assume that proper -Fu and -Fi, to provide
# paths for FPC to our units, have already been defined.
# This allows to call FPC from any directory (otherwise you have to call
# FPC from this directory, containing castle-fpc.cfg, to make relative paths
# here work).
#
# For alternative, more flexible compilation method use
# tools/build-tool/castle-engine.lpr
# [https://github.com/castle-engine/castle-engine/wiki/Build-Tool] .
#

# output options -------------------------------------------------------------

# Show FPC logo (shows fpc version)
-l

# Show warnings + notes.
# Do not show hints (there are too many useless hints produced by FPC).
-vwn

# Input/output checks always, even in release version.
# Some code may depend on the fact that IO errors in standard Pascal
# functions are checked automatically (and raise exceptions
# if SysUtils is compiled in). Although 99% of code should use TStream
# instead of old Pascal IO, and then this switch doesn't matter.
-Ci

# do not show Warning: (2045) APPTYPE is not supported by the target OS
-vm2045
# do not show Hint: (5024) Parameter "..." not used
-vm5024

# do not show Warning: Symbol "TArrayHelper$1" is experimental
# (only for FPC 3.1.1, for 3.0.x we fix this in our custom Generics.Collections unit)
# TODO: This is a pity, we also hide useful warnings this way.
#IFNDEF VER3_0
-vm05063
#ENDIF

# do not show
# Warning: Constructing a class "TCustomDictionaryEnumerator$4$crc6100464F" with abstract method "GetCurrent"
# Warning: Constructing a class "TCustomDictionaryEnumerator$4$crcBD4794B2" with abstract method "DoMoveNext"
# TODO: This is a pity, we also hide useful warnings this way.
# Submitted as https://bugs.freepascal.org/view.php?id=32142
-vm04046

# syntax options --------------------------------------------------------

# Default syntax mode.
#
# When compiled with FPC, we use ObjFpc mode by default
# (if CASTLE_ENGINE_TEST_DELPHI_MODE not defined, and it's really only for internal
# testing).
#
# Some reasons why we prefer -Mobjfpc (not -Mdelphi mode):
#
# - There are some things strange in delphi mode, for compatibility with delphi/tp,
#   that sometimes bite me (like the fact that in FPC >= 2.0.3
#   Single(Integer) makes a variable typecast, not a value typecast).
#   TODO: check is the above still true?
#
# - ObjFpc has some nice improvements:
#
#   - Assigning procedural variables is better:
#     "@" is required to get an address of a procedure,
#     and assignment is always checked for parameter correctness.
#     In Delphi mode @ may be omitted, and when it's
#     not omitted, you can cheat and pass procedure with not matching params.
#     Using {$TYPEDADDRESS ON} in Delphi (10.2) helps with this
#     (but not in FPC Delphi mode).
#
#   - Overloading without the "overload" keyword is often more sane:
#     It's not cross-class and cross-unit. This allows to hide ancestor
#     methods, while still defining multiple versions of them.
#     It avoids a nasty trap of Delphi "overload" described
#     at TNoParameterlessContructor documentation.
#
#   - Check that method parameter names must differ from class
#     fields/methods/properties names --- this is nice, saves you from some
#     hard to spot bugs otherwise when renaming.
#
# - ObjFpc is preferred by Lazarus, suggested for new source code by Lazarus.

#IFDEF CASTLE_ENGINE_TEST_DELPHI_MODE

-Mdelphi
# Disable macros and C-like operators
-Sm-
-Sc-

#ELSE

-Mobjfpc
# Enable macros
-Sm
# Enable C-like operators +=, -= etc.
-Sc

#ENDIF

# Use ansistrings ("string" = "AnsiString")
-Sh
# Enable inline (although we sometimes surround it in {$ifdef SUPPORTS_INLINE} anyway)
-Si

# units/includes paths --------------------------------------------------

# It seems that FPC does not define symbol UNIX before reading config file,
# even though it defines LINUX (or FREEBSD; I assume that this is also
# the case with DARWIN).
# But I need symbol UNIX *now* to include paths common for all UNIXes.
#IFDEF LINUX
  #DEFINE UNIX
#ENDIF
#IFDEF DARWIN
  #DEFINE UNIX
#ENDIF
#IFDEF FREEBSD
  #DEFINE UNIX
#ENDIF

# Looks like MSWINDOWS symbol needs to be fixed now, just like UNIX above.
#IFDEF WIN32
  #DEFINE MSWINDOWS
#ENDIF
#IFDEF WIN64
  #DEFINE MSWINDOWS
#ENDIF

#IFNDEF CASTLE_ENGINE_PATHS_ALREADY_DEFINED

  # Common paths for all OSes
  -Fusrc/base/
  -Fisrc/base/
  -Fusrc/base/opengl/
  -Fisrc/base/opengl/
  -Fisrc/base/opengl/glsl/
  -Fusrc/fonts/
  -Fisrc/fonts/
  -Fusrc/fonts/opengl/
  -Fisrc/fonts/opengl/
  -Fisrc/opengl/glsl/
  -Fusrc/window/
  -Fisrc/window/
  -Fisrc/window/gtk/
  -Fusrc/images/
  -Fisrc/images/
  -Fusrc/images/opengl/
  -Fisrc/images/opengl/
  -Fisrc/images/opengl/glsl/
  -Fusrc/3d/
  -Fisrc/3d/
  -Fusrc/3d/opengl/
  -Fisrc/3d/opengl/
  -Fusrc/x3d/
  -Fisrc/x3d/
  -Fusrc/x3d/opengl/
  -Fisrc/x3d/opengl/
  -Fisrc/x3d/opengl/glsl/
  -Fusrc/audio/
  -Fisrc/audio/
  -Fusrc/files/
  -Fisrc/files/
  -Fusrc/castlescript/
  -Fisrc/castlescript/
  -Fusrc/ui/
  -Fisrc/ui/
  -Fusrc/ui/opengl/
  -Fisrc/ui/opengl/
  -Fusrc/game/
  -Fisrc/game/
  -Fusrc/services/
  -Fisrc/services/
  -Fusrc/services/opengl/
  -Fisrc/services/opengl/
  -Fusrc/physics/
  -Fisrc/physics/
  -Fusrc/physics/kraft/
  -Fisrc/physics/kraft/

  #IFDEF UNIX
    -Fusrc/base/unix/
    -Fisrc/base/unix/
    -Fusrc/opengl/unix/
    -Fisrc/opengl/unix/
    -Fusrc/window/unix/
    -Fisrc/window/unix/
  #ENDIF

  #IFDEF MSWINDOWS
    -Fusrc/base/windows/
    -Fisrc/base/windows/
    -Fusrc/fonts/windows/
    -Fusrc/opengl/windows/
    -Fisrc/opengl/windows/
    -Fusrc/window/windows/
    -Fisrc/window/windows/
    -Fusrc/ui/windows/
    -Fisrc/ui/windows/
  #ENDIF

  #IFDEF ANDROID
    -Fusrc/base/android/
    -Fisrc/base/android/
  #ENDIF

  # Include local version of Generics.Collections for FPC < 3.1.1
  #IFDEF VER3_0
  -Fusrc/compatibility/generics.collections/src
  #ENDIF
  #IFDEF VER2
  -Fusrc/compatibility/generics.collections/src
  #ENDIF

#ENDIF

# others ---------------------------------------------------------------------

#IFDEF ANDROID
  # See tools/build-tool/toolcompile.pas for more comments about Android options.
  -CpARMV7A
  # Necessary to work fast.
  # It is possible to compile without this (in such case,
  # also compile FPC RTL without this). But the engine will run much slower.
  # See https://github.com/castle-engine/castle-engine/wiki/Android-FAQ#notes-about-compiling-with-hard-floats--cfvfpv3 .
  -CfVFPV3
#ENDIF

# debug specific -------------------------------------------------

#IFDEF DEBUG
  #WRITE Compiling Debug Version

  # range checks
  -Cr
  # overflow checks
  -Co

  # Stack overflow checks.
  #
  # castle fails with stack checking errors on x86-64.
  # Otherwise, works OK, so I guess it's FPC bug.
  # TODO: make testcase and submit. For now, stack checking is not
  # done on x86-64.
  #
  # It also causes failures on Android with pthread in castleandroidnativeappglue.pas.
  #IFNDEF CPUX86_64
  #IFNDEF ANDROID
  -Ct
  #ENDIF
  #ENDIF

  # assertions checks
  -Sa

  # virtual method table checks
  -CR

  # trash local variables (to detect uninitialized uses)
  -gt

  # debug info for gdb and browser.
  -g
  #-bl

  # LineMode unit for backtraces with line info.
  -gl

  # HeapTrc unit to track memory leaks.
  #
  # -gh is not enabled by default, because
  # it produces confusing output when the program exits with
  # exception (like from ProgramBreak) or Halt: it will always show
  # some leaked memory in this case. Indeed, FPC always leaks memory then,
  # this is FPC problem (although harmless, since in this case OS
  # will free this memory anyway).
  #
  # If you understand this, you can (and should) enable -gh and use
  # it to catch memory leaks in your programs.
  # There should be *no* memory leaks from Castle Game Engine
  # when the program exits in a usual fashion.
  #-gh

  # Check pointer validity.
  #
  # -gc is not used by default, because
  #
  # 1.It makes many false errors (when I dereference memory allocated
  #   by other libraries, e.g. libpng or gtk). I'm masking them by
  #
  #     { We dereference here memory allocated with PNG, so pointer checks
  #       will make false errors. }
  #     {$checkpointer off}
  #
  #     ....
  #
  #     {$ifdef KAMBI_CHECK_POINTER}
  #     { Turn checkpointer back on }
  #     {$checkpointer on}
  #     {$endif}
  #
  #   (I need -dKAMBI_CHECK_POINTER for this trick, since {$ifopt checkpointer}
  #   doesn't work.)
  #   But this masking is error prone, so a lot of valid code may still report
  #   false errors. IOW, unless you know what you're doing (and can
  #   recognize false error from a real one in the engine code), don't use -gc.
  #
  # 2.Also, -gc for whole code still makes code much slower.
  #
  # Note that -gc requires -gh because checking pointer
  # validity is part of HeapTrc unit.
  #-gc
  #-dKAMBI_CHECK_POINTER
#ENDIF

# profiling ------------------------------------------------------------------
#
# Profiling options should be used without -dDEBUG,
# -dDEBUG code may be (slightly) slower in (slightly)
# different places because of debug checks (range, overflow, stack checks etc.).
#
# They generally should be used with -dRELEASE, as you want to profile
# program timings experienced by the user, although sometimes -dRELASE may cause
# optimizations that may obfuscate profiler output.
# So sometimes yoy may want to undefine both DEBUG and RELEASE.

# gprof
# -pg

# valgrind
#-gl
#-gv

# release specific -----------------------------------------------

#IFDEF DARWIN
  #IFDEF CPUAARCH64
    #WRITE Disabling FPC optimizations, known to be buggy on Darwin/aarch64
    #DEFINE CASTLE_DISABLE_OPTIMIZATIONS
  #ENDIF
#ENDIF

#IFDEF RELEASE
  #WRITE Compiling Release Version

  # optimize : level 2, faster code
  #IFDEF CASTLE_DISABLE_OPTIMIZATIONS
  -O-
  #ELSE
  -O2
  #ENDIF

  #-OG # obsolete, FPC optimizes for faster code always

  # (Don't optimize for Pentium;
  #  1. there are still some people with older i386 processors ?
  #  2. these Pentium-specific optimizations don't seem to give *any*
  #     real improvement for my code (checked with rayhunter
  #     with FPC 1.0.10;  TODO -- do some speed checks with FPC 2.0.0))
  # Note: remember, if you enable it, wrap it in #IFDEF CPUI386
  # -Op2

  # (smartlink turned off because REALLY slows down compilation
  # and doesn't reduce size of my programs too much)
  #-CX
  #-XX

  # strip symbols from exe (symbols are used only in debugging)
  -Xs
#ENDIF

# eof --------------------------------------------------------------------------