Skip to content
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

Create an example of including UnoDB as a CMake subdirectory #633

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 104 additions & 55 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
---
version: 2.1

parameters:
GCC_VERSION:
type: string
default: "14"
CLANG_VERSION:
type: string
default: "19"

jobs:
build-linux:
parameters:
Expand All @@ -19,36 +27,38 @@ jobs:
ubsan:
type: boolean
default: false
environment:
GCC_VERSION: << pipeline.parameters.GCC_VERSION >>
CLANG_VERSION: << pipeline.parameters.CLANG_VERSION >>
machine:
image: ubuntu-2404:2024.11.1
resource_class: arm.medium
steps:
- checkout
- run:
name: Checkout submodules
command: git submodule update --init
- run:
name: Installing dependencies (common)
command: |
sudo apt-get update
sudo apt-get install -y libboost-dev
sudo apt-get install -y libboost-dev libgtest-dev libgmock-dev \
libbenchmark-dev valgrind
- when:
condition:
equal: ["gcc", << parameters.compiler >>]
steps:
- run:
name: Installing dependencies (GCC)
command: |
sudo apt-get install -y g++-14
sudo apt-get install -y g++-${GCC_VERSION}
- when:
condition:
equal: ["clang", << parameters.compiler >>]
steps:
- run:
name: Installing dependencies (LLVM common)
command: |
sudo apt-get install -y clang-19 clang-tidy-19 iwyu \
libstdc++-14-dev
sudo apt-get install -y clang-${CLANG_VERSION} \
clang-tidy-${CLANG_VERSION} iwyu \
libstdc++-${GCC_VERSION}-dev
- when:
condition:
and:
Expand All @@ -58,7 +68,8 @@ jobs:
- run:
name: Installing dependencies (LLVM Release)
command: |
sudo apt-get install -y libomp5-19 llvm-19 lld-19
sudo apt-get install -y libomp5-${CLANG_VERSION} \
llvm-${CLANG_VERSION} lld-${CLANG_VERSION}
- when:
condition:
<< parameters.tsan >>
Expand All @@ -69,37 +80,66 @@ jobs:
# https://github.com/google/sanitizers/issues/1716 has
# propagated everywhere
command: sudo sysctl vm.mmap_rnd_bits=28
- when:
condition:
not:
or:
- << parameters.asan >>
- << parameters.tsan >>
- << parameters.ubsan >>
steps:
- run:
name: Configure CMake (examples)
command: |
readonly BUILD_TYPE=<< parameters.build_type >>
readonly COMPILER=<< parameters.compiler >>
if [[ $COMPILER == "gcc" ]]; then
export CC=gcc-$GCC_VERSION
export CXX=g++-$GCC_VERSION
elif [[ $COMPILER == "clang" ]]; then
export CC=clang-$CLANG_VERSION
export CXX=clang++-$CLANG_VERSION
fi
cmake -S examples -B build-examples \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
- run:
name: Examples
working_directory: build-examples
command: make -j2 -k examples
- run:
name: Valgrind examples
working_directory: build-examples
command: make -k valgrind_examples
- run:
name: Create build environment
command: mkdir build
name: Checkout submodules
command: git submodule update --init
- run:
name: Configure CMake
working_directory: build
command: |
mkdir build
cd build
readonly BUILD_TYPE=<< parameters.build_type >>
readonly COMPILER=<< parameters.compiler >>
readonly ASAN=<< parameters.asan >>
readonly TSAN=<< parameters.tsan >>
readonly UBSAN=<< parameters.ubsan >>
if [[ $COMPILER == "gcc" ]]; then
V=14
export CC=gcc-$V
export CXX=g++-$V
export CC=gcc-$GCC_VERSION
export CXX=g++-$GCC_VERSION
EXTRA_CMAKE_ARGS=()
elif [[ $COMPILER == "clang" ]]; then
V=19
export CC=clang-$V
export CXX=clang++-$V
export CC=clang-$CLANG_VERSION
export CXX=clang++-$CLANG_VERSION
if [[ $BUILD_TYPE == "Release" ]]; then
EXTRA_CMAKE_ARGS=(\
"-DLLVMAR_EXECUTABLE=/usr/bin/llvm-ar-$V" \
"-DLLVMNM_EXECUTABLE=/usr/bin/llvm-nm-$V" \
"-DLLVMRANLIB_EXECUTABLE=/usr/bin/llvm-ranlib-$V")
"-DLLVMAR_EXECUTABLE=/usr/bin/llvm-ar-$CLANG_VERSION" \
"-DLLVMNM_EXECUTABLE=/usr/bin/llvm-nm-$CLANG_VERSION" \
"-DLLVMRANLIB_EXECUTABLE=/usr/bin/llvm-ranlib-$CLANG_VERSION")
else
EXTRA_CMAKE_ARGS=()
fi
EXTRA_CMAKE_ARGS=("${EXTRA_CMAKE_ARGS[@]}" \
"-DCLANG_TIDY_EXE=/usr/bin/clang-tidy-$V")
"-DCLANG_TIDY_EXE=/usr/bin/clang-tidy-$CLANG_VERSION")
fi
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSTANDALONE=ON \
-DMAINTAINER_MODE=ON -DSANITIZE_ADDRESS=$ASAN \
Expand All @@ -109,10 +149,6 @@ jobs:
name: Build
working_directory: build
command: make -j2 -k
- run:
name: Examples
working_directory: build
command: make -k examples
- run:
name: Correctness test
working_directory: build
Expand All @@ -139,9 +175,7 @@ jobs:
- run:
name: Valgrind test
working_directory: build
command: |
sudo NEEDRESTART_MODE=a apt-get install -y valgrind
make -k valgrind
command: make -k valgrind

