Add a build option for enabling undefined behavior sanitizer, use for CI

Similar to ASAN, now that we can this is a nice and cheap way to keep
compiler gremlins at bay.
This commit is contained in:
Panu Matilainen 2024-01-31 10:43:00 +02:00
parent ca8d1cf3f4
commit c853986925
2 changed files with 12 additions and 1 deletions

View File

@ -19,6 +19,7 @@ option(ENABLE_NDB "Enable ndb rpmdb support" ON)
option(ENABLE_BDB_RO "Enable read-only Berkeley DB rpmdb support (EXPERIMENTAL)" OFF)
option(ENABLE_TESTSUITE "Enable test-suite" ON)
option(ENABLE_ASAN "Enable address-sanitizer" OFF)
option(ENABLE_UBSAN "Enable undefined behavior-sanitizer" OFF)
option(WITH_CAP "Build with capability support" ON)
option(WITH_ACL "Build with ACL support" ON)
@ -376,10 +377,18 @@ endif()
if (ENABLE_ASAN)
add_compile_options(-fsanitize=address)
add_compile_options(-fno-omit-frame-pointer)
add_link_options(-fsanitize=address)
endif()
if (ENABLE_UBSAN)
add_compile_options(-fsanitize=undefined)
add_link_options(-fsanitize=undefined)
endif()
if (ENABLE_ASAN OR ENABLE_UBSAN)
add_compile_options(-fno-omit-frame-pointer)
endif()
# try to ensure some compiler sanity
foreach (flag -fno-strict-overflow -fno-delete-null-pointer-checks)
check_c_compiler_flag(${flag} found)

View File

@ -50,6 +50,7 @@ RUN dnf -y install \
fsverity-utils fsverity-utils-devel \
pandoc \
libasan \
libubsan \
&& dnf clean all
RUN echo "%_dbpath $(rpm --eval '%_dbpath')" > /root/.rpmmacros
@ -79,6 +80,7 @@ ENV CFLAGS="-Og -g"
RUN cmake \
-DENABLE_WERROR=ON \
-DENABLE_ASAN=ON \
-DENABLE_UBSAN=ON \
-DENABLE_BDB_RO=ON \
-DWITH_FSVERITY=ON \
-DWITH_IMAEVM=ON \