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

Side by Side Diff: build/config/compiler/BUILD.gn

Issue 1326053003: port cfi to gn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rephrase comment 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 | « no previous file | build/config/sanitizers/sanitizers.gni » ('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 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 if (current_cpu == "arm") { 7 if (current_cpu == "arm") {
8 import("//build/config/arm.gni") 8 import("//build/config/arm.gni")
9 } 9 }
10 if (current_cpu == "mipsel" || current_cpu == "mips64el") { 10 if (current_cpu == "mipsel" || current_cpu == "mips64el") {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 cflags += [ "-fstack-protector" ] 192 cflags += [ "-fstack-protector" ]
193 } 193 }
194 } 194 }
195 195
196 # Linker warnings. 196 # Linker warnings.
197 if (!(is_chromeos && current_cpu == "arm") && !is_mac && !is_ios) { 197 if (!(is_chromeos && current_cpu == "arm") && !is_mac && !is_ios) {
198 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580 198 # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580
199 ldflags += [ "-Wl,--fatal-warnings" ] 199 ldflags += [ "-Wl,--fatal-warnings" ]
200 } 200 }
201 201
202 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer and 202 # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer,
203 # MemorySanitizer 203 # MemorySanitizer and non-official CFI builds.
204 if (using_sanitizer) { 204 if (using_sanitizer || (is_cfi && !is_official_build)) {
205 cflags += [ 205 cflags += [
206 "-fno-omit-frame-pointer", 206 "-fno-omit-frame-pointer",
207 "-gline-tables-only", 207 "-gline-tables-only",
208 ] 208 ]
209 } 209 }
210 if (is_asan) { 210 if (is_asan) {
211 asan_blacklist_path = 211 asan_blacklist_path =
212 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) 212 rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir)
213 cflags += [ 213 cflags += [
214 "-fsanitize=address", 214 "-fsanitize=address",
(...skipping 17 matching lines...) Expand all
232 } 232 }
233 if (is_msan) { 233 if (is_msan) {
234 msan_blacklist_path = 234 msan_blacklist_path =
235 rebase_path("//tools/msan/blacklist.txt", root_build_dir) 235 rebase_path("//tools/msan/blacklist.txt", root_build_dir)
236 cflags += [ 236 cflags += [
237 "-fsanitize=memory", 237 "-fsanitize=memory",
238 "-fsanitize-memory-track-origins=$msan_track_origins", 238 "-fsanitize-memory-track-origins=$msan_track_origins",
239 "-fsanitize-blacklist=$msan_blacklist_path", 239 "-fsanitize-blacklist=$msan_blacklist_path",
240 ] 240 ]
241 } 241 }
242 if (is_cfi && !is_nacl) {
243 cfi_blacklist_path =
244 rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
245 cflags += [
246 "-flto",
247 "-fsanitize=cfi-vcall",
248 "-fsanitize=cfi-derived-cast",
249 "-fsanitize=cfi-unrelated-cast",
250 "-fsanitize-blacklist=$cfi_blacklist_path",
251 ]
252 ldflags += [
253 "-flto",
254 "-fsanitize=cfi-vcall",
255 "-fsanitize=cfi-derived-cast",
256 "-fsanitize=cfi-unrelated-cast",
257 ]
258
259 # Apply a lower LTO optimization level in non-official builds.
260 if (!is_official_build) {
261 if (is_linux) {
262 ldflags += [ "-Wl,-plugin-opt,O1" ]
263 } else if (is_mac) {
264 ldflags += [ "-Wl,-mllvm,-O1" ]
265 }
266 }
267
268 # Work-around for http://openradar.appspot.com/20356002
269 if (is_mac) {
270 ldflags += [ "-Wl,-all_load" ]
271 }
272
273 # Without this flag, LTO produces a .text section that is larger
274 # than the maximum call displacement, preventing the linker from
275 # relocating calls (http://llvm.org/PR22999).
276 if (current_cpu == "arm") {
277 ldflags += [ "-Wl,-plugin-opt,-function-sections" ]
278 }
279
280 if (use_cfi_diag) {
281 cflags += [
282 "-fno-sanitize-trap=cfi",
283 "-fsanitize-recover=cfi",
284 ]
285 ldflags += [
286 "-fno-sanitize-trap=cfi",
287 "-fsanitize-recover=cfi",
288 ]
289 } else {
290 defines += [ "CFI_ENFORCEMENT" ]
291 }
292 }
242 293
243 if (use_custom_libcxx) { 294 if (use_custom_libcxx) {
244 cflags_cc += [ "-nostdinc++" ] 295 cflags_cc += [ "-nostdinc++" ]
245 include_dirs = [ 296 include_dirs = [
246 "//buildtools/third_party/libc++/trunk/include", 297 "//buildtools/third_party/libc++/trunk/include",
247 "//buildtools/third_party/libc++abi/trunk/include", 298 "//buildtools/third_party/libc++abi/trunk/include",
248 ] 299 ]
249 } 300 }
250 } 301 }
251 302
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 "-fPIC", 510 "-fPIC",
460 "-pipe", # Use pipes for communicating between sub-processes. Faster. 511 "-pipe", # Use pipes for communicating between sub-processes. Faster.
461 ] 512 ]
462 513
463 ldflags += [ 514 ldflags += [
464 "-fPIC", 515 "-fPIC",
465 "-Wl,-z,noexecstack", 516 "-Wl,-z,noexecstack",
466 "-Wl,-z,now", 517 "-Wl,-z,now",
467 "-Wl,-z,relro", 518 "-Wl,-z,relro",
468 ] 519 ]
469 if (!using_sanitizer) { 520 if (!using_sanitizer && !use_cfi_diag) {
470 ldflags += [ "-Wl,-z,defs" ] 521 ldflags += [ "-Wl,-z,defs" ]
471 } 522 }
472 } 523 }
473 524
474 # Linux-specific compiler flags setup. 525 # Linux-specific compiler flags setup.
475 # ------------------------------------ 526 # ------------------------------------
476 if (is_linux) { 527 if (is_linux) {
477 cflags += [ "-pthread" ] 528 cflags += [ "-pthread" ]
478 ldflags += [ "-pthread" ] 529 ldflags += [ "-pthread" ]
479 } 530 }
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 # rtti ------------------------------------------------------------------------ 1143 # rtti ------------------------------------------------------------------------
1093 # 1144 #
1094 # Allows turning Run-Time Type Identification on or off. 1145 # Allows turning Run-Time Type Identification on or off.
1095 1146
1096 config("rtti") { 1147 config("rtti") {
1097 if (is_win) { 1148 if (is_win) {
1098 cflags_cc = [ "/GR" ] 1149 cflags_cc = [ "/GR" ]
1099 } 1150 }
1100 } 1151 }
1101 config("no_rtti") { 1152 config("no_rtti") {
1102 if (is_win) { 1153 # CFI diagnostics require RTTI.
1103 cflags_cc = [ "/GR-" ] 1154 if (!use_cfi_diag) {
1104 } else { 1155 if (is_win) {
1105 cflags_cc = [ "-fno-rtti" ] 1156 cflags_cc = [ "/GR-" ]
1106 cflags_objcc = cflags_cc 1157 } else {
1158 cflags_cc = [ "-fno-rtti" ]
1159 cflags_objcc = cflags_cc
1160 }
1107 } 1161 }
1108 } 1162 }
1109 1163
1110 # Warnings --------------------------------------------------------------------- 1164 # Warnings ---------------------------------------------------------------------
1111 1165
1112 # This will generate warnings when using Clang if code generates exit-time 1166 # This will generate warnings when using Clang if code generates exit-time
1113 # destructors, which will slow down closing the program. 1167 # destructors, which will slow down closing the program.
1114 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600 1168 # TODO(thakis): Make this a blacklist instead, http://crbug.com/101600
1115 config("wexit_time_destructors") { 1169 config("wexit_time_destructors") {
1116 # TODO: Enable on Windows too, http://crbug.com/404525 1170 # TODO: Enable on Windows too, http://crbug.com/404525
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 cflags += [ "-gsplit-dwarf" ] 1396 cflags += [ "-gsplit-dwarf" ]
1343 } 1397 }
1344 } 1398 }
1345 } 1399 }
1346 1400
1347 config("no_symbols") { 1401 config("no_symbols") {
1348 if (!is_win) { 1402 if (!is_win) {
1349 cflags = [ "-g0" ] 1403 cflags = [ "-g0" ]
1350 } 1404 }
1351 } 1405 }
OLDNEW
« no previous file with comments | « no previous file | build/config/sanitizers/sanitizers.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698