diff mbox series

package/zfs: fix zfs autotools cross-compilation

Message ID 20231112221115.2289525-3-salvador.joseluis@gmail.com
State Accepted
Headers show
Series package/zfs: fix zfs autotools cross-compilation | expand

Commit Message

José Luis Salvador Rufo Nov. 12, 2023, 10:11 p.m. UTC
This commit addresses a long-standing bug encountered during ZFS
compilation in cross-platform environments. The issue arises because ZFS
autoconf triggers a `make modules` to detect if the kernel can compile
modules [1]. The problem occurs when autoconf uses the host environment
instead of the cross-platform environment.

To fix this, we export necessary environment variables to ensure that ZFS
autoconf utilizes the cross-platform environment correctly.

This patch resolves ZFS cross-platform compilations:
- http://autobuild.buildroot.net/results/ebeab256101bcba38c35fd55075c414e62f92caa/
- http://autobuild.buildroot.net/results/03b9f12a106bf100eec695a92b83bf09b22c68b0/
- http://autobuild.buildroot.net/results/c2da90337463607c2fadfeac7ad72e5c3899a61f/
- http://autobuild.buildroot.net/results/465a249f92d2f5db7ac4b61b4111e6cbaaa15688/
- http://autobuild.buildroot.net/results/7e2d3277e26fa5b0c8073a0e8b9e82f47ade9697/
- http://autobuild.buildroot.net/results/a8fb87336b09fef8787a7889dfcccf14fe1215b9/
- https://gitlab.com/kubu93/buildroot/-/jobs/1522848483

And fix a few emails:
- alpine.DEB.2.22.394.2108181630280.2028262@ridzo [build zfs into buildroot for raspberry pi 4]
- https://lists.buildroot.org/pipermail/buildroot/2021-August/621696.html
- https://lists.buildroot.org/pipermail/buildroot/2021-August/621345.html
- https://lists.buildroot.org/pipermail/buildroot/2022-July/646379.html
- https://lists.buildroot.org/pipermail/buildroot/2023-June/668467.html

[1] This is the full callback, you can just check the last link:
- https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel-declare-event-class.m4#L7C11-L7C11
- https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L883
- https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L868
- https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L668

Signed-off-by: José Luis Salvador Rufo <salvador.joseluis@gmail.com>
---
 package/zfs/zfs.mk | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Yann E. MORIN Nov. 26, 2023, 4:21 p.m. UTC | #1
José, All,

