From 88a8b4ae9a5cfa5779498e591cca796345f1635f Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 15 Dec 2023 20:55:02 -0500 Subject: [PATCH 1/4] fixing issue with broken tests. --- .github/workflows/alpine.yml | 2 +- .github/workflows/macos-ci.yml | 6 +++--- .github/workflows/s390x.yml | 2 +- .github/workflows/ubuntu-ci.yml | 4 ++-- .github/workflows/ubuntu-debug-sani-ci.yml | 2 +- .github/workflows/ubuntu-gcc10-ci.yml | 4 ++-- .github/workflows/ubuntu-legacy-ci.yml | 4 ++-- .github/workflows/ubuntu-noexcept-ci.yml | 2 +- .github/workflows/ubuntu-sani-ci.yml | 2 +- .github/workflows/ubuntu-sani-thread-ci.yml | 2 +- .github/workflows/vs16-ci.yml | 2 +- .github/workflows/vs17-ci.yml | 2 +- .github/workflows/vs17-clang-ci.yml | 2 +- CMakeLists.txt | 7 +++++-- README.md | 6 +++--- 15 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index 91bd366f1..8d1489509 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -20,7 +20,7 @@ jobs: ./alpine.sh apk add build-base cmake g++ linux-headers git bash - name: cmake run: | - ./alpine.sh cmake -B build_for_alpine + ./alpine.sh cmake -DENABLE_ROARING_TESTS=ON -B build_for_alpine - name: build run: | ./alpine.sh cmake --build build_for_alpine diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index 456383098..74ad15743 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -17,14 +17,14 @@ jobs: run: | mkdir build cd build - cmake -DCMAKE_INSTALL_PREFIX:PATH=destination .. + cmake -DCMAKE_INSTALL_PREFIX:PATH=destination -DENABLE_ROARING_TESTS=ON .. cmake --build . ctest . --output-on-failure cmake --install . cd ../tests/installation/find && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . - name: Build and Test (shared) run: | - cmake -DBUILD_SHARED_LIBS=ON -B buildshared -DCMAKE_INSTALL_PREFIX:PATH=destinationshared + cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX:PATH=destinationshared -DENABLE_ROARING_TESTS=ON -B buildshared cmake --build buildshared cmake --install buildshared cd tests/installation/find @@ -35,7 +35,7 @@ jobs: run: | mkdir builddebug cd builddebug - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=destination .. + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=destination -DENABLE_ROARING_TESTS=ON .. cmake --build . ctest . --output-on-failure cmake --install . diff --git a/.github/workflows/s390x.yml b/.github/workflows/s390x.yml index 6dd984500..42bb63e91 100644 --- a/.github/workflows/s390x.yml +++ b/.github/workflows/s390x.yml @@ -27,7 +27,7 @@ jobs: apt-get update -q -y apt-get install -y cmake make g++ run: | - cmake -DCMAKE_BUILD_TYPE=Release -B build + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_ROARING_TESTS=ON -B build cmake --build build -j=2 ctest --output-on-failure --test-dir build diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml index a5ea0f170..0fb5d99a4 100644 --- a/.github/workflows/ubuntu-ci.yml +++ b/.github/workflows/ubuntu-ci.yml @@ -22,7 +22,7 @@ jobs: run: | mkdir build cd build - cmake -DCMAKE_INSTALL_PREFIX:PATH=destination .. + cmake -DCMAKE_INSTALL_PREFIX:PATH=destination -DENABLE_ROARING_TESTS=ON .. cmake --build . ctest . --output-on-failure cmake --install . @@ -31,7 +31,7 @@ jobs: run: | mkdir builddebug cd builddebug - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=destination .. + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=destination -DENABLE_ROARING_TESTS=ON .. cmake --build . ctest . --output-on-failure cmake --install . diff --git a/.github/workflows/ubuntu-debug-sani-ci.yml b/.github/workflows/ubuntu-debug-sani-ci.yml index c3508d504..59edf4ef6 100644 --- a/.github/workflows/ubuntu-debug-sani-ci.yml +++ b/.github/workflows/ubuntu-debug-sani-ci.yml @@ -22,6 +22,6 @@ jobs: run: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=Debug -DROARING_SANITIZE=ON .. + cmake -DCMAKE_BUILD_TYPE=Debug -DROARING_SANITIZE=ON -DENABLE_ROARING_TESTS=ON .. cmake --build . ctest . --output-on-failure diff --git a/.github/workflows/ubuntu-gcc10-ci.yml b/.github/workflows/ubuntu-gcc10-ci.yml index 6d0bc1e1d..d40c41482 100644 --- a/.github/workflows/ubuntu-gcc10-ci.yml +++ b/.github/workflows/ubuntu-gcc10-ci.yml @@ -24,6 +24,6 @@ jobs: run: | mkdir build cd build - cmake .. - cmake --build . + cmake -DENABLE_ROARING_TESTS=ON .. + cmake --build . ctest . --output-on-failure diff --git a/.github/workflows/ubuntu-legacy-ci.yml b/.github/workflows/ubuntu-legacy-ci.yml index a083db2d5..6e0cc728a 100644 --- a/.github/workflows/ubuntu-legacy-ci.yml +++ b/.github/workflows/ubuntu-legacy-ci.yml @@ -18,8 +18,8 @@ jobs: run: | mkdir build cd build - cmake -DROARING_DISABLE_AVX=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. - cmake --build . + cmake -DROARING_DISABLE_AVX=ON -DCMAKE_INSTALL_PREFIX:PATH=destination -DENABLE_ROARING_TESTS=ON .. + cmake --build ctest . --output-on-failure cmake --install . cd ../tests/installation/find && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . diff --git a/.github/workflows/ubuntu-noexcept-ci.yml b/.github/workflows/ubuntu-noexcept-ci.yml index 64654b269..b486eaf08 100644 --- a/.github/workflows/ubuntu-noexcept-ci.yml +++ b/.github/workflows/ubuntu-noexcept-ci.yml @@ -22,6 +22,6 @@ jobs: run: | mkdir build cd build - cmake -DCMAKE_CXX_FLAGS=-fno-exceptions -DROARING_EXCEPTIONS=OFF .. + cmake -DCMAKE_CXX_FLAGS=-fno-exceptions -DROARING_EXCEPTIONS=OFF -DENABLE_ROARING_TESTS=ON .. cmake --build . ctest . --output-on-failure diff --git a/.github/workflows/ubuntu-sani-ci.yml b/.github/workflows/ubuntu-sani-ci.yml index 78d28e851..cba863e19 100644 --- a/.github/workflows/ubuntu-sani-ci.yml +++ b/.github/workflows/ubuntu-sani-ci.yml @@ -22,6 +22,6 @@ jobs: run: | mkdir build cd build - cmake -DROARING_SANITIZE=ON .. + cmake -DROARING_SANITIZE=ON -DENABLE_ROARING_TESTS=ON .. cmake --build . ctest . --output-on-failure diff --git a/.github/workflows/ubuntu-sani-thread-ci.yml b/.github/workflows/ubuntu-sani-thread-ci.yml index d5b505e09..a61afc4c8 100644 --- a/.github/workflows/ubuntu-sani-thread-ci.yml +++ b/.github/workflows/ubuntu-sani-thread-ci.yml @@ -22,6 +22,6 @@ jobs: run: | mkdir build cd build - cmake -DROARING_SANITIZE_THREADS=ON .. + cmake -DROARING_SANITIZE_THREADS=ON -DENABLE_ROARING_TESTS=ON .. cmake --build . ctest . --output-on-failure diff --git a/.github/workflows/vs16-ci.yml b/.github/workflows/vs16-ci.yml index 30609ec09..33b1cdfc8 100644 --- a/.github/workflows/vs16-ci.yml +++ b/.github/workflows/vs16-ci.yml @@ -21,7 +21,7 @@ jobs: - name: Configure run: | mkdir build - cd build && cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} .. + cd build && cmake -DENABLE_ROARING_TESTS=ON -G "${{matrix.gen}}" -A ${{matrix.arch}} .. - name: Build run: cmake --build build --config Release - name: Run basic tests diff --git a/.github/workflows/vs17-ci.yml b/.github/workflows/vs17-ci.yml index 6c58cca80..7f088534c 100644 --- a/.github/workflows/vs17-ci.yml +++ b/.github/workflows/vs17-ci.yml @@ -21,7 +21,7 @@ jobs: - name: Configure run: | mkdir build - cd build && cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} .. + cd build && cmake -DENABLE_ROARING_TESTS=ON -G "${{matrix.gen}}" -A ${{matrix.arch}} .. - name: Build run: cmake --build build --config Release - name: Run basic tests diff --git a/.github/workflows/vs17-clang-ci.yml b/.github/workflows/vs17-clang-ci.yml index 108af5129..6a545a351 100644 --- a/.github/workflows/vs17-clang-ci.yml +++ b/.github/workflows/vs17-clang-ci.yml @@ -21,7 +21,7 @@ jobs: - name: Configure run: | mkdir build - cd build && cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -T ClangCL .. + cd build && cmake -DENABLE_ROARING_TESTS=ON -G "${{matrix.gen}}" -A ${{matrix.arch}} -T ClangCL .. - name: Build run: cmake --build build --config Release --parallel - name: Run basic tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bdd478bd..0980e6366 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,14 +45,17 @@ option(ROARING_BUILD_C_TESTS_AS_CPP "Build test C files using C++ compilation" O option(ROARING_SANITIZE "Sanitize addresses" OFF) option(ROARING_SANITIZE_THREADS "Sanitize threads" OFF) -option(ENABLE_ROARING_TESTS "If OFF, disable unit tests altogether" ${BUILD_TESTING}) +option(ENABLE_ROARING_TESTS "If OFF, disable unit tests altogether" ON) +if(NOT ENABLE_ROARING_TESTS) + message(STATUS "Tests are disabled, you can enabled them by setting ENABLE_ROARING_TESTS to ON") +endif() set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake") +include(cmake/CPM.cmake) find_package(CTargets) find_package(Options) find_package(LTO) -include(cmake/CPM.cmake) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/roaring.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/roaring.pc" @ONLY) diff --git a/README.md b/README.md index bf964aff6..7d22913ff 100644 --- a/README.md +++ b/README.md @@ -82,9 +82,9 @@ Linux or macOS users might follow the following instructions if they have a rece 1. Pull the library in a directory ``` - wget https://github.com/RoaringBitmap/CRoaring/releases/download/v2.0.3/roaring.c - wget https://github.com/RoaringBitmap/CRoaring/releases/download/v2.0.3/roaring.h - wget https://github.com/RoaringBitmap/CRoaring/releases/download/v2.0.3/roaring.hh + wget https://github.com/RoaringBitmap/CRoaring/releases/download/v2.0.4/roaring.c + wget https://github.com/RoaringBitmap/CRoaring/releases/download/v2.0.4/roaring.h + wget https://github.com/RoaringBitmap/CRoaring/releases/download/v2.0.4/roaring.hh ``` 2. Create a new file named `demo.c` with this content: ```C From dcf8408e735b342c15fc705fae7f850a62919fd9 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 15 Dec 2023 21:01:46 -0500 Subject: [PATCH 2/4] fixing typo --- .github/workflows/ubuntu-ci.yml | 4 ++-- .github/workflows/ubuntu-legacy-ci.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ubuntu-ci.yml b/.github/workflows/ubuntu-ci.yml index 0fb5d99a4..07267e285 100644 --- a/.github/workflows/ubuntu-ci.yml +++ b/.github/workflows/ubuntu-ci.yml @@ -23,7 +23,7 @@ jobs: mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX:PATH=destination -DENABLE_ROARING_TESTS=ON .. - cmake --build . + cmake --build . ctest . --output-on-failure cmake --install . cd ../tests/installation/find && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . @@ -32,7 +32,7 @@ jobs: mkdir builddebug cd builddebug cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=destination -DENABLE_ROARING_TESTS=ON .. - cmake --build . + cmake --build . ctest . --output-on-failure cmake --install . cd ../tests/installation/find && mkdir builddebug && cd builddebug && cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . diff --git a/.github/workflows/ubuntu-legacy-ci.yml b/.github/workflows/ubuntu-legacy-ci.yml index 6e0cc728a..61ae771ef 100644 --- a/.github/workflows/ubuntu-legacy-ci.yml +++ b/.github/workflows/ubuntu-legacy-ci.yml @@ -1,4 +1,4 @@ -name: Ubuntu-CI +name: Ubuntu-Legacy-CI 'on': - push @@ -19,7 +19,7 @@ jobs: mkdir build cd build cmake -DROARING_DISABLE_AVX=ON -DCMAKE_INSTALL_PREFIX:PATH=destination -DENABLE_ROARING_TESTS=ON .. - cmake --build + cmake --build . ctest . --output-on-failure cmake --install . cd ../tests/installation/find && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . From c6e7c37b90ea5433db6a8b82cd5f5cbf2990e2c4 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 15 Dec 2023 21:23:34 -0500 Subject: [PATCH 3/4] Making these functions inline. --- include/roaring/portability.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/roaring/portability.h b/include/roaring/portability.h index fba2a4b25..9e51f2bf9 100644 --- a/include/roaring/portability.h +++ b/include/roaring/portability.h @@ -225,8 +225,8 @@ inline int roaring_leading_zeroes(unsigned long long input_num) { #ifndef CROARING_INTRINSICS #define CROARING_INTRINSICS 1 #define roaring_unreachable __builtin_unreachable() -static inline int roaring_trailing_zeroes(unsigned long long input_num) { return __builtin_ctzll(input_num); } -static inline int roaring_leading_zeroes(unsigned long long input_num) { return __builtin_clzll(input_num); } +inline int roaring_trailing_zeroes(unsigned long long input_num) { return __builtin_ctzll(input_num); } +inline int roaring_leading_zeroes(unsigned long long input_num) { return __builtin_clzll(input_num); } #endif #if CROARING_REGULAR_VISUAL_STUDIO From 7e655f701b6e9c0193b1bb864a3a84f10a2551cf Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 15 Dec 2023 21:33:24 -0500 Subject: [PATCH 4/4] adding missing extern --- src/roaring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/roaring.c b/src/roaring.c index 2b77bc126..0211eced7 100644 --- a/src/roaring.c +++ b/src/roaring.c @@ -20,7 +20,8 @@ extern "C" { namespace roaring { namespace api { #define CROARING_SERIALIZATION_ARRAY_UINT32 1 #define CROARING_SERIALIZATION_CONTAINER 2 - +extern inline int roaring_trailing_zeroes(unsigned long long input_num); +extern inline int roaring_leading_zeroes(unsigned long long input_num); extern inline void roaring_bitmap_init_cleared(roaring_bitmap_t *r); extern inline bool roaring_bitmap_get_copy_on_write(const roaring_bitmap_t* r); extern inline void roaring_bitmap_set_copy_on_write(roaring_bitmap_t* r, bool cow);