Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 2/2] Do not pass -DNDEBUG to Python compilations in development mode
Date: Sun, 16 Sep 2018 18:46:00 -0000	[thread overview]
Message-ID: <20180916184502.19617-3-tom@tromey.com> (raw)
In-Reply-To: <20180916184502.19617-1-tom@tromey.com>

The Python CFLAGS include -DNDEBUG.  This was apparently done
intentionally -- setting the flags is done manually because, according
to a comment, python-config passes too many things to the compiler
(which is true).

Per PR python/20445, this patch changes configure so that -DNDEBUG is
only used by release builds.  This probably doesn't have very much
effect in practice, but I did see that some Python headers use assert,
so perhaps it will give some safety.

Tested by rebuilding and re-running gdb.python/*.exp on x86-64 Fedora 28.

ChangeLog
2018-09-16  Tom Tromey  <tom@tromey.com>

	PR python/20445:
	* configure: Rebuild.
	* configure.ac: Conditionally use -DNDEBUG for Python.
---
 gdb/ChangeLog    | 6 ++++++
 gdb/configure    | 6 +++++-
 gdb/configure.ac | 6 +++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gdb/configure b/gdb/configure
index e011b77414b..2fb69a8eda6 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -10762,7 +10762,11 @@ $as_echo "#define HAVE_PYTHON 1" >>confdefs.h
   # would make the python-related objects be compiled differently from the
   # rest of GDB (e.g., -O2 and -fPIC).
   if test "${GCC}" = yes; then
-    tentative_python_cflags="-fno-strict-aliasing -DNDEBUG -fwrapv"
+    tentative_python_cflags="-fno-strict-aliasing -fwrapv"
+    # Python headers recommend -DNDEBUG, but it's unclear if that just
+    # refers to building Python itself.  In release mode, though, it
+    # doesn't hurt for the Python code in gdb to follow.
+    $development || tentative_python_cflags="tentative_python_cflags -DNDEBUG"
   fi
 
   if test "x${tentative_python_cflags}" != x; then
diff --git a/gdb/configure.ac b/gdb/configure.ac
index f658da84e32..0709b1ff720 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -965,7 +965,11 @@ if test "${have_libpython}" != no; then
   # would make the python-related objects be compiled differently from the
   # rest of GDB (e.g., -O2 and -fPIC).
   if test "${GCC}" = yes; then
-    tentative_python_cflags="-fno-strict-aliasing -DNDEBUG -fwrapv"
+    tentative_python_cflags="-fno-strict-aliasing -fwrapv"
+    # Python headers recommend -DNDEBUG, but it's unclear if that just
+    # refers to building Python itself.  In release mode, though, it
+    # doesn't hurt for the Python code in gdb to follow.
+    $development || tentative_python_cflags="tentative_python_cflags -DNDEBUG"
   fi
 
   if test "x${tentative_python_cflags}" != x; then
-- 
2.17.1


  reply	other threads:[~2018-09-16 18:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-16 18:45 [PATCH 0/2] two small configure patches Tom Tromey
2018-09-16 18:46 ` Tom Tromey [this message]
2018-09-17 18:19   ` [PATCH 2/2] Do not pass -DNDEBUG to Python compilations in development mode Joel Brobecker
2018-09-17 18:22     ` Tom Tromey
2018-09-17 19:53       ` Tom Tromey
2018-09-17 21:21         ` Joel Brobecker
2018-09-17 21:22           ` Tom Tromey
2018-09-16 18:46 ` [PATCH 1/2] Check for gmp when checking for mpfr Tom Tromey
2018-09-17 18:18   ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180916184502.19617-3-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox