无法在 Solaris 的最新编译器中将 xercesc 与新的 c+11 标志一起使用

Cannot use xercesc with new c+11 flags in Solaris' newest compiler

使用 xerces-c-3.1.1 和 SolarisStudio12.5Beta-solaris-x86-bin(在 Solaris 10 上)。

./configure CXX=CC CC=cc CXXFLAGS="-std=c++11"
gmake
gmake check
results in 37 core dumps and the error messages
terminate called after throwing an instance of 'xercesc_3_1::EndOfEntityException'

a pstack on 1 of the core files show
core 'core_gs580w_XSerializerTest_132_10_1462965423_23542' of 23542:  /usr/local/src/xerces-c-3.1.3/tests/.libs/XSerializerTest -v=always pe
fdb5c925 _lwp_kill (1, 6) + 15
fdb03783 raise    (6) + 1f
fdae29f5 abort    (fdc725cc, 107, 8118140, fdbc3cd8, fedb04d0, fdc725cc) + cd
fdd71eb5 _ZN9__gnu_cxx27__verbose_terminate_handlerEv (1, 0, fdd6eb0b, fddb3468, 8114df0, 8045f00) + 175
fdd6eb17 ???????? (fdd71d40, 0, fdd6eb75, fdd6eba7, fdd6eb99, fddb3468)
fdd6ebb0 ???????? (8114df0, fedb04d0, fdd6eb75, fdd6ee0f, fecfa708, 807b0c0)
fdd6ee3e ???????? (8114e10, fed7d848, feb24d00, feb24aec, 8114db8, fe8f3468)
feb24bff _ZN11xercesc_3_19ReaderMgr9popReaderEv (80df840, 8045b14, 0, feb21a2c) + 11f
feb21a60 _ZN11xercesc_3_19ReaderMgr14skipPastSpacesEv (80df840, 0, 0, febf3911) + 40
febf3d4e _ZN11xercesc_3_110DTDScanner17scanExtSubsetDeclEbb (8045f00, 0, 1, 64) + 44e
feb09db0 _ZN11xercesc_3_112IGXMLScanner15scanDocTypeDeclEv (80df7b8, fec9dec8, fef90c18, feb512f1) + 1610
feb5154f _ZN11xercesc_3_110XMLScanner10scanPrologEv (80df7b8, 80e5c38, feb24700, 0) + 26f
feb0483f _ZN11xercesc_3_112IGXMLScanner12scanDocumentERKNS_11InputSourceE (80df7b8, 80e5c38, 807b0c0, feb4cb51) + 9f
feb4d0ad _ZN11xercesc_3_110XMLScanner12scanDocumentEPKt (80df7b8, 80e5c08, 807b0c0, feb4d96e) + 56d
feb4d9c4 _ZN11xercesc_3_110XMLScanner12scanDocumentEPKc (80df7b8, 8046d5c, feb98f00, 0) + 64
feb9500f _ZN11xercesc_3_117SAX2XMLReaderImpl5parseEPKc (80df500, 8046d5c, 1, 8046ca8) + af
0805e1d2 _Z8parseOnePN11xercesc_3_115BinOutputStreamEPKc (80dd6c0, 8046d5c, 807adf0, fdd2305c) + 112
0805dd70 _Z9parseCasePKc (8046d5c, 0, 3e8, 0) + b0
0805d8a6 main     (3, 8046bb0, 8046bc0) + be6
0805a932 _start   (3, 8046d18, 8046d52, 8046d5c, 0, 8046d69) + 72

从配置中删除 CXXFLAGS="-std=c++11" 会导致成功 "gmake check"

关于使 xerces-c 与 sun studio 12.5 和 c++11 一起工作的任何提示?

假设 Xerces 3.1.1 的构建过程与 Xerces 3.1.4 相同,Xerces 明确链接到标准 Solaris C++ 运行-time 库中。这是一个问题,因为指定 -std=c++11 causes Solaris Studio to use the g++ ABI and runtime.

