Skip to content

Commit b09be57

Browse files
committed
feat: add support for BLAKE3-256 hash
1 parent cb22339 commit b09be57

14 files changed

+189
-41
lines changed

.docker/Dockerfile.arch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RUN pacman -S --noconfirm --needed \
2626
pkg-config \
2727
binutils \
2828
libarchive \
29+
libblake3 \
2930
benchmark \
3031
boost \
3132
brotli \

.docker/Dockerfile.fedora

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ RUN dnf install -y \
2727
pkg-config \
2828
binutils-devel \
2929
libarchive-devel \
30+
blake3-devel \
3031
google-benchmark \
3132
boost-devel \
3233
brotli-devel \

.docker/Dockerfile.suse

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ RUN zypper -n in --no-recommends \
3333
pkgconf-pkg-config \
3434
binutils-devel \
3535
libarchive-devel \
36+
blake3-devel \
3637
benchmark-devel \
3738
boost-devel \
3839
libboost_chrono-devel \

.docker/check_lib_versions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"xiph/flac",
99
"libunwind/libunwind",
1010
"google/benchmark",
11+
"BLAKE3-team/BLAKE3",
1112
"boostorg/boost",
1213
"openssl/openssl",
1314
"libressl/portable",

.docker/static-libs-fetch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ fetch_lib flac https://github.com/xiph/flac/releases/download/${FLAC_VERSION}/${
2222
fetch_lib libucontext https://github.com/kaniini/libucontext/archive/refs/tags/${LIBUCONTEXT_TARBALL}
2323
fetch_lib libunwind https://github.com/libunwind/libunwind/releases/download/v${LIBUNWIND_VERSION}/${LIBUNWIND_TARBALL}
2424
fetch_lib benchmark https://github.com/google/benchmark/archive/refs/tags/v${BENCHMARK_VERSION}.tar.gz ${BENCHMARK_TARBALL}
25+
fetch_lib blake3 https://github.com/BLAKE3-team/BLAKE3/archive/refs/tags/${BLAKE3_VERSION}.tar.gz ${BLAKE3_TARBALL}
2526
fetch_lib openssl https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/${OPENSSL_TARBALL}
2627
fetch_lib libressl https://github.com/libressl/portable/releases/download/v${LIBRESSL_VERSION}/${LIBRESSL_TARBALL}
2728
fetch_lib cpptrace https://github.com/jeremy-rifkin/cpptrace/archive/refs/tags/v${CPPTRACE_VERSION}.tar.gz ${CPPTRACE_TARBALL}

.docker/static-libs-install.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if [[ "$PKGS" == ":none" ]]; then
1818
echo "No libraries to build"
1919
exit 0
2020
elif [[ "$PKGS" == ":all" ]]; then
21-
PKGS="benchmark,boost,brotli,cpptrace,double-conversion,flac,fmt,fuse,fuse3,glog,jemalloc,libarchive,libdwarf,libevent,libucontext,libunwind,libressl,lz4,mimalloc,nlohmann,openssl,parallel-hashmap,range-v3,utfcpp,xxhash,xz,zstd"
21+
PKGS="benchmark,blake3,boost,brotli,cpptrace,double-conversion,flac,fmt,fuse,fuse3,glog,jemalloc,libarchive,libdwarf,libevent,libucontext,libunwind,libressl,lz4,mimalloc,nlohmann,openssl,parallel-hashmap,range-v3,utfcpp,xxhash,xz,zstd"
2222
fi
2323

2424
export COMMON_CFLAGS="-ffunction-sections -fdata-sections -fmerge-all-constants"
@@ -270,6 +270,18 @@ if use_lib nlohmann; then
270270
cp "$HOME/pkgs/json.hpp" "$INSTALL_DIR/include/nlohmann/json.hpp"
271271
fi
272272

273+
if use_lib blake3; then
274+
opt_size
275+
cd "$WORKDIR"
276+
tar xf ${WORKROOT}/${BLAKE3_TARBALL}
277+
cd BLAKE3-${BLAKE3_VERSION}/c
278+
mkdir build
279+
cd build
280+
cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" ${CMAKE_ARGS}
281+
$NINJA_PARALLEL
282+
ninja install
283+
fi
284+
273285
if use_lib utfcpp; then
274286
opt_size
275287
cd "$WORKDIR"

.docker/static-libs-versions.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ FLAC_VERSION=1.5.0 # 2025-02-11
77
LIBUCONTEXT_VERSION=1.3.2 # 2024-10-07
88
LIBUNWIND_VERSION=1.8.3 # 2025-09-04
99
BENCHMARK_VERSION=1.9.4 # 2025-05-19
10+
BLAKE3_VERSION=1.8.2 # 2025-04-21
1011
BOOST_VERSION=1.89.0 # 2025-08-14
1112
OPENSSL_VERSION=3.6.0 # 2025-10-01
1213
LIBRESSL_VERSION=4.2.1 # 2025-10-30
@@ -38,6 +39,7 @@ FLAC_TARBALL="flac-${FLAC_VERSION}.tar.xz"
3839
LIBUCONTEXT_TARBALL="libucontext-${LIBUCONTEXT_VERSION}.tar.gz"
3940
LIBUNWIND_TARBALL="libunwind-${LIBUNWIND_VERSION}.tar.gz"
4041
BENCHMARK_TARBALL="benchmark-${BENCHMARK_VERSION}.tar.gz"
42+
BLAKE3_TARBALL="BLAKE3-${BLAKE3_VERSION}.tar.gz"
4143
OPENSSL_TARBALL="openssl-${OPENSSL_VERSION}.tar.gz"
4244
LIBRESSL_TARBALL="libressl-${LIBRESSL_VERSION}.tar.gz"
4345
CPPTRACE_TARBALL="cpptrace-${CPPTRACE_VERSION}.tar.gz"

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ set(RANGE_V3_PREFERRED_VERSION 0.12.0)
109109
set(PARALLEL_HASHMAP_REQUIRED_VERSION 1.3.8)
110110
set(PARALLEL_HASHMAP_PREFERRED_VERSION 2.0.0)
111111

