Debug: add cgo symbolizer (#5255)

* Add cgo_symbolizer config

* Add comment

* use import block
This commit is contained in:
Preston Van Loon 2020-03-30 20:20:27 -07:00 committed by GitHub
parent 6edb3018f9
commit 00ef08b3dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 2 deletions

View File

@ -39,6 +39,12 @@ build:release --compilation_mode=opt
build:llvm --crosstool_top=@llvm_toolchain//:toolchain
build:llvm --define compiler=llvm
# Build binary with cgo symbolizer for debugging / profiling.
build:cgo_symbolizer --config=llvm
build:cgo_symbolizer --copt=-g
build:cgo_symbolizer --define=USE_CGO_SYMBOLIZER=true
build:cgo_symbolizer -c dbg
# multi-arch cross-compiling toolchain configs:
-----------------------------------------------
build:cross --crosstool_top=@prysm_toolchains//:multiarch_toolchain

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ bazel-*
# Coverage outputs
coverage.txt
profile.out
profile.grind
# Nodejs
node_modules

View File

@ -1649,3 +1649,10 @@ go_repository(
load("@com_github_prysmaticlabs_prombbolt//:repositories.bzl", "prombbolt_dependencies")
prombbolt_dependencies()
go_repository(
name = "com_github_ianlancetaylor_cgosymbolizer",
importpath = "github.com/ianlancetaylor/cgosymbolizer",
sum = "h1:GWsU1WjSE2rtvyTYGcndqmPPkQkBNV7pEuZdnGtwtu4=",
version = "v0.0.0-20200321040036-d43e30eacb43",
)

View File

@ -1,11 +1,20 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
config_setting(
name = "use_cgosymbolizer",
values = {"define": "USE_CGO_SYMBOLIZER=true"},
)
# gazelle:ignore cgo_symbolizer.go
go_library(
name = "go_default_library",
srcs = [
"debug.go",
"maxprocs_metric.go",
],
] + select({
":use_cgosymbolizer": ["cgo_symbolizer.go"],
"//conditions:default": [],
}),
importpath = "github.com/prysmaticlabs/prysm/shared/debug",
visibility = ["//visibility:public"],
deps = [
@ -14,5 +23,8 @@ go_library(
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@in_gopkg_urfave_cli_v2//:go_default_library",
],
] + select({
":use_cgosymbolizer": ["@com_github_ianlancetaylor_cgosymbolizer//:go_default_library"],
"//conditions:default": [],
}),
)

View File

@ -0,0 +1,8 @@
package debug
import (
// Using this file with this imported library configures the process to
// expose cgo symbols when possible. Use --config=cgo_symbolizer to make use of
// this feature.
_ "github.com/ianlancetaylor/cgosymbolizer"
)