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 ifeq ($(CONFIG_ARM64),y)
46 CFLAGS_REMOVE_zcommon/zfs_fletcher_aarch64_neon.o += -mgeneral-regs-only
47 CFLAGS_REMOVE_zfs/vdev_raidz_math_aarch64_neon.o += -mgeneral-regs-only
48 CFLAGS_REMOVE_zfs/vdev_raidz_math_aarch64_neonx2.o += -mgeneral-regs-only
51 # Suppress unused-value warnings in sparc64 architecture headers
52 ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
55 obj-$(CONFIG_ZFS) := spl.o zfs.o
77 spl-objs += $(addprefix os/linux/spl/,$(SPL_OBJS))
83 algs/aes/aes_impl_generic.o \
84 algs/aes/aes_modes.o \
85 algs/blake3/blake3.o \
86 algs/blake3/blake3_generic.o \
87 algs/blake3/blake3_impl.o \
94 algs/modes/gcm_generic.o \
96 algs/sha2/sha2_generic.o \
97 algs/sha2/sha256_impl.o \
98 algs/sha2/sha512_impl.o \
100 algs/skein/skein_block.o \
101 algs/skein/skein_iv.o \
105 core/kcf_callprov.o \
106 core/kcf_mech_tabs.o \
107 core/kcf_prov_lib.o \
108 core/kcf_prov_tabs.o \
117 asm-x86_64/aes/aes_aesni.o \
118 asm-x86_64/aes/aes_amd64.o \
119 asm-x86_64/aes/aeskey.o \
120 asm-x86_64/blake3/blake3_avx2.o \
121 asm-x86_64/blake3/blake3_avx512.o \
122 asm-x86_64/blake3/blake3_sse2.o \
123 asm-x86_64/blake3/blake3_sse41.o \
124 asm-x86_64/sha2/sha256-x86_64.o \
125 asm-x86_64/sha2/sha512-x86_64.o \
126 asm-x86_64/modes/aesni-gcm-x86_64.o \
127 asm-x86_64/modes/gcm_pclmulqdq.o \
128 asm-x86_64/modes/ghash-x86_64.o
131 algs/aes/aes_impl_aesni.o \
132 algs/aes/aes_impl_x86-64.o \
133 algs/modes/gcm_pclmulqdq.o
136 asm-arm/sha2/sha256-armv7.o \
137 asm-arm/sha2/sha512-armv7.o
140 asm-aarch64/blake3/b3_aarch64_sse2.o \
141 asm-aarch64/blake3/b3_aarch64_sse41.o \
142 asm-aarch64/sha2/sha256-armv8.o \
143 asm-aarch64/sha2/sha512-armv8.o
145 ICP_OBJS_PPC_PPC64 := \
146 asm-ppc64/blake3/b3_ppc64le_sse2.o \
147 asm-ppc64/blake3/b3_ppc64le_sse41.o \
148 asm-ppc64/sha2/sha256-p8.o \
149 asm-ppc64/sha2/sha512-p8.o \
150 asm-ppc64/sha2/sha256-ppc.o \
151 asm-ppc64/sha2/sha512-ppc.o
153 zfs-objs += $(addprefix icp/,$(ICP_OBJS))
154 zfs-$(CONFIG_X86) += $(addprefix icp/,$(ICP_OBJS_X86))
155 zfs-$(CONFIG_UML_X86)+= $(addprefix icp/,$(ICP_OBJS_X86))
156 zfs-$(CONFIG_X86_64) += $(addprefix icp/,$(ICP_OBJS_X86_64))
157 zfs-$(CONFIG_ARM) += $(addprefix icp/,$(ICP_OBJS_ARM))
158 zfs-$(CONFIG_ARM64) += $(addprefix icp/,$(ICP_OBJS_ARM64))
159 zfs-$(CONFIG_PPC) += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
160 zfs-$(CONFIG_PPC64) += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
162 $(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64) \
163 $(ICP_OBJS_ARM64) $(ICP_OBJS_PPC_PPC64)) : asflags-y += -I$(icp_include) -I$(zfs_include)/os/linux/spl -I$(zfs_include)
165 $(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64) \
166 $(ICP_OBJS_ARM64) $(ICP_OBJS_PPC_PPC64)) : ccflags-y += -I$(icp_include) -I$(zfs_include)/os/linux/spl -I$(zfs_include)
168 # Suppress objtool "return with modified stack frame" warnings.
169 OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y
171 # Suppress objtool "unsupported stack pointer realignment" warnings.
172 # See #6950 for the reasoning.
173 OBJECT_FILES_NON_STANDARD_sha256-x86_64.o := y
174 OBJECT_FILES_NON_STANDARD_sha512-x86_64.o := y
203 zfs-objs += $(addprefix lua/,$(LUA_OBJS))
209 nvpair_alloc_fixed.o \
212 zfs-objs += $(addprefix nvpair/,$(NVPAIR_OBJS))
219 zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS))
228 zfs_fletcher_superscalar.o \
229 zfs_fletcher_superscalar4.o \
235 ZCOMMON_OBJS_X86 := \
236 zfs_fletcher_avx512.o \
237 zfs_fletcher_intel.o \
240 ZCOMMON_OBJS_ARM64 := \
241 zfs_fletcher_aarch64_neon.o
243 zfs-objs += $(addprefix zcommon/,$(ZCOMMON_OBJS))
244 zfs-$(CONFIG_X86) += $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
245 zfs-$(CONFIG_UML_X86)+= $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
246 zfs-$(CONFIG_ARM64) += $(addprefix zcommon/,$(ZCOMMON_OBJS_ARM64))
249 # Zstd uses -O3 by default, so we should follow
250 ZFS_ZSTD_FLAGS := -O3
252 # -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h
253 # Set it for other compilers, too.
254 ZFS_ZSTD_FLAGS += -fno-tree-vectorize
256 # SSE register return with SSE disabled if -march=znverX is passed
257 ZFS_ZSTD_FLAGS += -U__BMI__
259 # Quiet warnings about frame size due to unused code in unmodified zstd lib
260 ZFS_ZSTD_FLAGS += -Wframe-larger-than=20480
266 ZSTD_UPSTREAM_OBJS := \
267 lib/common/entropy_common.o \
268 lib/common/error_private.o \
269 lib/common/fse_decompress.o \
271 lib/common/zstd_common.o \
272 lib/compress/fse_compress.o \
273 lib/compress/hist.o \
274 lib/compress/huf_compress.o \
275 lib/compress/zstd_compress.o \
276 lib/compress/zstd_compress_literals.o \
277 lib/compress/zstd_compress_sequences.o \
278 lib/compress/zstd_compress_superblock.o \
279 lib/compress/zstd_double_fast.o \
280 lib/compress/zstd_fast.o \
281 lib/compress/zstd_lazy.o \
282 lib/compress/zstd_ldm.o \
283 lib/compress/zstd_opt.o \
284 lib/decompress/huf_decompress.o \
285 lib/decompress/zstd_ddict.o \
286 lib/decompress/zstd_decompress.o \
287 lib/decompress/zstd_decompress_block.o
289 zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS))
291 # Disable aarch64 neon SIMD instructions for kernel mode
292 $(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS)
293 $(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include)
294 $(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w
295 $(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h
375 vdev_indirect_births.o \
376 vdev_indirect_mapping.o \
384 vdev_raidz_math_scalar.o \
457 vdev_raidz_math_avx2.o \
458 vdev_raidz_math_avx512bw.o \
459 vdev_raidz_math_avx512f.o \
460 vdev_raidz_math_sse2.o \
461 vdev_raidz_math_ssse3.o
464 vdev_raidz_math_aarch64_neon.o \
465 vdev_raidz_math_aarch64_neonx2.o
467 ZFS_OBJS_PPC_PPC64 := \
468 vdev_raidz_math_powerpc_altivec.o
470 zfs-objs += $(addprefix zfs/,$(ZFS_OBJS)) $(addprefix os/linux/zfs/,$(ZFS_OBJS_OS))
471 zfs-$(CONFIG_X86) += $(addprefix zfs/,$(ZFS_OBJS_X86))
472 zfs-$(CONFIG_UML_X86)+= $(addprefix zfs/,$(ZFS_OBJS_X86))
473 zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64))
474 zfs-$(CONFIG_PPC) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
475 zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
477 # Suppress incorrect warnings from versions of objtool which are not
478 # aware of x86 EVEX prefix instructions used for AVX512.
479 OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y
480 OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y
482 ifeq ($(CONFIG_ALTIVEC),y)
483 $(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec