CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
pmattern
Posts: 18
Joined: Tue, 2016-11-08, 13:18

CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#1 Post by pmattern »

Setting CMake variable DCMTK_USE_CXX11_STL is triggering FTBFS compiling recent commits on Arch Linux.

Problem is affecting 7872b1c and snapshot 3.6.1_20161102 but didn't affect e. g. 2b6c548 or snapshot 3.6.1_20160630 when these were the most recent versions of branch master and snapshot respectively.
I do not know whether this option is still meant to work in the first place or was deprecated in the meantime. If so the CMake output should be modified as it states
Info: Your compiler supports C++11. You may enable C++11 features via "DCMTK_USE_CXX11_STL" to create a C++11 build of DCMTK."
when the variable is not set on a system providing the necessary prerequisites.

Output of make when failing reads

Code: Select all

/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:63:5: error: body of constexpr function 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 2ul; Alternative0 = bool; Alternatives = {}; std::size_t = long unsigned int]' not a return-statement
                }
                ^
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h: In instantiation of 'struct OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 1ul; Alternative0 = float; Alternatives = {bool}; std::size_t = long unsigned int]::test':
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:61:108:   required from 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 1ul; Alternative0 = float; Alternatives = {bool}; std::size_t = long unsigned int]'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:61:83:   required from 'struct OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 0ul; Alternative0 = int; Alternatives = {float, bool}; std::size_t = long unsigned int]::test'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:61:108:   required from 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 0ul; Alternative0 = int; Alternatives = {float, bool}; std::size_t = long unsigned int]'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:316:30:   required from 'class OFvariant<int, float, bool>'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/tests/tvariant.cc:60:33:   required from here
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:61:105: error: requested alignment is not an integer constant
         struct test { alignas(OFvariant_traits<Index+1,Alternatives...>::alignment()) first_alternative a; };
                                                                                                        ^
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h: In instantiation of 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 1ul; Alternative0 = float; Alternatives = {bool}; std::size_t = long unsigned int]':
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:61:83:   required from 'struct OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 0ul; Alternative0 = int; Alternatives = {float, bool}; std::size_t = long unsigned int]::test'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:61:108:   required from 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 0ul; Alternative0 = int; Alternatives = {float, bool}; std::size_t = long unsigned int]'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:316:30:   required from 'class OFvariant<int, float, bool>'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/tests/tvariant.cc:60:33:   required from here
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:63:5: error: body of constexpr function 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 1ul; Alternative0 = float; Alternatives = {bool}; std::size_t = long unsigned int]' not a return-statement
                }
                ^
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h: In instantiation of 'struct OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 0ul; Alternative0 = int; Alternatives = {float, bool}; std::size_t = long unsigned int]::test':
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:61:108:   required from 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 0ul; Alternative0 = int; Alternatives = {float, bool}; std::size_t = long unsigned int]'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:316:30:   required from 'class OFvariant<int, float, bool>'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/tests/tvariant.cc:60:33:   required from here
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:61:105: error: requested alignment is not an integer constant
         struct test { alignas(OFvariant_traits<Index+1,Alternatives...>::alignment()) first_alternative a; };
                                                                                                    ^
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h: In instantiation of 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 0ul; Alternative0 = int; Alternatives = {float, bool}; std::size_t = long unsigned int]':
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:316:30:   required from 'class OFvariant<int, float, bool>'
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/tests/tvariant.cc:60:33:   required from here
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:63:5: error: body of constexpr function 'static constexpr std::size_t OFvariant_traits<Index, Alternative0, Alternatives ...>::alignment() [with long unsigned int Index = 0ul; Alternative0 = int; Alternatives = {float, bool}; std::size_t = long unsigned int]' not a return-statement
                   }
                   ^
In file included from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/tests/tvariant.cc:5:0:
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h: In instantiation of 'class OFvariant<int, float, bool>':
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/tests/tvariant.cc:60:33:   required from here
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofvriant.h:316:71: error: requested alignment is not an integer constant
     alignas(traits::alignment()) std::uint8_t m_Content[traits::size()];
                                                                      ^
