openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.7k stars 1.76k forks source link

Raspberry pi 4 compile 0.8.2 version #9504

Closed Hadatko closed 4 years ago

Hadatko commented 5 years ago

Hi, i cannot finish build on rasberry pi. I was using steps for rapsberry pi 3 but i am trying to build 0.8.2 version instead of 0.7.x

System information

Type Version/Name
Distribution Name Rasbian
Distribution Version Buster
Linux Kernel 4.19
Architecture arm
ZFS Version 0.8.2
SPL Version ----

Describe the problem you're observing

running install_egg_info
Copying pyzfs.egg-info to /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/usr/lib/python3/dist-packages/pyzfs-0.8.2-py3.7.egg-info
running install_scripts
make[6]: Nothing to be done for 'install-data-am'.
make[6]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2/contrib/pyzfs'
make[5]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2/contrib/pyzfs'
make[5]: Entering directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2/contrib'
make[6]: Entering directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2/contrib'
make[6]: Nothing to be done for 'install-exec-am'.
make[6]: Nothing to be done for 'install-data-am'.
make[6]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2/contrib'
make[5]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2/contrib'
make[4]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2/contrib'
make[4]: Entering directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2'
[ -x ./scripts/zfs-tests.sh ] && \
    ./scripts/zfs-tests.sh -c
make[5]: Entering directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2'
make[5]: Nothing to be done for 'install-exec-am'.
make  install-data-hook
make[6]: Entering directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2'
make[6]: Nothing to be done for 'install-data-hook'.
make[6]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2'
make[5]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2'
make[4]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2'
make[3]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2'
make[2]: Leaving directory '/tmp/zfs-build-pi-N5H6mfE4/BUILD/zfs-0.8.2'
+ find /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/lib/arm-linux-gnueabihf -name *.la -exec rm -f {} ;
+ exit 0
Processing files: zfs-0.8.2-1.armhf
error: File not found: /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/sbin/*
error: File not found: /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/usr/share/man/man1/*
error: File not found: /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/usr/share/man/man5/*
error: File not found: /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/usr/share/man/man8/*
error: File not found: /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/lib/udev/rules.d/*
error: File not found: /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/etc/init.d/*
error: File not found: /tmp/zfs-build-pi-N5H6mfE4/BUILDROOT/zfs-0.8.2-1.%{_arch}/etc/sudoers.d/*

Describe how to reproduce the problem

download zfs 0.8.2 tar gz and unpack cd ../zfs-0.8.2/ autoreconf --install --force ./configure --with-config=srpm sed -E 's/(^RPMBUILD = rpmbuild.)/\1 --target=armhf/' -i Makefile make pkg-utils deb-dkms for deb in .deb; do sudo dpkg -i "$deb"; done

IainCollins262 commented 5 years ago

As far as I can tell the problem is due to rpm not having a definition for the _arch macro.

I managed to build 0.8.2 on my RPi 4 yesterday by modifying the Makefile so that the rpmbuild command also defined _arch (e.g. RPMBUILD = rpmbuild --target=armhf --define "_arch Rpi") and then running the make and dpkg commands again.

I doubt that setting _arch to 'RPi' is the correct value and I haven't testing the resulting binaries in anger (I've just run a couple of simple zpool commands). But this may help some one more knowledgeable identify the correct solution.

behlendorf commented 5 years ago

That's definitely the issue. The _arch macro is expected to be defined in the /usr/lib/rpm/platform/<arch>/macros file, normally at the very top. Is this file missing on the RPi 4 or _arch or is it perhaps simply not defined?

kenthinson commented 5 years ago

@Hadatko Raspbian? I thought 32bit wasn't supported for zfs. Have you tried ubuntu 19.10 64bit?

Hadatko commented 5 years ago

Hi, the last version is still not working for me. I turned on arm64 in boot config. Also i run rpi-update and eeprom update... But i have stable version so not sure if the flag with arm64 is used or skipped.

kenthinson commented 5 years ago

@Hadatko turning on arch64 in the boot loader will still leave you with a 32bit kernel if I'm not mistaken. Not 100% on that. It just allows the system to execute 64bit code. ZOL is supposed to build on 32bit but it's strongly discouraged. It's possible that this is a build bug in zfs.

As far as solutions for you to use in the short term.... Here is some info I found about building a 64bit kernel. https://www.tal.org/tutorials/raspberry-pi3-build-64-bit-kernel

and enabling it. https://www.tal.org/tutorials/booting-64-bit-kernel-raspberry-pi-3

Or you could try the ubuntu arch64 sd card image. Much easier.

Hadatko commented 5 years ago

Hi @kenthinson i like the idea to put ubuntu on raspberry. Is there big difference in performance? Although i am not using gui (i am booting to cmd only) there shouldn't be big difference i guess.

kenthinson commented 5 years ago

@Hadatko seems to work fine for me. I run my personal website from it. I can't attest to ZFS performance as I've never tried on the pi.

Hadatko commented 5 years ago

That is ok. I thought OS performance. I am using samba, dlna, mydownloader.

hostingnuggets commented 5 years ago

@IainCollins262 I tried your workaround of manually adapting the RPMBUILD variable in the Makefile and the re-run make but unfortunately for me it does not work. I am running Raspbian 8 on a Raspberry Pi 3 and would like to compile ZFS 0.7.12 from the release tarball on github.

It fails quite fast at the beginning of the make and that would be the last output:

+ ./configure --host=arm-unknown-linux-gnueabihf --build=arm-unknown-linux-gnueabihf --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/lib/arm-linux-gnueabihf --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --with-config=user --with-udevdir=/lib/udev --with-udevruledir=/lib/udev/rules.d --with-dracutdir=/usr/share/dracut --disable-static --disable-debug --enable-sysvinit --disable-systemd
checking for gawk... gawk
checking metadata... META file
checking build system type... arm-unknown-linux-gnueabihf
checking host system type... arm-unknown-linux-gnueabihf
checking target system type... arm-unknown-linux-gnueabihf
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking whether make sets $(MAKE)... yes
checking for arm-unknown-linux-gnueabihf-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/tmp/zfs-build-pi-fRsgULVX/BUILD/zfs-0.7.12':
configure: error: C compiler cannot create executables
See `config.log' for more details
error: Bad exit status from /tmp/zfs-build-pi-fRsgULVX/TMP/rpm-tmp.Lgphsd (%build)

RPM build errors:
    Bad exit status from /tmp/zfs-build-pi-fRsgULVX/TMP/rpm-tmp.Lgphsd (%build)
Makefile:1212: recipe for target 'rpm-common' failed
make[1]: *** [rpm-common] Error 1
make[1]: Leaving directory '/home/pi/src/zfs-0.7.12'
Makefile:1171: recipe for target 'rpm-utils' failed
make: *** [rpm-utils] Error 2

In the config.log I see the following which must be the relevant part:

configure:3604: $? = 4
configure:3624: checking whether the C compiler works
configure:3646: gcc -O2 -g -march=armv7   conftest.c  >&5
conftest.c:1:0: error: target CPU does not support ARM mode
 /* confdefs.h */
 ^

