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

Side by Side Diff: gn/BUILD.gn

Issue 2289343002: GN: add sanitize arg (Closed)
Patch Set: rebase Created 4 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
OLDNEW
1 # Copyright 2016 Google Inc. 1 # Copyright 2016 Google Inc.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 declare_args() { 6 declare_args() {
7 ar = "ar" 7 ar = "ar"
8 cc = "cc" 8 cc = "cc"
9 cxx = "c++" 9 cxx = "c++"
10 10
11 if (is_android) { 11 if (is_android) {
12 ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar" 12 ar = "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin/ar"
13 cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang" 13 cc = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
14 cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++" 14 cxx = "$ndk/toolchains/llvm/prebuilt/$ndk_host/bin/clang++"
15 } 15 }
16 16
17 extra_cflags = "" 17 extra_cflags = ""
18 extra_cflags_c = "" 18 extra_cflags_c = ""
19 extra_cflags_cc = "" 19 extra_cflags_cc = ""
20 extra_ldflags = "" 20 extra_ldflags = ""
21 21
22 compiler_prefix = "" 22 compiler_prefix = ""
23 } 23 }
24 24
25 config("no_rtti") { 25 config("no_rtti") {
26 cflags_cc = [ "-fno-rtti" ] 26 if (sanitize != "ASAN") { # -fsanitize=vptr requires RTTI
27 cflags_cc = [ "-fno-rtti" ]
28 }
27 } 29 }
28 30
29 config("default") { 31 config("default") {
30 cflags = [ 32 cflags = [
31 "-O1", 33 "-O1",
32 "-g", 34 "-g",
33 "-fstrict-aliasing", 35 "-fstrict-aliasing",
34 "-fPIC", 36 "-fPIC",
35 "-fvisibility=hidden", 37 "-fvisibility=hidden",
36 38
37 "-Werror", 39 "-Werror",
38 "-Wall", 40 "-Wall",
39 "-Wextra", 41 "-Wextra",
40 "-Winit-self", 42 "-Winit-self",
41 "-Wpointer-arith", 43 "-Wpointer-arith",
42 "-Wsign-compare", 44 "-Wsign-compare",
43 "-Wvla", 45 "-Wvla",
44 46
45 "-Wno-deprecated-declarations", 47 "-Wno-deprecated-declarations",
46 "-Wno-unused-parameter", 48 "-Wno-unused-parameter",
47 ] 49 ]
48 cflags_cc = [ 50 cflags_cc = [
49 "-std=c++11", 51 "-std=c++11",
50 "-fno-exceptions", 52 "-fno-exceptions",
51 "-fno-threadsafe-statics", 53 "-fno-threadsafe-statics",
52 "-fvisibility-inlines-hidden", 54 "-fvisibility-inlines-hidden",
53 55
54 "-Wnon-virtual-dtor", 56 "-Wnon-virtual-dtor",
55 ] 57 ]
58 ldflags = []
59
56 if (current_cpu == "arm") { 60 if (current_cpu == "arm") {
57 cflags += [ 61 cflags += [
58 "-march=armv7-a", 62 "-march=armv7-a",
59 "-mfpu=neon", 63 "-mfpu=neon",
60 "-mthumb", 64 "-mthumb",
61 ] 65 ]
62 } else if (current_cpu == "mipsel") { 66 } else if (current_cpu == "mipsel") {
63 cflags += [ 67 cflags += [
64 "-march=mips32r2", 68 "-march=mips32r2",
65 "-mdspr2", 69 "-mdspr2",
66 ] 70 ]
67 } 71 }
68 72
69 if (is_android) { 73 if (is_android) {
70 asmflags = [ 74 asmflags = [
71 "--target=$ndk_target", 75 "--target=$ndk_target",
72 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", 76 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
73 ] 77 ]
74 cflags += [ 78 cflags += [
75 "--sysroot=$ndk/platforms/$ndk_platform", 79 "--sysroot=$ndk/platforms/$ndk_platform",
76 "--target=$ndk_target", 80 "--target=$ndk_target",
77 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", 81 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
78 ] 82 ]
79 cflags_cc += [ 83 cflags_cc += [
80 "-isystem$ndk/sources/android/support/include", 84 "-isystem$ndk/sources/android/support/include",
81 "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include", 85 "-isystem$ndk/sources/cxx-stl/llvm-libc++/libcxx/include",
82 ] 86 ]
83 ldflags = [ 87 ldflags += [
84 "--sysroot=$ndk/platforms/$ndk_platform", 88 "--sysroot=$ndk/platforms/$ndk_platform",
85 "--target=$ndk_target", 89 "--target=$ndk_target",
86 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin", 90 "-B$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/$ndk_target/bin",
87 "-pie", 91 "-pie",
88 ] 92 ]
89 lib_dirs = [ 93 lib_dirs = [
90 "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib", 94 "$ndk/sources/cxx-stl/llvm-libc++/libs/$ndk_stdlib",
91 "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4. 9.x", 95 "$ndk/toolchains/$ndk_gccdir-4.9/prebuilt/$ndk_host/lib/gcc/$ndk_target/4. 9.x",
92 ] 96 ]
93 libs = [ 97 libs = [
94 # Order matters here! Keep these three in exactly this order. 98 # Order matters here! Keep these three in exactly this order.
95 "c++_static", 99 "c++_static",
96 "c++abi", 100 "c++abi",
97 "android_support", 101 "android_support",
98 ] 102 ]
99 if (target_cpu == "arm") { 103 if (target_cpu == "arm") {
100 libs += [ "unwind" ] 104 libs += [ "unwind" ]
101 } 105 }
102 } 106 }
103 107
104 if (is_linux) { 108 if (is_linux) {
105 libs = [ "pthread" ] 109 libs = [ "pthread" ]
106 } 110 }
111
112 if (sanitize != "") {
113 # You can either pass the sanitizers directly, e.g. "address,undefined",
114 # or pass one of the couple common aliases used by the bots.
115 sanitizers = sanitize
116 if (sanitize == "ASAN") {
117 sanitizers = "address,bool,function,integer-divide-by-zero,nonnull-attribu te,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overfl ow,unreachable,vla-bound,vptr"
118 } else if (sanitize == "TSAN") {
119 sanitizers = "thread"
120 } else if (sanitize == "MSAN") {
121 sanitizers = "memory"
122 }
123
124 cflags += [
125 "-fsanitize=$sanitizers",
126 "-fno-sanitize-recover=$sanitizers",
127 "-fsanitize-blacklist=" + rebase_path("../tools/xsan.blacklist"),
128 ]
129 ldflags += [ "-fsanitize=$sanitizers" ]
130 if (sanitizers == "memory") {
131 cflags += [ "-fsanitize-memory-track-origins" ]
132 cflags_cc += [ "-stdlib=libc++" ]
133 ldflags += [ "-stdlib=libc++" ]
134 }
135 }
107 } 136 }
108 137
109 config("release") { 138 config("release") {
110 cflags = [ "-O3" ] 139 cflags = [ "-O3" ]
111 defines = [ "NDEBUG" ] 140 defines = [ "NDEBUG" ]
112 } 141 }
113 142
114 config("executable") { 143 config("executable") {
115 if (is_mac) { 144 if (is_mac) {
116 ldflags = [ "-Wl,-rpath,@loader_path/." ] 145 ldflags = [ "-Wl,-rpath,@loader_path/." ]
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 221 }
193 222
194 tool("stamp") { 223 tool("stamp") {
195 command = "touch {{output}}" 224 command = "touch {{output}}"
196 } 225 }
197 226
198 tool("copy") { 227 tool("copy") {
199 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" 228 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
200 } 229 }
201 } 230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698