Skip to content

Commit

Permalink
[bazel] Port zstd support
Browse files Browse the repository at this point in the history
Originally added in D128465. Used by `llvm:Support` and `lld:ELF`.

Enabled by default. Disable with `--@llvm_zstd//:llvm_enable_zstd=false`.

Reviewed By: MaskRay, GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D143344
  • Loading branch information
aaronmondal committed Mar 28, 2023
1 parent 5c2ae37 commit 75d2032
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
11 changes: 11 additions & 0 deletions utils/bazel/WORKSPACE
Expand Up @@ -121,3 +121,14 @@ maybe(
remote = "https://git.code.sf.net/p/perfmon2/libpfm4",
tag = "v4.12.1",
)

maybe(
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"
],
)
1 change: 1 addition & 0 deletions utils/bazel/llvm-project-overlay/lld/BUILD.bazel
Expand Up @@ -108,6 +108,7 @@ cc_library(
"//llvm:TargetParser",
"//llvm:TransformUtils",
"//llvm:config",
"@llvm_zstd//:zstd",
],
)

Expand Down
4 changes: 4 additions & 0 deletions utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
Expand Up @@ -283,6 +283,10 @@ cc_library(
# be an empty library unless zlib is enabled, in which case it will
# both provide the necessary dependencies and configuration defines.
"@llvm_zlib//:zlib",
# 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",
],
)

Expand Down
54 changes: 54 additions & 0 deletions utils/bazel/third_party_build/zstd.BUILD
@@ -0,0 +1,54 @@
# 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
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

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

bool_flag(
name = "llvm_enable_zstd",
build_setting_default = True,
)

config_setting(
name = "llvm_zstd_enabled",
flag_values = {":llvm_enable_zstd": "true"},
)

cc_library(
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({
":llvm_zstd_enabled": [
"lib/zstd.h",
"lib/zdict.h",
"lib/zstd_errors.h",
],
"//conditions:default": [],
}),
defines = select({
":llvm_zstd_enabled": [
"LLVM_ENABLE_ZSTD=1",
"ZSTD_MULTITHREAD",
],
"//conditions:default": [],
}),
strip_include_prefix = "lib",
)

0 comments on commit 75d2032

Please sign in to comment.