Skip to content

Commit

Permalink
configure: --enable-debugbuild flag for debug builds.
Browse files Browse the repository at this point in the history
This controls debug flags for the build, rather than --developer,
which is going away.

I thought about making this flag control the RUST_PROFILE too, but
it seems that we want that set to "release" for CI, whereas for the
C code we want --enable-debugbuild.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jul 9, 2023
1 parent 0c4426a commit fa596a9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
# We're going to check BOLT quotes, so get the latest version
git clone https://github.com/lightning/bolts.git ../${BOLTDIR}
- name: Configure
run: ./configure
run: ./configure --enable-debugbuild
- name: Check source
run: make -j 4 check-source BASE_REF="origin/${{ github.base_ref }}"
- name: Check Generated Files have been updated
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
- name: Build
run: |
./configure
./configure --enable-debugbuild
make -j $(nproc) check-units installcheck
check-units-sanitizers:
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
- name: Build
run: |
./configure CC=clang
./configure --enable-debugbuild CC=clang
make -j $(nproc) check-units installcheck
check-fuzz:
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:
- name: Build
run: |
./configure --enable-fuzzing CC=clang
./configure --enable-debugbuild --enable-fuzzing CC=clang
make -j $(nproc) check-fuzz
compile:
Expand Down Expand Up @@ -215,7 +215,7 @@ jobs:
pip3 install --user pip wheel poetry
poetry export -o requirements.txt --with dev --without-hashes
python3 -m pip install -r requirements.txt
./configure CC="$COMPILER"
./configure --enable-debugbuild CC="$COMPILER"
make -j $(nproc) testpack.tar.bz2
Expand Down Expand Up @@ -462,7 +462,7 @@ jobs:

- name: Build
run: |
./configure CC=clang --enable-address-sanitizer --enable-ub-sanitizer --disable-valgrind --enable-developer
./configure CC=clang --enable-address-sanitizer --enable-ub-sanitizer --disable-valgrind --enable-developer --enable-debugbuild
make -j $(nproc)
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ VG=VALGRIND=1 valgrind -q --error-exitcode=7
VG_TEST_ARGS = --track-origins=yes --leak-check=full --show-reachable=yes --errors-for-leak-kinds=all
endif

ifeq ($(DEVELOPER),1)
ifeq ($(DEBUGBUILD),1)
DEV_CFLAGS=-DCCAN_TAKE_DEBUG=1 -DCCAN_TAL_DEBUG=1 -DCCAN_JSON_OUT_DEBUG=1
else
DEV_CFLAGS=
Expand Down
31 changes: 20 additions & 11 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ usage_with_default()
echo " $1 (default $DEF)"
}