build-macos:
parameters:
Expand All @@ -162,38 +196,53 @@ jobs:
resource_class: macos.m1.medium.gen1
steps:
- checkout
- run:
name: Checkout submodules
command: git submodule update --init --recursive
- run:
name: Install dependencies
command: |
sudo -H pip install setuptools
brew install boost cmake
- when:
condition:
not:
or:
- << parameters.asan >>
- << parameters.tsan >>
- << parameters.ubsan >>
steps:
- run:
name: Installing dependencies (examples)
command: brew install googletest google-benchmark
- run:
name: Configure CMake (examples)
command: |
readonly BUILD_TYPE=<< parameters.build_type >>
export CC=clang
export CXX=clang++
cmake -S examples -B build-examples \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
- run:
name: Examples
working_directory: build-examples
command: make -j3 -k examples
- run:
name: Create build environment
command: mkdir build
name: Checkout submodules
command: git submodule update --init --recursive
- run:
name: Configure CMake
working_directory: build
command: |
readonly BUILD_TYPE=<< parameters.build_type >>
readonly ASAN=<< parameters.asan >>
readonly TSAN=<< parameters.tsan >>
readonly UBSAN=<< parameters.ubsan >>
export CC=clang
export CXX=clang++
cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSTANDALONE=ON \
cmake -S . -B build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSTANDALONE=ON \
-DMAINTAINER_MODE=OFF -DSANITIZE_ADDRESS=$ASAN \
-DSANITIZE_THREAD=$TSAN -DSANITIZE_UB=$UBSAN
- run:
name: Build
working_directory: build
command: make -j3 -k
- run:
name: Examples
working_directory: build
command: make -k examples
- run:
name: Correctness test
working_directory: build
Expand All @@ -214,80 +263,80 @@ workflows:
build:
jobs:
- build-linux:
name: GCC 14 Debug
name: GCC << pipeline.parameters.GCC_VERSION >> Debug
build_type: Debug
compiler: gcc
- build-linux:
name: GCC 14 Debug with ASan
name: GCC << pipeline.parameters.GCC_VERSION >> Debug with ASan
build_type: Debug
compiler: gcc
asan: true
- build-linux:
name: GCC 14 Debug with TSan
name: GCC << pipeline.parameters.GCC_VERSION >> Debug with TSan
build_type: Debug
compiler: gcc
tsan: true
- build-linux:
name: GCC 14 Debug with UBSan
name: GCC << pipeline.parameters.GCC_VERSION >> Debug with UBSan
build_type: Debug
compiler: gcc
ubsan: true
- build-linux:
name: GCC 14 Release
name: GCC << pipeline.parameters.GCC_VERSION >> Release
build_type: Release
compiler: gcc
- build-linux:
name: GCC 14 Release with ASan
name: GCC << pipeline.parameters.GCC_VERSION >> Release with ASan
build_type: Release
compiler: gcc
asan: true
- build-linux:
name: GCC 14 Release with TSan
name: GCC << pipeline.parameters.GCC_VERSION >> Release with TSan
build_type: Release
compiler: gcc
tsan: true
- build-linux:
name: GCC 14 Release with UBSan
name: GCC << pipeline.parameters.GCC_VERSION >> Release with UBSan
build_type: Release
compiler: gcc
ubsan: true
- build-linux:
name: clang 19 Debug
name: clang << pipeline.parameters.CLANG_VERSION >> Debug
build_type: Debug
compiler: clang
- build-linux:
name: clang 19 Debug with ASan
name: clang << pipeline.parameters.CLANG_VERSION >> Debug with ASan
build_type: Debug
compiler: clang
asan: true
- build-linux:
name: clang 19 Debug with TSan
name: clang << pipeline.parameters.CLANG_VERSION >> Debug with TSan
build_type: Debug
compiler: clang
tsan: true
- build-linux:
name: clang 19 Debug with UBSan
name: clang << pipeline.parameters.CLANG_VERSION >> Debug with UBSan
build_type: Debug
compiler: clang
ubsan: true
- build-linux:
name: clang 19 Release
name: clang << pipeline.parameters.CLANG_VERSION >> Release
build_type: Release
compiler: clang
# Disabled until https://github.com/laurynas-biveinis/unodb/issues/700 is
# fixed.
# - build-linux:
# name: clang 19 Release with ASan
# name: clang << pipeline.parameters.CLANG_VERSION >> Release with ASan
# build_type: Release
# compiler: clang
# asan: true
- build-linux:
name: clang 19 Release with TSan
name: clang << pipeline.parameters.CLANG_VERSION >> Release with TSan
build_type: Release
compiler: clang
tsan: true
- build-linux:
name: clang 19 Release with UBSan
name: clang << pipeline.parameters.CLANG_VERSION >> Release with UBSan
build_type: Release
compiler: clang
ubsan: true
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
DEFAULT_COVERAGE: OFF
DEFAULT_AVX2: ON

