8 INCDIR=${.CURDIR:H}/include
12 .PATH: ${SRCDIR}/avl \
15 ${SRCDIR}/icp/algs/blake3 \
16 ${SRCDIR}/icp/algs/edonr \
17 ${SRCDIR}/icp/algs/sha2 \
18 ${SRCDIR}/icp/asm-aarch64/blake3 \
19 ${SRCDIR}/icp/asm-aarch64/sha2 \
20 ${SRCDIR}/icp/asm-arm/sha2 \
21 ${SRCDIR}/icp/asm-ppc64/sha2 \
22 ${SRCDIR}/icp/asm-ppc64/blake3 \
23 ${SRCDIR}/icp/asm-x86_64/blake3 \
24 ${SRCDIR}/icp/asm-x86_64/sha2 \
25 ${SRCDIR}/os/freebsd/spl \
26 ${SRCDIR}/os/freebsd/zfs \
31 ${SRCDIR}/zstd/lib/common \
32 ${SRCDIR}/zstd/lib/compress \
33 ${SRCDIR}/zstd/lib/decompress
36 CFLAGS+= -I${SRCDIR}/icp/include
37 CFLAGS+= -I${INCDIR}/os/freebsd
38 CFLAGS+= -I${INCDIR}/os/freebsd/spl
39 CFLAGS+= -I${INCDIR}/os/freebsd/zfs
40 CFLAGS+= -I${SRCDIR}/zstd/include
41 CFLAGS+= -include ${INCDIR}/os/freebsd/spl/sys/ccompile.h
44 CFLAGS+= -D__KERNEL__ -DFREEBSD_NAMECACHE -DBUILDING_ZFS -D__BSD_VISIBLE=1 \
45 -DHAVE_UIO_ZEROCOPY -DWITHOUT_NETDUMP -D__KERNEL -D_SYS_CONDVAR_H_ \
46 -D_SYS_VMEM_H_ -DKDTRACE_HOOKS -DCOMPAT_FREEBSD11
48 .if ${MACHINE_ARCH} == "amd64"
49 CFLAGS+= -D__x86_64 -DHAVE_SSE2 -DHAVE_SSSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2 \
50 -DHAVE_AVX -DHAVE_AVX2 -DHAVE_AVX512F -DHAVE_AVX512VL -DHAVE_AVX512BW
53 .if defined(WITH_DEBUG) && ${WITH_DEBUG} == "true"
54 CFLAGS+= -DZFS_DEBUG -g
55 .if defined(WITH_INVARIANTS) && ${WITH_INVARIANTS} == "true"
56 CFLAGS+= -DINVARIANTS -DWITNESS -DOPENSOLARIS_WITNESS
58 .if defined(WITH_O0) && ${WITH_O0} == "true"
65 .if defined(WITH_VFS_DEBUG) && ${WITH_VFS_DEBUG} == "true"
66 # kernel must also be built with this option for this to work
67 CFLAGS+= -DDEBUG_VFS_LOCKS
70 .if defined(WITH_GCOV) && ${WITH_GCOV} == "true"
71 CFLAGS+= -fprofile-arcs -ftest-coverage
76 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
77 ${MACHINE_ARCH} == "powerpcspe" || ${MACHINE_ARCH} == "arm"
78 CFLAGS+= -DBITS_PER_LONG=32
80 CFLAGS+= -DBITS_PER_LONG=64
83 SRCS= vnode_if.h device_if.h bus_if.h
93 #icp/asm-aarch64/blake3
94 SRCS+= b3_aarch64_sse2.S \
98 SRCS+= b3_ppc64le_sse2.S \
101 #icp/asm-x86_64/blake3
102 SRCS+= blake3_avx2.S \
111 SRCS+= sha256_impl.c \
116 SRCS+= sha256-armv7.S \
119 #icp/asm-aarch64/sha2
120 SRCS+= sha256-armv8.S \
130 SRCS+= sha256-x86_64.S \
162 nvpair_alloc_fixed.c \
166 SRCS+= acl_common.c \
187 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
188 ${MACHINE_ARCH} == "powerpcspe" || ${MACHINE_ARCH} == "arm"
227 zfs_fletcher_avx512.c \
229 zfs_fletcher_intel.c \
231 zfs_fletcher_superscalar4.c \
232 zfs_fletcher_superscalar.c \
316 vdev_indirect_births.c \
318 vdev_indirect_mapping.c \
325 vdev_raidz_math_avx2.c \
326 vdev_raidz_math_avx512bw.c \
327 vdev_raidz_math_avx512f.c \
329 vdev_raidz_math_scalar.c \
330 vdev_raidz_math_sse2.c \
331 vdev_raidz_math_ssse3.c \
375 SRCS+= entropy_common.c \
383 SRCS+= fse_compress.c \
387 zstd_compress_literals.c \
388 zstd_compress_sequences.c \
389 zstd_compress_superblock.c \
397 SRCS+= huf_decompress.c \
399 zstd_decompress_block.c \
403 .if ${MK_DEBUG_FILES} != "no"
405 -f /etc/mtree/BSD.debug.dist \
406 -p ${DESTDIR}/usr/lib
409 .include <bsd.kmod.mk>
411 # Generated binary search code is particularly bad with this optimization.
412 # Oddly, range_tree.c is not affected when unrolling is not done and dsl_scan.c
413 # is not affected when unrolling is done.
414 # Disable it until the following upstream issue is resolved:
415 # https://github.com/llvm/llvm-project/issues/62790
417 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
418 CFLAGS.dsl_scan.c= -mllvm -x86-cmov-converter=false
419 CFLAGS.metaslab.c= -mllvm -x86-cmov-converter=false
420 CFLAGS.range_tree.c= -mllvm -x86-cmov-converter=false
421 CFLAGS.zap_micro.c= -mllvm -x86-cmov-converter=false
425 CFLAGS.sysctl_os.c= -include ../zfs_config.h
426 CFLAGS.xxhash.c+= -include ${SYSDIR}/sys/_null.h
428 CFLAGS.gcc+= -Wno-pointer-to-int-cast
430 CFLAGS.abd.c= -Wno-cast-qual
431 CFLAGS.ddt.c= -Wno-cast-qual
432 CFLAGS.ddt_log.c= -Wno-cast-qual -Wno-pointer-arith
433 CFLAGS.ddt_zap.c= -Wno-cast-qual
434 CFLAGS.dmu.c= -Wno-cast-qual
435 CFLAGS.dmu_traverse.c= -Wno-cast-qual
436 CFLAGS.dnode.c= ${NO_WUNUSED_BUT_SET_VARIABLE}
437 CFLAGS.dsl_deadlist.c= -Wno-cast-qual
438 CFLAGS.dsl_dir.c= -Wno-cast-qual
439 CFLAGS.dsl_prop.c= -Wno-cast-qual
440 CFLAGS.edonr.c= -Wno-cast-qual
441 CFLAGS.fm.c= -Wno-cast-qual
442 CFLAGS.hist.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
443 CFLAGS.lapi.c= -Wno-cast-qual
444 CFLAGS.lcompat.c= -Wno-cast-qual
445 CFLAGS.ldo.c= ${NO_WINFINITE_RECURSION}
446 CFLAGS.lobject.c= -Wno-cast-qual
447 CFLAGS.ltable.c= -Wno-cast-qual
448 CFLAGS.lvm.c= -Wno-cast-qual
449 CFLAGS.lz4.c= -Wno-cast-qual
450 CFLAGS.lz4_zfs.c= -Wno-cast-qual
451 CFLAGS.nvpair.c= -Wno-cast-qual -DHAVE_RPC_TYPES ${NO_WSTRINGOP_OVERREAD}
452 CFLAGS.pool.c+= ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
453 CFLAGS.pool.c= -U__BMI__ -fno-tree-vectorize
454 CFLAGS.spa.c= -Wno-cast-qual
455 CFLAGS.spa_misc.c= -Wno-cast-qual
456 CFLAGS.spl_string.c= -Wno-cast-qual
457 CFLAGS.spl_vm.c= -Wno-cast-qual
458 CFLAGS.spl_zlib.c= -Wno-cast-qual
459 CFLAGS.u8_textprep.c= -Wno-cast-qual
460 CFLAGS.vdev_draid.c= -Wno-cast-qual
461 CFLAGS.vdev_raidz.c= -Wno-cast-qual
462 CFLAGS.vdev_raidz_math.c= -Wno-cast-qual
463 CFLAGS.vdev_raidz_math_avx2.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
464 CFLAGS.vdev_raidz_math_avx512f.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
465 CFLAGS.vdev_raidz_math_scalar.c= -Wno-cast-qual
466 CFLAGS.vdev_raidz_math_sse2.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
467 CFLAGS.zap_leaf.c= -Wno-cast-qual
468 CFLAGS.zap_micro.c= -Wno-cast-qual
469 CFLAGS.zcp.c= -Wno-cast-qual
470 CFLAGS.zfs_fletcher.c= -Wno-cast-qual -Wno-pointer-arith
471 CFLAGS.zfs_fletcher_avx512.c= -Wno-cast-qual -Wno-pointer-arith
472 CFLAGS.zfs_fletcher_intel.c= -Wno-cast-qual -Wno-pointer-arith
473 CFLAGS.zfs_fletcher_sse.c= -Wno-cast-qual -Wno-pointer-arith
474 CFLAGS.zfs_fm.c= -Wno-cast-qual ${NO_WUNUSED_BUT_SET_VARIABLE}
475 CFLAGS.zfs_ioctl.c= -Wno-cast-qual
476 CFLAGS.zfs_log.c= -Wno-cast-qual
477 CFLAGS.zfs_vnops_os.c= -Wno-pointer-arith
478 CFLAGS.zfs_zstd.c= -Wno-cast-qual -Wno-pointer-arith
479 CFLAGS.zil.c= -Wno-cast-qual
480 CFLAGS.zio.c= -Wno-cast-qual
481 CFLAGS.zprop_common.c= -Wno-cast-qual
482 CFLAGS.zrlock.c= -Wno-cast-qual
485 CFLAGS.entropy_common.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
486 CFLAGS.error_private.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
487 CFLAGS.fse_compress.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL} ${NO_WUNUSED_BUT_SET_VARIABLE}
488 CFLAGS.fse_decompress.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
489 CFLAGS.huf_compress.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
490 CFLAGS.huf_decompress.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
491 CFLAGS.xxhash.c+= -U__BMI__ -fno-tree-vectorize
492 CFLAGS.xxhash.c+= ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
493 CFLAGS.zstd.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
494 CFLAGS.zstd_common.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
495 CFLAGS.zstd_compress.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
496 CFLAGS.zstd_compress_literals.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
497 CFLAGS.zstd_compress_sequences.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
498 CFLAGS.zstd_compress_superblock.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL} ${NO_WUNUSED_BUT_SET_VARIABLE}
499 CFLAGS.zstd_ddict.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
500 CFLAGS.zstd_decompress.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
501 CFLAGS.zstd_decompress_block.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
502 CFLAGS.zstd_double_fast.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
503 CFLAGS.zstd_fast.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
504 CFLAGS.zstd_lazy.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
505 CFLAGS.zstd_ldm.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
506 CFLAGS.zstd_opt.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
508 .if ${MACHINE_CPUARCH} == "aarch64"
509 __ZFS_ZSTD_AARCH64_FLAGS= -include ${SRCDIR}/zstd/include/aarch64_compat.h
510 CFLAGS.zstd.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
511 CFLAGS.entropy_common.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
512 CFLAGS.error_private.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
513 CFLAGS.fse_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
514 CFLAGS.fse_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
515 CFLAGS.hist.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
516 CFLAGS.huf_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
517 CFLAGS.huf_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
518 CFLAGS.pool.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
519 CFLAGS.xxhash.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
520 CFLAGS.zstd_common.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
521 CFLAGS.zstd_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
522 CFLAGS.zstd_compress_literals.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
523 CFLAGS.zstd_compress_sequences.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
524 CFLAGS.zstd_compress_superblock.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
525 CFLAGS.zstd_ddict.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
526 CFLAGS.zstd_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
527 CFLAGS.zstd_decompress_block.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
528 CFLAGS.zstd_double_fast.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
529 CFLAGS.zstd_fast.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
530 CFLAGS.zstd_lazy.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
531 CFLAGS.zstd_ldm.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
532 CFLAGS.zstd_opt.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
534 sha256-armv8.o: sha256-armv8.S
535 ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC} \
539 sha512-armv8.o: sha512-armv8.S
540 ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC} \
544 b3_aarch64_sse2.o: b3_aarch64_sse2.S
545 ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC} \
549 b3_aarch64_sse41.o: b3_aarch64_sse41.S
550 ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC} \