JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.58k stars 5.48k forks source link

Julia cannot be compiled anymore on 32bit ARM Linux plus glibc #47345

Open fingolfin opened 1 year ago

fingolfin commented 1 year ago

While trying to update libjulia_jll for the latest Julia master / 1.9-DEV (see https://github.com/JuliaPackaging/Yggdrasil/pull/5506 resp. 9afd74785845accfb93e4b7c88edc35b59f56f9c), we discovered that support for ARM 32bit builds on Linux is broken, as in: Julia does not compile anymore. This seems to go back to PR #45110 by @vtjnash.

I'll summarize the error here, further details can be found on the Yggdrasil PR linked above.

[23:16:44] /workspace/srcdir/julia/src/stackwalk.c: In function 'jl_rec_backtrace':
[23:16:44] /workspace/srcdir/julia/src/stackwalk.c:903:24: error: 'bt_context_t {aka struct unw_tdep_context}' has no member named 'uc_mcontext'
[23:16:44]      mcontext_t *mc = &c.uc_mcontext;
[23:16:44]                         ^
fingolfin commented 1 year ago

CC @giordano @benlorenz

PallHaraldsson commented 1 year ago

Arm 32-bit (unlike 64-bit which is tier 2) is "Tier 3: Julia may or may not build. If it does, it is unlikely to pass tests."

Does that mean even though it built before you can expect this to happen (at least temporarily, i.e. best-effort)? Or should there have been test to prevent this from happening?

fingolfin commented 1 year ago

Yes, I think that's what it means. As I understand it, part of the requirement to move to Tier 2 is to have a responsive CI system which can conduct tests for that platform (on all PRs! So a simple Raspberry Pi wouldn't cut it ;-). Perhaps a cluster... ;-) ). And of course a lot of more powerful ARM hardware is 64 bit.

I guess beyond the hardware support you then also need people able and willing to address regressions...

gbaraldi commented 1 year ago

I imagine that's missing an ifdef somewhere.

vtjnash commented 1 year ago

It looks like ARM doesn't use the usual structure (intentionally) for this struct, so you have to add a cast there to give it the expected struct typedef: https://github.com/libunwind/libunwind/blob/fbaa4d5b0c47a4129ff7e514bdecc284635b36e9/include/libunwind-arm.h#L258-L266

fingolfin commented 1 year ago

@vtjnash So what has to be cast to what?

vtjnash commented 1 year ago

c may need to be cast directly to mcontext_t, instead of getting it from the struct field address

fingolfin commented 1 year ago

I tried mcontext_t *mc = (mcontext_t *)&c; on a RaspBerry Pi but this just lead to a segfault while building Julia, at a point where it tried to run Julia.

fingolfin commented 1 year ago

OK so it already segfaults on my Raspberry Pi when building the previous commit 9a2f5ae0531524e60b3308d7695100b14801534e -- but it also fails building the v1.7.3 tag. Yet the website offers an ARM 32 bit download for Julia 1.7.3. which does seem to work on the Raspberry Pi. So maybe something is wrong with that test setup? Here is the error (the warning about missing gfortran seems problematic -- could that be the cause? (This error is from v1.7.3)

$ make
/bin/sh: 1: gfortran: not found
/bin/sh: 1: gfortran: not found
    JULIA usr/lib/julia/corecompiler.ji
Segmentation fault
make[1]: *** [sysimage.mk:61: /tmpbig/horn/julia.master/usr/lib/julia/corecompiler.ji] Error 139
make: *** [Makefile:82: julia-sysimg-ji] Error 2
fingolfin commented 1 year ago

Forgot to mention: this is a Raspberry Pi 4 Model B Rev 1.4, running Raspbian GNU/Linux 11 (bullseye) on armv7l, CPU: ARMv7 Processor rev 3 (v7l)