xref: /freebsd/sys/contrib/openzfs/module/Kbuild.in (revision d9a42747950146bf03cda7f6e25d219253f8a57a)
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
45ifeq ($(CONFIG_ARM64),y)
46CFLAGS_REMOVE_zcommon/zfs_fletcher_aarch64_neon.o += -mgeneral-regs-only
47CFLAGS_REMOVE_zfs/vdev_raidz_math_aarch64_neon.o += -mgeneral-regs-only
48CFLAGS_REMOVE_zfs/vdev_raidz_math_aarch64_neonx2.o += -mgeneral-regs-only
49endif
50
51# Suppress unused-value warnings in sparc64 architecture headers
52ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
53
54
55obj-$(CONFIG_ZFS) := spl.o zfs.o
56
57SPL_OBJS := \
58	spl-atomic.o \
59	spl-condvar.o \
60	spl-cred.o \
61	spl-err.o \
62	spl-generic.o \
63	spl-kmem-cache.o \
64	spl-kmem.o \
65	spl-kstat.o \
66	spl-proc.o \
67	spl-procfs-list.o \
68	spl-taskq.o \
69	spl-thread.o \
70	spl-trace.o \
71	spl-tsd.o \
72	spl-vmem.o \
73	spl-xdr.o \
74	spl-zlib.o \
75	spl-zone.o
76
77spl-objs += $(addprefix os/linux/spl/,$(SPL_OBJS))
78
79zfs-objs += avl/avl.o
80
81ICP_OBJS := \
82	algs/aes/aes_impl.o \
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 \
88	algs/edonr/edonr.o \
89	algs/modes/cbc.o \
90	algs/modes/ccm.o \
91	algs/modes/ctr.o \
92	algs/modes/ecb.o \
93	algs/modes/gcm.o \
94	algs/modes/gcm_generic.o \
95	algs/modes/modes.o \
96	algs/sha2/sha2_generic.o \
97	algs/sha2/sha256_impl.o \
98	algs/sha2/sha512_impl.o \
99	algs/skein/skein.o \
100	algs/skein/skein_block.o \
101	algs/skein/skein_iv.o \
102	api/kcf_cipher.o \
103	api/kcf_ctxops.o \
104	api/kcf_mac.o \
105	core/kcf_callprov.o \
106	core/kcf_mech_tabs.o \
107	core/kcf_prov_lib.o \
108	core/kcf_prov_tabs.o \
109	core/kcf_sched.o \
110	illumos-crypto.o \
111	io/aes.o \
112	io/sha2_mod.o \
113	io/skein_mod.o \
114	spi/kcf_spi.o
115
116ICP_OBJS_X86_64 := \
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
129
130ICP_OBJS_X86 := \
131	algs/aes/aes_impl_aesni.o \
132	algs/aes/aes_impl_x86-64.o \
133	algs/modes/gcm_pclmulqdq.o
134
135ICP_OBJS_ARM := \
136	asm-arm/sha2/sha256-armv7.o \
137	asm-arm/sha2/sha512-armv7.o
138
139ICP_OBJS_ARM64 := \
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
144
145ICP_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
152
153zfs-objs             += $(addprefix icp/,$(ICP_OBJS))
154zfs-$(CONFIG_X86)    += $(addprefix icp/,$(ICP_OBJS_X86))
155zfs-$(CONFIG_UML_X86)+= $(addprefix icp/,$(ICP_OBJS_X86))
156zfs-$(CONFIG_X86_64) += $(addprefix icp/,$(ICP_OBJS_X86_64))
157zfs-$(CONFIG_ARM)    += $(addprefix icp/,$(ICP_OBJS_ARM))
158zfs-$(CONFIG_ARM64)  += $(addprefix icp/,$(ICP_OBJS_ARM64))
159zfs-$(CONFIG_PPC)    += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
160zfs-$(CONFIG_PPC64)  += $(addprefix icp/,$(ICP_OBJS_PPC_PPC64))
161
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)
164
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)
167
168# Suppress objtool "return with modified stack frame" warnings.
169OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y
170
171# Suppress objtool "unsupported stack pointer realignment" warnings.
172# See #6950 for the reasoning.
173OBJECT_FILES_NON_STANDARD_sha256-x86_64.o := y
174OBJECT_FILES_NON_STANDARD_sha512-x86_64.o := y
175
176LUA_OBJS := \
177	lapi.o \
178	lauxlib.o \
179	lbaselib.o \
180	lcode.o \
181	lcompat.o \
182	lcorolib.o \
183	lctype.o \
184	ldebug.o \
185	ldo.o \
186	lfunc.o \
187	lgc.o \
188	llex.o \
189	lmem.o \
190	lobject.o \
191	lopcodes.o \
192	lparser.o \
193	lstate.o \
194	lstring.o \
195	lstrlib.o \
196	ltable.o \
197	ltablib.o \
198	ltm.o \
199	lvm.o \
200	lzio.o \
201	setjmp/setjmp.o
202
203zfs-objs += $(addprefix lua/,$(LUA_OBJS))
204
205
206NVPAIR_OBJS := \
207	fnvpair.o \
208	nvpair.o \
209	nvpair_alloc_fixed.o \
210	nvpair_alloc_spl.o
211
212zfs-objs += $(addprefix nvpair/,$(NVPAIR_OBJS))
213
214
215UNICODE_OBJS := \
216	u8_textprep.o \
217	uconv.o
218
219zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS))
220
221
222ZCOMMON_OBJS := \
223	cityhash.o \
224	zfeature_common.o \
225	zfs_comutil.o \
226	zfs_deleg.o \
227	zfs_fletcher.o \
228	zfs_fletcher_superscalar.o \
229	zfs_fletcher_superscalar4.o \
230	zfs_namecheck.o \
231	zfs_prop.o \
232	zpool_prop.o \
233	zprop_common.o
234
235ZCOMMON_OBJS_X86 := \
236	zfs_fletcher_avx512.o \
237	zfs_fletcher_intel.o \
238	zfs_fletcher_sse.o
239
240ZCOMMON_OBJS_ARM64 := \
241	zfs_fletcher_aarch64_neon.o
242
243zfs-objs            += $(addprefix zcommon/,$(ZCOMMON_OBJS))
244zfs-$(CONFIG_X86)   += $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
245zfs-$(CONFIG_UML_X86)+= $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
246zfs-$(CONFIG_ARM64) += $(addprefix zcommon/,$(ZCOMMON_OBJS_ARM64))
247
248
249# Zstd uses -O3 by default, so we should follow
250ZFS_ZSTD_FLAGS := -O3
251
252# -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h
253# Set it for other compilers, too.
254ZFS_ZSTD_FLAGS += -fno-tree-vectorize
255
256# SSE register return with SSE disabled if -march=znverX is passed
257ZFS_ZSTD_FLAGS += -U__BMI__
258
259# Quiet warnings about frame size due to unused code in unmodified zstd lib
260ZFS_ZSTD_FLAGS += -Wframe-larger-than=20480
261
262ZSTD_OBJS := \
263	zfs_zstd.o \
264	zstd_sparc.o
265
266ZSTD_UPSTREAM_OBJS := \
267	lib/common/entropy_common.o \
268	lib/common/error_private.o \
269	lib/common/fse_decompress.o \
270	lib/common/pool.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
288
289zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS))
290
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
296
297
298ZFS_OBJS := \
299	abd.o \
300	aggsum.o \
301	arc.o \
302	blake3_zfs.o \
303	blkptr.o \
304	bplist.o \
305	bpobj.o \
306	bptree.o \
307	bqueue.o \
308	brt.o \
309	btree.o \
310	dataset_kstats.o \
311	dbuf.o \
312	dbuf_stats.o \
313	ddt.o \
314	ddt_zap.o \
315	dmu.o \
316	dmu_diff.o \
317	dmu_object.o \
318	dmu_objset.o \
319	dmu_recv.o \
320	dmu_redact.o \
321	dmu_send.o \
322	dmu_traverse.o \
323	dmu_tx.o \
324	dmu_zfetch.o \
325	dnode.o \
326	dnode_sync.o \
327	dsl_bookmark.o \
328	dsl_crypt.o \
329	dsl_dataset.o \
330	dsl_deadlist.o \
331	dsl_deleg.o \
332	dsl_destroy.o \
333	dsl_dir.o \
334	dsl_pool.o \
335	dsl_prop.o \
336	dsl_scan.o \
337	dsl_synctask.o \
338	dsl_userhold.o \
339	edonr_zfs.o \
340	fm.o \
341	gzip.o \
342	hkdf.o \
343	lz4.o \
344	lz4_zfs.o \
345	lzjb.o \
346	metaslab.o \
347	mmp.o \
348	multilist.o \
349	objlist.o \
350	pathname.o \
351	range_tree.o \
352	refcount.o \
353	rrwlock.o \
354	sa.o \
355	sha2_zfs.o \
356	skein_zfs.o \
357	spa.o \
358	spa_checkpoint.o \
359	spa_config.o \
360	spa_errlog.o \
361	spa_history.o \
362	spa_log_spacemap.o \
363	spa_misc.o \
364	spa_stats.o \
365	space_map.o \
366	space_reftree.o \
367	txg.o \
368	uberblock.o \
369	unique.o \
370	vdev.o \
371	vdev_cache.o \
372	vdev_draid.o \
373	vdev_draid_rand.o \
374	vdev_indirect.o \
375	vdev_indirect_births.o \
376	vdev_indirect_mapping.o \
377	vdev_initialize.o \
378	vdev_label.o \
379	vdev_mirror.o \
380	vdev_missing.o \
381	vdev_queue.o \
382	vdev_raidz.o \
383	vdev_raidz_math.o \
384	vdev_raidz_math_scalar.o \
385	vdev_rebuild.o \
386	vdev_removal.o \
387	vdev_root.o \
388	vdev_trim.o \
389	zap.o \
390	zap_leaf.o \
391	zap_micro.o \
392	zcp.o \
393	zcp_get.o \
394	zcp_global.o \
395	zcp_iter.o \
396	zcp_set.o \
397	zcp_synctask.o \
398	zfeature.o \
399	zfs_byteswap.o \
400	zfs_chksum.o \
401	zfs_fm.o \
402	zfs_fuid.o \
403	zfs_impl.o \
404	zfs_ioctl.o \
405	zfs_log.o \
406	zfs_onexit.o \
407	zfs_quota.o \
408	zfs_ratelimit.o \
409	zfs_replay.o \
410	zfs_rlock.o \
411	zfs_sa.o \
412	zfs_vnops.o \
413	zil.o \
414	zio.o \
415	zio_checksum.o \
416	zio_compress.o \
417	zio_inject.o \
418	zle.o \
419	zrlock.o \
420	zthr.o \
421	zvol.o
422
423ZFS_OBJS_OS := \
424	abd_os.o \
425	arc_os.o \
426	mmp_os.o \
427	policy.o \
428	qat.o \
429	qat_compress.o \
430	qat_crypt.o \
431	spa_misc_os.o \
432	trace.o \
433	vdev_disk.o \
434	vdev_file.o \
435	zfs_acl.o \
436	zfs_ctldir.o \
437	zfs_debug.o \
438	zfs_dir.o \
439	zfs_file_os.o \
440	zfs_ioctl_os.o \
441	zfs_racct.o \
442	zfs_sysfs.o \
443	zfs_uio.o \
444	zfs_vfsops.o \
445	zfs_vnops_os.o \
446	zfs_znode.o \
447	zio_crypt.o \
448	zpl_ctldir.o \
449	zpl_export.o \
450	zpl_file.o \
451	zpl_inode.o \
452	zpl_super.o \
453	zpl_xattr.o \
454	zvol_os.o
455
456ZFS_OBJS_X86 := \
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
462
463ZFS_OBJS_ARM64 := \
464	vdev_raidz_math_aarch64_neon.o \
465	vdev_raidz_math_aarch64_neonx2.o
466
467ZFS_OBJS_PPC_PPC64 := \
468	vdev_raidz_math_powerpc_altivec.o
469
470zfs-objs            += $(addprefix zfs/,$(ZFS_OBJS)) $(addprefix os/linux/zfs/,$(ZFS_OBJS_OS))
471zfs-$(CONFIG_X86)   += $(addprefix zfs/,$(ZFS_OBJS_X86))
472zfs-$(CONFIG_UML_X86)+= $(addprefix zfs/,$(ZFS_OBJS_X86))
473zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64))
474zfs-$(CONFIG_PPC)   += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
475zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
476
477# Suppress incorrect warnings from versions of objtool which are not
478# aware of x86 EVEX prefix instructions used for AVX512.
479OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y
480OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y
481
482ifeq ($(CONFIG_ALTIVEC),y)
483$(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec
484endif
485