Fix userspace memory leaks found by Clang Static Analzyer
[zfs.git] / module / Makefile.bsd
blob8829ad9421306d4ce34843f18b553ddf6b8c1981
1 .if !defined(WITH_CTF)
2 WITH_CTF=1
3 .endif
5 .include <bsd.sys.mk>
7 SRCDIR=${.CURDIR}
8 INCDIR=${.CURDIR:H}/include
10 KMOD=   openzfs
12 .PATH:  ${SRCDIR}/avl \
13         ${SRCDIR}/icp/algs/blake3 \
14         ${SRCDIR}/icp/asm-aarch64/blake3 \
15         ${SRCDIR}/icp/asm-ppc64/blake3 \
16         ${SRCDIR}/icp/asm-x86_64/blake3 \
17         ${SRCDIR}/lua \
18         ${SRCDIR}/nvpair \
19         ${SRCDIR}/icp/algs/edonr \
20         ${SRCDIR}/os/freebsd/spl \
21         ${SRCDIR}/os/freebsd/zfs \
22         ${SRCDIR}/unicode \
23         ${SRCDIR}/zcommon \
24         ${SRCDIR}/zfs \
25         ${SRCDIR}/zstd \
26         ${SRCDIR}/zstd/lib/common \
27         ${SRCDIR}/zstd/lib/compress \
28         ${SRCDIR}/zstd/lib/decompress
32 CFLAGS+= -I${.OBJDIR:H}/include
33 CFLAGS+= -I${INCDIR}
34 CFLAGS+= -I${INCDIR}/os/freebsd
35 CFLAGS+= -I${INCDIR}/os/freebsd/spl
36 CFLAGS+= -I${INCDIR}/os/freebsd/zfs
37 CFLAGS+= -I${SRCDIR}/zstd/include
38 CFLAGS+= -I${SRCDIR}/icp/include
39 CFLAGS+= -include ${INCDIR}/os/freebsd/spl/sys/ccompile.h
41 CFLAGS+= -D__KERNEL__ -DFREEBSD_NAMECACHE -DBUILDING_ZFS  -D__BSD_VISIBLE=1 \
42          -DHAVE_UIO_ZEROCOPY -DWITHOUT_NETDUMP -D__KERNEL -D_SYS_CONDVAR_H_ \
43          -D_SYS_VMEM_H_ -DKDTRACE_HOOKS -DSMP -DCOMPAT_FREEBSD11
45 .if ${MACHINE_ARCH} == "amd64"
46 CFLAGS+= -D__x86_64 -DHAVE_SSE2 -DHAVE_SSSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2 \
47          -DHAVE_AVX -DHAVE_AVX2 -DHAVE_AVX512F -DHAVE_AVX512VL
48 .endif
50 .if defined(WITH_DEBUG) && ${WITH_DEBUG} == "true"
51 CFLAGS+= -DZFS_DEBUG -g
52 .if defined(WITH_INVARIANTS) && ${WITH_INVARIANTS} == "true"
53  CFLAGS+= -DINVARIANTS -DWITNESS -DOPENSOLARIS_WITNESS
54 .endif
55 .if defined(WITH_O0) && ${WITH_O0} == "true"
56  CFLAGS+= -O0
57 .endif
58 .else
59 CFLAGS += -DNDEBUG
60 .endif
62 .if defined(WITH_VFS_DEBUG) && ${WITH_VFS_DEBUG} == "true"
63 # kernel must also be built with this option for this to work
64 CFLAGS+= -DDEBUG_VFS_LOCKS
65 .endif
67 .if defined(WITH_GCOV) && ${WITH_GCOV} == "true"
68 CFLAGS+=         -fprofile-arcs -ftest-coverage
69 .endif
71 DEBUG_FLAGS=-g
73 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
74         ${MACHINE_ARCH} == "arm"
75 CFLAGS+= -DBITS_PER_LONG=32
76 .else
77 CFLAGS+= -DBITS_PER_LONG=64
78 .endif
80 SRCS=   vnode_if.h device_if.h bus_if.h
82 #avl
83 SRCS+=  avl.c
85 # icp
86 SRCS+=  edonr.c
88 #icp/algs/blake3
89 SRCS+=  blake3.c \
90         blake3_generic.c \
91         blake3_impl.c \
92         blake3_x86-64.c
94 #icp/asm-aarch64/blake3
95 SRCS+=  b3_aarch64_sse2.S \
96         b3_aarch64_sse41.S
98 #icp/asm-ppc64/blake3
99 SRCS+=  b3_ppc64le_sse2.S \
100         b3_ppc64le_sse41.S
102 #icp/asm-x86_64/blake3
103 SRCS+=  blake3_avx2.S \
104         blake3_avx512.S \
105         blake3_sse2.S \
106         blake3_sse41.S
108 #lua
109 SRCS+=  lapi.c \
110         lauxlib.c \
111         lbaselib.c \
112         lcode.c \
113         lcompat.c \
114         lcorolib.c \
115         lctype.c \
116         ldebug.c \
117         ldo.c \
118         lfunc.c \
119         lgc.c \
120         llex.c \
121         lmem.c \
122         lobject.c \
123         lopcodes.c \
124         lparser.c \
125         lstate.c \
126         lstring.c \
127         lstrlib.c \
128         ltable.c \
129         ltablib.c \
130         ltm.c \
131         lvm.c \
132         lzio.c
134 #nvpair
135 SRCS+=  nvpair.c \
136         fnvpair.c \
137         nvpair_alloc_spl.c \
138         nvpair_alloc_fixed.c
140 #os/freebsd/spl
141 SRCS+=  acl_common.c \
142         callb.c \
143         list.c \
144         sha256c.c \
145         sha512c.c \
146         spl_acl.c \
147         spl_cmn_err.c \
148         spl_dtrace.c \
149         spl_kmem.c \
150         spl_kstat.c \
151         spl_misc.c \
152         spl_policy.c \
153         spl_procfs_list.c \
154         spl_string.c \
155         spl_sunddi.c \
156         spl_sysevent.c \
157         spl_taskq.c \
158         spl_uio.c \
159         spl_vfs.c \
160         spl_vm.c \
161         spl_zlib.c \
162         spl_zone.c
165 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
166         ${MACHINE_ARCH} == "arm"
167 SRCS+= spl_atomic.c
168 .endif
170 #os/freebsd/zfs
171 SRCS+=  abd_os.c \
172         arc_os.c \
173         crypto_os.c \
174         dmu_os.c \
175         event_os.c \
176         hkdf.c \
177         kmod_core.c \
178         spa_os.c \
179         sysctl_os.c \
180         vdev_file.c \
181         vdev_geom.c \
182         vdev_label_os.c \
183         zfs_acl.c \
184         zfs_ctldir.c \
185         zfs_debug.c \
186         zfs_dir.c \
187         zfs_ioctl_compat.c \
188         zfs_ioctl_os.c \
189         zfs_racct.c \
190         zfs_vfsops.c \
191         zfs_vnops_os.c \
192         zfs_znode.c \
193         zio_crypt.c \
194         zvol_os.c
196 #unicode
197 SRCS+=  uconv.c \
198         u8_textprep.c
200 #zcommon
201 SRCS+=  zfeature_common.c \
202         zfs_comutil.c \
203         zfs_deleg.c \
204         zfs_fletcher.c \
205         zfs_fletcher_avx512.c \
206         zfs_fletcher_intel.c \
207         zfs_fletcher_sse.c \
208         zfs_fletcher_superscalar.c \
209         zfs_fletcher_superscalar4.c \
210         zfs_namecheck.c \
211         zfs_prop.c \
212         zpool_prop.c \
213         zprop_common.c
215 #zfs
216 SRCS+=  abd.c \
217         aggsum.c \
218         arc.c \
219         blake3_zfs.c \
220         blkptr.c \
221         bplist.c \
222         bpobj.c \
223         btree.c \
224         cityhash.c \
225         dbuf.c \
226         dbuf_stats.c \
227         bptree.c \
228         bqueue.c \
229         dataset_kstats.c \
230         ddt.c \
231         ddt_zap.c \
232         dmu.c \
233         dmu_diff.c \
234         dmu_object.c \
235         dmu_objset.c \
236         dmu_recv.c \
237         dmu_redact.c \
238         dmu_send.c \
239         dmu_traverse.c \
240         dmu_tx.c \
241         dmu_zfetch.c \
242         dnode.c \
243         dnode_sync.c \
244         dsl_dataset.c \
245         dsl_deadlist.c \
246         dsl_deleg.c \
247         dsl_bookmark.c \
248         dsl_dir.c \
249         dsl_crypt.c \
250         dsl_destroy.c \
251         dsl_pool.c \
252         dsl_prop.c \
253         dsl_scan.c \
254         dsl_synctask.c \
255         dsl_userhold.c \
256         edonr_zfs.c \
257         fm.c \
258         gzip.c \
259         lzjb.c \
260         lz4.c \
261         lz4_zfs.c \
262         metaslab.c \
263         mmp.c \
264         multilist.c \
265         objlist.c \
266         pathname.c \
267         range_tree.c \
268         refcount.c \
269         rrwlock.c \
270         sa.c \
271         sha256.c \
272         skein_zfs.c \
273         spa.c \
274         spa_checkpoint.c \
275         spa_config.c \
276         spa_errlog.c \
277         spa_history.c \
278         spa_log_spacemap.c \
279         spa_misc.c \
280         spa_stats.c \
281         space_map.c \
282         space_reftree.c \
283         txg.c \
284         uberblock.c \
285         unique.c \
286         vdev.c \
287         vdev_cache.c \
288         vdev_draid.c \
289         vdev_draid_rand.c \
290         vdev_indirect.c \
291         vdev_indirect_births.c \
292         vdev_indirect_mapping.c \
293         vdev_initialize.c \
294         vdev_label.c \
295         vdev_mirror.c \
296         vdev_missing.c \
297         vdev_queue.c \
298         vdev_raidz.c \
299         vdev_raidz_math.c \
300         vdev_raidz_math_scalar.c \
301         vdev_raidz_math_avx2.c \
302         vdev_raidz_math_avx512bw.c \
303         vdev_raidz_math_avx512f.c \
304         vdev_raidz_math_sse2.c \
305         vdev_raidz_math_ssse3.c \
306         vdev_rebuild.c \
307         vdev_removal.c \
308         vdev_root.c \
309         vdev_trim.c \
310         zap.c \
311         zap_leaf.c \
312         zap_micro.c \
313         zcp.c \
314         zcp_get.c \
315         zcp_global.c \
316         zcp_iter.c \
317         zcp_set.c \
318         zcp_synctask.c \
319         zfeature.c \
320         zfs_byteswap.c \
321         zfs_chksum.c \
322         zfs_file_os.c \
323         zfs_fm.c \
324         zfs_fuid.c \
325         zfs_ioctl.c \
326         zfs_log.c \
327         zfs_onexit.c \
328         zfs_quota.c \
329         zfs_ratelimit.c \
330         zfs_replay.c \
331         zfs_rlock.c \
332         zfs_sa.c \
333         zfs_vnops.c \
334         zil.c \
335         zio.c \
336         zio_checksum.c \
337         zio_compress.c \
338         zio_inject.c \
339         zle.c \
340         zrlock.c \
341         zthr.c \
342         zvol.c
344 #zstd
345 SRCS+=  zfs_zstd.c \
346         entropy_common.c \
347         error_private.c \
348         fse_decompress.c \
349         pool.c \
350         zstd_common.c \
351         fse_compress.c \
352         hist.c \
353         huf_compress.c \
354         zstd_compress.c \
355         zstd_compress_literals.c \
356         zstd_compress_sequences.c \
357         zstd_compress_superblock.c \
358         zstd_double_fast.c \
359         zstd_fast.c \
360         zstd_lazy.c \
361         zstd_ldm.c \
362         zstd_opt.c \
363         huf_decompress.c \
364         zstd_ddict.c \
365         zstd_decompress.c \
366         zstd_decompress_block.c
368 beforeinstall:
369 .if ${MK_DEBUG_FILES} != "no"
370         mtree -eu \
371             -f /etc/mtree/BSD.debug.dist \
372             -p ${DESTDIR}/usr/lib
373 .endif
375 .include <bsd.kmod.mk>
378 CFLAGS.gcc+= -Wno-pointer-to-int-cast
380 CFLAGS.lapi.c= -Wno-cast-qual
381 CFLAGS.lcompat.c= -Wno-cast-qual
382 CFLAGS.lobject.c= -Wno-cast-qual
383 CFLAGS.ltable.c= -Wno-cast-qual
384 CFLAGS.lvm.c= -Wno-cast-qual
385 CFLAGS.nvpair.c= -DHAVE_RPC_TYPES -Wno-cast-qual
386 CFLAGS.spl_string.c= -Wno-cast-qual
387 CFLAGS.spl_vm.c= -Wno-cast-qual
388 CFLAGS.spl_zlib.c= -Wno-cast-qual
389 CFLAGS.abd.c= -Wno-cast-qual
390 CFLAGS.zfs_log.c= -Wno-cast-qual
391 CFLAGS.zfs_vnops_os.c= -Wno-pointer-arith
392 CFLAGS.u8_textprep.c= -Wno-cast-qual
393 CFLAGS.zfs_fletcher.c= -Wno-cast-qual -Wno-pointer-arith
394 CFLAGS.zfs_fletcher_intel.c= -Wno-cast-qual -Wno-pointer-arith
395 CFLAGS.zfs_fletcher_sse.c= -Wno-cast-qual -Wno-pointer-arith
396 CFLAGS.zfs_fletcher_avx512.c= -Wno-cast-qual -Wno-pointer-arith
397 CFLAGS.zprop_common.c= -Wno-cast-qual
398 CFLAGS.ddt.c= -Wno-cast-qual
399 CFLAGS.dmu.c= -Wno-cast-qual
400 CFLAGS.dmu_traverse.c= -Wno-cast-qual
401 CFLAGS.dsl_dir.c= -Wno-cast-qual
402 CFLAGS.dsl_deadlist.c= -Wno-cast-qual
403 CFLAGS.dsl_prop.c= -Wno-cast-qual
404 CFLAGS.edonr.c=-Wno-cast-qual
405 CFLAGS.fm.c= -Wno-cast-qual
406 CFLAGS.lz4_zfs.c= -Wno-cast-qual
407 CFLAGS.spa.c= -Wno-cast-qual
408 CFLAGS.spa_misc.c= -Wno-cast-qual
409 CFLAGS.sysctl_os.c= -include ../zfs_config.h
410 CFLAGS.vdev_draid.c= -Wno-cast-qual
411 CFLAGS.vdev_raidz.c= -Wno-cast-qual
412 CFLAGS.vdev_raidz_math.c= -Wno-cast-qual
413 CFLAGS.vdev_raidz_math_scalar.c= -Wno-cast-qual
414 CFLAGS.vdev_raidz_math_avx2.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
415 CFLAGS.vdev_raidz_math_avx512f.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
416 CFLAGS.vdev_raidz_math_sse2.c= -Wno-cast-qual -Wno-duplicate-decl-specifier
417 CFLAGS.zap_leaf.c= -Wno-cast-qual
418 CFLAGS.zap_micro.c= -Wno-cast-qual
419 CFLAGS.zcp.c= -Wno-cast-qual
420 CFLAGS.zfs_fm.c= -Wno-cast-qual
421 CFLAGS.zfs_ioctl.c= -Wno-cast-qual
422 CFLAGS.zil.c= -Wno-cast-qual
423 CFLAGS.zio.c= -Wno-cast-qual
424 CFLAGS.zrlock.c= -Wno-cast-qual
425 CFLAGS.zfs_zstd.c= -Wno-cast-qual -Wno-pointer-arith
426 CFLAGS.entropy_common.c= -fno-tree-vectorize -U__BMI__
427 CFLAGS.error_private.c= -fno-tree-vectorize -U__BMI__
428 CFLAGS.fse_decompress.c= -fno-tree-vectorize -U__BMI__
429 CFLAGS.pool.c= -fno-tree-vectorize -U__BMI__
430 CFLAGS.xxhash.c= -fno-tree-vectorize -U__BMI__
431 CFLAGS.zstd_common.c= -fno-tree-vectorize -U__BMI__
432 CFLAGS.fse_compress.c= -fno-tree-vectorize -U__BMI__
433 CFLAGS.hist.c= -fno-tree-vectorize -U__BMI__
434 CFLAGS.huf_compress.c= -fno-tree-vectorize -U__BMI__
435 CFLAGS.zstd_compress.c= -fno-tree-vectorize -U__BMI__
436 CFLAGS.zstd_compress_literals.c= -fno-tree-vectorize -U__BMI__
437 CFLAGS.zstd_compress_sequences.c= -fno-tree-vectorize -U__BMI__
438 CFLAGS.zstd_compress_superblock.c= -fno-tree-vectorize -U__BMI__
439 CFLAGS.zstd_double_fast.c= -fno-tree-vectorize -U__BMI__
440 CFLAGS.zstd_fast.c= -fno-tree-vectorize -U__BMI__
441 CFLAGS.zstd_lazy.c= -fno-tree-vectorize -U__BMI__
442 CFLAGS.zstd_ldm.c= -fno-tree-vectorize -U__BMI__
443 CFLAGS.zstd_opt.c= -fno-tree-vectorize -U__BMI__
444 CFLAGS.huf_decompress.c= -fno-tree-vectorize -U__BMI__
445 CFLAGS.zstd_ddict.c= -fno-tree-vectorize -U__BMI__
446 CFLAGS.zstd_decompress.c= -fno-tree-vectorize -U__BMI__
447 CFLAGS.zstd_decompress_block.c= -fno-tree-vectorize -U__BMI__