Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion utils/bazel/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use_repo(
"gmp",
"llvm-raw",
"llvm_zlib",
"llvm_zstd",
"mpc",
"mpfr",
"nanobind",
Expand All @@ -34,6 +33,8 @@ use_repo(
"vulkan_sdk",
)

bazel_dep(name = "zstd", version = "1.5.7", repo_name = "llvm_zstd")

llvm_configure = use_repo_rule("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")

llvm_configure(name = "llvm-project")
17 changes: 4 additions & 13 deletions utils/bazel/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions utils/bazel/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ def _llvm_repos_extension_impl(module_ctx):
build_file = "@llvm-raw//utils/bazel/third_party_build:pfm.BUILD",
)

http_archive(
name = "llvm_zstd",
build_file = "@llvm-raw//utils/bazel/third_party_build:zstd.BUILD",
sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0",
strip_prefix = "zstd-1.5.2",
urls = [
"https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz",
],
)

http_archive(
name = "pybind11",
url = "https://github.com/pybind/pybind11/archive/v2.10.3.zip",
Expand Down
2 changes: 1 addition & 1 deletion utils/bazel/llvm-project-overlay/lld/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ cc_library(
"//llvm:TargetParser",
"//llvm:TransformUtils",
"//llvm:config",
"//third-party:zstd",
"@llvm_zlib//:zlib",
"@llvm_zstd//:zstd",
],
)

Expand Down
2 changes: 1 addition & 1 deletion utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ cc_library(
# We unconditionally depend on the custom LLVM zstd wrapper. This will
# be an empty library unless zstd is enabled, in which case it will
# both provide the necessary dependencies and configuration defines.
"@llvm_zstd//:zstd",
"//third-party:zstd",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

package(
default_visibility = ["//visibility:public"],
# BSD/MIT-like license (for zstd)
licenses = ["notice"],
)
load(":cc_library_wrapper.bzl", "cc_library_wrapper")

bool_flag(
name = "llvm_enable_zstd",
Expand All @@ -19,36 +14,20 @@ config_setting(
flag_values = {":llvm_enable_zstd": "true"},
)

cc_library(
cc_library_wrapper(
name = "zstd",
srcs = select({
":llvm_zstd_enabled": glob([
"lib/common/*.c",
"lib/common/*.h",
"lib/compress/*.c",
"lib/compress/*.h",
"lib/decompress/*.c",
"lib/decompress/*.h",
"lib/decompress/*.S",
"lib/dictBuilder/*.c",
"lib/dictBuilder/*.h",
]),
"//conditions:default": [],
}),
hdrs = select({
defines = select({
":llvm_zstd_enabled": [
"lib/zdict.h",
"lib/zstd.h",
"lib/zstd_errors.h",
"LLVM_ENABLE_ZSTD=1",
"ZSTD_MULTITHREAD",
],
"//conditions:default": [],
}),
defines = select({
visibility = ["//visibility:public"],
deps = select({
":llvm_zstd_enabled": [
"LLVM_ENABLE_ZSTD=1",
"ZSTD_MULTITHREAD",
"@llvm_zstd//:zstd",
],
"//conditions:default": [],
}),
strip_include_prefix = "lib",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

"""Re-export a cc_library with added LLVM specific settings.

This re-exports the dependent libraries in a way that satisfies layering_check

cc_library_wrapper(
name = "library_wrapper",
deps = [
"@example//:library",
],
defines = [
"LLVM_ENABLE_EXAMPLE=1",
],
)
"""

load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")

visibility("private")

def _cc_library_wrapper_impl(ctx):
all_cc_infos = [dep[CcInfo] for dep in ctx.attr.deps]
if ctx.attr.defines:
all_cc_infos.append(CcInfo(
compilation_context = cc_common.create_compilation_context(
defines = depset(ctx.attr.defines),
),
))

return cc_common.merge_cc_infos(direct_cc_infos = all_cc_infos)

cc_library_wrapper = rule(
implementation = _cc_library_wrapper_impl,
attrs = {
"deps": attr.label_list(
doc = "Dependencies to cc_library targets to re-export.",
providers = [CcInfo],
),
"defines": attr.string_list(
doc = "Additional preprocessor definitions to add to all dependent targets.",
default = [],
),
},
doc = "Re-export a cc_library with added LLVM specific settings.",
provides = [CcInfo],
)
Loading