这是编译 Xerces 3.1.4 的测试可执行文件之一的 ldd 输出,诚然在 Solaris 11 上:

bash-4.1$ ldd XSValueTest
    libxerces-c-3.1.so =>    /home/achenle/xerces/xerces-c-3.1.4/src/.libs/libxerces-c-3.1.so
    libpthread.so.1 =>   /lib/libpthread.so.1
    libcurl.so.3 =>  /usr/lib/libcurl.so.3
    libidn.so.11 =>  /usr/lib/libidn.so.11
    libsldap.so.1 =>     /usr/lib/libsldap.so.1
    libldap.so.5 =>  /usr/lib/libldap.so.5
    libsocket.so.1 =>    /lib/libsocket.so.1
    libnsl.so.1 =>   /lib/libnsl.so.1
    libgss.so.1 =>   /usr/lib/libgss.so.1
    libssl.so.1.0.0 =>   /lib/libssl.so.1.0.0
    libcrypto.so.1.0.0 =>    /lib/libcrypto.so.1.0.0
    libz.so.1 =>     /lib/libz.so.1
    libstdc++.so.6 =>    /opt/SUNWspro/lib/compilers/CC-gcc/lib/libstdc++.so.6
    libgcc_s.so.1 =>     /opt/SUNWspro/lib/compilers/CC-gcc/lib/libgcc_s.so.1
    librt.so.1 =>    /lib/librt.so.1
    libm.so.2 =>     /lib/libm.so.2
    libc.so.1 =>     /lib/libc.so.1
    libstatomic.so.1 =>  /opt/SUNWspro/lib/compilers/atomic/libstatomic.so.1
    libCstd.so.1 =>  /usr/lib/libCstd.so.1
    libCrun.so.1 =>  /usr/lib/libCrun.so.1
    libscf.so.1 =>   /lib/libscf.so.1
    libsasl.so.1 =>  /usr/lib/libsasl.so.1
    libmd.so.1 =>    /lib/libmd.so.1
    libnspr4.so =>   /usr/lib/mps/libnspr4.so
    libplc4.so =>    /usr/lib/mps/libplc4.so
    libnss3.so =>    /usr/lib/mps/libnss3.so
    libssl3.so =>    /usr/lib/mps/libssl3.so
    libmp.so.2 =>    /lib/libmp.so.2
    libuutil.so.1 =>     /lib/libuutil.so.1
    libgen.so.1 =>   /lib/libgen.so.1
    libnvpair.so.1 =>    /lib/libnvpair.so.1
    libsmbios.so.1 =>    /usr/lib/libsmbios.so.1
    libsoftcrypto.so.1 =>    /lib/libsoftcrypto.so.1
    libelf.so.1 =>   /lib/libelf.so.1
    libdl.so.1 =>    /lib/libdl.so.1
    libnssutil3.so =>    /usr/lib/mps/libnssutil3.so
    libplds4.so =>   /usr/lib/mps/libplds4.so
    libthread.so.1 =>    /lib/libthread.so.1
    libcryptoutil.so.1 =>    /lib/libcryptoutil.so.1

注意 libstdc++.so.6(g++ 运行时间)和 libCstd.so.1libCrun.so.1(标准 Solaris C++ 运行时间)的存在。

本文来自 "What's New" documentation on Solaris Studio 12.4:

Using C++11 Features

In Oracle Solaris Studio 12.4, the C++ compiler supports C++11, a new language and ABI (Application Binary Interface).

In C++ 11 mode, the CC compiler uses the g++ ABI and a version of the g++ runtime library that is supplied with Oracle Solaris Studio. For this release, version 4.8.2 of the g++ runtime library is used.

C++11 暗示使用 g++ ABI and runtime also applies to Solaris Studio 12.5:

A.2.88 –std=v

...

c++11

Selects C++ 11 dialect and g++ binary compatibility. It sets the __SUNPRO_CC_COMPAT preprocessor macro to 'G'.

但除了隐式链接的 g++ 运行time 之外,Xerces 在标准 Solaris C++ 运行time 中构建显式链接。