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 = $(src)/icp/include
20 zstd_include = $(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 # Generated binary search code is particularly bad with this optimization.
38 # Oddly, range_tree.c is not affected when unrolling is not done and dsl_scan.c
39 # is not affected when unrolling is done.
40 # Disable it until the following upstream issue is resolved:
41 # https://github.com/llvm/llvm-project/issues/62790
42 ifeq ($(CONFIG_X86),y)
43 ifeq ($(CONFIG_CC_IS_CLANG),y)
44 CFLAGS_zfs/dsl_scan.o += -mllvm -x86-cmov-converter=false
45 CFLAGS_zfs/metaslab.o += -mllvm -x86-cmov-converter=false
46 CFLAGS_zfs/range_tree.o += -mllvm -x86-cmov-converter=false
47 CFLAGS_zfs/zap_micro.o += -mllvm -x86-cmov-converter=false
51 ifneq ($(KBUILD_EXTMOD),)
52 @CONFIG_QAT_TRUE@ZFS_MODULE_CFLAGS += -I@QAT_SRC@/include
53 @CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@
56 asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
57 ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
59 ifeq ($(CONFIG_ARM64),y)
60 CFLAGS_REMOVE_zcommon/zfs_fletcher_aarch64_neon.o += -mgeneral-regs-only
61 CFLAGS_REMOVE_zfs/vdev_raidz_math_aarch64_neon.o += -mgeneral-regs-only
62 CFLAGS_REMOVE_zfs/vdev_raidz_math_aarch64_neonx2.o += -mgeneral-regs-only
65 # Suppress unused-value warnings in sparc64 architecture headers
66 ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
69 obj-$(CONFIG_ZFS) := spl.o zfs.o
92 spl-objs += $(addprefix os/linux/spl/,$(SPL_OBJS))
98 algs/aes/aes_impl_generic.o \
99 algs/aes/aes_modes.o \
100 algs/blake3/blake3.o \
101 algs/blake3/blake3_generic.o \
102 algs/blake3/blake3_impl.o \
106 algs/modes/gcm_generic.o \
108 algs/sha2/sha2_generic.o \
109 algs/sha2/sha256_impl.o \
110 algs/sha2/sha512_impl.o \
112 algs/skein/skein_block.o \
113 algs/skein/skein_iv.o \
117 core/kcf_callprov.o \
118 core/kcf_mech_tabs.o \
119 core/kcf_prov_lib.o \
120 core/kcf_prov_tabs.o \
128 asm-x86_64/aes/aes_aesni.o \
129 asm-x86_64/aes/aes_amd64.o \
130 asm-x86_64/aes/aeskey.o \
131 asm-x86_64/blake3/blake3_avx2.o \
132 asm-x86_64/blake3/blake3_avx512.o \
133 asm-x86_64/blake3/blake3_sse2.o \
134 asm-x86_64/blake3/blake3_sse41.o \
135 asm-x86_64/sha2/sha256-x86_64.o \
136 asm-x86_64/sha2/sha512-x86_64.o \
137 asm-x86_64/modes/aesni-gcm-x86_64.o \
138 asm-x86_64/modes/gcm_pclmulqdq.o \
139 asm-x86_64/modes/ghash-x86_64.o
142 algs/aes/aes_impl_aesni.o \
143 algs/aes/aes_impl_x86-64.o \
144 algs/modes/gcm_pclmulqdq.o
147 asm-arm/sha2/sha256-armv7.o \
148 asm-arm/sha2/sha512-armv7.o
151 asm-aarch64/blake3/b3_aarch64_sse2.o \
152 asm-aarch64/blake3/b3_aarch64_sse41.o \
153 asm-aarch64/sha2/sha256-armv8.o \
154 asm-aarch64/sha2/sha512-armv8.o
156 ICP_OBJS_PPC_PPC64 := \
157 asm-ppc64/blake3/b3_ppc64le_sse2.o \
158 asm-ppc64/blake3/b3_ppc64le_sse41.o \
159 asm-ppc64/sha2/sha256-p8.o \
160 asm-ppc64/sha2/sha512-p8.o \
161 asm-ppc64/sha2/sha256-ppc.o \
162 asm-ppc64/sha2/sha512-ppc.o
164 zfs-objs += $(addprefix icp/,$(ICP_OBJS))
165 zfs-$(CONFIG_X86) += $(addprefix icp/,$(ICP_OBJS_X86))
166 zfs-$(CONFIG_UML_X86)+= $(addprefix icp/,$(ICP_OBJS_X86))
167 zfs-$(CONFIG_X86_64) += $(addprefix icp/,$(ICP_OBJS_X86_64))
168 zfs-$(CONFIG_ARM) += $(addprefix icp/,$(ICP_OBJS_ARM))
169 zfs-$(CONFIG_ARM64) += $(addprefix icp/,$(ICP_OBJS_ARM64))
170 zfs-$(CONFIG_PPC) += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
171 zfs-$(CONFIG_PPC64) += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
173 $(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64) \
174 $(ICP_OBJS_ARM64) $(ICP_OBJS_PPC_PPC64)) : asflags-y += -I$(icp_include) -I$(zfs_include)/os/linux/spl -I$(zfs_include)
176 $(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64) \
177 $(ICP_OBJS_ARM64) $(ICP_OBJS_PPC_PPC64)) : ccflags-y += -I$(icp_include) -I$(zfs_include)/os/linux/spl -I$(zfs_include)
179 # Suppress objtool "return with modified stack frame" warnings.
180 OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y
182 # Suppress objtool "unsupported stack pointer realignment" warnings.
183 # See #6950 for the reasoning.
184 OBJECT_FILES_NON_STANDARD_sha256-x86_64.o := y
185 OBJECT_FILES_NON_STANDARD_sha512-x86_64.o := y
214 zfs-objs += $(addprefix lua/,$(LUA_OBJS))
220 nvpair_alloc_fixed.o \
223 zfs-objs += $(addprefix nvpair/,$(NVPAIR_OBJS))
230 zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS))
240 zfs_fletcher_superscalar.o \
241 zfs_fletcher_superscalar4.o \
248 ZCOMMON_OBJS_X86 := \
249 zfs_fletcher_avx512.o \
250 zfs_fletcher_intel.o \
253 ZCOMMON_OBJS_ARM64 := \
254 zfs_fletcher_aarch64_neon.o
256 zfs-objs += $(addprefix zcommon/,$(ZCOMMON_OBJS))
257 zfs-$(CONFIG_X86) += $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
258 zfs-$(CONFIG_UML_X86)+= $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
259 zfs-$(CONFIG_ARM64) += $(addprefix zcommon/,$(ZCOMMON_OBJS_ARM64))
262 # Zstd uses -O3 by default, so we should follow
263 ZFS_ZSTD_FLAGS := -O3
265 # -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h
266 # Set it for other compilers, too.
267 ZFS_ZSTD_FLAGS += -fno-tree-vectorize
269 # SSE register return with SSE disabled if -march=znverX is passed
270 ZFS_ZSTD_FLAGS += -U__BMI__
272 # Quiet warnings about frame size due to unused code in unmodified zstd lib
273 ZFS_ZSTD_FLAGS += -Wframe-larger-than=20480
279 ZSTD_UPSTREAM_OBJS := \
280 lib/common/entropy_common.o \
281 lib/common/error_private.o \
282 lib/common/fse_decompress.o \
284 lib/common/zstd_common.o \
285 lib/compress/fse_compress.o \
286 lib/compress/hist.o \
287 lib/compress/huf_compress.o \
288 lib/compress/zstd_compress.o \
289 lib/compress/zstd_compress_literals.o \
290 lib/compress/zstd_compress_sequences.o \
291 lib/compress/zstd_compress_superblock.o \
292 lib/compress/zstd_double_fast.o \
293 lib/compress/zstd_fast.o \
294 lib/compress/zstd_lazy.o \
295 lib/compress/zstd_ldm.o \
296 lib/compress/zstd_opt.o \
297 lib/decompress/huf_decompress.o \
298 lib/decompress/zstd_ddict.o \
299 lib/decompress/zstd_decompress.o \
300 lib/decompress/zstd_decompress_block.o
302 zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS))
304 # Disable aarch64 neon SIMD instructions for kernel mode
305 $(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS)
306 $(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include)
307 $(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w
308 $(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h
390 vdev_indirect_births.o \
391 vdev_indirect_mapping.o \
399 vdev_raidz_math_scalar.o \
475 vdev_raidz_math_avx2.o \
476 vdev_raidz_math_avx512bw.o \
477 vdev_raidz_math_avx512f.o \
478 vdev_raidz_math_sse2.o \
479 vdev_raidz_math_ssse3.o
482 vdev_raidz_math_aarch64_neon.o \
483 vdev_raidz_math_aarch64_neonx2.o
485 ZFS_OBJS_PPC_PPC64 := \
486 vdev_raidz_math_powerpc_altivec.o
488 zfs-objs += $(addprefix zfs/,$(ZFS_OBJS)) $(addprefix os/linux/zfs/,$(ZFS_OBJS_OS))
489 zfs-$(CONFIG_X86) += $(addprefix zfs/,$(ZFS_OBJS_X86))
490 zfs-$(CONFIG_UML_X86)+= $(addprefix zfs/,$(ZFS_OBJS_X86))
491 zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64))
492 zfs-$(CONFIG_PPC) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
493 zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
495 UBSAN_SANITIZE_zap_leaf.o := n
496 UBSAN_SANITIZE_zap_micro.o := n
497 UBSAN_SANITIZE_sa.o := n
498 UBSAN_SANITIZE_zfs/zap_micro.o := n
499 UBSAN_SANITIZE_zfs/sa.o := n
501 # Suppress incorrect warnings from versions of objtool which are not
502 # aware of x86 EVEX prefix instructions used for AVX512.
503 OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y
504 OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y
506 ifeq ($(CONFIG_ALTIVEC),y)
507 $(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec