From 9b862bb5a69e88383338ef4dfd344cac9d8ec29e Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 4 Aug 2025 03:44:34 -0400 Subject: [PATCH 01/13] Remove lz4 installations --- .../core/tools/scripts/lib_install/lz4.sh | 92 ------------------- .../scripts/lib_install/macos/install-all.sh | 1 - .../install-packages-from-source.sh | 1 - .../install-packages-from-source.sh | 1 - .../install-packages-from-source.sh | 1 - 5 files changed, 96 deletions(-) delete mode 100755 components/core/tools/scripts/lib_install/lz4.sh diff --git a/components/core/tools/scripts/lib_install/lz4.sh b/components/core/tools/scripts/lib_install/lz4.sh deleted file mode 100755 index 6c60501e1a..0000000000 --- a/components/core/tools/scripts/lib_install/lz4.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -# Dependencies: -# - curl -# - make -# - gcc -# NOTE: Dependencies should be installed outside the script to allow the script to be largely distro-agnostic - -# Exit on any error -set -e - -cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" -if [ "$#" -lt 1 ] ; then - echo $cUsage - exit -fi -version=$1 - -package_name=liblz4 -temp_dir=/tmp/${package_name}-installation -deb_output_dir=${temp_dir} -if [[ "$#" -gt 1 ]] ; then - deb_output_dir="$(readlink -f "$2")" - if [ ! -d ${deb_output_dir} ] ; then - echo "${deb_output_dir} does not exist or is not a directory" - exit - fi -fi - -# Check if already installed -set +e -dpkg -l ${package_name} | grep ${version} -installed=$? -set -e -if [ $installed -eq 0 ] ; then - # Nothing to do - exit -fi - -echo "Checking for elevated privileges..." -install_cmd_args=() -if [ ${EUID:-$(id -u)} -ne 0 ] ; then - sudo echo "Script can elevate privileges." - install_cmd_args+=("sudo") -fi - -# Get number of cpu cores -num_cpus=$(grep -c ^processor /proc/cpuinfo) - -# Download -mkdir -p $temp_dir -cd $temp_dir -extracted_dir=${temp_dir}/lz4-${version} -if [ ! -e ${extracted_dir} ] ; then - tar_filename=v${version}.tar.gz - if [ ! -e ${tar_filename} ] ; then - curl -fsSL https://github.com/lz4/lz4/archive/${tar_filename} -o ${tar_filename} - fi - - tar -xf ${tar_filename} -fi - -# Build -cd ${extracted_dir} -make -j${num_cpus} - -# Check if checkinstall is installed -set +e -command -v checkinstall -checkinstall_installed=$? -set -e - -# Install -if [ $checkinstall_installed -eq 0 ] ; then - install_cmd_args+=( - checkinstall - --default - --fstrans=no - --nodoc - --pkgname "${package_name}" - --pkgversion "${version}" - --provides "${package_name}" - --pakdir "${deb_output_dir}" - ) -fi -install_cmd_args+=( - make install -) -"${install_cmd_args[@]}" - -# Clean up -rm -rf $temp_dir diff --git a/components/core/tools/scripts/lib_install/macos/install-all.sh b/components/core/tools/scripts/lib_install/macos/install-all.sh index 4f75fb8af4..5316cc7921 100755 --- a/components/core/tools/scripts/lib_install/macos/install-all.sh +++ b/components/core/tools/scripts/lib_install/macos/install-all.sh @@ -46,7 +46,6 @@ brew install \ java11 \ libarchive \ llvm@16 \ - lz4 \ mariadb-connector-c \ msgpack-cxx \ xz \ diff --git a/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh index d31343c8ee..f083908cd0 100755 --- a/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh @@ -15,7 +15,6 @@ lib_install_scripts_dir="${script_dir}/.." # repositories are either dated or don't include static libraries, so we install more recent # versions from source. "${lib_install_scripts_dir}/liblzma.sh" 5.8.1 -"${lib_install_scripts_dir}/lz4.sh" 1.10.0 "${lib_install_scripts_dir}/zstandard.sh" 1.5.7 "${lib_install_scripts_dir}/libarchive.sh" 3.8.0 diff --git a/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh index e1f65b9bcd..ba4423f19a 100755 --- a/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh @@ -15,7 +15,6 @@ lib_install_scripts_dir="${script_dir}/.." # repositories are either dated or don't include static libraries, so we install more recent # versions from source. "${lib_install_scripts_dir}/liblzma.sh" 5.8.1 -"${lib_install_scripts_dir}/lz4.sh" 1.10.0 "${lib_install_scripts_dir}/zstandard.sh" 1.5.7 "${lib_install_scripts_dir}/libarchive.sh" 3.8.0 diff --git a/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh index af1d2774a9..1a231040dc 100755 --- a/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh @@ -14,6 +14,5 @@ lib_install_scripts_dir=$script_dir/.. "$lib_install_scripts_dir"/libarchive.sh 3.5.1 "$lib_install_scripts_dir"/liblzma.sh 5.8.1 -"$lib_install_scripts_dir"/lz4.sh 1.8.2 "$lib_install_scripts_dir"/msgpack.sh 7.0.0 "$lib_install_scripts_dir"/zstandard.sh 1.4.9 From 2df11f3b07588be65f00d987148114b02a53cdfa Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 4 Aug 2025 04:35:45 -0400 Subject: [PATCH 02/13] Install LZ4 via task and update docs and find module scripts --- components/core/CMakeLists.txt | 6 +++ components/core/cmake/Modules/FindLZ4.cmake | 58 ++++++++++++++------- docs/src/dev-guide/components-core/index.md | 1 + taskfiles/deps/main.yaml | 17 ++++++ taskfiles/deps/utils.yaml | 1 + 5 files changed, 63 insertions(+), 20 deletions(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index 7c2f408a02..2d38bc6311 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -192,6 +192,12 @@ if(CLP_NEED_LOG_SURGEON) endif() endif() +if(CLP_USE_STATIC_LIBS) + set(LZ4_USE_STATIC_LIBS ON) +endif() +find_package(LZ4 REQUIRED) +message(STATUS "Found LZ4 ${LZ4_VERSION}") + if(CLP_NEED_NLOHMANN_JSON) find_package(nlohmann_json REQUIRED) if(nlohmann_json_FOUND) diff --git a/components/core/cmake/Modules/FindLZ4.cmake b/components/core/cmake/Modules/FindLZ4.cmake index 66ad14ff0d..2ae0e1227b 100644 --- a/components/core/cmake/Modules/FindLZ4.cmake +++ b/components/core/cmake/Modules/FindLZ4.cmake @@ -15,22 +15,39 @@ set(lz4_LIBNAME "lz4") include(cmake/Modules/FindLibraryDependencies.cmake) +set(lz4_HEADER "lz4.h") +set(lz4_LIBNAME "lz4") +set(lz4_LOCAL_PREFIX "lz4") +set(lz4_PKGCONFIG_NAME "liblz4") + +if(DEFINED LZ4_ROOT) + set(lz4_PKGCONFIG_DIR "${LZ4_ROOT}/lib/pkgconfig") + set(ENV{lz4_ORIG_PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}") + set(ENV{PKG_CONFIG_PATH} "${lz4_PKGCONFIG_DIR};$ENV{PKG_CONFIG_PATH}") +endif() + # Run pkg-config find_package(PkgConfig) -pkg_check_modules(lz4_PKGCONF QUIET "lib${lz4_LIBNAME}") +pkg_check_modules(lz4_PKGCONF QUIET "${lz4_PKGCONFIG_NAME}") + +# Manually set package finding hints in case of failure +if(NOT lz4_PKGCONF_FOUND) + message(WARNING "Cannot find package config for ${lz4_PKGCONFIG_NAME}") + if(DEFINED LZ4_ROOT) + set(lz4_PKGCONF_INCLUDEDIR "${LZ4_ROOT}/include") + set(lz4_PKGCONF_LIBDIR "${LZ4_ROOT}/lib") + endif() +endif() # Set include directory -find_path(LZ4_INCLUDE_DIR lz4.h +find_path(LZ4_INCLUDE_DIR ${lz4_HEADER} HINTS ${lz4_PKGCONF_INCLUDEDIR} PATH_SUFFIXES include ) # Handle static libraries if(LZ4_USE_STATIC_LIBS) - # Save current value of CMAKE_FIND_LIBRARY_SUFFIXES set(lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - - # Temporarily change CMAKE_FIND_LIBRARY_SUFFIXES to static library suffix set(CMAKE_FIND_LIBRARY_SUFFIXES .a) endif() @@ -40,40 +57,35 @@ find_library(LZ4_LIBRARY HINTS ${lz4_PKGCONF_LIBDIR} PATH_SUFFIXES lib ) -if (LZ4_LIBRARY) - # NOTE: This must be set for find_package_handle_standard_args to work - set(LZ4_FOUND ON) -endif() if(LZ4_USE_STATIC_LIBS) - FindStaticLibraryDependencies(${lz4_LIBNAME} lz4 "${lz4_PKGCONF_STATIC_LIBRARIES}") + FindStaticLibraryDependencies(${lz4_LIBNAME} ${lz4_LOCAL_PREFIX} + "${lz4_PKGCONF_STATIC_LIBRARIES}") # Restore original value of CMAKE_FIND_LIBRARY_SUFFIXES set(CMAKE_FIND_LIBRARY_SUFFIXES ${lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) unset(lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) endif() -FindDynamicLibraryDependencies(lz4 "${lz4_DYNAMIC_LIBS}") +FindDynamicLibraryDependencies(${lz4_LOCAL_PREFIX} "${lz4_DYNAMIC_LIBS}") # Set version set(LZ4_VERSION ${lz4_PKGCONF_VERSION}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(LZ4 - REQUIRED_VARS LZ4_INCLUDE_DIR + REQUIRED_VARS LZ4_LIBRARY LZ4_INCLUDE_DIR VERSION_VAR LZ4_VERSION ) if(NOT TARGET LZ4::LZ4) # Add library to build - if (LZ4_FOUND) - if (LZ4_USE_STATIC_LIBS) - add_library(LZ4::LZ4 STATIC IMPORTED) - else() - # NOTE: We use UNKNOWN so that if the user doesn't have the SHARED - # libraries installed, we can still use the STATIC libraries - add_library(LZ4::LZ4 UNKNOWN IMPORTED) - endif() + if (LZ4_USE_STATIC_LIBS) + add_library(LZ4::LZ4 STATIC IMPORTED) + else() + # NOTE: We use UNKNOWN so that if the user doesn't have the SHARED + # libraries installed, we can still use the STATIC libraries + add_library(LZ4::LZ4 UNKNOWN IMPORTED) endif() # Set include directories for library @@ -101,3 +113,9 @@ if(NOT TARGET LZ4::LZ4) endif() endif() endif() + +# Restore original value of PKG_CONFIG_PATH +if(DEFINED LZ4_ROOT) + set(ENV{PKG_CONFIG_PATH} "$ENV{lz4_ORIG_PKG_CONFIG_PATH}") + unset(ENV{lz4_ORIG_PKG_CONFIG_PATH}) +endif() diff --git a/docs/src/dev-guide/components-core/index.md b/docs/src/dev-guide/components-core/index.md index f58e0e2099..16cc9bbd31 100644 --- a/docs/src/dev-guide/components-core/index.md +++ b/docs/src/dev-guide/components-core/index.md @@ -42,6 +42,7 @@ The task will download, build, and install (within the build directory) the foll | [fmt](https://github.com/fmtlib/fmt) | v10.2.1 | | [json](https://github.com/nlohmann/json.git) | v3.11.3 | | [log-surgeon](https://github.com/y-scope/log-surgeon) | f801a3f | +| [LZ4](https://github.com/lz4/lz4) | v1.10.0 | | [mongo-cxx-driver](https://github.com/mongodb/mongo-cxx-driver) | r3.10.2 | | [simdjson](https://github.com/simdjson/simdjson) | v3.13.0 | | [spdlog](https://github.com/gabime/spdlog) | v1.14.1 | diff --git a/taskfiles/deps/main.yaml b/taskfiles/deps/main.yaml index e4cbd258c6..4a4fad0b94 100644 --- a/taskfiles/deps/main.yaml +++ b/taskfiles/deps/main.yaml @@ -67,6 +67,7 @@ tasks: - task: "date" - task: "fmt" - task: "log-surgeon" + - task: "lz4" - task: "microsoft.gsl" - task: "mongocxx" - task: "nlohmann_json" @@ -238,6 +239,22 @@ tasks: TARBALL_SHA256: "d91a7469db437162d518eb0f9175268084b478b5003163d0f6233abbbce9b0f8" TARBALL_URL: "https://github.com/y-scope/log-surgeon/archive/dfd5c79.tar.gz" + lz4: + internal: true + run: "once" + cmds: + - task: "utils:install-remote-cmake-lib" + vars: + CMAKE_GEN_ARGS: + - "-DBUILD_SHARED_LIBS=ON" + - "-DBUILD_STATIC_LIBS=ON" + - "-DCMAKE_BUILD_TYPE=Release" + - "-DCMAKE_INSTALL_MESSAGE=LAZY" + CMAKE_SOURCE_DIR: "build/cmake" + LIB_NAME: "LZ4" + TARBALL_SHA256: "537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b" + TARBALL_URL: "https://github.com/lz4/lz4/releases/download/v1.10.0/lz4-1.10.0.tar.gz" + microsoft.gsl: internal: true run: "once" diff --git a/taskfiles/deps/utils.yaml b/taskfiles/deps/utils.yaml index a80fe953a7..3911b935c2 100644 --- a/taskfiles/deps/utils.yaml +++ b/taskfiles/deps/utils.yaml @@ -68,6 +68,7 @@ tasks: CMAKE_JOBS: "{{.G_CORE_MAX_PARALLELISM_PER_BUILD_TASK}}" CMAKE_PACKAGE_NAME: "{{.LIB_NAME}}" CMAKE_SETTINGS_DIR: "{{.G_DEPS_CORE_CMAKE_SETTINGS_DIR}}" + CMAKE_SOURCE_DIR: "{{.CMAKE_SOURCE_DIR}}" TAR_SHA256: "{{.TARBALL_SHA256}}" TAR_URL: "{{.TARBALL_URL}}" WORK_DIR: "{{.G_DEPS_CORE_DIR}}" From 982ff319a2e75be2e4f7d84c7e0509f16a7e4eb3 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 4 Aug 2025 05:40:20 -0400 Subject: [PATCH 03/13] Use LZ4 built-in cmake find package moodule --- components/core/CMakeLists.txt | 9 +- components/core/cmake/Modules/FindLZ4.cmake | 121 -------------------- docs/src/dev-guide/components-core/index.md | 2 +- taskfiles/deps/main.yaml | 2 +- 4 files changed, 8 insertions(+), 126 deletions(-) delete mode 100644 components/core/cmake/Modules/FindLZ4.cmake diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index 2d38bc6311..b63c122115 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -192,11 +192,14 @@ if(CLP_NEED_LOG_SURGEON) endif() endif() +find_package(lz4 REQUIRED) +message(STATUS "Found lz4 ${lz4_VERSION}") +add_library(lz4_TARGET INTERFACE) if(CLP_USE_STATIC_LIBS) - set(LZ4_USE_STATIC_LIBS ON) + target_link_libraries(lz4_TARGET INTERFACE LZ4::lz4_static) +else() + target_link_libraries(lz4_TARGET INTERFACE LZ4::lz4_shared) endif() -find_package(LZ4 REQUIRED) -message(STATUS "Found LZ4 ${LZ4_VERSION}") if(CLP_NEED_NLOHMANN_JSON) find_package(nlohmann_json REQUIRED) diff --git a/components/core/cmake/Modules/FindLZ4.cmake b/components/core/cmake/Modules/FindLZ4.cmake deleted file mode 100644 index 2ae0e1227b..0000000000 --- a/components/core/cmake/Modules/FindLZ4.cmake +++ /dev/null @@ -1,121 +0,0 @@ -# Try to find LZ4 -# -# Set LZ4_USE_STATIC_LIBS=ON to look for static libraries. -# -# Once done this will define: -# LZ4_FOUND - Whether LZ4 was found on the system -# LZ4_INCLUDE_DIR - The LZ4 include directories -# LZ4_VERSION - The version of LZ4 installed on the system -# -# Conventions: -# - Variables only for use within the script are prefixed with "lz4_" -# - Variables that should be externally visible are prefixed with "LZ4_" - -set(lz4_LIBNAME "lz4") - -include(cmake/Modules/FindLibraryDependencies.cmake) - -set(lz4_HEADER "lz4.h") -set(lz4_LIBNAME "lz4") -set(lz4_LOCAL_PREFIX "lz4") -set(lz4_PKGCONFIG_NAME "liblz4") - -if(DEFINED LZ4_ROOT) - set(lz4_PKGCONFIG_DIR "${LZ4_ROOT}/lib/pkgconfig") - set(ENV{lz4_ORIG_PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}") - set(ENV{PKG_CONFIG_PATH} "${lz4_PKGCONFIG_DIR};$ENV{PKG_CONFIG_PATH}") -endif() - -# Run pkg-config -find_package(PkgConfig) -pkg_check_modules(lz4_PKGCONF QUIET "${lz4_PKGCONFIG_NAME}") - -# Manually set package finding hints in case of failure -if(NOT lz4_PKGCONF_FOUND) - message(WARNING "Cannot find package config for ${lz4_PKGCONFIG_NAME}") - if(DEFINED LZ4_ROOT) - set(lz4_PKGCONF_INCLUDEDIR "${LZ4_ROOT}/include") - set(lz4_PKGCONF_LIBDIR "${LZ4_ROOT}/lib") - endif() -endif() - -# Set include directory -find_path(LZ4_INCLUDE_DIR ${lz4_HEADER} - HINTS ${lz4_PKGCONF_INCLUDEDIR} - PATH_SUFFIXES include - ) - -# Handle static libraries -if(LZ4_USE_STATIC_LIBS) - set(lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - set(CMAKE_FIND_LIBRARY_SUFFIXES .a) -endif() - -# Find library -find_library(LZ4_LIBRARY - NAMES ${lz4_LIBNAME} - HINTS ${lz4_PKGCONF_LIBDIR} - PATH_SUFFIXES lib - ) - -if(LZ4_USE_STATIC_LIBS) - FindStaticLibraryDependencies(${lz4_LIBNAME} ${lz4_LOCAL_PREFIX} - "${lz4_PKGCONF_STATIC_LIBRARIES}") - - # Restore original value of CMAKE_FIND_LIBRARY_SUFFIXES - set(CMAKE_FIND_LIBRARY_SUFFIXES ${lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - unset(lz4_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) -endif() - -FindDynamicLibraryDependencies(${lz4_LOCAL_PREFIX} "${lz4_DYNAMIC_LIBS}") - -# Set version -set(LZ4_VERSION ${lz4_PKGCONF_VERSION}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LZ4 - REQUIRED_VARS LZ4_LIBRARY LZ4_INCLUDE_DIR - VERSION_VAR LZ4_VERSION - ) - -if(NOT TARGET LZ4::LZ4) - # Add library to build - if (LZ4_USE_STATIC_LIBS) - add_library(LZ4::LZ4 STATIC IMPORTED) - else() - # NOTE: We use UNKNOWN so that if the user doesn't have the SHARED - # libraries installed, we can still use the STATIC libraries - add_library(LZ4::LZ4 UNKNOWN IMPORTED) - endif() - - # Set include directories for library - if(LZ4_INCLUDE_DIR) - set_target_properties(LZ4::LZ4 - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}" - ) - endif() - - # Set location of library - if(EXISTS "${LZ4_LIBRARY}") - set_target_properties(LZ4::LZ4 - PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${LZ4_LIBRARY}" - ) - - # Add component's dependencies for linking - if(lz4_LIBRARY_DEPENDENCIES) - set_target_properties(LZ4::LZ4 - PROPERTIES - INTERFACE_LINK_LIBRARIES "${lz4_LIBRARY_DEPENDENCIES}" - ) - endif() - endif() -endif() - -# Restore original value of PKG_CONFIG_PATH -if(DEFINED LZ4_ROOT) - set(ENV{PKG_CONFIG_PATH} "$ENV{lz4_ORIG_PKG_CONFIG_PATH}") - unset(ENV{lz4_ORIG_PKG_CONFIG_PATH}) -endif() diff --git a/docs/src/dev-guide/components-core/index.md b/docs/src/dev-guide/components-core/index.md index 16cc9bbd31..8b73f885b6 100644 --- a/docs/src/dev-guide/components-core/index.md +++ b/docs/src/dev-guide/components-core/index.md @@ -42,7 +42,7 @@ The task will download, build, and install (within the build directory) the foll | [fmt](https://github.com/fmtlib/fmt) | v10.2.1 | | [json](https://github.com/nlohmann/json.git) | v3.11.3 | | [log-surgeon](https://github.com/y-scope/log-surgeon) | f801a3f | -| [LZ4](https://github.com/lz4/lz4) | v1.10.0 | +| [lz4](https://github.com/lz4/lz4) | v1.10.0 | | [mongo-cxx-driver](https://github.com/mongodb/mongo-cxx-driver) | r3.10.2 | | [simdjson](https://github.com/simdjson/simdjson) | v3.13.0 | | [spdlog](https://github.com/gabime/spdlog) | v1.14.1 | diff --git a/taskfiles/deps/main.yaml b/taskfiles/deps/main.yaml index 4a4fad0b94..f0f7a3ea4a 100644 --- a/taskfiles/deps/main.yaml +++ b/taskfiles/deps/main.yaml @@ -251,7 +251,7 @@ tasks: - "-DCMAKE_BUILD_TYPE=Release" - "-DCMAKE_INSTALL_MESSAGE=LAZY" CMAKE_SOURCE_DIR: "build/cmake" - LIB_NAME: "LZ4" + LIB_NAME: "lz4" TARBALL_SHA256: "537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b" TARBALL_URL: "https://github.com/lz4/lz4/releases/download/v1.10.0/lz4-1.10.0.tar.gz" From 5835dbc61bd56fad155c5b27f049d87ce1ffed5c Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 4 Aug 2025 05:41:52 -0400 Subject: [PATCH 04/13] Temporarily test lz4 --- components/core/CMakeLists.txt | 1 + components/core/tests/test-string_utils.cpp | 34 +++++++++++++++++++++ taskfiles/deps/main.yaml | 1 - 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index b63c122115..0ece72e349 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -788,6 +788,7 @@ if(CLP_BUILD_TESTING) ystdlib::error_handling ${LIBLZMA_LIBRARIES} ZStd::ZStd + lz4_TARGET ) target_compile_features(unitTest PRIVATE cxx_std_20 diff --git a/components/core/tests/test-string_utils.cpp b/components/core/tests/test-string_utils.cpp index 25dbd54dfb..4a231ab9e5 100644 --- a/components/core/tests/test-string_utils.cpp +++ b/components/core/tests/test-string_utils.cpp @@ -562,3 +562,37 @@ TEST_CASE("convert_string_to_int", "[convert_string_to_int]") { REQUIRE(convert_string_to_int(raw, converted)); REQUIRE(98'340 == converted); } + + +#include +#include +#include + +TEST_CASE("LZ4 compress and decompress roundtrip", "[lz4]") { + const std::string input = "This is a test string for LZ4 compression."; + const int max_dst_size = LZ4_compressBound(static_cast(input.size())); + + std::vector compressed(max_dst_size); + std::vector decompressed(input.size()); + + SECTION("Compression succeeds") { + int compressed_size = LZ4_compress_default( + input.data(), + compressed.data(), + static_cast(input.size()), + max_dst_size + ); + REQUIRE(compressed_size > 0); + + int decompressed_size = LZ4_decompress_safe( + compressed.data(), + decompressed.data(), + compressed_size, + static_cast(decompressed.size()) + ); + REQUIRE(decompressed_size == static_cast(input.size())); + + std::string output(decompressed.begin(), decompressed.end()); + REQUIRE(output == input); + } +} diff --git a/taskfiles/deps/main.yaml b/taskfiles/deps/main.yaml index f0f7a3ea4a..f55fafec07 100644 --- a/taskfiles/deps/main.yaml +++ b/taskfiles/deps/main.yaml @@ -67,7 +67,6 @@ tasks: - task: "date" - task: "fmt" - task: "log-surgeon" - - task: "lz4" - task: "microsoft.gsl" - task: "mongocxx" - task: "nlohmann_json" From ac3292dc240a15d6fb689e0d7eb973d6e3e598d7 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 4 Aug 2025 06:32:09 -0400 Subject: [PATCH 05/13] Revert "Temporarily test lz4" This reverts commit 5835dbc61bd56fad155c5b27f049d87ce1ffed5c. --- components/core/CMakeLists.txt | 1 - components/core/tests/test-string_utils.cpp | 34 --------------------- taskfiles/deps/main.yaml | 1 + 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index 0ece72e349..b63c122115 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -788,7 +788,6 @@ if(CLP_BUILD_TESTING) ystdlib::error_handling ${LIBLZMA_LIBRARIES} ZStd::ZStd - lz4_TARGET ) target_compile_features(unitTest PRIVATE cxx_std_20 diff --git a/components/core/tests/test-string_utils.cpp b/components/core/tests/test-string_utils.cpp index 4a231ab9e5..25dbd54dfb 100644 --- a/components/core/tests/test-string_utils.cpp +++ b/components/core/tests/test-string_utils.cpp @@ -562,37 +562,3 @@ TEST_CASE("convert_string_to_int", "[convert_string_to_int]") { REQUIRE(convert_string_to_int(raw, converted)); REQUIRE(98'340 == converted); } - - -#include -#include -#include - -TEST_CASE("LZ4 compress and decompress roundtrip", "[lz4]") { - const std::string input = "This is a test string for LZ4 compression."; - const int max_dst_size = LZ4_compressBound(static_cast(input.size())); - - std::vector compressed(max_dst_size); - std::vector decompressed(input.size()); - - SECTION("Compression succeeds") { - int compressed_size = LZ4_compress_default( - input.data(), - compressed.data(), - static_cast(input.size()), - max_dst_size - ); - REQUIRE(compressed_size > 0); - - int decompressed_size = LZ4_decompress_safe( - compressed.data(), - decompressed.data(), - compressed_size, - static_cast(decompressed.size()) - ); - REQUIRE(decompressed_size == static_cast(input.size())); - - std::string output(decompressed.begin(), decompressed.end()); - REQUIRE(output == input); - } -} diff --git a/taskfiles/deps/main.yaml b/taskfiles/deps/main.yaml index f55fafec07..f0f7a3ea4a 100644 --- a/taskfiles/deps/main.yaml +++ b/taskfiles/deps/main.yaml @@ -67,6 +67,7 @@ tasks: - task: "date" - task: "fmt" - task: "log-surgeon" + - task: "lz4" - task: "microsoft.gsl" - task: "mongocxx" - task: "nlohmann_json" From fc2b711377d5fa13c52a5585dc2c7d6c8c55ee41 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 4 Aug 2025 07:42:09 -0400 Subject: [PATCH 06/13] Migrate zstandard to task --- components/core/CMakeLists.txt | 20 ++-- components/core/src/clp/clg/CMakeLists.txt | 2 +- components/core/src/clp/clo/CMakeLists.txt | 2 +- components/core/src/clp/clp/CMakeLists.txt | 2 +- .../make_dictionaries_readable/CMakeLists.txt | 2 +- components/core/src/clp_s/CMakeLists.txt | 4 +- .../core/src/clp_s/indexer/CMakeLists.txt | 2 +- components/core/src/glt/glt/CMakeLists.txt | 2 +- .../scripts/lib_install/macos/install-all.sh | 3 +- .../install-packages-from-source.sh | 1 - .../install-packages-from-source.sh | 1 - .../install-packages-from-source.sh | 1 - .../tools/scripts/lib_install/zstandard.sh | 95 ------------------- taskfiles/deps/main.yaml | 20 ++++ 14 files changed, 37 insertions(+), 120 deletions(-) delete mode 100755 components/core/tools/scripts/lib_install/zstandard.sh diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index b63c122115..0e6c09d23a 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -306,17 +306,13 @@ if(CLP_NEED_YSTDLIB) add_subdirectory("${CLP_YSTDLIB_SOURCE_DIRECTORY}" "${CMAKE_BINARY_DIR}/ystdlib" EXCLUDE_FROM_ALL) endif() -# Find and setup ZStd Library -if(CLP_NEED_ZSTD) - if(CLP_USE_STATIC_LIBS) - set(ZStd_USE_STATIC_LIBS ON) - endif() - find_package(ZStd 1.4.4 REQUIRED) - if(ZStd_FOUND) - message(STATUS "Found ZStd ${ZStd_VERSION}") - else() - message(FATAL_ERROR "Could not find ${CLP_LIBS_STRING} libraries for ZStd") - endif() +find_package(zstd 1.4.4 REQUIRED) +message(STATUS "Found zstd ${zstd_VERSION}") +add_library(zstd_TARGET INTERFACE) +if(CLP_USE_STATIC_LIBS) + target_link_libraries(zstd_TARGET INTERFACE zstd::libzstd_static) +else() + target_link_libraries(zstd_TARGET INTERFACE zstd::libzstd_shared) endif() # Find and setup LZMA Library @@ -787,7 +783,7 @@ if(CLP_BUILD_TESTING) ystdlib::containers ystdlib::error_handling ${LIBLZMA_LIBRARIES} - ZStd::ZStd + zstd_TARGET ) target_compile_features(unitTest PRIVATE cxx_std_20 diff --git a/components/core/src/clp/clg/CMakeLists.txt b/components/core/src/clp/clg/CMakeLists.txt index 816173bdb0..0444937f01 100644 --- a/components/core/src/clp/clg/CMakeLists.txt +++ b/components/core/src/clp/clg/CMakeLists.txt @@ -146,7 +146,7 @@ if(CLP_BUILD_EXECUTABLES) yaml-cpp ystdlib::containers ystdlib::error_handling - ZStd::ZStd + zstd_TARGET ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp/clo/CMakeLists.txt b/components/core/src/clp/clo/CMakeLists.txt index 94d03c79e0..69d6503dd5 100644 --- a/components/core/src/clp/clo/CMakeLists.txt +++ b/components/core/src/clp/clo/CMakeLists.txt @@ -174,7 +174,7 @@ if(CLP_BUILD_EXECUTABLES) clp::string_utils ystdlib::containers ystdlib::error_handling - ZStd::ZStd + zstd_TARGET ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp/clp/CMakeLists.txt b/components/core/src/clp/clp/CMakeLists.txt index e9b35c296e..8b74da5abe 100644 --- a/components/core/src/clp/clp/CMakeLists.txt +++ b/components/core/src/clp/clp/CMakeLists.txt @@ -189,7 +189,7 @@ if(CLP_BUILD_EXECUTABLES) yaml-cpp ystdlib::containers ystdlib::error_handling - ZStd::ZStd + zstd_TARGET ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt b/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt index 65bf33e03e..d36da576fa 100644 --- a/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt +++ b/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt @@ -49,7 +49,7 @@ if(CLP_BUILD_EXECUTABLES) spdlog::spdlog clp::string_utils ystdlib::containers - ZStd::ZStd + zstd_TARGET ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp_s/CMakeLists.txt b/components/core/src/clp_s/CMakeLists.txt index ef3b34b2fc..f580456317 100644 --- a/components/core/src/clp_s/CMakeLists.txt +++ b/components/core/src/clp_s/CMakeLists.txt @@ -102,7 +102,7 @@ if(CLP_BUILD_CLP_S_CLP_DEPENDENCIES) OpenSSL::Crypto spdlog::spdlog ystdlib::error_handling - ZStd::ZStd + zstd_TARGET ) endif() @@ -182,7 +182,7 @@ if(CLP_BUILD_CLP_S_IO) clp_s::clp_dependencies fmt::fmt spdlog::spdlog - ZStd::ZStd + zstd_TARGET ) endif() diff --git a/components/core/src/clp_s/indexer/CMakeLists.txt b/components/core/src/clp_s/indexer/CMakeLists.txt index 20e9e9a1e0..a36ca6acfc 100644 --- a/components/core/src/clp_s/indexer/CMakeLists.txt +++ b/components/core/src/clp_s/indexer/CMakeLists.txt @@ -97,7 +97,7 @@ if(CLP_BUILD_EXECUTABLES) spdlog::spdlog yaml-cpp ystdlib::containers - ZStd::ZStd + zstd_TARGET ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/glt/glt/CMakeLists.txt b/components/core/src/glt/glt/CMakeLists.txt index 8576f391f5..de9044170f 100644 --- a/components/core/src/glt/glt/CMakeLists.txt +++ b/components/core/src/glt/glt/CMakeLists.txt @@ -192,7 +192,7 @@ if(CLP_BUILD_EXECUTABLES) clp::string_utils yaml-cpp ystdlib::error_handling - ZStd::ZStd + zstd_TARGET ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/tools/scripts/lib_install/macos/install-all.sh b/components/core/tools/scripts/lib_install/macos/install-all.sh index 5316cc7921..91ef95a1f7 100755 --- a/components/core/tools/scripts/lib_install/macos/install-all.sh +++ b/components/core/tools/scripts/lib_install/macos/install-all.sh @@ -48,8 +48,7 @@ brew install \ llvm@16 \ mariadb-connector-c \ msgpack-cxx \ - xz \ - zstd + xz # Install pkg-config if it isn't already installed # NOTE: We might expect that pkg-config is installed through brew, so trying to install it again diff --git a/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh index f083908cd0..10bc63e017 100755 --- a/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh @@ -15,7 +15,6 @@ lib_install_scripts_dir="${script_dir}/.." # repositories are either dated or don't include static libraries, so we install more recent # versions from source. "${lib_install_scripts_dir}/liblzma.sh" 5.8.1 -"${lib_install_scripts_dir}/zstandard.sh" 1.5.7 "${lib_install_scripts_dir}/libarchive.sh" 3.8.0 "${lib_install_scripts_dir}/msgpack.sh" 7.0.0 diff --git a/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh index ba4423f19a..790dddafd0 100755 --- a/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh @@ -15,7 +15,6 @@ lib_install_scripts_dir="${script_dir}/.." # repositories are either dated or don't include static libraries, so we install more recent # versions from source. "${lib_install_scripts_dir}/liblzma.sh" 5.8.1 -"${lib_install_scripts_dir}/zstandard.sh" 1.5.7 "${lib_install_scripts_dir}/libarchive.sh" 3.8.0 "${lib_install_scripts_dir}/msgpack.sh" 7.0.0 diff --git a/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh index 1a231040dc..1df0642acf 100755 --- a/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh @@ -15,4 +15,3 @@ lib_install_scripts_dir=$script_dir/.. "$lib_install_scripts_dir"/libarchive.sh 3.5.1 "$lib_install_scripts_dir"/liblzma.sh 5.8.1 "$lib_install_scripts_dir"/msgpack.sh 7.0.0 -"$lib_install_scripts_dir"/zstandard.sh 1.4.9 diff --git a/components/core/tools/scripts/lib_install/zstandard.sh b/components/core/tools/scripts/lib_install/zstandard.sh deleted file mode 100755 index df1a3a3404..0000000000 --- a/components/core/tools/scripts/lib_install/zstandard.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash - -# Dependencies: -# - cmake -# - curl -# - g++ -# NOTE: Dependencies should be installed outside the script to allow the script to be largely distro-agnostic - -# Exit on any error -set -e - -cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" -if [ "$#" -lt 1 ] ; then - echo $cUsage - exit -fi -version=$1 - -package_name=libzstd -temp_dir=/tmp/${package_name}-installation -deb_output_dir=${temp_dir} -if [[ "$#" -gt 1 ]] ; then - deb_output_dir="$(readlink -f "$2")" - if [ ! -d ${deb_output_dir} ] ; then - echo "${deb_output_dir} does not exist or is not a directory" - exit - fi -fi - -# Check if already installed -set +e -dpkg -l ${package_name} | grep ${version} -installed=$? -set -e -if [ $installed -eq 0 ] ; then - # Nothing to do - exit -fi - -echo "Checking for elevated privileges..." -install_cmd_args=() -if [ ${EUID:-$(id -u)} -ne 0 ] ; then - sudo echo "Script can elevate privileges." - install_cmd_args+=("sudo") -fi - -# Get number of cpu cores -num_cpus=$(grep -c ^processor /proc/cpuinfo) - -# Download -mkdir -p $temp_dir -cd $temp_dir -extracted_dir=${temp_dir}/zstd-${version} -if [ ! -e ${extracted_dir} ] ; then - tar_filename=zstd-${version}.tar.gz - if [ ! -e ${tar_filename} ] ; then - curl -fsSL https://github.com/facebook/zstd/releases/download/v${version}/${tar_filename} -o ${tar_filename} - fi - - tar -xf ${tar_filename} -fi - -# Build -cd ${extracted_dir}/build/cmake -mkdir -p cmake-build-release -cd cmake-build-release -cmake ../ -make -j${num_cpus} - -# Check if checkinstall is installed -set +e -command -v checkinstall -checkinstall_installed=$? -set -e - -# Install -if [ $checkinstall_installed -eq 0 ] ; then - install_cmd_args+=( - checkinstall - --default - --fstrans=no - --nodoc - --pkgname "${package_name}" - --pkgversion "${version}" - --provides "${package_name}" - --pakdir "${deb_output_dir}" - ) -fi -install_cmd_args+=( - make install -) -"${install_cmd_args[@]}" - -# Clean up -rm -rf $temp_dir diff --git a/taskfiles/deps/main.yaml b/taskfiles/deps/main.yaml index f0f7a3ea4a..d478cac6d2 100644 --- a/taskfiles/deps/main.yaml +++ b/taskfiles/deps/main.yaml @@ -77,6 +77,7 @@ tasks: - task: "utfcpp" - task: "yaml-cpp" - task: "ystdlib" + - task: "zstd" absl: internal: true @@ -430,3 +431,22 @@ tasks: echo "set( CLP_YSTDLIB_SOURCE_DIRECTORY \"{{.YSTDLIB_OUTPUT_DIR}}\" )" > "{{.G_DEPS_CORE_CMAKE_SETTINGS_DIR}}/{{.LIB_NAME}}.cmake" + + zstd: + internal: true + run: "once" + cmds: + - task: "utils:install-remote-cmake-lib" + vars: + CMAKE_GEN_ARGS: + - "-DCMAKE_BUILD_TYPE=Release" + - "-DCMAKE_INSTALL_MESSAGE=LAZY" + - "-DZSTD_BUILD_CONTRIB=OFF" + - "-DZSTD_BUILD_PROGRAMS=OFF" + - "-DZSTD_BUILD_SHARED=ON" + - "-DZSTD_BUILD_STATIC=ON" + - "-DZSTD_BUILD_TESTS=OFF" + CMAKE_SOURCE_DIR: "build/cmake" + LIB_NAME: "zstd" + TARBALL_SHA256: "eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3" + TARBALL_URL: "https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz" From 48fd88d7840421c601384a1bbf214c82ae963556 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 4 Aug 2025 10:31:43 -0400 Subject: [PATCH 07/13] misc fix --- components/core/cmake/Modules/FindZStd.cmake | 106 ------------------- docs/src/dev-guide/components-core/index.md | 1 + 2 files changed, 1 insertion(+), 106 deletions(-) delete mode 100644 components/core/cmake/Modules/FindZStd.cmake diff --git a/components/core/cmake/Modules/FindZStd.cmake b/components/core/cmake/Modules/FindZStd.cmake deleted file mode 100644 index 503dfebfac..0000000000 --- a/components/core/cmake/Modules/FindZStd.cmake +++ /dev/null @@ -1,106 +0,0 @@ -# Try to find ZStd -# -# Set ZStd_USE_STATIC_LIBS=ON to look for static libraries. -# -# Once done this will define: -# ZStd_FOUND - Whether ZStd was found on the system -# ZStd_INCLUDE_DIR - The ZStd include directories -# ZStd_VERSION - The version of ZStd installed on the system -# -# Conventions: -# - Variables only for use within the script are prefixed with "zstd_" -# - Variables that should be externally visible are prefixed with "ZStd_" - -set(zstd_LIBNAME "zstd") - -include(cmake/Modules/FindLibraryDependencies.cmake) - -# Run pkg-config -find_package(PkgConfig) -pkg_check_modules(zstd_PKGCONF QUIET lib${zstd_LIBNAME}) - -# Set include directory -find_path(ZStd_INCLUDE_DIR zstd.h - HINTS ${zstd_PKGCONF_INCLUDEDIR} - PATH_SUFFIXES include - ) - -# Handle static libraries -if(ZStd_USE_STATIC_LIBS) - # Save current value of CMAKE_FIND_LIBRARY_SUFFIXES - set(zstd_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - - # Temporarily change CMAKE_FIND_LIBRARY_SUFFIXES to static library suffix - set(CMAKE_FIND_LIBRARY_SUFFIXES .a) -endif() - -# Find library -find_library(ZStd_LIBRARY - NAMES zstd - HINTS ${zstd_PKGCONF_LIBDIR} - PATH_SUFFIXES lib - ) -if (ZStd_LIBRARY) - # NOTE: This must be set for find_package_handle_standard_args to work - set(ZStd_FOUND ON) -endif() - -if(ZStd_USE_STATIC_LIBS) - FindStaticLibraryDependencies(${zstd_LIBNAME} zstd "${zstd_PKGCONF_STATIC_LIBRARIES}") - - # Restore original value of CMAKE_FIND_LIBRARY_SUFFIXES - set(CMAKE_FIND_LIBRARY_SUFFIXES ${zstd_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - unset(zstd_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) -endif() - -# Add pthread manually since zstd's pkgconfig doesn't include it -list(APPEND zstd_DYNAMIC_LIBS "pthread") - -FindDynamicLibraryDependencies(zstd "${zstd_DYNAMIC_LIBS}") - -# Set version -set(ZStd_VERSION ${zstd_PKGCONF_VERSION}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(ZStd - REQUIRED_VARS ZStd_INCLUDE_DIR - VERSION_VAR ZStd_VERSION - ) - -if(NOT TARGET ZStd::ZStd) - # Add library to build - if (ZStd_FOUND) - if (ZStd_USE_STATIC_LIBS) - add_library(ZStd::ZStd STATIC IMPORTED) - else() - # NOTE: We use UNKNOWN so that if the user doesn't have the SHARED - # libraries installed, we can still use the STATIC libraries - add_library(ZStd::ZStd UNKNOWN IMPORTED) - endif() - endif() - - # Set include directories for library - if(ZStd_INCLUDE_DIR) - set_target_properties(ZStd::ZStd - PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${ZStd_INCLUDE_DIR}" - ) - endif() - - # Set location of library - if(EXISTS "${ZStd_LIBRARY}") - set_target_properties(ZStd::ZStd - PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${ZStd_LIBRARY}" - ) - - # Add component's dependencies for linking - if(zstd_LIBRARY_DEPENDENCIES) - set_target_properties(ZStd::ZStd - PROPERTIES - INTERFACE_LINK_LIBRARIES "${zstd_LIBRARY_DEPENDENCIES}" - ) - endif() - endif() -endif() diff --git a/docs/src/dev-guide/components-core/index.md b/docs/src/dev-guide/components-core/index.md index 8b73f885b6..ffe2c9189f 100644 --- a/docs/src/dev-guide/components-core/index.md +++ b/docs/src/dev-guide/components-core/index.md @@ -51,6 +51,7 @@ The task will download, build, and install (within the build directory) the foll | [yaml-cpp](https://github.com/jbeder/yaml-cpp.git) | v0.7.0 | | [yscope-log-viewer](https://github.com/y-scope/yscope-log-viewer.git) | 969ff35 | | [ystdlib-cpp](https://github.com/y-scope/ystdlib-cpp.git) | d80cf86 | +| [zstd](https://github.com/facebook/zstd) | v1.5.7 | ### Environment From 47a2b18b630251a1f1c28c7c6a85936f77dd59e5 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 4 Aug 2025 12:26:51 -0400 Subject: [PATCH 08/13] Fix macos package selection with find package hints. Add missing linking libs --- components/core/CMakeLists.txt | 4 ++-- components/core/src/clp_s/CMakeLists.txt | 4 ++++ components/core/src/clp_s/search/CMakeLists.txt | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index 0e6c09d23a..513115ea9b 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -192,7 +192,7 @@ if(CLP_NEED_LOG_SURGEON) endif() endif() -find_package(lz4 REQUIRED) +find_package(lz4 1.10.0 REQUIRED HINTS "${lz4_ROOT}") message(STATUS "Found lz4 ${lz4_VERSION}") add_library(lz4_TARGET INTERFACE) if(CLP_USE_STATIC_LIBS) @@ -306,7 +306,7 @@ if(CLP_NEED_YSTDLIB) add_subdirectory("${CLP_YSTDLIB_SOURCE_DIRECTORY}" "${CMAKE_BINARY_DIR}/ystdlib" EXCLUDE_FROM_ALL) endif() -find_package(zstd 1.4.4 REQUIRED) +find_package(zstd 1.5.7 REQUIRED HINTS "${zstd_ROOT}") message(STATUS "Found zstd ${zstd_VERSION}") add_library(zstd_TARGET INTERFACE) if(CLP_USE_STATIC_LIBS) diff --git a/components/core/src/clp_s/CMakeLists.txt b/components/core/src/clp_s/CMakeLists.txt index f580456317..54bb8adb96 100644 --- a/components/core/src/clp_s/CMakeLists.txt +++ b/components/core/src/clp_s/CMakeLists.txt @@ -250,6 +250,7 @@ if(CLP_BUILD_CLP_S_ARCHIVEWRITER) ${CURL_LIBRARIES} fmt::fmt spdlog::spdlog + zstd_TARGET ) endif() @@ -313,6 +314,7 @@ if(CLP_BUILD_CLP_S_ARCHIVEREADER) ${CURL_LIBRARIES} fmt::fmt spdlog::spdlog + zstd_TARGET ) endif() @@ -340,6 +342,7 @@ if(CLP_BUILD_CLP_S_JSONCONSTRUCTOR) fmt::fmt ${MONGOCXX_TARGET} spdlog::spdlog + zstd_TARGET ) endif() @@ -405,6 +408,7 @@ if(CLP_BUILD_EXECUTABLES) msgpack-cxx spdlog::spdlog ystdlib::error_handling + zstd_TARGET ) set_target_properties( clp-s diff --git a/components/core/src/clp_s/search/CMakeLists.txt b/components/core/src/clp_s/search/CMakeLists.txt index 133e08c49c..c75742a8a3 100644 --- a/components/core/src/clp_s/search/CMakeLists.txt +++ b/components/core/src/clp_s/search/CMakeLists.txt @@ -54,5 +54,6 @@ if(CLP_BUILD_CLP_S_SEARCH) clp_s::clp_dependencies clp_s::io spdlog::spdlog + zstd_TARGET ) endif() From 4ec9c70d698acdb625a8d865de05e6d318f30489 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 5 Aug 2025 21:48:54 -0400 Subject: [PATCH 09/13] Use variable instead of library target for multiplexing lz4 and zstd targets --- components/core/CMakeLists.txt | 12 +++++------- components/core/src/clp/clg/CMakeLists.txt | 2 +- components/core/src/clp/clo/CMakeLists.txt | 2 +- components/core/src/clp/clp/CMakeLists.txt | 2 +- .../clp/make_dictionaries_readable/CMakeLists.txt | 2 +- components/core/src/clp_s/CMakeLists.txt | 12 ++++++------ components/core/src/clp_s/indexer/CMakeLists.txt | 2 +- components/core/src/clp_s/search/CMakeLists.txt | 2 +- components/core/src/glt/glt/CMakeLists.txt | 2 +- 9 files changed, 18 insertions(+), 20 deletions(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index 513115ea9b..c3ffe68b41 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -194,11 +194,10 @@ endif() find_package(lz4 1.10.0 REQUIRED HINTS "${lz4_ROOT}") message(STATUS "Found lz4 ${lz4_VERSION}") -add_library(lz4_TARGET INTERFACE) if(CLP_USE_STATIC_LIBS) - target_link_libraries(lz4_TARGET INTERFACE LZ4::lz4_static) + set(lz4_TARGET LZ4::lz4_static) else() - target_link_libraries(lz4_TARGET INTERFACE LZ4::lz4_shared) + set(lz4_TARGET LZ4::lz4_shared) endif() if(CLP_NEED_NLOHMANN_JSON) @@ -308,11 +307,10 @@ endif() find_package(zstd 1.5.7 REQUIRED HINTS "${zstd_ROOT}") message(STATUS "Found zstd ${zstd_VERSION}") -add_library(zstd_TARGET INTERFACE) if(CLP_USE_STATIC_LIBS) - target_link_libraries(zstd_TARGET INTERFACE zstd::libzstd_static) + set(zstd_TARGET zstd::libzstd_static) else() - target_link_libraries(zstd_TARGET INTERFACE zstd::libzstd_shared) + set(zstd_TARGET zstd::libzstd_shared) endif() # Find and setup LZMA Library @@ -783,7 +781,7 @@ if(CLP_BUILD_TESTING) ystdlib::containers ystdlib::error_handling ${LIBLZMA_LIBRARIES} - zstd_TARGET + ${zstd_TARGET} ) target_compile_features(unitTest PRIVATE cxx_std_20 diff --git a/components/core/src/clp/clg/CMakeLists.txt b/components/core/src/clp/clg/CMakeLists.txt index 0444937f01..6ecaca9a9b 100644 --- a/components/core/src/clp/clg/CMakeLists.txt +++ b/components/core/src/clp/clg/CMakeLists.txt @@ -146,7 +146,7 @@ if(CLP_BUILD_EXECUTABLES) yaml-cpp ystdlib::containers ystdlib::error_handling - zstd_TARGET + ${zstd_TARGET} ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp/clo/CMakeLists.txt b/components/core/src/clp/clo/CMakeLists.txt index 69d6503dd5..4a4adf76f2 100644 --- a/components/core/src/clp/clo/CMakeLists.txt +++ b/components/core/src/clp/clo/CMakeLists.txt @@ -174,7 +174,7 @@ if(CLP_BUILD_EXECUTABLES) clp::string_utils ystdlib::containers ystdlib::error_handling - zstd_TARGET + ${zstd_TARGET} ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp/clp/CMakeLists.txt b/components/core/src/clp/clp/CMakeLists.txt index 8b74da5abe..c468725ed7 100644 --- a/components/core/src/clp/clp/CMakeLists.txt +++ b/components/core/src/clp/clp/CMakeLists.txt @@ -189,7 +189,7 @@ if(CLP_BUILD_EXECUTABLES) yaml-cpp ystdlib::containers ystdlib::error_handling - zstd_TARGET + ${zstd_TARGET} ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt b/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt index d36da576fa..c979b9453b 100644 --- a/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt +++ b/components/core/src/clp/make_dictionaries_readable/CMakeLists.txt @@ -49,7 +49,7 @@ if(CLP_BUILD_EXECUTABLES) spdlog::spdlog clp::string_utils ystdlib::containers - zstd_TARGET + ${zstd_TARGET} ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp_s/CMakeLists.txt b/components/core/src/clp_s/CMakeLists.txt index 54bb8adb96..3c89faf374 100644 --- a/components/core/src/clp_s/CMakeLists.txt +++ b/components/core/src/clp_s/CMakeLists.txt @@ -102,7 +102,7 @@ if(CLP_BUILD_CLP_S_CLP_DEPENDENCIES) OpenSSL::Crypto spdlog::spdlog ystdlib::error_handling - zstd_TARGET + ${zstd_TARGET} ) endif() @@ -182,7 +182,7 @@ if(CLP_BUILD_CLP_S_IO) clp_s::clp_dependencies fmt::fmt spdlog::spdlog - zstd_TARGET + ${zstd_TARGET} ) endif() @@ -250,7 +250,7 @@ if(CLP_BUILD_CLP_S_ARCHIVEWRITER) ${CURL_LIBRARIES} fmt::fmt spdlog::spdlog - zstd_TARGET + ${zstd_TARGET} ) endif() @@ -314,7 +314,7 @@ if(CLP_BUILD_CLP_S_ARCHIVEREADER) ${CURL_LIBRARIES} fmt::fmt spdlog::spdlog - zstd_TARGET + ${zstd_TARGET} ) endif() @@ -342,7 +342,7 @@ if(CLP_BUILD_CLP_S_JSONCONSTRUCTOR) fmt::fmt ${MONGOCXX_TARGET} spdlog::spdlog - zstd_TARGET + ${zstd_TARGET} ) endif() @@ -408,7 +408,7 @@ if(CLP_BUILD_EXECUTABLES) msgpack-cxx spdlog::spdlog ystdlib::error_handling - zstd_TARGET + ${zstd_TARGET} ) set_target_properties( clp-s diff --git a/components/core/src/clp_s/indexer/CMakeLists.txt b/components/core/src/clp_s/indexer/CMakeLists.txt index a36ca6acfc..d57cf337c2 100644 --- a/components/core/src/clp_s/indexer/CMakeLists.txt +++ b/components/core/src/clp_s/indexer/CMakeLists.txt @@ -97,7 +97,7 @@ if(CLP_BUILD_EXECUTABLES) spdlog::spdlog yaml-cpp ystdlib::containers - zstd_TARGET + ${zstd_TARGET} ) # Put the built executable at the root of the build directory set_target_properties( diff --git a/components/core/src/clp_s/search/CMakeLists.txt b/components/core/src/clp_s/search/CMakeLists.txt index c75742a8a3..184691d56d 100644 --- a/components/core/src/clp_s/search/CMakeLists.txt +++ b/components/core/src/clp_s/search/CMakeLists.txt @@ -54,6 +54,6 @@ if(CLP_BUILD_CLP_S_SEARCH) clp_s::clp_dependencies clp_s::io spdlog::spdlog - zstd_TARGET + ${zstd_TARGET} ) endif() diff --git a/components/core/src/glt/glt/CMakeLists.txt b/components/core/src/glt/glt/CMakeLists.txt index de9044170f..6936dab8ea 100644 --- a/components/core/src/glt/glt/CMakeLists.txt +++ b/components/core/src/glt/glt/CMakeLists.txt @@ -192,7 +192,7 @@ if(CLP_BUILD_EXECUTABLES) clp::string_utils yaml-cpp ystdlib::error_handling - zstd_TARGET + ${zstd_TARGET} ) # Put the built executable at the root of the build directory set_target_properties( From 7dc87e97e536e722ec7dcbe3019137df7bc185a0 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Thu, 7 Aug 2025 22:42:27 -0400 Subject: [PATCH 10/13] Put back zstd guard and remove superfluous zstd linkage --- components/core/CMakeLists.txt | 22 +++++++------------ components/core/src/clp_s/CMakeLists.txt | 4 ---- .../core/src/clp_s/search/CMakeLists.txt | 1 - 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index 19e06fd767..529c923f37 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -192,14 +192,6 @@ if(CLP_NEED_LOG_SURGEON) endif() endif() -find_package(lz4 1.10.0 REQUIRED HINTS "${lz4_ROOT}") -message(STATUS "Found lz4 ${lz4_VERSION}") -if(CLP_USE_STATIC_LIBS) - set(lz4_TARGET LZ4::lz4_static) -else() - set(lz4_TARGET LZ4::lz4_shared) -endif() - if(CLP_NEED_NLOHMANN_JSON) find_package(nlohmann_json REQUIRED) if(nlohmann_json_FOUND) @@ -305,12 +297,14 @@ if(CLP_NEED_YSTDLIB) add_subdirectory("${CLP_YSTDLIB_SOURCE_DIRECTORY}" "${CMAKE_BINARY_DIR}/ystdlib" EXCLUDE_FROM_ALL) endif() -find_package(zstd 1.5.7 REQUIRED HINTS "${zstd_ROOT}") -message(STATUS "Found zstd ${zstd_VERSION}") -if(CLP_USE_STATIC_LIBS) - set(zstd_TARGET zstd::libzstd_static) -else() - set(zstd_TARGET zstd::libzstd_shared) +if(CLP_NEED_ZSTD) + find_package(zstd 1.5.7 REQUIRED HINTS "${zstd_ROOT}") + message(STATUS "Found zstd ${zstd_VERSION}") + if(CLP_USE_STATIC_LIBS) + set(zstd_TARGET zstd::libzstd_static) + else() + set(zstd_TARGET zstd::libzstd_shared) + endif() endif() # Find and setup LZMA Library diff --git a/components/core/src/clp_s/CMakeLists.txt b/components/core/src/clp_s/CMakeLists.txt index 3c89faf374..2dbb44172e 100644 --- a/components/core/src/clp_s/CMakeLists.txt +++ b/components/core/src/clp_s/CMakeLists.txt @@ -250,7 +250,6 @@ if(CLP_BUILD_CLP_S_ARCHIVEWRITER) ${CURL_LIBRARIES} fmt::fmt spdlog::spdlog - ${zstd_TARGET} ) endif() @@ -314,7 +313,6 @@ if(CLP_BUILD_CLP_S_ARCHIVEREADER) ${CURL_LIBRARIES} fmt::fmt spdlog::spdlog - ${zstd_TARGET} ) endif() @@ -342,7 +340,6 @@ if(CLP_BUILD_CLP_S_JSONCONSTRUCTOR) fmt::fmt ${MONGOCXX_TARGET} spdlog::spdlog - ${zstd_TARGET} ) endif() @@ -408,7 +405,6 @@ if(CLP_BUILD_EXECUTABLES) msgpack-cxx spdlog::spdlog ystdlib::error_handling - ${zstd_TARGET} ) set_target_properties( clp-s diff --git a/components/core/src/clp_s/search/CMakeLists.txt b/components/core/src/clp_s/search/CMakeLists.txt index 184691d56d..133e08c49c 100644 --- a/components/core/src/clp_s/search/CMakeLists.txt +++ b/components/core/src/clp_s/search/CMakeLists.txt @@ -54,6 +54,5 @@ if(CLP_BUILD_CLP_S_SEARCH) clp_s::clp_dependencies clp_s::io spdlog::spdlog - ${zstd_TARGET} ) endif() From ea509896d331389fd6b4a54701a462c651028aa3 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Thu, 7 Aug 2025 23:07:14 -0400 Subject: [PATCH 11/13] Put back lz4 and zstd installations for now since libarchive cannot search custom install paths --- .../install-prebuilt-packages.sh | 1 + .../core/tools/scripts/lib_install/lz4.sh | 92 ++++++++++++++++++ .../scripts/lib_install/macos/install-all.sh | 4 +- .../install-packages-from-source.sh | 2 + .../install-packages-from-source.sh | 2 + .../install-packages-from-source.sh | 2 + .../tools/scripts/lib_install/zstandard.sh | 95 +++++++++++++++++++ 7 files changed, 197 insertions(+), 1 deletion(-) create mode 100755 components/core/tools/scripts/lib_install/lz4.sh create mode 100755 components/core/tools/scripts/lib_install/zstandard.sh diff --git a/components/core/tools/scripts/lib_install/centos-stream-9/install-prebuilt-packages.sh b/components/core/tools/scripts/lib_install/centos-stream-9/install-prebuilt-packages.sh index 1d5b253a57..f91035b61c 100755 --- a/components/core/tools/scripts/lib_install/centos-stream-9/install-prebuilt-packages.sh +++ b/components/core/tools/scripts/lib_install/centos-stream-9/install-prebuilt-packages.sh @@ -16,6 +16,7 @@ dnf install -y \ libarchive-devel \ libcurl-devel \ libzstd-devel \ + lz4-devel \ make \ mariadb-connector-c-devel \ openssl-devel \ diff --git a/components/core/tools/scripts/lib_install/lz4.sh b/components/core/tools/scripts/lib_install/lz4.sh new file mode 100755 index 0000000000..6c60501e1a --- /dev/null +++ b/components/core/tools/scripts/lib_install/lz4.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# Dependencies: +# - curl +# - make +# - gcc +# NOTE: Dependencies should be installed outside the script to allow the script to be largely distro-agnostic + +# Exit on any error +set -e + +cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" +if [ "$#" -lt 1 ] ; then + echo $cUsage + exit +fi +version=$1 + +package_name=liblz4 +temp_dir=/tmp/${package_name}-installation +deb_output_dir=${temp_dir} +if [[ "$#" -gt 1 ]] ; then + deb_output_dir="$(readlink -f "$2")" + if [ ! -d ${deb_output_dir} ] ; then + echo "${deb_output_dir} does not exist or is not a directory" + exit + fi +fi + +# Check if already installed +set +e +dpkg -l ${package_name} | grep ${version} +installed=$? +set -e +if [ $installed -eq 0 ] ; then + # Nothing to do + exit +fi + +echo "Checking for elevated privileges..." +install_cmd_args=() +if [ ${EUID:-$(id -u)} -ne 0 ] ; then + sudo echo "Script can elevate privileges." + install_cmd_args+=("sudo") +fi + +# Get number of cpu cores +num_cpus=$(grep -c ^processor /proc/cpuinfo) + +# Download +mkdir -p $temp_dir +cd $temp_dir +extracted_dir=${temp_dir}/lz4-${version} +if [ ! -e ${extracted_dir} ] ; then + tar_filename=v${version}.tar.gz + if [ ! -e ${tar_filename} ] ; then + curl -fsSL https://github.com/lz4/lz4/archive/${tar_filename} -o ${tar_filename} + fi + + tar -xf ${tar_filename} +fi + +# Build +cd ${extracted_dir} +make -j${num_cpus} + +# Check if checkinstall is installed +set +e +command -v checkinstall +checkinstall_installed=$? +set -e + +# Install +if [ $checkinstall_installed -eq 0 ] ; then + install_cmd_args+=( + checkinstall + --default + --fstrans=no + --nodoc + --pkgname "${package_name}" + --pkgversion "${version}" + --provides "${package_name}" + --pakdir "${deb_output_dir}" + ) +fi +install_cmd_args+=( + make install +) +"${install_cmd_args[@]}" + +# Clean up +rm -rf $temp_dir diff --git a/components/core/tools/scripts/lib_install/macos/install-all.sh b/components/core/tools/scripts/lib_install/macos/install-all.sh index 91ef95a1f7..4f75fb8af4 100755 --- a/components/core/tools/scripts/lib_install/macos/install-all.sh +++ b/components/core/tools/scripts/lib_install/macos/install-all.sh @@ -46,9 +46,11 @@ brew install \ java11 \ libarchive \ llvm@16 \ + lz4 \ mariadb-connector-c \ msgpack-cxx \ - xz + xz \ + zstd # Install pkg-config if it isn't already installed # NOTE: We might expect that pkg-config is installed through brew, so trying to install it again diff --git a/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh index 10bc63e017..d31343c8ee 100755 --- a/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/manylinux_2_28/install-packages-from-source.sh @@ -15,6 +15,8 @@ lib_install_scripts_dir="${script_dir}/.." # repositories are either dated or don't include static libraries, so we install more recent # versions from source. "${lib_install_scripts_dir}/liblzma.sh" 5.8.1 +"${lib_install_scripts_dir}/lz4.sh" 1.10.0 +"${lib_install_scripts_dir}/zstandard.sh" 1.5.7 "${lib_install_scripts_dir}/libarchive.sh" 3.8.0 "${lib_install_scripts_dir}/msgpack.sh" 7.0.0 diff --git a/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh index 790dddafd0..e1f65b9bcd 100755 --- a/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/musllinux_1_2/install-packages-from-source.sh @@ -15,6 +15,8 @@ lib_install_scripts_dir="${script_dir}/.." # repositories are either dated or don't include static libraries, so we install more recent # versions from source. "${lib_install_scripts_dir}/liblzma.sh" 5.8.1 +"${lib_install_scripts_dir}/lz4.sh" 1.10.0 +"${lib_install_scripts_dir}/zstandard.sh" 1.5.7 "${lib_install_scripts_dir}/libarchive.sh" 3.8.0 "${lib_install_scripts_dir}/msgpack.sh" 7.0.0 diff --git a/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh b/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh index 1df0642acf..161058ae9f 100755 --- a/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh +++ b/components/core/tools/scripts/lib_install/ubuntu-jammy/install-packages-from-source.sh @@ -14,4 +14,6 @@ lib_install_scripts_dir=$script_dir/.. "$lib_install_scripts_dir"/libarchive.sh 3.5.1 "$lib_install_scripts_dir"/liblzma.sh 5.8.1 +"$lib_install_scripts_dir"/lz4.sh 1.10.0 "$lib_install_scripts_dir"/msgpack.sh 7.0.0 +"$lib_install_scripts_dir"/zstandard.sh 1.5.7 diff --git a/components/core/tools/scripts/lib_install/zstandard.sh b/components/core/tools/scripts/lib_install/zstandard.sh new file mode 100755 index 0000000000..df1a3a3404 --- /dev/null +++ b/components/core/tools/scripts/lib_install/zstandard.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# Dependencies: +# - cmake +# - curl +# - g++ +# NOTE: Dependencies should be installed outside the script to allow the script to be largely distro-agnostic + +# Exit on any error +set -e + +cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" +if [ "$#" -lt 1 ] ; then + echo $cUsage + exit +fi +version=$1 + +package_name=libzstd +temp_dir=/tmp/${package_name}-installation +deb_output_dir=${temp_dir} +if [[ "$#" -gt 1 ]] ; then + deb_output_dir="$(readlink -f "$2")" + if [ ! -d ${deb_output_dir} ] ; then + echo "${deb_output_dir} does not exist or is not a directory" + exit + fi +fi + +# Check if already installed +set +e +dpkg -l ${package_name} | grep ${version} +installed=$? +set -e +if [ $installed -eq 0 ] ; then + # Nothing to do + exit +fi + +echo "Checking for elevated privileges..." +install_cmd_args=() +if [ ${EUID:-$(id -u)} -ne 0 ] ; then + sudo echo "Script can elevate privileges." + install_cmd_args+=("sudo") +fi + +# Get number of cpu cores +num_cpus=$(grep -c ^processor /proc/cpuinfo) + +# Download +mkdir -p $temp_dir +cd $temp_dir +extracted_dir=${temp_dir}/zstd-${version} +if [ ! -e ${extracted_dir} ] ; then + tar_filename=zstd-${version}.tar.gz + if [ ! -e ${tar_filename} ] ; then + curl -fsSL https://github.com/facebook/zstd/releases/download/v${version}/${tar_filename} -o ${tar_filename} + fi + + tar -xf ${tar_filename} +fi + +# Build +cd ${extracted_dir}/build/cmake +mkdir -p cmake-build-release +cd cmake-build-release +cmake ../ +make -j${num_cpus} + +# Check if checkinstall is installed +set +e +command -v checkinstall +checkinstall_installed=$? +set -e + +# Install +if [ $checkinstall_installed -eq 0 ] ; then + install_cmd_args+=( + checkinstall + --default + --fstrans=no + --nodoc + --pkgname "${package_name}" + --pkgversion "${version}" + --provides "${package_name}" + --pakdir "${deb_output_dir}" + ) +fi +install_cmd_args+=( + make install +) +"${install_cmd_args[@]}" + +# Clean up +rm -rf $temp_dir From 85e2e53cc16262278053ae729cebb32ebb123f8a Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Sun, 10 Aug 2025 18:32:05 +0800 Subject: [PATCH 12/13] Apply suggestions from code review Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> --- components/core/CMakeLists.txt | 3 ++- taskfiles/deps/main.yaml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index bfe10f7b50..2cc4183538 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -298,7 +298,8 @@ if(CLP_NEED_YSTDLIB) endif() if(CLP_NEED_ZSTD) - find_package(zstd 1.5.7 REQUIRED HINTS "${zstd_ROOT}") + # v1.4.8 is the lowest version available in the package managers of the OSes we support. + find_package(zstd 1.4.8 REQUIRED HINTS "${zstd_ROOT}") message(STATUS "Found zstd ${zstd_VERSION}") if(CLP_USE_STATIC_LIBS) set(zstd_TARGET zstd::libzstd_static) diff --git a/taskfiles/deps/main.yaml b/taskfiles/deps/main.yaml index d478cac6d2..cdb5905a3b 100644 --- a/taskfiles/deps/main.yaml +++ b/taskfiles/deps/main.yaml @@ -251,6 +251,7 @@ tasks: - "-DBUILD_STATIC_LIBS=ON" - "-DCMAKE_BUILD_TYPE=Release" - "-DCMAKE_INSTALL_MESSAGE=LAZY" + - "-DLZ4_BUILD_CLI=OFF" CMAKE_SOURCE_DIR: "build/cmake" LIB_NAME: "lz4" TARBALL_SHA256: "537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b" From a7c2b63364cd170dc6dfa0386ccfb7c34f726848 Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Mon, 11 Aug 2025 01:26:04 +0800 Subject: [PATCH 13/13] Address review concern --- components/core/CMakeLists.txt | 2 +- taskfiles/deps/utils.yaml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/core/CMakeLists.txt b/components/core/CMakeLists.txt index 2cc4183538..ecbb0a6fdc 100644 --- a/components/core/CMakeLists.txt +++ b/components/core/CMakeLists.txt @@ -299,7 +299,7 @@ endif() if(CLP_NEED_ZSTD) # v1.4.8 is the lowest version available in the package managers of the OSes we support. - find_package(zstd 1.4.8 REQUIRED HINTS "${zstd_ROOT}") + find_package(zstd 1.4.8 REQUIRED) message(STATUS "Found zstd ${zstd_VERSION}") if(CLP_USE_STATIC_LIBS) set(zstd_TARGET zstd::libzstd_static) diff --git a/taskfiles/deps/utils.yaml b/taskfiles/deps/utils.yaml index 3911b935c2..4ab651b7a7 100644 --- a/taskfiles/deps/utils.yaml +++ b/taskfiles/deps/utils.yaml @@ -46,11 +46,15 @@ tasks: # @param {string} TARBALL_URL # @param {string[]} [CMAKE_GEN_ARGS] Any additional arguments to pass to the CMake generate # command. + # @param {string} [CMAKE_SOURCE_DIR=.] The path, within the tarball extraction directory, + # containing the project's top level CMakeLists.txt. install-remote-cmake-lib: internal: true vars: CMAKE_GEN_ARGS: ref: "default (list) .CMAKE_GEN_ARGS" + CMAKE_SOURCE_DIR: >- + {{default "." .CMAKE_SOURCE_DIR}} INSTALL_PREFIX: "{{.G_DEPS_CORE_DIR}}/{{.LIB_NAME}}-install" INSTALL_DIR_CHECKSUM_FILE: "{{.G_DEPS_CORE_CHECKSUMS_DIR}}/{{.LIB_NAME}}.md5" deps: