JuliaInterop / Cxx.jl

The Julia C++ Interface
Other
757 stars 108 forks source link

C++ 14 features unavailable with-fno-rtti #365

Open wbhart opened 6 years ago

wbhart commented 6 years ago

We are trying to interface to a large C++ library, called polymake [1]. Unfortunately, Cxx does not seem to like the C++14 header files for that project. See the full error messages at the end of this post.

The problem seems to be that clang is essentially reading the header files with -fno-rtti.

I tried setting use_rtti = true in Cxx's bootstrap.cpp and rebuilding Cxx, which prevents the error, but now it cannot find any symbols in the library.

LLVM ERROR: Program used external function '_ZN2pm4perl4MainC1ERKSsS3_S3_' which could not be resolved!

Does rtti cause clang to further decorate symbol names?

RTTI is apparently a standard feature of C++ and numerous basic features of the language rely on it. Is there some hope it could be turned on and supported?

[1] https://polymake.org/doku.php

INFO: Recompiling stale cache file /home/wbhart/.julia/lib/v0.6/Cxx.ji for module Cxx.
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:21:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/Value.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/GenericIO.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/sparse.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Series.h:24:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/comparators_ops.h:23:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/comparators_basic_defs.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/operations_basic_defs.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/type_manip.h:22:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/type_utils.h:197:28: error: cannot use typeid with -fno-rtti
   return legible_typename(typeid(T));
                           ^
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:21:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/Value.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/GenericIO.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/sparse.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Series.h:24:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/comparators_ops.h:23:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/comparators_basic_defs.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/operations_basic_defs.h:20:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/type_manip.h:1109:57: warning: '&&' within '||'
         object_traits<T>::IO_separator==IO_sep_inherit &&
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/type_manip.h:1109:57: note: place parentheses around the '&&' expression to silence this warning
         object_traits<T>::IO_separator==IO_sep_inherit &&
                                                        ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/type_manip.h:1111:60: warning: '&&' within '||'
      || object_traits<T>::IO_separator==IO_sep_containers &&
      ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/type_manip.h:1111:60: note: place parentheses around the '&&' expression to silence this warning
      || object_traits<T>::IO_separator==IO_sep_containers &&
                                                           ^
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:21:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/Value.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/GenericIO.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/sparse.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Series.h:25:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/shared_object.h:199:41: warning: '&&' within '||'
      return is_owner() || al_set.owner && refc > al_set.owner->n_aliases+1;
                        ~~ ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/shared_object.h:199:41: note: place parentheses around the '&&' expression to silence this warning
      return is_owner() || al_set.owner && refc > al_set.owner->n_aliases+1;
                                        ^
                           (                                               )
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:21:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/Value.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/GenericIO.h:20:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/sparse.h:23:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/iterator_zipper.h:35:45: warning: operator '<<' has lower precedence than '+'; '+' will be evaluated first
   static int state(int cmp) { return 1 << 1+cmp; }
                                        ~~ ~^~~~
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/iterator_zipper.h:35:45: note: place parentheses around the '+' expression to silence this warning
   static int state(int cmp) { return 1 << 1+cmp; }
                                            ^
                                           (    )
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/iterator_zipper.h:64:45: warning: operator '<<' has lower precedence than '-'; '-' will be evaluated first
   static int state(int cmp) { return 1 << 1-cmp; }
                                        ~~ ~^~~~
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/iterator_zipper.h:64:45: note: place parentheses around the '-' expression to silence this warning
   static int state(int cmp) { return 1 << 1-cmp; }
                                            ^
                                           (    )
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:21:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/Value.h:21:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/assoc.h:22:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/TransformedContainer.h:131:85: warning: '&&' within '||'
      use_sparse_coupler = (sparse1 || sparse2) && (partially_defined || !constant1 && !constant2),
                                                                      ~~ ~~~~~~~~~~~^~~~~~~~~~~~~
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/TransformedContainer.h:131:85: note: place parentheses around the '&&' expression to silence this warning
      use_sparse_coupler = (sparse1 || sparse2) && (partially_defined || !constant1 && !constant2),
                                                                                    ^
                                                                         (                       )
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:21:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/Value.h:21:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/internal/assoc.h:23:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/GenericSet.h:760:40: warning: '&&' within '||'
      return n2==0 || set1.tree_form() && ( n1/n2>=31 || (1<<(n1/n2))>n1 );
                   ~~ ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/GenericSet.h:760:40: note: place parentheses around the '&&' expression to silence this warning
      return n2==0 || set1.tree_form() && ( n1/n2>=31 || (1<<(n1/n2))>n1 );
                                       ^
                      (                                                   )
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:21:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/Value.h:840:34: error: cannot use typeid with -fno-rtti
            if (*canned.first == typeid(Target)) {
                                 ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/Value.h:1176:37: error: cannot use typeid with -fno-rtti
               if (*canned.first == typeid(Target))
                                    ^
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:22:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/types.h:112:27: error: cannot use typeid with -fno-rtti
          infos.set_descr(typeid(typename remove_unsigned<T>::type)))
                          ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/types.h:121:39: error: cannot use typeid with -fno-rtti
      infos.set_proto(prescribed_pkg, typeid(T));
                                      ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/types.h:221:39: error: cannot use typeid with -fno-rtti
      infos.set_proto(prescribed_pkg, typeid(T), type_cache<Representative>::get_proto());
                                      ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/types.h:320:46: error: cannot use typeid with -fno-rtti
      arr.push(Scalar::const_string_with_int(typeid(Type).name(), attrib<Type>::is_const));
                                             ^
