From bbaeea65375219e6ae355db494794e9e12739cb4 Mon Sep 17 00:00:00 2001
From: Florian Schmaus <flow@cs.fau.de>
Date: Mon, 24 Jan 2022 12:13:27 +0100
Subject: [PATCH] [meson] Enable _GLIBCXX_DEBUG on debug builds

---
 meson.build       | 6 ++++++
 meson_options.txt | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/meson.build b/meson.build
index 71cb6c4a..2467cdc1 100644
--- a/meson.build
+++ b/meson.build
@@ -177,6 +177,12 @@ else
 	              check_anywhere_queue_while_stealing == 'true')
 endif
 
+is_debug_buildtype = get_option('buildtype').startswith('debug')
+libstdcxx_debug = get_option('libstdcxx_debug')
+if (libstdcxx_debug == 'auto' and is_debug_buildtype) or libstdcxx_debug == true
+  add_global_arguments('-D_GLIBCXX_DEBUG', language: 'cpp')
+endif
+
 # check io meson options consistency
 if get_option('io_single_uring')
 	if io_sqpoll_option == 'each' or io_sqpoll_option == 'numa'
diff --git a/meson_options.txt b/meson_options.txt
index 1b54e3de..8ee2e7cb 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -217,3 +217,10 @@ option(
   description: 'Memory ordering used for the lockless CQ algorithm',
   value: 'weak',
 )
+option(
+  'libstdcxx_debug',
+  type: 'combo',
+  choices: ['auto', 'true', 'false'],
+  description: 'Enable __GLIBCXX_DEBUG by defining it',
+  value: 'auto',
+)
-- 
GitLab