Problem installing prerequisites for building Julia

The README for the official julia repo links to this set of instructions for building julia. The latter link states that

On Debian-based distributions (e.g. Ubuntu), you can easily install them with apt-get:
sudo apt-get install build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config curl

However, when I run those commands (on a raspberry pi) I get the following error:

pi@raspberrypi:~/julia $ sudo apt-get install build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  python-is-python3 2to3

E: Package 'python' has no installation candidate

When I call python from the command line, python 3.11.2 opens up just fine:

pi@raspberrypi:~/julia $ python
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

Should the error that occurs when installing prerequisites just be ignored? The build later went on to fail, and I keep getting errors of the type seen in the screenshot below:

My use-case is that I need a later version of julia on a raspberry pi on order to use functionality implemented after 1.6.

Perhaps a symlink for python3 in /usr/bin? I think that is how the build tools call it. Or perhaps in your apt install line, just change python to python3?

Raspberry Pi does a lot of custom things … but then again so do most distros. On WSL2 (specifically, the Ubuntu one), calling python3 gives you a symlink to /usr/bin/python3.10

I end up getting the following error:

Copying in usr/share/man/man1/julia.1
/home/pi/julia/contrib/install.sh 755 /home/pi/julia/contrib/julia-config.jl /home/pi/julia/usr/share/julia/
    PERL base/pcre_h.jl
    PERL base/errno_h.jl
    PERL base/build_h.jl.phony
    PERL base/features_h.jl
    PERL base/features_h.jl
    PERL base/features_h.jl
    PERL base/file_constants.jl
    PERL base/uv_constants.jl
    PERL base/version_git.jl.phony
    CC cli/loader_exe.o
    CC cli/loader_lib.o
    CC cli/loader_trampolines.o
    LINK usr/lib/libjulia.so.1.9
    LINK usr/lib/libjulia.so.1
    LINK usr/lib/libjulia.so
    LINK usr/bin/julia
    CC src/support/hashing.o
    CC src/support/timefuncs.o
    CC src/support/ptrhash.o
    CC src/support/operators.o
    CC src/support/utf8.o
    CC src/support/ios.o
    CC src/support/htable.o
    CC src/support/bitvector.o
    CC src/support/int2str.o
    CC src/support/libsupportinit.o
    CC src/support/arraylist.o
    CC src/support/strtod.o
    CC src/support/rle.o
    LINK src/support/libsupport.a
    CC src/flisp/flisp.o
    CC src/flisp/builtins.o
    CC src/flisp/string.o
    CC src/flisp/equalhash.o
    CC src/flisp/table.o
    CC src/flisp/iostream.o
    CC src/flisp/julia_extensions.o
    LINK src/flisp/libflisp.a
    CC src/flisp/flmain.o
    LINK src/flisp/flisp
    FLISP src/julia_flisp.boot
    FLISP src/julia_flisp.boot.inc
    CC src/jltypes.o
    CC src/gf.o
    CC src/typemap.o
    CC src/smallintset.o
    CC src/ast.o
    CC src/builtins.o
    CC src/module.o
    CC src/interpreter.o
    CC src/symbol.o
    CC src/dlload.o
    CC src/sys.o
    CC src/init.o
    CC src/task.o
    CC src/array.o
    CC src/staticdata.o
    CC src/toplevel.o
    CC src/jl_uv.o
    CC src/datatype.o
    CC src/simplevector.o
    CC src/runtime_intrinsics.o
    CC src/precompile.o
    CC src/jloptions.o
    CC src/threading.o
    CC src/partr.o
    CC src/stackwalk.o
/home/pi/julia/src/stackwalk.c: In function 'jl_rec_backtrace':
/home/pi/julia/src/stackwalk.c:903:24: error: 'bt_context_t' {aka 'struct unw_tdep_context'} has no member named 'uc_mcontext'
  903 |     mcontext_t *mc = &c.uc_mcontext;
      |                        ^
make[1]: *** [Makefile:225: stackwalk.o] Error 1
make: *** [Makefile:78: julia-src-release] Error 2

Doing into /usr/bin and doing ls reveals that “python”, “python3” and “python3.11” are defined. Do you think that I need to add another excecutable inside bin? Would that explain the error that occurs?

The error you copied does not look like a Python error … seems like what happened is that apt just warned you that it couldn’t find a package named python to install, but it didn’t matter, because Raspbian has Python3 installed anyhow. From what you say about /usr/bin you don’t need to make any changes there.

The error you listed seems to indicate that the source for stackwalk.c has a problem somewhere near it. I’m running the latest from github, so my source will be different, but the uc_mcontext field appears to be a member of _JUMP_BUFFER. Grep’ing in the source for that string only yields two files: win32_ucontext.c and stackwalk.c, but neither appear to define it. Really not sure where it is defined?

How are you downloading and building? I usually just git clone the link in GitHub and then make -j4 to get an executable …

1 Like

You should file an issue for this, it sounds like maybe 32-bit ARM is missing an implementation in libunwind (where I suspect uc_mcontext comes from).

1 Like

32-bit arm platforms have been broken for a while:

2 Likes

I tried installing dependencies, cloning, doing git checkout v1.9.3, and running make. When that did not work, I tried what is recommended in jlcross. Specifically, there is this section in the readme:


In the comment section of that gist, we are told to put the following content inside Make.user:

