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.

4
  • 1
    "It looks almost like there is the wrong architecture defined." -> You might want to demonstrate you actually are doing this on a 64-bit userland by editing in the output from file (which bash). (If you are using stock Raspbian/RpiOS, it is 32-bit, and running it on a Pi 4 does not change this.) Commented Aug 24, 2021 at 15:48
  • I added output of some commands. Commented Aug 25, 2021 at 13:48
  • Notice that bash is an "ELF 32-bit LSB executable". That means the entire userland is 32-bit (this is explained more in my comments on your answer). You can't build (or run, or meaningfully use) a 64-bit anything that way. Commented Aug 26, 2021 at 13:56
  • I removed "arm64" from the title because it makes it read a bit as if what you wanted to do was install the 64-bit version and you are confused why it doesn't work, when what really happened is probably what is described in Dmitry's answer: raspberrypi.stackexchange.com/a/130868/5538 Commented Aug 26, 2021 at 14:05

3 Answers 3

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).

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.

4
  • "I have compiled ruby 2.7 only yesterday with rvm on a pi 4 running the latest updated buster OS." -> The latest updated (non-beta) Buster RpiOS is 32-bit, but the OP seems to be using a 64-bit OS (either the beta RpiOS or something else). Commented Aug 24, 2021 at 15:50
  • @goldilocks Good point, I totally missed the ARM64 reference, thanks Commented Aug 24, 2021 at 15:54
  • My problem doesn't seem to be in the installed tools. What happens is that one of the provide assembler files contains code not valid for the current architecture. I couldn't find a source on how to force a certain architecture. Commented Aug 25, 2021 at 13:50
  • It's not valid for the architecture because you installed or tried to build the 64-bit version on a 32-bit system, hence you get "illegal instruction" when you try to run it. Commented Aug 26, 2021 at 13:58
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.

4
  • 1
    "I think that's the 32-bit version." uname tell you the architecture of the kernel. That actually isn't what is important, except that to run a 64-bit userland you need a 64-bit kernel -- but running a 64-bit kernel doesn't make it so, because you can also run a 32-bit userland that way. Which is what the stock Raspbian/RpiOS is; 32-bit, although on some models it loads a 64-bit kernel by default. To build or use 64-bit software, you need a 64-bit kernel and a 64-bit userland. Commented Aug 26, 2021 at 13:52
  • 1
    "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." -> Perhaps you typo'd 64 and 32 backward here but again: To build 64-bit software you need a 64-bit userland. It is not possible otherwise. Commented Aug 26, 2021 at 13:54
  • I’ll go back and try to install a 64 bit version of kernel and userland. Commented Aug 27, 2021 at 11:52
  • 1
    I had the same problem: 64 bits kernel loaded on a 32 bits userland. Checking my /boot/config.txt configuration I had the arm_64bit=1 option. By commenting it, I was able to reboot under a 32 bits kernel and the compilation went well. Commented Sep 13, 2022 at 13:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.