blob: 170bbcca2e7ecc4f3eade04af671c8d5dcc2c1ca [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT
import("//build/zircon/migrated_targets.gni")
zx_library("instrumentation") {
kernel = true
sources = []
public_deps = [ "//zircon/system/ulib/fbl:headers" ]
if (is_kernel) {
sources += [ "vmo.cc" ]
deps = [
":profile",
":sancov",
"asan",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/version",
"//zircon/kernel/object",
"//zircon/system/ulib/fbl",
]
public_deps += [
# <lib/instrumentation/asan/asan-init-x64.cc> has #include <lib/counters.h>
# TODO(fxbug.dev/51163): Move this to deps when possible.
"//zircon/kernel/lib/counters",
# <lib/instrumentation/vmo.h> has #include <ktl/array.h>.
"//zircon/kernel/lib/ktl:headers",
# TODO(fxbug.dev/51163): Move this to deps when possible.
# <lib/instrumentation/asan/asan-init.cc> has #include <vm/vm_aspace.h>.
"//zircon/kernel/vm:headers",
]
}
}
# This defines C symbol `__llvm_profile_header` with reference to the other
# `__llvm_prof*` sections generated by the compiler. These pasted together in
# the right order make up the data file format understood by `llvm-profdata`.
# That can be done statically in a linker script, or dynamically at run time
# by code referring to the various implicit `__start___llvm_prof*` symbols.
# The compiler also generates a dummy reference to `__llvm_profile_runtime`,
# so a symbol by that name must be defined at link time regardless; this file
# also defines it.
source_set("profile") {
_profile_config = [ "//build/config/profile" ]
_has_profile = toolchain_variant.configs + _profile_config -
_profile_config != toolchain_variant.configs
if (_has_profile) {
sources = [ "profile.cc" ]
if (current_os == "win") {
# The LLVM header file describing the instrumentation data tests this.
defines = [ "_WIN32" ]
}
}
}
source_set("sancov") {
_sancov_config = [ "//build/config/sanitizers:sancov" ]
if (configs + _sancov_config - _sancov_config != configs) {
configs -= _sancov_config
sources = [ "sancov.cc" ]
}
# sancov code shouldn't make asan checks.
# Annotating the functions with NO_ASAN is not enough, as it doesnt
# allow for ktl::atomic operations to be inlined.
_asan_config = [ "//build/config/sanitizers:asan" ]
if (configs + _asan_config - _asan_config != configs) {
configs -= _asan_config
}
}