|
30 | 30 | } |
31 | 31 | ''' |
32 | 32 |
|
33 | | -VALID_BUILD_TYPES = ['fastnative', 'fast', 'humanrights', 'debug', 'sanitize', 'msan', 'none'] |
| 33 | +VALID_BUILD_TYPES = ['fastnative', 'fast', 'humanrights', 'debug', 'sanitize', 'msan', 'asan', 'none'] |
34 | 34 |
|
35 | 35 | LINKFLAGS = { |
36 | 36 | 'common': { |
|
42 | 42 | 'clang': ['-fsanitize=memory', '-pthread'], |
43 | 43 | 'default': ['NO_MSAN_HERE'] |
44 | 44 | }, |
| 45 | + 'asan': { |
| 46 | + 'clang': ['-fsanitize=address', '-pthread'], |
| 47 | + 'gcc': ['-fsanitize=address', '-pthread'], |
| 48 | + 'msvc': ['/SAFESEH:NO'] |
| 49 | + }, |
45 | 50 | 'sanitize': { |
46 | 51 | 'clang': ['-fsanitize=undefined', '-fsanitize=address', '-pthread'], |
47 | 52 | 'gcc': ['-fsanitize=undefined', '-fsanitize=address', '-pthread'], |
|
56 | 61 | 'common': { |
57 | 62 | # disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP |
58 | 63 | 'msvc': ['/D_USING_V110_SDK71_', '/FS', '/Zc:threadSafeInit-', '/MT', '/MP', '/Zc:__cplusplus'], |
59 | | - 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden', '-fno-threadsafe-statics'], |
60 | | - 'gcc': ['-g', '-fvisibility=hidden'], |
| 64 | + 'clang': ['-g', '-gdwarf-2', '-fvisibility=hidden', '-fno-threadsafe-statics', '-fasynchronous-unwind-tables'], |
| 65 | + 'gcc': ['-g', '-fvisibility=hidden', '-fasynchronous-unwind-tables'], |
61 | 66 | 'owcc': ['-fno-short-enum', '-ffloat-store', '-g3'] |
62 | 67 | }, |
63 | 68 | 'fast': { |
|
95 | 100 | 'clang': ['-O2', '-g', '-fno-omit-frame-pointer', '-fsanitize=memory', '-pthread'], |
96 | 101 | 'default': ['NO_MSAN_HERE'] |
97 | 102 | }, |
| 103 | + 'asan': { |
| 104 | + 'msvc': ['/Od', '/RTC1', '/Zi', '/fsanitize=address'], |
| 105 | + 'gcc': ['-Og', '-fsanitize=address', '-pthread'], |
| 106 | + 'clang': ['-Og', '-fsanitize=address', '-pthread'], |
| 107 | + 'default': ['-O0'] |
| 108 | + }, |
98 | 109 | 'sanitize': { |
99 | 110 | 'msvc': ['/Od', '/RTC1', '/Zi', '/fsanitize=address'], |
100 | 111 | 'gcc': ['-O0', '-fsanitize=undefined', '-fsanitize=address', '-pthread'], |
@@ -166,6 +177,9 @@ def options(opt): |
166 | 177 | grp.add_option('--enable-profile', action = 'store_true', dest = 'PROFILE_GENERATE', default = False, |
167 | 178 | help = 'enable profile generating build (stored in xash3d-prof directory) [default: %(default)s]') |
168 | 179 |
|
| 180 | + grp.add_option('--enable-limited-debuginfo', action = 'store_true', dest = 'LIMITED_DEBUGINFO', default = False, |
| 181 | + help = 'only save line debuginfo, useful for release builds [default: %(default)s]') |
| 182 | + |
169 | 183 | grp.add_option('--use-profile', action = 'store', dest = 'PROFILE_USE', default = None, |
170 | 184 | help = 'use profile during build [default: %(default)s]') |
171 | 185 |
|
@@ -229,21 +243,31 @@ def get_optimization_flags(conf): |
229 | 243 | linkflags+= [conf.get_flags_by_compiler(PROFILE_USE_LINKFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE] |
230 | 244 | cflags += [conf.get_flags_by_compiler(PROFILE_USE_CFLAGS, conf.env.COMPILER_CC)[0] % conf.options.PROFILE_USE] |
231 | 245 |
|
232 | | - if conf.env.DEST_OS == 'nswitch' and conf.options.BUILD_TYPE == 'debug': |
233 | | - # enable remote debugger |
234 | | - cflags.append('-DNSWITCH_DEBUG') |
| 246 | + if conf.env.DEST_OS == 'nswitch': |
| 247 | + if conf.options.BUILD_TYPE == 'debug': |
| 248 | + # enable remote debugger |
| 249 | + cflags.append('-DNSWITCH_DEBUG') |
| 250 | + # this port don't have stack printing support |
| 251 | + cflags.remove('-fasynchronous-unwind-tables') |
235 | 252 | elif conf.env.DEST_OS == 'psvita': |
236 | 253 | # this optimization is broken in vitasdk |
237 | 254 | cflags.append('-fno-optimize-sibling-calls') |
238 | 255 | # remove fvisibility to allow everything to be exported by default |
239 | 256 | cflags.remove('-fvisibility=hidden') |
| 257 | + # this port don't have stack printing support |
| 258 | + cflags.remove('-fasynchronous-unwind-tables') |
240 | 259 |
|
241 | | - if conf.env.COMPILER_CC != 'msvc' and conf.env.COMPILER_CC != 'owcc': |
| 260 | + if conf.env.COMPILER_CC in ['gcc', 'clang'] and conf.options.LIMITED_DEBUGINFO: |
| 261 | + # probably not a good idea to do this, but it should save space on Android builds especially |
| 262 | + # that are never going to be run under debugger, but we still want that readable fileline |
| 263 | + # info in backtraces |
| 264 | + # might enable this for release/fast/fastnative builds in the future |
| 265 | + cflags = ['-gline-tables-only' if flag.startswith('-g') else flag for flag in cflags] |
| 266 | + |
| 267 | + if conf.env.COMPILER_CC in ['gcc', 'clang'] and conf.env.DEST_OS not in ['android']: |
242 | 268 | # HLSDK by default compiles with these options under Linux |
243 | 269 | # no reason for us to not do the same |
244 | | - |
245 | | - # TODO: fix DEST_CPU in force 32 bit mode |
246 | | - if conf.env.DEST_CPU == 'x86' or (conf.env.DEST_CPU == 'x86_64' and conf.env.DEST_SIZEOF_VOID_P == 4): |
| 270 | + if conf.env.DEST_CPU == 'x86': |
247 | 271 | cflags.append('-march=pentium-m') |
248 | 272 | cflags.append('-mtune=core2') |
249 | 273 |
|
|
0 commit comments