On 2023-11-12 23:11 +0100, José Luis Salvador Rufo spake thusly:
> This commit addresses a long-standing bug encountered during ZFS
> compilation in cross-platform environments. The issue arises because ZFS
> autoconf triggers a `make modules` to detect if the kernel can compile
> modules [1]. The problem occurs when autoconf uses the host environment
> instead of the cross-platform environment.
> 
> To fix this, we export necessary environment variables to ensure that ZFS
> autoconf utilizes the cross-platform environment correctly.
> 
> This patch resolves ZFS cross-platform compilations:
> - http://autobuild.buildroot.net/results/ebeab256101bcba38c35fd55075c414e62f92caa/
> - http://autobuild.buildroot.net/results/03b9f12a106bf100eec695a92b83bf09b22c68b0/
> - http://autobuild.buildroot.net/results/c2da90337463607c2fadfeac7ad72e5c3899a61f/
> - http://autobuild.buildroot.net/results/465a249f92d2f5db7ac4b61b4111e6cbaaa15688/
> - http://autobuild.buildroot.net/results/7e2d3277e26fa5b0c8073a0e8b9e82f47ade9697/
> - http://autobuild.buildroot.net/results/a8fb87336b09fef8787a7889dfcccf14fe1215b9/
> - https://gitlab.com/kubu93/buildroot/-/jobs/1522848483
> 
> And fix a few emails:
> - alpine.DEB.2.22.394.2108181630280.2028262@ridzo [build zfs into buildroot for raspberry pi 4]
> - https://lists.buildroot.org/pipermail/buildroot/2021-August/621696.html
> - https://lists.buildroot.org/pipermail/buildroot/2021-August/621345.html
> - https://lists.buildroot.org/pipermail/buildroot/2022-July/646379.html
> - https://lists.buildroot.org/pipermail/buildroot/2023-June/668467.html
> 
> [1] This is the full callback, you can just check the last link:
> - https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel-declare-event-class.m4#L7C11-L7C11
> - https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L883
> - https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L868
> - https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L668
> 
> Signed-off-by: José Luis Salvador Rufo <salvador.joseluis@gmail.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  package/zfs/zfs.mk | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/package/zfs/zfs.mk b/package/zfs/zfs.mk
> index f0461ea9ec..ab530cbcf0 100644
> --- a/package/zfs/zfs.mk
> +++ b/package/zfs/zfs.mk
> @@ -59,6 +59,14 @@ else
>  ZFS_CONF_OPTS += --disable-pam
>  endif
>  
> +# Sets the environment for the `make` that will be run ZFS autotools checks.
> +ZFS_CONF_ENV += \
> +	ARCH=$(KERNEL_ARCH) \
> +	CROSS_COMPILE="$(TARGET_CROSS)"
> +ZFS_MAKE_ENV += \
> +	ARCH=$(KERNEL_ARCH) \
> +	CROSS_COMPILE="$(TARGET_CROSS)"
> +
>  # ZFS userland tools are unfunctional without the Linux kernel modules.
>  ZFS_MODULE_SUBDIRS = \
>  	module/avl \
> -- 
> 2.42.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Peter Korsgaard Nov. 30, 2023, 8:17 a.m. UTC | #2
>>>>> "José" == José Luis Salvador Rufo <salvador.joseluis@gmail.com> writes:

 > This commit addresses a long-standing bug encountered during ZFS
 > compilation in cross-platform environments. The issue arises because ZFS
 > autoconf triggers a `make modules` to detect if the kernel can compile
 > modules [1]. The problem occurs when autoconf uses the host environment
 > instead of the cross-platform environment.

 > To fix this, we export necessary environment variables to ensure that ZFS
 > autoconf utilizes the cross-platform environment correctly.

 > This patch resolves ZFS cross-platform compilations:
 > - http://autobuild.buildroot.net/results/ebeab256101bcba38c35fd55075c414e62f92caa/
 > - http://autobuild.buildroot.net/results/03b9f12a106bf100eec695a92b83bf09b22c68b0/
 > - http://autobuild.buildroot.net/results/c2da90337463607c2fadfeac7ad72e5c3899a61f/
 > - http://autobuild.buildroot.net/results/465a249f92d2f5db7ac4b61b4111e6cbaaa15688/
 > - http://autobuild.buildroot.net/results/7e2d3277e26fa5b0c8073a0e8b9e82f47ade9697/
 > - http://autobuild.buildroot.net/results/a8fb87336b09fef8787a7889dfcccf14fe1215b9/
 > - https://gitlab.com/kubu93/buildroot/-/jobs/1522848483

 > And fix a few emails:
 > - alpine.DEB.2.22.394.2108181630280.2028262@ridzo [build zfs into buildroot for raspberry pi 4]
 > - https://lists.buildroot.org/pipermail/buildroot/2021-August/621696.html
 > - https://lists.buildroot.org/pipermail/buildroot/2021-August/621345.html
 > - https://lists.buildroot.org/pipermail/buildroot/2022-July/646379.html
 > - https://lists.buildroot.org/pipermail/buildroot/2023-June/668467.html

 > [1] This is the full callback, you can just check the last link:
 > - https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel-declare-event-class.m4#L7C11-L7C11
 > - https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L883
 > - https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L868
 > - https://github.com/openzfs/zfs/blob/zfs-2.1.12/config/kernel.m4#L668

 > Signed-off-by: José Luis Salvador Rufo <salvador.joseluis@gmail.com>

Committed to 2023.02.x and 2023.08.x, thanks.
diff mbox series

Patch

diff --git a/package/zfs/zfs.mk b/package/zfs/zfs.mk
index f0461ea9ec..ab530cbcf0 100644
--- a/package/zfs/zfs.mk
+++ b/package/zfs/zfs.mk
@@ -59,6 +59,14 @@  else
 ZFS_CONF_OPTS += --disable-pam
 endif
 
+# Sets the environment for the `make` that will be run ZFS autotools checks.
+ZFS_CONF_ENV += \
+	ARCH=$(KERNEL_ARCH) \
+	CROSS_COMPILE="$(TARGET_CROSS)"
+ZFS_MAKE_ENV += \
+	ARCH=$(KERNEL_ARCH) \
+	CROSS_COMPILE="$(TARGET_CROSS)"
+
 # ZFS userland tools are unfunctional without the Linux kernel modules.
 ZFS_MODULE_SUBDIRS = \
 	module/avl \