Any ideas anyone how I can make it compile?

hostingnuggets commented 5 years ago

Just wanted to let you all know that I finally managed to compile ZFS 0.7.12 by upgrading Raspbian jessie to stretch. On stretch compilation runs just fine.

MAFLO321 commented 4 years ago

The following works to build zfs on a Raspberry Pi 4 B

Type Version/Name
Distribution Name Rasbian
Distribution Version Buster
Linux Kernel 4.19.75
Architecture arm
ZFS Version 0.8.2
SPL Version ----
./autogen.sh
./configure --disable-pyzfs
# https://github.com/zfsonlinux/zfs/issues/9504
sed -E 's/(^RPMBUILD = rpmbuild.*)/\1 --define "_arch arm"/' -i Makefile

make deb-dkms deb-utils
loli10K commented 4 years ago

This doesn't seem to be a ZFS specific issue, Debian's rpm package ships its macros in a directory which is not in the canonical search paths:

root@linux:~# rpm -E '%{_arch}'
%{_arch}
root@linux:~# rpm -E '%{_target}'
armv7hnl-linux
root@linux:~# ls -l /usr/lib/rpm/platform/armv7hnl-linux
ls: cannot access '/usr/lib/rpm/platform/armv7hnl-linux': No such file or directory
root@linux:~# ls -l /usr/lib/rpm/platform/armv7hnl-linux-gnueabihf/
total 4
-rw-r--r-- 1 root root 3094 Feb 17  2019 macros
root@linux:~# rpm --macros /usr/lib/rpm/platform/armv7hnl-linux-gnueabihf/macros -E '%{_arch}'
arm
root@linux:~# lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
root@linux:~# 

A bug report on Debian's tracker seems more appropriate here.

awehrfritz commented 4 years ago

@loli10K can you please post the link to the Debian bug report?

I frequently run into this issue when compiling ZFS on a helios4 running Armbian.