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

Side by Side Diff: build/toolchain/gcc_toolchain.gni

Issue 2667853004: Remove dependency on scan-build wrapper script for Clang analysis builds. (Closed)
Patch Set: Added stdlib error suppression flag. Created 3 years, 9 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 (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/clang/clang.gni") 6 import("//build/config/clang/clang.gni")
7 import("//build/config/nacl/config.gni") 7 import("//build/config/nacl/config.gni")
8 import("//build/config/sanitizers/sanitizers.gni") 8 import("//build/config/sanitizers/sanitizers.gni")
9 import("//build/config/v8_target_cpu.gni") 9 import("//build/config/v8_target_cpu.gni")
10 import("//build/toolchain/cc_wrapper.gni") 10 import("//build/toolchain/cc_wrapper.gni")
11 import("//build/toolchain/clang_static_analyzer.gni") 11 import("//build/toolchain/clang_static_analyzer.gni")
12 import("//build/toolchain/goma.gni") 12 import("//build/toolchain/goma.gni")
13 import("//build/toolchain/toolchain.gni") 13 import("//build/toolchain/toolchain.gni")
14 14
15 # Path to the Clang static analysis wrapper script.
16 # REVIEWERS: can you suggest a better location for this?
17 # GN is really picky about dead stores of variables except at the global scope.
Nico 2017/03/10 01:55:02 I think the usual workaround is to assert() on the
18 analyzer_wrapper =
19 rebase_path("//build/toolchain/clang_static_analyzer_wrapper.py",
20 root_build_dir)
21
15 # This template defines a toolchain for something that works like gcc 22 # This template defines a toolchain for something that works like gcc
16 # (including clang). 23 # (including clang).
17 # 24 #
18 # It requires the following variables specifying the executables to run: 25 # It requires the following variables specifying the executables to run:
19 # - ar 26 # - ar
20 # - cc 27 # - cc
21 # - cxx 28 # - cxx
22 # - ld 29 # - ld
23 # 30 #
24 # Optional parameters that control the tools: 31 # Optional parameters that control the tools:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (defined(toolchain_args.use_goma)) { 126 if (defined(toolchain_args.use_goma)) {
120 toolchain_uses_goma = toolchain_args.use_goma 127 toolchain_uses_goma = toolchain_args.use_goma
121 } else { 128 } else {
122 toolchain_uses_goma = use_goma 129 toolchain_uses_goma = use_goma
123 } 130 }
124 if (defined(toolchain_args.cc_wrapper)) { 131 if (defined(toolchain_args.cc_wrapper)) {
125 toolchain_cc_wrapper = toolchain_args.cc_wrapper 132 toolchain_cc_wrapper = toolchain_args.cc_wrapper
126 } else { 133 } else {
127 toolchain_cc_wrapper = cc_wrapper 134 toolchain_cc_wrapper = cc_wrapper
128 } 135 }
136 assert(!(toolchain_cc_wrapper != "" && toolchain_uses_goma),
137 "Goma and cc_wrapper can't be used together.")
129 138
130 # Compute the compiler prefix. 139 # When the invoker has explicitly overridden use_goma or cc_wrapper in the
140 # toolchain args, use those values, otherwise default to the global one.
141 # This works because the only reasonable override that toolchains might
142 # supply for these values are to force-disable them.
131 if (toolchain_uses_goma) { 143 if (toolchain_uses_goma) {
132 assert(toolchain_cc_wrapper == "", 144 goma_path = "$goma_dir/gomacc"
133 "Goma and cc_wrapper can't be used together.") 145
134 compiler_prefix = "$goma_dir/gomacc " 146 # Use the static analysis script if static analysis is turned on
135 } else if (toolchain_cc_wrapper != "") { 147 # AND the tool has not opted out by setting
136 compiler_prefix = toolchain_cc_wrapper + " " 148 # 'is_clang_static_analysis_supported' to false.
149 if (is_clang && use_clang_static_analyzer &&
150 (!defined(invoker.is_clang_analysis_supported) ||
151 invoker.is_clang_analysis_supported)) {
152 compiler_prefix = "${analyzer_wrapper} ${goma_path} "
153
154 # Create a distinct variable for "asm", since analysis runs pass
155 # a bunch of flags to clang/clang++ that are nonsensical on assembler
156 # runs.
157 asm = "${goma_path} ${invoker.cc}"
158 } else {
159 compiler_prefix = "${goma_path} "
160 }
137 } else { 161 } else {
138 compiler_prefix = "" 162 if (is_clang && use_clang_static_analyzer &&
163 (!defined(invoker.is_clang_analysis_supported) ||
164 invoker.is_clang_analysis_supported)) {
165 compiler_prefix = "${analyzer_wrapper} "
166 asm = invoker.cc
167 } else {
168 compiler_prefix = "${toolchain_cc_wrapper} "
169 }
139 } 170 }
140 171
141 cc = compiler_prefix + invoker.cc 172 cc = compiler_prefix + invoker.cc
142 cxx = compiler_prefix + invoker.cxx 173 cxx = compiler_prefix + invoker.cxx
143 ar = invoker.ar 174 ar = invoker.ar
144 ld = invoker.ld 175 ld = invoker.ld
176 if (!defined(asm)) {
177 asm = cc
178 }
145 if (defined(invoker.readelf)) { 179 if (defined(invoker.readelf)) {
146 readelf = invoker.readelf 180 readelf = invoker.readelf
147 } else { 181 } else {
148 readelf = "readelf" 182 readelf = "readelf"
149 } 183 }
150 if (defined(invoker.nm)) { 184 if (defined(invoker.nm)) {
151 nm = invoker.nm 185 nm = invoker.nm
152 } else { 186 } else {
153 nm = "nm" 187 nm = "nm"
154 } 188 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 compile_wrapper = 287 compile_wrapper =
254 rebase_path("//build/toolchain/gcc_compile_wrapper.py", 288 rebase_path("//build/toolchain/gcc_compile_wrapper.py",
255 root_build_dir) 289 root_build_dir)
256 command = "$python_path \"$compile_wrapper\" --resource-whitelist=\"{{ou tput}}.whitelist\" $command" 290 command = "$python_path \"$compile_wrapper\" --resource-whitelist=\"{{ou tput}}.whitelist\" $command"
257 } 291 }
258 } 292 }
259 293
260 tool("asm") { 294 tool("asm") {
261 # For GCC we can just use the C compiler to compile assembly. 295 # For GCC we can just use the C compiler to compile assembly.
262 depfile = "{{output}}.d" 296 depfile = "{{output}}.d"
263 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}" 297 command = "$asm -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{asmflags}} -c {{source}} -o {{output}}"
264 depsformat = "gcc" 298 depsformat = "gcc"
265 description = "ASM {{output}}" 299 description = "ASM {{output}}"
266 outputs = [ 300 outputs = [
267 "$object_subdir/{{source_name_part}}.o", 301 "$object_subdir/{{source_name_part}}.o",
268 ] 302 ]
269 } 303 }
270 304
271 tool("alink") { 305 tool("alink") {
272 rspfile = "{{output}}.rsp" 306 rspfile = "{{output}}.rsp"
273 whitelist_flag = " " 307 whitelist_flag = " "
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 toolprefix = invoker.toolprefix 514 toolprefix = invoker.toolprefix
481 } else { 515 } else {
482 toolprefix = "" 516 toolprefix = ""
483 } 517 }
484 518
485 gcc_toolchain(target_name) { 519 gcc_toolchain(target_name) {
486 prefix = rebase_path("$clang_base_path/bin", root_build_dir) 520 prefix = rebase_path("$clang_base_path/bin", root_build_dir)
487 cc = "$prefix/clang" 521 cc = "$prefix/clang"
488 cxx = "$prefix/clang++" 522 cxx = "$prefix/clang++"
489 ld = cxx 523 ld = cxx
490
491 if (use_clang_static_analyzer) {
492 # Static analysis isn't supported under GOMA. See crbug.com/687245
493 # for progress on this issue.
494 assert(!use_goma, "'use_clang_static_analyzer' cannot be used with GOMA.")
495
496 # Call "ccc-analyzer" or "c++-analyzer" instead of directly calling Clang.
497 # |wrapper_tool| sets the environment variables which are read by the
498 # analyzer tools.
499 analyzer_wrapper =
500 rebase_path("//build/toolchain/clang_static_analyzer_wrapper.py",
501 root_build_dir)
502 cc = analyzer_wrapper + " --clang-cc-path=${cc} --analyzer=" +
503 rebase_path("//third_party/scan-build/src/libexec/ccc-analyzer",
504 root_build_dir)
505 cxx = analyzer_wrapper + " --clang-cxx-path=${cxx} --analyzer=" +
506 rebase_path("//third_party/scan-build/src/libexec/c++-analyzer",
507 root_build_dir)
508 }
509
510 readelf = "${toolprefix}readelf" 524 readelf = "${toolprefix}readelf"
511 ar = "${toolprefix}ar" 525 ar = "${toolprefix}ar"
512 nm = "${toolprefix}nm" 526 nm = "${toolprefix}nm"
513 527
514 forward_variables_from(invoker, [ "strip" ]) 528 forward_variables_from(invoker,
529 [
530 "strip",
531 "is_clang_analysis_supported",
532 ])
515 533
516 toolchain_args = { 534 toolchain_args = {
517 if (defined(invoker.toolchain_args)) { 535 if (defined(invoker.toolchain_args)) {
518 forward_variables_from(invoker.toolchain_args, "*") 536 forward_variables_from(invoker.toolchain_args, "*")
519 } 537 }
520 is_clang = true 538 is_clang = true
521 } 539 }
522 } 540 }
523 } 541 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698