In file included from /Cxx.cpp:1:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/Main.h:31:
In file included from /home/wbhart/.julia/v0.6/Polymake/local/include/polymake/client.h:24:
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:108:47: error: cannot use typeid with -fno-rtti
            if (!try_conv || *canned.first == typeid(value_type))
                                              ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:111:47: error: cannot use typeid with -fno-rtti
            if (!try_conv || *canned.first == typeid(given_value_type))
                                              ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:235:94: error: cannot use typeid with -fno-rtti
                                TypeListUtils<Fptr>::get_type_names(), nullptr, (void*)fptr, typeid(type2type<Fptr>).name());
                                                                                             ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:530:10: error: cannot use typeid with -fno-rtti
         typeid(T).name(),
         ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:533:13: error: cannot use typeid with -fno-rtti
            typeid(T), sizeof(T), mlist_contains<primitive_lvalues, T>::value,
            ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:600:10: error: cannot use typeid with -fno-rtti
         typeid(T).name(),
         ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:604:13: error: cannot use typeid with -fno-rtti
            typeid(T), sizeof(T),
            ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:627:10: error: cannot use typeid with -fno-rtti
         typeid(T).name(),
         ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:631:13: error: cannot use typeid with -fno-rtti
            typeid(T), sizeof(T),
            ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:683:10: error: cannot use typeid with -fno-rtti
         typeid(T).name(),
         ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:687:13: error: cannot use typeid with -fno-rtti
            typeid(T), sizeof(T),
            ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:1052:10: error: cannot use typeid with -fno-rtti
         typeid(T), sizeof(T),
         ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:1086:10: error: cannot use typeid with -fno-rtti
         typeid(T).name(),
         ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:1230:10: error: cannot use typeid with -fno-rtti
         typeid(T).name(),
         ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:1233:13: error: cannot use typeid with -fno-rtti
            typeid(T), sizeof(T),
            ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:1303:10: error: cannot use typeid with -fno-rtti
         typeid(T).name(),
         ^
/home/wbhart/.julia/v0.6/Polymake/local/include/polymake/perl/wrappers.h:1307:13: error: cannot use typeid with -fno-rtti
            typeid(T), sizeof(T), object_traits<T>::total_dimension,
wbhart commented 6 years ago

We found the pull request [1] related to rtti and tried enabling rtti by setting the JULIA_CXX_RTTI environment variable before starting Julia.

That actually works for some of us, but not others. In my case it complains:

error: run-time type information was disabled in PCH file but is currently enabled
<built-in>:1:10: fatal error: 'Cxx.h' file not found
#include "Cxx.h"
         ^

I see from the comments on the PR that this is a difficult issue to resolve. I'm sure you are already aware of it, but I thought it best to report it, as others will likely encounter the same.

[1] https://github.com/Keno/Cxx.jl/pull/313

wbhart commented 6 years ago

Apparently, despite what is said in that PR, rebuilding Cxx is still required after changing this environment variable. It now works on my machine.