Cxx.jl icon indicating copy to clipboard operation
Cxx.jl copied to clipboard

Compiling in OS X

Open matteoicardi opened this issue 7 years ago • 3 comments

I could not compile Cxx in OS X as it complained about not finding LLVM library and other issues with the system clang compiler. I found a workaround (though there is still some Cxx functionality that does not work) by compiling Julia with USE_SYSTEM_LLVM:=1 and BUILD_LLVM_CLANG := 1, but I had to manually change baseclangdir to my local dir to make Cxx work. I think this might be easily fixed to automatically look for the system LLVM

PS: the same happens with 0.5 0.6 and 0.7 Julia versions

matteoicardi avatar Jul 13 '17 14:07 matteoicardi

Can you post the exact error message you originally say? Cxx does not currently support julia 0.7.

Keno avatar Jul 13 '17 14:07 Keno

This is what I get with the Julia 0.5.2 system binaries:

julia> Pkg.add("Cxx")
INFO: Installing Compat v0.26.0
INFO: Installing Cxx v0.2.0
INFO: Building Cxx
INFO: Building julia binary build
In file included from /Users/icardi/.julia/v0.6/Cxx/deps/src/llvm-3.9.1/lib/LibDriver/LibDriver.cpp:39:
/Users/icardi/.julia/v0.6/Cxx/deps/build/llvm-3.9.1/lib/LibDriver/Options.inc:15:8: error: default initialization
      of an object of const type 'const char *const'
PREFIX(prefix_<U+0001>, {"/" COMMA "-" COMMA "-?" COMMA nullptr})
       ^
/Users/icardi/.julia/v0.6/Cxx/deps/build/llvm-3.9.1/lib/LibDriver/Options.inc:15:15: error: expected ';' after
      top level declarator
PREFIX(prefix_<U+0001>, {"/" COMMA "-" COMMA "-?" COMMA nullptr})
              ^
/Users/icardi/.julia/v0.6/Cxx/deps/src/llvm-3.9.1/lib/LibDriver/LibDriver.cpp:54:19: error: no matching
      constructor for initialization of 'llvm::opt::OptTable'
  LibOptTable() : OptTable(infoTable, true) {}
                  ^        ~~~~~~~~~~~~~~~
