50
50
# - Replacing generated files with files committed to the tree. This is special
51
51
# case of moving from one directory to another. The stale generated file also
52
52
# needs to be deleted, so that it isn't found in make's .PATH. Note the
53
- # unconditional `rm -f `: there's no need for an extra call to first check for
53
+ # unconditional `rm -fv `: there's no need for an extra call to first check for
54
54
# the file's existence.
55
55
#
56
56
# # 20250110 3863fec1ce2d add strlen SIMD implementation
57
57
# clean_dep lib/libc strlen S arm-optimized-routines
58
- # run rm -f "$OBJTOP"/lib/libc/strlen.S
58
+ # run rm -fv "$OBJTOP"/lib/libc/strlen.S
59
59
#
60
60
# A rule may be required for only one architecture:
61
61
#
@@ -152,6 +152,11 @@ run()
152
152
fi
153
153
}
154
154
155
+ # Clean the depend and object files for a given source file if the
156
+ # depend file matches a regex (which defaults to the source file
157
+ # name). This is typically used if a file was renamed, especially if
158
+ # only its extension was changed (e.g. from .c to .cc).
159
+ #
155
160
# $1 directory
156
161
# $2 source filename w/o extension
157
162
# $3 source extension
@@ -162,13 +167,34 @@ clean_dep()
162
167
dirprfx=${libcompat: +obj-lib${libcompat} / }
163
168
if egrep -qw " ${4:- $2 \. $3 } " " $OBJTOP " /$dirprfx $1 /.depend.$2 .* o 2> /dev/null; then
164
169
echo " Removing stale ${libcompat: +lib${libcompat} } dependencies and objects for $2 .$3 "
165
- run rm -f \
170
+ run rm -fv \
166
171
" $OBJTOP " /$dirprfx $1 /.depend.$2 .* \
167
172
" $OBJTOP " /$dirprfx $1 /$2 .* o
168
173
fi
169
174
done
170
175
}
171
176
177
+ # Clean the object file for a given source file if it exists and
178
+ # matches a regex. This is typically used if a a change in CFLAGS or
179
+ # similar caused a change in the generated code without a change in
180
+ # the sources.
181
+ #
182
+ # $1 directory
183
+ # $2 source filename w/o extension
184
+ # $3 source extension
185
+ # $4 regex for egrep -w
186
+ clean_obj ()
187
+ {
188
+ for libcompat in " " $ALL_libcompats ; do
189
+ dirprfx=${libcompat: +obj-lib${libcompat} / }
190
+ if strings " $OBJTOP " /$dirprfx $1 /$2 .* o 2> /dev/null | egrep -qw " ${4} " ; then
191
+ echo " Removing stale ${libcompat: +lib${libcompat} } objects for $2 .$3 "
192
+ run rm -fv \
193
+ " $OBJTOP " /$dirprfx $1 /$2 .* o
194
+ fi
195
+ done
196
+ }
197
+
172
198
extract_epoch ()
173
199
{
174
200
[ -s " $1 " ] || return 0
243
269
if stat " $OBJTOP " /tests/sys/kqueue/libkqueue/* kqtest* \
244
270
" $OBJTOP " /tests/sys/kqueue/libkqueue/.depend.kqtest* > /dev/null 2>&1 ; then
245
271
echo " Removing old kqtest"
246
- run rm -f " $OBJTOP " /tests/sys/kqueue/libkqueue/.depend.* \
272
+ run rm -fv " $OBJTOP " /tests/sys/kqueue/libkqueue/.depend.* \
247
273
" $OBJTOP " /tests/sys/kqueue/libkqueue/*
248
274
fi
249
275
317
343
if [ -f " $OBJTOP " /rescue/rescue/rescue.mk ] && \
318
344
! grep -q ' nvme_util.o' " $OBJTOP " /rescue/rescue/rescue.mk; then
319
345
echo " removing rescue.mk without nvme_util.o"
320
- run rm -f " $OBJTOP " /rescue/rescue/rescue.mk
346
+ run rm -fv " $OBJTOP " /rescue/rescue/rescue.mk
321
347
fi
322
348
323
349
# 20240910 e2df9bb44109
@@ -337,7 +363,7 @@ if [ ${MACHINE} = riscv ]; then
337
363
fi
338
364
if ! grep -q ' lib/libc/csu/riscv/reloc\.c' " $f " ; then
339
365
echo " Removing stale dependencies and objects for libc_start1.c"
340
- run rm -f \
366
+ run rm -fv \
341
367
" $OBJTOP " /lib/libc/.depend.libc_start1.* \
342
368
" $OBJTOP " /lib/libc/libc_start1.* o
343
369
break
@@ -351,28 +377,28 @@ f="$p"/arm_mve_builtin_sema.inc
351
377
if [ -e " $f " ]; then
352
378
if grep -q SemaBuiltinConstantArgRange " $f " ; then
353
379
echo " Removing pre-llvm19 clang-tblgen output"
354
- run rm -f " $p " /* .inc
380
+ run rm -fv " $p " /* .inc
355
381
fi
356
382
fi
357
383
358
384
# 20241025 cb5e41b16083 Unbundle hash functions fom lib/libcrypt
359
- clean_dep lib/libcrypt crypt-md5 c
360
- clean_dep lib/libcrypt crypt-nthash c
361
- clean_dep lib/libcrypt crypt-sha256 c
362
- clean_dep lib/libcrypt crypt-sha512 c
385
+ clean_obj lib/libcrypt crypt-md5 c __MD5Init
386
+ clean_obj lib/libcrypt crypt-nthash c __MD4Init
387
+ clean_obj lib/libcrypt crypt-sha256 c __SHA256Init
388
+ clean_obj lib/libcrypt crypt-sha512 c __SHA512Init
363
389
364
390
# 20241213 b55f5e1c4ae3 jemalloc: Move generated jemalloc.3 into lib/libc tree
365
391
if [ -h " $OBJTOP " /lib/libc/jemalloc.3 ]; then
366
392
# Have to cleanup the jemalloc.3 in the obj tree since make gets
367
393
# confused and won't use the one in lib/libc/malloc/jemalloc/jemalloc.3
368
394
echo " Removing stale jemalloc.3 object"
369
- run rm -f " $OBJTOP " /lib/libc/jemalloc.3
395
+ run rm -fv " $OBJTOP " /lib/libc/jemalloc.3
370
396
fi
371
397
372
398
if [ $MACHINE_ARCH = aarch64 ]; then
373
399
# 20250110 5e7d93a60440 add strcmp SIMD implementation
374
400
ALL_libcompats= clean_dep lib/libc strcmp S arm-optimized-routines
375
- run rm -f " $OBJTOP " /lib/libc/strcmp.S
401
+ run rm -fv " $OBJTOP " /lib/libc/strcmp.S
376
402
377
403
# 20250110 b91003acffe7 add strspn optimized implementation
378
404
ALL_libcompats= clean_dep lib/libc strspn c
@@ -391,7 +417,7 @@ if [ $MACHINE_ARCH = aarch64 ]; then
391
417
392
418
# 20250110 25c485e14769 add strncmp SIMD implementation
393
419
ALL_libcompats= clean_dep lib/libc strncmp S arm-optimized-routines
394
- run rm -f " $OBJTOP " /lib/libc/strncmp.S
420
+ run rm -fv " $OBJTOP " /lib/libc/strncmp.S
395
421
396
422
# 20250110 bad17991c06d add memccpy SIMD implementation
397
423
ALL_libcompats= clean_dep lib/libc memccpy c
@@ -402,11 +428,11 @@ if [ $MACHINE_ARCH = aarch64 ]; then
402
428
# 20250110 bea89d038ac5 add strlcat SIMD implementation, and move memchr
403
429
ALL_libcompats= clean_dep lib/libc strlcat c " libc.string.strlcat.c"
404
430
ALL_libcompats= clean_dep lib/libc memchr S " [[:space:]]memchr.S"
405
- run rm -f " $OBJTOP " /lib/libc/memchr.S
431
+ run rm -fv " $OBJTOP " /lib/libc/memchr.S
406
432
407
433
# 20250110 3863fec1ce2d add strlen SIMD implementation
408
434
ALL_libcompats= clean_dep lib/libc strlen S arm-optimized-routines
409
- run rm -f " $OBJTOP " /lib/libc/strlen.S
435
+ run rm -fv " $OBJTOP " /lib/libc/strlen.S
410
436
411
437
# 20250110 79e01e7e643c add bcopy & bzero wrapper
412
438
ALL_libcompats= clean_dep lib/libc bcopy c " libc.string.bcopy.c"
@@ -431,15 +457,15 @@ clean_dep usr.sbin/ctld uclparse c
431
457
# 20250425 2e47f35be5dc libllvm, libclang and liblldb became shared libraries
432
458
if [ -f " $OBJTOP " /lib/clang/libllvm/libllvm.a ]; then
433
459
echo " Removing old static libllvm library"
434
- run rm -f " $OBJTOP " /lib/clang/libllvm/libllvm.a
460
+ run rm -fv " $OBJTOP " /lib/clang/libllvm/libllvm.a
435
461
fi
436
462
if [ -f " $OBJTOP " /lib/clang/libclang/libclang.a ]; then
437
463
echo " Removing old static libclang library"
438
- run rm -f " $OBJTOP " /lib/clang/libclang/libclang.a
464
+ run rm -fv " $OBJTOP " /lib/clang/libclang/libclang.a
439
465
fi
440
466
if [ -f " $OBJTOP " /lib/clang/liblldb/liblldb.a ]; then
441
467
echo " Removing old static liblldb library"
442
- run rm -f " $OBJTOP " /lib/clang/liblldb/liblldb.a
468
+ run rm -fv " $OBJTOP " /lib/clang/liblldb/liblldb.a
443
469
fi
444
470
445
471
# 20250813 4f766afc1ca0 tcopy converted to C++
0 commit comments