Module 'std.codecvt' is incompatible with feature 'header_existence'

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?


Please read tips for efficient and successful posting and posting code

_ROOT Version:6.22.02
_Platform:Ubuntu 20.04.2
_Compiler:Cling


Hi @harelamnon,

I am sure @vvassilev might already have some ideas on this. Otherwise, we could take a deeper look at it.

Cheers,
J.

Hi @harelamnon, can you attach the output of ROOTDEBUG=7 root.exe -l -b -q -e 'gROOT->LoadMacro( "src/VolumeMaker.cpp++" )'

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)

thanks for looking into it!

Thank you! Nothing seems overly suspicious to me. One thing we can try is adding this patch to root (v6-22-02) and rebuilding from scratch:

diff --git a/interpreter/cling/include/cling/std.modulemap b/interpreter/cling/include/cling/std.modulemap
index 6b9acf1140..39df34a62e 100644
--- a/interpreter/cling/include/cling/std.modulemap
+++ b/interpreter/cling/include/cling/std.modulemap
@@ -171,6 +171,11 @@ module "std" [system] {
     export *
     header "functional"
   }
+  module "filesystem" {
+    requires !header_existence
+    export *
+    header "filesystem"
+  }
   module "future" {
     export *
     header "future"

Thanks for the suggestion. Unfortunately, toml11 uses std::filesystem, so the conflict is still there:

/home/aharel/programs/ROOT/6.22.02/etc//cling/std.modulemap:175:10: error: module 'std.filesystem' is incompatible with feature 'header_existence'
  module "filesystem" {
         ^
/home/aharel/sim/pw/geometry/toml11/toml/parser.hpp:19:10: note: submodule of top-level module 'std' implicitly imported here
#include <filesystem>
         ^
/home/aharel/sim/pw/geometry/toml11/toml/parser.hpp:2114:53: error: no member named 'filesystem' in namespace 'std'
basic_value<Comment, Table, Array> parse(const std::filesystem::path& fpath)
                                               ~~~~~^
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.
Aborted (core dumped)
~

Hm… can you create a minimal reproducer for me to debug?

Hi. Actually, that was much easier than I expected.

#include <optional>
#include "toml11/toml.hpp"
std::optional<int> maybe_int( int i )
{
  if( i ) return std::nullopt;
  return i+1;
}

This is still with the simplified toml11 (I commented out the _has_include), and the hacked ```
std.modulemap

Gives:

~/sim/pw/geometry $ root.exe -l -b
root [0] gROOT->LoadMacro( “test2.c++” )
Info in TUnixSystem::ACLiC: creating shared library /home/aharel/sim/pw/geometry/./test2_c.so
/home/aharel/programs/ROOT/6.22.02/etc//cling/std.modulemap:175:10: error: module ‘std.filesystem’ is incompatible with feature ‘header_existence’
module “filesystem” {
^
/home/aharel/sim/pw/geometry/toml11/toml/parser.hpp:19:10: note: submodule of top-level module ‘std’ implicitly imported here
#include
^
/home/aharel/sim/pw/geometry/toml11/toml/parser.hpp:2114:53: error: no member named ‘filesystem’ in namespace ‘std’
basic_value<Comment, Table, Array> parse(const std::filesystem::path& fpath)
~~~~~^
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.
Aborted (core dumped)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.