112+
set(BLAKE3_REQUIRED_VERSION 1.2.0)
113+
set(BLAKE3_PREFERRED_VERSION 1.8.2)
114+
112115
set(BOOST_REQUIRED_VERSION 1.67.0)
113116
set(LIBCRYPTO_REQUIRED_VERSION 3.0.0)
114117
set(LIBLZ4_REQUIRED_VERSION 1.9.3)
@@ -127,11 +130,13 @@ if(DEFINED ENV{DWARFS_LOCAL_REPO_PATH})
127130
set(GOOGLETEST_GIT_REPO $ENV{DWARFS_LOCAL_REPO_PATH}/googletest)
128131
set(RANGE_V3_GIT_REPO $ENV{DWARFS_LOCAL_REPO_PATH}/range-v3)
129132
set(PARALLEL_HASHMAP_GIT_REPO $ENV{DWARFS_LOCAL_REPO_PATH}/parallel-hashmap)
133+
set(BLAKE3_GIT_REPO $ENV{DWARFS_LOCAL_REPO_PATH}/BLAKE3)
130134
else()
131135
set(LIBFMT_GIT_REPO https://github.com/fmtlib/fmt.git)
132136
set(GOOGLETEST_GIT_REPO https://github.com/google/googletest.git)
133137
set(RANGE_V3_GIT_REPO https://github.com/ericniebler/range-v3.git)
134138
set(PARALLEL_HASHMAP_GIT_REPO https://github.com/greg7mdp/parallel-hashmap.git)
139+
set(BLAKE3_GIT_REPO https://github.com/BLAKE3-team/BLAKE3.git)
135140
endif()
136141

137142
if(APPLE)
@@ -194,6 +199,7 @@ if(WITH_TESTS)
194199
include(${CMAKE_SOURCE_DIR}/cmake/need_gtest.cmake)
195200
endif()
196201

202+
include(${CMAKE_SOURCE_DIR}/cmake/need_blake3.cmake)
197203
include(${CMAKE_SOURCE_DIR}/cmake/need_fmt.cmake)
198204
include(${CMAKE_SOURCE_DIR}/cmake/need_range_v3.cmake)
199205

cmake/libdwarfs.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ add_cpp2_thrift_library(thrift/history.thrift
208208
add_cpp2_thrift_library(thrift/features.thrift
209209
TARGET dwarfs_features_thrift OUTPUT_PATH dwarfs)
210210

211-
target_link_libraries(dwarfs_common PRIVATE dwarfs_folly_lite PkgConfig::LIBCRYPTO PkgConfig::XXHASH PkgConfig::ZSTD)
211+
target_link_libraries(dwarfs_common PRIVATE dwarfs_folly_lite PkgConfig::LIBCRYPTO PkgConfig::XXHASH PkgConfig::ZSTD BLAKE3::blake3)
212212
target_link_libraries(dwarfs_compressor PRIVATE dwarfs_common)
213213
target_link_libraries(dwarfs_decompressor PRIVATE dwarfs_common)
214214
target_link_libraries(dwarfs_reader PUBLIC dwarfs_common dwarfs_decompressor)

cmake/need_blake3.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (c) Marcus Holland-Moritz
3+
#
4+
# This file is part of dwarfs.
5+
#
6+
# dwarfs is free software: you can redistribute it and/or modify it under the
7+
# terms of the GNU General Public License as published by the Free Software
8+
# Foundation, either version 3 of the License, or (at your option) any later
9+
# version.
10+
#
11+
# dwarfs is distributed in the hope that it will be useful, but WITHOUT ANY
12+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License along with
16+
# dwarfs. If not, see <https://www.gnu.org/licenses/>.
17+
#
18+
19+
cmake_minimum_required(VERSION 3.28.0)
20+
21+
find_package(blake3 ${BLAKE3_REQUIRED_VERSION} CONFIG)
22+
23+
if(NOT blake3_FOUND)
24+
FetchContent_Declare(
25+
blake3
26+
GIT_REPOSITORY ${BLAKE3_GIT_REPO}
27+
GIT_TAG ${BLAKE3_PREFERRED_VERSION}
28+
SOURCE_SUBDIR c
29+
EXCLUDE_FROM_ALL
30+
SYSTEM
31+
)
32+
FetchContent_MakeAvailable(blake3)
33+
endif()

0 commit comments

Comments
 (0)