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