/Users/icardi/.julia/v0.6/Cxx/deps/src/llvm-3.9.1/include/llvm/Option/OptTable.h:76:3: note: candidate
      constructor not viable: cannot convert argument of incomplete type 'const llvm::opt::OptTable::Info []' to
      'ArrayRef<llvm::opt::OptTable::Info>' for 1st argument
  OptTable(ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
  ^
/Users/icardi/.julia/v0.6/Cxx/deps/src/llvm-3.9.1/include/llvm/Option/OptTable.h:32:7: note: candidate
      constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class OptTable {
      ^
3 errors generated.
make[3]: *** [lib/LibDriver/CMakeFiles/LLVMLibDriver.dir/LibDriver.cpp.o] Error 1
make[2]: *** [lib/LibDriver/CMakeFiles/LLVMLibDriver.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all] Error 2
make: *** [build/llvm-3.9.1/bin/llvm-config] Error 2
=================================================[ ERROR: Cxx ]==================================================

LoadError: failed process: Process(`make -j8 -f BuildBootstrap.Makefile BASE_JULIA_BIN=/Applications/Julia-0.6.app/Contents/Resources/julia/bin BASE_JULIA_SRC=/Applications/Julia-0.6.app/Contents/Resources/julia/bin/../..`, ProcessExited(2)) [2]
while loading /Users/icardi/.julia/v0.6/Cxx/deps/build.jl, in expression starting on line 54

=================================================================================================================

This is what I get with my own compiled Julia 0.6.0 with the default Make.inc:

julia> Pkg.add("Cxx")
INFO: Installing Compat v0.26.0
INFO: Installing Cxx v0.2.0
INFO: Building Cxx
INFO: Building julia source build
CMake Error at /usr/local/Cellar/cmake/3.8.2/share/cmake/Modules/CMakeTestCCompiler.cmake:51 (message):
  The C compiler
  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"
  is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: /Users/icardi/.julia/v0.6/Cxx/deps/build/clang-3.9.1/CMakeFiles/CMakeTmp



  Run Build Command:"/usr/bin/make" "cmTC_619f4/fast"

  /Applications/Xcode.app/Contents/Developer/usr/bin/make -f
  CMakeFiles/cmTC_619f4.dir/build.make CMakeFiles/cmTC_619f4.dir/build

  Building C object CMakeFiles/cmTC_619f4.dir/testCCompiler.c.o


  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
  -I/usr/include -I/usr/local/include -o
  CMakeFiles/cmTC_619f4.dir/testCCompiler.c.o -c
  /Users/icardi/.julia/v0.6/Cxx/deps/build/clang-3.9.1/CMakeFiles/CMakeTmp/testCCompiler.c


  Linking C executable cmTC_619f4

  /usr/local/Cellar/cmake/3.8.2/bin/cmake -E cmake_link_script
  CMakeFiles/cmTC_619f4.dir/link.txt --verbose=1


  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
  -I/usr/include -I/usr/local/include -Wl,-search_paths_first
  -Wl,-headerpad_max_install_names -L/usr/lib -L/usr/local/lib -lLLVM
  CMakeFiles/cmTC_619f4.dir/testCCompiler.c.o -o cmTC_619f4

  ld: library not found for -lLLVM

  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

  make[2]: *** [cmTC_619f4] Error 1

  make[1]: *** [cmTC_619f4/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:6 (project)


make: *** [build/clang-3.9.1/Makefile] Error 1
=================================================[ ERROR: Cxx ]==================================================

LoadError: failed process: Process(`make -j8 -f BuildBootstrap.Makefile BASE_JULIA_BIN=/Users/icardi/julia/julia6/usr/bin BASE_JULIA_SRC=/Users/icardi/julia/julia6/usr/bin/../..`, ProcessExited(2)) [2]
while loading /Users/icardi/.julia/v0.6/Cxx/deps/build.jl, in expression starting on line 54

=================================================================================================================

matteoicardi avatar Jul 14 '17 16:07 matteoicardi

I'm running Julia 0.6.0 on High Sierra OS 10.13.1 and also trying to get Cxx.jl to work.

This is the tail end of what I get when I ran Pkg.build("Cxx")

 "virtual thunk to std::__1::basic_iostream<char, std::__1::char_traits<char> >::~basic_iostream()", referenced from:
      construction vtable for std::__1::basic_iostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libclangAnalysis.a(ThreadSafety.cpp.o)
      construction vtable for std::__1::basic_iostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libclangStaticAnalyzerCore.a(HTMLDiagnostics.cpp.o)
      construction vtable for std::__1::basic_iostream<char, std::__1::char_traits<char> >-in-std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> > in libclangTooling.a(CompilationDatabase.cpp.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [usr/lib/libcxxffi.dylib] Error 1
========================================================================================================================================================[ ERROR: Cxx ]========================================================================================================================================================

LoadError: failed process: Process(`make -j8 -f BuildBootstrap.Makefile BASE_JULIA_BIN=/Users/mira/julia-0.6.0/usr/bin BASE_JULIA_SRC=/Users/mira/julia-0.6.0/usr/bin/../..`, ProcessExited(2)) [2]
while loading /Users/mira/.julia/v0.6/Cxx/deps/build.jl, in expression starting on line 54

==============================================================================================================================================================================================================================================================================================================================

=======================================================================================================================================================[ BUILD ERRORS ]=======================================================================================================================================================

WARNING: Cxx had build errors.

 - packages with build errors remain installed in /Users/mira/.julia/v0.6
 - build the package(s) and all dependencies with `Pkg.build("Cxx")`
 - build a single package by running its `deps/build.jl` script


albi3ro avatar Dec 01 '17 08:12 albi3ro