1# Copyright 2017 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/buildflag_header.gni") 6import("//build/config/coverage/coverage.gni") 7import("//build/config/rust.gni") 8 9config("default_coverage") { 10 if (use_clang_coverage) { 11 configs = [] 12 ldflags = [] 13 rustflags = [] 14 if (!is_win) { 15 ldflags += [ "-fprofile-instr-generate" ] 16 } else { 17 # Windows directly calls link.exe instead of the compiler driver when 18 # linking, and embeds the path to the profile runtime library as 19 # dependent library into each object file. 20 # 21 # However... some build targets have no C++ object file (they have Rust 22 # instead), and thus the linker ends up not pulling in the profile 23 # library. So we add an edge to it directly. 24 if (toolchain_has_rust) { 25 configs += [ "//build/config/clang:compiler_profile" ] 26 } 27 } 28 29 cflags = [ 30 "-fprofile-instr-generate", 31 "-fcoverage-mapping", 32 33 # Following experimental flags removes unused header functions from the 34 # coverage mapping data embedded in the test binaries, and the reduction 35 # of binary size enables building Chrome's large unit test targets on 36 # MacOS. Please refer to crbug.com/796290 for more details. 37 "-mllvm", 38 "-limited-coverage-experimental=true", 39 ] 40 41 # Rust coverage is gated on using the Chromium-built Rust toolchain as it 42 # needs to have a compatible LLVM version with the C++ compiler and the LLVM 43 # tools that will be used to process the coverage output. This is because 44 # the coverage file format is not stable. 45 if (use_chromium_rust_toolchain) { 46 rustflags += [ "-Cinstrument-coverage" ] 47 } 48 49 if (is_linux || is_chromeos) { 50 # TODO(crbug.com/1194301): Remove this flag. 51 cflags += [ "-fno-use-cxa-atexit" ] 52 } 53 } 54} 55 56buildflag_header("buildflags") { 57 header = "buildflags.h" 58 flags = [ "USE_JAVASCRIPT_COVERAGE=$use_javascript_coverage" ] 59} 60