permissions: { }
permissions: {}

jobs:
build:
Expand Down Expand Up @@ -349,14 +349,10 @@ jobs:
run: brew install cppcheck
if: runner.os == 'macOS' && env.CPPCHECK == 'ON'

- name: Create build environment
run: mkdir ${{github.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment
# variable access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
run: |
COMPILER="${COMPILER:-$DEFAULT_COMPILER}"
SANITIZE_ADDRESS="${SANITIZE_ADDRESS:-$DEFAULT_SANITIZE_ADDRESS}"
Expand Down Expand Up @@ -407,7 +403,7 @@ jobs:
export CC=clang
export CXX=clang++
fi
cmake "$GITHUB_WORKSPACE" "$CBT" -DSTANDALONE=ON \
cmake -B build "$GITHUB_WORKSPACE" "$CBT" -DSTANDALONE=ON \
-DMAINTAINER_MODE=ON -DIWYU=ON \
"-DSANITIZE_ADDRESS=${SANITIZE_ADDRESS}" \
"-DSANITIZE_THREAD=${SANITIZE_THREAD}" \
Expand All @@ -427,11 +423,6 @@ jobs:
--force-analyze-debug-code make -j3 -k;
if: env.STATIC_ANALYSIS == 'ON' && env.COMPILER == 'clang'

- name: Examples
working-directory: ${{github.workspace}}/build
run: make -k examples
if: env.STATIC_ANALYSIS != 'ON' && env.COVERAGE != 'ON'

- name: Correctness test
working-directory: ${{github.workspace}}/build
run: ctest -j3 -V
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ jobs:
languages: ${{ matrix.language }}
build-mode: manual

- name: Create build environment
run: mkdir ${{github.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment
# variable access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
run: |
cmake "$GITHUB_WORKSPACE" -DCMAKE_BUILD_TYPE=Release -DSTANDALONE=ON
cmake -B build "$GITHUB_WORKSPACE" -DCMAKE_BUILD_TYPE=Release \
-DSTANDALONE=ON

- name: Build
working-directory: ${{github.workspace}}/build
Expand Down
Loading
Loading