Blob Blame Raw
From d88bf0eb80e2531a8017de4efd4eb02f1e3081ec Mon Sep 17 00:00:00 2001
From: Dylan Baker <dylan@pnwbakers.com>
Date: Mon, 25 Mar 2019 11:35:18 -0700
Subject: [PATCH] compilers: n_debug=if-release and buildtype=plain should not
 enable assertions

It's a bit odd that it doesn't, and has resulted in bugs in distro
packaging.

Fixes #5141
---
 docs/markdown/snippets/debug-if-release-plain.md | 4 ++++
 mesonbuild/compilers/compilers.py                | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 docs/markdown/snippets/debug-if-release-plain.md

diff --git a/docs/markdown/snippets/debug-if-release-plain.md b/docs/markdown/snippets/debug-if-release-plain.md
new file mode 100644
index 00000000..013e6c83
--- /dev/null
+++ b/docs/markdown/snippets/debug-if-release-plain.md
@@ -0,0 +1,4 @@
+## n_debug=if-release and buildtype=plain means no asserts
+
+Previously if this combination was used then assertions were enabled,
+which is fairly surprising behavior.
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index da029806..66195dc1 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -510,7 +510,7 @@ def get_base_compile_args(options, compiler):
     try:
         if (options['b_ndebug'].value == 'true' or
                 (options['b_ndebug'].value == 'if-release' and
-                 options['buildtype'].value == 'release')):
+                 options['buildtype'].value in {'release', 'plain'})):
             args += ['-DNDEBUG']
     except KeyError:
         pass
-- 
2.21.0