Skip to content

Commit 9626c90

Browse files
authored
[bazel] Use zlib-ng from the BCR (#169450)
This way if a downstream project also uses this, it is dedup'd
1 parent b111135 commit 9626c90

File tree

8 files changed

+39
-41
lines changed

8 files changed

+39
-41
lines changed

utils/bazel/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ bazel_dep(name = "rules_cc", version = "0.2.11")
1515
bazel_dep(name = "rules_foreign_cc", version = "0.15.1")
1616
bazel_dep(name = "rules_python", version = "1.6.3")
1717
bazel_dep(name = "rules_shell", version = "0.6.1")
18+
bazel_dep(name = "zlib-ng", version = "2.0.7", repo_name = "llvm_zlib")
1819
bazel_dep(name = "zstd", version = "1.5.7", repo_name = "llvm_zstd")
1920

2021
llvm_repos_extension = use_extension(":extensions.bzl", "llvm_repos_extension")
2122
use_repo(
2223
llvm_repos_extension,
2324
"gmp",
2425
"llvm-raw",
25-
"llvm_zlib",
2626
"mpc",
2727
"mpfr",
2828
"nanobind",

utils/bazel/MODULE.bazel.lock

Lines changed: 3 additions & 12 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
@@ -16,16 +16,6 @@ def _llvm_repos_extension_impl(module_ctx):
1616
path = "../../",
1717
)
1818

19-
http_archive(
20-
name = "llvm_zlib",
21-
build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD",
22-
sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731",
23-
strip_prefix = "zlib-ng-2.0.7",
24-
urls = [
25-
"https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip",
26-
],
27-
)
28-
2919
http_archive(
3020
name = "vulkan_headers",
3121
build_file = "@llvm-raw//utils/bazel/third_party_build:vulkan_headers.BUILD",

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:zlib",
108109
"//third-party:zstd",
109-
"@llvm_zlib//:zlib",
110110
],
111111
)
112112

utils/bazel/llvm-project-overlay/lldb/source/Plugins/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ cc_library(
493493
"//llvm:Support",
494494
"//llvm:TargetParser",
495495
"//llvm:config",
496-
"@llvm_zlib//:zlib",
496+
"//third-party:zlib",
497497
],
498498
)
499499

@@ -1406,7 +1406,7 @@ cc_library(
14061406
"//lldb:Utility",
14071407
"//llvm:Support",
14081408
"//llvm:config",
1409-
"@llvm_zlib//:zlib",
1409+
"//third-party:zlib",
14101410
],
14111411
)
14121412

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ cc_library(
327327
# We unconditionally depend on the custom LLVM zlib wrapper. This will
328328
# be an empty library unless zlib is enabled, in which case it will
329329
# both provide the necessary dependencies and configuration defines.
330-
"@llvm_zlib//:zlib",
330+
"//third-party:zlib",
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.

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,30 @@ cc_library_wrapper(
3232
"//conditions:default": [],
3333
}),
3434
)
35+
36+
bool_flag(
37+
name = "llvm_enable_zlib",
38+
build_setting_default = True,
39+
)
40+
41+
config_setting(
42+
name = "llvm_zlib_enabled",
43+
flag_values = {":llvm_enable_zlib": "true"},
44+
)
45+
46+
cc_library_wrapper(
47+
name = "zlib",
48+
defines = select({
49+
":llvm_zlib_enabled": [
50+
"LLVM_ENABLE_ZLIB=1",
51+
],
52+
"//conditions:default": [],
53+
}),
54+
visibility = ["//visibility:public"],
55+
deps = select({
56+
":llvm_zlib_enabled": [
57+
"@llvm_zlib//:zlib-ng",
58+
],
59+
"//conditions:default": [],
60+
}),
61+
)

utils/bazel/third_party_build/zlib-ng.BUILD

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4-
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
54
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
5+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
66

77
package(
88
default_visibility = ["//visibility:public"],
99
# BSD/MIT-like license (for zlib)
1010
licenses = ["notice"],
1111
)
1212

13-
bool_flag(
14-
name = "llvm_enable_zlib",
15-
build_setting_default = True,
16-
)
17-
18-
config_setting(
19-
name = "llvm_zlib_enabled",
20-
flag_values = {":llvm_enable_zlib": "true"},
21-
)
22-
2313
copy_file(
2414
# The input template is identical to the CMake output.
2515
name = "zconf_gen",
@@ -31,7 +21,7 @@ copy_file(
3121
cc_library(
3222
name = "zlib",
3323
srcs = select({
34-
":llvm_zlib_enabled": [
24+
"@llvm-project//third-party:llvm_zlib_enabled": [
3525
"adler32.c",
3626
"adler32_p.h",
3727
"chunkset.c",
@@ -79,7 +69,7 @@ cc_library(
7969
"//conditions:default": [],
8070
}),
8171
hdrs = select({
82-
":llvm_zlib_enabled": [
72+
"@llvm-project//third-party:llvm_zlib_enabled": [
8373
"zlib.h",
8474
":zconf_gen",
8575
],
@@ -96,7 +86,7 @@ cc_library(
9686
# the default config for reproducibility.
9787
],
9888
defines = select({
99-
":llvm_zlib_enabled": [
89+
"@llvm-project//third-party:llvm_zlib_enabled": [
10090
"LLVM_ENABLE_ZLIB=1",
10191
],
10292
"//conditions:default": [],

0 commit comments

Comments
 (0)