Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(857)

Side by Side Diff: tools/gn.py

Issue 2614493002: GN: Add option to build with TSAN (Closed)
Patch Set: Add an option for MSAN as well Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/tools/gyp/runtime-configurations.gypi ('k') | tools/gyp/all.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The Dart project authors. All rights reserved. 2 # Copyright 2016 The Dart project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import multiprocessing 7 import multiprocessing
8 import os 8 import os
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 gn_args['dart_host_pub_exe'] = "" 83 gn_args['dart_host_pub_exe'] = ""
84 84
85 # We only want the fallback root certs in the standalone VM on 85 # We only want the fallback root certs in the standalone VM on
86 # Linux and Windows. 86 # Linux and Windows.
87 if gn_args['target_os'] in ['linux', 'win']: 87 if gn_args['target_os'] in ['linux', 'win']:
88 gn_args['dart_use_fallback_root_certificates'] = True 88 gn_args['dart_use_fallback_root_certificates'] = True
89 89
90 gn_args['dart_zlib_path'] = "//runtime/bin/zlib" 90 gn_args['dart_zlib_path'] = "//runtime/bin/zlib"
91 91
92 # Use tcmalloc only when targeting Linux and when not using ASAN. 92 # Use tcmalloc only when targeting Linux and when not using ASAN.
93 gn_args['dart_use_tcmalloc'] = (gn_args['target_os'] == 'linux' 93 gn_args['dart_use_tcmalloc'] = ((gn_args['target_os'] == 'linux')
94 and not args.asan) 94 and not args.asan
95 and not args.msan
96 and not args.tsan)
95 97
96 # Force -mfloat-abi=hard and -mfpu=neon on Linux as we're specifying 98 # Force -mfloat-abi=hard and -mfpu=neon on Linux as we're specifying
97 # a gnueabihf compiler in //build/toolchain/linux BUILD.gn. 99 # a gnueabihf compiler in //build/toolchain/linux BUILD.gn.
98 # TODO(zra): This will likely need some adjustment to build for armv6 etc. 100 # TODO(zra): This will likely need some adjustment to build for armv6 etc.
99 hard_float = (gn_args['target_cpu'].startswith('arm') and 101 hard_float = (gn_args['target_cpu'].startswith('arm') and
100 gn_args['target_os'] == 'linux') 102 (gn_args['target_os'] == 'linux'))
101 if hard_float: 103 if hard_float:
102 gn_args['arm_float_abi'] = 'hard' 104 gn_args['arm_float_abi'] = 'hard'
103 gn_args['arm_use_neon'] = True 105 gn_args['arm_use_neon'] = True
104 106
105 gn_args['is_debug'] = mode == 'debug' 107 gn_args['is_debug'] = mode == 'debug'
106 gn_args['is_release'] = mode == 'release' 108 gn_args['is_release'] = mode == 'release'
107 gn_args['is_product'] = mode == 'product' 109 gn_args['is_product'] = mode == 'product'
108 gn_args['dart_debug'] = mode == 'debug' 110 gn_args['dart_debug'] = mode == 'debug'
109 111
110 # This setting is only meaningful for Flutter. Standalone builds of the VM 112 # This setting is only meaningful for Flutter. Standalone builds of the VM
111 # should leave this set to 'develop', which causes the build to defer to 113 # should leave this set to 'develop', which causes the build to defer to
112 # 'is_debug', 'is_release' and 'is_product'. 114 # 'is_debug', 'is_release' and 'is_product'.
113 gn_args['dart_runtime_mode'] = 'develop' 115 gn_args['dart_runtime_mode'] = 'develop'
114 116
115 # TODO(zra): Investigate using clang with these configurations. 117 # TODO(zra): Investigate using clang with these configurations.
116 # Clang compiles tcmalloc's inline assembly for ia32 on Linux wrong, so we 118 # Clang compiles tcmalloc's inline assembly for ia32 on Linux wrong, so we
117 # don't use clang in that configuration. 119 # don't use clang in that configuration. Thus, we use gcc for ia32 *unless*
120 # asan or tsan is specified.
118 has_clang = (host_os != 'win' 121 has_clang = (host_os != 'win'
119 and args.os not in ['android'] 122 and args.os not in ['android']
120 and not (gn_args['target_os'] == 'linux' and
121 gn_args['host_cpu'] == 'x86' and
122 not args.asan) # Use clang for asan builds.
123 and not gn_args['target_cpu'].startswith('arm') 123 and not gn_args['target_cpu'].startswith('arm')
124 and not gn_args['target_cpu'].startswith('mips')) 124 and not gn_args['target_cpu'].startswith('mips')
125 and not ((gn_args['target_os'] == 'linux')
126 and (gn_args['host_cpu'] == 'x86')
127 and not args.asan
128 and not args.msan
129 and not args.tsan)) # Use clang for sanitizer builds.
125 gn_args['is_clang'] = args.clang and has_clang 130 gn_args['is_clang'] = args.clang and has_clang
126 131
127 gn_args['is_asan'] = args.asan and gn_args['is_clang'] 132 gn_args['is_asan'] = args.asan and gn_args['is_clang']
133 gn_args['is_msan'] = args.msan and gn_args['is_clang']
134 gn_args['is_tsan'] = args.tsan and gn_args['is_clang']
128 135
129 # Setup the user-defined sysroot. 136 # Setup the user-defined sysroot.
130 if gn_args['target_os'] == 'linux' and args.wheezy: 137 if gn_args['target_os'] == 'linux' and args.wheezy:
131 gn_args['dart_use_wheezy_sysroot'] = True 138 gn_args['dart_use_wheezy_sysroot'] = True
132 else: 139 else:
133 if args.target_sysroot: 140 if args.target_sysroot:
134 gn_args['target_sysroot'] = args.target_sysroot 141 gn_args['target_sysroot'] = args.target_sysroot
135 142
136 if args.toolchain_prefix: 143 if args.toolchain_prefix:
137 gn_args['toolchain_prefix'] = args.toolchain_prefix 144 gn_args['toolchain_prefix'] = args.toolchain_prefix
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 if host_os.startswith('win'): 214 if host_os.startswith('win'):
208 return '--ide=vs' 215 return '--ide=vs'
209 elif host_os.startswith('mac'): 216 elif host_os.startswith('mac'):
210 return '--ide=xcode' 217 return '--ide=xcode'
211 else: 218 else:
212 return '--ide=json' 219 return '--ide=json'
213 220
214 221
215 # Environment variables for default settings. 222 # Environment variables for default settings.
216 DART_USE_ASAN = "DART_USE_ASAN" 223 DART_USE_ASAN = "DART_USE_ASAN"
224 DART_USE_MSAN = "DART_USE_MSAN"
225 DART_USE_TSAN = "DART_USE_TSAN"
217 DART_USE_WHEEZY = "DART_USE_WHEEZY" 226 DART_USE_WHEEZY = "DART_USE_WHEEZY"
218 227
219 def use_asan(): 228 def use_asan():
220 return DART_USE_ASAN in os.environ 229 return DART_USE_ASAN in os.environ
221 230
231 def use_msan():
232 return DART_USE_MSAN in os.environ
233
234 def use_tsan():
235 return DART_USE_TSAN in os.environ
222 236
223 def use_wheezy(): 237 def use_wheezy():
224 return DART_USE_WHEEZY in os.environ 238 return DART_USE_WHEEZY in os.environ
225 239
226 240
227 def parse_args(args): 241 def parse_args(args):
228 args = args[1:] 242 args = args[1:]
229 parser = argparse.ArgumentParser(description='A script to run `gn gen`.') 243 parser = argparse.ArgumentParser(
244 description='A script to run `gn gen`.',
245 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
246 common_group = parser.add_argument_group('Common Arguments')
247 other_group = parser.add_argument_group('Other Arguments')
230 248
231 parser.add_argument("-v", "--verbose", 249 common_group.add_argument('--arch', '-a',
232 help='Verbose output.',
233 default=False, action="store_true")
234 parser.add_argument('--mode', '-m',
235 type=str,
236 help='Build variants (comma-separated).',
237 metavar='[all,debug,release,product]',
238 default='debug')
239 parser.add_argument('--os',
240 type=str,
241 help='Target OSs (comma-separated).',
242 metavar='[all,host,android]',
243 default='host')
244 parser.add_argument('--arch', '-a',
245 type=str, 250 type=str,
246 help='Target architectures (comma-separated).', 251 help='Target architectures (comma-separated).',
247 metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,' 252 metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,'
248 'simmips,mips,simarm64,arm64,simdbc,armsimdbc]', 253 'simmips,mips,simarm64,arm64,simdbc,armsimdbc]',
249 default='x64') 254 default='x64')
250 parser.add_argument('--asan', 255 common_group.add_argument('--mode', '-m',
256 type=str,
257 help='Build variants (comma-separated).',
258 metavar='[all,debug,release,product]',
259 default='debug')
260 common_group.add_argument('--os',
261 type=str,
262 help='Target OSs (comma-separated).',
263 metavar='[all,host,android]',
264 default='host')
265 common_group.add_argument("-v", "--verbose",
266 help='Verbose output.',
267 default=False, action="store_true")
268
269 other_group.add_argument('--asan',
251 help='Build with ASAN', 270 help='Build with ASAN',
252 default=use_asan(), 271 default=use_asan(),
253 action='store_true') 272 action='store_true')
254 parser.add_argument('--no-asan', 273 other_group.add_argument('--no-asan',
255 help='Disable ASAN', 274 help='Disable ASAN',
256 dest='asan', 275 dest='asan',
257 action='store_false') 276 action='store_false')
258 parser.add_argument('--wheezy', 277 other_group.add_argument('--clang',
278 help='Use Clang',
279 default=True,
280 action='store_true')
281 other_group.add_argument('--no-clang',
282 help='Disable Clang',
283 dest='clang',
284 action='store_false')
285 other_group.add_argument('--goma',
286 help='Use goma',
287 default=True,
288 action='store_true')
289 other_group.add_argument('--no-goma',
290 help='Disable goma',
291 dest='goma',
292 action='store_false')
293 other_group.add_argument('--ide',
294 help='Generate an IDE file.',
295 default=os_has_ide(HOST_OS),
296 action='store_true')
297 other_group.add_argument('--msan',
298 help='Build with MSAN',
299 default=use_msan(),
300 action='store_true')
301 other_group.add_argument('--no-msan',
302 help='Disable MSAN',
303 dest='msan',
304 action='store_false')
305 other_group.add_argument('--target-sysroot', '-s',
306 type=str,
307 help='Path to the toolchain sysroot')
308 other_group.add_argument('--toolchain-prefix', '-t',
309 type=str,
310 help='Path to the toolchain prefix')
311 other_group.add_argument('--tsan',
312 help='Build with TSAN',
313 default=use_tsan(),
314 action='store_true')
315 other_group.add_argument('--no-tsan',
316 help='Disable TSAN',
317 dest='tsan',
318 action='store_false')
319 other_group.add_argument('--wheezy',
259 help='Use the Debian wheezy sysroot on Linux', 320 help='Use the Debian wheezy sysroot on Linux',
260 default=use_wheezy(), 321 default=use_wheezy(),
261 action='store_true') 322 action='store_true')
262 parser.add_argument('--no-wheezy', 323 other_group.add_argument('--no-wheezy',
263 help='Disable the Debian wheezy sysroot on Linux', 324 help='Disable the Debian wheezy sysroot on Linux',
264 dest='wheezy', 325 dest='wheezy',
265 action='store_false') 326 action='store_false')
266 parser.add_argument('--goma', 327 other_group.add_argument('--workers', '-w',
267 help='Use goma',
268 default=True,
269 action='store_true')
270 parser.add_argument('--no-goma',
271 help='Disable goma',
272 dest='goma',
273 action='store_false')
274 parser.add_argument('--clang',
275 help='Use Clang',
276 default=True,
277 action='store_true')
278 parser.add_argument('--no-clang',
279 help='Disable Clang',
280 dest='clang',
281 action='store_false')
282 parser.add_argument('--ide',
283 help='Generate an IDE file.',
284 default=os_has_ide(HOST_OS),
285 action='store_true')
286 parser.add_argument('--target-sysroot', '-s',
287 type=str,
288 help='Path to the toolchain sysroot')
289 parser.add_argument('--toolchain-prefix', '-t',
290 type=str,
291 help='Path to the toolchain prefix')
292 parser.add_argument('--workers', '-w',
293 type=int, 328 type=int,
294 help='Number of simultaneous GN invocations', 329 help='Number of simultaneous GN invocations',
295 dest='workers', 330 dest='workers',
296 default=multiprocessing.cpu_count()) 331 default=multiprocessing.cpu_count())
297 332
298 options = parser.parse_args(args) 333 options = parser.parse_args(args)
299 if not process_options(options): 334 if not process_options(options):
300 parser.print_help() 335 parser.print_help()
301 return None 336 return None
302 return options 337 return options
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return 1 388 return 1
354 389
355 endtime = time.time() 390 endtime = time.time()
356 if args.verbose: 391 if args.verbose:
357 print ("GN Time: %.3f seconds" % (endtime - starttime)) 392 print ("GN Time: %.3f seconds" % (endtime - starttime))
358 return 0 393 return 0
359 394
360 395
361 if __name__ == '__main__': 396 if __name__ == '__main__':
362 sys.exit(main(sys.argv)) 397 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « runtime/tools/gyp/runtime-configurations.gypi ('k') | tools/gyp/all.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698