1 # When integrated in to a monolithic kernel the spl module must appear
2 # first. This ensures its module initialization function is run before
3 # any of the other module initialization functions which depend on it.
5 ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
6 ZFS_MODULE_CFLAGS += -Wmissing-prototypes
7 ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@ @NO_FORMAT_ZERO_LENGTH@
9 ifneq ($(KBUILD_EXTMOD),)
10 zfs_include = @abs_top_srcdir@/include
11 icp_include = @abs_srcdir@/icp/include
12 zstd_include = @abs_srcdir@/zstd/include
13 ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h
14 ZFS_MODULE_CFLAGS += -I@abs_top_builddir@/include
18 zfs_include = $(srctree)/include/zfs
19 icp_include = $(srctree)/$(src)/icp/include
20 zstd_include = $(srctree)/$(src)/zstd/include
21 ZFS_MODULE_CFLAGS += -include $(zfs_include)/zfs_config.h
24 ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/kernel
25 ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/spl
26 ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/zfs
27 ZFS_MODULE_CFLAGS += -I$(zfs_include)
28 ZFS_MODULE_CPPFLAGS += -D_KERNEL
29 ZFS_MODULE_CPPFLAGS += @KERNEL_DEBUG_CPPFLAGS@
31 # KASAN enables -Werror=frame-larger-than=1024, which
32 # breaks oh so many parts of our build.
33 ifeq ($(CONFIG_KASAN),y)
34 ZFS_MODULE_CFLAGS += -Wno-error=frame-larger-than=
37 ifneq ($(KBUILD_EXTMOD),)
38 @CONFIG_QAT_TRUE@ZFS_MODULE_CFLAGS += -I@QAT_SRC@/include
39 @CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@
42 asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
43 ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
45 # Suppress unused-value warnings in sparc64 architecture headers
46 ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
49 obj-$(CONFIG_ZFS) := spl.o zfs.o
71 spl-objs += $(addprefix os/linux/spl/,$(SPL_OBJS))
77 algs/aes/aes_impl_generic.o \
78 algs/aes/aes_modes.o \
79 algs/blake3/blake3.o \
80 algs/blake3/blake3_generic.o \
81 algs/blake3/blake3_impl.o \
82 algs/blake3/blake3_x86-64.o \
89 algs/modes/gcm_generic.o \
93 algs/skein/skein_block.o \
94 algs/skein/skein_iv.o \
99 core/kcf_mech_tabs.o \
100 core/kcf_prov_lib.o \
101 core/kcf_prov_tabs.o \
110 asm-x86_64/aes/aes_aesni.o \
111 asm-x86_64/aes/aes_amd64.o \
112 asm-x86_64/aes/aeskey.o \
113 asm-x86_64/blake3/blake3_avx2.o \
114 asm-x86_64/blake3/blake3_avx512.o \
115 asm-x86_64/blake3/blake3_sse2.o \
116 asm-x86_64/blake3/blake3_sse41.o \
117 asm-x86_64/modes/aesni-gcm-x86_64.o \
118 asm-x86_64/modes/gcm_pclmulqdq.o \
119 asm-x86_64/modes/ghash-x86_64.o \
120 asm-x86_64/sha2/sha256_impl.o \
121 asm-x86_64/sha2/sha512_impl.o
125 algs/aes/aes_impl_aesni.o \
126 algs/aes/aes_impl_x86-64.o \
127 algs/modes/gcm_pclmulqdq.o
131 asm-aarch64/blake3/b3_aarch64_sse2.o \
132 asm-aarch64/blake3/b3_aarch64_sse41.o
135 ICP_OBJS_PPC_PPC64 := \
136 asm-ppc64/blake3/b3_ppc64le_sse2.o \
137 asm-ppc64/blake3/b3_ppc64le_sse41.o
139 zfs-objs += $(addprefix icp/,$(ICP_OBJS))
140 zfs-$(CONFIG_X86) += $(addprefix icp/,$(ICP_OBJS_X86))
141 zfs-$(CONFIG_UML_X86)+= $(addprefix icp/,$(ICP_OBJS_X86))
142 zfs-$(CONFIG_X86_64) += $(addprefix icp/,$(ICP_OBJS_X86_64))
143 zfs-$(CONFIG_ARM64) += $(addprefix icp/,$(ICP_OBJS_ARM64))
144 zfs-$(CONFIG_PPC) += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
145 zfs-$(CONFIG_PPC64) += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
147 $(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64) \
148 $(ICP_OBJS_ARM64) $(ICP_OBJS_PPC_PPC64)) : asflags-y += -I$(icp_include)
150 $(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64) \
151 $(ICP_OBJS_ARM64) $(ICP_OBJS_PPC_PPC64)) : ccflags-y += -I$(icp_include)
153 # Suppress objtool "can't find jump dest instruction at" warnings. They
154 # are caused by the constants which are defined in the text section of the
155 # assembly file using .byte instructions (e.g. bswap_mask). The objtool
156 # utility tries to interpret them as opcodes and obviously fails doing so.
157 OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y
158 OBJECT_FILES_NON_STANDARD_ghash-x86_64.o := y
160 # Suppress objtool "unsupported stack pointer realignment" warnings. We are
161 # not using a DRAP register while aligning the stack to a 64 byte boundary.
162 # See #6950 for the reasoning.
163 OBJECT_FILES_NON_STANDARD_sha256_impl.o := y
164 OBJECT_FILES_NON_STANDARD_sha512_impl.o := y
194 zfs-objs += $(addprefix lua/,$(LUA_OBJS))
200 nvpair_alloc_fixed.o \
203 zfs-objs += $(addprefix nvpair/,$(NVPAIR_OBJS))
210 zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS))
219 zfs_fletcher_superscalar.o \
220 zfs_fletcher_superscalar4.o \
226 ZCOMMON_OBJS_X86 := \
227 zfs_fletcher_avx512.o \
228 zfs_fletcher_intel.o \
231 ZCOMMON_OBJS_ARM64 := \
232 zfs_fletcher_aarch64_neon.o
234 zfs-objs += $(addprefix zcommon/,$(ZCOMMON_OBJS))
235 zfs-$(CONFIG_X86) += $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
236 zfs-$(CONFIG_UML_X86)+= $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
237 zfs-$(CONFIG_ARM64) += $(addprefix zcommon/,$(ZCOMMON_OBJS_ARM64))
240 # Zstd uses -O3 by default, so we should follow
241 ZFS_ZSTD_FLAGS := -O3
243 # -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h
244 # Set it for other compilers, too.
245 ZFS_ZSTD_FLAGS += -fno-tree-vectorize
247 # SSE register return with SSE disabled if -march=znverX is passed
248 ZFS_ZSTD_FLAGS += -U__BMI__
250 # Quiet warnings about frame size due to unused code in unmodified zstd lib
251 ZFS_ZSTD_FLAGS += -Wframe-larger-than=20480
257 ZSTD_UPSTREAM_OBJS := \
258 lib/common/entropy_common.o \
259 lib/common/error_private.o \
260 lib/common/fse_decompress.o \
262 lib/common/zstd_common.o \
263 lib/compress/fse_compress.o \
264 lib/compress/hist.o \
265 lib/compress/huf_compress.o \
266 lib/compress/zstd_compress.o \
267 lib/compress/zstd_compress_literals.o \
268 lib/compress/zstd_compress_sequences.o \
269 lib/compress/zstd_compress_superblock.o \
270 lib/compress/zstd_double_fast.o \
271 lib/compress/zstd_fast.o \
272 lib/compress/zstd_lazy.o \
273 lib/compress/zstd_ldm.o \
274 lib/compress/zstd_opt.o \
275 lib/decompress/huf_decompress.o \
276 lib/decompress/zstd_ddict.o \
277 lib/decompress/zstd_decompress.o \
278 lib/decompress/zstd_decompress_block.o
280 zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS))
282 # Disable aarch64 neon SIMD instructions for kernel mode
283 $(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS)
284 $(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include)
285 $(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w
286 $(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h
365 vdev_indirect_births.o \
366 vdev_indirect_mapping.o \
374 vdev_raidz_math_scalar.o \
446 vdev_raidz_math_avx2.o \
447 vdev_raidz_math_avx512bw.o \
448 vdev_raidz_math_avx512f.o \
449 vdev_raidz_math_sse2.o \
450 vdev_raidz_math_ssse3.o
453 vdev_raidz_math_aarch64_neon.o \
454 vdev_raidz_math_aarch64_neonx2.o
456 ZFS_OBJS_PPC_PPC64 := \
457 vdev_raidz_math_powerpc_altivec.o
459 zfs-objs += $(addprefix zfs/,$(ZFS_OBJS)) $(addprefix os/linux/zfs/,$(ZFS_OBJS_OS))
460 zfs-$(CONFIG_X86) += $(addprefix zfs/,$(ZFS_OBJS_X86))
461 zfs-$(CONFIG_UML_X86)+= $(addprefix zfs/,$(ZFS_OBJS_X86))
462 zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64))
463 zfs-$(CONFIG_PPC) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
464 zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
466 # Suppress incorrect warnings from versions of objtool which are not
467 # aware of x86 EVEX prefix instructions used for AVX512.
468 OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y
469 OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y
471 ifeq ($(CONFIG_ALTIVEC),y)
472 $(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec