JuliaInterop / Cxx.jl

The Julia C++ Interface
Other
760 stars 107 forks source link

Upgrade build system to BB2 -- Part 1 #406

Closed Gnimuc closed 5 years ago

Gnimuc commented 5 years ago

This PR is for providing an out-of-box user installation experience of Cxx.jl. You could give it a test by (v1.1) pkg> add https://github.com/Gnimuc/Cxx.jl#BB2.

Platform Status
macOS
Linux x86_64
Linux i686
Windows x86_64 experimental (see https://github.com/JuliaInterop/Cxx.jl/pull/406#issuecomment-471311121 below)
Windows i686
FreeBSD

In short, the package works fine almost on all x86_64 platforms. There is a symbol missing error (clang::FileManager::getVirtualFile(llvm::StringRef, long, long)) on i686 platforms, which is probably due to the incompatibility between LLVMBuilder(only tested with gcc7) and current released 32bit Julia.

UPDATE

Since there are still some compatibility issues between Julia and LLVMBuilder (especially i686 platforms), I won't revisit this until Julia1.2 is released. Currently, the binary build for macOS and Linux x86_64 is working quite well. Windows x86_64 support is still experimental: pre-built binary can be loaded successfully and a lot of examples can work as expected, but other examples may trigger segment faults which, I guess, are due to some unknown bugs in Cxx.

I think the first step is to merge this PR and tag a new release so more people can test this package and submit bug reports. Then we can try to support other Tier 1 platforms until after Julia1.2 is released. It looks like Keno is heading on other important things and doesn't have time to review this, so I'm pinging all you guys here (sorry in advance if this is disturbing), but it would be great if you could help to review/test this PR.

cc @ararslan @cdsousa @phlavenk @btaidm @oschulz @ahumenberger @grizzlysmit @zsz00 @ervinbosenbacher @DrKrar @skariel

fix #403, fix #398, fix #397, fix #394, fix #393, fix #388

ararslan commented 5 years ago

Don't forget to add FreeBSD to the list. 😉

ararslan commented 5 years ago

Why delete the Project.toml file?

Gnimuc commented 5 years ago

To temporarily workaround a dependency problem, I will add it back in the end.

Gnimuc commented 5 years ago

It turns out LLVMBuilder for FreeBSD is currently broken :(

Gnimuc commented 5 years ago

Package compiled on Windows, but I got some errors when running the basic example:

julia> using Cxx
julia> jnum = 10
10
julia> cxx""" #include<iostream> """
true
julia> cxx"""
           void printme(int x) {
               std::cout << x << std::endl;
           }
          """
true
julia> @cxx printme(jnum)
Invalid bitcast
  %dummy = bitcast i64 %0 to i32
define void @cxxjl.5(i64) personality i32 ()* @__cxxjl_personality_v0 {
top:
  %dummy.addr = alloca i32, align 4
  %dummy = bitcast i64 %0 to i32
  store i32 %dummy, i32* %dummy.addr, align 4
  %1 = load i32, i32* %dummy.addr, align 4
  call void @_Z7printmei(i32 %1)
  ret void
}
ERROR: error compiling cppcall: Malformed LLVM Function
Stacktrace:
 [1] top-level scope at none:0

this can be fixed by @cxx printme(Cint(jnum)), so I guess there might be something wrong in the codegen. @Keno could you give some hints on how to debug this issue?

UPDATE

This issue was reported on 32bit platforms before: https://github.com/JuliaInterop/Cxx.jl/issues/370

UPDATE2

This has been fixed by forcing to use

https://github.com/JuliaInterop/Cxx.jl/blob/c62cb578ebde43d040e3f175ea2365b292c6f487/src/bootstrap.cpp#L172-L173

even on 64bit Windows. However, I don't any idea about how to fix the following segfaults: This error is due to Julia/Cxx can't handle $:(julia_global::Int64) correctly on Windows. It can be fixed by directly insert $julia_global into the cxx_str macro.

julia> using Cxx
julia> cxx"""
       #include <stdint.h>
       """
julia> julia_global = 1
julia> cxx"""
       uint64_t bar() {
           return (uint64_t)$:(julia_global::Int64);
           }
           """

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x0 -- unknown function (ip: 0000000000000000)
in expression starting at no file:0
unknown function (ip: FFFFFFFFFFFFFFFF)
CloneFunctionAndAdjust at C:\Users\gnimuc\.julia\dev\Cxx\deps\usr\bin\libcxxffi.DLL (unknown line)
ReplaceFunctionForDecl at C:\Users\gnimuc\.julia\dev\Cxx\deps\usr\bin\libcxxffi.DLL (unknown line)
#ReplaceFunctionForDecl#5 at C:\Users\gnimuc\.julia\dev\Cxx\src\clangwrapper.jl:385 [inlined]
#ReplaceFunctionForDecl at .\none:0 [inlined]
#ReplaceFunctionForDecl#6 at C:\Users\gnimuc\.julia\dev\Cxx\src\clangwrapper.jl:391 [inlined]
#ReplaceFunctionForDecl at .\none:0
...
...
...
twadleigh commented 5 years ago

I have been using the Gnimuc:patch-mac branch of Cxx lately, but last night gave this branch a try. I got this:

In file included from /Cxx.cpp:1:
In file included from /home/tracy/dev/CompoundEye-CUDA/jl/pkgs/CeCxx/src/generic.jl:117:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/boost/shared_ptr.hpp:17:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/boost/smart_ptr/shared_ptr.hpp:28:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/boost/smart_ptr/detail/shared_count.hpp:29:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/boost/smart_ptr/detail/sp_counted_base.hpp:45:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/boost/smart_ptr/detail/sp_counted_base_clang.hpp:18:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/boost/detail/sp_typeinfo.hpp:20:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/boost/core/typeinfo.hpp:119:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/boost/core/demangle.hpp:32:
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/cxxabi.h:128:3: error: exception specification in declaration does not match previous declaration
  __cxa_atexit(void (*)(void*), void*, void*) _GLIBCXX_NOTHROW;
  ^
/home/tracy/.julia/packages/Cxx/4XAMz/src/boot.h:35:10: note: previous declaration is here
    void __cxa_atexit() {}
         ^

The offending line was:

cxx"""
#include <memory>
#include <boost/shared_ptr.hpp>  // <-- this one
"""

I realize this is just a WIP right now, but thought I'd try to help surface any issues early.

Gnimuc commented 5 years ago

@twadleigh that's due to this commit https://github.com/JuliaInterop/Cxx.jl/pull/406/commits/7b9dd68e2f53faf4c2e6d061054724928809d82d which should be Win32 only.

ararslan commented 5 years ago

This is really great work! I don't feel fully qualified to review it, but I've left a few comments in-line. Aside from those, I'll note:

Gnimuc commented 5 years ago

Hi @ararslan, I've rebased this PR and applied your suggestions. I can successfully build libcxxffi binary for FreeBSD: https://github.com/Gnimuc/CxxBuilder/releases/tag/v0.0.4-1, but I don't have a BSD environment for testing whether the pre-built lib is dlopen-able. We also need to add an init function for it.

This PR is for Julia-1.1+LLVM-6.0.1 only. The main reason is the incompatibility between the official Julia binaries and LLVMBuilder releases. You could refer to previous discussions for details:

It's possible to add binary-build support for Julia-1.0, but I failed to make that work on Windows. For now, the libcxxffi binary used in this PR is actually Julia-master compatible which happens to be compatible with Julia-1.1 x86_64 platforms. It's hard to get everything works without the full compatibility between Julia and LLVMBuilder. Hopefully, we will have it in post-Julia-1.2-era.

ararslan commented 5 years ago

I can give it a try on my FreeBSD system, and if all goes well we can turn on Cirrus CI for this repo to test on FreeBSD.

ararslan commented 5 years ago

welp https://github.com/staticfloat/LLVMBuilder/issues/45

EDIT: So apparently one should not be opening multiple copies of libLLVM, which is the cause of that issue. What is it that needs to be dlopened in this case? Is it libclang?

Gnimuc commented 5 years ago

It's libcxxffi.so, but I think libLLVM should also be dlopen-able.

kraftpunk97-zz commented 5 years ago

@Gnimuc Not sure if this is still a WIP, but I got multiple errors when I tried to precompile your #master. Is this behaviour expected?

Gnimuc commented 5 years ago

@kraftpunk97 It should work as long as you're working on macOS, Linux(64bit) or Windows(64bit). Could you comment those errors below?

BTW, you may need to manually git fetch the latest master.

kraftpunk97-zz commented 5 years ago

@Gnimuc Here's the error when I precompile Cxx, after calling ] add https://github.com/Gnimuc/Cxx.jl and building it... It says could not add directory /usr/include to clang search path. Perhaps, this is an easy fix?

julia> using Cxx
[ Info: Recompiling stale cache file /Users/kartikeygupta/.julia/compiled/v1.1/Cxx/ESGkI.ji for Cxx [a0b5b9ef-44b7-5148-a2d1-f6db19f3c3d2]
WARNING: Could not add directory /usr/include to clang search path!
In file included from /Cxx.h:1:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/boot.h:16:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found
#include_next <string.h>
              ^~~~~~~~~~
In file included from /Cxx.h:1:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/replpane.jl:83:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Parse/Parser.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/AST/Availability.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/SourceLocation.h:18:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/LLVM.h:22:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/Support/Casting.h:19:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/Support/type_traits.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:198:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:80:44: error: base specifier must name a class
template <class _Tp> struct __tuple_like : false_type {};
                                           ^~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:165:63: error: base specifier must name a class
template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
                                                              ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:197:72: error: base specifier must name a class
template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
                                                                       ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:225:78: error: base specifier must name a class
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
                                                                             ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:299:71: error: base specifier must name a class
template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
                                                                      ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:418:14: error: base specifier must name a class
    : public false_type {};
      ~~~~~~~^~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:433:14: error: base specifier must name a class
    : public false_type {};
      ~~~~~~~^~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:448:14: error: base specifier must name a class
    : public false_type {};
      ~~~~~~~^~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__tuple:472:37: error: base specifier must name a class
struct __tuple_like_with_size_imp : false_type {};
                                    ^~~~~~~~~~
In file included from /Cxx.h:1:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/replpane.jl:83:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Parse/Parser.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/AST/Availability.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/SourceLocation.h:18:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/LLVM.h:22:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/Support/Casting.h:19:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/Support/type_traits.h:19:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:268:1: error: redefinition of 'swap' as different kind of symbol
swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:4602:1: note: previous definition is here
swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
^
In file included from /Cxx.h:1:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/replpane.jl:83:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Parse/Parser.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/AST/Availability.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/SourceLocation.h:18:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/LLVM.h:22:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/Support/Casting.h:19:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/Support/type_traits.h:19:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:950:10: error: no member named 'memcpy' in namespace 'std'; did you mean 'memchr'?
    std::memcpy(&__r, __p, sizeof(__r));
    ~~~~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:81:9: note: 'memchr' declared here
using ::memchr;
        ^
In file included from /Cxx.h:1:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/replpane.jl:83:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Parse/Parser.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/AST/Availability.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/SourceLocation.h:18:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/LLVM.h:22:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/Support/Casting.h:20:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cassert:21:10: fatal error: 'assert.h' file not found
#include <assert.h>
         ^~~~~~~~~~
WARNING: Could not add directory /usr/include to clang search path!
In file included from /Cxx.cpp:1:
In file included from /Cxx.h:1:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/replpane.jl:83:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Parse/Parser.h:22:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Lex/Preprocessor.h:18:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/Builtins.h:19:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/ADT/ArrayRef.h:26:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:328:38: error: no type named 'const_pointer' in 'std::__1::allocator_traits<std::__1::allocator<bool> >'
    typedef typename __alloc_traits::const_pointer   const_pointer;
            ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:448:15: note: in instantiation of template class 'std::__1::__vector_base<bool, std::__1::allocator<bool> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
/Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/std.jl:43:12: note: in instantiation of template class 'std::__1::vector<bool, std::__1::allocator<bool> >' requested here
__juliavar1.size();
           ^
In file included from /Cxx.cpp:1:
In file included from /Cxx.h:1:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/replpane.jl:83:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Parse/Parser.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/AST/Availability.h:17:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/SourceLocation.h:18:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/LLVM.h:22:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/Support/Casting.h:21:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:2166:38: error: no member named 'value' in 'std::__1::is_same<int, std::__1::allocator<bool> >'
  static_assert((!is_same<_T1, _T2>::value),
                  ~~~~~~~~~~~~~~~~~~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:334:48: note: in instantiation of template class 'std::__1::__compressed_pair<int, std::__1::allocator<bool> >' requested here
    __compressed_pair<pointer, allocator_type> __end_cap_;
                                               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:448:15: note: in instantiation of template class 'std::__1::__vector_base<bool, std::__1::allocator<bool> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
/Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/std.jl:43:12: note: in instantiation of template class 'std::__1::vector<bool, std::__1::allocator<bool> >' requested here
__juliavar1.size();
           ^
In file included from /Cxx.cpp:1:
In file included from /Cxx.h:1:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/replpane.jl:83:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Parse/Parser.h:22:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Lex/Preprocessor.h:18:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/src/clang-6.0.1/include/clang/Basic/Builtins.h:19:
In file included from /Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/CxxREPL/../../deps/usr/build/clang-6.0.1/include/llvm/ADT/ArrayRef.h:26:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:457:30: error: '__alloc_traits' is a protected member of 'std::__1::__vector_base<bool, std::__1::allocator<bool> >'
    typedef typename __base::__alloc_traits          __alloc_traits;
                             ^
/Users/kartikeygupta/.julia/packages/Cxx/mXAva/src/std.jl:43:12: note: in instantiation of template class 'std::__1::vector<bool, std::__1::allocator<bool> >' requested here
__juliavar1.size();
           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:322:54: note: declared protected here
    typedef allocator_traits<allocator_type>         __alloc_traits;
                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:458:30: error: 'reference' is a protected member of 'std::__1::__vector_base<bool, std::__1::allocator<bool> >'
    typedef typename __base::reference               reference;
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:323:54: note: declared protected here
    typedef value_type&                              reference;
                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:459:30: error: 'const_reference' is a protected member of 'std::__1::__vector_base<bool, std::__1::allocator<bool> >'
    typedef typename __base::const_reference         const_reference;
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:324:54: note: declared protected here
    typedef const value_type&                        const_reference;
                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:460:30: error: 'size_type' is a protected member of 'std::__1::__vector_base<bool, std::__1::allocator<bool> >'
    typedef typename __base::size_type               size_type;
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:325:54: note: declared protected here
    typedef typename __alloc_traits::size_type       size_type;
                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:461:30: error: 'difference_type' is a protected member of 'std::__1::__vector_base<bool, std::__1::allocator<bool> >'
    typedef typename __base::difference_type         difference_type;
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:326:54: note: declared protected here
    typedef typename __alloc_traits::difference_type difference_type;
                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:462:30: error: 'pointer' is a protected member of 'std::__1::__vector_base<bool, std::__1::allocator<bool> >'
    typedef typename __base::pointer                 pointer;
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:327:54: note: declared protected here
    typedef typename __alloc_traits::pointer         pointer;
                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:463:30: error: 'const_pointer' is a protected member of 'std::__1::__vector_base<bool, std::__1::allocator<bool> >'
    typedef typename __base::const_pointer           const_pointer;
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:328:54: note: declared protected here
    typedef typename __alloc_traits::const_pointer   const_pointer;
                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/vector:469:78: error: no member named 'value' in 'std::__1::is_same<bool, bool>'
    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
fredrikekre commented 5 years ago

Here's the error when I precompile Cxx, after calling ] add https://github.com/Gnimuc/Cxx.jl and building it...

Shouldn't you use the BB2 branch that this PR is based on? e.g. ] add https://github.com/Gnimuc/Cxx.jl#BB2

Gnimuc commented 5 years ago

aha, I got that /usr/include-missing error before. Apple is the one to be blamed here. It could be fixed by https://apple.stackexchange.com/questions/337940/why-is-usr-include-missing-i-have-xcode-and-command-line-tools-installed-moja

Shouldn't you use the BB2 branch that this PR is based on? e.g. ] add https://github.com/Gnimuc/Cxx.jl#BB2

Yeah, that's actually my bad. I've updated the command in the OP. Currently, I manually keep syncing these two branches.

kraftpunk97-zz commented 5 years ago

Thanks @Gnimuc, problem solved

Gnimuc commented 5 years ago

Hi @ararslan, did you successfully dlopen libcxxffi.so on FreeBSD? If not, I think we can try it again when Julia 1.2 is released. For now, let's merge this and tag a new version for Julia 1.1.

ararslan commented 5 years ago

Sorry for the delay in getting back to you on that. I just tried your FreeBSD-compatible release for CxxBuilder and I can dlopen libcxxffi.so just fine on FreeBSD 11.2 with Julia 1.1.

oschulz commented 5 years ago

Seems to work out of the box (CentOS Singularity Container on Ubuntu)! Thanks so much for all your work on this, @Gnimuc and all the other that were involved! I was really missing Cxx.jl ...

oschulz commented 5 years ago

Yep, just remembered, lol. Sorry! Hadn't used Cxx for too long. :-)

oschulz commented 5 years ago

Another question: Is there an easy way to supply the binary deps in a central location (e.g. a container image), to speed up Cxx installation and keep the user .julia directories small(er)?

Petr-Hlavenka commented 5 years ago

Thank you for your effort! Installs on windows without problem and runs as "experimental" as expected - I've started to fill windows specific issues to #409.

Gnimuc commented 5 years ago

@oschulz It's possible to shrink deps size. I tried before but failed to do it correctly. For now, BB just ships the whole LLVM/Clang deps which are very huge. I think we can revisit it after Julia 1.2 has been released.

grizzlysmit commented 5 years ago

doesn't install on ubuntu 19.04 Disco Dingo

$ julia                          ()     |  Documentation: https://docs.julialang.org   ()     | () ()    |       | |_     |  Type "?" for help, "]?" for Pkg help.   | | | | | | |/ ` |  |   | | || | | | (| |  |  Version 1.0.3  / |_'|||_'_|  |  Ubuntu ⛬  julia/1.0.3+dfsg-4 |/                   |

julia> using Pkg

julia> Pkg.add("Cxx")   Updating registry at ~/.julia/registries/General   Updating git-repo https://github.com/JuliaRegistries/General.git  Resolving package versions... ERROR: Unsatisfiable requirements detected for package Cxx [a0b5b9ef]:  Cxx [a0b5b9ef] log:  ├─possible versions are: [0.0.1-0.0.2, 0.1.0-0.1.1, 0.2.0] or uninstalled  ├─restricted to versions * by an explicit requirement, leaving only versions [0.0.1-0.0.2, 0.1.0-0.1.1, 0.2.0]  └─restricted by julia compatibility requirements to versions: uninstalled — no versions left Stacktrace:  [1] #propagate_constraints!#61(::Bool, ::Function, ::Pkg.GraphType.Graph, ::Set{Int64}) at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/GraphType.jl:1005  [2] propagate_constraints! at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/GraphType.jl:946 [inlined]  [3] #simplify_graph!#121(::Bool, ::Function, ::Pkg.GraphType.Graph, ::Set{Int64}) at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/GraphType.jl:1460  [4] simplify_graph! at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/GraphType.jl:1460 [inlined] (repeats 2 times)  [5] resolve_versions!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Nothing) at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:373  [6] resolve_versions! at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:316 [inlined]  [7] #add_or_develop#62(::Array{Base.UUID,1}, ::Symbol, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1201  [8] #add_or_develop at ./none:0 [inlined]  [9] #add_or_develop#13(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:64  [10] #add_or_develop at ./none:0 [inlined]  [11] #add_or_develop#12 at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:29 [inlined]  [12] #add_or_develop at ./none:0 [inlined]  [13] #add_or_develop#11 at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:28 [inlined]  [14] #add_or_develop at ./none:0 [inlined]  [15] #add_or_develop#10 at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:27 [inlined]  [16] #add_or_develop at ./none:0 [inlined]  [17] #add#18 at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:69 [inlined]  [18] add(::String) at /build/julia-wlSndE/julia-1.0.3+dfsg/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:69  [19] top-level scope at none:0

On 12/4/19 2:26 am, Gnimuc wrote:

This PR is for providing an out-of-box user installation experience of Cxx.jl. You could give it a test by |(v1.1) pkg> dev https://github.com/Gnimuc/Cxx.jl.git|.

Platform Status macOS ✅ Linux x86_64 ✅ Linux i686 ❌ Windows x86_64 see #406 (comment) https://github.com/JuliaInterop/Cxx.jl/pull/406#issuecomment-471311121 below Windows i686 ❌ FreeBSD pending upstream (LLVMBuilder)

In short, the package works fine almost on all x86_64 platforms. There is a symbol missing error (|clang::FileManager::getVirtualFile(llvm::StringRef, long, long)|) on i686 platforms, which is probably due to the incompatibility between LLVMBuilder(only tested with gcc7) and current released 32bit Julia.

UPDATE

Since there are still some compatibility issues between Julia and LLVMBuilder (especially i686 platforms), I won't try this until Julia1.2 is released. Currently, the binary build for macOS and Linux x86_64 is working quite well. Windows x86_64 support is still experimental: pre-built binary can be loaded successfully and a lot of examples can work as expected. However, some examples will trigger segment faults which, I guess, are due to some unknown bugs in Cxx.

I think the first step is to merge this PR and tag a new release so more people can test this package and submit bug reports. Then we can try to support other Tier 1 platforms until after Julia1.2 is released. It looks like Keno is heading on other important things and doesn't have time to review this, so I'm pinging all you guys here (sorry in advance if this is disturbing), but it would be great if you could help to review/test this PR.

cc @ararslan https://github.com/ararslan @cdsousa https://github.com/cdsousa @phlavenk https://github.com/phlavenk @btaidm https://github.com/btaidm @oschulz https://github.com/oschulz @ahumenberger https://github.com/ahumenberger @grizzlysmit https://github.com/grizzlysmit @zsz00 https://github.com/zsz00 @ervinbosenbacher https://github.com/ervinbosenbacher @DrKrar https://github.com/DrKrar @skariel https://github.com/skariel


    You can view, comment on, or merge this pull request online at:

https://github.com/JuliaInterop/Cxx.jl/pull/406

    Commit Summary

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JuliaInterop/Cxx.jl/pull/406, or mute the thread https://github.com/notifications/unsubscribe-auth/AInk9huHeglqHo3hdyxUCxm9sCt0utXiks5vf2I6gaJpZM4bmusy.

--

.~.     In my life God comes first....
/V\         but Linux is pretty high after that :-D

/( )\ Francis (Grizzly) Smit ^^-^^ http://www.smit.id.au/

Gnimuc commented 5 years ago

@grizzlysmit, unfortunately, Cxx doesn't support binary build for Julia 1.0.x for now. You may need to upgrade Julia to 1.1 firstly and then run dev Cxx. The reason why it doesn't support 1.0 is explained at this https://github.com/JuliaInterop/Cxx.jl/pull/406#issuecomment-482601621.

oschulz commented 5 years ago

@oschulz It's possible to shrink deps size. I tried before but failed to do it correctly. For now, BB just ships the whole LLVM/Clang deps which are very huge. I think we can revisit it after Julia 1.2 has been released.

Sounds good, thanks!