summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-14 15:45:45 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-05-16 09:05:13 +0200
commit392f87b099509d0c0f5e553ae1c5970dca9dc235 (patch)
tree2577dcad211da4b26eca1265078daf7a74777386
parentstd::stable_sort() where libc++ debug mode breaks a unittest (diff)
downloadcore-392f87b099509d0c0f5e553ae1c5970dca9dc235.tar.gz
core-392f87b099509d0c0f5e553ae1c5970dca9dc235.zip
enable libc++ debug mode again if available
Now includes a configure check for the std::to_string() crash. Change-Id: I45c3b804b7a1ff5f6520f7bdf772497f72ddee47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134338 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--config_host.mk.in1
-rw-r--r--configure.ac28
-rw-r--r--solenv/gbuild/platform/com_GCC_defs.mk4
3 files changed, 33 insertions, 0 deletions
diff --git a/config_host.mk.in b/config_host.mk.in
index 4d1a98967551..df8205e8ad1d 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -305,6 +305,7 @@ export HAVE_GNUMAKE_FILE_FUNC=@HAVE_GNUMAKE_FILE_FUNC@
export HAVE_LD_BSYMBOLIC_FUNCTIONS=@HAVE_LD_BSYMBOLIC_FUNCTIONS@
export HAVE_LD_HASH_STYLE=@HAVE_LD_HASH_STYLE@
export HAVE_LIBCPP=@HAVE_LIBCPP@
+export HAVE_LIBCPP_DEBUG=@HAVE_LIBCPP_DEBUG@
export HAVE_LIBSTDCPP=@HAVE_LIBSTDCPP@
export HAVE_POSIX_FALLOCATE=@HAVE_POSIX_FALLOCATE@
export HAVE_WDEPRECATED_COPY_DTOR=@HAVE_WDEPRECATED_COPY_DTOR@
diff --git a/configure.ac b/configure.ac
index 2c65a1200f69..2f0f5a574ed6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7419,6 +7419,34 @@ AC_LANG_POP([C++])
AC_SUBST([HAVE_LIBSTDCPP])
AC_SUBST([HAVE_LIBCPP])
+HAVE_LIBCPP_DEBUG=
+if test -n "$HAVE_LIBCPP" -a -n "$ENABLE_DBGUTIL"; then
+ # Libc++ supports debug mode only if built for it, Mac libc++ isn't,
+ # and there would be undefined references to debug functions.
+ # Moreover std::to_string() has a bug (https://reviews.llvm.org/D125184).
+ AC_MSG_CHECKING([if libc++ has a usable debug mode])
+ AC_LANG_PUSH([C++])
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#define _LIBCPP_DEBUG 1
+#include <string>
+#include <vector>
+int foo(const std::vector<int>& v) { return *v.begin(); }
+int main()
+{
+ std::vector<int> v{ 1, 2 };
+ std::string s = "xxxxxxxxxxxxxxxxxxxxxxxxx" + std::to_string(10);
+ return (foo(v) + s.size()) != 0 ? 0 : 1;
+}
+]])],
+ [AC_MSG_RESULT(yes)
+ HAVE_LIBCPP_DEBUG=1
+ ],
+ [AC_MSG_RESULT(no)]
+ )
+ AC_LANG_POP([C++])
+fi
+AC_SUBST([HAVE_LIBCPP_DEBUG])
+
dnl ===================================================================
dnl Check for gperf
dnl ===================================================================
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk
index c7cc1c3ef577..c2db27243457 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -53,6 +53,10 @@ gb_COMPILERDEFS := \
ifeq ($(gb_ENABLE_DBGUTIL),$(true))
ifneq ($(HAVE_LIBSTDCPP),)
gb_COMPILERDEFS_STDLIB_DEBUG = -D_GLIBCXX_DEBUG
+else
+ifneq ($(HAVE_LIBCPP_DEBUG),)
+gb_COMPILERDEFS_STDLIB_DEBUG = -D_LIBCPP_DEBUG=1
+endif
endif
gb_COMPILERDEFS += $(gb_COMPILERDEFS_STDLIB_DEBUG)
endif