build(thirdparty): replace CRoaring submodule with amalgamation (~292M -> ~1MB) (#381)

This commit is contained in:
luoxiaojian 2026-05-12 14:55:08 +08:00 committed by GitHub
parent ee40e5e0b7
commit 269c611f78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 30069 additions and 22 deletions

3
.gitmodules vendored
View File

@ -19,9 +19,6 @@
path = thirdparty/arrow/apache-arrow-21.0.0
url = https://github.com/apache/arrow.git
ignore = all
[submodule "thirdparty/CRoaring/CRoaring-2.0.4"]
path = thirdparty/CRoaring/CRoaring-2.0.4
url = https://github.com/RoaringBitmap/CRoaring.git
[submodule "thirdparty/glog/glog-0.5.0"]
path = thirdparty/glog/glog-0.5.0
url = https://github.com/google/glog.git

View File

@ -1,24 +1,62 @@
set(ENABLE_ROARING_TESTS OFF CACHE BOOL "Disable testing in CRoaring" FORCE)
if(MSVC)
set(ROARING_BUILD_STATIC ON CACHE BOOL "" FORCE)
endif()
# CRoaring v2.0.4 - integrated as a single-file amalgamation build.
#
# We deliberately do NOT pull the upstream repository as a git submodule
# anymore: it ships ~292M of benchmarks/test data that we never build, which
# made `git submodule update --init --recursive` painfully slow and bloated
# the local checkout.
#
# Instead, the official amalgamation produced by CRoaring's release pipeline
# (https://github.com/RoaringBitmap/CRoaring/releases/tag/v2.0.4) is checked
# into CRoaring-2.0.4/:
#
# CRoaring-2.0.4/roaring.c - single C TU containing the entire library
# CRoaring-2.0.4/roaring.h - public C API (from official release)
# CRoaring-2.0.4/roaring.hh - public C++ wrapper (from official release)
# CRoaring-2.0.4/roaring64map.hh - 64-bit C++ wrapper (from cpp/ in tarball)
# CRoaring-2.0.4/include/roaring/roaring.h
# - identical to roaring.h, exposed under the
# historical <roaring/roaring.h> path so
# existing callers keep working.
#
# To upgrade, replace these files with the assets from a newer release tag
# (and grab cpp/roaring64map.hh from the source tarball if it is still split).
set(_ROARING_AMAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CRoaring-2.0.4)
set(_SAVED_CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_DIR})
add_subdirectory(CRoaring-2.0.4)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${_SAVED_CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
unset(_SAVED_CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
add_library(roaring STATIC ${_ROARING_AMAL_DIR}/roaring.c)
set_target_properties(roaring PROPERTIES
POSITION_INDEPENDENT_CODE ON
ARCHIVE_OUTPUT_DIRECTORY ${EXTERNAL_LIB_DIR}
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(roaring PRIVATE
-Wno-unused-parameter
# Two include roots:
# - CRoaring-2.0.4/ -> <roaring.h>, <roaring.hh>, <roaring64map.hh>
# - CRoaring-2.0.4/include/ -> <roaring/roaring.h> (legacy path used in code)
target_include_directories(roaring PUBLIC
$<BUILD_INTERFACE:${_ROARING_AMAL_DIR}>
$<BUILD_INTERFACE:${_ROARING_AMAL_DIR}/include>
)
# The amalgamation is plain C11; the C++ wrappers in roaring.hh require C++11+.
target_compile_features(roaring PUBLIC c_std_11)
# Silence warnings that come from the third-party amalgamation itself; we do
# not want them polluting our build.
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang"
OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(roaring PRIVATE
-Wno-unused-parameter
-Wno-unused-but-set-variable
-Wno-unused-function
)
endif()
get_target_property(roaring_SOURCE_DIR roaring INTERFACE_SOURCE_DIR)
set(ROARING_FOUND TRUE PARENT_SCOPE)
set(ROARING_INCLUDE_DIR ${roaring_SOURCE_DIR}/include PARENT_SCOPE)
set(ROARING_INCLUDE_DIRS ${roaring_SOURCE_DIR}/include PARENT_SCOPE)
set(ROARING_LIBRARY $<TARGET_FILE:roaring> PARENT_SCOPE)
set(ROARING_LIBRARIES $<TARGET_FILE:roaring> PARENT_SCOPE)
# Preserve the legacy ROARING_* variables so any consumer that still reads
# them (instead of linking the `roaring` target directly) keeps working.
set(ROARING_FOUND TRUE PARENT_SCOPE)
set(ROARING_INCLUDE_DIR ${_ROARING_AMAL_DIR} PARENT_SCOPE)
set(ROARING_INCLUDE_DIRS ${_ROARING_AMAL_DIR}
${_ROARING_AMAL_DIR}/include PARENT_SCOPE)
set(ROARING_LIBRARY $<TARGET_FILE:roaring> PARENT_SCOPE)
set(ROARING_LIBRARIES $<TARGET_FILE:roaring> PARENT_SCOPE)
unset(_ROARING_AMAL_DIR)

@ -1 +0,0 @@
Subproject commit 0a5c300a7a0391e5ec75465332ac7728e18b677f

View File

@ -0,0 +1,48 @@
The CRoaring project is under a dual license (Apache/MIT).
Users of the library may choose one or the other license.
=======================================================================
Apache License, Version 2.0
=======================================================================
Copyright 2016-2022 The CRoaring 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.
SPDX-License-Identifier: Apache-2.0
=======================================================================
MIT License
=======================================================================
Copyright 2016-2022 The CRoaring authors
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
SPDX-License-Identifier: MIT

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff