Skip to content

Commit

Permalink
Don't compile cgo code with --coverage (#1808)
Browse files Browse the repository at this point in the history
If we do an internal link, we may have undefined references to
coverage functions.

Fixes #1801
  • Loading branch information
jayconrod authored and Jay Conrod committed Nov 5, 2018
1 parent 07bcc88 commit 6fd13c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ _GoContextData = provider()
_COMPILER_OPTIONS_BLACKLIST = {
"-fcolor-diagnostics": None,
"-Wall": None,
"-g0": None, # symbols are needed by Go, so keep them

# Symbols are needed by Go, so keep them
"-g0": None,

# Don't compile generated cgo code with coverage. If we do an internal
# link, we may have undefined references to coverage functions.
"--coverage": None,
"-ftest-coverage": None,
"-fprofile-arcs": None,
}

_LINKER_OPTIONS_BLACKLIST = {
Expand Down
5 changes: 4 additions & 1 deletion tests/core/race/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ else
result=0
fi
""",
command = "test",
# NOTE(#1801): we use "coverage" instead of "test" here to verify that
# race binaries can link when coverage is enabled. Adding a new
# bazel_test, so we piggy-back on this one.
command = "coverage",
targets = [":race_auto_test"],
)

Expand Down

0 comments on commit 6fd13c5

Please sign in to comment.