Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for cross-compiling kernel modules #16924

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,16 @@ AC_DEFUN([ZFS_LINUX_COMPILE], [
building kernel modules])
AC_ARG_VAR([KERNEL_LLVM], [Binary option to
build kernel modules with LLVM/CLANG toolchain])
AC_ARG_VAR([KERNEL_CROSS_COMPILE], [Cross compile prefix
for kernel module builds])
AC_ARG_VAR([KERNEL_ARCH], [Architecture to build kernel modules for])
AC_TRY_COMMAND([
KBUILD_MODPOST_NOFINAL="$5" KBUILD_MODPOST_WARN="$6"
make modules -k -j$TEST_JOBS ${KERNEL_CC:+CC=$KERNEL_CC}
${KERNEL_LD:+LD=$KERNEL_LD} ${KERNEL_LLVM:+LLVM=$KERNEL_LLVM}
CONFIG_MODULES=y CFLAGS_MODULE=-DCONFIG_MODULES
${KERNEL_CROSS_COMPILE:+CROSS_COMPILE=$KERNEL_CROSS_COMPILE}
${KERNEL_ARCH:+ARCH=$KERNEL_ARCH}
behlendorf marked this conversation as resolved.
Show resolved Hide resolved
-C $LINUX_OBJ $ARCH_UM M=$PWD/$1 >$1/build.log 2>&1])
AS_IF([AC_TRY_COMMAND([$2])], [$3], [$4])
])
Expand Down
2 changes: 2 additions & 0 deletions config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ AC_DEFUN([ZFS_AC_RPM], [
RPM_DEFINE_KMOD=${RPM_DEFINE_KMOD}' --define "kernel_cc KERNEL_CC=$(KERNEL_CC)"'
RPM_DEFINE_KMOD=${RPM_DEFINE_KMOD}' --define "kernel_ld KERNEL_LD=$(KERNEL_LD)"'
RPM_DEFINE_KMOD=${RPM_DEFINE_KMOD}' --define "kernel_llvm KERNEL_LLVM=$(KERNEL_LLVM)"'
RPM_DEFINE_KMOD=${RPM_DEFINE_KMOD}' --define "kernel_cross_compile KERNEL_CROSS_COMPILE=$(KERNEL_CROSS_COMPILE)"'
RPM_DEFINE_KMOD=${RPM_DEFINE_KMOD}' --define "kernel_arch KERNEL_ARCH=$(KERNEL_ARCH)"'
])

RPM_DEFINE_DKMS=''
Expand Down
2 changes: 2 additions & 0 deletions module/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ modules-Linux:
mkdir -p $(sort $(dir $(zfs-objs) $(zfs-)))
$(MAKE) -C @LINUX_OBJ@ $(if @KERNEL_CC@,CC=@KERNEL_CC@) \
$(if @KERNEL_LD@,LD=@KERNEL_LD@) $(if @KERNEL_LLVM@,LLVM=@KERNEL_LLVM@) \
$(if @KERNEL_CROSS_COMPILE@,CROSS_COMPILE=@KERNEL_CROSS_COMPILE@) \
$(if @KERNEL_ARCH@,ARCH=@KERNEL_ARCH@) \
M="$$PWD" @KERNEL_MAKE@ CONFIG_ZFS=m modules

modules-FreeBSD:
Expand Down
4 changes: 3 additions & 1 deletion rpm/generic/zfs-kmod.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ for kernel_version in %{?kernel_versions}; do
%{debuginfo} \
%{?kernel_cc} \
%{?kernel_ld} \
%{?kernel_llvm}
%{?kernel_llvm} \
%{?kernel_cross_compile} \
%{?kernel_arch}

# Pre-6.10 kernel builds didn't need to copy over the source files to the
# build directory. However we do need to do it though post-6.10 due to
Expand Down
4 changes: 3 additions & 1 deletion rpm/redhat/zfs-kmod.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ fi
%{debuginfo} \
%{?kernel_cc} \
%{?kernel_ld} \
%{?kernel_llvm}
%{?kernel_llvm} \
%{?kernel_cross_compile} \
%{?kernel_arch}
make %{?_smp_mflags}

# Module signing (modsign)
Expand Down
Loading