]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/build] Fix adding -DNDEBUG to python flags of release build
authorTom de Vries <tdevries@suse.de>
Thu, 30 Nov 2023 20:31:46 +0000 (21:31 +0100)
committerTom de Vries <tdevries@suse.de>
Thu, 30 Nov 2023 20:31:46 +0000 (21:31 +0100)
commitd5835df2eebf8e9cd3ae35b683c831c2a16a5269
tree59ea9bd1a82f8e289e4a96004fb724fc20ff1a23
parent946df73fa09e782b15f75fc82729bff6a00d2554
[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 <tom@tromey.com>
PR build/31099
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31099
gdb/configure
gdb/configure.ac