Skip to content

Commit

Permalink
Try to get the linux arm64 cgo build working again
Browse files Browse the repository at this point in the history
  • Loading branch information
mostynb committed Oct 12, 2024
1 parent 0a414c4 commit be24e5f
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 142 deletions.
14 changes: 14 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
142 changes: 0 additions & 142 deletions external/gozstd.patch

This file was deleted.

Empty file added patches/BUILD.bazel
Empty file.
110 changes: 110 additions & 0 deletions patches/gozstd.patch
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit be24e5f

Please sign in to comment.