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