2

I'm trying to install Ruby version 2.7.x or 3.0.x using rvm on a Pi 4. The make process fails compiling the file coroutine/arm64/Context.S

assembling coroutine/arm64/Context.S
coroutine/arm64/Context.S: Assembler messages:
coroutine/arm64/Context.S:25: Error: shift expression expected -- `sub sp,sp,0xb0'
coroutine/arm64/Context.S:28: Error: bad instruction `stp d8,d9,[sp,0x00]'
coroutine/arm64/Context.S:29: Error: bad instruction `stp d10,d11,[sp,0x10]'
coroutine/arm64/Context.S:30: Error: bad instruction `stp d12,d13,[sp,0x20]'
coroutine/arm64/Context.S:31: Error: bad instruction `stp d14,d15,[sp,0x30]'
coroutine/arm64/Context.S:32: Error: bad instruction `stp x19,x20,[sp,0x40]'
coroutine/arm64/Context.S:33: Error: bad instruction `stp x21,x22,[sp,0x50]'
coroutine/arm64/Context.S:34: Error: bad instruction `stp x23,x24,[sp,0x60]'
coroutine/arm64/Context.S:35: Error: bad instruction `stp x25,x26,[sp,0x70]'
coroutine/arm64/Context.S:36: Error: bad instruction `stp x27,x28,[sp,0x80]'
coroutine/arm64/Context.S:37: Error: bad instruction `stp x29,x30,[sp,0x90]'
coroutine/arm64/Context.S:40: Error: ARM register expected -- `str x30,[sp,0xa0]'
coroutine/arm64/Context.S:43: Error: ARM register expected -- `mov x2,sp'
coroutine/arm64/Context.S:44: Error: ARM register expected -- `str x2,[x0,0]'
coroutine/arm64/Context.S:47: Error: ARM register expected -- `ldr x3,[x1,0]'
coroutine/arm64/Context.S:48: Error: immediate expression requires a # prefix -- `mov sp,x3'
coroutine/arm64/Context.S:51: Error: bad instruction `ldp d8,d9,[sp,0x00]'
coroutine/arm64/Context.S:52: Error: bad instruction `ldp d10,d11,[sp,0x10]'
coroutine/arm64/Context.S:53: Error: bad instruction `ldp d12,d13,[sp,0x20]'
coroutine/arm64/Context.S:54: Error: bad instruction `ldp d14,d15,[sp,0x30]'
coroutine/arm64/Context.S:55: Error: bad instruction `ldp x19,x20,[sp,0x40]'
coroutine/arm64/Context.S:56: Error: bad instruction `ldp x21,x22,[sp,0x50]'
coroutine/arm64/Context.S:57: Error: bad instruction `ldp x23,x24,[sp,0x60]'
coroutine/arm64/Context.S:58: Error: bad instruction `ldp x25,x26,[sp,0x70]'
coroutine/arm64/Context.S:59: Error: bad instruction `ldp x27,x28,[sp,0x80]'
coroutine/arm64/Context.S:60: Error: bad instruction `ldp x29,x30,[sp,0x90]'
coroutine/arm64/Context.S:63: Error: ARM register expected -- `ldr x4,[sp,0xa0]'
coroutine/arm64/Context.S:66: Error: shift expression expected -- `add sp,sp,0xb0'
coroutine/arm64/Context.S:69: Error: bad instruction `ret x4'
make: *** [Makefile:430: coroutine/arm64/Context.o] Error 1

It looks almost like there is the wrong architecture defined. I tried to compile Ruby from the github repo but ran into the same problem.

output from some system commands

root@callisto:~# file $(which bash)
/usr/bin/bash: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=3e5e2847bbc51da2ab313bc53d4bdcff0faf2462, stripped

root@callisto:~# uname -a Linux callisto 5.10.52-v8+ #1441 SMP PREEMPT Tue Aug 3 18:14:03 BST 2021 aarch64 GNU/Linux

root@callisto:~# lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster

Any ideas what I could do? Given that I can't find anything it might be a local problem and I'll have to reinstall the OS.

goldilocks
  • 60,325
  • 17
  • 117
  • 234

3 Answers3

3

It is wrong architecture: you're trying to build arm64 code with an arm32 assembler. You need to install the toolchain which produces Aarch64 code (crossbuild-essential-arm64?), or specify ARM or ARMv7 in the build options if you want to build a 32-bit version.

If you don't specify the target architecture, the architecture of your system is used implicitly as a target by the build scripts. That's why you only get the problem on 64-bit system: I dare to guess you had a 64-bit kernel with a 32-bit userland, and that made the build scripts assume your system was really 64-bit, which it wasn't. It's tempting for build script writers to call the POSIX-standard uname and assume the kernel and the userland have the same architecture, instead of parsing the output of a distro-specific command which prints the userland architecture (for the Pi that would be dpkg-architecture).

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
1

I have compiled ruby 2.7 only yesterday with rvm on a pi 4 running the latest updated buster OS. I use this as part of a script which installs a software suite on a Pi 4 after a fresh install and update

I use these commands before creating an rvmrc file which requires ruby 2.7, as soon as I activate the rvmrc then it prompts me to build ruby 2.7 and the command completes successfully

sudo apt-get install -y nodejs
sudo apt-get install -y gnupg2
sudo apt-get install -y build-essential
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
curl -sSL https://get.rvm.io | bash -s stable

If you do this then log out and back in to get the environment set up and it still fails maybe you should start with a fresh install and see If it works then.

SEWTGIYWTKHNTDS
  • 458
  • 3
  • 8
1

After reimaging the sd card with the latest Raspbian version (7-may-2021) the problem didn't happen anymore.

I noticed that the output of uname -a now shows armv71. I think that's the 32-bit version. free shows 8gb of memory which I hope can be used be all applications.

I must have installed the 64-bit version earlier which led to the problem. I still don't understand why it happened though and how I could build a 64-bit version of Ruby on that system configuration.