xref: /freebsd/sys/contrib/openzfs/module/Kbuild.in (revision 716fd348e01c5f2ba125f878a634a753436c2994)
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
70spl-objs += $(addprefix os/linux/spl/,$(SPL_OBJS))
71
72zfs-objs += avl/avl.o
73
74ICP_OBJS := \
75	algs/aes/aes_impl.o \
76	algs/aes/aes_impl_generic.o \
77	algs/aes/aes_modes.o \
78	algs/edonr/edonr.o \
79	algs/modes/cbc.o \
80	algs/modes/ccm.o \
81	algs/modes/ctr.o \
82	algs/modes/ecb.o \
83	algs/modes/gcm.o \
84	algs/modes/gcm_generic.o \
85	algs/modes/modes.o \
86	algs/sha2/sha2.o \
87	algs/skein/skein.o \
88	algs/skein/skein_block.o \
89	algs/skein/skein_iv.o \
90	api/kcf_cipher.o \
91	api/kcf_ctxops.o \
92	api/kcf_mac.o \
93	core/kcf_callprov.o \
94	core/kcf_mech_tabs.o \
95	core/kcf_prov_lib.o \
96	core/kcf_prov_tabs.o \
97	core/kcf_sched.o \
98	illumos-crypto.o \
99	io/aes.o \
100	io/sha2_mod.o \
101	io/skein_mod.o \
102	spi/kcf_spi.o
103
104ICP_OBJS_X86_64 := \
105	asm-x86_64/aes/aes_aesni.o \
106	asm-x86_64/aes/aes_amd64.o \
107	asm-x86_64/aes/aeskey.o \
108	asm-x86_64/modes/aesni-gcm-x86_64.o \
109	asm-x86_64/modes/gcm_pclmulqdq.o \
110	asm-x86_64/modes/ghash-x86_64.o \
111	asm-x86_64/sha2/sha256_impl.o \
112	asm-x86_64/sha2/sha512_impl.o
113
114ICP_OBJS_X86 := \
115	algs/aes/aes_impl_aesni.o \
116	algs/aes/aes_impl_x86-64.o \
117	algs/modes/gcm_pclmulqdq.o
118
119zfs-objs             += $(addprefix icp/,$(ICP_OBJS))
120zfs-$(CONFIG_X86)    += $(addprefix icp/,$(ICP_OBJS_X86))
121zfs-$(CONFIG_X86_64) += $(addprefix icp/,$(ICP_OBJS_X86_64))
122
123$(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64)) : asflags-y += -I$(icp_include)
124$(addprefix $(obj)/icp/,$(ICP_OBJS) $(ICP_OBJS_X86) $(ICP_OBJS_X86_64)) : ccflags-y += -I$(icp_include)
125
126# Suppress objtool "can't find jump dest instruction at" warnings.  They
127# are caused by the constants which are defined in the text section of the
128# assembly file using .byte instructions (e.g. bswap_mask).  The objtool
129# utility tries to interpret them as opcodes and obviously fails doing so.
130OBJECT_FILES_NON_STANDARD_aesni-gcm-x86_64.o := y
131OBJECT_FILES_NON_STANDARD_ghash-x86_64.o := y
132# Suppress objtool "unsupported stack pointer realignment" warnings. We are
133# not using a DRAP register while aligning the stack to a 64 byte boundary.
134# See #6950 for the reasoning.
135OBJECT_FILES_NON_STANDARD_sha256_impl.o := y
136OBJECT_FILES_NON_STANDARD_sha512_impl.o := y
137
138
139LUA_OBJS := \
140	lapi.o \
141	lauxlib.o \
142	lbaselib.o \
143	lcode.o \
144	lcompat.o \
145	lcorolib.o \
146	lctype.o \
147	ldebug.o \
148	ldo.o \
149	lfunc.o \
150	lgc.o \
151	llex.o \
152	lmem.o \
153	lobject.o \
154	lopcodes.o \
155	lparser.o \
156	lstate.o \
157	lstring.o \
158	lstrlib.o \
159	ltable.o \
160	ltablib.o \
161	ltm.o \
162	lvm.o \
163	lzio.o \
164	setjmp/setjmp.o
165
166zfs-objs += $(addprefix lua/,$(LUA_OBJS))
167
168
169NVPAIR_OBJS := \
170	fnvpair.o \
171	nvpair.o \
172	nvpair_alloc_fixed.o \
173	nvpair_alloc_spl.o
174
175zfs-objs += $(addprefix nvpair/,$(NVPAIR_OBJS))
176
177
178UNICODE_OBJS := \
179	u8_textprep.o \
180	uconv.o
181
182zfs-objs += $(addprefix unicode/,$(UNICODE_OBJS))
183
184
185ZCOMMON_OBJS := \
186	cityhash.o \
187	zfeature_common.o \
188	zfs_comutil.o \
189	zfs_deleg.o \
190	zfs_fletcher.o \
191	zfs_fletcher_superscalar.o \
192	zfs_fletcher_superscalar4.o \
193	zfs_namecheck.o \
194	zfs_prop.o \
195	zpool_prop.o \
196	zprop_common.o
197
198ZCOMMON_OBJS_X86 := \
199	zfs_fletcher_avx512.o \
200	zfs_fletcher_intel.o \
201	zfs_fletcher_sse.o
202
203ZCOMMON_OBJS_ARM64 := \
204	zfs_fletcher_aarch64_neon.o
205
206zfs-objs            += $(addprefix zcommon/,$(ZCOMMON_OBJS))
207zfs-$(CONFIG_X86)   += $(addprefix zcommon/,$(ZCOMMON_OBJS_X86))
208zfs-$(CONFIG_ARM64) += $(addprefix zcommon/,$(ZCOMMON_OBJS_ARM64))
209
210
211# Zstd uses -O3 by default, so we should follow
212ZFS_ZSTD_FLAGS := -O3
213
214# -fno-tree-vectorize gets set for gcc in zstd/common/compiler.h
215# Set it for other compilers, too.
216ZFS_ZSTD_FLAGS += -fno-tree-vectorize
217
218# SSE register return with SSE disabled if -march=znverX is passed
219ZFS_ZSTD_FLAGS += -U__BMI__
220
221# Quiet warnings about frame size due to unused code in unmodified zstd lib
222ZFS_ZSTD_FLAGS += -Wframe-larger-than=20480
223
224ZSTD_OBJS := \
225	zfs_zstd.o \
226	zstd_sparc.o
227
228ZSTD_UPSTREAM_OBJS := \
229	lib/common/entropy_common.o \
230	lib/common/error_private.o \
231	lib/common/fse_decompress.o \
232	lib/common/pool.o \
233	lib/common/zstd_common.o \
234	lib/compress/fse_compress.o \
235	lib/compress/hist.o \
236	lib/compress/huf_compress.o \
237	lib/compress/zstd_compress.o \
238	lib/compress/zstd_compress_literals.o \
239	lib/compress/zstd_compress_sequences.o \
240	lib/compress/zstd_compress_superblock.o \
241	lib/compress/zstd_double_fast.o \
242	lib/compress/zstd_fast.o \
243	lib/compress/zstd_lazy.o \
244	lib/compress/zstd_ldm.o \
245	lib/compress/zstd_opt.o \
246	lib/decompress/huf_decompress.o \
247	lib/decompress/zstd_ddict.o \
248	lib/decompress/zstd_decompress.o \
249	lib/decompress/zstd_decompress_block.o
250
251zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS))
252
253# Disable aarch64 neon SIMD instructions for kernel mode
254$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS)
255$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include)
256$(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w
257$(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h
258
259
260ZFS_OBJS := \
261	abd.o \
262	aggsum.o \
263	arc.o \
264	blkptr.o \
265	bplist.o \
266	bpobj.o \
267	bptree.o \
268	bqueue.o \
269	btree.o \
270	dataset_kstats.o \
271	dbuf.o \
272	dbuf_stats.o \
273	ddt.o \
274	ddt_zap.o \
275	dmu.o \
276	dmu_diff.o \
277	dmu_object.o \
278	dmu_objset.o \
279	dmu_recv.o \
280	dmu_redact.o \
281	dmu_send.o \
282	dmu_traverse.o \
283	dmu_tx.o \
284	dmu_zfetch.o \
285	dnode.o \
286	dnode_sync.o \
287	dsl_bookmark.o \
288	dsl_crypt.o \
289	dsl_dataset.o \
290	dsl_deadlist.o \
291	dsl_deleg.o \
292	dsl_destroy.o \
293	dsl_dir.o \
294	dsl_pool.o \
295	dsl_prop.o \
296	dsl_scan.o \
297	dsl_synctask.o \
298	dsl_userhold.o \
299	edonr_zfs.o \
300	fm.o \
301	gzip.o \
302	hkdf.o \
303	lz4.o \
304	lz4_zfs.o \
305	lzjb.o \
306	metaslab.o \
307	mmp.o \
308	multilist.o \
309	objlist.o \
310	pathname.o \
311	range_tree.o \
312	refcount.o \
313	rrwlock.o \
314	sa.o \
315	sha256.o \
316	skein_zfs.o \
317	spa.o \
318	spa_boot.o \
319	spa_checkpoint.o \
320	spa_config.o \
321	spa_errlog.o \
322	spa_history.o \
323	spa_log_spacemap.o \
324	spa_misc.o \
325	spa_stats.o \
326	space_map.o \
327	space_reftree.o \
328	txg.o \
329	uberblock.o \
330	unique.o \
331	vdev.o \
332	vdev_cache.o \
333	vdev_draid.o \
334	vdev_draid_rand.o \
335	vdev_indirect.o \
336	vdev_indirect_births.o \
337	vdev_indirect_mapping.o \
338	vdev_initialize.o \
339	vdev_label.o \
340	vdev_mirror.o \
341	vdev_missing.o \
342	vdev_queue.o \
343	vdev_raidz.o \
344	vdev_raidz_math.o \
345	vdev_raidz_math_scalar.o \
346	vdev_rebuild.o \
347	vdev_removal.o \
348	vdev_root.o \
349	vdev_trim.o \
350	zap.o \
351	zap_leaf.o \
352	zap_micro.o \
353	zcp.o \
354	zcp_get.o \
355	zcp_global.o \
356	zcp_iter.o \
357	zcp_set.o \
358	zcp_synctask.o \
359	zfeature.o \
360	zfs_byteswap.o \
361	zfs_fm.o \
362	zfs_fuid.o \
363	zfs_ioctl.o \
364	zfs_log.o \
365	zfs_onexit.o \
366	zfs_quota.o \
367	zfs_ratelimit.o \
368	zfs_replay.o \
369	zfs_rlock.o \
370	zfs_sa.o \
371	zfs_vnops.o \
372	zil.o \
373	zio.o \
374	zio_checksum.o \
375	zio_compress.o \
376	zio_inject.o \
377	zle.o \
378	zrlock.o \
379	zthr.o \
380	zvol.o
381
382ZFS_OBJS_OS := \
383	abd_os.o \
384	arc_os.o \
385	mmp_os.o \
386	policy.o \
387	qat.o \
388	qat_compress.o \
389	qat_crypt.o \
390	spa_misc_os.o \
391	trace.o \
392	vdev_disk.o \
393	vdev_file.o \
394	zfs_acl.o \
395	zfs_ctldir.o \
396	zfs_debug.o \
397	zfs_dir.o \
398	zfs_file_os.o \
399	zfs_ioctl_os.o \
400	zfs_racct.o \
401	zfs_sysfs.o \
402	zfs_uio.o \
403	zfs_vfsops.o \
404	zfs_vnops_os.o \
405	zfs_znode.o \
406	zio_crypt.o \
407	zpl_ctldir.o \
408	zpl_export.o \
409	zpl_file.o \
410	zpl_inode.o \
411	zpl_super.o \
412	zpl_xattr.o \
413	zvol_os.o
414
415ZFS_OBJS_X86 := \
416	vdev_raidz_math_avx2.o \
417	vdev_raidz_math_avx512bw.o \
418	vdev_raidz_math_avx512f.o \
419	vdev_raidz_math_sse2.o \
420	vdev_raidz_math_ssse3.o
421
422ZFS_OBJS_ARM64 := \
423	vdev_raidz_math_aarch64_neon.o \
424	vdev_raidz_math_aarch64_neonx2.o
425
426ZFS_OBJS_PPC_PPC64 := \
427	vdev_raidz_math_powerpc_altivec.o
428
429zfs-objs            += $(addprefix zfs/,$(ZFS_OBJS)) $(addprefix os/linux/zfs/,$(ZFS_OBJS_OS))
430zfs-$(CONFIG_X86)   += $(addprefix zfs/,$(ZFS_OBJS_X86))
431zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64))
432zfs-$(CONFIG_PPC)   += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
433zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
434
435# Suppress incorrect warnings from versions of objtool which are not
436# aware of x86 EVEX prefix instructions used for AVX512.
437OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y
438OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512f.o := y
439
440ifeq ($(CONFIG_ALTIVEC),y)
441$(obj)/zfs/vdev_raidz_math_powerpc_altivec.o : c_flags += -maltivec
442endif
443