make[2]: *** [ofstd/tests/CMakeFiles/ofstd_tests.dir/build.make:567: ofstd/tests/CMakeFiles/ofstd_tests.dir/tvariant.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:369: ofstd/tests/CMakeFiles/ofstd_tests.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 25%] Building CXX object oflog/libsrc/CMakeFiles/oflog.dir/cygwin32.cc.o
[ 25%] Building CXX object oflog/libsrc/CMakeFiles/oflog.dir/striconv.cc.o
[ 25%] Building CXX object oflog/libsrc/CMakeFiles/oflog.dir/strcloc.cc.o
[ 25%] Building CXX object oflog/libsrc/CMakeFiles/oflog.dir/strccloc.cc.o
[ 25%] Building CXX object oflog/libsrc/CMakeFiles/oflog.dir/unixsock.cc.o
[ 25%] Linking CXX static library ../../lib/liboflog.a
[ 25%] Built target oflog
make: *** [Makefile:139: all] Error 2

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#2 Post by Michael Onken »

Hi,

C++11 support was meant to work, so this is clearly a bug that we also found (too late). It will be resolved in the future.

Thank you for the report,
Michael

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#3 Post by Jan Schlamelcher »

As Michael stated, this seems to be a bug. These guys seem to have found the same one using clang, which gave some better error messages. To my understanding it is simply the case that I cannot define a struct inside a constexpr function prior to C++14 and the rest are probably consequential errors. I simply didn't know that and my compiler forgave me during all tests (which is strange since I'm also on Arch Linux, but who knows).

EDIT: it seems I didn't remember it correctly and only tested it with GCC-4.9.2 on our debian server. My Arch Linux gave me exaclty the same errors than yours. I have just pushed a fix for those problems to our internal testing branch, it will be provided tomorrow if it passes our nightly builds.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#4 Post by Jan Schlamelcher »

The fix is live, see commit #b7b5503b8e

pmattern
Posts: 18
Joined: Tue, 2016-11-08, 13:18

Re: CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#5 Post by pmattern »

Confirming the problem can no longer be seen as of b7b5503.

The fix does introduce some new warnings like

Code: Select all

/usr/local/peter/Tests/DCMTK/ArchLinux/dcmtk-git/src/dcmtk/ofstd/tests/tlimits.cc:61:63: warning: integer overflow in expression [-Woverflow]
         OFCHECK( OFstatic_cast( T, OFnumeric_limits<T>::max() + 1 ) == OFnumeric_limits<T>::min() );
/usr/local/peter/Tests/DCMTK/ArchLinux/dcmtk-git/src/dcmtk/ofstd/include/dcmtk/ofstd/oftest.h:483:15: note: in definition of macro 'OFCHECK'
         if (!(condition)) \
               ^~~~~~~~~

/usr/local/peter/Tests/DCMTK/ArchLinux/dcmtk-git/src/dcmtk/ofstd/tests/tlimits.cc:61:18: note: in expansion of macro 'OFstatic_cast'
         OFCHECK( OFstatic_cast( T, OFnumeric_limits<T>::max() + 1 ) == OFnumeric_limits<T>::min() );
                  ^~~~~~~~~~~~~
seen compiling b7b5503 or dd23149 on Arch Linux.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#6 Post by Jan Schlamelcher »

Thanks for confirming!

