diff --git a/.bazelrc b/.bazelrc index 33e4327738..13a0102968 100644 --- a/.bazelrc +++ b/.bazelrc @@ -19,6 +19,7 @@ build --host_copt "-Wno-comment" # https://github.com/google/googletest/issues/4383 build --define absl=1 build --incompatible_enable_cc_toolchain_resolution +build --@llvm_zstd//:llvm_enable_zstd=false # Settings for --config=asan address sanitizer build build:asan --strip=never diff --git a/dependency_support/com_github_facebook_zstd/BUILD b/dependency_support/com_github_facebook_zstd/BUILD new file mode 100644 index 0000000000..4b8fbec780 --- /dev/null +++ b/dependency_support/com_github_facebook_zstd/BUILD @@ -0,0 +1,15 @@ +# Copyright 2023 The XLS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Needed to make this a package. diff --git a/dependency_support/com_github_facebook_zstd/bundled.BUILD.bazel b/dependency_support/com_github_facebook_zstd/bundled.BUILD.bazel new file mode 100644 index 0000000000..dbe80f692e --- /dev/null +++ b/dependency_support/com_github_facebook_zstd/bundled.BUILD.bazel @@ -0,0 +1,50 @@ +# Copyright 2023 The XLS Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +# Builds everything together similarly to the zstd cmake file: +# https://github.com/facebook/zstd/blob/dev/build/cmake/lib/CMakeLists.txt +# but with legacy support and defines as in the zstd BUCK file: +# https://github.com/facebook/zstd/blob/dev/lib/BUCK + +cc_library( + name = "zstd", + srcs = glob([ + "lib/common/*.h", + "lib/common/*.c", + "lib/compress/*.h", + "lib/compress/*.c", + "lib/decompress/*.h", + "lib/decompress/*.c", + "lib/decompress/*.S", + "lib/deprecated/*.h", + "lib/deprecated/*.c", + "lib/dictBuilder/*.h", + "lib/dictBuilder/*.c", + "lib/legacy/*.h", + "lib/legacy/*.c", + ]), + hdrs = [ + "lib/zstd.h", + ], + strip_include_prefix = "lib", + local_defines = [ + "ZSTD_LEGACY_SUPPORT=4", + "XXH_NAMESPACE=ZSTD_", + ], + visibility = ["//visibility:public"], +) diff --git a/dependency_support/load_external.bzl b/dependency_support/load_external.bzl index b7e7d07070..0550d801a2 100644 --- a/dependency_support/load_external.bzl +++ b/dependency_support/load_external.bzl @@ -286,3 +286,14 @@ def load_external_repositories(): "https://github.com/nlohmann/json/archive/refs/tags/v3.10.2.tar.gz", ], ) + + # Version 1.4.7 released on 17.12.2020 + # https://github.com/facebook/zstd/releases/tag/v1.4.7 + # Updated 23.11.2023 + http_archive( + name = "com_github_facebook_zstd", + sha256 = "192cbb1274a9672cbcceaf47b5c4e9e59691ca60a357f1d4a8b2dfa2c365d757", + strip_prefix = "zstd-1.4.7", + urls = ["https://github.com/facebook/zstd/releases/download/v1.4.7/zstd-1.4.7.tar.gz"], + build_file = "@//dependency_support/com_github_facebook_zstd:bundled.BUILD.bazel", + )