Page MenuHomePhabricator

DCMTK build fails with clang 7
Closed, ResolvedPublic

Description

I get this error when I try to build the MITK master on mac with clang 7:

[  2%] Building CXX object ofstd/tests/CMakeFiles/ofstd_tests.dir/tvariant.cc.o
In file included from /Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/tests/tvariant.cc:5:
In file included from /Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/ofvriant.h:375:
In file included from /Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/variadic/variant.h:19:
/Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/variadic/helpers.h:57:30: error: non-type template
      argument evaluates to -1, which cannot be narrowed to type 'unsigned long' [-Wc++11-narrowing]
: OFintegral_constant<size_t,-1> {};
                             ^
1 error generated.

The current snapshot used on the master is:

dcmtk-3.6.1_20161102.tar.gz

The next version compiles fine:

dcmtk-3.6.1_20170228.tar.gz

So, unless it has other problems, it would be good to upgrade.

Event Timeline

I am testing a PR with the latest master and ran into this again.

nolden added a subscriber: nolden.

I can reproduce this with clang 3.8.1 on debian. I'm working on a solution

@espak : what is the clang version of mac? "7" is probably some other numbering, since the latest official clang is 4.0 if I remember correctly

It reports this:

cklemt:niftk-debug mespak$ clang --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
cklemt:niftk-debug mespak$

@espak : and could you check the CMakeCache.txt of the DCMTK build in <MITK Build Folder>/ep/src/DCMTK-build? Options named like CXX11 or STL? If I just update DCMTK with the current configuration in MITK I get similar errors.

You remember well, but I do not know if this can be matched this to the official numbering.

//Flags used to enable C++11 support.
DCMTK_CXX11_FLAGS:STRING=-std=c++11

DCMTK_USE_CXX11_STL:BOOL=OFF

Shall I try to switch on the second?

I tried, but I get a different error:

Scanning dependencies of target dcmdata
In file included from /Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/tests/tvariant.cc:5:
/Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/ofvriant.h:61:23: error: requested alignment is less than minimum alignment of 4 for type 'first_alternative' (aka 'float')
        struct test { alignas(OFvariant_traits<Index+1,Alternatives...>::alignment()) first_alternative a; };
                      ^
/Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/ofvriant.h:61:16: note: in instantiation of member class 'test' requested here
        struct test { alignas(OFvariant_traits<Index+1,Alternatives...>::alignment()) first_alternative a; };
               ^
/Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/ofvriant.h:61:74: note: in instantiation of member function 'OFvariant_traits<1, float, bool>::alignment' requested here
        struct test { alignas(OFvariant_traits<Index+1,Alternatives...>::alignment()) first_alternative a; };
                                                                         ^
/Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/ofvriant.h:61:16: note: in instantiation of member class 'test' requested here
        struct test { alignas(OFvariant_traits<Index+1,Alternatives...>::alignment()) first_alternative a; };
               ^
/Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/ofvriant.h:316:21: note: in instantiation of member function 'OFvariant_traits<0, int, float, bool>::alignment' requested here
    alignas(traits::alignment()) std::uint8_t m_Content[traits::size()];
                    ^
/Users/mespak/src/mitk-debug/ep/src/DCMTK/ofstd/tests/tvariant.cc:60:31: note: in instantiation of template class 'OFvariant<int, float, bool>' requested here
    OFvariant<int,float,bool> v0( true );
                              ^
1 error generated.

Ok, this is interesting. For me (with clang 3.8.1) this configuration fails, but enabling CXX11_STL leads to a different problem. I'm in touch with the DCMTK team to find a working solution for this. They recently updated things in that area and will release them soon with a new official release. g

It seems that they fixed this other error already. This works for me:

diff --git a/CMakeExternals/DCMTK.cmake b/CMakeExternals/DCMTK.cmake
index 8b112c5..418b877 100644
--- a/CMakeExternals/DCMTK.cmake
+++ b/CMakeExternals/DCMTK.cmake
@@ -28,8 +28,9 @@ if(MITK_USE_DCMTK)
 
     ExternalProject_Add(${proj}
       LIST_SEPARATOR ${sep}
-      URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/dcmtk-3.6.1_20161102.tar.gz
-      URL_MD5 682e12cf52c405e79724be614545709f
+#      URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/dcmtk-3.6.1_20161102.tar.gz
+      URL http://dicom.offis.de/download/dcmtk/snapshot/dcmtk-3.6.1_20170228.tar.gz
+#      URL_MD5 682e12cf52c405e79724be614545709f
       PATCH_COMMAND ${PATCH_COMMAND} -N -p1 -i ${CMAKE_CURRENT_LIST_DIR}/DCMTK.patch
       CMAKE_GENERATOR ${gen}
       CMAKE_ARGS
@@ -37,7 +38,7 @@ if(MITK_USE_DCMTK)
          ${additional_args}
          "-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} ${DCMTK_CXX_FLAGS}"
          "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} ${DCMTK_C_FLAGS}"
-         -DDCMTK_USE_CXX11_STL:BOOL=OFF
+         -DDCMTK_USE_CXX11_STL:BOOL=ON
          -DDCMTK_WITH_DOXYGEN:BOOL=OFF
          -DDCMTK_WITH_ZLIB:BOOL=OFF # see bug #9894
          -DDCMTK_WITH_OPENSSL:BOOL=OFF # see bug #9894

Thanks!

Works for me as well (OSX 10.11). However, current MITK master does not include the changes to dcmtk-3.6.1_20170228.tar.gz yet, to which @espak is referring to.

Tested also with current DCMTK release 3.6.2, but compiling breaks on OSX.

This error is thrown when building DCMTK 3.6.2 release on OSX with latest CLang

mitk_build_xcode/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/variadic/helpers.h:57:30: error: non-type template argument evaluates to -1, which cannot be narrowed to type 'unsigned long' [-Wc++11-narrowing]

line 57 in helpers.h

: OFintegral_constant<size_t,-1> {};

This error is thrown when building DCMTK 3.6.2 release on OSX with latest CLang

mitk_build_xcode/ep/src/DCMTK/ofstd/include/dcmtk/ofstd/variadic/helpers.h:57:30: error: non-type template argument evaluates to -1, which cannot be narrowed to type 'unsigned long' [-Wc++11-narrowing]

line 57 in helpers.h

: OFintegral_constant<size_t,-1> {};

Seems you did not include @espak's suggestion:

-DDCMTK_USE_CXX11_STL:BOOL=ON

Should work with the 3.6.2 release, I will push a fix soon, in this task or in the generic Clang fixes

@reicht: but would be good if you could test 3.6.2 with STL ON on Mac, since STL implementations could differ

Pushed new branch T22775-dcmtk-update.

merged your branch to branch T23248-test-with-latest-master to trigger Jenkins Jobs.

DCMTK 3.6.2 builds on MacOS 10.13 without errors. @nolden, this task seems solved.

DCMTK 3.6.2 on Ubuntu 16 throws this error:

ubuntu1604/build_type/Debug/build/ep/src/DCMTK/config/tests/../math.cc:119:12:
  error: ‘::isinf’ has not been declared

       return ::isinf( d );
              ^

Does a DCMTK.patch file in MITKs CMakeExternal seems appropriate in this case?

Does a DCMTK.patch file in MITKs CMakeExternal seems appropriate in this case?

Please have a look at 095a478652a8 . I don't like the patch file anymore, so I created a specific version which is descibed in CMakeExternals/DCMTK.cmake . I will close this bug, please re-open if there are still issues