1616
1717set -eux
1818
19- source_dir=${1}
20- enable_sanitizer=${2:- false}
21- check_clang_tidy=${3:- false}
22- build_type=${4:- Debug}
19+ usage () {
20+ echo " Usage: $0 --source_dir <path> [--enable_asan] [--enable_ubsan] [--enable_tsan] [--check_clang_tidy] [--build_type <type>]"
21+ }
22+
23+ source_dir=" "
24+ enable_asan=" false"
25+ enable_ubsan=" false"
26+ enable_tsan=" false"
27+ check_clang_tidy=" false"
28+ build_type=" Debug"
29+
30+ while [[ $# -gt 0 ]]; do
31+ case " $1 " in
32+ --source_dir)
33+ if [[ $# -lt 2 ]]; then
34+ echo " Missing value for --source_dir" >&2
35+ usage >&2
36+ exit 1
37+ fi
38+ source_dir=$2
39+ shift 2
40+ ;;
41+ --enable_asan)
42+ enable_asan=" true"
43+ shift
44+ ;;
45+ --enable_ubsan)
46+ enable_ubsan=" true"
47+ shift
48+ ;;
49+ --enable_tsan)
50+ enable_tsan=" true"
51+ shift
52+ ;;
53+ --check_clang_tidy)
54+ check_clang_tidy=" true"
55+ shift
56+ ;;
57+ --build_type)
58+ if [[ $# -lt 2 ]]; then
59+ echo " Missing value for --build_type" >&2
60+ usage >&2
61+ exit 1
62+ fi
63+ build_type=$2
64+ shift 2
65+ ;;
66+ -h | --help)
67+ usage
68+ exit 0
69+ ;;
70+ * )
71+ echo " Unknown argument: $1 " >&2
72+ usage >&2
73+ exit 1
74+ ;;
75+ esac
76+ done
77+
78+ if [[ -z " ${source_dir} " ]]; then
79+ echo " --source_dir is required" >&2
80+ usage >&2
81+ exit 1
82+ fi
83+
84+ if [[ " ${enable_asan} " == " true" && " ${enable_tsan} " == " true" ]]; then
85+ echo " ASAN and TSAN cannot be enabled together" >&2
86+ usage >&2
87+ exit 1
88+ fi
89+
2390build_dir=" ${source_dir} /build"
2491
2592# Display ccache status if available
@@ -46,6 +113,9 @@ if [[ "${CC:-}" == *"gcc-8"* ]] || [[ "${CXX:-}" == *"g++-8"* ]]; then
46113 # Consider supporting Lance from source compilation in the future
47114 ENABLE_TANTIVY=" OFF" # tantivy-fts (Rust FFI) is not built on the gcc-8 image.
48115fi
116+ if [[ " ${enable_tsan} " == " true" ]]; then
117+ ENABLE_TANTIVY=" OFF" # Tantivy's Rust library is not TSAN-instrumented.
118+ fi
49119
50120CMAKE_ARGS=(
51121 " -G Ninja"
@@ -58,11 +128,14 @@ CMAKE_ARGS=(
58128 " -DPAIMON_ENABLE_TANTIVY=${ENABLE_TANTIVY} "
59129)
60130
61- if [[ " ${enable_sanitizer} " == " true" ]]; then
62- CMAKE_ARGS+=(
63- " -DPAIMON_USE_ASAN=ON"
64- " -DPAIMON_USE_UBSAN=ON"
65- )
131+ if [[ " ${enable_asan} " == " true" ]]; then
132+ CMAKE_ARGS+=(" -DPAIMON_USE_ASAN=ON" )
133+ fi
134+ if [[ " ${enable_ubsan} " == " true" ]]; then
135+ CMAKE_ARGS+=(" -DPAIMON_USE_UBSAN=ON" )
136+ fi
137+ if [[ " ${enable_tsan} " == " true" ]]; then
138+ CMAKE_ARGS+=(" -DPAIMON_USE_TSAN=ON" )
66139fi
67140
68141cmake " ${CMAKE_ARGS[@]} " " ${source_dir} "
0 commit comments