Chromium Code Reviews| Index: build/toolchain/gcc_toolchain.gni |
| diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni |
| index b31980668d89732523e9765f83e2e24f7caf1a4d..6673640ffd2c2e4a14a8acdf70239d4d2c08eb16 100644 |
| --- a/build/toolchain/gcc_toolchain.gni |
| +++ b/build/toolchain/gcc_toolchain.gni |
| @@ -12,6 +12,13 @@ import("//build/toolchain/clang_static_analyzer.gni") |
| import("//build/toolchain/goma.gni") |
| import("//build/toolchain/toolchain.gni") |
| +# Path to the Clang static analysis wrapper script. |
| +# REVIEWERS: can you suggest a better location for this? |
| +# GN is really picky about dead stores of variables except at the global scope. |
| +analyzer_wrapper = |
| + rebase_path("//build/toolchain/clang_static_analyzer_wrapper.py", |
| + root_build_dir) |
| + |
| # This template defines a toolchain for something that works like gcc |
| # (including clang). |
| # |
| @@ -121,27 +128,47 @@ template("gcc_toolchain") { |
| } else { |
| toolchain_uses_goma = use_goma |
| } |
| - if (defined(toolchain_args.cc_wrapper)) { |
| - toolchain_cc_wrapper = toolchain_args.cc_wrapper |
| - } else { |
| - toolchain_cc_wrapper = cc_wrapper |
| - } |
| # Compute the compiler prefix. |
| + compiler_prefix = "" |
| 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
|
| - assert(toolchain_cc_wrapper == "", |
| - "Goma and cc_wrapper can't be used together.") |
| - compiler_prefix = "$goma_dir/gomacc " |
| - } else if (toolchain_cc_wrapper != "") { |
| - compiler_prefix = toolchain_cc_wrapper + " " |
| + goma_path = "$goma_dir/gomacc" |
| + |
| + # Use the static analysis script if static analysis is turned on |
| + # AND the tool has not opted out by setting |
| + # 'is_clang_static_analysis_supported' to false. |
| + if (is_clang && use_clang_static_analyzer && |
| + (!defined(invoker.is_clang_analysis_supported) || |
| + invoker.is_clang_analysis_supported)) { |
| + compiler_prefix = "${analyzer_wrapper} $goma_path " |
| + |
| + # Create a distinct variable for "asm", since analysis runs pass |
| + # a bunch of flags to clang/clang++ that are nonsensical on assembler |
| + # runs. |
| + asm = "${goma_path} ${invoker.cc}" |
| + } else { |
| + compiler_prefix = "${goma_path} " |
| + } |
| } else { |
| - compiler_prefix = "" |
| + if (defined(toolchain_args.cc_wrapper)) { |
| + compiler_prefix = "${toolchain_args.cc_wrapper} " |
| + } else if (is_clang && use_clang_static_analyzer && |
| + (!defined(invoker.is_clang_analysis_supported) || |
| + 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.
|
| + compiler_prefix = analyzer_wrapper + " " |
| + asm = invoker.cc |
| + } else { |
| + compiler_prefix = "${cc_wrapper} " |
| + } |
| } |
| cc = compiler_prefix + invoker.cc |
| cxx = compiler_prefix + invoker.cxx |
| ar = invoker.ar |
| ld = invoker.ld |
| + if (!defined(asm)) { |
| + asm = cc |
| + } |
| if (defined(invoker.readelf)) { |
| readelf = invoker.readelf |
| } else { |
| @@ -260,7 +287,7 @@ template("gcc_toolchain") { |
| tool("asm") { |
| # For GCC we can just use the C compiler to compile assembly. |
| depfile = "{{output}}.d" |
| - command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}" |
| + command = "$asm -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}" |
| depsformat = "gcc" |
| description = "ASM {{output}}" |
| outputs = [ |
| @@ -487,31 +514,15 @@ template("clang_toolchain") { |
| cc = "$prefix/clang" |
| cxx = "$prefix/clang++" |
| ld = cxx |
| - |
| - if (use_clang_static_analyzer) { |
| - # Static analysis isn't supported under GOMA. See crbug.com/687245 |
| - # for progress on this issue. |
| - assert(!use_goma, "'use_clang_static_analyzer' cannot be used with GOMA.") |
| - |
| - # Call "ccc-analyzer" or "c++-analyzer" instead of directly calling Clang. |
| - # |wrapper_tool| sets the environment variables which are read by the |
| - # analyzer tools. |
| - analyzer_wrapper = |
| - rebase_path("//build/toolchain/clang_static_analyzer_wrapper.py", |
| - root_build_dir) |
| - cc = analyzer_wrapper + " --clang-cc-path=${cc} --analyzer=" + |
| - rebase_path("//third_party/scan-build/src/libexec/ccc-analyzer", |
| - root_build_dir) |
| - cxx = analyzer_wrapper + " --clang-cxx-path=${cxx} --analyzer=" + |
| - rebase_path("//third_party/scan-build/src/libexec/c++-analyzer", |
| - root_build_dir) |
| - } |
| - |
| readelf = "${toolprefix}readelf" |
| ar = "${toolprefix}ar" |
| nm = "${toolprefix}nm" |
| - forward_variables_from(invoker, [ "strip" ]) |
| + forward_variables_from(invoker, |
| + [ |
| + "strip", |
| + "is_clang_analysis_supported", |
| + ]) |
| toolchain_args = { |
| if (defined(invoker.toolchain_args)) { |