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