Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go link: use external linker when in race mode #3370

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion go/private/actions/link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ def emit_link(
tool_args = go.tool_args(go)

# Add in any mode specific behaviours
tool_args.add_all(extld_from_cc_toolchain(go))
extld = extld_from_cc_toolchain(go)
tool_args.add_all(extld)
if go.mode.race:
tool_args.add("-race")
if go.mode.msan:
tool_args.add("-msan")
if ((go.mode.static and not go.mode.pure) or
(go.mode.race and extld) or
go.mode.link != LINKMODE_NORMAL or
go.mode.goos == "windows" and (go.mode.race or go.mode.msan)):
# Force external linking for the following conditions:
Expand All @@ -106,6 +108,11 @@ def emit_link(
# incompatibilities with mingw, and we get link errors in race mode.
# Using the C linker avoids that. Race and msan always require a
# a C toolchain. See #2614.
# * Linux race builds: we get linker errors during build with Go's
# internal linker. For example, when using zig cc v0.10
# (clang-15.0.3):
#
# runtime/cgo(.text): relocation target memset not defined
tool_args.add("-linkmode", "external")
if go.mode.pure:
# Force internal linking in pure mode. We don't have a C toolchain,
Expand Down