Skip to content

Commit d47185d

Browse files
author
gberkes
committed
Build System: Introduce Configurable Assertion Handling
Implemented a new configuration option --enable-assertions=[yes|no] within config.ac, enabling controlled inclusion of -DNDEBUG in CPPFLAGS. The default setting suppresses assertions (by adding -DNDEBUG to CPPFLAGS), preserving the original behavior. This enhancement allows for the optional enabling of assertions during development or debugging by setting --enable-assertions=yes, thereby excluding -DNDEBUG from CPPFLAGS.
1 parent 053e3b5 commit d47185d

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
matrix:
1313
os: [ubuntu-22.04]
1414
platform:
15-
- {label: "x64", arch: "amd64", configure: ""}
16-
- {label: "x32", arch: "i386", configure: "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32"}
15+
- {label: "x64", arch: "amd64", configure: "--enable-assertions=yes"}
16+
- {label: "x32", arch: "i386", configure: "PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS= -m32--enable-assertions=yes"}
1717
compiler:
1818
- {label: "gcc", cc: "gcc", cxx: "g++"}
1919
- {label: "clang", cc: "clang", cxx: "clang++"}
@@ -112,7 +112,7 @@ jobs:
112112
- name: build.sh
113113
run: ./build.sh
114114
- name: configure
115-
run: ./configure ${{ matrix.configure.opt }}
115+
run: ./configure ${{ matrix.configure.opt }} --enable-assertions=yes
116116
- uses: ammaraskar/gcc-problem-matcher@master
117117
- name: make
118118
run: make -j `sysctl -n hw.logicalcpu`

configure.ac

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,17 @@ AC_SUBST([MSC_VERSION])
248248
MSC_GIT_VERSION=msc_version_git
249249
AC_SUBST([MSC_GIT_VERSION])
250250

251+
AC_ARG_ENABLE(assertions,
252+
[AS_HELP_STRING([--enable-assertions],[Turn on assertions feature: undefine NDEBUG])],
253+
254+
[case "${enableval}" in
255+
yes) assertions=true ;;
256+
no) assertions=false ;;
257+
*) AC_MSG_ERROR(bad value ${enableval} for --enable-assertions) ;;
258+
esac],
259+
260+
[assertions=false]
261+
)
251262

252263
AC_ARG_ENABLE(debug-logs,
253264
[AS_HELP_STRING([--disable-debug-logs],[Turn off the SecDebugLog feature])],
@@ -377,6 +388,14 @@ if test "$aflFuzzer" == "true"; then
377388
GLOBAL_CPPFLAGS="$GLOBAL_CPPFLAGS $FUZZ_CPPCFLAGS"
378389
$buildExamples = false
379390
fi
391+
392+
case $assertions in
393+
false) ASSERTIONS_CPPCFLAGS="-DNDEBUG" ;;
394+
true) ASSERTIONS_CPPCFLAGS="-UNDEBUG" ;;
395+
*) AC_MSG_ERROR(bad value ${assertions} for assertions) ;;
396+
esac
397+
GLOBAL_CPPFLAGS="$GLOBAL_CPPFLAGS $ASSERTIONS_CPPCFLAGS"
398+
380399
AC_SUBST(GLOBAL_LDADD)
381400
AC_SUBST(GLOBAL_CPPFLAGS)
382401

@@ -613,6 +632,11 @@ if test $buildTestUtilities = true; then
613632
else
614633
echo " + Test Utilities ....disabled"
615634
fi
635+
if test $assertions = true; then
636+
echo " + Assertions ....enabled"
637+
else
638+
echo " + Assertions ....disabled"
639+
fi
616640
if test $debugLogs = true; then
617641
echo " + SecDebugLog ....enabled"
618642
else

0 commit comments

Comments
 (0)