Skip to content

Commit a49686c

Browse files
committed
[bazel] Use zstd from the BCR
This way if the downstream consuming project uses zstd we make sure they are dedup'd.
1 parent b6dadc7 commit a49686c

File tree

7 files changed

+48
-80
lines changed

7 files changed

+48
-80
lines changed

utils/bazel/MODULE.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use_repo(
2222
"gmp",
2323
"llvm-raw",
2424
"llvm_zlib",
25-
"llvm_zstd",
2625
"mpc",
2726
"mpfr",
2827
"nanobind",
@@ -34,6 +33,8 @@ use_repo(
3433
"vulkan_sdk",
3534
)
3635

36+
bazel_dep(name = "zstd", version = "1.5.7", repo_name = "llvm_zstd")
37+
3738
llvm_configure = use_repo_rule("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")
3839

3940
llvm_configure(name = "llvm-project")

utils/bazel/MODULE.bazel.lock

Lines changed: 4 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

utils/bazel/extensions.bzl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ def _llvm_repos_extension_impl(module_ctx):
7979
build_file = "@llvm-raw//utils/bazel/third_party_build:pfm.BUILD",
8080
)
8181

82-
http_archive(
83-
name = "llvm_zstd",
84-
build_file = "@llvm-raw//utils/bazel/third_party_build:zstd.BUILD",
85-
sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0",
86-
strip_prefix = "zstd-1.5.2",
87-
urls = [
88-
"https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz",
89-
],
90-
)
91-
9282
http_archive(
9383
name = "pybind11",
9484
url = "https://github.com/pybind/pybind11/archive/v2.10.3.zip",

utils/bazel/llvm-project-overlay/lld/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ cc_library(
105105
"//llvm:TargetParser",
106106
"//llvm:TransformUtils",
107107
"//llvm:config",
108+
"//third_party:zstd",
108109
"@llvm_zlib//:zlib",
109-
"@llvm_zstd//:zstd",
110110
],
111111
)
112112

utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ cc_library(
331331
# We unconditionally depend on the custom LLVM zstd wrapper. This will
332332
# be an empty library unless zstd is enabled, in which case it will
333333
# both provide the necessary dependencies and configuration defines.
334-
"@llvm_zstd//:zstd",
334+
"//third-party:zstd",
335335
],
336336
)
337337

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
5+
load("@rules_cc//cc:defs.bzl", "cc_library")
6+
7+
cc_library(name = "empty_lib")
8+
9+
bool_flag(
10+
name = "llvm_enable_zstd",
11+
build_setting_default = True,
12+
)
13+
14+
config_setting(
15+
name = "llvm_zstd_enabled",
16+
flag_values = {":llvm_enable_zstd": "true"},
17+
)
18+
19+
cc_library(
20+
name = "zstd_wrapper",
21+
defines = select({
22+
":llvm_zstd_enabled": [
23+
"LLVM_ENABLE_ZSTD=1",
24+
"ZSTD_MULTITHREAD",
25+
],
26+
"//conditions:default": [],
27+
}),
28+
deps = [
29+
"@llvm_zstd//:zstd",
30+
],
31+
)
32+
33+
alias(
34+
name = "zstd",
35+
actual = select({
36+
":llvm_zstd_enabled": ":zstd_wrapper",
37+
"//conditions:default": ":empty_lib",
38+
}),
39+
visibility = ["//visibility:public"],
40+
)

utils/bazel/third_party_build/zstd.BUILD

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)