diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-04-30 21:27:20 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-05-01 08:40:12 +0200 |
commit | 6014f363a08f2edd6086cf30b3bbb913f1c621c6 (patch) | |
tree | f933ad4116b9430089da50177332445cfea17306 | |
parent | 5200a73627d13e2997f81b53f61e143e77e328ee (diff) |
improve support for using libc++ on Linux and for libc++ debug mode
It seems to run slightly faster in --enable-dbgutil mode and also
builds a bit faster (at least with Clang). But libc++ on Mac
isn't built with debug mode support.
Change-Id: Idf5dba9c4a56aba1f4163aa518a78d34b6837149
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133664
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r-- | config_host.mk.in | 2 | ||||
-rw-r--r-- | configure.ac | 23 | ||||
-rw-r--r-- | external/clucene/Library_clucene.mk | 1 | ||||
-rw-r--r-- | solenv/gbuild/platform/com_GCC_defs.mk | 4 | ||||
-rw-r--r-- | solenv/gbuild/platform/unxgcc.mk | 4 |
5 files changed, 34 insertions, 0 deletions
diff --git a/config_host.mk.in b/config_host.mk.in index 8d7fe3c12865..e129b28bfeee 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -304,6 +304,8 @@ export HAVE_GCC_STACK_CLASH_PROTECTION=@HAVE_GCC_STACK_CLASH_PROTECTION@ 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 cdef1a6507e5..c4e71a8a12ff 100644 --- a/configure.ac +++ b/configure.ac @@ -7371,6 +7371,7 @@ dnl =================================================================== AC_MSG_CHECKING([what the C++ library is]) HAVE_LIBSTDCPP= +HAVE_LIBCPP= AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <utility> @@ -7391,6 +7392,7 @@ foo bar [CPP_LIBRARY=LIBCPP cpp_library_name="LLVM libc++" AC_DEFINE([HAVE_LIBCXX]) + HAVE_LIBCPP=TRUE ], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <utility> @@ -7405,6 +7407,27 @@ foo bar AC_MSG_RESULT([$cpp_library_name]) 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 + AC_MSG_CHECKING([if libc++ is built with debug mode]) + AC_LANG_PUSH([C++]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#define _LIBCPP_DEBUG 1 +#include <vector> +int foo(const std::vector<int>& v) { return *v.begin(); } +]])], + [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 diff --git a/external/clucene/Library_clucene.mk b/external/clucene/Library_clucene.mk index 6f585f6f2bfa..c6f2895501d6 100644 --- a/external/clucene/Library_clucene.mk +++ b/external/clucene/Library_clucene.mk @@ -41,6 +41,7 @@ ifeq ($(OS),LINUX) $(eval $(call gb_Library_add_libs,clucene,\ -lm \ -ldl \ + -pthread \ )) endif 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 diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk index b98732030b32..b3388eec436a 100644 --- a/solenv/gbuild/platform/unxgcc.mk +++ b/solenv/gbuild/platform/unxgcc.mk @@ -47,6 +47,10 @@ gb_CFLAGS := \ ifneq ($(HAVE_LIBSTDCPP),) gb_CXX_LINKFLAGS := -pthread endif +# libc++ needs it too +ifneq ($(HAVE_LIBCPP),) +gb_CXX_LINKFLAGS := -pthread +endif gb_CXXFLAGS := \ $(gb_CXXFLAGS_COMMON) \ |