CxxWrap.jl
CxxWrap.jl copied to clipboard
Fails with Julia 1.9?
I tried the simple example from the manual,
JLCXX_MODULE define_julia_module(jlcxx::Module& mod)
{
FLAGS_fst_error_fatal = false;
mod.add_type<MyStruct>("MyStruct");
mod.method("greet", []() {return "Hello";});
}
which runs fine in Julia 1.8, but not in dev (1.9.0-DEV.1189 (2022-08-26)): the error message appears in
julia> using XXX
C++ exception while wrapping module XXX: invalid subtyping in definition of MyStruct with supertype Any
ERROR: LoadError: invalid subtyping in definition of MyStruct with supertype Any
By the way, both 1.8 and 1.9 define the method "greet", but it does not return a string, rather a pointer:
julia> XXX.greet()
CxxWrap.CxxWrapCore.ConstCxxPtr{CxxWrap.CxxWrapCore.CxxChar}(Ptr{CxxWrap.CxxWrapCore.CxxChar} @0x0000000146bf5985)
The issue is that you need to build both libcxxwrap-julia and the example code against Julia 1.9, since there is a binary incompatibility between 1.8 and 1.9. Unfortunately at this time I can't build against 1.9, erroring on this:
/usr/bin/ld: test/CMakeFiles/test_type_init.dir/test_type_init.cpp.o: copy relocation against non-copyable protected symbol `jl_unionall_type'
@fingolfin Have you encountered this?
Would it be possible to provide artifacts for Julia 1.9 and 1.10 (aka. the Julia master branch), or alternatively, refuse installation on unsupported versions (i.e. don't provide an artifact so that packages fail to load)? Currently, CxxWrap dependents crash hard (with a segfault), and those crashes are prominently featured in every PkgEval report.
One example: ConnectFourSolver.jl
[47] signal (11.1): Segmentation fault
in expression starting at /home/pkgeval/.julia/packages/CxxWrap/94t40/src/StdLib.jl:17
ijl_new_datatype at /cache/build/default-amdci4-5/julialang/julia-master/src/datatype.c:717
_ZN5jlcxx12new_datatypeEP9_jl_sym_tP12_jl_module_tP14_jl_datatype_tP9jl_svec_tS7_S7_iii at /home/pkgeval/.julia/artifacts/d54a2909808f0f05123ef98f8eef4fcde1073e52/lib/libcxxwrap_julia.so.0 (unknown line)
_ZN5jlcxx6Module17add_type_internalINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_13ParameterListIJEEE11_jl_value_tEENS_11TypeWrapperIT_EERKS7_PT1_ at /home/pkgeval/.julia/artifacts/d54a2909808f0f05123ef98f8eef4fcde1073e52/lib/libcxxwrap_julia_stl.so (unknown line)
define_cxxwrap_stl_module at /home/pkgeval/.julia/artifacts/d54a2909808f0f05123ef98f8eef4fcde1073e52/lib/libcxxwrap_julia_stl.so (unknown line)
register_julia_module at /home/pkgeval/.julia/artifacts/d54a2909808f0f05123ef98f8eef4fcde1073e52/lib/libcxxwrap_julia.so.0 (unknown line)
register_julia_module at /home/pkgeval/.julia/packages/CxxWrap/94t40/src/CxxWrap.jl:399 [inlined]
readmodule at /home/pkgeval/.julia/packages/CxxWrap/94t40/src/CxxWrap.jl:694
wrapmodule at /home/pkgeval/.julia/packages/CxxWrap/94t40/src/CxxWrap.jl:698
Cxxwrap binaries for 1.9 have been in use by us since shortly after Julia master switched to 1.9 . For 1.10 the binaries were released today, just a few days after Julia master adopted that version number.
AFAIK ConnectFour has its own JLL, which its maintainer will have to update
Closing here since this is tracked now at the ConnectFourSolver repl.