Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: LoadError: UndefVarError: JULIA_HOME not defined #398

Closed
zsz00 opened this issue Nov 29, 2018 · 6 comments · Fixed by #406
Closed

ERROR: LoadError: UndefVarError: JULIA_HOME not defined #398

zsz00 opened this issue Nov 29, 2018 · 6 comments · Fixed by #406

Comments

@zsz00
Copy link

zsz00 commented Nov 29, 2018

(v1.0) pkg> add Cxx#master

Building Cxx ─→ ~/.julia/packages/Cxx/81BGP/deps/build.log
┌ Error: Error building Cxx:
│ [ Info: Building julia binary build
│ ERROR: LoadError: UndefVarError: JULIA_HOME not defined
│ Stacktrace:
│ [1] top-level scope at logging.jl:312
│ [2] top-level scope at /root/.julia/packages/Cxx/81BGP/deps/build.jl:43
│ [3] include at ./boot.jl:317 [inlined]
│ [4] include_relative(::Module, ::String) at ./loading.jl:1041
│ [5] include(::Module, ::String) at ./sysimg.jl:29
│ [6] include(::String) at ./client.jl:388
│ [7] top-level scope at none:0
│ in expression starting at /root/.julia/packages/Cxx/81BGP/deps/build.jl:42
│ writing path.jl file
│ Tuning for julia installation at /root/julia-1.0/bin with sources possibly at /root/julia-1.0/bin/../..
└ @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1069

Julia Version 1.0.1
Commit 0d713926f8 (2018-09-29 19:05 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

@danieloff
Copy link

danieloff commented Nov 29, 2018

It worked for me when I built Julia from source, I got a similar error when using a download version of julia.

@cdsousa
Copy link

cdsousa commented Nov 29, 2018

It is still not working with non-"built from source" Julia installations. That error could be simply corrected by puttingSys.BINDIR in the place of JULIA_HOME in the deps/build.jl file, but nevertheless everything else is still not prepared to compile the LLVM/Clang 6.0.0 needed by normal downloaded Julia installations.

I'm slowly (just a couple of minute a day) trying to figure out how to use BinaryBuilder.jl to ship compiled LLVM/Clang for Cxx in downloaded Julia installations.

@Gnimuc
Copy link
Member

Gnimuc commented Dec 1, 2018

UPDATE:
It turns out there is no need to rebuid Clang. I uploaded a prebuilt libcxxffi binaries for 64bit Linux:
https://github.com/Gnimuc/LLVMBuilder/releases


@cdsousa I tried a binary build on Linux, after tweaking the makefile, it's basically working.

Prerequisites

Julia binary is not shipped with Clang and LLVM tools, so the first step is to build Julia 1.0 compatible LLVM tools and Clang. Although LLVMBuilder has released several versions of LLVM binaries, it looks like none of them are 1.0 compatible. Fortunately, I've locally(CI is too slow for such a thing) built a 1.0 compatible version a while ago for Clang.jl, so we can use it here. Now, we have LLVM tools, build/libs, build/includes.

Rebuild Clang

Using the Clang built via LLVMBuilder directly, I got weird link errors like cannot find symbol for dump(), so I just rebuild Clang. To build Clang, we need to download LLVM&cfe source code: https://github.com/Gnimuc/Cxx.jl/blob/binary-build/deps/download.jl#L42-L56. We also download Julia source code(src/support). After building Clang, we have Clang build/libs and build/includes.
edit: it looks like the link error is macOS only, I get the same error when building from source(Julia-master):

rontend -lclangTooling -lclangToolingCore -lclangCodeGen -lclangARCMigrate -lclangFormat  build/bootstrap.o 
│ Undefined symbols for architecture x86_64:"llvm::Type::dump() const", referenced from:
│       _llvmtdump in bootstrap.o
│   "llvm::Value::dump() const", referenced from:
│       _ReplaceFunctionForDecl in bootstrap.o
│       _llvmdump in bootstrap.o
│ ld: symbol(s) not found for architecture x86_64
│ clang: error: linker command failed with exit code 1 (use -v to see invocation)
│ make: *** [usr/lib/libcxxffi.dylib] Error 1
│ [ Info: Building julia source build

Build boostrap & libcxxffi

From the source code, we have Clang src/libs, src/include and LLVM src/include. We also have Julia libs and includes that are already shipped with Julia binary by default. Now, just tweak those variables in BuildBootstrap.Makefile to the correct path and it's good to go.

Troubleshooting

if CMake complains about workspace/destdir/XXX cannot find, you may need to tell CMake where those LLVM tools live in. Manually copy-pasting those LLVM tools to workspace/destdir can also do the trick.

@twadleigh
Copy link

@cdsousa, have you made much progress on the BinaryBuilder front? I have some motivation to push that effort forward and might be able to carve out some time for it.

@cdsousa
Copy link

cdsousa commented Jan 2, 2019

@twadleigh , nothing since #390 (comment).
Besides that (that uses a fully build of Cxx from @Gnimuc), I've tried using only the BinaryBuilder of LLVM: #390 (comment), but there is no LLVMBuilder release with the right version, 6.0.0, for julia 1.0.X (and I have not asked the LLVMBuilder authors anyway) (Julia 1.1 will use LLVM 6.0.1).

@Gnimuc
Copy link
Member

Gnimuc commented Jan 3, 2019

Here is the routine I used for building libcxxffi: https://github.com/Gnimuc/LLVMBuilder/tree/libcxxffi-cmake#build-libcxxffi

But I'm still not crystal clear about what's the canonical way to build Julia1.0-compatible LLVM/Clang binaries. You may notice that the BB version I used is 0.0.4 #e973095, but that's not mandatory I guess. In fact, I also tried BB-0.1.0 a while ago, but with no luck, see related reports in this issue. It's possible that I just did something wrong, but I don't have time to look into it, since building LLVM/Clang is very time consuming, it costs about 30min for a single target on my machine, not to mension that BB binaries also need to be redownload when switching versions.

Given prebuild LLVM/Clang binaries, it's actually not hard to build libcxxffi, just cross-compile bootstrap.cpp and link LLVM/Clang and Julia. As for Windows support, the last thing that I can't figure out is the compatibility of Windows Julia binaries. I guess a potential solution would be JuliaLang/julia#30338.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants