diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-06-28 16:57:14 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-06-29 10:08:25 +0200 |
commit | 7e30d784025d2c36c85d8f3defc7740ef8a2fe5a (patch) | |
tree | 445d1705627231662c39c2b23befabd9c0def42f /external | |
parent | 2cf8c1d10e719a13afa6a5d9362a60f80e4318ed (diff) |
Adapt to LLVM 15 trunk libc++ dropping std::unary_/binary_function
...for C++17 and beyond with
<https://github.com/llvm/llvm-project/commit/681cde7dd8b5613dbafc9ca54e0288477f946be3>
"[libc++] Complete the implementation of N4190". (Unless explicitly opted-in
with _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION. This is similar to the
MSVC standard library needing _HAS_AUTO_PTR_ETC=1 to enable those zombie
functions for quite some time now. Only libstdc++ still supports them
unconditionally.)
Most uses of those zombie functions across LibreOffice itself and the bundled
external/* are indirectly within Boost include files. And many (but not all) of
those Boost include files only use those zombie functions conditionally, based
on BOOST_NO_CXX98_FUNCTION_BASE. For the (Dinkumware-derived) MSVC standard
library, workdir/UnpackedTarball/boost/boost/config/stdlib/dinkumware.hpp
already defined BOOST_NO_CXX98_FUNCTION_BASE. So add a patch to define that
also in workdir/UnpackedTarball/boost/boost/config/stdlib/libcpp.hpp (for all of
C++11 and beyond, even if those functions were still available as deprecated in
C++11 and C++14, but which shouldn't make a difference with our C++17 baseline
anyway; only make sure that things still work if those Boost include files ever
get used by code built with gb_CXX03FLAGS). (Patching our bundled
external/boost of course doesn't help when building with such a new libc++ and
--with-system-boost against an unpatched Boost, but lets consider that "not my
problem". Also, one could always use a sledgehammer like passing
CPPFLAGS=-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION into gbuild in
such a case.)
Then there are two places that include boost/multi_array.hpp, which indirectly
includes workdir/UnpackedTarball/boost/boost/functional.hpp, which still uses
those zombie functions for non-MSVC builds (at least in the bundled
Boost 1.79.0). Lets do a targeted
_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION in those cases.
(Alternatively, we could patch
workdir/UnpackedTarball/boost/boost/functional.hpp. Also, I decided to make
loplugin:reservedid support the new suppression mechanism, rather than extending
its existing ignorelist even further.)
And then there is external/clucene using those zombie functions even outside of
a Boost include file, so extend the existing hack there that was already needed
for MSVC. (And adapt the accompanying comment: For one, we are unconditionally
"in C++17 mode" by now. And for another, the exact places where
external/clucene uses those functions have apparently changed over time.)
Change-Id: Id0eec3bedcfddae86b16d33c02c7b5d3b3f8a16f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136579
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/boost/UnpackedTarball_boost.mk | 2 | ||||
-rw-r--r-- | external/boost/libc++.patch.0 | 12 | ||||
-rw-r--r-- | external/clucene/Library_clucene.mk | 10 | ||||
-rw-r--r-- | external/libmspub/ExternalProject_libmspub.mk | 10 |
4 files changed, 31 insertions, 3 deletions
diff --git a/external/boost/UnpackedTarball_boost.mk b/external/boost/UnpackedTarball_boost.mk index 91a0e264a926..384782f586f0 100644 --- a/external/boost/UnpackedTarball_boost.mk +++ b/external/boost/UnpackedTarball_boost.mk @@ -31,6 +31,8 @@ boost_patches += windows-no-utf8-locales.patch.0 boost_patches += msvc2017.patch.0 +boost_patches += libc++.patch.0 + $(eval $(call gb_UnpackedTarball_UnpackedTarball,boost)) $(eval $(call gb_UnpackedTarball_set_tarball,boost,$(BOOST_TARBALL))) diff --git a/external/boost/libc++.patch.0 b/external/boost/libc++.patch.0 new file mode 100644 index 000000000000..f912e6cdb6c7 --- /dev/null +++ b/external/boost/libc++.patch.0 @@ -0,0 +1,12 @@ +--- boost/config/stdlib/libcpp.hpp ++++ boost/config/stdlib/libcpp.hpp +@@ -167,5 +167,9 @@ + #if !defined(BOOST_NO_CXX14_HDR_SHARED_MUTEX) && (_LIBCPP_VERSION < 5000) + # define BOOST_NO_CXX14_HDR_SHARED_MUTEX + #endif ++ ++#if __cplusplus >= 201103 ++# define BOOST_NO_CXX98_FUNCTION_BASE ++#endif + + // --- end --- diff --git a/external/clucene/Library_clucene.mk b/external/clucene/Library_clucene.mk index c6f2895501d6..e837f9f64fb6 100644 --- a/external/clucene/Library_clucene.mk +++ b/external/clucene/Library_clucene.mk @@ -31,11 +31,17 @@ $(eval $(call gb_Library_add_defs,clucene,\ -Dclucene_contribs_lib_EXPORTS \ )) -# Needed when building against MSVC in C++17 mode, as -# workdir/UnpackedTarball/clucene/src/core/CLucene/util/Equators.h uses std::binary_function: +# Needed when building against either libc++ or MSVC's standard library (including clang-cl builds), +# as e.g. workdir/UnpackedTarball/clucene/src/core/CLucene/util/_Arrays.h uses std::binary_function: +ifeq ($(HAVE_LIBCPP),TRUE) +$(eval $(call gb_Library_add_defs,clucene, \ + -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION \ +)) +else ifeq ($(COM),MSC) $(eval $(call gb_Library_add_defs,clucene, \ -D_HAS_AUTO_PTR_ETC=1 \ )) +endif ifeq ($(OS),LINUX) $(eval $(call gb_Library_add_libs,clucene,\ diff --git a/external/libmspub/ExternalProject_libmspub.mk b/external/libmspub/ExternalProject_libmspub.mk index f84e5c9b2214..7e7153e75416 100644 --- a/external/libmspub/ExternalProject_libmspub.mk +++ b/external/libmspub/ExternalProject_libmspub.mk @@ -22,6 +22,14 @@ $(eval $(call gb_ExternalProject_use_externals,libmspub,\ zlib \ )) +libmspub_CPPFLAGS := $(CPPFLAGS) $(ICU_UCHAR_TYPE) $(BOOST_CPPFLAGS) +# Needed when workdir/UnpackedTarball/libmspub/src/lib/MSPUBCollector.cpp includes Boost 1.79.0 +# boost/multi_array.hpp, which indirectly includes +# workdir/UnpackedTarball/boost/boost/functional.hpp using std::unary_/binary_function: +ifeq ($(HAVE_LIBCPP),TRUE) +libmspub_CPPFLAGS += -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION +endif + $(call gb_ExternalProject_get_state_target,libmspub,build) : $(call gb_Trace_StartRange,libmspub,EXTERNAL) $(call gb_ExternalProject_run,build,\ @@ -37,7 +45,7 @@ $(call gb_ExternalProject_get_state_target,libmspub,build) : --disable-weffc \ $(if $(verbose),--disable-silent-rules,--enable-silent-rules) \ CXXFLAGS="$(gb_CXXFLAGS) $(call gb_ExternalProject_get_build_flags,libmspub)" \ - CPPFLAGS="$(CPPFLAGS) $(ICU_UCHAR_TYPE) $(BOOST_CPPFLAGS)" \ + CPPFLAGS="$(libmspub_CPPFLAGS)" \ LDFLAGS="$(call gb_ExternalProject_get_link_flags,libmspub)" \ $(gb_CONFIGURE_PLATFORMS) \ && $(MAKE) \ |