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

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: Removed goma TODO from docs Created 3 years, 10 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.
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 121
115 # When the invoker has explicitly overridden use_goma or cc_wrapper in the 122 # When the invoker has explicitly overridden use_goma or cc_wrapper in the
116 # toolchain args, use those values, otherwise default to the global one. 123 # toolchain args, use those values, otherwise default to the global one.
117 # This works because the only reasonable override that toolchains might 124 # This works because the only reasonable override that toolchains might
118 # supply for these values are to force-disable them. 125 # supply for these values are to force-disable them.
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)) {
125 toolchain_cc_wrapper = toolchain_args.cc_wrapper
126 } else {
127 toolchain_cc_wrapper = cc_wrapper
128 }
129 131
130 # Compute the compiler prefix. 132 # Compute the compiler prefix.
133 compiler_prefix = ""
131 if (toolchain_uses_goma) { 134 if (toolchain_uses_goma) {
Wez 2017/02/03 08:05:00 Should we be asserting that toolchain_args.cc_wrap
Kevin M 2017/02/03 18:46:29 Done - did a little restructuring here while I'm a
Wez 2017/02/03 19:27:54 This looks better, but isn't it the case that comp
132 assert(toolchain_cc_wrapper == "", 135 goma_path = "$goma_dir/gomacc"
133 "Goma and cc_wrapper can't be used together.") 136
134 compiler_prefix = "$goma_dir/gomacc " 137 # Use the static analysis script if static analysis is turned on
135 } else if (toolchain_cc_wrapper != "") { 138 # AND the tool has not opted out by setting
136 compiler_prefix = toolchain_cc_wrapper + " " 139 # 'is_clang_static_analysis_supported' to false.
140 if (is_clang && use_clang_static_analyzer &&
141 (!defined(invoker.is_clang_analysis_supported) ||
142 invoker.is_clang_analysis_supported)) {
143 compiler_prefix = "${analyzer_wrapper} $goma_path "
144
145 # Create a distinct variable for "asm", since analysis runs pass
146 # a bunch of flags to clang/clang++ that are nonsensical on assembler
147 # runs.
148 asm = "${goma_path} ${invoker.cc}"
149 } else {
150 compiler_prefix = "${goma_path} "
151 }
137 } else { 152 } else {
138 compiler_prefix = "" 153 if (defined(toolchain_args.cc_wrapper)) {
154 compiler_prefix = "${toolchain_args.cc_wrapper} "
155 } else if (is_clang && use_clang_static_analyzer &&
156 (!defined(invoker.is_clang_analysis_supported) ||
157 invoker.is_clang_analysis_supported)) {
Wez 2017/02/03 08:05:00 Could you move this check ahead of the toolchain_u
Kevin M 2017/02/03 18:46:29 Done.
158 compiler_prefix = analyzer_wrapper + " "
159 asm = invoker.cc
160 } else {
161 compiler_prefix = "${cc_wrapper} "
162 }
139 } 163 }
140 164
141 cc = compiler_prefix + invoker.cc 165 cc = compiler_prefix + invoker.cc
142 cxx = compiler_prefix + invoker.cxx 166 cxx = compiler_prefix + invoker.cxx
143 ar = invoker.ar 167 ar = invoker.ar
144 ld = invoker.ld 168 ld = invoker.ld
169 if (!defined(asm)) {
170 asm = cc
171 }
145 if (defined(invoker.readelf)) { 172 if (defined(invoker.readelf)) {
146 readelf = invoker.readelf 173 readelf = invoker.readelf
147 } else { 174 } else {
148 readelf = "readelf" 175 readelf = "readelf"
149 } 176 }
150 if (defined(invoker.nm)) { 177 if (defined(invoker.nm)) {
151 nm = invoker.nm 178 nm = invoker.nm
152 } else { 179 } else {
153 nm = "nm" 180 nm = "nm"
154 } 181 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 compile_wrapper = 280 compile_wrapper =
254 rebase_path("//build/toolchain/gcc_compile_wrapper.py", 281 rebase_path("//build/toolchain/gcc_compile_wrapper.py",
255 root_build_dir) 282 root_build_dir)
256 command = "$python_path \"$compile_wrapper\" --resource-whitelist=\"{{ou tput}}.whitelist\" $command" 283 command = "$python_path \"$compile_wrapper\" --resource-whitelist=\"{{ou tput}}.whitelist\" $command"
257 } 284 }
258 } 285 }
259 286
260 tool("asm") { 287 tool("asm") {
261 # For GCC we can just use the C compiler to compile assembly. 288 # For GCC we can just use the C compiler to compile assembly.
262 depfile = "{{output}}.d" 289 depfile = "{{output}}.d"
263 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}" 290 command = "$asm -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{asmflags}} -c {{source}} -o {{output}}"
264 depsformat = "gcc" 291 depsformat = "gcc"
265 description = "ASM {{output}}" 292 description = "ASM {{output}}"
266 outputs = [ 293 outputs = [
267 "$object_subdir/{{source_name_part}}.o", 294 "$object_subdir/{{source_name_part}}.o",
268 ] 295 ]
269 } 296 }
270 297
271 tool("alink") { 298 tool("alink") {
272 rspfile = "{{output}}.rsp" 299 rspfile = "{{output}}.rsp"
273 whitelist_flag = " " 300 whitelist_flag = " "
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 toolprefix = invoker.toolprefix 507 toolprefix = invoker.toolprefix
481 } else { 508 } else {
482 toolprefix = "" 509 toolprefix = ""
483 } 510 }
484 511
485 gcc_toolchain(target_name) { 512 gcc_toolchain(target_name) {
486 prefix = rebase_path("$clang_base_path/bin", root_build_dir) 513 prefix = rebase_path("$clang_base_path/bin", root_build_dir)
487 cc = "$prefix/clang" 514 cc = "$prefix/clang"
488 cxx = "$prefix/clang++" 515 cxx = "$prefix/clang++"
489 ld = cxx 516 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" 517 readelf = "${toolprefix}readelf"
511 ar = "${toolprefix}ar" 518 ar = "${toolprefix}ar"
512 nm = "${toolprefix}nm" 519 nm = "${toolprefix}nm"
513 520
514 forward_variables_from(invoker, [ "strip" ]) 521 forward_variables_from(invoker,
522 [
523 "strip",
524 "is_clang_analysis_supported",
525 ])
515 526
516 toolchain_args = { 527 toolchain_args = {
517 if (defined(invoker.toolchain_args)) { 528 if (defined(invoker.toolchain_args)) {
518 forward_variables_from(invoker.toolchain_args, "*") 529 forward_variables_from(invoker.toolchain_args, "*")
519 } 530 }
520 is_clang = true 531 is_clang = true
521 } 532 }
522 } 533 }
523 } 534 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698