openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Lewis <truck...@apache.org>
Subject Re: C++ standard when building OpenOffice
Date Tue, 05 Nov 2019 01:19:02 GMT
On  3 Nov, Don Lewis wrote:
> For much of our history, until fairly recently, the versions of gcc that
> we used defaulted to -std=gnu++98 when compiiling C++ code.
> 
> When FreeBSD on i386 and amd64 switched from gcc to clang, it also
> defaulted to -std=gnu++98.  Clang has been C++11 compliant from version
> 3.3 onwards.  Around the time of the switch, I added the
> -DHAVE_STL_INCLUDE_PATH compiler flag so that clang would use it's own
> STL include files instead of the boost TR1 includes.  Clang was
> perfectly happy using its own STL include files even though they were
> not part of C++98, only C++11.
> 
> Later on, when clang 6 changed the default to gnu++14, the build
> generated tons warning and some number of errors.  To work around this,
> I added the -std=gnu++98 compiler flag to force the old mode.
> 
> FreeBSD on powerpc still uses gcc and it recently came to my attention
> that the build was broken there.  The FreeBSD port of AOO to powerpc
> does not use -DHAVE_STL_INCLUDE_PATH, so it was falling back to the
> boost TR1 headers.  The FreeBSD port uses the system boost, and recent
> versions of boost have dropped TR1 support.  To work around that, I
> tried enabling -DHAVE_STL_INCLUDE_PATH to use the gcc C++ headers.  This
> failed badly because the gcc STL headers check to see if the compilation
> mode is C++11 or better and immediately error out of this is not the
> case.  Switching the compilation mode to c++11 results in the warning
> and error spew mentioned above.  I tried modifying the stlport headers
> to include the gcc TR1 headers in gnu++98 mode.  That worked better, but
> I still got some mysterious C++ errors that I was not able to figure
> out.  My next attempt will be to try the boost non-TR1 headers.
> 
> Turning to Linux as a stepping stone, I've notice the build warning
> spewage on recent Linux distributions, such as Debian 9, that have newer
> versions of gcc.  By using the patch below, I was able to reduce the
> size of the build log for trunk from 1354815 lines to 359998 lines.  I
> think the extra compiler defines are required because the compiler
> detection code in our bundled version of boost is too old to figure out
> what to do with new gcc in gnu++98 mode.
> 
> One of the largest contributors to the warnings is std::auto_ptr.  This
> is deprecated in C++11 and is totally removed in C++17.  The new way is
> to use std::unique_ptr, but that wasn't available before C++11.  We
> can't fix our code for this until we are totally off the old toolchains,
> which means after we have abandoned CentOS 6 and earlier as well as
> Visual Studio earlier than 2015.
> 
> Once our code has been converted to C++11, then I think we might be able
> to deorbit the boost and stlport modules and just use the compiler
> includes directly.
> 
> diff --git a/main/solenv/gbuild/platform/linux.mk b/main/solenv/gbuild/platform/linux.mk
> index 3f35f2a3ce..0ffaf1a84f 100644
> --- a/main/solenv/gbuild/platform/linux.mk
> +++ b/main/solenv/gbuild/platform/linux.mk
> @@ -89,6 +89,10 @@ gb_CXXFLAGS := \
>  	-fuse-cxa-atexit \
>  	-fvisibility-inlines-hidden \
>  	-fvisibility=hidden \
> +	-std=gnu++98 \
> +	-DBOOST_NO_CXX11_VARIADIC_TEMPLATES \
> +	-DBOOST_NO_CXX11_RVALUE_REFERENCES \
> +	-DBOOST_NO_CXX11_STATIC_ASSERT \
>  	-pipe \
>  
>  ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
> diff --git a/main/solenv/inc/unxlng.mk b/main/solenv/inc/unxlng.mk
> index afaa50a0e5..060ee5976c 100644
> --- a/main/solenv/inc/unxlng.mk
> +++ b/main/solenv/inc/unxlng.mk
> @@ -77,7 +77,7 @@ CFLAGSENABLESYMBOLS=-g # was temporarily commented out, reenabled before
Beta
>  .ENDIF
>  
>  # flags for the C++ Compiler
> -CFLAGSCC= -pipe $(ARCH_FLAGS)
> +CFLAGSCC= -pipe $(ARCH_FLAGS) -std=gnu++98 -DBOOST_NO_CXX11_VARIADIC_TEMPLATES -DBOOST_NO_CXX11_RVALUE_REFERENCES
-DBOOST_NO_CXX11_STATIC_ASSERT
>  # Flags for enabling exception handling
>  .IF "$(COM)"=="CLANG"
>  CFLAGSEXCEPTIONS=-fexceptions

