Julia Installation on RISC-V (Build Failing at 79%)

I’m trying to build Julia from source for the RISC-V architecture by following the guide provided here: julia/doc/src/devdocs/build/riscv.md at master · alexfanqi/julia · GitHub.

I’m running the script located in my RISC-V environment: build-julia-riscv.sh, but the build process has stopped at 79% with the following error:

collect2: error: ld returned 1 exit status
make[4]: *** [tools/llvm-shlib/CMakeFiles/LLVM.dir/build.make:240: lib/libLLVM-14jl.so] Error 1
make[4]: Leaving directory '/home/user/julia/deps/scratch/llvm-julia-14.0.6-0/build_Release'
make[3]: *** [CMakeFiles/Makefile2:25382: tools/llvm-shlib/CMakeFiles/LLVM.dir/all] Error 2
make[3]: *** Waiting for unfinished jobs....
make[4]: Leaving directory '/home/user/julia/deps/scratch/llvm-julia-14.0.6-0/build_Release'
[ 79%] Built target llvm-exegesis
make[3]: Leaving directory '/home/user/julia/deps/scratch/llvm-julia-14.0.6-0/build_Release'
make[2]: *** [Makefile:159: all] Error 2
make[2]: Leaving directory '/home/user/julia/deps/scratch/llvm-julia-14.0.6-0/build_Release'
make[1]: *** [/home/user/julia/deps/llvm.mk:250: scratch/llvm-julia-14.0.6-0/build_Release/build-compiled] Error 2
make[1]: Leaving directory '/home/user/julia/deps'
make: *** [Makefile:75: julia-deps] Error 2

I’ve already tried the basic debugging steps, including ensuring all dependencies are installed and checking system resources. Despite this, the build keeps failing.

I would really appreciate any guidance on:

  1. How to resolve this specific linking issue.
  2. Whether there are any pre-built Julia binaries or installation packages for the RISC-V architecture that I can use.

Thanks in advance for any help or suggestions!

2 Likes

I suspect the actual error was before the portion you copied. To be clear your build is failing at building llvm.

3 Likes

While I do see in the 2-year-old docs (has there much work been done since? RISC-V support was incomplete then):

Currently, this fork is compiling okay and seems to work fine.

I note that it used patched LLVM 14, and Julia is now at LLVM 18 or 19. It might help, actually, or hurt?

Two years ago is Julia 1.7-1.8 timeframe, and you might start with trying to build such Julia (i.e. some that uses LLVM 14). If you hit success, it might do for you, or then I would try 1.8, 1.9 etc.

RISC-V isn’t yet an officially-supported platform, thus no official binaries, nor unofficial that I know of (i.e. under “General usage” maybe misleading, rather go under internals category?), so unless you really need it, or want to help with it working, why are you using it?

You usually do not have to build Julia from source. It’s only for advanced/developer use, not for beginner Julia users. Not saying you are, maybe you want to help with RISC-V.

RISC-V has no official support tier, not even tier 3, maybe that would have been appropriate at the time, I’m guessing now (unofficial) tier 4 (only 1.10 is now stable version, older no longer supported, 1.10 will become LTS, and then likely 1.6 dropped as LTS soon, I’m even unclear on if 1.6 ever ran RISC-V):

  • Tier 3: Julia may or may not build. If it does, it is unlikely to pass tests. Binaries may be available in some cases. When they are, they should be considered experimental. Ongoing support is dependent on community efforts.
  • Tier 4: Julia built at some point in the past, but is known not to build currently.
2 Likes

I’m having a look at rebasing that branch, and should have a PR ready in a couple of days.

4 Likes
10 Likes

After reading

I was wondering if that’s the time that took you to compile everything :sweat_smile:

2 Likes

A significant part of it, yeah; compiling LLVM on my VisionFive2 is a real doozy! I’ve kicked off a binary-dist build now, with a more conservative rv64gc target, so I should be able to share that here… in a couple of days :sweat_smile:

3 Likes

is it faster to compile on the VisionFive2 or on a VM?

A cross-compiler is probably faster; I didn’t bother setting one up (which is always a bit annoying since how Julia’s build system really expects the ability to execute binaries). It’s just chugging along in the background.

3 Likes

Here’s a build: Release v1.12-0a92fecc12 · maleadt/julia · GitHub

6 Likes

Hi @maleadt ,

I’m trying to install your build on my VisionFive 2 board, but I’m encountering a GLIBC compatibility error. Here’s the output I’m getting:

$ ./julia --version
ERROR: Unable to load dependent library /home/user/julia-0a92fecc12/bin/../lib/julia/libstdc++.so.6
Message:/lib/riscv64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /home/user/julia-0a92fecc12/bin/../lib/ju


$ ldd --version
ldd (Debian GLIBC 2.36-6) 2.36

It seems that the version of GLIBC on my system is 2.36, while the build requires GLIBC 2.38. Could you please guide me on how to resolve this issue? Are there any specific versions of Julia that are compatible with GLIBC 2.36, or would it be better to compile Julia from source?

That’s what I mentioned in the release notes:

Built on Debian Trixie, so requires glibc 2.40.

There’s no easy way to build for an older glibc version, so I won’t be able to easily provide a more compatible build. Even the cross-build environment I’ve just set-up using GitHub - riscv-collab/riscv-gnu-toolchain: GNU toolchain for RISC-V, including GCC is already using glibc 2.40. I’ll try downgrading glibc in there, but no guarantees.

1 Like

Thank you for the update! Would it be possible for you to generate a compatible version of Julia that supports GLIBC version 2.36 in visionfive? That would be incredibly helpful for us, as compiling the source of Julia directly on the VisionFive 2 board takes more than two days.

Not easily; the build I attempted for glibc 2.36 doesn’t execute here on device, and I don’t have the time to debug this. You’ll probably have to build it yourself.

1 Like

Thanks a lot @maleadt ! I have installed it and tested it with a “Hello, World!” program, which is working fine. I will continue to test further.

Interesting; it fails here during module deserialization with a relocation-related error. Glad to see it works for you, at least.

1 Like

I cannot imagine that build working for you, at least not on a VisionFive2. The build of the JuliaSyntaxHighlighting stdlib (which gets loaded as soon as you start the REPL) contains instructions that are not supported on that device:

❯ objdump -d share/julia/compiled/v1.12/JuliaSyntaxHighlighting/lOBbc_7PawL.so | grep -i "vlenb"
    cda2:	c2202673          	csrr	a2,vlenb

Well, the csrr as part of Zicsr is, but the vlenb CSR is only available with Rvv. I’m not sure where this comes from, as I’m building with -march and Julia’s -C set to rv64gc. Maybe we’re not correctly forwarding -C to some of the package image builds…

EDIT: that hypothesis seems correct, Fix `JULIA_CPU_TARGET` being propagated to workers precompiling stdlib pkgimages by KristofferC · Pull Request #54093 · JuliaLang/julia · GitHub

1 Like

With the fix from @kristoffer.carlsson applied, here’s a fully-functional (minus bugs, of course) glibc 2.36 build: Release v1.12-25092a3982 · maleadt/julia · GitHub

1 Like