MARCH="armv7-a"
LDFLAGS=-latomic
prefix=~/binary_0407

That however produces error: '-mfloat-abi=hard': selected architecture lacks an FPU.

But it seems like building on raspberry pi has been broken for a year, as seen in the post marked as a solution. I guess I should not expect to get 1.9 or 1.10 running anytime soon.

Hmm, I’m sorry to hear that you are running in to so many problems with that. My RPi is still in a box somewhere … I have a Pi3 … this blogger seems to have installed Julia 1.5.3 from the repository on RPi. Perhaps it might be good enough for you though?

Also, I’m sure your search-engine kung-fu is as good as mine, but this project might also have some folks that know how to fix it?

The official binaries are for 1.6.7, ao the problem is getting a later version than that.

Regarding JuliaBerry, I happen to be the one who made the latest significant commit to the installation instructions :sweat_smile: it was their build-instructions I started using.

I have same the problem when I build Julia v1.10, 1.11 for RaspberryPi3.

The following Make.user

# Make.user
MARCH="armv7-a+neon-vfpv4"

and the following patch may solve our problem.

diff --git a/src/processor_arm.cpp b/src/processor_arm.cpp
index 0d069b085a..6b7279cd21 100644
--- a/src/processor_arm.cpp
+++ b/src/processor_arm.cpp
@@ -1649,13 +1649,15 @@ static void ensure_jit_target(bool imaging)
         auto &features0 = jit_targets[t.base].en.features;
         // Always clone when code checks CPU features
         t.en.flags |= JL_TARGET_CLONE_CPU;
-        static constexpr uint32_t clone_fp16[] = {Feature::fp16fml,Feature::fullfp16};
+        /*
+	static constexpr uint32_t clone_fp16[] = {Feature::fp16fml,Feature::fullfp16};
         for (auto fe: clone_fp16) {
             if (!test_nbit(features0, fe) && test_nbit(t.en.features, fe)) {
                 t.en.flags |= JL_TARGET_CLONE_FLOAT16;
                 break;
             }
         }
+	*/
         // The most useful one in general...
         t.en.flags |= JL_TARGET_CLONE_LOOP;
 #ifdef _CPU_ARM_
@@ -1834,7 +1836,7 @@ JL_DLLEXPORT jl_value_t *jl_cpu_has_fma(int bits)
 #else
     TargetData<feature_sz> target = jit_targets.front();
     FeatureList<feature_sz> features = target.en.features;
-    if (bits == 32 && test_nbit(features, Feature::vfp4sp))
+    if (bits == 32 && test_nbit(features, Feature::vfp4))
         return jl_true;
     else if ((bits == 64 || bits == 32) && test_nbit(features, Feature::vfp4))
         return jl_true;
diff --git a/src/runtime_intrinsics.c b/src/runtime_intrinsics.c
index ff479a4d30..e4126498ff 100644
--- a/src/runtime_intrinsics.c
+++ b/src/runtime_intrinsics.c
@@ -256,9 +256,11 @@ JL_DLLEXPORT float julia_half_to_float(uint16_t param) {
      (defined(__clang__) && __clang_major__ > 14)) && \
     !defined(_CPU_PPC64_) && !defined(_CPU_PPC_) && \
     !defined(_OS_WINDOWS_)
-    #define FLOAT16_TYPE _Float16
-    #define FLOAT16_TO_UINT16(x) (*(uint16_t*)&(x))
-    #define FLOAT16_FROM_UINT16(x) (*(_Float16*)&(x))
+    // otherwise, pass using floating-point calling conventions
+    #define FLOAT16_TYPE float
+    #define FLOAT16_TO_UINT16(x) ((uint16_t)*(uint32_t*)&(x))
+    #define FLOAT16_FROM_UINT16(x) ({ uint32_t tmp = (uint32_t)(x); *(float*)&tmp; })
+
 // on older compilers, we need to emulate the platform-specific ABI
 #elif defined(_CPU_X86_) || (defined(_CPU_X86_64_) && !defined(_OS_WINDOWS_))
     // on x86, we can use __m128; except on Windows where x64 calling
diff --git a/src/stackwalk.c b/src/stackwalk.c
index 37f2396095..e12fc139d1 100644
--- a/src/stackwalk.c
+++ b/src/stackwalk.c
@@ -915,6 +915,8 @@ static void jl_rec_backtrace(jl_task_t *t) JL_NOTSAFEPOINT
         context = &t->ctx.ctx;
 #elif defined(JL_HAVE_UCONTEXT)
         context = jl_to_bt_context(&t->ctx.ctx);
+#elif defined(_OS_LINUX_) && defined(__GLIBC__)
+	context = jl_to_bt_context(&t->ctx.ctx);
 #elif defined(JL_HAVE_ASM)
         memset(&c, 0, sizeof(c));
      #if defined(_OS_LINUX_) && defined(__GLIBC__)

Did you look at Fixes for armv7l buildbots by staticfloat · Pull Request #51945 · JuliaLang/julia · GitHub?

Thank you!!! I’ll check!!!

With a little/messy modification, I could build Julia for 32-bit Raspberry Pi OS.

It’s time to feedback staticfloat’s PR.

1 Like

Amazing! Are you good with standing behind the push to get those changes to the build process into the official build scripts, so that no hacking is needed after?

Yes, I agree.