Skip to content

Commit 7191c1d

Browse files
ckaneixhamza
authored andcommitted
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. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Coleman Kane <[email protected]> Closes openzfs#17517
1 parent a4d2525 commit 7191c1d

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

0 commit comments

Comments
 (0)