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

Side by Side Diff: build/config/BUILDCONFIG.gn

Issue 1324623005: Move sanitizer and symbol flags out of BUILDCONFIG (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « base/BUILD.gn ('k') | build/config/compiler/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # ============================================================================= 5 # =============================================================================
6 # PLATFORM SELECTION 6 # PLATFORM SELECTION
7 # ============================================================================= 7 # =============================================================================
8 # 8 #
9 # There are two main things to set: "os" and "cpu". The "toolchain" is the name 9 # There are two main things to set: "os" and "cpu". The "toolchain" is the name
10 # of the GN thing that encodes combinations of these things. 10 # of the GN thing that encodes combinations of these things.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for 104 # - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for
105 # your feature) rather than just "foo". 105 # your feature) rather than just "foo".
106 # 106 #
107 # - Write good comments directly above the declaration with no blank line. 107 # - Write good comments directly above the declaration with no blank line.
108 # These comments will appear as documentation in "gn args --list". 108 # These comments will appear as documentation in "gn args --list".
109 # 109 #
110 # - Don't call exec_script inside declare_args. This will execute the script 110 # - Don't call exec_script inside declare_args. This will execute the script
111 # even if the value is overridden, which is wasteful. See first bullet. 111 # even if the value is overridden, which is wasteful. See first bullet.
112 112
113 declare_args() { 113 declare_args() {
114 # How many symbols to include in the build. This affects the performance of
115 # the build since the symbols are large and dealing with them is slow.
116 # 2 means regular build with symbols.
117 # 1 means minimal symbols, usually enough for backtraces only.
118 # 0 means no symbols.
119 # -1 means auto-set (off in release, regular in debug).
120 symbol_level = -1
121
122 # Component build. 114 # Component build.
123 is_component_build = false 115 is_component_build = false
124 116
125 # Debug build. 117 # Debug build.
126 is_debug = true 118 is_debug = true
127 119
128 # Whether we're a traditional desktop unix. 120 # Whether we're a traditional desktop unix.
129 is_desktop_linux = current_os == "linux" && current_os != "chromeos" 121 is_desktop_linux = current_os == "linux" && current_os != "chromeos"
130 122
131 # Set to true when compiling with the Clang compiler. Typically this is used 123 # Set to true when compiling with the Clang compiler. Typically this is used
132 # to configure warnings. 124 # to configure warnings.
133 is_clang = current_os == "mac" || current_os == "ios" || 125 is_clang = current_os == "mac" || current_os == "ios" ||
134 current_os == "linux" || current_os == "chromeos" 126 current_os == "linux" || current_os == "chromeos"
135 127
136 # Compile for Address Sanitizer to find memory bugs.
137 is_asan = false
138
139 # Compile for Leak Sanitizer to find leaks.
140 is_lsan = false
141
142 # Compile for Memory Sanitizer to find uninitialized reads.
143 is_msan = false
144
145 # Compile for Thread Sanitizer to find threading bugs.
146 is_tsan = false
147
148 if (current_os == "chromeos") { 128 if (current_os == "chromeos") {
149 # Allows the target toolchain to be injected as arguments. This is needed 129 # Allows the target toolchain to be injected as arguments. This is needed
150 # to support the CrOS build system which supports per-build-configuration 130 # to support the CrOS build system which supports per-build-configuration
151 # toolchains. 131 # toolchains.
152 cros_use_custom_toolchain = false 132 cros_use_custom_toolchain = false
153 } 133 }
154 134
155 # DON'T ADD MORE FLAGS HERE. Read the comment above. 135 # DON'T ADD MORE FLAGS HERE. Read the comment above.
156 } 136 }
157 137
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 # across many projects in the tree. 329 # across many projects in the tree.
350 # 330 #
351 # Therefore, we only add rules to this list corresponding to platforms on the 331 # Therefore, we only add rules to this list corresponding to platforms on the
352 # Chromium waterfall. This is not for non-officially-supported platforms 332 # Chromium waterfall. This is not for non-officially-supported platforms
353 # (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases, 333 # (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases,
354 # write a conditional in the target to remove the file(s) from the list when 334 # write a conditional in the target to remove the file(s) from the list when
355 # your platform/toolkit/feature doesn't apply. 335 # your platform/toolkit/feature doesn't apply.
356 set_sources_assignment_filter(sources_assignment_filter) 336 set_sources_assignment_filter(sources_assignment_filter)
357 337
358 # ============================================================================= 338 # =============================================================================
359 # BUILD OPTIONS
360 # =============================================================================
361
362 # These Sanitizers all imply using the Clang compiler. On Windows they either
363 # don't work or work differently.
364 if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) {
365 is_clang = true
366 }
367
368 # =============================================================================
369 # TARGET DEFAULTS 339 # TARGET DEFAULTS
370 # ============================================================================= 340 # =============================================================================
371 # 341 #
372 # Set up the default configuration for every build target of the given type. 342 # Set up the default configuration for every build target of the given type.
373 # The values configured here will be automatically set on the scope of the 343 # The values configured here will be automatically set on the scope of the
374 # corresponding target. Target definitions can add or remove to the settings 344 # corresponding target. Target definitions can add or remove to the settings
375 # here as needed. 345 # here as needed.
376 346
377 # Holds all configs used for making native executables and libraries, to avoid 347 # Holds all configs used for making native executables and libraries, to avoid
378 # duplication in each target below. 348 # duplication in each target below.
379 _native_compiler_configs = [ 349 _native_compiler_configs = [
380 "//build/config:feature_flags", 350 "//build/config:feature_flags",
381 "//build/config/compiler:compiler", 351 "//build/config/compiler:compiler",
382 "//build/config/compiler:compiler_arm_fpu", 352 "//build/config/compiler:compiler_arm_fpu",
383 "//build/config/compiler:chromium_code", 353 "//build/config/compiler:chromium_code",
384 "//build/config/compiler:default_include_dirs", 354 "//build/config/compiler:default_include_dirs",
355 "//build/config/compiler:default_optimization",
356 "//build/config/compiler:default_symbols",
385 "//build/config/compiler:no_rtti", 357 "//build/config/compiler:no_rtti",
386 "//build/config/compiler:runtime_library", 358 "//build/config/compiler:runtime_library",
387 ] 359 ]
388 if (is_win) { 360 if (is_win) {
389 _native_compiler_configs += [ 361 _native_compiler_configs += [
390 "//build/config/win:lean_and_mean", 362 "//build/config/win:lean_and_mean",
391 "//build/config/win:nominmax", 363 "//build/config/win:nominmax",
392 "//build/config/win:sdk", 364 "//build/config/win:sdk",
393 "//build/config/win:unicode", 365 "//build/config/win:unicode",
394 "//build/config/win:winver", 366 "//build/config/win:winver",
(...skipping 20 matching lines...) Expand all
415 _native_compiler_configs += [ "//build/config/android:sdk" ] 387 _native_compiler_configs += [ "//build/config/android:sdk" ]
416 } 388 }
417 389
418 if (is_clang && !is_nacl) { 390 if (is_clang && !is_nacl) {
419 _native_compiler_configs += [ 391 _native_compiler_configs += [
420 "//build/config/clang:find_bad_constructs", 392 "//build/config/clang:find_bad_constructs",
421 "//build/config/clang:extra_warnings", 393 "//build/config/clang:extra_warnings",
422 ] 394 ]
423 } 395 }
424 396
425 # Optimizations and debug checking. 397 # Optimizations and debug checking.
Dirk Pranke 2015/09/04 22:32:26 it seems like this comment might be a bit confusin
brettw 2015/09/04 23:36:24 Done.
426 if (is_debug) { 398 if (is_debug) {
427 _native_compiler_configs += [ "//build/config:debug" ] 399 _native_compiler_configs += [ "//build/config:debug" ]
428 _default_optimization_config = "//build/config/compiler:no_optimize"
429 } else { 400 } else {
430 _native_compiler_configs += [ "//build/config:release" ] 401 _native_compiler_configs += [ "//build/config:release" ]
431 _default_optimization_config = "//build/config/compiler:optimize"
432 } 402 }
433 _native_compiler_configs += [ _default_optimization_config ]
434
435 # If it wasn't manually set, set to an appropriate default.
436 if (symbol_level == -1) {
437 # Linux is slowed by having symbols as part of the target binary, whereas
438 # Mac and Windows have them separate, so in Release Linux, default them off.
439 if (is_debug || !is_linux) {
440 symbol_level = 2
441 } else if (is_asan || is_lsan || is_tsan || is_msan) {
442 # Sanitizers require symbols for filename suppressions to work.
443 symbol_level = 1
444 } else {
445 symbol_level = 0
446 }
447 }
448
449 # Symbol setup.
450 if (symbol_level == 2) {
451 _default_symbols_config = "//build/config/compiler:symbols"
452 } else if (symbol_level == 1) {
453 _default_symbols_config = "//build/config/compiler:minimal_symbols"
454 } else if (symbol_level == 0) {
455 _default_symbols_config = "//build/config/compiler:no_symbols"
456 } else {
457 assert(false, "Bad value for symbol_level.")
458 }
459 _native_compiler_configs += [ _default_symbols_config ]
460 403
461 # Windows linker setup for EXEs and DLLs. 404 # Windows linker setup for EXEs and DLLs.
462 if (is_win) { 405 if (is_win) {
463 _windows_linker_configs = [ 406 _windows_linker_configs = [
464 "//build/config/win:default_incremental_linking", 407 "//build/config/win:default_incremental_linking",
465 "//build/config/win:sdk_link", 408 "//build/config/win:sdk_link",
466 "//build/config/win:common_linker_setup", 409 "//build/config/win:common_linker_setup",
467 410
468 # Default to console-mode apps. Most of our targets are tests and such 411 # Default to console-mode apps. Most of our targets are tests and such
469 # that shouldn't use the windows subsystem. 412 # that shouldn't use the windows subsystem.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 forward_variables_from(invoker, "*") 561 forward_variables_from(invoker, "*")
619 562
620 # All shared libraries must have the sanitizer deps to properly link in 563 # All shared libraries must have the sanitizer deps to properly link in
621 # asan mode (this target will be empty in other cases). 564 # asan mode (this target will be empty in other cases).
622 if (!defined(deps)) { 565 if (!defined(deps)) {
623 deps = [] 566 deps = []
624 } 567 }
625 deps += [ "//build/config/sanitizers:deps" ] 568 deps += [ "//build/config/sanitizers:deps" ]
626 } 569 }
627 } 570 }
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | build/config/compiler/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698