xref: /freebsd/sys/contrib/openzfs/module/Kbuild.in (revision 7543a9c0280a0f4262489671936a6e03b9b2c563)
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.
4
5ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
6ZFS_MODULE_CFLAGS += -Wmissing-prototypes
7ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@  @NO_FORMAT_ZERO_LENGTH@
8
9ifneq ($(KBUILD_EXTMOD),)
10zfs_include = @abs_top_srcdir@/include
11icp_include = @abs_srcdir@/icp/include
12zstd_include = @abs_srcdir@/zstd/include
13ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h
14ZFS_MODULE_CFLAGS += -I@abs_top_builddir@/include
15src = @abs_srcdir@
16obj = @abs_builddir@
17else
18zfs_include = $(srctree)/include/zfs
19icp_include = $(srctree)/$(src)/icp/include
20zstd_include = $(srctree)/$(src)/zstd/include
21ZFS_MODULE_CFLAGS += -include $(zfs_include)/zfs_config.h
22endif
23
24ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/kernel
25ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/spl
26ZFS_MODULE_CFLAGS += -I$(zfs_include)/os/linux/zfs
27ZFS_MODULE_CFLAGS += -I$(zfs_include)
28ZFS_MODULE_CPPFLAGS += -D_KERNEL
29ZFS_MODULE_CPPFLAGS += @KERNEL_DEBUG_CPPFLAGS@
30
31# KASAN enables -Werror=frame-larger-than=1024, which
32# breaks oh so many parts of our build.
33ifeq ($(CONFIG_KASAN),y)
34ZFS_MODULE_CFLAGS += -Wno-error=frame-larger-than=
35endif
36
37ifneq ($(KBUILD_EXTMOD),)
38@CONFIG_QAT_TRUE@ZFS_MODULE_CFLAGS += -I@QAT_SRC@/include
39@CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@
40endif
41
42asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
43ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
44
45# Suppress unused-value warnings in sparc64 architecture headers
46ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
47
48
49obj-$(CONFIG_ZFS) := spl.o zfs.o
50
51SPL_OBJS := \
52	spl-atomic.o \
53	spl-condvar.o \
54	spl-cred.o \
55	spl-err.o \
56	spl-generic.o \
57	spl-kmem-cache.o \
58	spl-kmem.o \
59	spl-kstat.o \
60	spl-proc.o \
61	spl-procfs-list.o \
62	spl-taskq.o \
63	spl-thread.o \
64	spl-trace.o \
65	spl-tsd.o \
66	spl-vmem.o \
67	spl-xdr.o \
68	spl-zlib.o \
69	spl-zone.o
70
71spl-objs += $(addprefix os/linux/spl/,$(SPL_OBJS))
72
73zfs-objs += avl/avl.o
74
75ICP_OBJS := \
76	algs/aes/aes_impl.o \
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 \
83	algs/edonr/edonr.o \
84	algs/modes/cbc.o \
85	algs/modes/ccm.o \
86	algs/modes/ctr.o \
87	algs/modes/ecb.o \
88	algs/modes/gcm.o \
89	algs/modes/gcm_generic.o \
90	algs/modes/modes.o \
91	algs/sha2/sha2.o \
92	algs/skein/skein.o \
93	algs/skein/skein_block.o \
94	algs/skein/skein_iv.o \
95	api/kcf_cipher.o \
96	api/kcf_ctxops.o \
97	api/kcf_mac.o \
98	core/kcf_callprov.o \
99	core/kcf_mech_tabs.o \
100	core/kcf_prov_lib.o \
101	core/kcf_prov_tabs.o \
102	core/kcf_sched.o \
103	illumos-crypto.o \
104	io/aes.o \
105	io/sha2_mod.o \
106	io/skein_mod.o \
107	spi/kcf_spi.o
108
109ICP_OBJS_X86_64 := \
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
122
123
124ICP_OBJS_X86 := \
125	algs/aes/aes_impl_aesni.o \
126	algs/aes/aes_impl_x86-64.o \
127	algs/modes/gcm_pclmulqdq.o
128
129
130ICP_OBJS_ARM64 := \
131	asm-aarch64/blake3/b3_aarch64_sse2.o \
132	asm-aarch64/blake3/b3_aarch64_sse41.o
133
134
135ICP_OBJS_PPC_PPC64 := \
136	asm-ppc64/blake3/b3_ppc64le_sse2.o \
137	asm-ppc64/blake3/b3_ppc64le_sse41.o
138
139zfs-objs             += $(addprefix icp/,$(ICP_OBJS))
140zfs-$(CONFIG_X86)    += $(addprefix icp/,$(ICP_OBJS_X86))
141zfs-$(CONFIG_UML_X86)+= $(addprefix icp/,$(ICP_OBJS_X86))
142zfs-$(CONFIG_X86_64) += $(addprefix icp/,$(ICP_OBJS_X86_64))
143zfs-$(CONFIG_ARM64)  += $(addprefix icp/,$(ICP_OBJS_ARM64))
144zfs-$(CONFIG_PPC)    += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
145zfs-$(CONFIG_PPC64)  += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
146
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)
149
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)
152
153# Suppress objtool "return with modified stack frame" warnings.
154OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y
155
156# Suppress objtool "unsupported stack pointer realignment" warnings. We are
157# not using a DRAP register while aligning the stack to a 64 byte boundary.
158# See #6950 for the reasoning.
159OBJECT_FILES_NON_STANDARD_sha256_impl.o := y
160OBJECT_FILES_NON_STANDARD_sha512_impl.o := y
161
162
163LUA_OBJS := \
164	lapi.o \
165	lauxlib.o \
166	lbaselib.o \
167	lcode.o \
168	lcompat.o \
169	lcorolib.o \
170	lctype.o \
171	ldebug.o \
172	ldo.o \
173	lfunc.o \
174	lgc.o \
175	llex.o \
176	lmem.o \
177	lobject.o \
178	lopcodes.o \
179	lparser.o \
180	lstate.o \
181	lstring.o \
182	lstrlib.o \
183	ltable.o \
184	ltablib.o \
185	ltm.o \
186	lvm.o \
187	lzio.o \
188	setjmp/setjmp.o
189
190zfs-objs += $(addprefix lua/,$(LUA_OBJS))
191
192
193NVPAIR_OBJS := \
194	fnvpair.o \
195	nvpair.o \
196	nvpair_alloc_fixed.o \
197	nvpair_alloc_spl.o
198
199zfs-objs += $(addprefix nvpair/,$(NVPAIR_OBJS))
200
201
202UNICODE_OBJS := \
203	u8_textprep.o \
204	uconv.o
205
206zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS))
207
208
209ZCOMMON_OBJS := \
210	cityhash.o \
211	zfeature_common.o \
212	zfs_comutil.o \
213	zfs_deleg.o \
214	zfs_fletcher.o \
215	zfs_fletcher_superscalar.o \
216	zfs_fletcher_superscalar4.o \
217	zfs_namecheck.o \
218	zfs_prop.o \
219	zpool_prop.o \
220	zprop_common.o
221
222ZCOMMON_OBJS_X86 := \
223	zfs_fletcher_avx512.o \
224	zfs_fletcher_intel.o \
225	zfs_fletcher_sse.o
226
227ZCOMMON_OBJS_ARM64 := \
228	zfs_fletcher_aarch64_neon.o
229
230zfs-objs            += $(addprefix zcommon/,$(ZCOMMON_OBJS))
231zfs-$(CONFIG_X86)   += $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
232zfs-$(CONFIG_UML_X86)+= $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
233zfs-$(CONFIG_ARM64) += $(addprefix zcommon/,$(ZCOMMON_OBJS_ARM64))
234
235
236# Zstd uses -O3 by default, so we should follow
237ZFS_ZSTD_FLAGS := -O3
238
239# -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h
240# Set it for other compilers, too.
241ZFS_ZSTD_FLAGS += -fno-tree-vectorize
242
243# SSE register return with SSE disabled if -march=znverX is passed
244ZFS_ZSTD_FLAGS += -U__BMI__
245
246# Quiet warnings about frame size due to unused code in unmodified zstd lib
247ZFS_ZSTD_FLAGS += -Wframe-larger-than=20480
248
249ZSTD_OBJS := \
250	zfs_zstd.o \
251	zstd_sparc.o
252
253ZSTD_UPSTREAM_OBJS := \
254	lib/common/entropy_common.o \
255	lib/common/error_private.o \
256	lib/common/fse_decompress.o \
257	lib/common/pool.o \
258	lib/common/zstd_common.o \
259	lib/compress/fse_compress.o \
260	lib/compress/hist.o \
261	lib/compress/huf_compress.o \
262	lib/compress/zstd_compress.o \
263	lib/compress/zstd_compress_literals.o \
264	lib/compress/zstd_compress_sequences.o \
265	lib/compress/zstd_compress_superblock.o \
266	lib/compress/zstd_double_fast.o \
267	lib/compress/zstd_fast.o \
268	lib/compress/zstd_lazy.o \
269	lib/compress/zstd_ldm.o \
270	lib/compress/zstd_opt.o \
271	lib/decompress/huf_decompress.o \
272	lib/decompress/zstd_ddict.o \
273	lib/decompress/zstd_decompress.o \
274	lib/decompress/zstd_decompress_block.o
275
276zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS))
277
278# Disable aarch64 neon SIMD instructions for kernel mode
279$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS)
280$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include)
281$(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w
282$(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h
283
284
285ZFS_OBJS := \
286	abd.o \
287	aggsum.o \
288	arc.o \
289	blake3_zfs.o \
290	blkptr.o \
291	bplist.o \
292	bpobj.o \
293	bptree.o \
294	bqueue.o \
295	btree.o \
296	dataset_kstats.o \
297	dbuf.o \
298	dbuf_stats.o \
299	ddt.o \
300	ddt_zap.o \
301	dmu.o \
302	dmu_diff.o \
303	dmu_object.o \
304	dmu_objset.o \
305	dmu_recv.o \
306	dmu_redact.o \
307	dmu_send.o \
308	dmu_traverse.o \
309	dmu_tx.o \
310	dmu_zfetch.o \
311	dnode.o \
312	dnode_sync.o \
313	dsl_bookmark.o \
314	dsl_crypt.o \
315	dsl_dataset.o \
316	dsl_deadlist.o \
317	dsl_deleg.o \
318	dsl_destroy.o \
319	dsl_dir.o \
320	dsl_pool.o \
321	dsl_prop.o \
322	dsl_scan.o \
323	dsl_synctask.o \
324	dsl_userhold.o \
325	edonr_zfs.o \
326	fm.o \
327	gzip.o \
328	hkdf.o \
329	lz4.o \
330	lz4_zfs.o \
331	lzjb.o \
332	metaslab.o \
333	mmp.o \
334	multilist.o \
335	objlist.o \
336	pathname.o \
337	range_tree.o \
338	refcount.o \
339	rrwlock.o \
340	sa.o \
341	sha256.o \
342	skein_zfs.o \
343	spa.o \
344	spa_checkpoint.o \
345	spa_config.o \
346	spa_errlog.o \
347	spa_history.o \
348	spa_log_spacemap.o \
349	spa_misc.o \
350	spa_stats.o \
351	space_map.o \
352	space_reftree.o \
353	txg.o \
354	uberblock.o \
355	unique.o \
356	vdev.o \
357	vdev_cache.o \
358	vdev_draid.o \
359	vdev_draid_rand.o \
360	vdev_indirect.o \
361	vdev_indirect_births.o \
362	vdev_indirect_mapping.o \
363	vdev_initialize.o \
364	vdev_label.o \
365	vdev_mirror.o \
366	vdev_missing.o \
367	vdev_queue.o \
368	vdev_raidz.o \
369	vdev_raidz_math.o \
370	vdev_raidz_math_scalar.o \
371	vdev_rebuild.o \
372	vdev_removal.o \
373	vdev_root.o \
374	vdev_trim.o \
375	zap.o \
376	zap_leaf.o \
377	zap_micro.o \
378	zcp.o \
379	zcp_get.o \
380	zcp_global.o \
381	zcp_iter.o \
382	zcp_set.o \
383	zcp_synctask.o \
384	zfeature.o \
385	zfs_byteswap.o \
386	zfs_chksum.o \
387	zfs_fm.o \
388	zfs_fuid.o \
389	zfs_ioctl.o \
390	zfs_log.o \
391	zfs_onexit.o \
392	zfs_quota.o \
393	zfs_ratelimit.o \
394	zfs_replay.o \
395	zfs_rlock.o \
396	zfs_sa.o \
397	zfs_vnops.o \
398	zil.o \
399	zio.o \
400	zio_checksum.o \
401	zio_compress.o \
402	zio_inject.o \
403	zle.o \
404	zrlock.o \
405	zthr.o \
406	zvol.o
407
408ZFS_OBJS_OS := \
409	abd_os.o \
410	arc_os.o \
411	mmp_os.o \
412	policy.o \
413	qat.o \
414	qat_compress.o \
415	qat_crypt.o \
416	spa_misc_os.o \
417	trace.o \
418	vdev_disk.o \
419	vdev_file.o \
420	zfs_acl.o \
421	zfs_ctldir.o \
422	zfs_debug.o \
423	zfs_dir.o \
424	zfs_file_os.o \
425	zfs_ioctl_os.o \
426	zfs_racct.o \
427	zfs_sysfs.o \
428	zfs_uio.o \
429	zfs_vfsops.o \
430	zfs_vnops_os.o \
431	zfs_znode.o \
432	zio_crypt.o \
433	zpl_ctldir.o \
434	zpl_export.o \
435	zpl_file.o \
436	zpl_inode.o \
437	zpl_super.o \
438	zpl_xattr.o \
439	zvol_os.o
440
441ZFS_OBJS_X86 := \
442	vdev_raidz_math_avx2.o \
443	vdev_raidz_math_avx512bw.o \
444	vdev_raidz_math_avx512f.o \
445	vdev_raidz_math_sse2.o \
446	vdev_raidz_math_ssse3.o
447
448ZFS_OBJS_ARM64 := \
449	vdev_raidz_math_aarch64_neon.o \
450	vdev_raidz_math_aarch64_neonx2.o
451
452ZFS_OBJS_PPC_PPC64 := \
453	vdev_raidz_math_powerpc_altivec.o
454
455zfs-objs            += $(addprefix zfs/,$(ZFS_OBJS)) $(addprefix os/linux/zfs/,$(ZFS_OBJS_OS))
456zfs-$(CONFIG_X86)   += $(addprefix zfs/,$(ZFS_OBJS_X86))
457zfs-$(CONFIG_UML_X86)+= $(addprefix zfs/,$(ZFS_OBJS_X86))
458zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64))
459zfs-$(CONFIG_PPC)   += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
460zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
461
462# Suppress incorrect warnings from versions of objtool which are not
463# aware of x86 EVEX prefix instructions used for AVX512.
464OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y
465OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y
466
467ifeq ($(CONFIG_ALTIVEC),y)
468$(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec
469endif
470