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