If I fix the compiler feature detection code in boost, then the changes
needed to always build in gnu++98 mode on Linux are pretty trivial:

diff --git a/main/boost/boost_1_55_0.patch b/main/boost/boost_1_55_0.patch
index 6cec7bb358..df9b8ec8e0 100644
--- a/main/boost/boost_1_55_0.patch
+++ b/main/boost/boost_1_55_0.patch
@@ -328,22 +328,34 @@ diff -ur misc/boost_1_55_0/boost/unordered/detail/unique.hpp misc/build/boost_1_
          ////////////////////////////////////////////////////////////////////////
 diff -ur misc/boost_1_55_0/boost/config/compiler/gcc.hpp misc/build/boost_1_55_0/boost/config/compiler/gcc.hpp
 --- misc/boost_1_55_0/boost/config/compiler/gcc.hpp	2013-09-17 09:55:51.000000000 -0700
-+++ misc/build/boost_1_55_0/boost/config/compiler/gcc.hpp	2016-09-02 19:15:48.775411000 -0700
-@@ -137,7 +137,7 @@
++++ misc/build/boost_1_55_0/boost/config/compiler/gcc.hpp	2019-11-04 09:59:20.741944674 -0800
+@@ -137,14 +137,18 @@
  
  // C++0x features in 4.3.n and later
  //
 -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
-+#if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) && defined(__GXX_EXPERIMENTAL_CXX0X__))
|| (__GNUC__ > 6) || (__GNUC__ == 6 && __GNUC_MINOR__ > 0)
++#if ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2)) && defined(__GXX_EXPERIMENTAL_CXX0X__))
|| (__cplusplus >= 201103L)
  // C++0x features are only enabled when -std=c++0x or -std=gnu++0x are
  // passed on the command line, which in turn defines
  // __GXX_EXPERIMENTAL_CXX0X__.
-@@ -153,7 +153,7 @@
+ #  define BOOST_HAS_DECLTYPE
+ #  define BOOST_HAS_RVALUE_REFS
+ #  define BOOST_HAS_STATIC_ASSERT
+-#  define BOOST_HAS_VARIADIC_TMPL
++#  if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))
++#    define BOOST_HAS_VARIADIC_TMPL
++#  else
++#    define BOOST_NO_CXX11_VARIADIC_TEMPLATES
++#  endif
+ #else
+ #  define BOOST_NO_CXX11_DECLTYPE
+ #  define BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS
+@@ -153,7 +157,7 @@
  
  // Variadic templates compiler:
  //   http://www.generic-programming.org/~dgregor/cpp/variadic-templates.html
 -#  if defined(__VARIADIC_TEMPLATES) || (__GNUC__ > 4) || ((__GNUC__ == 4) &&
(__GNUC_MINOR__ >= 4) && defined(__GXX_EXPERIMENTAL_CXX0X__))
-+#  if defined(__VARIADIC_TEMPLATES) || ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__
> 2)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (__GNUC__ > 6) || (__GNUC__
== 6 && __GNUC_MINOR__ > 0)
++#  if defined(__VARIADIC_TEMPLATES)
  #    define BOOST_HAS_VARIADIC_TMPL
  #  else
  #    define BOOST_NO_CXX11_VARIADIC_TEMPLATES
diff --git a/main/solenv/gbuild/platform/linux.mk b/main/solenv/gbuild/platform/linux.mk
index 3f35f2a3ce..02b8830a39 100644
--- a/main/solenv/gbuild/platform/linux.mk
+++ b/main/solenv/gbuild/platform/linux.mk
@@ -89,6 +89,7 @@ gb_CXXFLAGS := \
 	-fuse-cxa-atexit \
 	-fvisibility-inlines-hidden \
 	-fvisibility=hidden \
+	-std=gnu++98 \
 	-pipe \
 
 ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE)
diff --git a/main/solenv/inc/unxlng.mk b/main/solenv/inc/unxlng.mk
index afaa50a0e5..32b88bc91d 100644
--- a/main/solenv/inc/unxlng.mk
+++ b/main/solenv/inc/unxlng.mk
@@ -77,7 +77,7 @@ CFLAGSENABLESYMBOLS=-g # was temporarily commented out, reenabled before
Beta
 .ENDIF
 
 # flags for the C++ Compiler
-CFLAGSCC= -pipe $(ARCH_FLAGS)
+CFLAGSCC= -pipe $(ARCH_FLAGS) -std=gnu++98
 # Flags for enabling exception handling
 .IF "$(COM)"=="CLANG"
 CFLAGSEXCEPTIONS=-fexceptions
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@openoffice.apache.org
For additional commands, e-mail: dev-help@openoffice.apache.org


Mime
View raw message