summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-12-15 11:05:00 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-12-15 22:23:31 +0100
commitc5f6043b0f2c4cb521e8694dbf3dd355042fd704 (patch)
tree328fad1064ebe23c4feb485f0ec7ed05ecceb809
parentbe46bc5d20ad82be1d9c8513a83584ecee9edbc2 (diff)
Enable C++17 for clang-cl, too
Similar to libc++ in C++17 mode, some types like std::auto_ptr are indeed removed in C++17 mode by default, and need _HAS_AUTO_PTR_ETC=1 to be enabled (see <https://blogs.msdn.microsoft.com/vcblog/2017/12/08/c17-feature-removals- and-deprecations/>). Unlike libc++, also std::binary_function and std::unary_function are removed (and need the same _HAS_AUTO_PTR_ETC=1 to enable). So either set that flag to make external code build, or use patches (for external/mdds) to make externals' files included in LO proper still work there. Change-Id: I886cc0de8196255334ee03ec48cb4bc54d460afd Reviewed-on: https://gerrit.libreoffice.org/46514 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--compilerplugins/clang/reservedid.cxx1
-rw-r--r--configure.ac7
-rw-r--r--external/boost/StaticLibrary_boost_date_time.mk7
-rw-r--r--external/boost/StaticLibrary_boost_locale.mk3
-rw-r--r--external/clucene/Library_clucene.mk6
-rw-r--r--external/liborcus/Library_orcus-parser.mk6
-rw-r--r--external/liborcus/Library_orcus.mk6
-rw-r--r--external/mdds/UnpackedTarball_mdds.mk1
-rwxr-xr-xexternal/mdds/c++17.patch22
-rw-r--r--unotools/source/i18n/resmgr.cxx2
10 files changed, 58 insertions, 3 deletions
diff --git a/compilerplugins/clang/reservedid.cxx b/compilerplugins/clang/reservedid.cxx
index ad1dcece0037..82bbc7ea033c 100644
--- a/compilerplugins/clang/reservedid.cxx
+++ b/compilerplugins/clang/reservedid.cxx
@@ -69,6 +69,7 @@ void ReservedId::run() {
&& id != "_ATL_STATIC_REGISTRY"
// extensions/source/activex/StdAfx2.h
&& id != "_GLIBCXX_CDTOR_CALLABI"
+ && id != "_HAS_AUTO_PTR_ETC" // unotools/source/i18n/resmgr.cxx
&& id != "_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR" // unotools/source/i18n/resmgr.cxx
&& id != "_MAX_PATH" // Windows
&& id != "_POSIX_SOURCE"
diff --git a/configure.ac b/configure.ac
index 6645af1aab51..bd5f184f66ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6037,11 +6037,11 @@ libo_FUZZ_ARG_ENABLE(c++17,
)
CXXFLAGS_CXX11=
-if test "$COM" = MSC; then
+if test "$COM" = MSC -a "$COM_IS_CLANG" != TRUE; then
AC_MSG_CHECKING([whether $CXX supports C++11])
AC_MSG_RESULT(yes)
# MSVC supports (a subset of) CXX11 without any switch
-elif test "$GCC" = "yes"; then
+elif test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then
HAVE_CXX11=
AC_MSG_CHECKING([whether $CXX supports C++17, C++14, or C++11])
dnl But only use C++17 if the gperf that is being used knows not to emit
@@ -6052,6 +6052,9 @@ elif test "$GCC" = "yes"; then
my_flags="-std=gnu++17 -std=gnu++1z -std=c++17 -std=c++1z $my_flags"
fi
for flag in $my_flags; do
+ if test "$COM" = MSC; then
+ flag="-Xclang $flag"
+ fi
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $flag -Werror"
if test "$SYSTEM_LIBCMIS" = TRUE; then
diff --git a/external/boost/StaticLibrary_boost_date_time.mk b/external/boost/StaticLibrary_boost_date_time.mk
index ef97e25c8823..9f871ee164fe 100644
--- a/external/boost/StaticLibrary_boost_date_time.mk
+++ b/external/boost/StaticLibrary_boost_date_time.mk
@@ -18,6 +18,13 @@ $(eval $(call gb_StaticLibrary_add_defs,boost_date_time,\
-DBOOST_ALL_NO_LIB \
))
+# Needed when building against MSVC in C++17 mode, as
+# workdir/UnpackedTarball/boost/boost/numeric/conversion/detail/converter.hpp uses
+# std::unary_function:
+$(eval $(call gb_StaticLibrary_add_defs,boost_date_time, \
+ -D_HAS_AUTO_PTR_ETC=1 \
+))
+
$(eval $(call gb_StaticLibrary_use_external,boost_date_time,boost_headers))
$(eval $(call gb_StaticLibrary_set_generated_cxx_suffix,boost_date_time,cpp))
diff --git a/external/boost/StaticLibrary_boost_locale.mk b/external/boost/StaticLibrary_boost_locale.mk
index b6734d149c14..520131fb9174 100644
--- a/external/boost/StaticLibrary_boost_locale.mk
+++ b/external/boost/StaticLibrary_boost_locale.mk
@@ -18,9 +18,10 @@ $(eval $(call gb_StaticLibrary_add_defs,boost_locale,\
-DBOOST_ALL_NO_LIB -DBOOST_LOCALE_NO_WINAPI_BACKEND -DBOOST_LOCALE_NO_POSIX_BACKEND -DBOOST_USE_WINDOWS_H \
))
-# Needed when building against libc++ in C++17 mode, as Boost 1.65.1
+# Needed when building against MSVC resp. libc++ in C++17 mode, as Boost 1.65.1
# workdir/UnpackedTarball/boost/boost/locale/generator.hpp contains "std::auto_ptr<data> d;":
$(eval $(call gb_StaticLibrary_add_defs,boost_locale, \
+ -D_HAS_AUTO_PTR_ETC=1 \
-D_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR \
))
diff --git a/external/clucene/Library_clucene.mk b/external/clucene/Library_clucene.mk
index e0f04b6e2894..abc14d903f46 100644
--- a/external/clucene/Library_clucene.mk
+++ b/external/clucene/Library_clucene.mk
@@ -29,6 +29,12 @@ $(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:
+$(eval $(call gb_Library_add_defs,clucene, \
+ -D_HAS_AUTO_PTR_ETC=1 \
+))
+
# clucene is riddled with warnings... let's spare use
# the pointless spamming
$(eval $(call gb_Library_add_cxxflags,clucene,\
diff --git a/external/liborcus/Library_orcus-parser.mk b/external/liborcus/Library_orcus-parser.mk
index 4c2ca7f291db..83a4a2f48806 100644
--- a/external/liborcus/Library_orcus-parser.mk
+++ b/external/liborcus/Library_orcus-parser.mk
@@ -30,6 +30,12 @@ $(eval $(call gb_Library_add_defs,orcus-parser,\
-D__ORCUS_PSR_BUILDING_DLL \
))
+# Needed when building against MSVC in C++17 mode, as
+# workdir/UnpackedTarball/liborcus/include/orcus/global.hpp uses std::unary_function:
+$(eval $(call gb_Library_add_defs,orcus-parser, \
+ -D_HAS_AUTO_PTR_ETC=1 \
+))
+
$(eval $(call gb_Library_set_generated_cxx_suffix,orcus-parser,cpp))
$(eval $(call gb_Library_add_generated_exception_objects,orcus-parser,\
diff --git a/external/liborcus/Library_orcus.mk b/external/liborcus/Library_orcus.mk
index 9916f6fe5236..6457ec4afc0c 100644
--- a/external/liborcus/Library_orcus.mk
+++ b/external/liborcus/Library_orcus.mk
@@ -36,6 +36,12 @@ $(eval $(call gb_Library_add_defs,orcus,\
-D__ORCUS_XLS_XML \
))
+# Needed when building against MSVC in C++17 mode, as
+# workdir/UnpackedTarball/liborcus/src/liborcus/css_document_tree.cpp uses std::unary_function:
+$(eval $(call gb_Library_add_defs,orcus, \
+ -D_HAS_AUTO_PTR_ETC=1 \
+))
+
$(eval $(call gb_Library_use_libraries,orcus,\
orcus-parser \
))
diff --git a/external/mdds/UnpackedTarball_mdds.mk b/external/mdds/UnpackedTarball_mdds.mk
index c015f4c13f5a..93eb3e6214fd 100644
--- a/external/mdds/UnpackedTarball_mdds.mk
+++ b/external/mdds/UnpackedTarball_mdds.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_UnpackedTarball_set_tarball,mdds,$(MDDS_TARBALL)))
$(eval $(call gb_UnpackedTarball_set_patchlevel,mdds,0))
$(eval $(call gb_UnpackedTarball_add_patches,mdds,\
+ external/mdds/c++17.patch \
))
# vim: set noet sw=4 ts=4:
diff --git a/external/mdds/c++17.patch b/external/mdds/c++17.patch
new file mode 100755
index 000000000000..d96910f34e68
--- /dev/null
+++ b/external/mdds/c++17.patch
@@ -0,0 +1,22 @@
+--- include/mdds/multi_type_matrix.hpp
++++ include/mdds/multi_type_matrix.hpp
+@@ -149,7 +149,7 @@
+
+ private:
+ template<typename _Func>
+- struct walk_func : std::unary_function<typename store_type::const_iterator::value_type, void>
++ struct walk_func
+ {
+ _Func& m_func;
+ walk_func(_Func& func) : m_func(func) {}
+--- include/mdds/multi_type_vector.hpp
++++ include/mdds/multi_type_vector.hpp
+@@ -139,7 +139,7 @@
+ block& operator=(block);
+ };
+
+- struct element_block_deleter : public std::unary_function<void, const element_block_type*>
++ struct element_block_deleter
+ {
+ void operator() (const element_block_type* p)
+ {
diff --git a/unotools/source/i18n/resmgr.cxx b/unotools/source/i18n/resmgr.cxx
index 99b27cd7bbbf..ce5bc28f8896 100644
--- a/unotools/source/i18n/resmgr.cxx
+++ b/unotools/source/i18n/resmgr.cxx
@@ -23,6 +23,8 @@
#include <config_libcxx.h>
#if HAVE_LIBCXX && __cplusplus >= 201703L
#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
+#elif defined _MSC_VER && __cplusplus >= 201703L
+#define _HAS_AUTO_PTR_ETC 1
#endif
#include <config_folders.h>