Chromium Code Reviews| 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 import("//build/config/chrome_build.gni") | 6 import("//build/config/chrome_build.gni") |
| 7 import("//build/config/chromecast_build.gni") | 7 import("//build/config/chromecast_build.gni") |
| 8 import("//build/config/compiler/compiler.gni") | 8 import("//build/config/compiler/compiler.gni") |
| 9 import("//build/config/nacl/config.gni") | 9 import("//build/config/nacl/config.gni") |
| 10 import("//build/toolchain/cc_wrapper.gni") | 10 import("//build/toolchain/cc_wrapper.gni") |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 if (is_win) { | 155 if (is_win) { |
| 156 configs += [ "//build/config/win:compiler" ] | 156 configs += [ "//build/config/win:compiler" ] |
| 157 } else if (is_android) { | 157 } else if (is_android) { |
| 158 configs += [ "//build/config/android:compiler" ] | 158 configs += [ "//build/config/android:compiler" ] |
| 159 } else if (is_linux) { | 159 } else if (is_linux) { |
| 160 configs += [ "//build/config/linux:compiler" ] | 160 configs += [ "//build/config/linux:compiler" ] |
| 161 } else if (is_nacl) { | 161 } else if (is_nacl) { |
| 162 configs += [ "//build/config/nacl:compiler" ] | 162 configs += [ "//build/config/nacl:compiler" ] |
| 163 } else if (is_ios || is_mac) { | 163 } else if (is_ios || is_mac) { |
| 164 configs += [ "//build/config/mac:compiler" ] | 164 configs += [ "//build/config/mac:compiler" ] |
| 165 } else if (current_os == "aix") { | |
| 166 configs += [ "//build/config/aix:compiler" ] | |
| 165 } | 167 } |
| 166 | 168 |
| 167 # See the definitions below. | 169 # See the definitions below. |
| 168 configs += [ | 170 configs += [ |
| 169 ":compiler_cpu_abi", | 171 ":compiler_cpu_abi", |
| 170 ":compiler_codegen", | 172 ":compiler_codegen", |
| 171 ] | 173 ] |
| 172 | 174 |
| 173 # In general, Windows is totally different, but all the other builds share | 175 # In general, Windows is totally different, but all the other builds share |
| 174 # some common GCC configuration. | 176 # some common GCC configuration. |
| 175 if (!is_win) { | 177 if (!is_win) { |
| 176 # Common GCC compiler flags setup. | 178 # Common GCC compiler flags setup. |
| 177 # -------------------------------- | 179 # -------------------------------- |
| 178 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 | 180 if (current_os != "aix" && |
|
Michael Achenbach
2017/04/25 14:08:30
Just double-checking: You don't need the aix check
rayb
2017/04/25 17:28:48
We only support AIX on ppc64 BE. So further checki
| |
| 179 cflags_cc += [ | 181 !(is_linux && (current_cpu == "s390x" || current_cpu == "s390" || |
| 180 # Not exporting C++ inline functions can generally be applied anywhere | 182 current_cpu == "ppc64" || current_cpu == "ppc"))) { |
| 181 # so we do so here. Normal function visibility is controlled by | 183 cflags_cc += [ |
|
Michael Achenbach
2017/04/18 13:46:04
This doesn't include -fno-strict-aliasing in cflag
rayb
2017/04/25 00:41:04
Acknowledged.
| |
| 182 # //build/config/gcc:symbol_visibility_hidden. | 184 "fno-strict-aliasing", |
| 183 "-fvisibility-inlines-hidden", | 185 |
| 184 ] | 186 # Not exporting C++ inline functions can generally be applied anywhere |
| 187 # so we do so here. Normal function visibility is controlled by | |
| 188 # //build/config/gcc:symbol_visibility_hidden. | |
| 189 "-fvisibility-inlines-hidden", | |
| 190 ] | |
| 191 } | |
| 185 | 192 |
| 186 # Stack protection. | 193 # Stack protection. |
| 187 if (is_mac) { | 194 if (is_mac) { |
| 188 # The strong variant of the stack protector significantly increases | 195 # The strong variant of the stack protector significantly increases |
| 189 # binary size, so only enable it in debug mode. | 196 # binary size, so only enable it in debug mode. |
| 190 if (is_debug) { | 197 if (is_debug) { |
| 191 cflags += [ "-fstack-protector-strong" ] | 198 cflags += [ "-fstack-protector-strong" ] |
| 192 } else { | 199 } else { |
| 193 cflags += [ "-fstack-protector" ] | 200 cflags += [ "-fstack-protector" ] |
| 194 } | 201 } |
| 195 } else if (is_posix && !is_chromeos && !is_nacl) { | 202 } else if (is_posix && !is_chromeos && !is_nacl) { |
| 196 # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it. | 203 # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it. |
| 197 # See also https://crbug.com/533294 | 204 # See also https://crbug.com/533294 |
| 198 cflags += [ "--param=ssp-buffer-size=4" ] | 205 cflags += [ "--param=ssp-buffer-size=4" ] |
| 199 | 206 |
| 200 # The x86 toolchain currently has problems with stack-protector. | 207 # The x86 toolchain currently has problems with stack-protector. |
| 201 if (is_android && current_cpu == "x86") { | 208 if (is_android && current_cpu == "x86") { |
| 202 cflags += [ "-fno-stack-protector" ] | 209 cflags += [ "-fno-stack-protector" ] |
| 203 } else { | 210 } else if (current_os != "aix") { |
| 211 # Not available on aix. | |
| 204 cflags += [ "-fstack-protector" ] | 212 cflags += [ "-fstack-protector" ] |
| 205 } | 213 } |
| 206 } | 214 } |
| 207 | 215 |
| 208 # Linker warnings. | 216 # Linker warnings. |
| 209 if (fatal_linker_warnings && !(is_chromeos && current_cpu == "arm") && | 217 if (fatal_linker_warnings && !(is_chromeos && current_cpu == "arm") && |
| 210 !(is_android && use_order_profiling) && !is_mac && !is_ios) { | 218 !(is_android && use_order_profiling) && !is_mac && !is_ios && |
| 219 current_os != "aix") { | |
| 211 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 | 220 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 |
| 212 # TODO(lizeb,pasko): Fix link errors when linking with order_profiling=1 | 221 # TODO(lizeb,pasko): Fix link errors when linking with order_profiling=1 |
| 213 # crbug.com/485542 | 222 # crbug.com/485542 |
| 214 ldflags += [ "-Wl,--fatal-warnings" ] | 223 ldflags += [ "-Wl,--fatal-warnings" ] |
| 215 } | 224 } |
| 216 } | 225 } |
| 217 | 226 |
| 218 # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for | 227 # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for |
| 219 # deterministic build. See https://crbug.com/314403 | 228 # deterministic build. See https://crbug.com/314403 |
| 220 if (!is_official_build) { | 229 if (!is_official_build) { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 # clang-cl (used if is_win) doesn't expose this flag. | 438 # clang-cl (used if is_win) doesn't expose this flag. |
| 430 # Currently disabled for nacl since its toolchain lacks this flag (too old). | 439 # Currently disabled for nacl since its toolchain lacks this flag (too old). |
| 431 # TODO(zforman): Once nacl's toolchain is updated, remove check. | 440 # TODO(zforman): Once nacl's toolchain is updated, remove check. |
| 432 if (is_clang && is_linux && strip_absolute_paths_from_debug_symbols) { | 441 if (is_clang && is_linux && strip_absolute_paths_from_debug_symbols) { |
| 433 absolute_path = rebase_path("//.") | 442 absolute_path = rebase_path("//.") |
| 434 cflags += [ "-fdebug-prefix-map=$absolute_path=." ] | 443 cflags += [ "-fdebug-prefix-map=$absolute_path=." ] |
| 435 } | 444 } |
| 436 | 445 |
| 437 # C++11 compiler flags setup. | 446 # C++11 compiler flags setup. |
| 438 # --------------------------- | 447 # --------------------------- |
| 439 if (is_linux || is_android || (is_nacl && is_clang)) { | 448 if (is_linux || is_android || (is_nacl && is_clang) || current_os == "aix") { |
| 440 # gnu++11 instead of c++11 is needed because some code uses typeof() (a | 449 # gnu++11 instead of c++11 is needed because some code uses typeof() (a |
| 441 # GNU extension). | 450 # GNU extension). |
| 442 # TODO(thakis): Eventually switch this to c++11 instead, | 451 # TODO(thakis): Eventually switch this to c++11 instead, |
| 443 # http://crbug.com/427584 | 452 # http://crbug.com/427584 |
| 444 cflags_cc += [ "-std=gnu++11" ] | 453 cflags_cc += [ "-std=gnu++11" ] |
| 445 } else if (!is_win && !is_nacl) { | 454 } else if (!is_win && !is_nacl) { |
| 446 # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either gnu++11 | 455 # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either gnu++11 |
| 447 # or c++11; we technically don't need this toolchain any more, but there | 456 # or c++11; we technically don't need this toolchain any more, but there |
| 448 # are still a few buildbots using it, so until those are turned off | 457 # are still a few buildbots using it, so until those are turned off |
| 449 # we need the !is_nacl clause and the (is_nacl && is_clang) clause, above. | 458 # we need the !is_nacl clause and the (is_nacl && is_clang) clause, above. |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1130 } | 1139 } |
| 1131 | 1140 |
| 1132 # In Chromium code, we define __STDC_foo_MACROS in order to get the | 1141 # In Chromium code, we define __STDC_foo_MACROS in order to get the |
| 1133 # C99 macros on Mac and Linux. | 1142 # C99 macros on Mac and Linux. |
| 1134 defines = [ | 1143 defines = [ |
| 1135 "__STDC_CONSTANT_MACROS", | 1144 "__STDC_CONSTANT_MACROS", |
| 1136 "__STDC_FORMAT_MACROS", | 1145 "__STDC_FORMAT_MACROS", |
| 1137 ] | 1146 ] |
| 1138 | 1147 |
| 1139 if (!is_debug && !using_sanitizer && | 1148 if (!is_debug && !using_sanitizer && |
| 1140 (!is_linux || !is_clang || is_official_build)) { | 1149 (!is_linux || !is_clang || is_official_build) && |
| 1150 (current_cpu != "s390x" && current_cpu != "s390" && | |
| 1151 current_cpu != "ppc64" && current_cpu != "ppc")) { | |
|
Michael Achenbach
2017/04/18 13:46:04
nit: For readability, maybe we could add a helper
rayb
2017/04/25 00:41:04
Done.
| |
| 1141 # _FORTIFY_SOURCE isn't really supported by Clang now, see | 1152 # _FORTIFY_SOURCE isn't really supported by Clang now, see |
| 1142 # http://llvm.org/bugs/show_bug.cgi?id=16821. | 1153 # http://llvm.org/bugs/show_bug.cgi?id=16821. |
| 1143 # It seems to work fine with Ubuntu 12 headers though, so use it in | 1154 # It seems to work fine with Ubuntu 12 headers though, so use it in |
| 1144 # official builds. | 1155 # official builds. |
| 1145 # | 1156 # |
| 1146 # Non-chromium code is not guaranteed to compile cleanly with | 1157 # Non-chromium code is not guaranteed to compile cleanly with |
| 1147 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are | 1158 # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are |
| 1148 # disabled, so only do that for Release build. | 1159 # disabled, so only do that for Release build. |
| 1149 defines += [ "_FORTIFY_SOURCE=2" ] | 1160 defines += [ "_FORTIFY_SOURCE=2" ] |
| 1150 } | 1161 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1350 "-Wl,--warn-shared-textrel", | 1361 "-Wl,--warn-shared-textrel", |
| 1351 ] | 1362 ] |
| 1352 } | 1363 } |
| 1353 } | 1364 } |
| 1354 | 1365 |
| 1355 if (is_mac || is_ios) { | 1366 if (is_mac || is_ios) { |
| 1356 if (symbol_level == 2) { | 1367 if (symbol_level == 2) { |
| 1357 # Mac dead code stripping requires symbols. | 1368 # Mac dead code stripping requires symbols. |
| 1358 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] | 1369 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] |
| 1359 } | 1370 } |
| 1360 } else { | 1371 } else if (current_os != "aix") { |
| 1361 # Non-Mac Posix flags. | 1372 # Non-Mac Posix flags. |
| 1362 | 1373 |
| 1363 common_optimize_on_cflags += [ | 1374 common_optimize_on_cflags += [ |
| 1364 # Don't emit the GCC version ident directives, they just end up in the | 1375 # Don't emit the GCC version ident directives, they just end up in the |
| 1365 # .comment section taking up binary size. | 1376 # .comment section taking up binary size. |
| 1366 "-fno-ident", | 1377 "-fno-ident", |
| 1367 | 1378 |
| 1368 # Put data and code in their own sections, so that unused symbols | 1379 # Put data and code in their own sections, so that unused symbols |
| 1369 # can be removed at link time with --gc-sections. | 1380 # can be removed at link time with --gc-sections. |
| 1370 "-fdata-sections", | 1381 "-fdata-sections", |
| 1371 "-ffunction-sections", | 1382 "-ffunction-sections", |
| 1372 ] | 1383 ] |
| 1373 | 1384 |
| 1374 common_optimize_on_ldflags += [ | 1385 if (current_os != "aix") { |
|
Michael Achenbach
2017/04/18 13:46:03
This is already nested in a current_os != "aix" sc
rayb
2017/04/25 00:41:04
Done.
| |
| 1375 # Specifically tell the linker to perform optimizations. | 1386 common_optimize_on_ldflags += [ |
| 1376 # See http://lwn.net/Articles/192624/ . | 1387 # Specifically tell the linker to perform optimizations. |
| 1377 "-Wl,-O1", | 1388 # See http://lwn.net/Articles/192624/ . |
| 1378 "-Wl,--gc-sections", | 1389 "-Wl,-O1", |
| 1379 ] | 1390 "-Wl,--gc-sections", |
| 1391 ] | |
| 1392 } | |
| 1380 } | 1393 } |
| 1381 } | 1394 } |
| 1382 | 1395 |
| 1383 config("default_stack_frames") { | 1396 config("default_stack_frames") { |
| 1384 if (is_posix) { | 1397 if (is_posix) { |
| 1385 if (enabled_frame_pointers) { | 1398 if (enabled_frame_pointers) { |
| 1386 cflags = [ "-fno-omit-frame-pointer" ] | 1399 cflags = [ "-fno-omit-frame-pointer" ] |
| 1387 } else { | 1400 } else { |
| 1388 cflags = [ "-fomit-frame-pointer" ] | 1401 cflags = [ "-fomit-frame-pointer" ] |
| 1389 } | 1402 } |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1717 | 1730 |
| 1718 if (is_ios || is_mac) { | 1731 if (is_ios || is_mac) { |
| 1719 # On Mac and iOS, this enables support for ARC (automatic ref-counting). | 1732 # On Mac and iOS, this enables support for ARC (automatic ref-counting). |
| 1720 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. | 1733 # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html. |
| 1721 config("enable_arc") { | 1734 config("enable_arc") { |
| 1722 common_flags = [ "-fobjc-arc" ] | 1735 common_flags = [ "-fobjc-arc" ] |
| 1723 cflags_objc = common_flags | 1736 cflags_objc = common_flags |
| 1724 cflags_objcc = common_flags | 1737 cflags_objcc = common_flags |
| 1725 } | 1738 } |
| 1726 } | 1739 } |
| OLD | NEW |