-
Notifications
You must be signed in to change notification settings - Fork 140
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
CI: add workflow with sanitizers check #356
Merged
alexander-e1off
merged 122 commits into
bloomberg:main
from
alexander-e1off:add_sanitizers_to_ci
Jul 22, 2024
Merged
Changes from all commits
Commits
Show all changes
122 commits
Select commit
Hold shift + click to select a range
f02419e
Fix macro redefinition warnings, add bmqstoragetool.td target
alexander-e1off 122344f
Merge branch 'bloomberg:main' into main
alexander-e1off 9e23230
Merge branch 'bloomberg:main' into main
alexander-e1off 9117ac7
Fix order of objects creation in unit test
alexander-e1off 87cdf0b
Merge branch 'bloomberg:main' into main
alexander-e1off 8e88dc2
Merge branch 'bloomberg:main' into main
alexander-e1off 6dfd1fa
Merge branch 'bloomberg:main' into main
alexander-e1off 4ba1056
Merge branch 'bloomberg:main' into main
alexander-e1off dcae5bf
Merge branch 'bloomberg:main' into main
alexander-e1off 7482e16
Merge branch 'bloomberg:main' into main
alexander-e1off 81a0854
Merge branch 'bloomberg:main' into main
alexander-e1off 2e29ae8
Merge branch 'bloomberg:main' into main
alexander-e1off 924c207
Merge branch 'bloomberg:main' into main
alexander-e1off 950cbf9
Add sanitizers folder with build scripts
alexander-e1off aaba5ac
Fix build errors, add run test script
alexander-e1off 79ec4bc
build.yaml: add build_and_run_asan job
alexander-e1off 40a71cd
build.yaml: fix build_and_run_asan job
alexander-e1off e0d420a
build.yaml: debug build_and_run_asan job
alexander-e1off 9112acf
build.yaml: debug build_and_run_asan job
alexander-e1off b2b7096
build.yaml: debug build_and_run_asan job
alexander-e1off 7fbaaf5
build.yaml: debug build_and_run_asan job
alexander-e1off 535d4e3
Add reusable workflow sanitizers.yaml
alexander-e1off 349cf97
debug build_and_run_asan job
alexander-e1off 5056ec4
debug build_and_run_asan job
alexander-e1off 16848c8
debug build_and_run_asan job
alexander-e1off 57910ac
debug build_and_run_asan job
alexander-e1off 52ff967
debug build_and_run_asan job
alexander-e1off c37d1f7
debug build_and_run_asan job
alexander-e1off f850100
debug build_and_run_asan job
alexander-e1off b91a7e0
debug build_and_run_asan job
alexander-e1off a2206a4
debug build_and_run_asan job
alexander-e1off 37670ed
debug build_and_run_asan job
alexander-e1off 32ee569
debug build_and_run_asan job
alexander-e1off bd36cb4
debug build_and_run_asan job
alexander-e1off 4a6d2e4
debug build_and_run_asan job
alexander-e1off 623bd42
debug build_and_run_asan job
alexander-e1off 532bedf
debug build_and_run_asan job
alexander-e1off db59b0a
debug build_and_run_asan job
alexander-e1off d31d6df
debug build_and_run_asan job
alexander-e1off 4a6e4cf
debug build_and_run_asan job
alexander-e1off 12f8cbe
debug build_and_run_asan job
alexander-e1off efacf0c
debug build_and_run_asan job
alexander-e1off 988e566
debug build_and_run_asan job
alexander-e1off dbfcfcc
debug build_and_run_asan job
alexander-e1off f077610
debug build_and_run_asan job
alexander-e1off 64673a8
debug build_and_run_asan job
alexander-e1off bdb4f69
debug build_and_run_asan job
alexander-e1off 04b7fb6
debug build_and_run_asan job
alexander-e1off f8d7278
debug build_and_run_asan job
alexander-e1off 4ee909d
debug build_and_run_asan job
alexander-e1off 824a6e5
debug build_and_run_asan job
alexander-e1off b072e36
build.yaml: debug build_and_run_asan job
alexander-e1off 01f7999
build.yaml: debug build_and_run_asan job
alexander-e1off 79e095a
build.yaml: debug build_and_run_asan job
alexander-e1off 10a3ec4
build.yaml: debug build_and_run_asan job
alexander-e1off 45e9056
build.yaml: debug build_and_run_asan job
alexander-e1off a939200
build.yaml: debug build_and_run_asan job
alexander-e1off d4a4231
build.yaml: debug build_and_run_asan job
alexander-e1off d83b464
build.yaml: debug build_and_run_asan job
alexander-e1off 4732a1b
build.yaml: debug build_and_run_asan job
alexander-e1off 2801c05
build.yaml: debug build_and_run_asan job
alexander-e1off ed275eb
build.yaml: debug build_and_run_asan job
alexander-e1off 528004e
build.yaml: debug build_and_run_asan job
alexander-e1off f6ec3a4
build.yaml: debug build_and_run_asan job
alexander-e1off 7f04b57
build.yaml: debug build_and_run_asan job
alexander-e1off ed85cdd
build.yaml: debug build_and_run_asan job
alexander-e1off 5e74621
build.yaml: debug build_and_run_asan job
alexander-e1off fa5d657
build.yaml: debug build_and_run_asan job
alexander-e1off db38a03
build.yaml: debug build_and_run_asan job
alexander-e1off 88a2e9c
build.yaml: debug build_and_run_asan job
alexander-e1off b9c5cb4
build.yaml: debug build_and_run_asan job
alexander-e1off c07cb4d
build.yaml: debug build_and_run_asan job
alexander-e1off 895f0f9
Build.yaml: debug build_and_run_asan job
alexander-e1off 81d25de
build.yaml: debug asan and msan jobs
alexander-e1off e7c1b7e
build.yaml: debug asan and msan jobs
alexander-e1off ef83652
build.yaml: debug asan and msan jobs
alexander-e1off d8426f2
build.yaml: debug asan and msan jobs
alexander-e1off 21e83ed
build.yaml: debug asan and msan jobs
alexander-e1off 04a7635
debug asan
alexander-e1off 3e6d953
debug asan and msan
alexander-e1off 38560d4
build.yaml: add all sanitizers
alexander-e1off 778c2e7
add cmake toolchain files for tsan and ubsan
alexander-e1off fd01763
Cleanup scripts
alexander-e1off 3bf72d4
Add missed env.var
alexander-e1off 26e1942
Add -DHAVE_STD_REGEX=ON for google-benchmark
alexander-e1off 8264a38
Cosmetic change
alexander-e1off e87dfd9
build_sanitizer.sh: use llvm.tar.gz
alexander-e1off 27a1d6e
mwcu_sharedresource.t: skip Asan for 2 tests
alexander-e1off c6e92a8
mwcu_sharedresource.t: add BDE version check
alexander-e1off f7f3ef9
Add sanitize.yaml, rename sanitizers->sanitizer-check.yaml
alexander-e1off 7fe283a
Cleanup
alexander-e1off 29c2557
Remove empty line
alexander-e1off d1a111e
Remove empty line
alexander-e1off 184e978
Fix comment
alexander-e1off 51b43bf
Make path absolute
alexander-e1off c67a194
Fix code format
alexander-e1off 6464a18
Cleanup
alexander-e1off f5cce55
Fix shellcheck issues
alexander-e1off d31b791
Debug CI
alexander-e1off f86ec70
Debug CI
alexander-e1off 72767a3
Debug CI
alexander-e1off 673e020
Debug CI
alexander-e1off 9bdc208
Merge branch 'main' into add_sanitizers_to_ci
alexander-e1off 9d76bd8
Debug CI
alexander-e1off ede9ccf
Debug CI
alexander-e1off 2cb956e
Debug CI
alexander-e1off 4152ac7
Debug CI
alexander-e1off 5a3f7a5
Fix CMAKE_OPTIONS in build_sanitizer.sh
alexander-e1off 7091a82
Merge branch 'main' into add_sanitizers_to_ci
alexander-e1off 51203f9
Fix cfgquery() in build_sanitizer.sh
alexander-e1off c19622c
tsansup.txt: suppress TestSession::arriveAtStepWithCfgs
alexander-e1off 4f87f18
Merge branch 'main' into add_sanitizers_to_ci
alexander-e1off ef64ace
Remove debug script
alexander-e1off b856d13
Merge branch 'main' into add_sanitizers_to_ci
alexander-e1off 46829a7
Optimize llvm installation: install only clang
alexander-e1off 24d7993
Switch to stable LLVM version 17
alexander-e1off 6920447
Restore 'all' option for LLVM install
alexander-e1off 17435b2
Use common cmake file for sanitizers, remove unneeded checks in job
alexander-e1off 07801ca
Cleanup unneeded files
alexander-e1off 2b52119
Merge branch 'main' into add_sanitizers_to_ci
alexander-e1off 13dfce4
Cleanup unneeded flags in cmake files
alexander-e1off 400fa8f
Merge branch 'main' into add_sanitizers_to_ci
678098 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 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,80 @@ | ||
name: Sanitize with AddressSanitizer, MemorySanitizer, ThreadSanitizer and UndefinedBehaviorSanitizer. | ||
|
||
on: | ||
pull_request_review: | ||
types: [submitted] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build_dependencies: | ||
name: Build deps [ubuntu] | ||
runs-on: ubuntu-latest | ||
if: github.event.review.state == 'APPROVED' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get dependencies hash | ||
id: get-hash | ||
run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT | ||
- name: Cache lookup | ||
uses: actions/cache/restore@v4 | ||
id: cache-lookup | ||
with: | ||
path: deps | ||
key: deps-${{ steps.get-hash.outputs.deps_hash }} | ||
lookup-only: true | ||
- name: Set up dependencies | ||
if: steps.cache-lookup.outputs.cache-hit != 'true' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -qy build-essential \ | ||
gdb \ | ||
curl \ | ||
python3.10 \ | ||
python3-pip \ | ||
cmake \ | ||
ninja-build \ | ||
pkg-config \ | ||
bison \ | ||
libfl-dev \ | ||
libbenchmark-dev \ | ||
libgmock-dev \ | ||
libz-dev | ||
- name: Fetch & Build non packaged dependencies | ||
if: steps.cache-lookup.outputs.cache-hit != 'true' | ||
run: | | ||
mkdir -p deps | ||
cd deps | ||
../docker/build_deps.sh | ||
- name: Cache save | ||
if: steps.cache-lookup.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: deps | ||
key: deps-${{ steps.get-hash.outputs.deps_hash }} | ||
|
||
run_asan: | ||
needs: build_dependencies | ||
uses: ./.github/workflows/sanitizer-check.yaml | ||
with: | ||
sanitizer-name: 'asan' | ||
|
||
run_msan: | ||
needs: build_dependencies | ||
uses: ./.github/workflows/sanitizer-check.yaml | ||
with: | ||
sanitizer-name: 'msan' | ||
|
||
run_tsan: | ||
needs: build_dependencies | ||
uses: ./.github/workflows/sanitizer-check.yaml | ||
with: | ||
sanitizer-name: 'tsan' | ||
|
||
run_ubsan: | ||
needs: build_dependencies | ||
uses: ./.github/workflows/sanitizer-check.yaml | ||
with: | ||
sanitizer-name: 'ubsan' |
This file contains 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,27 @@ | ||
name: Build and run Sanitizer | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
sanitizer-name: | ||
description: Sanitizer name (asan/msan/tsan/ubsan) | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
build_and_run_sanitizer: | ||
name: Build and run Sanitizer | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get dependencies hash | ||
id: get-hash | ||
run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT | ||
- uses: actions/cache/restore@v4 | ||
with: | ||
path: deps | ||
key: deps-${{ steps.get-hash.outputs.deps_hash }} | ||
- name: Build BlazingMQ and dependencies with sanitizer instrumentation | ||
run: ${{ github.workspace }}/.github/workflows/sanitizers/build_sanitizer.sh ${{ inputs.sanitizer-name }} | ||
- name: Run unit tests under sanitizer | ||
run: ${{ github.workspace }}/cmake.bld/Linux/run-unittests.sh |
This file contains 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,287 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script can be used to build BlazingMQ, and all of its transitive | ||
# dependencies (up to and including the standard library) using: | ||
# - Clang | ||
# - LLVM libc++ standard library | ||
# - A CMake toolchain file specific for instrumented build | ||
# It is currently used to build instrumented BlazingMQ binaries for CI for all | ||
# Clang sanitizers (i.e. Address/Leak, Memory, Thread, UndefinedBehavior). | ||
# | ||
# It performs the following: | ||
# 1) Install clang compiler. | ||
# 2) Download llvm-project required for libc++ instrumentation. | ||
# 3) Download external dependencies required for instrumentation. | ||
# 4) Build libc++ with the instrumentation specified by <LLVM Sanitizer Name>. | ||
# 5) Build sanitizer-instrumented dependencies including BDE, NTF, GoogleTest, | ||
# Google Benchmark and zlib. | ||
# 6) Build sanitizer-instrumented BlazingMQ unit tests. | ||
# 7) Generate scripts to run unit tests: | ||
# ./cmake.bld/Linux/run-unittests.sh | ||
# This script is used as-is by CI to run unit tests under sanitizer. | ||
|
||
set -eux | ||
|
||
# :: Required arguments ::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
if [ -z "${1}" ]; then | ||
echo 'Error: Missing sanitizer name.' >&2 | ||
echo ' (Usage: build_sanitizer.sh <sanitizer-name>)' >&2 | ||
exit 1 | ||
fi | ||
|
||
SANITIZER_NAME="${1}" | ||
|
||
# Github's 'ubuntu-22.04' image contains a lot of preinstalled tools, | ||
# see https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md. | ||
# Uninstall uneeded tools which cause of versions clash. | ||
sudo apt-get purge \ | ||
llvm-14 \ | ||
clang-14 \ | ||
gcc-9 \ | ||
gcc-10 \ | ||
gcc-11 \ | ||
gcc-12 | ||
|
||
# Install prerequisites | ||
sudo apt-get update && sudo apt-get install -qy \ | ||
lsb-release \ | ||
wget \ | ||
software-properties-common \ | ||
gnupg \ | ||
git \ | ||
curl \ | ||
jq \ | ||
ninja-build \ | ||
bison \ | ||
libfl-dev \ | ||
pkg-config | ||
|
||
# Install prerequisites for LLVM: latest cmake version, Ubuntu apt repository contains cmake version 3.22.1 | ||
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \ | ||
| gpg --dearmor - \ | ||
| sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null | ||
sudo apt-add-repository -y "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | ||
sudo apt-get install -qy cmake | ||
|
||
# Install LLVM | ||
wget https://apt.llvm.org/llvm.sh | ||
chmod +x llvm.sh | ||
LLVM_VERSION=17 | ||
sudo ./llvm.sh ${LLVM_VERSION} all | ||
|
||
# Create version-agnostic pointers to required LLVM binaries. | ||
sudo ln -sf /usr/bin/clang-${LLVM_VERSION} /usr/bin/clang | ||
sudo ln -sf /usr/bin/clang++-${LLVM_VERSION} /usr/bin/clang++ | ||
sudo ln -sf /usr/bin/llvm-symbolizer-${LLVM_VERSION} /usr/bin/llvm-symbolizer | ||
|
||
# Set some initial constants | ||
PARALLELISM=8 | ||
|
||
DIR_ROOT="${PWD}" | ||
DIR_SCRIPTS="${DIR_ROOT}/.github/workflows/sanitizers" | ||
DIR_EXTERNAL="${DIR_ROOT}/deps" | ||
DIR_SRCS_EXT="${DIR_EXTERNAL}/srcs" | ||
DIR_BUILD_EXT="${DIR_EXTERNAL}/cmake.bld" | ||
|
||
DIR_SRC_BMQ="${DIR_ROOT}" | ||
DIR_BUILD_BMQ="${DIR_SRC_BMQ}/cmake.bld/Linux" | ||
|
||
# Parse sanitizers config | ||
cfgquery() { | ||
jq "${1}" "${DIR_SCRIPTS}/sanitizers.json" --raw-output | ||
} | ||
LLVM_SANITIZER_NAME="$(cfgquery ."${SANITIZER_NAME}".llvm_sanitizer_name)" | ||
# Check if llvm specific cmake options are present for the given sanitizer | ||
LLVM_SPECIFIC_CMAKE_OPTIONS="$(cfgquery ."${SANITIZER_NAME}".llvm_specific_cmake_options)" | ||
if [[ "$LLVM_SPECIFIC_CMAKE_OPTIONS" == null ]]; then LLVM_SPECIFIC_CMAKE_OPTIONS=""; fi | ||
|
||
checkoutGitRepo() { | ||
local repo=$1 | ||
local ref=$2 | ||
local repoDir=$3 | ||
echo "Checking out ${repo} at ${ref}" | ||
|
||
local repoPath="${DIR_SRCS_EXT}/${repoDir}" | ||
|
||
git clone -b "${ref}" "${repo}" \ | ||
--depth 1 --single-branch --no-tags -c advice.detachedHead=false "${repoPath}" | ||
} | ||
github_url() { echo "https://github.com/$1.git"; } | ||
|
||
# Download external dependencies | ||
mkdir -p "${DIR_SRCS_EXT}" | ||
|
||
# Download LLVM | ||
LLVM_TAG="llvmorg-17.0.6" | ||
curl -SL "https://github.com/llvm/llvm-project/archive/refs/tags/${LLVM_TAG}.tar.gz" \ | ||
| tar -xzC "${DIR_SRCS_EXT}" | ||
mv "${DIR_SRCS_EXT}/llvm-project-${LLVM_TAG}" "${DIR_SRCS_EXT}/llvm-project" | ||
|
||
# Download google-benchmark | ||
GOOGLE_BENCHMARK_TAG="v1.8.4" | ||
checkoutGitRepo "$(github_url google/benchmark)" "${GOOGLE_BENCHMARK_TAG}" "google-benchmark" | ||
|
||
# Download googletest | ||
GOOGLETEST_TAG="v1.14.0" | ||
checkoutGitRepo "$(github_url google/googletest)" "${GOOGLETEST_TAG}" "googletest" | ||
|
||
# Download zlib | ||
ZLIB_TAG="v1.3.1" | ||
checkoutGitRepo "$(github_url madler/zlib)" "${ZLIB_TAG}" "zlib" | ||
|
||
# Build libc++ with required instrumentation | ||
# | ||
# The extent to which all dependencies to be compiled with sanitizer-support | ||
# varies by sanitizer. MemorySanitizer is especially unforgiving: Failing to | ||
# link against an instrumented standard library will yield many false | ||
# positives. Concensus is that compiling libc++ with `-fsanitize=memory` is a | ||
# significantly easier endeavor than doing the same with libstdc++ (the gcc | ||
# standard library). | ||
# | ||
# We therefore opt to use libc++ here, just to ensure maximum flexibility. We | ||
# follow build instructions from https://libcxx.llvm.org/BuildingLibcxx.html | ||
LIBCXX_SRC_PATH="${DIR_SRCS_EXT}/llvm-project/runtimes" | ||
LIBCXX_BUILD_PATH="${LIBCXX_SRC_PATH}/cmake.bld" | ||
|
||
cmake -B "${LIBCXX_BUILD_PATH}" \ | ||
-S "${LIBCXX_SRC_PATH}" \ | ||
-DCMAKE_BUILD_TYPE="Debug" \ | ||
-DCMAKE_C_COMPILER="clang" \ | ||
-DCMAKE_CXX_COMPILER="clang++" \ | ||
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ | ||
-DLLVM_USE_SANITIZER="${LLVM_SANITIZER_NAME}" \ | ||
"${LLVM_SPECIFIC_CMAKE_OPTIONS}" | ||
|
||
cmake --build "${LIBCXX_BUILD_PATH}" -j${PARALLELISM} --target cxx cxxabi unwind generate-cxx-headers | ||
|
||
# Variables read by our custom CMake toolchain used to build everything else. | ||
export LIBCXX_BUILD_PATH="${LIBCXX_BUILD_PATH}" | ||
export DIR_SRC_BMQ="${DIR_SRC_BMQ}" | ||
export DIR_SCRIPTS="${DIR_SCRIPTS}" | ||
|
||
TOOLCHAIN_PATH="${DIR_SCRIPTS}/clang-libcxx-sanitizer.cmake" | ||
export SANITIZER_NAME="${SANITIZER_NAME}" | ||
export CC="clang" | ||
export CXX="clang++" | ||
export CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES="/usr/include;/usr/include/clang/${LLVM_VERSION}/include" | ||
export BBS_BUILD_SYSTEM="ON" | ||
PATH="$PATH:$(realpath "${DIR_SRCS_EXT}"/bde-tools/bin)" | ||
export PATH | ||
|
||
# Build BDE + NTF | ||
pushd "${DIR_SRCS_EXT}/bde" | ||
eval "$(bbs_build_env -u dbg_64_safe_cpp20 -b "${DIR_BUILD_EXT}/bde")" | ||
bbs_build configure --toolchain "${TOOLCHAIN_PATH}" | ||
bbs_build build -j${PARALLELISM} | ||
bbs_build --install=/opt/bb --prefix=/ install | ||
popd | ||
|
||
pushd "${DIR_SRCS_EXT}/ntf-core" | ||
# TODO The deprecated flag "-fcoroutines-ts" has been removed in clang | ||
# 17.0.1, but NTF is still using it. We manually change this flag until | ||
# the fix in issue 175307231 is resolved. | ||
sed -i 's/fcoroutines-ts/fcoroutines/g' 'repository.cmake' | ||
|
||
./configure --keep \ | ||
--prefix /opt/bb \ | ||
--output "${DIR_BUILD_EXT}/ntf" \ | ||
--without-warnings-as-errors \ | ||
--without-usage-examples \ | ||
--without-applications \ | ||
--ufid 'dbg_64_safe_cpp20' \ | ||
--toolchain "${TOOLCHAIN_PATH}" | ||
make -j${PARALLELISM} | ||
make install | ||
popd | ||
|
||
# Note: Hack to circumvent faulty behavior in "nts-targets.cmake" | ||
ln -sf "/opt/bb/include" "/opt/include" | ||
ln -sf "/opt/bb/lib64" "/opt/lib64" | ||
|
||
# Setup CMake options for all remaining builds | ||
CMAKE_OPTIONS=( \ | ||
-D BUILD_BITNESS=64 \ | ||
-D CMAKE_BUILD_TYPE=Debug \ | ||
-D CMAKE_INSTALL_INCLUDEDIR=include \ | ||
-D CMAKE_INSTALL_LIBDIR=lib64 \ | ||
-D CMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_PATH}") | ||
|
||
# Build GoogleTest | ||
cmake -B "${DIR_SRCS_EXT}/googletest/cmake.bld" \ | ||
-S "${DIR_SRCS_EXT}/googletest" "${CMAKE_OPTIONS[@]}" \ | ||
-DCMAKE_INSTALL_PREFIX=/opt/bb | ||
cmake --build "${DIR_SRCS_EXT}/googletest/cmake.bld" -j${PARALLELISM} | ||
cmake --install "${DIR_SRCS_EXT}/googletest/cmake.bld" --prefix "/opt/bb" | ||
|
||
# Build Google Benchmark | ||
cmake -B "${DIR_SRCS_EXT}/google-benchmark/cmake.bld" \ | ||
-S "${DIR_SRCS_EXT}/google-benchmark" "${CMAKE_OPTIONS[@]}" \ | ||
-DCMAKE_INSTALL_PREFIX=/opt/bb \ | ||
-DBENCHMARK_DOWNLOAD_DEPENDENCIES="ON" \ | ||
-DBENCHMARK_ENABLE_GTEST_TESTS="false" \ | ||
-DHAVE_STD_REGEX="ON" \ | ||
-DBENCHMARK_ENABLE_TESTING="OFF" | ||
cmake --build "${DIR_SRCS_EXT}/google-benchmark/cmake.bld" -j${PARALLELISM} | ||
cmake --install "${DIR_SRCS_EXT}/google-benchmark/cmake.bld" --prefix "/opt/bb" | ||
|
||
# Build zlib | ||
# Note: zlib has completely broken CMake install rules, so we must | ||
# specify the install prefix *exactly* as it will be at configure | ||
# time | ||
# https://discourse.cmake.org/t/cmake-install-prefix-not-work/5040 | ||
cmake -B "${DIR_SRCS_EXT}/zlib/cmake.bld" -S "${DIR_SRCS_EXT}/zlib" \ | ||
-D CMAKE_INSTALL_PREFIX="/opt/bb" \ | ||
"${CMAKE_OPTIONS[@]}" | ||
# Make and install zlib. | ||
cmake --build "${DIR_SRCS_EXT}/zlib/cmake.bld" -j${PARALLELISM} | ||
cmake --install "${DIR_SRCS_EXT}/zlib/cmake.bld" | ||
|
||
# Build BlazingMQ | ||
PKG_CONFIG_PATH="/opt/bb/lib64/pkgconfig:/opt/bb/lib/pkgconfig:/opt/bb/share/pkgconfig:$(pkg-config --variable pc_path pkg-config)" \ | ||
cmake -B "${DIR_BUILD_BMQ}" -S "${DIR_SRC_BMQ}" -G Ninja \ | ||
-DBDE_BUILD_TARGET_64=ON \ | ||
-DBDE_BUILD_TARGET_CPP17=ON \ | ||
-DCMAKE_PREFIX_PATH="${DIR_SRCS_EXT}/bde-tools/BdeBuildSystem" \ | ||
-DBDE_BUILD_TARGET_SAFE=1 "${CMAKE_OPTIONS[@]}" | ||
cmake --build "${DIR_BUILD_BMQ}" -j${PARALLELISM} \ | ||
--target all.t -v --clean-first | ||
|
||
# Create testing script | ||
envcfgquery() { | ||
# Parses the '<build-name>.environment' object from 'sanitizers.json', | ||
# and outputs a string of whitespace-separated 'VAR=VAL' pairs intended to | ||
# be used to set the environment for a command. | ||
# e.g. 'asan' -> 'ASAN_OPTIONS="foo=bar:baz=baf" LSAN_OPTIONS="abc=fgh"' | ||
# | ||
cfgquery " \ | ||
.${1}.environment | \ | ||
to_entries | \ | ||
map(\"\(.key)=\\\"\(.value | \ | ||
to_entries | \ | ||
map(\"\(.key)=\(.value)\") | \ | ||
join(\":\"))\\\"\") | \ | ||
join(\" \")" | | ||
sed "s|%%SRC%%|$(realpath "${DIR_SRC_BMQ}")|g" | | ||
sed "s|%%ROOT%%|$(realpath "${DIR_ROOT}")|g" | ||
} | ||
|
||
mkscript() { | ||
local cmd=${1} | ||
local outfile=${2} | ||
|
||
echo '#!/usr/bin/env bash' > "${outfile}" | ||
echo "${cmd}" >> "${outfile}" | ||
chmod +x "${outfile}" | ||
} | ||
|
||
SANITIZER_ENV="BMQ_BUILD=$(realpath "${DIR_BUILD_BMQ}") " | ||
SANITIZER_ENV+="BMQ_REPO=${DIR_SRC_BMQ} " | ||
SANITIZER_ENV+="$(envcfgquery "${SANITIZER_NAME}")" | ||
|
||
# 'run-env.sh' runs a command with environment required of the sanitizer. | ||
mkscript "${SANITIZER_ENV} \${@}" "${DIR_BUILD_BMQ}/run-env.sh" | ||
|
||
# 'run-unittests.sh' runs all instrumented unit-tests. | ||
CMD="cd $(realpath "${DIR_BUILD_BMQ}") && " | ||
CMD+="./run-env.sh ctest -E mwcsys_executil.t --output-on-failure" | ||
mkscript "${CMD}" "${DIR_BUILD_BMQ}/run-unittests.sh" |
Oops, something went wrong.
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.
Is the state case sensitive?
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.
In github actions doc it is in uppercase , but I saw also in lowercase, e.g. here