I have a project which uses C++17 features and includes the library toml11, which, as its name says, was build for C++11. A few months ago I got this project to build with gcc (with my makefile) and via pyroot / clang / cling. But when I came back to it, some OS update must’ve messed things up. After deleting a few files and fixing a few casts (std::string vs. TString vs. char*), it builds again with gcc. But I can’t get root / clang / cling to build it, even when I issue the commands from the root prompt rather than via pyroot. After loading all sorts of stuff, I get to loading the C++ code that uses toml11, and I get:
root [19] gROOT->LoadMacro( “src/VolumeMaker.cpp++” )
Info in TUnixSystem::ACLiC: creating shared library /home/aharel/sim/pw/geometry/./src/VolumeMaker_cpp.so
/home/aharel/programs/ROOT/6.22.02/etc//cling/std.modulemap:368:10: error: module ‘std.codecvt’ is incompatible with feature ‘header_existence’
module “codecvt” {
^
/usr/include/c++/9/bits/fs_path.h:40:10: note: submodule of top-level module ‘std’ implicitly imported here #include
^
root.exe: /home/aharel/downloads/programs/ROOT-sources/root-6.22.02/core/metacling/src/TCling.cxx:2255: virtual void TCling::RegisterModule(const char*, const char**, const char**, const char*, const char*, void (*)(), const FwdDeclArgsToKeepCollection_t&, const char**, Bool_t, Bool_t): Assertion `cling::Interpreter::kSuccess == compRes && “Payload code of a dictionary could not be parsed correctly.”’ failed.
Reading a bit, I see that codecvt has a complicated, compiler-dependent history in C++11 and C++17, and that “feature ‘header_existence’” is probably referring to the __has_include macro which is used in toml11 a few times. I also found Fail to compile root 6.20.04 on Fedora 32, and tried the patch that appears at its end. This caused a few more similar error to appear after the first one, about “module ‘std.bits/unique_ptr.h’ is incompatible with feature ‘header_existence’”.
Any ideas how to work around this compilation failure?
OK. So the setup is a bit more complicated, and I made an unnamed macro for that, whose last line is gROOT->LoadMacro( "src/VolumeMaker.cpp++" ). Then I did ROOTDEBUG=7 root.exe -l -b -q test_clang_failure.c >& test_clang_failure.out and basically got the same output as above.
BTW: before seeing your reply, I tried resolving the issue by commenting out the _has_include lines (after making sure they evaluate to true, of course). Oddly, the problem remained. Maybe there’s another way of using this ‘header_existence’ feature?
The output below is with the 3 “has_include” lines I found commented out. test_clang_failure.out.tgz (53.5 KB)