enable asserts in a majority of CMake CI builds (#7482)
Bazel builds already had asserts enabled, so this is only about CMake builds.
It's generally useful to build CI with asserts, but we wouldn't want to build only asserts-builds at all: after all, the notion that asserts are only actually assertions and don't play a part in the program's actual function, is left entirely up to the programmer, and we want to catch mistakes at that level e.g. instances of assert(is_status_ok(important_file_io()) expanding to nothing in non-asserts builds.
So this PR adds IREE_ENABLE_ASSERTIONS=ON to some common build.sh scripts used for CI, but intentionally not all of them. For example, the -asan CI uses its own build.sh file and we are intentionally not adding asserts there just so we keep some non-asserts coverage (this isn't embodying an opinion about whether to conflate asserts and asan in the same builds or to keep them separate! it's just what was quick to do here).
Fixes Issue #7320 .
diff --git a/build_tools/cmake/build_android.sh b/build_tools/cmake/build_android.sh
index 12d1bd1..dcf07f4 100755
--- a/build_tools/cmake/build_android.sh
+++ b/build_tools/cmake/build_android.sh
@@ -45,6 +45,7 @@
# Configure, build, install.
"${CMAKE_BIN?}" -G Ninja .. \
-DCMAKE_INSTALL_PREFIX=./install \
+ -DIREE_ENABLE_ASSERTIONS=ON \
-DIREE_BUILD_COMPILER=ON \
-DIREE_BUILD_TESTS=OFF \
-DIREE_BUILD_BENCHMARKS=ON \
@@ -74,6 +75,7 @@
-DANDROID_ABI="${ANDROID_ABI?}" \
-DANDROID_PLATFORM=android-29 \
-DIREE_HOST_BINARY_ROOT=$PWD/../build-host/install \
+ -DIREE_ENABLE_ASSERTIONS=ON \
-DIREE_BUILD_COMPILER=OFF \
-DIREE_BUILD_TESTS=ON \
-DIREE_BUILD_SAMPLES=OFF
diff --git a/build_tools/cmake/build_riscv.sh b/build_tools/cmake/build_riscv.sh
index bf085ac..4bc9ae4 100755
--- a/build_tools/cmake/build_riscv.sh
+++ b/build_tools/cmake/build_riscv.sh
@@ -40,6 +40,7 @@
-DCMAKE_INSTALL_PREFIX="${BUILD_HOST_DIR?}/install" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
+ -DIREE_ENABLE_ASSERTIONS=ON \
-DIREE_BUILD_COMPILER=ON \
-DIREE_BUILD_TESTS=OFF \
-DIREE_BUILD_SAMPLES=OFF \
@@ -66,6 +67,7 @@
-DCMAKE_TOOLCHAIN_FILE="$(realpath ${ROOT_DIR?}/build_tools/cmake/riscv.toolchain.cmake)"
-DIREE_HOST_BINARY_ROOT="$(realpath ${BUILD_HOST_DIR?}/install)"
-DRISCV_CPU="${RISCV_CONFIG?}"
+ -DIREE_ENABLE_ASSERTIONS=ON
-DIREE_BUILD_COMPILER=OFF
-DIREE_BUILD_SAMPLES=ON
)
diff --git a/build_tools/cmake/rebuild.sh b/build_tools/cmake/rebuild.sh
index 2e20245..68e9420 100755
--- a/build_tools/cmake/rebuild.sh
+++ b/build_tools/cmake/rebuild.sh
@@ -41,6 +41,13 @@
# Enable building the python bindings on CI. Most heavy targets are gated on
# IREE_ENABLE_TENSORFLOW, so what's left here should be fast.
"-DIREE_BUILD_PYTHON_BINDINGS=ON"
+
+ # Enable assertions. We wouldn't want to be testing *only* with assertions
+ # enabled, but at the moment only certain CI builds are using this script,
+ # e.g. ASan builds are not using this, so by enabling assertions here, we
+ # get a reasonable mix of {builds with asserts, builds with other features
+ # such as ASan but without asserts}.
+ "-DIREE_ENABLE_ASSERTIONS=ON"
)
"$CMAKE_BIN" "${CMAKE_ARGS[@]?}" ..