diff --git a/BUILD.bazel b/BUILD.bazel index 4458d8281..4af9a5ec3 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,5 @@ load("@gazelle//:def.bzl", "gazelle") -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push", "oci_tarball") load("@rules_pkg//:pkg.bzl", "pkg_tar") diff --git a/MODULE.bazel b/MODULE.bazel index 6ab3db4d8..2c4837274 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ # https://registry.bazel.build/ bazel_dep(name = "googleapis", version = "0.0.0-20240326-1c8d509c5") -bazel_dep(name = "rules_go", version = "0.50.1") +bazel_dep(name = "rules_go", version = "0.50.1", repo_name = "io_bazel_rules_go") bazel_dep(name = "gazelle", version = "0.38.0") bazel_dep(name = "rules_proto", version = "6.0.2") bazel_dep(name = "rules_pkg", version = "1.0.1") @@ -26,7 +26,7 @@ oci.pull( use_repo(oci, "cgo_arm64_base") # Download an SDK for the host OS & architecture as well as common remote execution platforms. -go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk") +go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk") go_sdk.download(version = "1.23.0") go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") @@ -81,6 +81,20 @@ go_deps.module( sum = "h1:R2ZVGCZzU95oXFJxncosHS9LsX8N4/MYUdGGWOb2cFk=", version = "v0.4.1-0.20220112235402-e1cee1c72f2f", ) +go_deps.module_override( + patch_strip = 1, + patches = [ + "//patches:gozstd.patch", + ], + path = "github.com/valyala/gozstd", +) +go_deps.gazelle_override( + directives = [ + # The patch applied in go_deps.module_override provides a better/working build config. + "gazelle:ignore on", + ], + path = "github.com/valyala/gozstd", +) use_repo( go_deps, "com_github_abbot_go_http_auth", diff --git a/cache/BUILD.bazel b/cache/BUILD.bazel index 918fe5538..75ecb84a4 100644 --- a/cache/BUILD.bazel +++ b/cache/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/cache/azblobproxy/BUILD.bazel b/cache/azblobproxy/BUILD.bazel index c30650e0e..3038c7119 100644 --- a/cache/azblobproxy/BUILD.bazel +++ b/cache/azblobproxy/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/cache/disk/BUILD.bazel b/cache/disk/BUILD.bazel index 69fa97dd2..dd44026ef 100644 --- a/cache/disk/BUILD.bazel +++ b/cache/disk/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/cache/disk/casblob/BUILD.bazel b/cache/disk/casblob/BUILD.bazel index edb3e0b77..64df55194 100644 --- a/cache/disk/casblob/BUILD.bazel +++ b/cache/disk/casblob/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/cache/disk/zstdimpl/BUILD.bazel b/cache/disk/zstdimpl/BUILD.bazel index 545cf76b5..18fe1df78 100644 --- a/cache/disk/zstdimpl/BUILD.bazel +++ b/cache/disk/zstdimpl/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -6,7 +6,7 @@ go_library( "gozstd.go", "zstdimpl.go", ] + select({ - "@rules_go//go/toolchain:cgo_on": [ + "@io_bazel_rules_go//go/toolchain:cgo_on": [ "cgozstd.go", ], "//conditions:default": [], @@ -18,7 +18,7 @@ go_library( "@com_github_klauspost_compress//zstd:go_default_library", "@com_github_mostynb_zstdpool_syncpool//:go_default_library", ] + select({ - "@rules_go//go/toolchain:cgo_on": [ + "@io_bazel_rules_go//go/toolchain:cgo_on": [ "@com_github_valyala_gozstd//:go_default_library", ], "//conditions:default": [], diff --git a/cache/gcsproxy/BUILD.bazel b/cache/gcsproxy/BUILD.bazel index e0c8ab951..caf019164 100644 --- a/cache/gcsproxy/BUILD.bazel +++ b/cache/gcsproxy/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/cache/grpcproxy/BUILD.bazel b/cache/grpcproxy/BUILD.bazel index e9c7de338..867039e78 100644 --- a/cache/grpcproxy/BUILD.bazel +++ b/cache/grpcproxy/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/cache/httpproxy/BUILD.bazel b/cache/httpproxy/BUILD.bazel index 5dde90059..b3da81320 100644 --- a/cache/httpproxy/BUILD.bazel +++ b/cache/httpproxy/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/cache/s3proxy/BUILD.bazel b/cache/s3proxy/BUILD.bazel index 66e1f2e04..193f69012 100644 --- a/cache/s3proxy/BUILD.bazel +++ b/cache/s3proxy/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/config/BUILD.bazel b/config/BUILD.bazel index 010c0b1a2..5e1409d42 100644 --- a/config/BUILD.bazel +++ b/config/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/external/gozstd.patch b/external/gozstd.patch deleted file mode 100644 index 453176a39..000000000 --- a/external/gozstd.patch +++ /dev/null @@ -1,142 +0,0 @@ -From 88b6abf2c7151f9fd8e4bd401fbdf1acb32b4dcb Mon Sep 17 00:00:00 2001 -From: Grzegorz Lukasik -Date: Mon, 11 Oct 2021 15:05:52 -0700 -Subject: [PATCH] Added BUILD file that works for bazel. - -https://github.com/bazelbuild/bazel-gazelle currently (v0.24.0) -does not create working go_repository for https://github.com/valyala/gozstd - -gazelle creates a go_library, that adds a number of linkopts from -parsing go files for different platforms, ending with entry like: - - go_library( - name = "gozstd", - ... - clinkopts = select({ - "@rules_go//go/platform:android_amd64": [ - "./libzstd_linux_amd64.a", - ], - "@rules_go//go/platform:android_arm": [ - "./libzstd_linux_arm.a", - ], - ... - -But the .a files are not included as input files, because of that bazel -fails during linking with: - - gcc: error: ./libzstd_linux_amd64.a: No such file or directory - -This patch commits statically fixed BUILD.bazel file with using -cc_library that the gozstd library depends on, which causes proper -linking flags and addition of .a files to the input files. ---- - BUILD.bazel | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 97 insertions(+) - create mode 100644 BUILD.bazel - -diff --git a/BUILD.bazel b/BUILD.bazel -new file mode 100644 -index 0000000..ce0ff97 ---- /dev/null -+++ b/BUILD.bazel -@@ -0,0 +1,97 @@ -+load("@rules_go//go:def.bzl", "go_library", "go_test") -+ -+cc_library( -+ name = "gozstd-c-archive", -+ srcs = select({ -+ "@rules_go//go/platform:android_amd64": [ -+ "libzstd_linux_amd64.a", -+ ], -+ "@rules_go//go/platform:android_arm": [ -+ "libzstd_linux_arm.a", -+ ], -+ "@rules_go//go/platform:android_arm64": [ -+ "libzstd_linux_arm64.a", -+ ], -+ "@rules_go//go/platform:darwin_amd64": [ -+ "libzstd_darwin_amd64.a", -+ ], -+ "@rules_go//go/platform:darwin_arm64": [ -+ "libzstd_darwin_arm64.a", -+ ], -+ "@rules_go//go/platform:freebsd_amd64": [ -+ "libzstd_freebsd_amd64.a", -+ ], -+ "@rules_go//go/platform:ios_amd64": [ -+ "libzstd_darwin_amd64.a", -+ ], -+ "@rules_go//go/platform:ios_arm64": [ -+ "libzstd_darwin_arm64.a", -+ ], -+ "@rules_go//go/platform:linux_amd64": [ -+ "libzstd_linux_amd64.a", -+ ], -+ "@rules_go//go/platform:linux_arm": [ -+ "libzstd_linux_arm.a", -+ ], -+ "@rules_go//go/platform:linux_arm64": [ -+ "libzstd_linux_arm64.a", -+ ], -+ "@rules_go//go/platform:windows_amd64": [ -+ "libzstd_windows_amd64.a", -+ ]}, -+ no_match_error = "Platform not supported by cgo zstd implementation"), -+ -+) -+ -+go_library( -+ name = "gozstd", -+ srcs = [ -+ "dict.go", -+ "doc.go", -+ "gozstd.go", -+ "libzstd_darwin_amd64.go", -+ "libzstd_darwin_arm64.go", -+ "libzstd_freebsd_amd64.go", -+ "libzstd_linux_amd64.go", -+ "libzstd_linux_arm.go", -+ "libzstd_linux_arm64.go", -+ "libzstd_windows_amd64.go", -+ "reader.go", -+ "stream.go", -+ "writer.go", -+ "zdict.h", -+ "zstd.h", -+ "zstd_errors.h", -+ ], -+ cgo = True, -+ cdeps = [":gozstd-c-archive"], -+ copts = ["-O3"], -+ importpath = "github.com/valyala/gozstd", -+ visibility = ["//visibility:public"], -+) -+ -+alias( -+ name = "go_default_library", -+ actual = ":gozstd", -+ visibility = ["//visibility:public"], -+) -+ -+go_test( -+ name = "gozstd_test", -+ srcs = [ -+ "dict_example_test.go", -+ "dict_test.go", -+ "gozstd_example_test.go", -+ "gozstd_test.go", -+ "gozstd_timing_test.go", -+ "reader_example_test.go", -+ "reader_test.go", -+ "reader_timing_test.go", -+ "stream_test.go", -+ "stream_timing_test.go", -+ "writer_example_test.go", -+ "writer_test.go", -+ "writer_timing_test.go", -+ ], -+ embed = [":gozstd"], -+) --- -2.33.0 - diff --git a/genproto/build/bazel/remote/asset/v1/BUILD.bazel b/genproto/build/bazel/remote/asset/v1/BUILD.bazel index 60a0e73c5..c0132e882 100644 --- a/genproto/build/bazel/remote/asset/v1/BUILD.bazel +++ b/genproto/build/bazel/remote/asset/v1/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/genproto/build/bazel/remote/execution/v2/BUILD.bazel b/genproto/build/bazel/remote/execution/v2/BUILD.bazel index a598f1d4d..952867331 100644 --- a/genproto/build/bazel/remote/execution/v2/BUILD.bazel +++ b/genproto/build/bazel/remote/execution/v2/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/genproto/build/bazel/semver/BUILD.bazel b/genproto/build/bazel/semver/BUILD.bazel index 6894088fe..45ebbe160 100644 --- a/genproto/build/bazel/semver/BUILD.bazel +++ b/genproto/build/bazel/semver/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/ldap/BUILD.bazel b/ldap/BUILD.bazel index 8bbda3d37..190c0ee6e 100644 --- a/ldap/BUILD.bazel +++ b/ldap/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/patches/BUILD.bazel b/patches/BUILD.bazel new file mode 100644 index 000000000..e69de29bb diff --git a/patches/gozstd.patch b/patches/gozstd.patch new file mode 100644 index 000000000..96fa2532f --- /dev/null +++ b/patches/gozstd.patch @@ -0,0 +1,110 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +new file mode 100644 +index 0000000..2dd6245 +--- /dev/null ++++ b/BUILD.bazel +@@ -0,0 +1,75 @@ ++load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") ++ ++cc_library( ++ name = "libzstd", ++ srcs = select({ ++ "@io_bazel_rules_go//go/platform:android_amd64": ["libzstd_linux_amd64.a"], ++ "@io_bazel_rules_go//go/platform:android_arm": ["libzstd_linux_arm.a"], ++ "@io_bazel_rules_go//go/platform:android_arm64": ["libzstd_linux_arm64.a"], ++ "@io_bazel_rules_go//go/platform:darwin_amd64": ["libzstd_darwin_amd64.a"], ++ "@io_bazel_rules_go//go/platform:darwin_arm64": ["libzstd_darwin_arm64.a"], ++ "@io_bazel_rules_go//go/platform:freebsd_amd64": ["libzstd_freebsd_amd64.a"], ++ "@io_bazel_rules_go//go/platform:ios_amd64": ["libzstd_darwin_amd64.a"], ++ "@io_bazel_rules_go//go/platform:ios_arm64": ["libzstd_darwin_arm64.a"], ++ "@io_bazel_rules_go//go/platform:linux_amd64": ["libzstd_linux_amd64.a"], ++ "@io_bazel_rules_go//go/platform:linux_arm": ["libzstd_linux_arm.a"], ++ "@io_bazel_rules_go//go/platform:linux_arm64": ["libzstd_linux_arm64.a"], ++ "@io_bazel_rules_go//go/platform:windows_amd64": ["libzstd_windows_amd64.a"], ++ "//conditions:default": ["UNSUPPORTED_PLATFORM"], ++ }), ++ hdrs = [ ++ "zdict.h", ++ "zstd.h", ++ "zstd_errors.h", ++ ], ++) ++ ++go_library( ++ name = "gozstd", ++ srcs = [ ++ "dict.go", ++ "doc.go", ++ "gozstd.go", ++ "libzstd_darwin_amd64.go", ++ "libzstd_darwin_arm64.go", ++ "libzstd_freebsd_amd64.go", ++ "libzstd_linux_amd64.go", ++ "libzstd_linux_arm.go", ++ "libzstd_linux_arm64.go", ++ "libzstd_windows_amd64.go", ++ "reader.go", ++ "stream.go", ++ "writer.go", ++ ], ++ cdeps = [":libzstd"], ++ cgo = True, ++ copts = ["-O3"], ++ importpath = "github.com/valyala/gozstd", ++ visibility = ["//visibility:public"], ++) ++ ++alias( ++ name = "go_default_library", ++ actual = ":gozstd", ++ visibility = ["//visibility:public"], ++) ++ ++go_test( ++ name = "gozstd_test", ++ srcs = [ ++ "dict_example_test.go", ++ "dict_test.go", ++ "gozstd_example_test.go", ++ "gozstd_test.go", ++ "gozstd_timing_test.go", ++ "reader_example_test.go", ++ "reader_test.go", ++ "reader_timing_test.go", ++ "stream_test.go", ++ "stream_timing_test.go", ++ "writer_example_test.go", ++ "writer_test.go", ++ "writer_timing_test.go", ++ ], ++ embed = [":gozstd"], ++) +diff --git a/MODULE.bazel b/MODULE.bazel +new file mode 100644 +index 0000000..150b214 +--- /dev/null ++++ b/MODULE.bazel +@@ -0,0 +1,14 @@ ++module( ++ name = "gozstd", ++ version = "0.1", ++) ++ ++bazel_dep(name = "io_bazel_rules_go", version = "0.50.1") ++bazel_dep(name = "gazelle", version = "0.38.0") ++ ++# Download an SDK for the host OS & architecture as well as common remote execution platforms. ++go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk") ++go_sdk.download(version = "1.23.0") ++ ++go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") ++go_deps.from_file(go_mod = "//:go.mod") +diff --git a/go.mod b/go.mod +index f422410..0df723d 100644 +--- a/go.mod ++++ b/go.mod +@@ -1,3 +1,3 @@ + module github.com/valyala/gozstd + +-go 1.12 ++go 1.17 diff --git a/server/BUILD.bazel b/server/BUILD.bazel index 81f5cd8ee..1286be262 100644 --- a/server/BUILD.bazel +++ b/server/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/utils/BUILD.bazel b/utils/BUILD.bazel index bd310f346..655a81318 100644 --- a/utils/BUILD.bazel +++ b/utils/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/utils/annotate/BUILD.bazel b/utils/annotate/BUILD.bazel index dd43d4619..a35d254a2 100644 --- a/utils/annotate/BUILD.bazel +++ b/utils/annotate/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/utils/backendproxy/BUILD.bazel b/utils/backendproxy/BUILD.bazel index 8b68517e0..868b21fb1 100644 --- a/utils/backendproxy/BUILD.bazel +++ b/utils/backendproxy/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/utils/fakes3/BUILD.bazel b/utils/fakes3/BUILD.bazel index da4f1dde3..1d1610967 100644 --- a/utils/fakes3/BUILD.bazel +++ b/utils/fakes3/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") go_library( name = "go_default_library", diff --git a/utils/flags/BUILD.bazel b/utils/flags/BUILD.bazel index 4a023ee85..2b06046d1 100644 --- a/utils/flags/BUILD.bazel +++ b/utils/flags/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/utils/grpcreadclient/BUILD.bazel b/utils/grpcreadclient/BUILD.bazel index eeff74c7d..e0014b9f9 100644 --- a/utils/grpcreadclient/BUILD.bazel +++ b/utils/grpcreadclient/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") go_library( name = "go_default_library", diff --git a/utils/idle/BUILD.bazel b/utils/idle/BUILD.bazel index c7c58d3c8..976d89ce9 100644 --- a/utils/idle/BUILD.bazel +++ b/utils/idle/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/utils/rlimit/BUILD.bazel b/utils/rlimit/BUILD.bazel index 7a2fafc85..1736a2da0 100644 --- a/utils/rlimit/BUILD.bazel +++ b/utils/rlimit/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/utils/tempfile/BUILD.bazel b/utils/tempfile/BUILD.bazel index 6b6b062d5..f5bf91274 100644 --- a/utils/tempfile/BUILD.bazel +++ b/utils/tempfile/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/utils/validate/BUILD.bazel b/utils/validate/BUILD.bazel index a849d39e3..36fd6a5f7 100644 --- a/utils/validate/BUILD.bazel +++ b/utils/validate/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", diff --git a/utils/zstdpool/BUILD.bazel b/utils/zstdpool/BUILD.bazel index 4ca21f5c9..23ff83d6c 100644 --- a/utils/zstdpool/BUILD.bazel +++ b/utils/zstdpool/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library",