OLD | NEW |
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 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
6 if (current_cpu == "arm") { | 6 if (current_cpu == "arm") { |
7 import("//build/config/arm.gni") | 7 import("//build/config/arm.gni") |
8 } | 8 } |
9 if (current_cpu == "mipsel" || current_cpu == "mips64el") { | 9 if (current_cpu == "mipsel" || current_cpu == "mips64el") { |
10 import("//build/config/mips.gni") | 10 import("//build/config/mips.gni") |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 # TODO(GYP): is_ubsan, is_ubsan_vptr | 72 # TODO(GYP): is_ubsan, is_ubsan_vptr |
73 if (!is_win) { | 73 if (!is_win) { |
74 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan | 74 using_sanitizer = is_asan || is_lsan || is_tsan || is_msan |
75 } | 75 } |
76 | 76 |
77 # compiler --------------------------------------------------------------------- | 77 # compiler --------------------------------------------------------------------- |
78 # | 78 # |
79 # Base compiler configuration. | 79 # Base compiler configuration. |
80 # | 80 # |
81 # See also "runtime_library" below for related stuff and a discusison about | 81 # See also "runtime_library" below for related stuff and a discussion about |
82 # where stuff should go. Put warning related stuff in the "warnings" config. | 82 # where stuff should go. Put warning related stuff in the "warnings" config. |
83 | 83 |
84 config("compiler") { | 84 config("compiler") { |
85 cflags = [] | 85 cflags = [] |
86 cflags_c = [] | 86 cflags_c = [] |
87 cflags_cc = [] | 87 cflags_cc = [] |
88 ldflags = [] | 88 ldflags = [] |
89 defines = [] | 89 defines = [] |
90 | 90 |
91 # In general, Windows is totally different, but all the other builds share | 91 # In general, Windows is totally different, but all the other builds share |
92 # some common GCC configuration. This section sets up Windows and the common | 92 # some common GCC configuration. This section sets up Windows and the common |
93 # GCC flags, and then we handle the other non-Windows platforms specifically | 93 # GCC flags, and then we handle the other non-Windows platforms specifically |
94 # below. | 94 # below. |
95 if (is_win) { | 95 if (is_win) { |
96 # Windows compiler flags setup. | 96 # Windows compiler flags setup. |
97 # ----------------------------- | 97 # ----------------------------- |
98 cflags += [ | 98 cflags += [ |
99 "/Gy", # Enable function-level linking. | 99 "/Gy", # Enable function-level linking. |
100 "/GS", # Enable buffer security checking. | 100 "/GS", # Enable buffer security checking. |
101 "/FS", # Preserve previous PDB behavior. | 101 "/FS", # Preserve previous PDB behavior. |
102 ] | 102 ] |
103 if (is_component_build) { | |
104 cflags += [ "/EHsc" ] # Assume C functions can't throw exceptions and don
't catch | |
105 # structured exceptions (only C++ ones). | |
106 } | |
107 } else { | 103 } else { |
108 # Common GCC compiler flags setup. | 104 # Common GCC compiler flags setup. |
109 # -------------------------------- | 105 # -------------------------------- |
110 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 | 106 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 |
111 cflags_cc += [ | 107 cflags_cc += [ |
112 "-fno-threadsafe-statics", | 108 "-fno-threadsafe-statics", |
113 | 109 |
114 # Not exporting C++ inline functions can generally be applied anywhere | 110 # Not exporting C++ inline functions can generally be applied anywhere |
115 # so we do so here. Normal function visibility is controlled by | 111 # so we do so here. Normal function visibility is controlled by |
116 # //build/config/gcc:symbol_visibility_hidden. | 112 # //build/config/gcc:symbol_visibility_hidden. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 # Allow comparing the address of references and 'this' against 0 | 150 # Allow comparing the address of references and 'this' against 0 |
155 # in debug builds. Technically, these can never be null in | 151 # in debug builds. Technically, these can never be null in |
156 # well-defined C/C++ and Clang can optimize such checks away in | 152 # well-defined C/C++ and Clang can optimize such checks away in |
157 # release builds, but they may be used in asserts in debug builds. | 153 # release builds, but they may be used in asserts in debug builds. |
158 cflags_cc += [ | 154 cflags_cc += [ |
159 "-Wno-undefined-bool-conversion", | 155 "-Wno-undefined-bool-conversion", |
160 "-Wno-tautological-undefined-compare", | 156 "-Wno-tautological-undefined-compare", |
161 ] | 157 ] |
162 } | 158 } |
163 | 159 |
164 if (is_clang && !is_win) { | 160 if (is_clang && !is_win && !is_nacl) { |
165 # This is here so that all files get recompiled after a clang roll and | 161 # This is here so that all files get recompiled after a clang roll and |
166 # when turning clang on or off. (defines are passed via the command line, | 162 # when turning clang on or off. (defines are passed via the command line, |
167 # and build system rebuild things when their commandline changes). Nothing | 163 # and build system rebuild things when their commandline changes). Nothing |
168 # should ever read this define. | 164 # should ever read this define. |
169 defines += [ "CR_CLANG_REVISION=" + | 165 defines += [ "CR_CLANG_REVISION=" + |
170 exec_script("//tools/clang/scripts/posix-print-revision.py", | 166 exec_script("//tools/clang/scripts/posix-print-revision.py", |
171 [], | 167 [], |
172 "value") ] | 168 "value") ] |
173 } | 169 } |
174 | 170 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 # Experimentation found that using four linking threads | 392 # Experimentation found that using four linking threads |
397 # saved ~20% of link time. | 393 # saved ~20% of link time. |
398 # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_threa
d/thread/281527606915bb36 | 394 # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_threa
d/thread/281527606915bb36 |
399 # Only apply this to the target linker, since the host | 395 # Only apply this to the target linker, since the host |
400 # linker might not be gold, but isn't used much anyway. | 396 # linker might not be gold, but isn't used much anyway. |
401 # TODO(raymes): Disable threading because gold is frequently | 397 # TODO(raymes): Disable threading because gold is frequently |
402 # crashing on the bots: crbug.com/161942. | 398 # crashing on the bots: crbug.com/161942. |
403 #"-Wl,--threads", | 399 #"-Wl,--threads", |
404 #"-Wl,--thread-count=4", | 400 #"-Wl,--thread-count=4", |
405 ] | 401 ] |
| 402 |
| 403 # TODO(thestig): Make this flag work with GN. |
| 404 #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan |
| is_msan)) { |
| 405 # ldflags += [ |
| 406 # "-Wl,--detect-odr-violations", |
| 407 # ] |
| 408 #} |
406 } | 409 } |
407 | 410 |
408 if (linux_use_bundled_binutils) { | 411 if (linux_use_bundled_binutils) { |
409 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", | 412 binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", |
410 root_build_dir) | 413 root_build_dir) |
411 cflags += [ "-B$binutils_path" ] | 414 cflags += [ "-B$binutils_path" ] |
412 } | 415 } |
413 | 416 |
414 # Clang-specific compiler flags setup. | 417 # Clang-specific compiler flags setup. |
415 # ------------------------------------ | 418 # ------------------------------------ |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 # about things not matching, so keep exceptions on. | 530 # about things not matching, so keep exceptions on. |
528 if (is_debug) { | 531 if (is_debug) { |
529 cflags += [ "/MDd" ] | 532 cflags += [ "/MDd" ] |
530 } else { | 533 } else { |
531 cflags += [ "/MD" ] | 534 cflags += [ "/MD" ] |
532 } | 535 } |
533 } | 536 } |
534 } else { | 537 } else { |
535 # Static CRT. | 538 # Static CRT. |
536 if (is_win) { | 539 if (is_win) { |
537 # We don't use exceptions, and when we link statically we can just get | |
538 # rid of them entirely. | |
539 defines += [ "_HAS_EXCEPTIONS=0" ] | |
540 if (is_debug) { | 540 if (is_debug) { |
541 cflags += [ "/MTd" ] | 541 cflags += [ "/MTd" ] |
542 } else { | 542 } else { |
543 cflags += [ "/MT" ] | 543 cflags += [ "/MT" ] |
544 } | 544 } |
545 } | 545 } |
546 } | 546 } |
547 | 547 |
548 if (is_win) { | 548 if (is_win) { |
549 defines += [ | 549 defines += [ |
550 "__STD_C", | 550 "__STD_C", |
551 "__STDC_CONSTANT_MACROS", | |
552 "__STDC_FORMAT_MACROS", | |
553 "_CRT_RAND_S", | 551 "_CRT_RAND_S", |
554 "_CRT_SECURE_NO_DEPRECATE", | 552 "_CRT_SECURE_NO_DEPRECATE", |
| 553 "_HAS_EXCEPTIONS=0", |
555 "_SCL_SECURE_NO_DEPRECATE", | 554 "_SCL_SECURE_NO_DEPRECATE", |
556 ] | 555 ] |
557 } | 556 } |
558 | 557 |
559 # Stlport setup. Android uses a different (smaller) version of the STL. | 558 # Stlport setup. Android uses a different (smaller) version of the STL. |
560 if (is_android) { | 559 if (is_android) { |
561 if (is_clang) { | 560 if (is_clang) { |
562 # Work around incompatibilities between bionic and clang headers. | 561 # Work around incompatibilities between bionic and clang headers. |
563 defines += [ | 562 defines += [ |
564 "__compiler_offsetof=__builtin_offsetof", | 563 "__compiler_offsetof=__builtin_offsetof", |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 | 719 |
721 # Warnings --------------------------------------------------------------------- | 720 # Warnings --------------------------------------------------------------------- |
722 # | 721 # |
723 # This is where we disable various warnings that we've decided aren't | 722 # This is where we disable various warnings that we've decided aren't |
724 # worthwhile, and enable special warnings. | 723 # worthwhile, and enable special warnings. |
725 | 724 |
726 config("default_warnings") { | 725 config("default_warnings") { |
727 if (is_win) { | 726 if (is_win) { |
728 cflags = [ | 727 cflags = [ |
729 "/WX", # Treat warnings as errors. | 728 "/WX", # Treat warnings as errors. |
730 | |
731 # Warnings permanently disabled: | 729 # Warnings permanently disabled: |
732 | 730 |
733 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled | 731 # TODO(GYP) The GYP build doesn't have this globally enabled but disabled |
734 # for a bunch of individual targets. Re-enable this globally when those | 732 # for a bunch of individual targets. Re-enable this globally when those |
735 # targets are fixed. | 733 # targets are fixed. |
736 "/wd4018", # Comparing signed and unsigned values. | 734 "/wd4018", # Comparing signed and unsigned values. |
737 | 735 |
738 # C4127: conditional expression is constant | 736 # C4127: conditional expression is constant |
739 # This warning can in theory catch dead code and other problems, but | 737 # This warning can in theory catch dead code and other problems, but |
740 # triggers in far too many desirable cases where the conditional | 738 # triggers in far too many desirable cases where the conditional |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 | 773 |
776 # C4611: interaction between 'function' and C++ object destruction is | 774 # C4611: interaction between 'function' and C++ object destruction is |
777 # non-portable | 775 # non-portable |
778 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN | 776 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN |
779 # suggests using exceptions instead of setjmp/longjmp for C++, but | 777 # suggests using exceptions instead of setjmp/longjmp for C++, but |
780 # Chromium code compiles without exception support. We therefore have to | 778 # Chromium code compiles without exception support. We therefore have to |
781 # use setjmp/longjmp for e.g. JPEG decode error handling, which means we | 779 # use setjmp/longjmp for e.g. JPEG decode error handling, which means we |
782 # have to turn off this warning (and be careful about how object | 780 # have to turn off this warning (and be careful about how object |
783 # destruction happens in such cases). | 781 # destruction happens in such cases). |
784 "/wd4611", | 782 "/wd4611", |
785 | |
786 # Warnings to evaluate and possibly fix/reenable later: | 783 # Warnings to evaluate and possibly fix/reenable later: |
787 | 784 |
788 "/wd4100", # Unreferenced formal function parameter. | 785 "/wd4100", # Unreferenced formal function parameter. |
789 "/wd4121", # Alignment of a member was sensitive to packing. | 786 "/wd4121", # Alignment of a member was sensitive to packing. |
790 "/wd4244", # Conversion: possible loss of data. | 787 "/wd4244", # Conversion: possible loss of data. |
791 "/wd4481", # Nonstandard extension: override specifier. | 788 "/wd4481", # Nonstandard extension: override specifier. |
792 "/wd4505", # Unreferenced local function has been removed. | 789 "/wd4505", # Unreferenced local function has been removed. |
793 "/wd4510", # Default constructor could not be generated. | 790 "/wd4510", # Default constructor could not be generated. |
794 "/wd4512", # Assignment operator could not be generated. | 791 "/wd4512", # Assignment operator could not be generated. |
795 "/wd4610", # Class can never be instantiated, constructor required. | 792 "/wd4610", # Class can never be instantiated, constructor required. |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 cflags += [ "-gsplit-dwarf" ] | 1106 cflags += [ "-gsplit-dwarf" ] |
1110 } | 1107 } |
1111 } | 1108 } |
1112 } | 1109 } |
1113 | 1110 |
1114 config("no_symbols") { | 1111 config("no_symbols") { |
1115 if (!is_win) { | 1112 if (!is_win) { |
1116 cflags = [ "-g0" ] | 1113 cflags = [ "-g0" ] |
1117 } | 1114 } |
1118 } | 1115 } |
OLD | NEW |