# Given DEVELOPER, what COPTFLAGS do we default to.
# Given DEBUGBUILD, what COPTFLAGS do we default to.
default_coptflags()
{
if [ "$1" = 0 ]; then
Expand Down Expand Up @@ -142,6 +142,9 @@ set_defaults()
CC=${CC:-cc}
CDEBUGFLAGS=${CDEBUGFLAGS--std=gnu11 -g -fstack-protector-strong}
DEVELOPER=${DEVELOPER:-0}
DEBUGBUILD=${DEBUGBUILD:-0}
# --enable-developer forces debug build
[ "$DEVELOPER" = 0 ] || DEBUGBUILD=1
COMPAT=${COMPAT:-1}
STATIC=${STATIC:-0}
CLANG_COVERAGE=${CLANG_COVERAGE:-0}
Expand All @@ -152,13 +155,13 @@ set_defaults()
CSANFLAGS=""
if [ "$ASAN" != 0 ]; then
CSANFLAGS="$CSANFLAGS -fsanitize=address"
if [ "$DEVELOPER" != 0 ]; then
if [ "$DEBUGBUILD" != 0 ]; then
CSANFLAGS="$CSANFLAGS -fno-sanitize-recover=address"
fi
fi
if [ "$UBSAN" != 0 ]; then
CSANFLAGS="$CSANFLAGS -fsanitize=undefined"
if [ "$DEVELOPER" != 0 ]; then
if [ "$DEBUGBUILD" != 0 ]; then
CSANFLAGS="$CSANFLAGS -fno-sanitize-recover=undefined"
fi
fi
Expand All @@ -168,7 +171,7 @@ set_defaults()
fi
echo CSANFLAGS = $CSANFLAGS
PYTEST=${PYTEST-$(default_pytest)}
COPTFLAGS=${COPTFLAGS-$(default_coptflags "$DEVELOPER")}
COPTFLAGS=${COPTFLAGS-$(default_coptflags "$DEBUGBUILD")}
CONFIGURATOR_CC=${CONFIGURATOR_CC-$CC}
VALGRIND=${VALGRIND:-$(default_valgrind_setting)}
TEST_NETWORK=${TEST_NETWORK:-regtest}
Expand All @@ -181,7 +184,7 @@ usage()
echo "If --reconfigure is specified, $CONFIG_VAR_FILE will set defaults."
echo "Default settings:"
set_defaults
DEFAULT_COPTFLAGS="$(default_coptflags $DEVELOPER)"
DEFAULT_COPTFLAGS="$(default_coptflags $DEBUGBUILD)"
# We assume we have a modern gcc.
DEFAULT_CWARNFLAGS="$(default_cwarnflags ""$DEFAULT_COPTFLAGS"" 1 1)"
usage_with_default "CC" "$CC"
Expand All @@ -198,6 +201,8 @@ usage()
echo " Prefix for make install"
usage_with_default "--enable/disable-developer" "$DEVELOPER" "enable" "disable"
echo " Developer mode, good for testing"
usage_with_default "--enable/disable-debug" "$DEBUGBUILD" "enable" "disable"
echo " Extra debug checks in the build, good for testing"
usage_with_default "--enable/disable-compat" "$COMPAT" "enable" "disable"
echo " Compatibility mode, good to disable to see if your software breaks"
usage_with_default "--enable/disable-valgrind" "(autodetect)"
Expand Down Expand Up @@ -236,20 +241,21 @@ for opt in "$@"; do
# Set from values if not already set.
while IFS='=' read VAR VAL; do
if eval [ -z \${$VAR+x} ]; then eval $VAR=\"$VAL\"; fi
# If they had an old config, it might set DEVELOPER.
if [ "$VAR" = DEVELOPER ]; then
DEFAULT_COPTFLAGS=$(default_coptflags "$VAL")
DEBUGBUILD="$VAL"
VAR=DEBUGBUILD
fi
if [ "$VAR" = DEBUGBUILD ]; then
DEFAULT_COPTFLAGS=$(default_coptflags "$VAL")
fi
done < $CONFIG_VAR_FILE
# If we were those defaults, unset so we get new defaults in
# case DEVELOPER has changed.
# case DEBUGBUILD has changed.
if [ x"$COPTFLAGS" = x"$DEFAULT_COPTFLAGS" ]; then
unset COPTFLAGS
fi
# If they didn't have -Wshadow=local, add it on --reconfigure
# (we only added it later)
if [ x"${CWARNFLAGS%*-Wshadow=local}" = x"$CWARNFLAGS" ]; then
unset CWARNFLAGS
fi
;;
CC=*) CC="${opt#CC=}";;
CONFIGURATOR_CC=*) CONFIGURATOR_CC="${opt#CONFIGURATOR_CC=}";;
Expand All @@ -260,6 +266,8 @@ for opt in "$@"; do
--prefix=*) PREFIX="${opt#--prefix=}";;
--enable-developer) DEVELOPER=1;;
--disable-developer) DEVELOPER=0;;
--enable-debugbuild) DEBUGBUILD=1;;
--disable-debugbuild) DEBUGBUILD=0;;
--enable-compat) COMPAT=1;;
--disable-compat) COMPAT=0;;
--enable-valgrind) VALGRIND=1;;
Expand Down Expand Up @@ -493,6 +501,7 @@ add_var POSTGRES_INCLUDE "$POSTGRES_INCLUDE"
add_var POSTGRES_LDLIBS "$POSTGRES_LDLIBS"
add_var VALGRIND "$VALGRIND"
add_var DEVELOPER "$DEVELOPER" $CONFIG_HEADER.$$
add_var DEBUGBUILD "$DEBUGBUILD"
add_var COMPAT "$COMPAT" $CONFIG_HEADER.$$
add_var PYTEST "$PYTEST"
add_var STATIC "$STATIC"
Expand Down

0 comments on commit fa596a9

Please sign in to comment.