1

update rules_go

this is used only in tests.
This commit is contained in:
Motiejus Jakštys 2022-12-11 22:06:28 +02:00
parent 1fb93e089c
commit 47d54b8099
3 changed files with 7 additions and 62 deletions

View File

@ -4,19 +4,18 @@ workspace(
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive( http_archive(
name = "io_bazel_rules_go", name = "io_bazel_rules_go",
patch_args = ["-p1"], sha256 = "56d8c5a5c91e1af73eca71a6fab2ced959b67c86d12ba37feedb0a2dfea441a6",
patches = [
"//patches:rulesgo-race-extld.patch", # https://github.com/bazelbuild/rules_go/pull/3370
],
sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
urls = [ urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip", "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.37.0/rules_go-v0.37.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.37.0/rules_go-v0.37.0.zip",
], ],
) )
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
http_archive( http_archive(
name = "bazel_gazelle", name = "bazel_gazelle",
sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e", sha256 = "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e",
@ -34,6 +33,7 @@ go_rules_dependencies()
# use latest stable. # use latest stable.
go_download_sdk( go_download_sdk(
name = "go_sdk", name = "go_sdk",
#version = "1.20rc1",
version = "1.19.3", version = "1.19.3",
) )

View File

@ -1 +0,0 @@
exports_files(glob(["*.patch"]))

View File

@ -1,54 +0,0 @@
From 4c15193a7f1a94895a5e0af0f0a15879af040ce2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= <motiejus@uber.com>
Date: Wed, 30 Nov 2022 10:38:18 +0200
Subject: [PATCH] go link: use external linker when in race mode
As of clang 15.0.3 (via zig v0.10), when building with `race = "on"` on
x86_64 Linux, we observe the following:
runtime/cgo(.text): relocation target memset not defined
From my past experience, reporting a Go linker error when the external
linker works has a high chance to get the ticket closed as unactionable;
so it makes sense to just use an external linker, when it works.
Also, do not set the flag if external cpp toolchain is not set up.
---
go/private/actions/link.bzl | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/go/private/actions/link.bzl b/go/private/actions/link.bzl
index 7f059e2d..ddc9cd0e 100644
--- a/go/private/actions/link.bzl
+++ b/go/private/actions/link.bzl
@@ -80,12 +80,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:
@@ -97,6 +99,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,
--
2.34.1