Skip to content

Commit 4f0ec3e

Browse files
committed
linux: Fix out-of-src builds
The linux kernel modules haven't been building successfully when the build occurs in a separate directory than the source code, which is a common build pattern in Linux. Was not able to determine the root cause, but the %.o targets in subdirectories are no longer being matched by the pattern targets in the Linux Kbuild system. This change fixes the issue by dynamically creating the missing ones inside our Kbuild. Signed-off-by: Coleman Kane <[email protected]>
1 parent 6af8db6 commit 4f0ec3e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

module/Kbuild.in

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,34 @@ UBSAN_SANITIZE_zfs/sa.o := n
494494
ifeq ($(CONFIG_ALTIVEC),y)
495495
$(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec
496496
endif
497+
498+
# The following recipes attempt to fix out of src-tree builds, where $(src) != $(obj), so that the
499+
# subdir %.c/%.S -> %.o targets will work as expected. The in-kernel pattern targets do not seem to
500+
# be working on subdirs since about ~6.10
501+
zobjdirs = $(dir $(zfs-objs)) $(dir $(spl-objs)) \
502+
$(dir $(zfs-$(CONFIG_X86))) $(dir $(zfs-$(CONFIG_UML_X86))) $(dir $(zfs-$(CONFIG_ARM64))) \
503+
$(dir $(zfs-$(CONFIG_PPC64))) $(dir $(zfs-$(CONFIG_PPC)))
504+
505+
z_cdirs = $(sort $(filter-out lua/setjmp/ $(addprefix icp/asm-aarch64/, aes/ blake3/ modes/ sha2/) \
506+
$(addprefix icp/asm-x86_64/, aes/ blake3/ modes/ sha2/) \
507+
$(addprefix icp/asm-ppc/, aes/ blake3/ modes/ sha2/) \
508+
$(addprefix icp/asm-ppc64/, aes/ blake3/ modes/ sha2/), $(zobjdirs)))
509+
z_sdirs = $(sort $(filter lua/setjmp/ $(addprefix icp/asm-aarch64/, aes/ blake3/ modes/ sha2/) \
510+
$(addprefix icp/asm-x86_64/, aes/ blake3/ modes/ sha2/) \
511+
$(addprefix icp/asm-ppc/, aes/ blake3/ modes/ sha2/) \
512+
$(addprefix icp/asm-ppc64/, aes/ blake3/ modes/ sha2/), $(zobjdirs)))
513+
514+
define ZKMOD_C_O_MAKE_TARGET
515+
$1%.o: $(src)/$1%.c FORCE
516+
$$(call if_changed_rule,cc_o_c)
517+
$$(call cmd,force_checksrc)
518+
endef
519+
520+
define ZKMOD_S_O_MAKE_TARGET
521+
$1%.o: $(src)/$1%.S FORCE
522+
$$(call if_changed_rule,as_o_S)
523+
$$(call cmd,force_checksrc)
524+
endef
525+
526+
$(foreach target,$(z_cdirs), $(eval $(call ZKMOD_C_O_MAKE_TARGET,$(target))))
527+
$(foreach target,$(z_sdirs), $(eval $(call ZKMOD_S_O_MAKE_TARGET,$(target))))

0 commit comments

Comments
 (0)