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

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

Issue 2187063003: [Mac/GN] Use a special .symbol_resolver to help load the ASan dynamic library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Static symbol stubs Created 4 years, 4 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/generate_asan_runtime_stubs.py » ('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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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/chrome_build.gni") 5 import("//build/config/chrome_build.gni")
6 import("//build/config/chromecast_build.gni") 6 import("//build/config/chromecast_build.gni")
7 import("//build/config/clang/clang.gni") 7 import("//build/config/clang/clang.gni")
8 import("//build/config/sanitizers/sanitizers.gni") 8 import("//build/config/sanitizers/sanitizers.gni")
9 import("//build/toolchain/toolchain.gni") 9 import("//build/toolchain/toolchain.gni")
10 10
11 # Contains the dependencies needed for sanitizers to link into executables and 11 # Contains the dependencies needed for sanitizers to link into executables and
12 # shared_libraries. Unconditionally depend upon this target as it is empty if 12 # shared_libraries. Unconditionally depend upon this target as it is empty if
13 # |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false. 13 # |is_asan|, |is_lsan|, |is_tsan|, |is_msan| and |use_custom_libcxx| are false.
14 group("deps") { 14 group("deps") {
15 public_deps = [ 15 public_deps = [
16 ":deps_no_options", 16 ":deps_no_options",
17 ] 17 ]
18 if (using_sanitizer) { 18 if (using_sanitizer) {
19 public_configs = [ 19 public_configs = [
20 ":sanitizer_options_link_helper", 20 ":sanitizer_options_link_helper",
21 21
22 # Even when a target removes default_sanitizer_flags, it may be depending 22 # Even when a target removes default_sanitizer_flags, it may be depending
23 # on a library that did not remove default_sanitizer_flags. Thus, we need 23 # on a library that did not remove default_sanitizer_flags. Thus, we need
24 # to add the ldflags here as well as in default_sanitizer_flags. 24 # to add the ldflags here as well as in default_sanitizer_flags.
25 ":default_sanitizer_ldflags", 25 ":default_sanitizer_ldflags",
26 ] 26 ]
27 deps = [ 27 deps = [
28 ":options_sources", 28 ":options_sources",
29 ] 29 ]
30 if (is_mac) {
31 deps += [ ":asan_runtime_stubs" ]
32 }
30 } 33 }
31 if (use_afl) { 34 if (use_afl) {
32 deps += [ "//third_party/afl" ] 35 deps += [ "//third_party/afl" ]
33 } 36 }
34 } 37 }
35 38
36 group("deps_no_options") { 39 group("deps_no_options") {
37 if (using_sanitizer) { 40 if (using_sanitizer) {
38 public_configs = [ 41 public_configs = [
39 # Even when a target removes default_sanitizer_flags, it may be depending 42 # Even when a target removes default_sanitizer_flags, it may be depending
(...skipping 29 matching lines...) Expand all
69 } 72 }
70 if (is_mac) { 73 if (is_mac) {
71 data_deps = [ 74 data_deps = [
72 ":copy_asan_runtime", 75 ":copy_asan_runtime",
73 ] 76 ]
74 } 77 }
75 } 78 }
76 } 79 }
77 80
78 if (is_mac && using_sanitizer) { 81 if (is_mac && using_sanitizer) {
79 copy("copy_asan_runtime") { 82 action("copy_asan_runtime") {
83 script = "//build/config/sanitizers/copy_asan_runtime.py"
84 _lib_name = "libclang_rt.asan_osx_dynamic.dylib"
80 sources = [ 85 sources = [
81 "$clang_base_path/lib/clang/$clang_version/lib/darwin/libclang_rt.asan_osx _dynamic.dylib", 86 "$clang_base_path/lib/clang/$clang_version/lib/darwin/$_lib_name",
82 ] 87 ]
83 outputs = [ 88 outputs = [
84 "$root_out_dir/{{source_file_part}}", 89 "$root_out_dir/$_lib_name",
90 ]
91 args = rebase_path(sources + outputs, root_build_dir)
92 }
93
94 action("generate_asan_runtime_stubs") {
95 script = "//build/config/sanitizers/generate_asan_runtime_stubs.py"
96 inputs = get_target_outputs(":copy_asan_runtime")
97 outputs = [
98 "$target_gen_dir/asan_runtime_stubs.cc",
99 ]
100 args = rebase_path(inputs + outputs, root_build_dir)
101 deps = [ ":copy_asan_runtime" ]
102 }
103
104 source_set("asan_runtime_stubs") {
105 sources = get_target_outputs(":generate_asan_runtime_stubs")
106 deps = [ ":generate_asan_runtime_stubs" ]
107 configs = []
108 cflags = [
109 "-std=c++11",
110 "-mmacosx-version-min=10.7",
85 ] 111 ]
86 } 112 }
87 } 113 }
88 114
89 config("sanitizer_options_link_helper") { 115 config("sanitizer_options_link_helper") {
90 if (is_mac) { 116 if (is_mac) {
91 ldflags = [ "-Wl,-U,_sanitizer_options_link_helper" ] 117 ldflags = [ "-Wl,-U,_sanitizer_options_link_helper" ]
92 } else if (!is_win) { 118 } else if (!is_win) {
93 ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ] 119 ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ]
94 } 120 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ] 190 ]
165 } 191 }
166 if (use_cfi_diag) { 192 if (use_cfi_diag) {
167 ldflags += [ 193 ldflags += [
168 "-fno-sanitize-trap=cfi", 194 "-fno-sanitize-trap=cfi",
169 "-fsanitize-recover=cfi", 195 "-fsanitize-recover=cfi",
170 ] 196 ]
171 } 197 }
172 } 198 }
173 } 199 }
200
201 if (is_mac) {
202 ldflags += [ "-nodefaultlibs", "-lc++", "-lSystem", "-lc++abi" ]
203 }
174 } 204 }
175 205
176 config("common_sanitizer_flags") { 206 config("common_sanitizer_flags") {
177 cflags = [] 207 cflags = []
178 cflags_cc = [] 208 cflags_cc = []
179 209
180 # Sanitizers need line table info for stack traces. They don't need type info 210 # Sanitizers need line table info for stack traces. They don't need type info
181 # or variable info, so we can leave that out to speed up the build. 211 # or variable info, so we can leave that out to speed up the build.
182 if (using_sanitizer) { 212 if (using_sanitizer) {
183 assert(is_clang, "sanitizers only supported with clang") 213 assert(is_clang, "sanitizers only supported with clang")
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 # This allows to selectively disable ubsan_vptr, when needed. In particular, 462 # This allows to selectively disable ubsan_vptr, when needed. In particular,
433 # if some third_party code is required to be compiled without rtti, which 463 # if some third_party code is required to be compiled without rtti, which
434 # is a requirement for ubsan_vptr. 464 # is a requirement for ubsan_vptr.
435 config("default_sanitizer_flags_but_ubsan_vptr") { 465 config("default_sanitizer_flags_but_ubsan_vptr") {
436 configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ] 466 configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ]
437 } 467 }
438 468
439 config("default_sanitizer_flags_but_coverage") { 469 config("default_sanitizer_flags_but_coverage") {
440 configs = all_sanitizer_configs - [ ":coverage_flags" ] 470 configs = all_sanitizer_configs - [ ":coverage_flags" ]
441 } 471 }
OLDNEW
« no previous file with comments | « no previous file | build/config/sanitizers/generate_asan_runtime_stubs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698