From d5835df2eebf8e9cd3ae35b683c831c2a16a5269 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 30 Nov 2023 21:31:46 +0100 Subject: [gdb/build] Fix adding -DNDEBUG to python flags of release build In gdb/configure the line: ... $development || tentative_python_cflags="$tentative_python_cflags -DNDEBUG" ... intends to ensure that -DNDEBUG is added to the python flags of a release build. However, when building gdb-14-branch we have: ... configure:22024: checking compiler flags for python code ... configure:22047: result: -fno-strict-aliasing -fwrapv ... This is a regression since commit db6878ac553 ("Move sourcing of development.sh to GDB_AC_COMMON"), which introduced a reference before assignment: ... $development || tentative_python_cflags="$tentative_python_cflags -DNDEBUG" ... . $srcdir/../bfd/development.sh ... and consequently -DNDEBUG is never added. [ This was not obvious to me, but apparently evaluating an empty or undefined variable in this context is similar to using ':' or 'true', so the line is evaluated as: ... true || tentative_python_cflags="$tentative_python_cflags -DNDEBUG" ... ] Fix this by moving GDB_AC_COMMON up in gdb/configure.ac, similar to how that was done for gdbserver/configure.ac in commit db6878ac553. [ Unfortunately, the move might introduce issues similar to the one we're fixing, and I'm not sure how to check for this. Shellcheck doesn't detect this type of problem. FWIW, I did run shellcheck (using arguments -xa, in the src/gdb directory to make sure ../bfd/development.sh is taken into account) before and after and observed that the number of lines/words/chars in the shellcheck output is identical. ] Build & tested on top of trunk. Also build on top of gdb-14-branch, and observed this in gdb/config.log: ... configure:25214: checking compiler flags for python code ... configure:25237: result: -fno-strict-aliasing -fwrapv -DNDEBUG ... Approved-By: Tom Tromey PR build/31099 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31099 --- gdb/configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gdb/configure.ac') diff --git a/gdb/configure.ac b/gdb/configure.ac index 43e5067..cbde370 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -57,6 +57,8 @@ LT_OUTPUT # necessary, set CXX_DIALECT to some -std=xxx switch. AX_CXX_COMPILE_STDCXX(17, , mandatory) +GDB_AC_COMMON + # Dependency checking. ZW_CREATE_DEPDIR ZW_PROG_COMPILER_DEPENDENCIES([CC]) @@ -1353,7 +1355,6 @@ AC_CHECK_FUNCS([getuid getgid \ setrlimit getrlimit posix_madvise waitpid \ use_default_colors]) AM_LANGINFO_CODESET -GDB_AC_COMMON # Check the return and argument types of ptrace. GDB_AC_PTRACE -- cgit v1.1