Skip to content

Instantly share code, notes, and snippets.

@windelbouwman
Created March 4, 2022 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windelbouwman/1e3deb742c0a5ae399f876ca2eb1b0f1 to your computer and use it in GitHub Desktop.
Save windelbouwman/1e3deb742c0a5ae399f876ca2eb1b0f1 to your computer and use it in GitHub Desktop.
ZFS bitbake recipe
From 290d74cee9f95f3eb859e066ed7024435e70fc64 Mon Sep 17 00:00:00 2001
From: Windel Bouwman <windel@windel.nl>
Date: Fri, 25 Feb 2022 09:43:41 +0100
Subject: [PATCH] Fix aarch64 support.
---
include/os/linux/spl/sys/isa_defs.h | 23 +++++++++++++++--------
lib/libefi/rdwr_efi.c | 2 +-
lib/libspl/include/sys/isa_defs.h | 25 +++++++++++++++++--------
3 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/include/os/linux/spl/sys/isa_defs.h b/include/os/linux/spl/sys/isa_defs.h
index 2207ee2..a032aae 100644
--- a/include/os/linux/spl/sys/isa_defs.h
+++ b/include/os/linux/spl/sys/isa_defs.h
@@ -95,7 +95,7 @@
#define _ALIGNMENT_REQUIRED 1
/* arm arch specific defines */
-#elif defined(__arm) || defined(__arm__) || defined(__aarch64__)
+#elif defined(__arm) || defined(__arm__)
#if !defined(__arm)
#define __arm
@@ -105,17 +105,11 @@
#define __arm__
#endif
-#if defined(__aarch64__)
-#if !defined(_LP64)
-#define _LP64
-#endif
-#else
#if !defined(_ILP32)
#define _ILP32
#endif
-#endif
-#if defined(__ARMEL__) || defined(__AARCH64EL__)
+#if defined(__ARMEL__)
#define _ZFS_LITTLE_ENDIAN
#else
#define _ZFS_BIG_ENDIAN
@@ -127,6 +121,19 @@
*/
#define _ALIGNMENT_REQUIRED 1
+/* aarch64 arch specific defines */
+#elif defined(__aarch64__)
+
+#if !defined(_LP64)
+#define _LP64
+#endif
+
+#if defined(__AARCH64EL__)
+#define _ZFS_LITTLE_ENDIAN
+#else
+#define _ZFS_BIG_ENDIAN
+#endif
+
/* sparc arch specific defines */
#elif defined(__sparc) || defined(__sparc__)
diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c
index 39b3509..1ff806b 100644
--- a/lib/libefi/rdwr_efi.c
+++ b/lib/libefi/rdwr_efi.c
@@ -157,7 +157,7 @@ struct dk_map2 default_vtoc_map[NDKMAP] = {
#if defined(i386) || defined(__amd64) || defined(__arm) || \
defined(__powerpc) || defined(__sparc) || defined(__s390__) || \
- defined(__mips__) || defined(__rv64g__)
+ defined(__mips__) || defined(__rv64g__) || defined(__aarch64__)
{ V_BOOT, V_UNMNT }, /* i - 8 */
{ V_ALTSCTR, 0 }, /* j - 9 */
diff --git a/lib/libspl/include/sys/isa_defs.h b/lib/libspl/include/sys/isa_defs.h
index 8c0932f..3922445 100644
--- a/lib/libspl/include/sys/isa_defs.h
+++ b/lib/libspl/include/sys/isa_defs.h
@@ -126,7 +126,7 @@ extern "C" {
#endif
/* arm arch specific defines */
-#elif defined(__arm) || defined(__arm__) || defined(__aarch64__)
+#elif defined(__arm) || defined(__arm__)
#if !defined(__arm)
#define __arm
@@ -136,17 +136,11 @@ extern "C" {
#define __arm__
#endif
-#if defined(__aarch64__)
-#if !defined(_LP64)
-#define _LP64
-#endif
-#else
#if !defined(_ILP32)
#define _ILP32
#endif
-#endif
-#if defined(__ARMEL__) || defined(__AARCH64EL__)
+#if defined(__ARMEL__)
#define _ZFS_LITTLE_ENDIAN
#else
#define _ZFS_BIG_ENDIAN
@@ -158,6 +152,21 @@ extern "C" {
#define HAVE_EFFICIENT_UNALIGNED_ACCESS
#endif
+/* aarch64 arch specific defines */
+#elif defined(__aarch64__)
+
+#if !defined(_LP64)
+#define _LP64
+#endif
+
+#if defined(__AARCH64EL__)
+#define _ZFS_LITTLE_ENDIAN
+#else
+#define _ZFS_BIG_ENDIAN
+#endif
+
+#define _SUNOS_VTOC_16
+
/* sparc arch specific defines */
#elif defined(__sparc) || defined(__sparc__)
SUMMARY = "OpenZFS on Linux and FreeBSD"
DESCRIPTION = "OpenZFS on Linux and FreeBSD"
LICENSE = "CDDL-1.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=7087caaf1dc8a2856585619f4a787faa"
SRC_URI = "https://github.com/openzfs/zfs/releases/download/${BPN}-${PV}/${BPN}-${PV}.tar.gz \
file://0001-Fix-aarch64-support.patch \
"
SRC_URI[sha256sum] = "258cf1d17a1f668a3b99b61eaf14be06c614df42503db0319bef1b9fc4c8b9e7"
# Using both 'module' and 'autotools' classes seems a bit odd, the both
# define a do_compile function.
# That's why we opt for module-base, also this prevents module splitting.
inherit module-base pkgconfig autotools
DEPENDS = "virtual/kernel zlib util-linux libtirpc openssl"
EXTRA_OECONF:append = " \
--disable-pyzfs \
--with-linux=${STAGING_KERNEL_DIR} --with-linux-obj=${STAGING_KERNEL_BUILDDIR} \
--enable-systemd \
--disable-sysvinit \
--without-dracutdir \
"
do_install:append() {
# /usr/share/zfs contains the zfs-tests folder which we do not need:
rm -rf ${D}${datadir}/zfs
rm -rf ${D}${datadir}/initramfs-tools
}
FILES:${PN} += "\
${base_sbindir}/* \
${base_libdir}/* \
${sysconfdir}/* \
${sbindir}/* \
${bindir}/* \
${libexecdir}/${BPN}/* \
${libdir}/* \
"
FILES:${PN}-dev += "\
${prefix}/src/zfs-${PV}/* \
${prefix}/src/spl-${PV}/* \
"
@ChrisPasda
Copy link

Hey guys,

i am new to yocto and i am trying to build zfs. How can i apply the patch and what should i have to do with the .bb-file? Simple implement it as a reciepe und bitbake it like always? Would it be even possible to load zfs out of initramfs?

Thank you very much in advance and best regards,

Chris

@windelbouwman
Copy link
Author

Hi Chris,

The purpose of this recipe is to place it into your own layer, and include it like that in your system.

Please check on the yocto manuals / tutorials, highly recommended if you are new to yocto. Please note that yocto has some sort of steep learning curve.

Best regards,
Windel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment