Skip to content

Commit 8a9c4bb

Browse files
committed
dependency_support: bump zstd version to fdfb2aff
Signed-off-by: Pawel Czarnecki <[email protected]>
1 parent 74f5afe commit 8a9c4bb

File tree

2 files changed

+156
-27
lines changed

2 files changed

+156
-27
lines changed
Lines changed: 147 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 The XLS Authors
1+
# Copyright 2024 The XLS Authors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,39 +12,165 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
package(default_visibility = ["//visibility:public"])
15+
""" Builds zstd.
16+
"""
1617

17-
licenses(["notice"])
18+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
1819

19-
# Builds everything together similarly to the zstd cmake file:
20-
# https://github.com/facebook/zstd/blob/dev/build/cmake/lib/CMakeLists.txt
21-
# but with legacy support and defines as in the zstd BUCK file:
22-
# https://github.com/facebook/zstd/blob/dev/lib/BUCK
20+
package(default_visibility = ["//visibility:public"])
2321

24-
cc_library(
25-
name = "zstd",
22+
filegroup(
23+
name = "common_sources",
2624
srcs = glob([
27-
"lib/common/*.h",
2825
"lib/common/*.c",
29-
"lib/compress/*.h",
26+
"lib/common/*.h",
27+
]),
28+
)
29+
30+
filegroup(
31+
name = "compress_sources",
32+
srcs = glob([
3033
"lib/compress/*.c",
31-
"lib/decompress/*.h",
34+
"lib/compress/*.h",
35+
]),
36+
)
37+
38+
filegroup(
39+
name = "decompress_sources",
40+
srcs = glob([
3241
"lib/decompress/*.c",
33-
"lib/decompress/*.S",
34-
"lib/deprecated/*.h",
35-
"lib/deprecated/*.c",
36-
"lib/dictBuilder/*.h",
42+
"lib/decompress/*.h",
43+
]) + select({
44+
"@platforms//os:windows": [],
45+
"//conditions:default": glob(["lib/decompress/*.S"]),
46+
}),
47+
)
48+
49+
filegroup(
50+
name = "dictbuilder_sources",
51+
srcs = glob([
3752
"lib/dictBuilder/*.c",
38-
"lib/legacy/*.h",
39-
"lib/legacy/*.c",
53+
"lib/dictBuilder/*.h",
4054
]),
55+
)
56+
57+
cc_library(
58+
name = "zstd",
59+
srcs = [
60+
":common_sources",
61+
":compress_sources",
62+
":decompress_sources",
63+
":dictbuilder_sources",
64+
],
4165
hdrs = [
66+
"lib/zdict.h",
4267
"lib/zstd.h",
68+
"lib/zstd_errors.h",
4369
],
44-
strip_include_prefix = "lib",
70+
includes = ["lib"],
71+
linkopts = ["-pthread"],
72+
linkstatic = True,
4573
local_defines = [
46-
"ZSTD_LEGACY_SUPPORT=4",
4774
"XXH_NAMESPACE=ZSTD_",
75+
"ZSTD_MULTITHREAD",
76+
"ZSTD_BUILD_SHARED=OFF",
77+
"ZSTD_BUILD_STATIC=ON",
78+
] + select({
79+
"@platforms//os:windows": ["ZSTD_DISABLE_ASM"],
80+
"//conditions:default": [],
81+
}),
82+
)
83+
84+
cc_binary(
85+
name = "zstd_cli",
86+
srcs = glob(
87+
include = [
88+
"programs/*.c",
89+
"programs/*.h",
90+
],
91+
exclude = [
92+
"programs/datagen.c",
93+
"programs/datagen.h",
94+
"programs/platform.h",
95+
"programs/util.h",
96+
],
97+
),
98+
deps = [
99+
":datagen",
100+
":util",
101+
":zstd",
102+
],
103+
)
104+
105+
cc_library(
106+
name = "util",
107+
srcs = [
108+
"programs/platform.h",
109+
"programs/util.c",
110+
],
111+
hdrs = [
112+
"lib/common/compiler.h",
113+
"lib/common/debug.h",
114+
"lib/common/mem.h",
115+
"lib/common/portability_macros.h",
116+
"lib/common/zstd_deps.h",
117+
"programs/util.h",
118+
],
119+
)
120+
121+
cc_library(
122+
name = "datagen",
123+
srcs = [
124+
"programs/datagen.c",
125+
"programs/platform.h",
126+
],
127+
hdrs = ["programs/datagen.h"],
128+
deps = [":util"],
129+
)
130+
131+
cc_binary(
132+
name = "datagen_cli",
133+
srcs = [
134+
"programs/lorem.c",
135+
"programs/lorem.h",
136+
"tests/datagencli.c",
137+
"tests/loremOut.c",
138+
"tests/loremOut.h",
139+
],
140+
includes = [
141+
"programs",
142+
"tests",
143+
],
144+
deps = [":datagen"],
145+
)
146+
147+
cc_test(
148+
name = "fullbench",
149+
srcs = [
150+
"lib/decompress/zstd_decompress_internal.h",
151+
"programs/benchfn.c",
152+
"programs/benchfn.h",
153+
"programs/benchzstd.c",
154+
"programs/benchzstd.h",
155+
"programs/lorem.c",
156+
"programs/lorem.h",
157+
"programs/timefn.c",
158+
"programs/timefn.h",
159+
"tests/fullbench.c",
160+
"tests/loremOut.c",
161+
"tests/loremOut.h",
162+
],
163+
copts = select({
164+
"@platforms//os:windows": [],
165+
"//conditions:default": ["-Wno-deprecated-declarations"],
166+
}),
167+
includes = [
168+
"lib/common",
169+
"programs",
170+
"tests",
171+
],
172+
deps = [
173+
":datagen",
174+
":zstd",
48175
],
49-
visibility = ["//visibility:public"],
50176
)

dependency_support/load_external.bzl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,16 @@ def load_external_repositories():
323323
sha256 = "cad05f864a32799f6f9022891de91ac78f30e0fa07dc68abac92a628121b5b11",
324324
)
325325

326-
# Version 1.4.7 released on 2020-12-17
327-
# https://github.com/facebook/zstd/releases/tag/v1.4.7
328-
# Updated 2024-06-27
326+
# Used in C++ tests of the ZSTD Module
327+
# Transitive dependency of fuzztest (required by riegeli in fuzztest workspace)
328+
# Version fdfb2aff released on 2024-07-31
329+
# https://github.com/facebook/zstd/commit/fdfb2aff39dc498372d8c9e5f2330b692fea9794
330+
# Updated 2024-08-08
329331
http_archive(
330332
name = "zstd",
331-
sha256 = "192cbb1274a9672cbcceaf47b5c4e9e59691ca60a357f1d4a8b2dfa2c365d757",
332-
strip_prefix = "zstd-1.4.7",
333-
urls = ["https://github.com/facebook/zstd/releases/download/v1.4.7/zstd-1.4.7.tar.gz"],
333+
sha256 = "9ace5a1b3c477048c6e034fe88d2abb5d1402ced199cae8e9eef32fdc32204df",
334+
strip_prefix = "zstd-fdfb2aff39dc498372d8c9e5f2330b692fea9794",
335+
urls = ["https://github.com/facebook/zstd/archive/fdfb2aff39dc498372d8c9e5f2330b692fea9794.zip"],
334336
build_file = "//dependency_support/com_github_facebook_zstd:bundled.BUILD.bazel",
335337
)
338+

0 commit comments

Comments
 (0)