3

The PHP-compiler on my Raspberry Pi 4 is only using 32 bits instead of 64 bits. I double-checked my kernel-architecture. Everything is configured to 64 bits...

Do i need to add a additional configuration to compile 64 bit php-code?

PHP test (on my Raspberry Pi 4)

$php -r 'echo PHP_INT_MAX;'

2147483647 (32 bit)

PHP test (on my PC, 64 bit)

php -r 'echo PHP_INT_MAX;'

9223372036854775807 (64 bit)

PHP-Version (on my Raspberry Pi 4)

php -v

Result:

PHP 8.1.13 (cli) (built: Nov 26 2022 14:29:42) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.13, Copyright (c) Zend Technologies
with Zend OPcache v8.1.13, Copyright (c), by Zend Technologies

unix name (on my Raspberry Pi 4)

uname -a  

Linux raspberrypi 5.10.103-v8+ #1529 SMP PREEMPT Tue Mar 8 12:26:46 GMT 2022 aarch64 GNU/Linux

I already updated to PHP 8.1.13 without any effect.

EDIT after Comment of Siguza

file /bin/bash  

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

I am not sure, why this comment is printing out "ELF 32-bit LSB executable".

Edit after Comment of Nate Eldredge

hostnamectl

Static hostname: raspberrypi
Icon name: computer
Machine ID: 082e8c9e42614daa82110aXXXXXXXXXX
Boot ID: 95b916d95e7d47df92342XXXXXXXXXX
Operating System: Raspbian GNU/Linux 11 (bullseye)
Kernel: Linux 5.15.84-v8+
Architecture: arm64

xy8000
  • 31
  • 4
  • 2
    What do `file /bin/bash` and `file $(which php)` print? It's very possible you have a 64bit kernel but 32bit userland. – Siguza Dec 31 '22 at 19:24
  • `file /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 `file $(which php)` /usr/bin/php: symbolic link to /etc/alternatives/php Seems like something is wrong. I don't know why 32bit is printed there... – xy8000 Jan 01 '23 at 12:30
  • What Linux distribution are you using, and how did you install it? Also, how did you install your kernel? – Nate Eldredge Jan 02 '23 at 07:09
  • I added the Information to the article. I followed this article to update to 64Bits: https://www.bastianoso.de/tipps-tricks/raspberry-pi/raspberry-pi-os-auf-64-bit-umstellen.html – xy8000 Jan 02 '23 at 20:53
  • 2
    @xy8000: From that article (translated): "With the switch from the Raspberry Pi OS to 64-bit, we have both the CPU and the operating system on 64-bit, while most programs are still running in 32-bit". So indeed, only your kernel is 64 bits, not userland programs like php. You *might* be able to install a 64-bit php as [multiarch](https://wiki.debian.org/Multiarch/HOWTO), but AFAIK this is not officially supported for Raspbian, and is painful even if it does work. You'll be much happier in the long run if you start over and install a fully 64-bit distro. Ubuntu for instance works fine. – Nate Eldredge Jan 03 '23 at 01:20
  • @NateEldredge: Thanks for your reply. That could be the problem. I will add the solution to the question. – xy8000 Jan 08 '23 at 11:29
  • 2
    @xy8000 Do not add the solution to your question. Instead, post an answer below the question. – Progman Jan 08 '23 at 12:03

1 Answers1

0

Solution (see comment from Nate Eldredge):

I followed this german article to upgrade the kernel to 64bits. Nate Eldredge responded with a possible solution. Quoted Comment:

From that article (translated): "With the switch from the Raspberry Pi OS to 64-bit, we have both the CPU and the operating system on 64-bit, while most programs are still running in 32-bit". So indeed, only your kernel is 64 bits, not userland programs like php. You might be able to install a 64-bit php as multiarch, but AFAIK this is not officially supported for Raspbian, and is painful even if it does work. You'll be much happier in the long run if you start over and install a fully 64-bit distro. Ubuntu for instance works fine.

xy8000
  • 31
  • 4