Bug 225129

Summary: editors/openoffice-{4,devel}: fails to build with clang 6.0
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: FreeBSD Office Team <office>
Status: Closed FIXED    
Severity: Affects Only Me CC: truckman
Priority: --- Keywords: needs-patch
Version: LatestFlags: bugzilla: maintainer-feedback? (office)
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 224669    

Description Jan Beich freebsd_committer freebsd_triage 2018-01-13 08:34:41 UTC
FreeBSD -CURRENT plans to update base Clang to 6.0.0 soon. While testing this port failed to build.

vcl/unx/generic/app/wmadaptor.cxx:2525:85: error: non-constant-expression cannot be narrowed from type 'sal_Int32' (aka 'int') to 'unsigned long' in initializer list [-Wc++11-narrowing]
    XTextProperty aClientProp = { (unsigned char*)aWmClient.getStr(), XA_STRING, 8, aWmClient.getLength() };
                                                                                    ^~~~~~~~~~~~~~~~~~~~~
vcl/unx/generic/app/wmadaptor.cxx:2525:85: note: insert an explicit cast to silence this issue
    XTextProperty aClientProp = { (unsigned char*)aWmClient.getStr(), XA_STRING, 8, aWmClient.getLength() };
                                                                                    ^~~~~~~~~~~~~~~~~~~~~
                                                                                    static_cast<unsigned long>( )

connectivity/source/parse/PColumn.cxx:176:156: error: reinterpret_cast from 'nullptr_t' to 'sal_Bool *' (aka 'unsigned char *') is not allowed
        registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION),                            PROPERTY_ID_FUNCTION,                           0,  &m_bFunction,                       ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
                                                                                                                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
connectivity/source/parse/PColumn.cxx:177:171: error: reinterpret_cast from 'nullptr_t' to 'sal_Bool *' (aka 'unsigned char *') is not allowed
        registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AGGREGATEFUNCTION),           PROPERTY_ID_AGGREGATEFUNCTION,          0,  &m_bAggregateFunction,              ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
                                                                                                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
connectivity/source/parse/PColumn.cxx:178:159: error: reinterpret_cast from 'nullptr_t' to '::rtl::OUString *' is not allowed
        registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME),                           PROPERTY_ID_TABLENAME,                          0,  &m_aTableName,                      ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
                                                                                                                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
connectivity/source/parse/PColumn.cxx:179:156: error: reinterpret_cast from 'nullptr_t' to '::rtl::OUString *' is not allowed
        registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME),                            PROPERTY_ID_REALNAME,                           0,  &m_aRealName,                       ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
                                                                                                                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
connectivity/source/parse/PColumn.cxx:180:180: error: reinterpret_cast from 'nullptr_t' to 'sal_Bool *' (aka 'unsigned char *') is not allowed
        registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED),       PROPERTY_ID_DBASEPRECISIONCHANGED,      0,  &m_bDbasePrecisionChanged,  ::getCppuType(reinterpret_cast<sal_Bool*>(NULL)));
                                                                                                                                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
connectivity/source/parse/PColumn.cxx:181:176: error: reinterpret_cast from 'nullptr_t' to 'sal_Bool *' (aka 'unsigned char *') is not allowed
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSEARCHABLE),            PROPERTY_ID_ISSEARCHABLE,                       0,  &m_bIsSearchable,           ::getCppuType(reinterpret_cast< sal_Bool*>(NULL)));
                                                                                                                                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
connectivity/source/parse/PColumn.cxx:182:162: error: reinterpret_cast from 'nullptr_t' to '::rtl::OUString *' is not allowed
    registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_LABEL),                               PROPERTY_ID_LABEL,                              0,  &m_sLabel,                          ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
                                                                                                                                                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
connectivity/source/parse/PColumn.cxx:268:99: error: reinterpret_cast from 'nullptr_t' to 'sal_Bool *' (aka 'unsigned char *') is not allowed
        PropertyAttribute::READONLY,  const_cast< sal_Bool* >( &m_bAscending ),    ::getCppuType( reinterpret_cast< sal_Bool* >( NULL ) ) );
                                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
connectivity/source/parse/PColumn.cxx:270:103: error: reinterpret_cast from 'nullptr_t' to '::rtl::OUString *' is not allowed
        PropertyAttribute::READONLY,  const_cast< ::rtl::OUString* >( &m_sTableName ),  ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
                                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To reproduce:
