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

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 | « breakpad/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 11 matching lines...) Expand all
169 # they have to figure out which one to remove depending on the state of the 149 # they have to figure out which one to remove depending on the state of the
170 # current build. It also means that symbol_level and the sanitizer flags need 150 # current build. It also means that symbol_level and the sanitizer flags need
171 # to be global. 151 # to be global.
172 # 152 #
173 # In the new scheme, this file sets a "default_symbols" and 153 # In the new scheme, this file sets a "default_symbols" and
174 # "default_optimization" configs, which then expands to the right thing 154 # "default_optimization" configs, which then expands to the right thing
175 # depending on the current build. This means less information has to be global, 155 # depending on the current build. This means less information has to be global,
176 # and there's only one config to remove that's the same in all cases for 156 # and there's only one config to remove that's the same in all cases for
177 # targets that want to override it. It also means that the associated flags can 157 # targets that want to override it. It also means that the associated flags can
178 # be non-global. 158 # be non-global.
179 using_new_global_compiler_configs = false 159 using_new_global_compiler_configs = true
180 160
181 # To assist in a multi-sided landing of updating the default optimization 161 # To assist in a multi-sided landing of updating the default optimization
182 # config. When false, this file sets up the default optimization config to be 162 # config. When false, this file sets up the default optimization config to be
163 # either "no_optimize" (debug) or "optimize" (release). When true it will
164 # always set the config "default_optimization".
165 #
166 # TODO(brettw) remove this when all repos are updated.
167 using_new_optimization_config = true
168
169 # To assist in a multi-sided landing of updating the default optimization
170 # config. When false, this file sets up the default optimization config to be
183 # either "no_optimize" (debug) or "optimize" (release). When true it will 171 # either "no_optimize" (debug) or "optimize" (release). When true it will
184 # always set the config "default_optimization". 172 # always set the config "default_optimization".
185 # 173 #
186 # TODO(brettw) remove this when all repos are updated. 174 # TODO(brettw) remove this when all repos are updated.
187 using_new_optimization_config = false 175 using_new_optimization_config = true
188 176
189 # ============================================================================= 177 # =============================================================================
190 # OS DEFINITIONS 178 # OS DEFINITIONS
191 # ============================================================================= 179 # =============================================================================
192 # 180 #
193 # We set these various is_FOO booleans for convenience in writing OS-based 181 # We set these various is_FOO booleans for convenience in writing OS-based
194 # conditions. 182 # conditions.
195 # 183 #
196 # - is_android, is_chromeos, is_ios, and is_win should be obvious. 184 # - is_android, is_chromeos, is_ios, and is_win should be obvious.
197 # - is_mac is set only for desktop Mac. It is not set on iOS. 185 # - is_mac is set only for desktop Mac. It is not set on iOS.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 # across many projects in the tree. 368 # across many projects in the tree.
381 # 369 #
382 # Therefore, we only add rules to this list corresponding to platforms on the 370 # Therefore, we only add rules to this list corresponding to platforms on the
383 # Chromium waterfall. This is not for non-officially-supported platforms 371 # Chromium waterfall. This is not for non-officially-supported platforms
384 # (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases, 372 # (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases,
385 # write a conditional in the target to remove the file(s) from the list when 373 # write a conditional in the target to remove the file(s) from the list when
386 # your platform/toolkit/feature doesn't apply. 374 # your platform/toolkit/feature doesn't apply.
387 set_sources_assignment_filter(sources_assignment_filter) 375 set_sources_assignment_filter(sources_assignment_filter)
388 376
389 # ============================================================================= 377 # =============================================================================
390 # BUILD OPTIONS
391 # =============================================================================
392
393 # These Sanitizers all imply using the Clang compiler. On Windows they either
394 # don't work or work differently.
395 if (!is_clang && (is_asan || is_lsan || is_tsan || is_msan)) {
396 is_clang = true
397 }
398
399 # =============================================================================
400 # TARGET DEFAULTS 378 # TARGET DEFAULTS
401 # ============================================================================= 379 # =============================================================================
402 # 380 #
403 # Set up the default configuration for every build target of the given type. 381 # Set up the default configuration for every build target of the given type.
404 # The values configured here will be automatically set on the scope of the 382 # The values configured here will be automatically set on the scope of the
405 # corresponding target. Target definitions can add or remove to the settings 383 # corresponding target. Target definitions can add or remove to the settings
406 # here as needed. 384 # here as needed.
407 385
408 # Holds all configs used for making native executables and libraries, to avoid 386 # Holds all configs used for making native executables and libraries, to avoid
409 # duplication in each target below. 387 # duplication in each target below.
410 _native_compiler_configs = [ 388 _native_compiler_configs = [
411 "//build/config:feature_flags", 389 "//build/config:feature_flags",
412 "//build/config/compiler:compiler", 390 "//build/config/compiler:compiler",
413 "//build/config/compiler:compiler_arm_fpu", 391 "//build/config/compiler:compiler_arm_fpu",
414 "//build/config/compiler:chromium_code", 392 "//build/config/compiler:chromium_code",
415 "//build/config/compiler:default_include_dirs", 393 "//build/config/compiler:default_include_dirs",
394 "//build/config/compiler:default_optimization",
395 "//build/config/compiler:default_symbols",
416 "//build/config/compiler:no_rtti", 396 "//build/config/compiler:no_rtti",
417 "//build/config/compiler:runtime_library", 397 "//build/config/compiler:runtime_library",
418 ] 398 ]
419 if (is_win) { 399 if (is_win) {
420 _native_compiler_configs += [ 400 _native_compiler_configs += [
421 "//build/config/win:lean_and_mean", 401 "//build/config/win:lean_and_mean",
422 "//build/config/win:nominmax", 402 "//build/config/win:nominmax",
423 "//build/config/win:sdk", 403 "//build/config/win:sdk",
424 "//build/config/win:unicode", 404 "//build/config/win:unicode",
425 "//build/config/win:winver", 405 "//build/config/win:winver",
426 ] 406 ]
427 } 407 }
428 if (current_os == "winrt_81" || current_os == "winrt_81_phone" || 408 if (current_os == "winrt_81" || current_os == "winrt_81_phone" ||
429 current_os == "winrt_10") { 409 current_os == "winrt_10") {
430 _native_compiler_configs += [ "//build/config/win:target_winrt" ] 410 _native_compiler_configs += [ "//build/config/win:target_winrt" ]
431 } 411 }
432 if (is_posix) { 412 if (is_posix) {
433 _native_compiler_configs += [ 413 _native_compiler_configs += [
434 "//build/config/gcc:no_exceptions", 414 "//build/config/gcc:no_exceptions",
435 "//build/config/gcc:symbol_visibility_hidden", 415 "//build/config/gcc:symbol_visibility_hidden",
436 ] 416 ]
437 } 417 }
438 418
439 if (is_linux) { 419 if (is_linux) {
440 _native_compiler_configs += [ "//build/config/linux:sdk" ] 420 _native_compiler_configs += [ "//build/config/linux:sdk" ]
441 } else if (is_mac) { 421 } else if (is_mac) {
442 _native_compiler_configs += [ "//build/config/mac:sdk" ] 422 _native_compiler_configs += [ "//build/config/mac:sdk" ]
443 } else if (is_ios) { 423 } else if (is_ios) {
444 _native_compiler_configs += [ "//build/config/ios:sdk" ]
445 } else if (is_android) { 424 } else if (is_android) {
446 _native_compiler_configs += [ "//build/config/android:sdk" ] 425 _native_compiler_configs += [ "//build/config/android:sdk" ]
447 } 426 }
448 427
449 if (is_clang && !is_nacl) { 428 if (is_clang && !is_nacl) {
450 _native_compiler_configs += [ 429 _native_compiler_configs += [
451 "//build/config/clang:find_bad_constructs", 430 "//build/config/clang:find_bad_constructs",
452 "//build/config/clang:extra_warnings", 431 "//build/config/clang:extra_warnings",
453 ] 432 ]
454 } 433 }
455 434
456 # Optimizations and debug checking. 435 # Debug/release-related defines.
457 if (is_debug) { 436 if (is_debug) {
458 _native_compiler_configs += [ "//build/config:debug" ] 437 _native_compiler_configs += [ "//build/config:debug" ]
459 _default_optimization_config = "//build/config/compiler:no_optimize"
460 } else { 438 } else {
461 _native_compiler_configs += [ "//build/config:release" ] 439 _native_compiler_configs += [ "//build/config:release" ]
462 _default_optimization_config = "//build/config/compiler:optimize"
463 } 440 }
464 _native_compiler_configs += [ _default_optimization_config ]
465
466 # If it wasn't manually set, set to an appropriate default.
467 if (symbol_level == -1) {
468 # Linux is slowed by having symbols as part of the target binary, whereas
469 # Mac and Windows have them separate, so in Release Linux, default them off.
470 if (is_debug || !is_linux) {
471 symbol_level = 2
472 } else if (is_asan || is_lsan || is_tsan || is_msan) {
473 # Sanitizers require symbols for filename suppressions to work.
474 symbol_level = 1
475 } else {
476 symbol_level = 0
477 }
478 }
479
480 # Symbol setup.
481 if (symbol_level == 2) {
482 _default_symbols_config = "//build/config/compiler:symbols"
483 } else if (symbol_level == 1) {
484 _default_symbols_config = "//build/config/compiler:minimal_symbols"
485 } else if (symbol_level == 0) {
486 _default_symbols_config = "//build/config/compiler:no_symbols"
487 } else {
488 assert(false, "Bad value for symbol_level.")
489 }
490 _native_compiler_configs += [ _default_symbols_config ]
491 441
492 # Windows linker setup for EXEs and DLLs. 442 # Windows linker setup for EXEs and DLLs.
493 if (is_win) { 443 if (is_win) {
494 _windows_linker_configs = [ 444 _windows_linker_configs = [
495 "//build/config/win:default_incremental_linking", 445 "//build/config/win:default_incremental_linking",
496 "//build/config/win:sdk_link", 446 "//build/config/win:sdk_link",
497 "//build/config/win:common_linker_setup", 447 "//build/config/win:common_linker_setup",
498 448
499 # Default to console-mode apps. Most of our targets are tests and such 449 # Default to console-mode apps. Most of our targets are tests and such
500 # that shouldn't use the windows subsystem. 450 # that shouldn't use the windows subsystem.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 forward_variables_from(invoker, "*") 599 forward_variables_from(invoker, "*")
650 600
651 # All shared libraries must have the sanitizer deps to properly link in 601 # All shared libraries must have the sanitizer deps to properly link in
652 # asan mode (this target will be empty in other cases). 602 # asan mode (this target will be empty in other cases).
653 if (!defined(deps)) { 603 if (!defined(deps)) {
654 deps = [] 604 deps = []
655 } 605 }
656 deps += [ "//build/config/sanitizers:deps" ] 606 deps += [ "//build/config/sanitizers:deps" ]
657 } 607 }
658 } 608 }
OLDNEW
« no previous file with comments | « breakpad/BUILD.gn ('k') | build/config/compiler/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698