JuliaInterop / Cxx.jl

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

Cxx fails to build for Julia 1.2 on Linux #436

Closed horst5000 closed 5 years ago

horst5000 commented 5 years ago

Since Julia 1.2 is officially out by today, I built it from source (no special flags except MARCH=native) and added Cxx resulting in the error below. It seems like there are some path issues with llvm-tblgen, though I'm not sure, if it's a Cxx issue or a Julia issue. Btw. I'm on Ubuntu 18.04.

Error: Error building `Cxx`:
│ mkdir -p build/clang-6.0.1/
│ cd build/clang-6.0.1/ && \
│       cmake -G "Unix Makefiles" \
│               -DLLVM_BUILD_LLVM_DYLIB=ON -DCMAKE_BUILD_TYPE=Release \
│               -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_ENABLE_THREADS=OFF \
│                         -DCMAKE_CXX_COMPILER_ARG1="-D_GLIBCXX_USE_CXX11_ABI=1" \
│               -DLLVM_CONFIG=/home/fppx/bin/julia/usr/bin/../tools/llvm-config -DLLVM_TABLEGEN_EXE=/home/fppx/bin/julia/usr/bin/../tools/llvm-tblgen ../../src/clang-6.0.1
│ Not building debug library because corresponding julia DEBUG library does not exist.
│ To build, simply run the build again once the library at
│ /libjulia-debug.so
│ has been built.
│ -- Found LLVM_CONFIG as /home/fppx/bin/julia/usr/tools/llvm-config
│ CMake Error at /home/fppx/bin/julia/usr/lib/cmake/llvm/LLVMExports.cmake:714 (message):
│   The imported target "llvm-tblgen" references the file
│
│      "/workspace/destdir/tools/llvm-tblgen"
│
│   but this file does not exist.  Possible reasons include:
│
│   * The file was deleted, renamed, or moved to another location.
│
│   * An install or uninstall procedure did not complete successfully.
│
│   * The installation package was faulty and contained
│
│      "/home/fppx/bin/julia/usr/lib/cmake/llvm/LLVMExports.cmake"
│
│   but not all the files it references.
│
│ Call Stack (most recent call first):
│   /home/fppx/bin/julia/usr/lib/cmake/llvm/LLVMConfig.cmake:157 (include)
│   CMakeLists.txt:70 (include)
Gnimuc commented 5 years ago

I built it from source (no special flags except MARCH=native)

please try to build Julia with USE_BINARYBUILDER=0.

horst5000 commented 5 years ago

please try to build Julia with USE_BINARYBUILDER=0.

Same error...

Gnimuc commented 5 years ago

Could you check it again that USE_BINARYBUILDER=0 takes effect on the build? It should download LLVM source code and build it from scratch which takes about 45min+ on a normal machine.

Gnimuc commented 5 years ago

you could also search USE_BINARYBUILDER in Make.inc and make it hard-coded to 0 to ensure no prebuilt LLVM binaries are used in your build process.

horst5000 commented 5 years ago

Could you check it again that USE_BINARYBUILDER=0 takes effect on the build? It should download LLVM source code and build it from scratch which takes about 45min+ on a normal machine.

Ok, I'll check again. I cleaned using make distcleanall and it downloaded the LLVM source, but the build didn't take that long... Short note: it works using the precompiled Julia binaries for 1.1 and 1.2.

Gnimuc commented 5 years ago

"/workspace/destdir/tools/llvm-tblgen" this path is the "install" dir in BB2 shard, which implies that Julia was still using prebuilt LLVM binaries.

horst5000 commented 5 years ago

Thanks, using USE_BINARYBUILDER=0 did the job. Maybe this should be added to the README, since many people will start to use 1.2 now it's officially released.

Nate711 commented 4 years ago

Where is the correct place to put Make.user? I put it in the top-level directory of julia, but ran into the same error that @horst5000 had where USE_BINARYBUILDER=0 was not actually active. Thanks!

Gnimuc commented 4 years ago

I put it in the top-level directory of julia, but ran into the same error that @horst5000 had where USE_BINARYBUILDER=0 was not actually active.

you could try https://github.com/JuliaInterop/Cxx.jl/issues/436#issuecomment-522993980 as a workaround.

goretkin commented 4 years ago

What is the bug that gives rise to this issue? Since it's possible to use Cxx with a julia binary release, I would expect it's possible to use it with a locally-compiled julia against an LLVM binary release.

Gnimuc commented 4 years ago

Not a bug actually. The reason why we now need to set USE_BINARYBUILDER=0 is that Cxx needs to be built with llvm/clang source code, but in Julia-1.2+ era, when building Julia from source, we only need to download and use llvm/clang binaries from LLVMBuilder, so Cxx cannot find those llvm/clang source files, which gives rise to the issue.

Since it's possible to use Cxx with a julia binary release

The binary build for Cxx ships those llvm/clang sources as well. https://github.com/Gnimuc/CxxBuilder/blob/master/build_tarballs.jl