$ poudriere jail -cj clang6-amd64 -a amd64 -v projects/clang600-import -m svn+https
$ poudriere bulk -Ctj clang6-amd64 editors/openoffice-4
Comment 1 Jan Beich freebsd_committer freebsd_triage 2018-01-13 08:43:51 UTC
Maybe use static_cast to fix an issue exposed by base r228918.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2018-01-13 09:00:40 UTC
-devel port is also affected

vcl/unx/headless/svptext.cxx:157:40: error: comparison between pointer and integer ('void *' and 'sal_Int32' (aka 'int'))
    if( rGlyphData.ExtDataRef().mpData != Format::NONE )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~
vcl/unx/gtk/a11y/atkutil.cxx:781:13: error: non-constant-expression cannot be narrowed from type 'guint' (aka 'unsigned int') to 'guint16' (aka 'unsigned short') in initializer list [-Wc++11-narrowing]
            type_query.class_size,
            ^~~~~~~~~~~~~~~~~~~~~
vcl/unx/gtk/a11y/atkutil.cxx:781:13: note: insert an explicit cast to silence this issue
            type_query.class_size,
            ^~~~~~~~~~~~~~~~~~~~~
            static_cast<guint16>()
vcl/unx/gtk/a11y/atkutil.cxx:787:13: error: non-constant-expression cannot be narrowed from type 'guint' (aka 'unsigned int') to 'guint16' (aka 'unsigned short') in initializer list [-Wc++11-narrowing]
            type_query.instance_size,
            ^~~~~~~~~~~~~~~~~~~~~~~~
vcl/unx/gtk/a11y/atkutil.cxx:787:13: note: insert an explicit cast to silence this issue
            type_query.instance_size,
            ^~~~~~~~~~~~~~~~~~~~~~~~
            static_cast<guint16>(   )
vcl/unx/gtk/a11y/atkwindow.cxx:294:13: error: non-constant-expression cannot be narrowed from type 'guint' (aka 'unsigned int') to 'guint16' (aka 'unsigned short') in initializer list [-Wc++11-narrowing]
            type_query.class_size,
            ^~~~~~~~~~~~~~~~~~~~~
vcl/unx/gtk/a11y/atkwindow.cxx:294:13: note: insert an explicit cast to silence this issue
            type_query.class_size,
            ^~~~~~~~~~~~~~~~~~~~~
            static_cast<guint16>()
vcl/unx/gtk/a11y/atkwindow.cxx:300:13: error: non-constant-expression cannot be narrowed from type 'guint' (aka 'unsigned int') to 'guint16' (aka 'unsigned short') in initializer list [-Wc++11-narrowing]
            type_query.instance_size,
            ^~~~~~~~~~~~~~~~~~~~~~~~
vcl/unx/gtk/a11y/atkwindow.cxx:300:13: note: insert an explicit cast to silence this issue
            type_query.instance_size,
            ^~~~~~~~~~~~~~~~~~~~~~~~
            static_cast<guint16>(   )
sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx:124:41: error: constant expression evaluates to 137 which cannot be narrowed to type 'Output_t' (aka 'char') [-Wc++11-narrowing]
    static const Output_t aHeader[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
                                        ^~~~
sdext/source/pdfimport/xpdfwrapper/pnghelper.cxx:124:41: note: insert an explicit cast to silence this issue
    static const Output_t aHeader[] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
                                        ^~~~
                                        static_cast<Output_t>( )
Comment 3 Don Lewis freebsd_committer freebsd_triage 2018-01-16 18:06:20 UTC
I think those errors go away with -std=c++98, however with that flag, I now see a number of errors like this:

In file included from /wrkdirs/usr/ports/editors/openoffice-4/work/aoo-4.1.5/main/basebmp/source/bitmapdevice.cxx:36:
In file included from ../inc/basebmp/colorblendaccessoradapter.hxx:27:
In file included from ../inc/basebmp/colortraits.hxx:30:
/usr/local/include/vigra/mathutil.hxx:172:1: error: no viable conversion from returned value of type 'unsigned long long' to function return type 'NumericTraits<unsigned long long>::Promote' (aka 'vigra::Error_NumericTraits_not_specialized_for_this_case')
VIGRA_DEFINE_SCALAR_DOT(unsigned long long)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/vigra/mathutil.hxx:166:61: note: expanded from macro 'VIGRA_DEFINE_SCALAR_DOT'
    inline NumericTraits<T>::Promote dot(T l, T r) { return l*r; }
                                                            ^~~
/usr/local/include/vigra/numerictraits.hxx:502:8: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'unsigned long long' to 'const vigra::Error_NumericTraits_not_specialized_for_this_case &' for 1st argument
struct Error_NumericTraits_not_specialized_for_this_case { };
       ^
Comment 4 Don Lewis freebsd_committer freebsd_triage 2018-01-16 19:00:42 UTC
-std=c++98 does not support long long, trying -std=gnu++98.
Comment 5 Don Lewis freebsd_committer freebsd_triage 2018-01-16 22:17:23 UTC
The build "succeeds" with -std=gnu++98, but I'm seeing these new errors:

cd ../../unxfbsdx.pro/lib && : &&     LD_LIBRARY_PATH=/wrkdirs/usr/ports/editors
/openoffice-4/work/aoo-4.1.5/main/solver/415/unxfbsdx.pro/lib${LD_LIBRARY_PATH:+
:${LD_LIBRARY_PATH}} /wrkdirs/usr/ports/editors/openoffice-4/work/aoo-4.1.5/main
/solver/415/unxfbsdx.pro/bin/uno \
                -ro uno_services.rdb -ro uno_types.rdb \
                -s com.sun.star.test.bridge.BridgeTest -- \
                com.sun.star.test.bridge.CppTestObject

creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory
creation of executable memory area failed: No such file or directory



 ### test succeeded!

They seem to come from main/bridges/source/cpp_uno/shared/vtablefactory.cxx as a result of mkstemp() failing.
Comment 6 Don Lewis freebsd_committer freebsd_triage 2018-01-18 04:33:12 UTC
The "creation of executable memory area failed: No such file or directory" errors appear to be caused by a recent poudriere change.  I can reproduce them with a copy of the jail that is older than the clang 6 upgrade.  mkstemp() is trying to create a scratch file under /nonexistent, which is ~nobody.  Poudriere was changed to run builds as nobody a while ago, but these errors are much more recent.
Comment 7 commit-hook freebsd_committer freebsd_triage 2018-01-18 07:31:43 UTC
A commit references this bug:

Author: truckman
Date: Thu Jan 18 07:31:31 UTC 2018
New revision: 459316
URL: https://svnweb.freebsd.org/changeset/ports/459316

Log:
  Fix editors/openoffice-4 build with clang 6.0.0 by compiling with
  -std=gnu++98 since that was the default for the compilers historically
  used for the build.  It turns out that -std=c++98 does not work
  because the vigra headers depend on LLONG_MAX and friends, which
  are not defined without the GNU extensions.

  Compensate for a recent poudriere change by overriding $HOME and
  setting it to /tmp if $HOME is not writeable.  Some of the test
  code run during the build wants to use mkstemp() to create temporary
  directories under $HOME, which does not work for the "nobody" user
  which points $HOME at /nonexistent.

  No PORTREVISION bump since this is a build fix and there is no
  change to the package.

  PR:		225129
  Reported by:	jbeich

Changes:
  head/editors/openoffice-4/Makefile
  head/editors/openoffice-4/files/patch-solenv_gbuild_platform_freebsd.mk
  head/editors/openoffice-4/files/patch-solenv_inc_unxfbsd.mk
Comment 8 commit-hook freebsd_committer freebsd_triage 2018-01-18 16:52:11 UTC
A commit references this bug:

Author: truckman
Date: Thu Jan 18 16:51:56 UTC 2018
New revision: 459363
URL: https://svnweb.freebsd.org/changeset/ports/459363

Log:
  Fix editors/openoffice-4 build with clang 6.0.0 by compiling with
  -std=gnu++98 since that was the default for the compilers historically
  used for the build.  It turns out that -std=c++98 does not work
  because the vigra headers depend on LLONG_MAX and friends, which
  are not defined without the GNU extensions.

  Compensate for a recent poudriere change by overriding $HOME and
  setting it to /tmp if $HOME is not writeable.  Some of the test
  code run during the build wants to use mkstemp() to create temporary
  directories under $HOME, which does not work for the "nobody" user
  which points $HOME at /nonexistent.

  No PORTREVISION bump since this is a build fix and there is no
  change to the package.

  PR:		225129
  Reported by:	jbeich

Changes:
  head/editors/openoffice-devel/Makefile
  head/editors/openoffice-devel/files/patch-solenv_gbuild_platform_freebsd.mk
  head/editors/openoffice-devel/files/patch-solenv_inc_unxfbsd.mk