1
Fork 0

remove rules/rules_go

1. Go needed quite a few hacks to be made work with Go. From
   https://github.com/ziglang/zig/pull/15060 less hacks are needed (but
   still not zero, though now documented).
2. This file was never meant to be exposed as part of
   `hermetic_cc_toolchain`. I probably broke someone. Sorry.
main
Motiejus Jakštys 2023-04-24 14:25:29 +03:00 committed by Motiejus Jakštys
parent cb46744cb8
commit 491144c721
6 changed files with 11 additions and 33 deletions

2
BUILD
View File

@ -3,8 +3,6 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:map_kind go_binary go_binary //rules:rules_go.bzl
# gazelle:build_file_name BUILD
# gazelle:prefix github.com/uber/hermetic_cc_toolchain
# gazelle:exclude tools.go

View File

@ -30,7 +30,7 @@ go_rules_dependencies()
# use latest stable.
go_download_sdk(
name = "go_sdk",
version = "1.20",
version = "1.20.3",
)
go_register_toolchains()

View File

@ -1,24 +0,0 @@
# Copyright 2023 Uber Technologies, Inc.
# Licensed under the MIT License
load("@io_bazel_rules_go//go:def.bzl", go_binary_rule = "go_binary")
"""
go_binary overrides go_binary from rules_go and provides default
gc_linkopts values that are needed to compile for macos target.
To use it, add this map_kind gazelle directive to your BUILD.bazel files
where target binary needs to be compiled with zig toolchain.
Example: if this toolchain is registered as hermetic_cc_toolchain in your WORKSPACE, add this to
your root BUILD file
# gazelle:map_kind go_binary go_binary @hermetic_cc_toolchain//rules:rules_go.bzl
"""
_MACOS_GC_LINKOPTS = ["-s", "-w", "-buildmode=pie"]
def go_binary(**kwargs):
kwargs["gc_linkopts"] = select({
"@platforms//os:macos": _MACOS_GC_LINKOPTS,
"//conditions:default": [],
}) + kwargs.pop("gc_linkopts", [])
go_binary_rule(**kwargs)

View File

@ -1,8 +1,7 @@
# Copyright 2023 Uber Technologies, Inc.
# Licensed under the MIT License
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//rules:rules_go.bzl", "go_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary", "platform_test")
go_library(
@ -22,6 +21,13 @@ go_test(
go_binary(
name = "cgo",
embed = [":cgo_lib"],
gc_linkopts = select({
"@platforms//os:macos": [
"-w", # https://github.com/ziglang/zig/issues/15439
"-buildmode=pie", # https://github.com/ziglang/zig/issues/15438
],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
)

View File

@ -1,8 +1,7 @@
# Copyright 2023 Uber Technologies, Inc.
# Licensed under the MIT License
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//rules:rules_go.bzl", "go_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
go_library(
name = "gorace_lib",

View File

@ -1,8 +1,7 @@
# Copyright 2023 Uber Technologies, Inc.
# Licensed under the MIT License
load("//rules:rules_go.bzl", "go_binary")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
go_library(
name = "releaser_lib",