Repository navigation
Initial support for lhc4codec #23391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
apeters1971
wants to merge
5
commits into
root-project:lhc4codec
Choose a base branch
from
apeters1971:lhc4codec
base: lhc4codec
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3697bf8
[ntuple] Use a plain Real32 column for uncompressed Double32_t.
apeters1971 d4f4fb2
[ntuple] Report importer payload size and on-disk file size.
apeters1971 a63f086
[ntuple] Remove a performance bottleneck in RNTupleImporter.
apeters1971 30defb2
[zip] Add optional LHC4 compression via lhc4codec.
apeters1971 0cbd2e3
[ntuple] Learned column compression profiles for LHC4 Crystal.
apeters1971 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| # Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. | ||
| # All rights reserved. | ||
| # | ||
| # For the licensing terms see $ROOTSYS/LICENSE. | ||
| # For the list of contributors see $ROOTSYS/README/CREDITS. | ||
|
|
||
| # Build lhc4codec as part of ROOT. Upstream: | ||
| # https://gitlab.cern.ch/apeters/lhc4codec.git | ||
| # | ||
| # If LHC4CODEC_SOURCE_DIR is set, that checkout is built via add_subdirectory | ||
| # (offline / development). Otherwise the source is fetched with ExternalProject | ||
| # (clad-style git clone; requires network and GitLab credentials). | ||
|
|
||
| include(ExternalProject) | ||
|
|
||
| # **PLEASE UPDATE ALSO THE FOLLOWING LINE WHEN UPDATING THE VERSION** | ||
| # 19 Oct 2026, https://gitlab.cern.ch/apeters/lhc4codec.git @ c433157 (Flash/Mosaic/Oracle docs, Crystal design note, RNTuple tools chapter) | ||
| set(ROOT_LHC4CODEC_VERSION 2.5.0) | ||
| set(ROOT_LHC4CODEC_GIT_REPOSITORY "https://gitlab.cern.ch/apeters/lhc4codec.git") | ||
| set(ROOT_LHC4CODEC_GIT_TAG "c433157729d96b4e15cd29971d9f88a25eb43496") | ||
|
|
||
| set(_lhc4codec_build_args | ||
| -DLHC4CODEC_BUILD_CLI=OFF | ||
| -DLHC4CODEC_BUILD_TESTS=OFF | ||
| -DLHC4CODEC_METAL=OFF | ||
| -DLHC4CODEC_HIP=OFF | ||
| -DLHC4CODEC_NATIVE=OFF | ||
| -DLHC4CODEC_LTO=OFF | ||
| -DLHC4CODEC_ZSTD=AUTO | ||
| -DLHC4CODEC_LZMA=AUTO | ||
| -DLHC4CODEC_BZIP3=BUNDLED | ||
| -DCMAKE_CXX_STANDARD=20 | ||
| -DCMAKE_POSITION_INDEPENDENT_CODE=ON | ||
| ) | ||
|
|
||
| if(LHC4CODEC_SOURCE_DIR) | ||
| if(NOT EXISTS "${LHC4CODEC_SOURCE_DIR}/CMakeLists.txt") | ||
| message(FATAL_ERROR "LHC4CODEC_SOURCE_DIR=\"${LHC4CODEC_SOURCE_DIR}\" does not contain a CMake project") | ||
| endif() | ||
|
|
||
| message(STATUS "Building builtin lhc4codec from ${LHC4CODEC_SOURCE_DIR}") | ||
|
|
||
| set(LHC4CODEC_BUILD_CLI OFF CACHE BOOL "" FORCE) | ||
| set(LHC4CODEC_BUILD_TESTS OFF CACHE BOOL "" FORCE) | ||
| set(LHC4CODEC_METAL OFF CACHE BOOL "" FORCE) | ||
| set(LHC4CODEC_HIP OFF CACHE BOOL "" FORCE) | ||
| set(LHC4CODEC_NATIVE OFF CACHE BOOL "" FORCE) | ||
| set(LHC4CODEC_LTO OFF CACHE BOOL "" FORCE) | ||
| set(LHC4CODEC_ZSTD AUTO CACHE STRING "" FORCE) | ||
| set(LHC4CODEC_LZMA AUTO CACHE STRING "" FORCE) | ||
| set(LHC4CODEC_BZIP3 BUNDLED CACHE STRING "" FORCE) | ||
| set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
|
||
| add_subdirectory(${LHC4CODEC_SOURCE_DIR} ${CMAKE_BINARY_DIR}/builtins/lhc4codec-build EXCLUDE_FROM_ALL) | ||
|
|
||
| set(LHC4CODEC_INCLUDE_DIRS ${LHC4CODEC_SOURCE_DIR}/include) | ||
| set(LHC4CODEC_LIBRARIES lhc4codec_static) | ||
|
|
||
| if(NOT TARGET LHC4CODEC::LHC4CODEC) | ||
| add_library(LHC4CODEC::LHC4CODEC ALIAS lhc4codec_static) | ||
| endif() | ||
| else() | ||
| message(STATUS "Downloading and building lhc4codec ${ROOT_LHC4CODEC_VERSION} from " | ||
| "${ROOT_LHC4CODEC_GIT_REPOSITORY} (${ROOT_LHC4CODEC_GIT_TAG})") | ||
|
|
||
| set(ROOT_LHC4CODEC_PREFIX ${CMAKE_BINARY_DIR}/builtins/lhc4codec-prefix) | ||
| set(ROOT_LHC4CODEC_SOURCE_DIR ${ROOT_LHC4CODEC_PREFIX}/src/BUILTIN_LHC4CODEC) | ||
| set(ROOT_LHC4CODEC_BUILD_DIR ${ROOT_LHC4CODEC_PREFIX}/src/BUILTIN_LHC4CODEC-build) | ||
| # Staged headers live outside the git tree so the path exists at configure time | ||
| # (CMake validates INTERFACE_INCLUDE_DIRECTORIES on imported targets). | ||
| set(ROOT_LHC4CODEC_INCLUDE_DIR ${ROOT_LHC4CODEC_PREFIX}/include) | ||
| set(ROOT_LHC4CODEC_LIBRARY | ||
| ${ROOT_LHC4CODEC_BUILD_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lhc4codec${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
| set(ROOT_LHC4CODEC_BZIP3_LIBRARY | ||
| ${ROOT_LHC4CODEC_BUILD_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lhc4_bzip3_bundled${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
| file(MAKE_DIRECTORY ${ROOT_LHC4CODEC_INCLUDE_DIR}) | ||
|
|
||
| if(MSVC) | ||
| set(_lhc4codec_build_type Release) | ||
| if(winrtdebug) | ||
| set(_lhc4codec_build_type Debug) | ||
| endif() | ||
| if(NOT CMAKE_GENERATOR MATCHES Ninja) | ||
| set(_lhc4codec_build_flags --config ${_lhc4codec_build_type}) | ||
| endif() | ||
| set(_lhc4codec_extra_cmake_args | ||
| -DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} | ||
| -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} | ||
| -DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}) | ||
| else() | ||
| set(_lhc4codec_build_type Release) | ||
| set(_lhc4codec_build_flags "") | ||
| set(_lhc4codec_extra_cmake_args "") | ||
| endif() | ||
|
|
||
| ExternalProject_Add( | ||
| BUILTIN_LHC4CODEC | ||
| GIT_REPOSITORY ${ROOT_LHC4CODEC_GIT_REPOSITORY} | ||
| GIT_TAG ${ROOT_LHC4CODEC_GIT_TAG} | ||
| GIT_SUBMODULES third_party/bzip3 | ||
| PREFIX ${ROOT_LHC4CODEC_PREFIX} | ||
| UPDATE_COMMAND "" | ||
| CMAKE_ARGS -G ${CMAKE_GENERATOR} | ||
| -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
| -DCMAKE_BUILD_TYPE=${_lhc4codec_build_type} | ||
| ${_lhc4codec_build_args} | ||
| ${_lhc4codec_extra_cmake_args} | ||
| BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> ${_lhc4codec_build_flags} | ||
| --target lhc4codec_static lhc4_bzip3_bundled | ||
| INSTALL_COMMAND "" | ||
| LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_OUTPUT_ON_FAILURE 1 | ||
| BUILD_BYPRODUCTS ${ROOT_LHC4CODEC_LIBRARY} ${ROOT_LHC4CODEC_BZIP3_LIBRARY} | ||
| TIMEOUT 600 | ||
| ) | ||
|
|
||
| # Copy public headers after the git clone, before the nested configure/build. | ||
| ExternalProject_Add_Step(BUILTIN_LHC4CODEC stage-headers | ||
| COMMAND ${CMAKE_COMMAND} -E rm -rf ${ROOT_LHC4CODEC_INCLUDE_DIR}/lhc4codec | ||
| COMMAND ${CMAKE_COMMAND} -E copy_directory | ||
| <SOURCE_DIR>/include/lhc4codec | ||
| ${ROOT_LHC4CODEC_INCLUDE_DIR}/lhc4codec | ||
| DEPENDEES download | ||
| DEPENDERS configure | ||
| ) | ||
|
|
||
| add_library(LHC4CODEC::LHC4CODEC IMPORTED STATIC GLOBAL) | ||
| add_dependencies(LHC4CODEC::LHC4CODEC BUILTIN_LHC4CODEC) | ||
| set_target_properties(LHC4CODEC::LHC4CODEC PROPERTIES | ||
| IMPORTED_LOCATION ${ROOT_LHC4CODEC_LIBRARY} | ||
| INTERFACE_INCLUDE_DIRECTORIES ${ROOT_LHC4CODEC_INCLUDE_DIR} | ||
| INTERFACE_LINK_LIBRARIES ${ROOT_LHC4CODEC_BZIP3_LIBRARY} | ||
| ) | ||
|
|
||
| set(LHC4CODEC_INCLUDE_DIRS ${ROOT_LHC4CODEC_INCLUDE_DIR}) | ||
| set(LHC4CODEC_LIBRARIES ${ROOT_LHC4CODEC_LIBRARY}) | ||
| endif() | ||
|
|
||
| set(LHC4CODEC_FOUND TRUE) | ||
| set(LHC4CODEC_VERSION ${ROOT_LHC4CODEC_VERSION}) | ||
|
|
||
| set(LHC4CODEC_INCLUDE_DIRS ${LHC4CODEC_INCLUDE_DIRS} PARENT_SCOPE) | ||
| set(LHC4CODEC_LIBRARIES ${LHC4CODEC_LIBRARIES} PARENT_SCOPE) | ||
| set(LHC4CODEC_FOUND ${LHC4CODEC_FOUND} PARENT_SCOPE) | ||
| set(LHC4CODEC_VERSION ${LHC4CODEC_VERSION} PARENT_SCOPE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| # Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. | ||
| # All rights reserved. | ||
| # | ||
| # For the licensing terms see $ROOTSYS/LICENSE. | ||
| # For the list of contributors see $ROOTSYS/README/CREDITS. | ||
|
|
||
| #.rst: | ||
| # FindLHC4CODEC | ||
| # ------------- | ||
| # | ||
| # Find the lhc4codec library header and define variables. | ||
| # | ||
| # Imported Targets | ||
| # ^^^^^^^^^^^^^^^^ | ||
| # | ||
| # This module defines :prop_tgt:`IMPORTED` target ``LHC4CODEC::LHC4CODEC``, | ||
| # if lhc4codec has been found. | ||
| # | ||
| # Result Variables | ||
| # ^^^^^^^^^^^^^^^^ | ||
| # | ||
| # This module defines the following variables: | ||
| # | ||
| # :: | ||
| # | ||
| # LHC4CODEC_FOUND - True if lhc4codec is found. | ||
| # LHC4CODEC_INCLUDE_DIRS - Where to find lhc4codec/lhc4codec_c.h | ||
| # LHC4CODEC_LIBRARIES - The lhc4codec library path | ||
| # LHC4CODEC_VERSION - The lhc4codec version string, if available | ||
| # LHC4CODEC_INSTALL_HELP - How to install a missing package (always set) | ||
|
|
||
| # Prebuilt packages: https://gitlab.cern.ch/apeters/lhc4codec-bin | ||
| set(LHC4CODEC_INSTALL_HELP [=[ | ||
| lhc4codec was not found (need lhc4codec/lhc4codec_c.h and liblhc4codec). | ||
|
|
||
| Install a prebuilt package from https://gitlab.cern.ch/apeters/lhc4codec-bin : | ||
|
|
||
| # AlmaLinux 9 / 10 (x86_64) | ||
| sudo curl -fsSL -o /etc/yum.repos.d/lhc4codec.repo \ | ||
| https://gitlab.cern.ch/apeters/lhc4codec-bin/-/raw/master/lhc4codec-el9.repo # or -el10 | ||
| sudo dnf install lhc4codec lhc4codec-devel | ||
|
|
||
| # macOS, Apple silicon (macOS 13+) | ||
| brew tap apeters/lhc4codec https://gitlab.cern.ch/apeters/lhc4codec-bin.git | ||
| brew install apeters/lhc4codec/lhc4codec | ||
|
|
||
| Or point CMake at an existing prefix: -DLHC4CODEC_ROOT=/path/to/prefix | ||
| Or let ROOT clone and build it: -Dbuiltin_lhc4codec=ON | ||
| (fetches https://gitlab.cern.ch/apeters/lhc4codec.git) | ||
| ]=]) | ||
|
|
||
| set(_lhc4codec_hints) | ||
| if(LHC4CODEC_ROOT) | ||
| list(APPEND _lhc4codec_hints "${LHC4CODEC_ROOT}") | ||
| endif() | ||
| if(DEFINED ENV{LHC4CODEC_ROOT}) | ||
| list(APPEND _lhc4codec_hints "$ENV{LHC4CODEC_ROOT}") | ||
| endif() | ||
|
|
||
| if(APPLE) | ||
| # Homebrew: arm64 default is /opt/homebrew, Intel is /usr/local. | ||
| list(APPEND _lhc4codec_hints /opt/homebrew /usr/local) | ||
| find_program(_lhc4codec_brew brew) | ||
| if(_lhc4codec_brew) | ||
| execute_process(COMMAND "${_lhc4codec_brew}" --prefix lhc4codec | ||
| OUTPUT_VARIABLE _lhc4codec_brew_formula | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET) | ||
| if(_lhc4codec_brew_formula) | ||
| list(APPEND _lhc4codec_hints "${_lhc4codec_brew_formula}") | ||
| endif() | ||
| execute_process(COMMAND "${_lhc4codec_brew}" --prefix | ||
| OUTPUT_VARIABLE _lhc4codec_brew_prefix | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET) | ||
| if(_lhc4codec_brew_prefix) | ||
| list(APPEND _lhc4codec_hints "${_lhc4codec_brew_prefix}") | ||
| endif() | ||
| endif() | ||
| unset(_lhc4codec_brew CACHE) | ||
| endif() | ||
|
|
||
| find_path(LHC4CODEC_INCLUDE_DIR lhc4codec/lhc4codec_c.h | ||
| HINTS ${_lhc4codec_hints} | ||
| PATH_SUFFIXES include | ||
| ) | ||
|
|
||
| find_library(LHC4CODEC_LIBRARY | ||
| NAMES lhc4codec lhc4codec_static | ||
| HINTS ${_lhc4codec_hints} | ||
| PATH_SUFFIXES lib lib64 | ||
| ) | ||
|
|
||
| if(LHC4CODEC_INCLUDE_DIR AND EXISTS "${LHC4CODEC_INCLUDE_DIR}/lhc4codec/lhc4codec_c.h") | ||
| file(READ "${LHC4CODEC_INCLUDE_DIR}/lhc4codec/lhc4codec_c.h" _lhc4codec_header) | ||
| string(REGEX MATCH "#define LHC4CODEC_VERSION \"([^\"]+)\"" _lhc4codec_version_match "${_lhc4codec_header}") | ||
| if(CMAKE_MATCH_1) | ||
| set(LHC4CODEC_VERSION "${CMAKE_MATCH_1}") | ||
| endif() | ||
| unset(_lhc4codec_header) | ||
| unset(_lhc4codec_version_match) | ||
| endif() | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(LHC4CODEC | ||
| REQUIRED_VARS LHC4CODEC_LIBRARY LHC4CODEC_INCLUDE_DIR | ||
| VERSION_VAR LHC4CODEC_VERSION | ||
| ) | ||
|
|
||
| if(LHC4CODEC_FOUND) | ||
| set(LHC4CODEC_INCLUDE_DIRS "${LHC4CODEC_INCLUDE_DIR}") | ||
| set(LHC4CODEC_LIBRARIES "${LHC4CODEC_LIBRARY}") | ||
|
|
||
| if(NOT TARGET LHC4CODEC::LHC4CODEC) | ||
| add_library(LHC4CODEC::LHC4CODEC UNKNOWN IMPORTED) | ||
| set_target_properties(LHC4CODEC::LHC4CODEC PROPERTIES | ||
| IMPORTED_LOCATION "${LHC4CODEC_LIBRARIES}" | ||
| INTERFACE_INCLUDE_DIRECTORIES "${LHC4CODEC_INCLUDE_DIRS}") | ||
| endif() | ||
| endif() | ||
|
|
||
| unset(_lhc4codec_hints) | ||
| unset(_lhc4codec_brew_formula) | ||
| unset(_lhc4codec_brew_prefix) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,4 +65,6 @@ | |
|
|
||
| #@hasgeom@ R__HAS_GEOM /**/ | ||
|
|
||
| #@haslhc4codec@ R__HAS_LHC4CODEC /**/ | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| ############################################################################ | ||
| # CMakeLists.txt file for building ROOT core/lhc4codec package | ||
| ############################################################################ | ||
|
|
||
| add_library(ROOTLHC4Zip OBJECT src/ZipLHC4.cxx) | ||
| set_target_properties(ROOTLHC4Zip PROPERTIES | ||
| CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF | ||
| POSITION_INDEPENDENT_CODE ON) | ||
| target_link_libraries(ROOTLHC4Zip PRIVATE LHC4CODEC::LHC4CODEC) | ||
| target_include_directories(ROOTLHC4Zip | ||
| PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc> | ||
| ) | ||
| # Compile with -DR__LHC4_FAILURE_DUMP (or uncomment below) to write failed | ||
| # zip/unzip frames under /tmp/root-lhc4-failure-<pid>/. | ||
| # target_compile_definitions(ROOTLHC4Zip PRIVATE R__LHC4_FAILURE_DUMP) | ||
|
|
||
| target_sources(Core PRIVATE $<TARGET_OBJECTS:ROOTLHC4Zip>) | ||
|
|
||
| target_link_libraries(Core PRIVATE LHC4CODEC::LHC4CODEC) | ||
|
|
||
| # Bundled bzip3 is a separate static lib in the lhc4codec build; propagate it when | ||
| # built via add_subdirectory (ExternalProject uses INTERFACE_LINK_LIBRARIES). | ||
| if(TARGET lhc4_bzip3_bundled) | ||
| target_link_libraries(Core PRIVATE lhc4_bzip3_bundled) | ||
| endif() | ||
|
|
||
| target_include_directories(Core PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>) | ||
|
|
||
| ROOT_INSTALL_HEADERS() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.