The warnings aren't new and also they can't be removed (potentially disabled at the scope via #pragma) since that is what is being tested there - how the compilier behaves regarding integer overflow and if it fits what is expected by the numeric limits.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#7 Post by Jan Schlamelcher »

I was able to suppress the warnings, see commit #8a79ba83b

pmattern
Posts: 18
Joined: Tue, 2016-11-08, 13:18

Re: CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#8 Post by pmattern »

Confirming the said warnings are gone both in 8a79ba8 and 0bf28e1.

FWIW in both commits warnings like the following can be seen

Code: Select all

[ 21%] Building CXX object ofstd/tests/CMakeFiles/ofstd_tests.dir/tstring.cc.o
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/oflog/libsrc/hierlock.cc: In destructor ‘dcmtk::log4cplus::HierarchyLocker::~HierarchyLocker()’:
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/oflog/libsrc/hierlock.cc:75:9: warning: throw will always call terminate() [-Wterminate]
         throw;
         ^~~~~
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/oflog/libsrc/hierlock.cc:75:9: note: in C++11 destructors default to noexcept
[ 21%] Building CXX object oflog/libsrc/CMakeFiles/oflog.dir/layout.cc.o
[...]
[ 68%] Building CXX object dcmrt/libsrc/CMakeFiles/dcmrt.dir/drtrpcs.cc.o
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc: In member function ‘void WlmFileSystemInteractionManager::DetermineWorklistFiles(OFVector<OFString>&)’:
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc:485:27: warning: ‘int readdir_r(DIR*, dirent*, dirent**)’ is deprecated [-Wdeprecated-declarations]
     for( int readResult = readdir_r( dirp, (struct dirent *)entryBuffer, &dp ) ; readResult == 0 && dp ; readResult = readdir_r( dirp, (struct dirent *)entryBuffer, &dp ) )
                           ^~~~~~~~~
In file included from /usr/include/features.h:368:0,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/os_defines.h:39,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/c++config.h:495,
                 from /usr/include/c++/6.2.1/climits:41,
                 from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofstdinc.h:197,
                 from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc:27:
/usr/include/dirent.h:189:12: note: declared here
 extern int __REDIRECT (readdir_r,
            ^
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc:485:78: warning: ‘int readdir_r(DIR*, dirent*, dirent**)’ is deprecated [-Wdeprecated-declarations]
     for( int readResult = readdir_r( dirp, (struct dirent *)entryBuffer, &dp ) ; readResult == 0 && dp ; readResult = readdir_r( dirp, (struct dirent *)entryBuffer, &dp ) )
                                                                              ^
In file included from /usr/include/features.h:368:0,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/os_defines.h:39,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/c++config.h:495,
                 from /usr/include/c++/6.2.1/climits:41,
                 from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofstdinc.h:197,
                 from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc:27:
/usr/include/dirent.h:189:12: note: declared here
 extern int __REDIRECT (readdir_r,
            ^
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc:485:119: warning: ‘int readdir_r(DIR*, dirent*, dirent**)’ is deprecated [-Wdeprecated-declarations]
     for( int readResult = readdir_r( dirp, (struct dirent *)entryBuffer, &dp ) ; readResult == 0 && dp ; readResult = readdir_r( dirp, (struct dirent *)entryBuffer, &dp ) )
                                                                                                                       ^~~~~~~~~
In file included from /usr/include/features.h:368:0,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/os_defines.h:39,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/c++config.h:495,
                 from /usr/include/c++/6.2.1/climits:41,
                 from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofstdinc.h:197,
                 from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc:27:
/usr/include/dirent.h:189:12: note: declared here
 extern int __REDIRECT (readdir_r,
            ^
/usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc:485:170: warning: ‘int readdir_r(DIR*, dirent*, dirent**)’ is deprecated [-Wdeprecated-declarations]
     for( int readResult = readdir_r( dirp, (struct dirent *)entryBuffer, &dp ) ; readResult == 0 && dp ; readResult = readdir_r( dirp, (struct dirent *)entryBuffer, &dp ) )
                                                                                                                                                                          ^
In file included from /usr/include/features.h:368:0,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/os_defines.h:39,
                 from /usr/include/c++/6.2.1/x86_64-pc-linux-gnu/bits/c++config.h:495,
                 from /usr/include/c++/6.2.1/climits:41,
                 from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/ofstd/include/dcmtk/ofstd/ofstdinc.h:197,
                 from /usr/local/peter/Tests/DCMTK/Projekt/dcmtk/dcmwlm/libsrc/wlfsim.cc:27:
/usr/include/dirent.h:189:12: note: declared here
 extern int __REDIRECT (readdir_r,
            ^
[ 68%] Building CXX object dcmrt/libsrc/CMakeFiles/dcmrt.dir/drtrpis.cc.o
I figure these don't indicate any real problem right now but may be worth having a look at as they may turn into some in the future.

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: CMake: FTBFS due to variable DCMTK_USE_CXX11_STL

#9 Post by Jan Schlamelcher »

As far as I know readdir_r is the reentrant alternative of readdir, which shall be used if it is available. We have a configure test for it, but it is not used in the code that leads to the warning. Reading here it seems that readdir_r was deprecated since readdir has become reentrant and readdir_r is therefore no longer needed. This will most likely not lead to problems if the configure test was used, since, even if readdir_r is removed in the future, our configure test will just fail and readdir will be used instead. So I think we should just get rid of the duplicated code and use OFStandard::searchDirectoryRecursively() instead, which already honors the configuration test's result. Perhaps the configure test should also be made to fail if readdir_r is deprecated, something like running it with

Code: Select all

-Werror=deprecated-declarations
.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest